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

bdc

hi abapers,

pls send requirement and answer for table control bdc.how we work with this?pls send it full scenario.

thanx and regrads,

priya

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 Sep 12, 2007 at 10:42 AM

    hi,

    Check my earlier post

    table-control-in-bdc

    Hope this helps !

    Cheers

    Alfred

    Reward with points for helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2007 at 10:51 AM

    hi,

    REPORT z_xd01_bdc_session

    NO STANDARD PAGE HEADING LINE-SIZE 255.

    INCLUDE <icon>.

    *----


    • DATA DELEClARATION

    *----


    DATA: BEGIN OF it_input OCCURS 0,

    kunnr LIKE kna1-kunnr,

    ktokd LIKE kna1-ktokd,

    name1 LIKE kna1-name1,

    sortl LIKE kna1-sortl,

    land1 LIKE kna1-land1,

    spras LIKE kna1-spras,

    lzone LIKE kna1-lzone,

    banks LIKE knbk-banks,

    bankl LIKE knbk-bankl,

    bankn LIKE knbk-bankn,

    END OF it_input.

    DATA: BEGIN OF it_header OCCURS 0,

    kunnr LIKE kna1-kunnr,

    ktokd LIKE kna1-ktokd,

    name1 LIKE kna1-name1,

    sortl LIKE kna1-sortl,

    land1 LIKE kna1-land1,

    spras LIKE kna1-spras,

    lzone LIKE kna1-lzone,

    END OF it_header.

    DATA: BEGIN OF it_item OCCURS 0,

    kunnr LIKE kna1-kunnr,

    banks LIKE knbk-banks,

    bankl LIKE knbk-bankl,

    bankn LIKE knbk-bankn,

    END OF it_item.

    DATA: BEGIN OF it_messages OCCURS 0,

    msg_type(1),

    msg_text(70),

    END OF it_messages.

    DATA: it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

    it_params LIKE ctu_params.

    DATA: g_file TYPE string,

    g_cnt(2) TYPE n,

    g_field(20) TYPE c,

    g_msg(1) TYPE c VALUE 'E',

    g_msg1(1) TYPE c VALUE 'S'.

    *----


    • Selection Screen.

    *----


    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    PARAMETER: p_file LIKE rlgrap-filename,

    p_group LIKE apqi-groupid.

    SELECTION-SCREEN: END OF BLOCK b1.

    *----


    • initialization.

    *----


    INITIALIZATION.

    it_params-defsize = 'X'.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

    *F4 help to get the file name,

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    program_name = syst-cprog

    dynpro_number = syst-dynnr

    field_name = ' '

    IMPORTING

    file_name = p_file.

    *----


    • start-of-selection.

    *----


    START-OF-SELECTION.

    PERFORM f1000_upload_file.

    LOOP AT it_input.

    MOVE-CORRESPONDING it_input TO it_header.

    MOVE-CORRESPONDING it_input TO it_item.

    APPEND it_header.

    APPEND it_item.

    CLEAR it_header.

    CLEAR it_item.

    ENDLOOP.

    SORT it_header BY kunnr.

    SORT it_item BY kunnr.

    DELETE ADJACENT DUPLICATES FROM it_header COMPARING kunnr.

    PERFORM open_group.

    LOOP AT it_header.

    REFRESH it_bdcdata.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0100'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RF02D-KTOKD'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'RF02D-KUNNR'

    it_header-kunnr.

    PERFORM bdc_field USING 'RF02D-KTOKD'

    it_header-ktokd.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0110'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNA1-NAME4'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'KNA1-NAME1'

    it_header-name1.

    PERFORM bdc_field USING 'KNA1-SORTL'

    it_header-sortl.

    PERFORM bdc_field USING 'KNA1-LAND1'

    it_header-land1.

    PERFORM bdc_field USING 'KNA1-SPRAS'

    it_header-spras.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNA1-LZONE'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'KNA1-LZONE'

    it_header-lzone.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0125'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNA1-NIELS'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0130'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNBK-BANKN(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    READ TABLE it_item WITH KEY kunnr = it_header-kunnr.

    IF sy-subrc = 0.

    g_cnt = 01.

    LOOP AT it_item FROM sy-tabix.

    IF it_item-kunnr = it_header-kunnr.

    • PERFORM bdc_dynpro USING 'SAPMF02D' '0130'.

    • PERFORM bdc_field USING 'BDC_CURSOR'

    • 'KNBK-BANKN(01)'.

    • PERFORM bdc_field USING 'BDC_OKCODE'

    • '=ENTR'.

    *

    CONCATENATE 'KNBK-BANKS( ' g_cnt ')' INTO g_field.

    PERFORM bdc_field USING g_field

    it_item-banks.

    CONCATENATE 'KNBK-BANKL( ' g_cnt ')' INTO g_field.

    PERFORM bdc_field USING g_field

    it_item-bankl.

    CONCATENATE 'KNBK-BANKN( ' g_cnt ')' INTO g_field.

    PERFORM bdc_field USING g_field

    it_item-bankn.

    g_cnt = g_cnt + 01.

    ELSE.

    EXIT.

    ENDIF.

    ENDLOOP.

    ENDIF.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0130'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNBK-BANKS(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0340'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RF02D-KUNNR'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0370'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RF02D-KUNNR'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_field USING 'KNA1-CIVVE'

    'X'.

    PERFORM bdc_dynpro USING 'SAPMF02D' '0360'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'KNVK-NAMEV(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_insert.

    • PERFORM bdc_transaction USING 'XD01'.

    ENDLOOP.

    PERFORM close_group.

    PERFORM display_messages.

    &----


    *& Form open_group

    &----


    FORM open_group .

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    client = sy-mandt

    group = p_group

    • HOLDDATE = FILLER8

    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.

    IF sy-subrc <> 0.

    EXIT.

    ELSE.

    PERFORM f1100_format_messages USING g_msg1 text-i02.

    ENDIF.

    .

    ENDFORM. " open_group

    &----


    *& Form f1000_upload_file

    &----


    FORM f1000_upload_file .

    g_file = p_file.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = g_file

    filetype = 'ASC'

    has_field_separator = 'X'

    TABLES

    data_tab = it_input

    EXCEPTIONS

    file_open_error = 1

    file_read_error = 2

    no_batch = 3

    gui_refuse_filetransfer = 4

    invalid_type = 5

    no_authority = 6

    unknown_error = 7

    bad_data_format = 8

    header_not_allowed = 9

    separator_not_allowed = 10

    header_too_long = 11

    unknown_dp_error = 12

    access_denied = 13

    dp_out_of_memory = 14

    disk_full = 15

    dp_timeout = 16

    OTHERS = 17.

    IF sy-subrc <> 0.

    PERFORM f1100_format_messages USING g_msg text-i11.

    EXIT.

    ELSE.

    PERFORM f1100_format_messages USING g_msg1 text-i01.

    ENDIF.

    ENDFORM. " f1000_upload_file

    &----


    *& Form close_group

    &----


    FORM close_group .

    CALL FUNCTION 'BDC_CLOSE_GROUP'

    EXCEPTIONS

    not_open = 1

    queue_error = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    EXIT.

    ELSE.

    PERFORM f1100_format_messages USING g_msg1 text-i04.

    ENDIF.

    ENDFORM. " close_group

    &----


    *& Form bdc_insert

    &----


    FORM bdc_insert .

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING

    tcode = 'XD01'

    ctuparams = it_params

    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.

    IF sy-subrc <> 0.

    EXIT.

    ENDIF.

    ENDFORM. " bdc_insert

    &----


    *& Form bdc_dynpro

    &----


    FORM bdc_dynpro USING program

    dynpro.

    CLEAR it_bdcdata.

    it_bdcdata-program = program.

    it_bdcdata-dynpro = dynpro.

    it_bdcdata-dynbegin = 'X'.

    APPEND it_bdcdata.

    ENDFORM. " bdc_dynpro

    &----


    *& Form BDC_FIELD

    &----


    FORM bdc_field USING fnam fval.

    CLEAR it_bdcdata.

    it_bdcdata-fnam = fnam.

    it_bdcdata-fval = fval.

    APPEND it_bdcdata.

    ENDFORM. "BDC_FIELD

    &----


    *& Form f1100_format_messages

    &----


    • text

    ----


    • -->P_G_MSG text

    • -->P_TEXT_001 text

    ----


    FORM f1100_format_messages USING p_g_msg

    p_text.

    it_messages-msg_type = p_g_msg.

    it_messages-msg_text = p_text.

    APPEND it_messages.

    ENDFORM. " f1100_format_messages

    &----


    *& Form display_messages

    &----


    FORM display_messages .

    WRITE:/1(106) sy-uline.

    WRITE:/1 sy-vline,2 'msgtype',

    7 sy-vline,8 'msgtext',

    106 sy-vline.

    WRITE:/1(106) sy-uline.

    LOOP AT it_messages.

    IF it_messages-msg_type = 'E'.

    WRITE:/1 sy-vline,2 icon_led_red AS ICON,

    7 sy-vline,8 it_messages-msg_text,

    106 sy-vline.

    ELSE.

    WRITE:/1 sy-vline,2 icon_led_green AS ICON,

    7 sy-vline,8 it_messages-msg_text,

    106 sy-vline.

    ENDIF.

    WRITE:/1(106) sy-uline.

    ENDLOOP.

    ENDFORM. " display_messages

    regards

    siva

    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.