Tuesday, November 4, 2008

*&---------------------------------------------------------------------*
*& Form SEND_MAIL
*&---------------------------------------------------------------------*
* send email to current user *
*----------------------------------------------------------------------*
FORM SEND_MAIL.

* PARAMETERS FOR SO_NEW_DOCUMENT_SEND_API1
DATA: W_OBJECT_ID LIKE SOODK,
W_SONV_FLAG LIKE SONV-FLAG.
DATA: T_RECEIVERS LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE,
W_OBJECT_CONTENT LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
W_DOC_DATA LIKE SODOCCHGI1 OCCURS 0 WITH HEADER LINE.
*
DATA: W_DATE(10).
CLEAR T_RECEIVERS.
T_RECEIVERS-RECEIVER = SY-UNAME.
T_RECEIVERS-REC_TYPE = 'B'.
T_RECEIVERS-EXPRESS = ' '.
APPEND T_RECEIVERS.

W_DOC_DATA-OBJ_DESCR = 'Change Expiry date'.


* Delivery NO
CONCATENATE 'Delivery No' M_VMVMA-VBELN INTO W_OBJECT_CONTENT
SEPARATED BY ' '.
APPEND W_OBJECT_CONTENT.
* material Batch
CONCATENATE 'Material' ZGREC-MATNR 'Batch' ZGREC-CHARG
INTO W_OBJECT_CONTENT SEPARATED BY ' '.
APPEND W_OBJECT_CONTENT.
* Expiry date
WRITE B_VFDAT TO W_DATE DD/MM/YYYY.
CONCATENATE 'Change expiry date to' W_DATE
INTO W_OBJECT_CONTENT SEPARATED BY ' '.
APPEND W_OBJECT_CONTENT.
*
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = ' '
TABLES
OBJECT_CONTENT = W_OBJECT_CONTENT
RECEIVERS = T_RECEIVERS
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
ENDFORM. " SEND_MAIL

IDocs are structured ASCII files (or a virtual equivalent). They are the file format used by SAP
R/3 to exchange data with foreign systems.

IDocs are simple ASCII data streams. When they are stored to a disk file, the IDocs
are simple flat files with lines of text, where the lines are structured into data fields.
The typical structured file has records, each record starting with a leading string that
identifies the record type. Their specification is stored in the data dictionary.
IDocs is the acronym for Interchange Document. This indicates a set of (electronic)
information which builds a logical entity. An IDoc is e.g. all the data of a single
customer in your customer master data file, or the IDoc is all the data of a single
invoice.

IDoc data is usually exchanged between systems and partners that are completely
independent. Therefore, the data should be transmitted in a format that can easily be
corrected by the computer operators. It is therefore mandatory to post the data in a
human readable form.

Nowadays, this means that data is coded in ASCII format, including numbers which
are sent as a string of figures 0 to 9. Such data can easily be read with any text editor
on any computer, be it a PC, Macintosh, UNIX System, S/390 or any internet
browser.

The information which is exchanged by IDocs is called a message and the IDoc is
the physical representation of such a message. The name “messages” for the
information sent via IDocs is used in the same ways as other EDI standards. .
Everybody who has ever dealt with interface programming, will find IDocs very
much like the hierarchical data files used in traditional data exchange.
International standards like the ODETTE or VDA formats are designed in the same
way as IDocs are.

Other EDI standards like XML, ANSI X.12 or EDIFACT/UN are based on a data
description language. They differ principally from the IDocs concept, because they
use a programming language syntax (e.g. like Postscript or HTML) to embed the
data.


ref: http://saplab.blogspot.com/2008/04/what-are-idocs.html

IDocs are basically a small number of records in ASCII format, building a logical entity. It makes sense to see an IDoc as a plain and simple ASCII text file, even if it might be transported via other means.

Any IDoc consists of two sections:
the control record

which is always the first line of the file and provides the administrative information. the data record

which contains the application dependent data, as in our example below the material master data.

We will discuss the exchange of the material master IDoc MATMAS in the paragraphs that follow..

The definition of the IDoc structure MATMAS01 is deposited in the data dictionary and can be viewed with WE30 .


ref: http://saplab.blogspot.com/2008/04/structure-of-idoc.html

ABAP Code to Creating F1 Help

Go to SE61 and create a general text TX like the one shown below.

  • Select General Text from Document Class
  • Select Language
  • Type Name and press create

createf1help02
Type in what you want to see in output
U1 is for the Bold Text you see in the heading of the F1 Help. If you don’t want to specify a bold text you can just type it in the DOKTITLE in the function module called.
createf1help04
Save the Text. Now Displaying the F1 Help. I have modified an existing program for showing F1 help. See below

*&---------------------------------------------------------------------*
*& Report ZGB_TEST_SEARCH_HELP*
*&---------------------------------------------------------------------*
REPORT ZGB_TEST_SEARCH_HELP .
* INTERNAL TABLE FOR STORING NAMES IN SELECTION LIST
data: begin of t_itab occurs 0,
name(10) type c,
end of t_itab.
*FIELDNAME AND TAB NAME FOR THE SELECTION
DATA :field_tab LIKE dfies OCCURS 0 WITH HEADER LINE.
*THE TABLE FOR RETURNING THE NAME OF THE SELECTED ITEM
DATA : return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE.
*START THE SELECTION SCREEN BLOCK
selection-screen begin of block ss1 with frame.
parameters: p_name1(10) type c.
selection-screen end of block ss1.
*& F4 Help for p_name1
at selection-screen on value-request for p_name1.
*CLEAR ALL EXISTING DATA
*TO BE DONE EVERYTIME F4 HELP IS REQUESTED
REFRESH t_itab.
REFRESH field_tab.
field_tab-fieldname = 'ERNAM'.
field_tab-tabname = 'VBAK'.
APPEND field_tab.
t_itab-name = 'Andrews'.
append t_itab.
t_itab-name = 'Jennie'.
append t_itab.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = field_tab-fieldname
* PVALKEY = ' '
* DYNPPROG = ' '
* DYNPNR = ' '
* DYNPROFIELD = ' '
* STEPL = 0
WINDOW_TITLE = 'Select name'
* VALUE = ' '
* VALUE_ORG = 'C'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* MARK_TAB =
* IMPORTING
* USER_RESET =
tables
value_tab = t_itab
FIELD_TAB = field_tab
RETURN_TAB = return_tab
* DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
p_name1 = return_tab-fieldval.
ENDIF.
*& F1 Help for p_name1 *
at selection-screen on help-request for p_name1.
CALL FUNCTION 'DSYS_SHOW_FOR_F1HELP'
EXPORTING
* APPLICATION = 'SO70'
dokclass = 'TX'
DOKLANGU = SY-LANGU
dokname = 'Z_GAURAB_DEMO'
* DOKTITLE = 'This appears as bold title'
* HOMETEXT = ' '
* OUTLINE = ' '
* VIEWNAME = 'STANDARD'
* Z_ORIGINAL_OUTLINE = ' '
* CALLED_FROM_SO70 = ' '
* SHORT_TEXT = ' '
* APPENDIX = ' '
* IMPORTING
* APPL =
* PF03 =
* PF15 =
* PF12 =
EXCEPTIONS
CLASS_UNKNOWN = 1
OBJECT_NOT_FOUND = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Apart from the FM DSYS_SHOW_FOR_F1HELP,following FM’s can also be used:

  • HELP_OBJECT_SHOW_FOR_FIELD
  • HELP_OBJECT_SHOW

Here is the output:

createf1help06