Application Development 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: 

in BDC

Former Member
0 Kudos
139

hi

In BDC when using call transaction method , to know whether the data is succesfully uploaded or not, we will return sy-subrc value. if it is not equal to zero. how to get the error records.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
109

<b>The below is logic for SY-SUBRC = 0 OR 4 .</b>

LOOP AT MESSTAB. 
        SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA 
                                  AND   ARBGB = MESSTAB-MSGID 
                                  AND   MSGNR = MESSTAB-MSGNR. 
        IF SY-SUBRC = 0. 
          L_MSTRING = T100-TEXT. 
          IF L_MSTRING CS '&1'. 
            REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ELSE. 
            REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ENDIF. 
          CONDENSE L_MSTRING. 
          WRITE: / MESSTAB-MSGTYP, L_MSTRING(250). 
        ELSE. 
          WRITE: / MESSTAB. 
        ENDIF. 
      ENDLOOP. 

reward points if it is usefull ....

Girish

8 REPLIES 8

Former Member
0 Kudos
109

Hi,

Check out this,

Collect data into MESSTAB and write it

  • messages of call transaction

DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

REFRESH MESSTAB.

CALL TRANSACTION TCODE USING BDCDATA

MODE CTUMODE

UPDATE CUPDATE

MESSAGES INTO MESSTAB.

L_SUBRC = SY-SUBRC.

IF SMALLLOG <> 'X'.

WRITE: / 'CALL_TRANSACTION',

TCODE,

'returncode:'(I05),

L_SUBRC,

'RECORD:',

SY-INDEX.

LOOP AT MESSTAB.

SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA

AND ARBGB = MESSTAB-MSGID

AND MSGNR = MESSTAB-MSGNR.

IF SY-SUBRC = 0.

L_MSTRING = T100-TEXT.

IF L_MSTRING CS '&1'.

REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ELSE.

REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ENDIF.

CONDENSE L_MSTRING.

WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).

ELSE.

WRITE: / MESSTAB.

ENDIF.

ENDLOOP.

SKIP.

ENDIF.

Reward if useful!

Former Member
0 Kudos
109

Hi,

Declare an internal table for error records say it_error.

then


if sy-subrc ne 0.
  move itab to it_error.
  append it_error.
endif.

After the loop download this error internal table using gui_download.

Reward points if useful,

Aleem.

Former Member
0 Kudos
109

Hi,

Use " MESSAGES INTO MESSTAB" extension of the call transaction keyword and collect all the messages. Loop at this table and display the messages.

Regards,

Shruthi R

.

Former Member
0 Kudos
109

Hi,

See the BDc sample code how the errors are handled using the FORMAT_MESSAGE function module

REPORT ZMMBDC1_1 NO STANDARD PAGE HEADING MESSAGE-ID ZT.

  • internal table for selecting data from flat file

DATA : BEGIN OF IT_DATA OCCURS 0,

MBRSH, " Industry sector

MTART(4), " Material type

KZSEL, " Checkbox

MAKTX(40), " Material description

MEINS(3), " Base unit of measure

MATKL(9), " Material group

BISMT(18), " Old material number

END OF IT_DATA.

  • internal table for bdcdata

DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • internal table to handle messages

DATA : IT_MESSAGES LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

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

  • Variables & Flag declaration

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

  • variables declaration

DATA : V_MESG(50).

  • flag declaration

DATA : FG_BDC,

FG_FLAG1 TYPE I.

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

  • selection screen

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

SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

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

  • parameter

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

PARAMETERS : P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.

SELECTION-SCREEN END OF BLOCK BLK1.

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

  • initialization

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

INITIALIZATION.

  • peform to initialize parameter

PERFORM INIT_PARM.

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

  • start of selection

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

start-of-selection.

  • perform to upload it_data

PERFORM UP_LOAD_IT_DATA.

  • perform transfer data

PERFORM TRANSFER_DATA.

  • end of selection

END-OF-SELECTION.

&----


*& Form INIT_PARM

&----


  • Initializing parameter

----


FORM INIT_PARM.

P_FILE = 'C:\'.

ENDFORM. " INIT_PARM

&----


*& Form UP_LOAD_IT_DATA

&----


  • Transfering data from file to internal table

----


FORM UP_LOAD_IT_DATA.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = P_FILE

FILETYPE = 'ASC'

TABLES

DATA_TAB = IT_DATA

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

GUI_REFUSE_FILETRANSFER = 8

OTHERS = 9.

IF SY-SUBRC = 2 .

FG_FLAG1 = 1.

MESSAGE I001.

ENDIF.

ENDFORM. " UP_LOAD_IT_DATA

&----


*& Form TRANSFER_DATA

&----


  • Processing the data

----


FORM TRANSFER_DATA.

FG_BDC = 'N'.

LOOP AT IT_DATA.

  • perform to fill it_bdcdata.

PERFORM FILL_IT_BDCDATA.

CALL TRANSACTION 'MM01' USING IT_BDCDATA MODE 'N' UPDATE 'S'

MESSAGES INTO IT_MESSAGES.

IF SY-SUBRC <> 0.

FG_FLAG1 = 1.

  • if error occurs in transaction mode run bdc session for that data

PERFORM BDC_PROCESS.

ENDIF.

  • Handles error messages

PERFORM ERROR_MESSAGES.

CLEAR : IT_BDCDATA,IT_DATA,IT_MESSAGES.

REFRESH : IT_BDCDATA,IT_MESSAGES.

ENDLOOP.

IF FG_FLAG1 = 0.

MESSAGE I003.

ENDIF.

IF FG_BDC = 'O'.

  • close bdc if it is open

PERFORM CLOSE_BDC.

ENDIF.

ENDFORM. " TRANSFER_DATA

&----


*& Form FILL_IT_BDCDATA

&----


  • Filling Bdcdata structure with it_data

  • Some fields have been commented for future updations

----


FORM FILL_IT_BDCDATA.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '0060'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '/00',

: 'BDC_CURSOR' 'RMMG1_REF-MATNR',

: 'RMMG1-MBRSH' IT_DATA-MBRSH,

: 'RMMG1-MTART' IT_DATA-MTART.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '0070'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=RESA'.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '0070'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=ENTR',

: 'MSICHTAUSW-KZSEL(01)' IT_DATA-KZSEL.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '4000'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=BU',

: 'BDC_SUBSCR' 'SAPLMGMM' & ' 2000TABFRA1',

: 'BDC_SUBSCR' 'SAPLMGD1' & ' 1002SUB1',

: 'BDC_CURSOR' 'MAKT-MAKTX',

: 'MAKT-MAKTX' IT_DATA-MAKTX,

: 'BDC_SUBSCR' 'SAPLMGD1' & ' 2001SUB2',

: 'MARA-MEINS' IT_DATA-MEINS,

: 'MARA-MATKL' IT_DATA-MATKL,

: 'MARA-BISMT' IT_DATA-BISMT,

: 'BDC_OKCODE' '=BU'.

*perform bdc_field using 'MARA-EXTWG' ''.

*perform bdc_field using 'MARA-LABOR' ''.

*perform bdc_field using 'MARA-KOSCH' ''.

*perform bdc_field using 'MARA-MSTAE' ''.

*perform bdc_field using 'MARA-MSTDE' ''.

*perform bdc_field using 'BDC_SUBSCR' 'SAPLMGD1' & ' 2561SUB3'.

*perform bdc_field using 'MARA-BEGRU' ''.

*perform bdc_field using 'BDC_SUBSCR' 'SAPLMGD1' & ' 2007SUB4'.

*perform bdc_field using 'MARA-NTGEW' ''.

*perform bdc_field using 'MARA-BRGEW' ''.

*perform bdc_field using 'MARA-GEWEI' ''.

*perform bdc_field using 'MARA-VOLUM' ''.

*perform bdc_field using 'MARA-VOLEH' ''.

*PERFORM BDC_FIELD USING 'MARA-GROES' ''.

*perform bdc_field using 'MARA-EAN11' ''.

*perform bdc_field using 'MARA-NUMTP' ''.

*PERFORM BDC_FIELD USING 'BDC_SUBSCR' 'SAPLMGD1' & ' 2005SUB5'.

*perform bdc_field using 'BDC_SUBSCR' 'SAPLMGD1' & ' 2011SUB6'.

*perform bdc_field using 'MARA-MAGRV' ''.

ENDFORM. " FILL_IT_BDCDATA

&----


*& Form BDC_DYNPRO

&----


  • Filling the it_bdcdata table with program name & screen number

----


FORM BDC_DYNPRO USING PROGRAM LIKE BDCDATA-PROGRAM

DYNPRO LIKE BDCDATA-DYNPRO.

IT_BDCDATA-PROGRAM = PROGRAM.

IT_BDCDATA-DYNPRO = DYNPRO.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

CLEAR IT_BDCDATA.

ENDFORM. " BDC_DYNPRO

&----


*& Form BDC_FIELD

&----


  • Filling it_bdcdata with field name and field value

----


FORM BDC_FIELD USING FNAM LIKE BDCDATA-FNAM

FVAL.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

CLEAR IT_BDCDATA.

ENDFORM. " BDC_FIELD

&----


*& Form ERROR_MESSAGES

&----


  • Displaying error messages

----


FORM ERROR_MESSAGES.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = SY-MSGID

LANG = '-D'

IMPORTING

MSG = V_MESG

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2.

LOOP AT IT_MESSAGES WHERE MSGTYP = 'E'.

WRITE : / 'Message :'(I06) ,V_MESG.

CLEAR IT_MESSAGES.

ENDLOOP.

ENDFORM. " ERROR_MESSAGES

&----


*& Form BDC_PROCESS

&----


  • Open bdc session if call transaction fails

----


FORM BDC_PROCESS.

IF FG_BDC = 'N'.

  • open bdc session

PERFORM OPEN_BDC.

FG_BDC = 'O'.

ENDIF.

IF FG_BDC = 'O'.

  • insert data into bdc session

PERFORM INSERT_BDC.

ENDIF.

ENDFORM. " BDC_PROCESS

&----


*& Form OPEN_BDC

&----


  • Calling function module to open bdc session

----


FORM OPEN_BDC.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'SMM1'

KEEP = 'X'

USER = SY-UNAME

EXCEPTIONS

CLIENT_INVALID = 1

DESTINATION_INVALID = 2

GROUP_INVALID = 3

GROUP_IS_LOCKED = 4

HOLDDATE_INVALID = 5

INTERNAL_ERROR = 6

QUEUE_ERROR = 7

RUNNING = 8

SYSTEM_LOCK_ERROR = 9

USER_INVALID = 10

OTHERS = 11.

ENDFORM. " OPEN_BDC

&----


*& Form INSERT_BDC

&----


  • Insert it_bdcdata into bdc by calling function module bdc_insert

----


FORM INSERT_BDC.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MM01'

TABLES

DYNPROTAB = IT_BDCDATA

EXCEPTIONS

INTERNAL_ERROR = 1

NOT_OPEN = 2

QUEUE_ERROR = 3

TCODE_INVALID = 4

PRINTING_INVALID = 5

POSTING_INVALID = 6

OTHERS = 7.

ENDFORM. " INSERT_BDC

&----


*& Form CLOSE_BDC

&----


  • Closing bdc session

----


FORM CLOSE_BDC.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 2

OTHERS = 3.

ENDFORM. " CLOSE_BDC

Plz go through the below mention link .there is an example for call transaction method error handling.

http://www.sapbrainsonline.com/PROJECTS/TECHNICAL/ABAP%20Source%20codes/Batch%20Input%20with%20Call%...

Reward all helpful answers..

Regards,

Omkar.

Former Member
0 Kudos
109

Hi

See the sample BDC program in which these errors are collected and displayed using the fun module FORMAT_MESSAGE

REPORT ZMMBDC1_1 NO STANDARD PAGE HEADING MESSAGE-ID ZT.

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

  • Declaration of internal tables

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

  • internal table for selecting data from flat file

DATA : BEGIN OF IT_DATA OCCURS 0,

MBRSH, " Industry sector

MTART(4), " Material type

KZSEL, " Checkbox

MAKTX(40), " Material description

MEINS(3), " Base unit of measure

MATKL(9), " Material group

BISMT(18), " Old material number

END OF IT_DATA.

  • internal table for bdcdata

DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • internal table to handle messages

DATA : IT_MESSAGES LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

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

  • Variables & Flag declaration

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

  • variables declaration

DATA : V_MESG(50).

  • flag declaration

DATA : FG_BDC,

FG_FLAG1 TYPE I.

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

  • selection screen

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

SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

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

  • parameter

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

PARAMETERS : P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.

SELECTION-SCREEN END OF BLOCK BLK1.

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

  • initialization

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

INITIALIZATION.

  • peform to initialize parameter

PERFORM INIT_PARM.

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

  • start of selection

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

start-of-selection.

  • perform to upload it_data

PERFORM UP_LOAD_IT_DATA.

  • perform transfer data

PERFORM TRANSFER_DATA.

  • end of selection

END-OF-SELECTION.

&----


*& Form INIT_PARM

&----


  • Initializing parameter

----


FORM INIT_PARM.

P_FILE = 'C:\'.

ENDFORM. " INIT_PARM

&----


*& Form UP_LOAD_IT_DATA

&----


  • Transfering data from file to internal table

----


FORM UP_LOAD_IT_DATA.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = P_FILE

FILETYPE = 'ASC'

TABLES

DATA_TAB = IT_DATA

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

GUI_REFUSE_FILETRANSFER = 8

OTHERS = 9.

IF SY-SUBRC = 2 .

FG_FLAG1 = 1.

MESSAGE I001.

ENDIF.

ENDFORM. " UP_LOAD_IT_DATA

&----


*& Form TRANSFER_DATA

&----


  • Processing the data

----


FORM TRANSFER_DATA.

FG_BDC = 'N'.

LOOP AT IT_DATA.

  • perform to fill it_bdcdata.

PERFORM FILL_IT_BDCDATA.

CALL TRANSACTION 'MM01' USING IT_BDCDATA MODE 'N' UPDATE 'S'

MESSAGES INTO IT_MESSAGES.

IF SY-SUBRC <> 0.

FG_FLAG1 = 1.

  • if error occurs in transaction mode run bdc session for that data

PERFORM BDC_PROCESS.

ENDIF.

  • Handles error messages

PERFORM ERROR_MESSAGES.

CLEAR : IT_BDCDATA,IT_DATA,IT_MESSAGES.

REFRESH : IT_BDCDATA,IT_MESSAGES.

ENDLOOP.

IF FG_FLAG1 = 0.

MESSAGE I003.

ENDIF.

IF FG_BDC = 'O'.

  • close bdc if it is open

PERFORM CLOSE_BDC.

ENDIF.

ENDFORM. " TRANSFER_DATA

&----


*& Form FILL_IT_BDCDATA

&----


  • Filling Bdcdata structure with it_data

  • Some fields have been commented for future updations

----


FORM FILL_IT_BDCDATA.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '0060'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '/00',

: 'BDC_CURSOR' 'RMMG1_REF-MATNR',

: 'RMMG1-MBRSH' IT_DATA-MBRSH,

: 'RMMG1-MTART' IT_DATA-MTART.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '0070'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=RESA'.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '0070'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=ENTR',

: 'MSICHTAUSW-KZSEL(01)' IT_DATA-KZSEL.

PERFORM BDC_DYNPRO USING : 'SAPLMGMM' '4000'.

PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=BU',

: 'BDC_SUBSCR' 'SAPLMGMM' & ' 2000TABFRA1',

: 'BDC_SUBSCR' 'SAPLMGD1' & ' 1002SUB1',

: 'BDC_CURSOR' 'MAKT-MAKTX',

: 'MAKT-MAKTX' IT_DATA-MAKTX,

: 'BDC_SUBSCR' 'SAPLMGD1' & ' 2001SUB2',

: 'MARA-MEINS' IT_DATA-MEINS,

: 'MARA-MATKL' IT_DATA-MATKL,

: 'MARA-BISMT' IT_DATA-BISMT,

: 'BDC_OKCODE' '=BU'.

*perform bdc_field using 'MARA-EXTWG' ''.

*perform bdc_field using 'MARA-LABOR' ''.

*perform bdc_field using 'MARA-KOSCH' ''.

*perform bdc_field using 'MARA-MSTAE' ''.

*perform bdc_field using 'MARA-MSTDE' ''.

*perform bdc_field using 'BDC_SUBSCR' 'SAPLMGD1' & ' 2561SUB3'.

*perform bdc_field using 'MARA-BEGRU' ''.

*perform bdc_field using 'BDC_SUBSCR' 'SAPLMGD1' & ' 2007SUB4'.

*perform bdc_field using 'MARA-NTGEW' ''.

*perform bdc_field using 'MARA-BRGEW' ''.

*perform bdc_field using 'MARA-GEWEI' ''.

*perform bdc_field using 'MARA-VOLUM' ''.

*perform bdc_field using 'MARA-VOLEH' ''.

*PERFORM BDC_FIELD USING 'MARA-GROES' ''.

*perform bdc_field using 'MARA-EAN11' ''.

*perform bdc_field using 'MARA-NUMTP' ''.

*PERFORM BDC_FIELD USING 'BDC_SUBSCR' 'SAPLMGD1' & ' 2005SUB5'.

*perform bdc_field using 'BDC_SUBSCR' 'SAPLMGD1' & ' 2011SUB6'.

*perform bdc_field using 'MARA-MAGRV' ''.

ENDFORM. " FILL_IT_BDCDATA

&----


*& Form BDC_DYNPRO

&----


  • Filling the it_bdcdata table with program name & screen number

----


FORM BDC_DYNPRO USING PROGRAM LIKE BDCDATA-PROGRAM

DYNPRO LIKE BDCDATA-DYNPRO.

IT_BDCDATA-PROGRAM = PROGRAM.

IT_BDCDATA-DYNPRO = DYNPRO.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

CLEAR IT_BDCDATA.

ENDFORM. " BDC_DYNPRO

&----


*& Form BDC_FIELD

&----


  • Filling it_bdcdata with field name and field value

----


FORM BDC_FIELD USING FNAM LIKE BDCDATA-FNAM

FVAL.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

CLEAR IT_BDCDATA.

ENDFORM. " BDC_FIELD

&----


*& Form ERROR_MESSAGES

&----


  • Displaying error messages

----


<b>FORM ERROR_MESSAGES.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = SY-MSGID

LANG = '-D'

IMPORTING

MSG = V_MESG

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2.

LOOP AT IT_MESSAGES WHERE MSGTYP = 'E'.

WRITE : / 'Message :'(I06) ,V_MESG.

CLEAR IT_MESSAGES.

ENDLOOP.

ENDFORM. " ERROR_MESSAGES</b>

&----


*& Form BDC_PROCESS

&----


  • Open bdc session if call transaction fails

----


FORM BDC_PROCESS.

IF FG_BDC = 'N'.

  • open bdc session

PERFORM OPEN_BDC.

FG_BDC = 'O'.

ENDIF.

IF FG_BDC = 'O'.

  • insert data into bdc session

PERFORM INSERT_BDC.

ENDIF.

ENDFORM. " BDC_PROCESS

&----


*& Form OPEN_BDC

&----


  • Calling function module to open bdc session

----


FORM OPEN_BDC.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'SMM1'

KEEP = 'X'

USER = SY-UNAME

EXCEPTIONS

CLIENT_INVALID = 1

DESTINATION_INVALID = 2

GROUP_INVALID = 3

GROUP_IS_LOCKED = 4

HOLDDATE_INVALID = 5

INTERNAL_ERROR = 6

QUEUE_ERROR = 7

RUNNING = 8

SYSTEM_LOCK_ERROR = 9

USER_INVALID = 10

OTHERS = 11.

ENDFORM. " OPEN_BDC

&----


*& Form INSERT_BDC

&----


  • Insert it_bdcdata into bdc by calling function module bdc_insert

----


FORM INSERT_BDC.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MM01'

TABLES

DYNPROTAB = IT_BDCDATA

EXCEPTIONS

INTERNAL_ERROR = 1

NOT_OPEN = 2

QUEUE_ERROR = 3

TCODE_INVALID = 4

PRINTING_INVALID = 5

POSTING_INVALID = 6

OTHERS = 7.

ENDFORM. " INSERT_BDC

&----


*& Form CLOSE_BDC

&----


  • Closing bdc session

----


FORM CLOSE_BDC.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

NOT_OPEN = 1

QUEUE_ERROR = 2

OTHERS = 3.

ENDFORM. " CLOSE_BDC

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos
109

hi

just refer to the link below

http://www.sapmaterial.com/?gclid=CN322K28t4sCFQ-WbgodSGbK2g

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Former Member
0 Kudos
110

<b>The below is logic for SY-SUBRC = 0 OR 4 .</b>

LOOP AT MESSTAB. 
        SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA 
                                  AND   ARBGB = MESSTAB-MSGID 
                                  AND   MSGNR = MESSTAB-MSGNR. 
        IF SY-SUBRC = 0. 
          L_MSTRING = T100-TEXT. 
          IF L_MSTRING CS '&1'. 
            REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ELSE. 
            REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ENDIF. 
          CONDENSE L_MSTRING. 
          WRITE: / MESSTAB-MSGTYP, L_MSTRING(250). 
        ELSE. 
          WRITE: / MESSTAB. 
        ENDIF. 
      ENDLOOP. 

reward points if it is usefull ....

Girish

Former Member
0 Kudos
109

u want to just know what are the error records are get the output of all error records in a different file?