Skip to Content
author's profile photo Former Member
Former Member

BDC program

Information about BDC program. means how it works

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 10:30 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 11:18 AM

    Hi Rakesh,

    BDC (Batch Data Communication) works based on the data in the Internal table of structure "BDCDATA", and some of the very important lines with information (in sequence) Dynpro, Cursor-field and Data Fields, then call Transaction / Session Creation Logic.

    In Call Transaction method of BDC, the Message is handled manually using the structure "BDCMSGCOLL" and by refering to messages in "T100" Table. [Refer the standard Include BECRECX1 for more information.

    BDC can be created by Recording tool or my scracth creating a new program. Use transaction code 'SHDB'.

    A sample code by using the Recording method (Here both Call transaction and Session Method of BDC will be created by standard Recording tool [this you can find in include BDCRECX1])

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

    Code Only the Program, withoug Include BDCRECX1 (This std, inclu you can find)

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

    ***INCLUDE BDCRECX1.

    • 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. "call transaction

    selection-screen comment 48(20) text-s08 for field ctu.

    selection-screen end of line.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    selection-screen begin of line.

    selection-screen comment 1(33) text-s11 for field smalllog.

    parameters: smalllog as checkbox. "' ' = log all transactions

    "'X' = no transaction logging

    selection-screen end of line.

    ----


    • data definition

    ----


    • Batchinputdata of single transaction

    data: bdcdata like bdcdata occurs 0 with header line.

    • messages of call transaction

    data: messtab like bdcmsgcoll occurs 0 with header line.

    • 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

    for input in text mode

    encoding default.

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

    e_group_opened = ' '.

    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.

    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.

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

    You can find many example programs in SDN or Google.... 😊

    Regards,

    Manjunatha.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.