Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to handle errors in BDC call transaction method with coding...

Former Member
0 Likes
458

Hi,

I had sucessfully uploaded and created materials in trans code 'MM01' using Call Transaction method. Now, I am trying to handle errors in it. I know it can be possible by using 'BDCMSGCOLL'. But, I am unable to write the code to handel those errors. I want to handle errors like...

Msg no: M3307 -


Material already created,

Msg no: M3196 -


Select atleast one view.

My Code is as fallows......

REPORT ZBAT_BDC5.

TABLES: RMMG1.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MBRSH LIKE MARA-MBRSH,

MTART LIKE MARA-MTART,

MAKTX LIKE MAKT-MAKTX,

MEINS LIKE MARA-MEINS,

MTPOS_MARA LIKE MARA-MTPOS_MARA,

END OF ITAB.

DATA: ITAB_ERROR LIKE MARA OCCURS 0 WITH HEADER LINE.

DATA: ITAB_BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF ITAB_MESSTAB OCCURS 0.

INCLUDE STRUCTURE BDCMSGCOLL.

DATA: END OF ITAB_MESSTAB.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'D:\Surender\MY TEST\STEST1.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ITAB

**************************************************************

******************************************************************

LOOP AT ITAB.

REFRESH ITAB_BDCTAB.

ITAB_BDCTAB-PROGRAM = 'SAPLMGMM'.

ITAB_BDCTAB-DYNPRO = '0060'.

ITAB_BDCTAB-DYNBEGIN = 'X'.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'RMMG1-MATNR'.

ITAB_BDCTAB-FVAL = ITAB-MATNR.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'RMMG1-MBRSH'.

ITAB_BDCTAB-FVAL = ITAB-MBRSH.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'RMMG1-MTART'.

ITAB_BDCTAB-FVAL = ITAB-MTART.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

******************************************

ITAB_BDCTAB-PROGRAM = 'SAPLMGMM'.

ITAB_BDCTAB-DYNPRO = '0070'.

ITAB_BDCTAB-DYNBEGIN = 'X'.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'MSICHTAUSW-KZSEL(01)'.

ITAB_BDCTAB-FVAL = 'X'.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'MSICHTAUSW-KZSEL(02)'.

ITAB_BDCTAB-FVAL = 'X'.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

*******************************************

ITAB_BDCTAB-PROGRAM = 'SAPLMGMM'.

ITAB_BDCTAB-DYNPRO = '4004'.

ITAB_BDCTAB-DYNBEGIN = 'X'.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'MAKT-MAKTX'.

ITAB_BDCTAB-FVAL = ITAB-MAKTX.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'MARA-MEINS'.

ITAB_BDCTAB-FVAL = ITAB-MEINS.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

ITAB_BDCTAB-FNAM = 'MARA-MTPOS_MARA'.

ITAB_BDCTAB-FVAL = ITAB-MTPOS_MARA.

APPEND ITAB_BDCTAB.

CLEAR ITAB_BDCTAB.

**************************************************

CALL TRANSACTION 'MM01' USING ITAB_BDCTAB MODE 'A' UPDATE 'S'

MESSAGES INTO ITAB_MESSTAB.

REFRESH ITAB_BDCTAB.

ENDLOOP.

1 REPLY 1
Read only

Former Member
0 Likes
299

Hi,

Do something like this.

loop at the ITAB_MESSTAB and read for the message based on message type ans display them accordingly.

loop at ITAB_MESSTAB.

if itab_mestab-msgty = 'S'.

write : / itab_mestab-msgv1, itab_mestab-text

award points if helpful.

Thanks

Dany

endloop.