Samples
This section provides an Advanced Business Application Programming (ABAP) program sample.
ABAP Program Sample
ABAP is a high level programming language used for developing application for SAP R/3 system.
Following is the sample ABAP Program for INSERTTOKEN function module created in the section Creating a Functional Module.
Section A
Section B
Section C
Section D
Section A in the preceding program consists of comments for the ABAP program. The comment should always start with ‘*&’.
Following two comments represent the TM Java API calls supported by the INSERTTOKEN function module created in SAP:
Section B in the preceding program shows the internal parameter declaration for ABAP program.
Following is the syntax to declare parameters in ABAP:
where, LOWER CASE
indicates the retention of the case (Upper/Lower) provided as in Input.
Section C in the preceding program shows the actual calling of Remote Function Module (RFM) destination through ABAP. While calling RFC, user must enter the exact name and case of the function module and SAPTM_DES as the destination as shown below:
In EXPORTING, user must supply all non-optional import parameters of the function modules with values appropriate to their type.
In IMPORTING, user may receive the export parameters from the function module by assigning them to variables of the appropriate type.
In EXCEPTIONS, allows user to handle the exceptions of function module.
Section D in the preceding program shows the response handling of the function module. The SY-SUBRC
is a return code set by the ABAP program. SY-SUBRC = 0
depicts the function module was executed successfully.
However, if SY-SUBRC = 1
, then the function module has encountered an error of system failure with error message received in variable RFC_MESS
(as per the mapping done in EXCEPTIONS).
If SY-SUBRC = 2
, then the function module has encountered an error of communication failure with error message received in variable RFC_MESS1
(as per the mapping done in EXCEPTIONS).
If SY-SUBRC = 3
, then the function module has encountered an exception during the execution of CT-V API with the error message and status received in SY-MSGID
, SY-MSGTY
, SY-MSGNO
, SY-MSGV1
, SY-MSGV2
.