Skip to Content
author's profile photo
Former Member

Reg. BDC Background Mode

Hi all,

I've done a BDC which runs in the background mode.

In case of any failure the BDC will not run further and it stops abruptly. This is because it runs in Mode 'N'. I've tried using Mode 'E' also, but in both the cases the BDC stops at the record where there is a Problem.

Now my Requirement is the BDC should continue with the next record in case of any mistake. Also, the record where the failure had occured should be stored somewhere so that I should display it as a report once the BDC is finished completely.

Is there any standard table? Is there any other Modes?

Please throw some light on this issue.

Regards

Ramakrishnan.G

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • author's profile photo
    Former Member
    Oct 06, 2005 at 04:42 AM

    are you able to paste the part of the code that creates the BDC. Would like to see how you have coded to process multiple records in one go ...

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 06, 2005 at 04:47 AM

    Hello RamaKrishna,

    If you are using Call Transaction then you should be able to catch the error messages using BDCMSGCOLL structure.

    You have to create an extra internal table of the record type you are trying to load for error records.

    In case of Session method error log will be created and you should be able to the statuses of the records by clicking 'Analysis' button or detail log by clicking 'job log'.

    Regards,

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 06, 2005 at 04:49 AM

    Hi,

    Check this sample code.

    yes u can collect all the error messages in a Internal table and display it.Please concentrate on the codes made in bold

    ***INCLUDE ZBDCRECX1.

    • When you generate the program using SHDB, you can replace it

    • with this if you want to execute it immediately without having

    • to process it using SM35.

    • During testing you can used the original include.

    • For example,

    • include zbdcrecx1. "After test

    • include bdcrecx. "Before test

    • -------------------------------------

    • Declare your internal table as RECORD

    • -------------------------------------

    • for programs doing a data transfer by creating a batch-input session

    • and

    • for programs doing a data transfer by CALL TRANSACTION USING

    *SELECTION-SCREEN BEGIN OF LINE.

    • PARAMETERS SESSION RADIOBUTTON GROUP CTU. "create session

    • SELECTION-SCREEN COMMENT 3(20) TEXT-S07 FOR FIELD SESSION.

    • selection-screen position 45.

    • PARAMETERS CTU RADIOBUTTON GROUP CTU DEFAULT 'X'. "call transaction

    • SELECTION-SCREEN COMMENT 48(20) TEXT-S08 FOR FIELD CTU.

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: SESSION NO-DISPLAY,

    CTU NO-DISPLAY DEFAULT 'X'.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 3(20) TEXT-S01 FOR FIELD GROUP.

    • selection-screen position 25.

    • PARAMETERS GROUP(12). "group name of session

    • SELECTION-SCREEN COMMENT 48(20) TEXT-S05 FOR FIELD CTUMODE.

    • selection-screen position 70.

    • PARAMETERS CTUMODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.

    • "A: show all dynpros

    • "E: show dynpro on error only

    • "N: do not display dynpro

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: GROUP(12) NO-DISPLAY,

    CTUMODE NO-DISPLAY DEFAULT 'N'.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 3(20) TEXT-S02 FOR FIELD USER.

    • selection-screen position 25.

    • PARAMETERS: USER(12) DEFAULT SY-UNAME. "user for session in batch

    • SELECTION-SCREEN COMMENT 48(20) TEXT-S06 FOR FIELD CUPDATE.

    • selection-screen position 70.

    • PARAMETERS CUPDATE LIKE CTU_PARAMS-UPDMODE DEFAULT 'L'.

    • "S: synchronously

    • "A: asynchronously

    • "L: local

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: USER(12) NO-DISPLAY DEFAULT SY-UNAME,

    CUPDATE LIKE CTU_PARAMS-UPDMODE DEFAULT 'L' NO-DISPLAY.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 3(20) TEXT-S03 FOR FIELD KEEP.

    • selection-screen position 25.

    • PARAMETERS: KEEP AS CHECKBOX. "' ' = delete session if finished

    • "'X' = keep session if finished

    • SELECTION-SCREEN COMMENT 48(20) TEXT-S09 FOR FIELD E_GROUP.

    • selection-screen position 70.

    • parameters E_GROUP(12). "group name of error-session

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: KEEP NO-DISPLAY,

    E_GROUP(12) NO-DISPLAY.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 3(20) TEXT-S04 FOR FIELD HOLDDATE.

    • selection-screen position 25.

    • PARAMETERS: HOLDDATE LIKE SY-DATUM.

    • SELECTION-SCREEN COMMENT 51(17) TEXT-S02 FOR FIELD E_USER.

    • selection-screen position 70.

    • PARAMETERS: E_USER(12) DEFAULT SY-UNAME. "user for error-session

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: HOLDDATE LIKE SY-DATUM NO-DISPLAY,

    E_USER(12) DEFAULT SY-UNAME NO-DISPLAY.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 51(17) TEXT-S03 FOR FIELD E_KEEP.

    • selection-screen position 70.

    • PARAMETERS: E_KEEP AS CHECKBOX. "' ' = delete session if finished

    • "'X' = keep session if finished

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: E_KEEP NO-DISPLAY.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 51(17) TEXT-S04 FOR FIELD E_HDATE.

    • selection-screen position 70.

    • PARAMETERS: E_HDATE LIKE SY-DATUM.

    *SELECTION-SCREEN END OF LINE.

    *SELECTION-SCREEN SKIP.

    PARAMETERS: E_HDATE LIKE SY-DATUM NO-DISPLAY.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 1(33) TEXT-S10 FOR FIELD NODATA.

    • PARAMETERS: NODATA DEFAULT '/' LOWER CASE. "nodata

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: NODATA DEFAULT '/' LOWER CASE NO-DISPLAY.

    *SELECTION-SCREEN BEGIN OF LINE.

    • SELECTION-SCREEN COMMENT 1(33) FOR FIELD SMALLLOG.

    • PARAMETERS: SMALLLOG as checkbox. "' ' = log all transactions

    • "'X' = no transaction logging

    *SELECTION-SCREEN END OF LINE.

    PARAMETERS: SMALLLOG NO-DISPLAY.

    ----


    • data definition

    ----


    • Batchinputdata of single transaction

    DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

    <b>* messages of call transaction

    DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.</b>

    • error session opened (' ' or 'X')

    DATA: E_GROUP_OPENED.

    • message texts

    TABLES: T100.

    ----


    • at selection screen *

    ----


    AT SELECTION-SCREEN.

    • group and user must be filled for create session

    IF SESSION = 'X' AND

    GROUP = SPACE OR USER = SPACE.

    MESSAGE E613(MS).

    ENDIF.

    ----


    • open dataset *

    ----


    FORM OPEN_DATASET USING P_DATASET.

    OPEN DATASET P_DATASET IN TEXT MODE.

    IF SY-SUBRC <> 0.

    WRITE: / TEXT-E00, SY-SUBRC.

    STOP.

    ENDIF.

    ENDFORM.

    ----


    • close dataset *

    ----


    FORM CLOSE_DATASET USING P_DATASET.

    CLOSE DATASET P_DATASET.

    ENDFORM.

    ----


    • create batchinput session *

    • (not for call transaction using...) *

    ----


    FORM OPEN_GROUP.

    IF SESSION = 'X'.

    SKIP.

    WRITE: /(20) 'Create group'(I01), GROUP.

    SKIP.

    • open batchinput group

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING CLIENT = SY-MANDT

    GROUP = GROUP

    USER = USER

    KEEP = KEEP

    HOLDDATE = HOLDDATE.

    WRITE: /(30) 'BDC_OPEN_GROUP'(I02),

    (12) 'returncode:'(I05),

    SY-SUBRC.

    ENDIF.

    ENDFORM.

    ----


    • end batchinput session *

    • (call transaction using...: error session) *

    ----


    FORM CLOSE_GROUP.

    IF SESSION = 'X'.

    • close batchinput group

    CALL FUNCTION 'BDC_CLOSE_GROUP'.

    WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),

    (12) 'returncode:'(I05),

    SY-SUBRC.

    ELSE.

    IF E_GROUP_OPENED = 'X'.

    CALL FUNCTION 'BDC_CLOSE_GROUP'.

    WRITE: /.

    WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).

    ENDIF.

    ENDIF.

    ENDFORM.

    ----


    • Start new transaction according to parameters *

    ----


    FORM BDC_TRANSACTION USING TCODE.

    DATA: L_MSTRING(480).

    DATA: L_SUBRC LIKE SY-SUBRC.

    • batch input session

    IF SESSION = 'X'.

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING TCODE = TCODE

    TABLES DYNPROTAB = BDCDATA.

    IF SMALLLOG <> 'X'.

    WRITE: / 'BDC_INSERT'(I03),

    TCODE,

    'returncode:'(I05),

    SY-SUBRC,

    'RECORD:',

    SY-INDEX.

    ENDIF.

    • call transaction using

    ELSE.

    <b>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.

    IF SY-SUBRC = 0.

    FORMAT COLOR OFF.

    WRITE:/ 'Successfully Process ', MESSTAB, RECORD.

    ELSE.

    FORMAT COLOR COL_NEGATIVE.

    WRITE:/ 'Failed Process ', MESSTAB, RECORD.

    ENDIF.

    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.</b> ** Erzeugen fehlermappe ************************************************

    IF L_SUBRC <> 0 AND E_GROUP <> SPACE.

    IF E_GROUP_OPENED = ' '.

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING CLIENT = SY-MANDT

    GROUP = E_GROUP

    USER = E_USER

    KEEP = E_KEEP

    HOLDDATE = E_HDATE.

    E_GROUP_OPENED = 'X'.

    ENDIF.

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING TCODE = TCODE

    TABLES DYNPROTAB = BDCDATA.

    ENDIF.

    ENDIF.

    REFRESH BDCDATA.

    ENDFORM.

    ----


    • Start new screen *

    ----


    FORM BDC_DYNPRO USING PROGRAM DYNPRO.

    CLEAR BDCDATA.

    BDCDATA-PROGRAM = PROGRAM.

    BDCDATA-DYNPRO = DYNPRO.

    BDCDATA-DYNBEGIN = 'X'.

    APPEND BDCDATA.

    ENDFORM.

    ----


    • Insert field *

    ----


    FORM BDC_FIELD USING FNAM FVAL.

    IF FVAL <> NODATA.

    CLEAR BDCDATA.

    BDCDATA-FNAM = FNAM.

    BDCDATA-FVAL = FVAL.

    APPEND BDCDATA.

    ENDIF.

    ENDFORM.

    --- End of ABAP Program

    hope u understood.

    Kindly reward points if u find it useful.

    Thanks&Regards,

    Ruthra

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi ruthra

      • include zbdcrecx1. "After test

      • include bdcrecx. "Before test

      i know only bdcrecx1,may i know about other includes.

      sap already provided bdcrecx1 why you are using your own includes..

      please explain the purpose of using other than include bdcrecx1.

  • author's profile photo
    Former Member
    Oct 06, 2005 at 09:18 AM

    Hi Ram,

    Using BDC you can process the records either by creating sessions or by using call transaction.

    1. Incase of Sessions you can schedule or execute it in background and will have the logs for success as well as failure records. Incase you have 10 records and 4 and 6 are not correct. Then session will get processed for all other records other than 4 and 6. You can get the session detail at SM35.

    2. Incase of Call transaction method the status of whether the record has been failed or not will available in the MESSTAB. Further if you execute it MODE = 'A', only then it will stop and in MODE = 'N' it will process the other records when a particular record fails. This will to captured but we need to take the logic from there to keep a track of the error reports.

    Hope that helps

    Thanks & Regards,

    Kathirvel

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 06, 2005 at 09:46 AM

    Hi everyone,

    Thanks for the answers that u've given.Actually Error Messages can be stored, True. But my requirement is To get the record for which error had occured. Here my BDC runs for "ME38" - Maintaining Schedule Agrrement.

    So, if any error occurs while running in Background my BDC should capture that Schedule Agreement No. & not that Error Message !!! I have already captured the error message but couldn't capture the Sch.Agreement No.

    Can anyone give some solutions to this?

    Thanks in advance,

    Regards,

    Ramakrishnan.G

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Ramakrishna,

      After reading your message I could not find out whether you do a call transaction or do a session method.

      If you do call transaction , then the SY-SUBRC after the call transaction will tell you whether the transaction failed . If sy-subrc ne 0 you can put the the Sch Agreement number ( which you already have in program ) in an internal table and later write this to list or save in a file which you can review later.

      If you are doing session method then you can goto SM35 , select your session , click on ANALYZE . Here you will see the error transactions. Double click on any of them .

      It will take you to screens of that transaction created by INSERT_GROUP. Just double click the first screen and you will see the agreement number . In Session method there is no way to capture the SCh Agg. number in program as sessions are processed by another program on which you have no control . You have to analyze sessions manually after they poted.

      If you mention what method you use in BDC you would get correct answers.

      Cheers.

      Message was edited by: Sanjay Sinha