Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

table control in bdc

hi all,

can anybody pls tell me in which scenario we r using bdc table control

method. Is it when we have lots of line items for a single header item.

thanks

pankaj

Former Member
replied

Hi

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

  • After recording using SHDB tcode, you have to save the generated code.

  • Select the recording name & click on Program to generate it.

  • Provide program name & check "Transfer from Recording" field contents.

  • Create a flat file with tab delimiters or Excel file with fields you have to enter into tablecontrol.

  • Field space must be as in the SAP table & provide the values for it.

  • If QTY & CURRENCY fields are there then change those fields to text in Excel file.

  • Save it as xls file & then Save As txt file.

  • While executing the program, select txt file for Uploading the Datas into Tablecontrol.

Ex:- ME51 transaction

REPORT ZK_ME51_01_NEW NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE BDCRECX1.

DATA: BEGIN OF ITAB OCCURS 0,

NUMBER(3),

MATNR LIKE EBAN-MATNR,

TXZ01 LIKE EBAN-TXZ01,

MENGE(13) TYPE C,

WERKS LIKE EBAN-WERKS,

LGORT(4),

END OF ITAB.

DATA: TABCT(2) TYPE C, "LINES IN FLAT FILE

CTL TYPE I, "

CTL1 TYPE C,

CTL2(3),

FINAL(3) TYPE C VALUE '0', " LAST VALUE IN FLAT FILE

PG(5) TYPE C VALUE '10', " FOR INCREMENTING THE PAGES

TEMPVAL(20) TYPE C.

START-OF-SELECTION.

PERFORM GETDATA.

PERFORM OPEN_GROUP.

SORT ITAB BY NUMBER.

LOOP AT ITAB.

IF ITAB-NUMBER NE FINAL.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EBAN-BSART'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'EBAN-BSART'

'NB'.

PERFORM BDC_FIELD USING 'RM06B-LPEIN'

'T'.

MOVE 0 TO CTL1.

MOVE 0 TO CTL.

LOOP AT ITAB WHERE NUMBER = ITAB-NUMBER.

CTL = CTL + 1.

CTL2 = CTL.

IF CTL2 >= 10.

CTL1 = ''.

ENDIF.

IF CTL >= 19.

CTL2 = '19'.

ENDIF.

IF CTL2 >= 19.

PG = PG + 10.

ENDIF.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0106'.

PERFORM BDC_FIELD USING 'RM06B-BNFPO'

PG.

CONCATENATE 'eban-lgort(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-LGORT.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

CONCATENATE 'eban-matnr(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-MATNR.

CONCATENATE 'eban-menge(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-MENGE.

CONCATENATE 'eban-meins(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL 'EA'.

CONCATENATE 'rm06b-eeind(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL '27.07.2007'.

CONCATENATE 'eban-ekgrp(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL '000'.

CONCATENATE 'eban-matkl(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL '001'.

CONCATENATE 'eban-werks(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-WERKS.

CONCATENATE 'eban-lgort(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-LGORT.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0102'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EBAN-MENGE'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'EBAN-TXZ01'

ITAB-TXZ01." 'Lubricating oil'.

PERFORM BDC_FIELD USING 'EBAN-LGORT'

ITAB-LGORT. " '0001'.

PERFORM BDC_FIELD USING 'EBAN-MENGE'

ITAB-MENGE. " '200'.

PERFORM BDC_FIELD USING 'RM06B-EEIND'

'30.07.2007'.

PERFORM BDC_FIELD USING 'RM06B-LPEIN'

'D'.

PERFORM BDC_FIELD USING 'EBAN-EKGRP'

'003'.

PERFORM BDC_FIELD USING 'EBAN-BADAT'

'30.08.2007'.

PERFORM BDC_FIELD USING 'EBAN-DISPO'

'001'.

PERFORM BDC_FIELD USING 'EBAN-FRGDT'

'19.07.2007'.

PERFORM BDC_FIELD USING 'EBAN-WEBAZ'

'1'.

PERFORM BDC_FIELD USING 'EBAN-PREIS'

' 1.46'.

PERFORM BDC_FIELD USING 'EBAN-WAERS'

'USD'.

PERFORM BDC_FIELD USING 'EBAN-PEINH'

'1'.

PERFORM BDC_FIELD USING 'EBAN-REPOS'

'X'.

FINAL = ITAB-NUMBER.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0106'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RM06B-BNFPO'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BU'.

PERFORM BDC_TRANSACTION USING 'ME51'.

REFRESH BDCDATA.

ENDIF.

ENDLOOP.

PERFORM CLOSE_GROUP.

&----


*& Form GETDATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GETDATA .

CALL FUNCTION 'UPLOAD'

EXPORTING

CODEPAGE = ' '

FILENAME = ' '

FILETYPE = ' '

TABLES

DATA_TAB = ITAB

EXCEPTIONS

CONVERSION_ERROR = 1

INVALID_TABLE_WIDTH = 2

INVALID_TYPE = 3

NO_BATCH = 4

UNKNOWN_ERROR = 5

GUI_REFUSE_FILETRANSFER = 6

OTHERS = 7.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDFORM. " GETDATA

Reward points if helpful.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question