Conditional Execution
It is possible to set up transactions/BAPIs, screens or fields in order to process them only if a given condition exists. For this, proceed as follows:
Transactions/BAPIs: If you want to execute a transaction only if a given condition is accomplished, then next to the transaction code enter the name of a condition separated by a semicolon. For example:
|
TRANS |
MM01;C1 |
|
|
|
SAPLKMA1 |
0300 |
|
|
|
|
|
BDC_OKCODE |
'/00' |
|
|
|
SGTXT |
NORMAL1 |
| BAPI | BAPI_ABSENCE_CREATE;C1 | ||
| EMPLOYEENUMBER | EMPLOYEENUMBER | ||
| VALIDITYBEGIN | VALIDITYBEGIN | ||
| VALIDITYEND | VALIDITYEND | ||
| ABSENCETYPE | ABSENCETYPE |
Screens: If you want to execute a screen if a given condition is accomplished, then next to the screen code enter the name of a condition separated by a semicolon. For example:
|
TRANS |
MM01 |
|
|
|
SAPLKMA1 |
0300;C2 |
|
|
|
|
|
BDC_OKCODE |
'/00' |
|
|
|
SGTXT |
NORMAL1 |
Fields or OKCODE's: If you want to fill a field or send an OKCODE only if a given condition is accomplished, then next to the field or OKCODE enter the name of a condition separated by semicolon. For example:
|
TRANS |
MM01 |
||
|
SAPLKMA1 |
0300 |
||
|
BDC_OKCODE;C3 |
'/00' |
||
|
SGTXT;C4 |
NORMAL1 |
||
| BAPI | BAPI_ABSENCE_CREATE | ||
| EMPLOYEENUMBER;C5 | EMPLOYEENUMBER | ||
| VALIDITYBEGIN | VALIDITYBEGIN | ||
| VALIDITYEND | VALIDITYEND | ||
| ABSENCETYPE | ABSENCETYPE |
Now define the execution conditions by clicking on the button "Define execution conditions".
Define execution conditions: First add the name of the condition to be defined. Then select the condition from the list and write for that condition the necessary ABAP/4 code to determine if the condition is accomplished (and the transaction, screen or field is to be sent). To refer to an input file/table field (single file or main table) use #field.
If the ABAP/4 code determines that the condition is accomplished, then you must assign YES to the RESULT variable, otherwise the RESULT variable would be NO and it will not be processed. Examples:
Assume the existence of a condition C1, the ABAP/4 code could be the following:
IF #TYPE_MATERIAL = 'RAWMAT'.
RESULT = YES.
ENDIF.
Assume the existence of a condition C2, you wish to process a screen only if material from source file is the old material, the ABAP/4 associated could be the following:
SELECT SINGLE BISMT INTO #MATERIAL FROM MARA WHERE BISMT = #MATERIAL.
IF SY-SUBRC = 0.
RESULT = YES.
ENDIF.
The ABAP/4 code manually entered is not checked and it is the user's responsibility.