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

BDC TABLE CONTROL

Hi,

Can anybody Provide me the sample code for BDC Table control and can u explain what is the use of that.

Thanks.......

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jan 09, 2007 at 04:54 AM

    REPORT zsowja NO STANDARD PAGE HEADING LINE-SIZE 255.

    DATA: bdcdat LIKE bdcdata OCCURS 0 WITH HEADER LINE.

    DATA: BEGIN OF record OCCURS 0,

    • data element: ELIFN

    lifnr(010),

    • data element: EKORG

    ekorg(004),

    • data element: BKGRP

    ekgrp(003),

    • data element: EMATNR

    ematn(018),

    • data element: BSTMG

    menge(017),

    • data element: EWERK

    werks(004),

    END OF record.

    DATA : BEGIN OF head_itab OCCURS 0,

    • data element: ELIFN

    lifnr(010),

    • data element: EKORG

    ekorg(004),

    • data element: BKGRP

    ekgrp(003),

    END OF head_itab.

    DATA : BEGIN OF item_itab OCCURS 0,

    • data element: ELIFN

    lifnr(010),

    • data element: EMATNR

    ematn(018),

    • data element: BSTMG

    menge(017),

    • data element: EWERK

    werks(004),

    END OF item_itab.

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    • CODEPAGE = ' '

    filename = 'c:/hello.txt'

    filetype = 'ASC'

    • HEADLEN = ' '

    • LINE_EXIT = ' '

    • TRUNCLEN = ' '

    • USER_FORM = ' '

    • USER_PROG = ' '

    • DAT_D_FORMAT = ' '

    • IMPORTING

    • FILELENGTH =

    TABLES

    data_tab = record

    • EXCEPTIONS

    • CONVERSION_ERROR = 1

    • FILE_OPEN_ERROR = 2

    • FILE_READ_ERROR = 3

    • INVALID_TYPE = 4

    • NO_BATCH = 5

    • UNKNOWN_ERROR = 6

    • INVALID_TABLE_WIDTH = 7

    • GUI_REFUSE_FILETRANSFER = 8

    • CUSTOMER_ERROR = 9

    • OTHERS = 10

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    LOOP AT record.

    ON CHANGE OF record-lifnr.

    head_itab-lifnr = record-lifnr.

    head_itab-ekorg = record-ekorg.

    head_itab-ekgrp = record-ekgrp.

    APPEND head_itab.

    CLEAR head_itab.

    ENDON.

    • TO HAVE LINK BETWEEN HEADER AND ITEM TABLE USE LIFNR AS LINKER

    item_itab-lifnr = record-lifnr.

    item_itab-ematn = record-ematn.

    item_itab-menge = record-menge.

    item_itab-werks = record-werks.

    APPEND item_itab.

    CLEAR item_itab.

    ENDLOOP.

    *TO CHECH THE DATA IN HEADET ITAB AND DETAIL/ITEM ITAB

    *

    *loop at head_itab.

    *write :/ head_itab.

    *endloop.

    *skip 2.

    *loop at item_itab.

    *write:/ item_itab.

    *endloop.

    SORT head_itab BY lifnr ekorg ekgrp.

    SORT item_itab BY lifnr.

    DATA linecount TYPE i.

    START-OF-SELECTION.

    LOOP AT head_itab.

    ON CHANGE OF head_itab-lifnr.

    REFRESH bdcdat.

    CLEAR bdcdat.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0100'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'EKKO-LIFNR'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'EKKO-LIFNR'

    head_itab-lifnr.

    PERFORM bdc_field USING 'EKKO-EKORG'

    head_itab-ekorg.

    PERFORM bdc_field USING 'EKKO-EKGRP'

    head_itab-ekgrp.

    linecount = 0.

    <b> LOOP AT item_itab WHERE lifnr = head_itab-lifnr.

    linecount = linecount + 1.

    IF linecount = 1.</b> try to analyse this code

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'EKPO-WERKS(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'EKPO-EMATN(01)'

    item_itab-ematn.

    PERFORM bdc_field USING 'EKPO-MENGE(01)'

    item_itab-menge.

    PERFORM bdc_field USING 'EKPO-WERKS(01)'

    item_itab-werks.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    ELSE.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'EKPO-WERKS(02)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=NP'.

    PERFORM bdc_field USING 'EKPO-EMATN(02)'

    item_itab-ematn.

    PERFORM bdc_field USING 'EKPO-MENGE(02)'

    item_itab-menge.

    PERFORM bdc_field USING 'EKPO-WERKS(02)'

    item_itab-werks.

    PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

    ENDIF.

    AT END OF lifnr.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=BU'.

    ENDAT.

    ENDLOOP.

    ENDON.

    CALL TRANSACTION 'ME21' USING bdcdat MODE 'A'.

    REFRESH bdcdat.

    ENDLOOP.

    FORM bdc_dynpro USING value(a) value(b).

    bdcdat-program = a.

    bdcdat-dynpro = b.

    bdcdat-dynbegin = 'X'.

    APPEND bdcdat.

    CLEAR bdcdat.

    ENDFORM.

    FORM bdc_field USING value(c) value(d).

    bdcdat-fnam = c.

    bdcdat-fval = d.

    APPEND bdcdat.

    CLEAR bdcdat.

    ENDFORM.

    Reward if useful

    Add a comment
    10|10000 characters needed characters exceeded

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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 04:49 AM

    Anil ,

    Go through this link.

    bdc-in-table-control

    Pls. mark if useful

    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.