0% found this document useful (0 votes)
73 views6 pages

Batch Input With 'Call Transaction' - Sample ABAP Program Code

This ABAP program demonstrates how to call a transaction using batch input and retrieve error messages. It builds a BDCDATA table to input fields for transaction FI01. When the transaction is called, it retrieves the error message text from table T100 using the system fields SY-MSGID, SY-MSGNO and concatenates any parameters from SY-MSGV1-4. The message is output along with the system field values.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views6 pages

Batch Input With 'Call Transaction' - Sample ABAP Program Code

This ABAP program demonstrates how to call a transaction using batch input and retrieve error messages. It builds a BDCDATA table to input fields for transaction FI01. When the transaction is called, it retrieves the error message text from table T100 using the system fields SY-MSGID, SY-MSGNO and concatenates any parameters from SY-MSGV1-4. The message is output along with the system field values.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Batch Input with 'Call Transaction' - Sample ABAP program Code about:reader?url=http://sapbrainsonline.com/abap-tutorial/codes/batch-in...

sapbrainsonline.com

Batch Input with 'Call Transaction' -


Sample ABAP program Code
Requirement:

Choose a transaction and write a Batch Input program with ‘Call


Transaction’. Do not use the Message tab feature of ‘Call
Transaction’. In this case the last error message will be at the
SY-MSG* system fields. Recreate the complete error message from
table T100! (This example is also used by the demonstration of
SY-MSG* system fields)

Solution:

REPORT ZSYSTEM LINE-SIZE 255.


TABLES: T100.
* Batch-input data
DATA: BEGIN OF G_BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF G_BDCDATA.

DATA: G_MESSAGE(200).

PERFORM FILL_BDCDATA.
CALL TRANSACTION ‘FI01’ USING G_BDCDATA MODE ‘N’.

1 of 6 8/22/2016 10:09 PM
Batch Input with 'Call Transaction' - Sample ABAP program Code about:reader?url=http://sapbrainsonline.com/abap-tutorial/codes/batch-in...

* of course it is nicer with a message itab, but this example


* should also demostrate the use of system variables.
SELECT SINGLE * FROM T100 WHERE
SPRSL = ‘E’
AND ARBGB = SY-MSGID
AND MSGNR = SY-MSGNO.
G_MESSAGE = T100-TEXT.

PERFORM REPLACE_PARAMETERS USING SY-MSGV1


SY-MSGV2
SY-MSGV3
SY-MSGV4
CHANGING G_MESSAGE.

WRITE: / ‘System variables:’.


SKIP.
WRITE: / ‘ Sy-msgty:’, SY-MSGTY.
WRITE: / ‘ Sy-msgid:’, SY-MSGID.
WRITE: / ‘ Sy-msgno:’, SY-MSGNO.
WRITE: / ‘ Sy-msgv1:’, SY-MSGV1.
WRITE: / ‘ Sy-msgv2:’, SY-MSGV2.
WRITE: / ‘ Sy-msgv3:’, SY-MSGV3.
WRITE: / ‘ Sy-msgv4:’, SY-MSGV4.
SKIP.
WRITE: / ‘The transaction was called with a wrong country code.’.
WRITE: / ‘The error message should be either that or that you
have’.
WRITE: / ‘ no authorisation to execute the transaction’.
SKIP.
WRITE: / ‘Message:’.

2 of 6 8/22/2016 10:09 PM
Batch Input with 'Call Transaction' - Sample ABAP program Code about:reader?url=http://sapbrainsonline.com/abap-tutorial/codes/batch-in...

SKIP.
WRITE: / SY-MSGTY, G_MESSAGE.

*———————————————————————*
* Build up the BDC-table *
*———————————————————————*
FORM FILL_BDCDATA.
REFRESH G_BDCDATA.

PERFORM BDC_DYNPRO USING ‘SAPMF02B’ ‘0100’.


PERFORM BDC_FIELD USING ‘BNKA-BANKS’ ‘ZZZ’.
PERFORM BDC_FIELD USING ‘BDC_OKCODE’ ‘QQQQQ’.

ENDFORM.

*———————————————————————*
* FORM BDC_DYNPRO *
*———————————————————————*
* Batchinput: Start new Dynpro *
*———————————————————————*
FORM BDC_DYNPRO USING P_PROGRAM P_DYNPRO.
CLEAR G_BDCDATA.
G_BDCDATA-PROGRAM = P_PROGRAM.
G_BDCDATA-DYNPRO = P_DYNPRO.
G_BDCDATA-DYNBEGIN = ‘X’.
APPEND G_BDCDATA.
ENDFORM. ” BDC_DYNPRO

*———————————————————————*
* FORM BDC_FIELD *

3 of 6 8/22/2016 10:09 PM
Batch Input with 'Call Transaction' - Sample ABAP program Code about:reader?url=http://sapbrainsonline.com/abap-tutorial/codes/batch-in...

*———————————————————————*
* Batchinput: Feld hinzufugen *
*———————————————————————*
FORM BDC_FIELD USING P_FNAM P_FVAL.
CLEAR G_BDCDATA.
G_BDCDATA-FNAM = P_FNAM.
G_BDCDATA-FVAL = P_FVAL.
APPEND G_BDCDATA.
ENDFORM. ” BDC_FIELD
*———————————————————————*
* FORM REPLACE_PARAMETERS *
*———————————————————————*
* …….. *
*———————————————————————*
* –> P_PAR_1 *
* –> P_PAR_2 *
* –> P_PAR_3 *
* –> P_PAR_4 *
* –> P_MESSAGE *
*———————————————————————*
FORM REPLACE_PARAMETERS USING P_PAR_1
P_PAR_2
P_PAR_3
P_PAR_4
CHANGING P_MESSAGE.

* erst mal pruefen, ob numerierte Parameter verwendet wurden


DO.
REPLACE ‘&1’ WITH P_PAR_1 INTO P_MESSAGE.
IF SY-SUBRC <> 0.

4 of 6 8/22/2016 10:09 PM
Batch Input with 'Call Transaction' - Sample ABAP program Code about:reader?url=http://sapbrainsonline.com/abap-tutorial/codes/batch-in...

EXIT.
ENDIF.
ENDDO.
DO.
REPLACE ‘&2’ WITH P_PAR_2 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE ‘&3’ WITH P_PAR_3 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE ‘&4’ WITH P_PAR_4 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
* falls keine numerierten Parameter vorh., ersetzen wie gehabt
REPLACE ‘&’ WITH P_PAR_1 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE ‘&’ WITH P_PAR_2 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE ‘&’ WITH P_PAR_3 INTO P_MESSAGE.
CONDENSE P_MESSAGE.

5 of 6 8/22/2016 10:09 PM
Batch Input with 'Call Transaction' - Sample ABAP program Code about:reader?url=http://sapbrainsonline.com/abap-tutorial/codes/batch-in...

IF SY-SUBRC EQ 0.
REPLACE ‘&’ WITH P_PAR_4 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
ENDIF.
ENDIF.
ENDIF.

ENDFORM. “replace_parameters

Author : Bence Toth

6 of 6 8/22/2016 10:09 PM

You might also like