Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Table control in bdc

Former Member
0 Kudos

hi i need material regarding table control in bdc... please help me out with study material

1 REPLY 1

Former Member
0 Kudos

Anupama,

First of all welcome to SDN.

ya for the docuementation check this link below

http://sap.niraj.tripod.com/id29.html

for sample coding check further links.....

what ever the data that u want to trnasfer to table ctrl, put it in a flat file.

create an internal able that can occupy those datas.

then transfer from internal table to table control.

ex: for me41/.

REPORT YELS_ME41_BDC_V NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE BDCRECX1.

  • INTERNAL TABLE DECLARATION.

DATA : BEGIN OF ITAB OCCURS 0,

V_NUM(3) TYPE C,"SERIAL NUMBER

EMATN LIKE EKPO-EMATN,

TXZ01 LIKE EKPO-TXZ01,

ANMNG(13) TYPE C,

MEINS(3) TYPE C,

LPEIN LIKE RM06E-LPEIN,

EEIND LIKE RM06E-EEIND,

MATKL LIKE EKPO-MATKL,

END OF ITAB.

  • VARIABLE DECLARATION

DATA : V_LASTNUM(3) TYPE C,

V_TEMPVAR(15),

V_PAGES(3) TYPE C VALUE '10',

V_COUNT TYPE I,

V_CTR TYPE I,

V_TCTR(2) TYPE C,

V_TEST TYPE C VALUE 0,

ITEM LIKE RM06E-EBELP.

*DATA: BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE.

  • BEGIN OF PROGRAM.

START-OF-SELECTION.

PERFORM GET-DATA.

SORT ITAB BY NUM EEIND.

PERFORM OPEN_GROUP.

*DATA TRANSFERRED FROM INTERNAL TABLE TO IST 2ND SCREEN FIELDS(HEADER

*DATA)

LOOP AT ITAB.

IF ITAB-V_NUM NE V_LASTNUM.

" HEADER DATA EXECUTES FOR ONLY ONE TIME FOR ONE RFQ GENERATION

  • WHEN SNO IS NOT EQUAL TO LASTNUMBER. THEN PROCEED.

V_TEST = 0.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0300'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EKKO-ANGDT'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'RM06E-ASART'

'AN'. "RFQ TYPE.

PERFORM BDC_FIELD USING 'EKKO-SPRAS'

'EN'. " LANGUAGE KEY.

PERFORM BDC_FIELD USING 'RM06E-ANFDT'

'19.07.2007'."RFQ DATE.

PERFORM BDC_FIELD USING 'EKKO-ANGDT'

'29.07.2007'."QUOTATION DEAD LINE.

PERFORM BDC_FIELD USING 'EKKO-EKORG'

'3000'."PURCHASE ORGANISATION.

PERFORM BDC_FIELD USING 'EKKO-EKGRP'

'003'."PURCHASE GROUP.

PERFORM BDC_FIELD USING 'RM06E-LPEIN'

'T'.

  • IIND SCREEN.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0301'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EKKO-SUBMI'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'BU'.

PERFORM BDC_FIELD USING 'EKKO-EKGRP'

'003'.

PERFORM BDC_FIELD USING 'EKKO-PINCR'

'10'." ITEM INTERVAL.

PERFORM BDC_FIELD USING 'EKKO-SUBMI'

'1'." COLL NO.

PERFORM BDC_FIELD USING 'EKKO-SPRAS'

'EN'.

PERFORM BDC_FIELD USING 'EKKO-UPINC'

'1'." SUB ITEM INTERVAL.

PERFORM BDC_FIELD USING 'EKKO-ANGDT'

'29.07.2007'.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0301'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EKKO-EKGRP'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'EKKO-EKGRP'

'003'.

PERFORM BDC_FIELD USING 'EKKO-PINCR'

'10'.

PERFORM BDC_FIELD USING 'EKKO-SUBMI'

'1'.

PERFORM BDC_FIELD USING 'EKKO-UPINC'

'1'.

PERFORM BDC_FIELD USING 'EKKO-ANGDT'

'29.07.2007'.

**********tab ctrl*********************************************

  • IIIRD SCREEN

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0320'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RM06E-EEIND(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'EKKO-ANGDT'

'29.07.2007'.

  • DATA MOVED FROM INTERNAL TABLE TO TABLE CONTROL

*

V_CTR = 0.

"FOR ONE RFQ , MORE ITEMS WILL BE THERE. COUNT STARTS HERE.

LOOP AT ITAB WHERE V_NUM = ITAB-V_NUM." CHECK THE SNO IS EQUAL .

V_CTR = V_CTR + 1." COUNT IS INCREMENTED BY 1.

  • MY TAB CTRL CAN HAVE ONLY 20 RECORDS.

  • IF COUNT IS LESS THAN OR EQUAL TO 20 ASSIGN THIS VALUE TO TCTR VAR

IF V_CTR <= 20.

V_TCTR = V_CTR.

ENDIF.

*IF COUNT IS GREATER THAN 20 ASSIGN THIS VALUE TO TCTR VAR

IF V_CTR > 20.

V_TCTR = '20'.

ENDIF.

  • IF COUNT IS LESS THAN OR EQUAL TO 10 BLANK SPACE IS ALLOTTED TO TEST

  • VAR.

IF V_CTR >= 10.

V_TEST = ''.

ENDIF.

  • WHEN COUNT IS LESS THAN 20 THEN ITEM (PAGES) WILL BE 10.

IF V_CTR < 20.

V_PAGES = 10.

PERFORM BDC_FIELD USING 'RM06E-EBELP'

V_PAGES.

ENDIF.

  • WHEN COUNT IS GREATER THAN 20 THEN ITEM (PAGES) WILL BE INCREMENTED BY

  • 10 FOR EVERY ENTRY..

IF V_CTR >= 20.

V_PAGES = V_PAGES + 10.

PERFORM BDC_FIELD USING 'RM06E-EBELP'

V_PAGES.

ENDIF.

  • CONCTAENATION IS DONE TO GET A PATTERN LIKE EKPO-EMATN(01).

  • UPLOAD EMATN FIELD INTO TABLE CONTROL

CONCATENATE 'ekpo-ematn(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING V_TEMPVAR ITAB-EMATN.

  • UPLOAD SHORT TEXT FIELD INTO TABLE CONTROL

CONCATENATE 'ekpo-txz01(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING V_TEMPVAR ITAB-TXZ01.

  • UPLOAD QUANTITY FIELD INTO TABLE CONTROL

CONCATENATE 'rm06e-anmng(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING V_TEMPVAR ITAB-ANMNG.

  • UPLOAD UNIT OF MEASURE FIELD INTO TABLE CONTROL

CONCATENATE 'ekpo-meins(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING V_TEMPVAR ITAB-MEINS.

  • UPLOAD DATE FORMAT FIELD INTO TABLE CONTROL

CONCATENATE 'rm06e-lpein(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING V_TEMPVAR ITAB-LPEIN.

  • UPLOAD DATE FIELD INTO TABLE CONTROL

CONCATENATE 'rm06e-eeind(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING V_TEMPVAR ITAB-EEIND.

  • UPLOAD MATERIAL GROUP FIELD INTO TABLE CONTROL

CONCATENATE 'EKPO-MATKL(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING V_TEMPVAR ITAB-MATKL.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0320'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EKKO-ANGDT'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=LS'.

PERFORM BDC_FIELD USING 'EKKO-ANGDT'

'29.07.2007'.

*AFTER INSERTING ONE ROW OF DATA PRESS ENTER .CURSOR SHOULD BE AT DEAD

*LINE DATE.

CONCATENATE 'ekpo-ematn(' V_TEST V_TCTR ')' INTO V_TEMPVAR.

CONDENSE V_TEMPVAR NO-GAPS.

PERFORM BDC_FIELD USING 'BDC_CURSOR' V_TEMPVAR.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

ENDLOOP.

*************************vendor addr*******************

V_LASTNUM = ITAB-V_NUM.

*******ENTER VENDOR NUMBER AND SAVE.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0140'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EKKO-LIFNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'EKKO-LIFNR'

'9054'." VENDOR NUMBER.

PERFORM BDC_DYNPRO USING 'SAPLMEXF' '0100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTE'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RM06E-SPRAS'.

PERFORM BDC_FIELD USING 'BUTTON_INIT'

'X'.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0140'.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0140'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EKKO-LIFNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BU'.

PERFORM BDC_FIELD USING 'EKKO-LIFNR'

'9054'.

PERFORM BDC_FIELD USING 'ADDR1_DATA-NAME1'

'tttt'.

PERFORM BDC_FIELD USING 'ADDR1_DATA-SORT1'

'TT'.

PERFORM BDC_FIELD USING 'ADDR1_DATA-COUNTRY'

'AZ'.

PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=YES'.

PERFORM BDC_TRANSACTION USING 'ME41'.

REFRESH BDCDATA.

ENDIF.

ENDLOOP.

PERFORM CLOSE_GROUP.

&----


*& Form get-data

&----


  • UPLOAD FLAT FILES TO INTERNAL TABLE.

----


FORM GET-DATA.

*TRANSFER DATA FROM FLAT FILE TO INTERNAL TABLE.

CALL FUNCTION 'UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = ' '

FILETYPE = ' '

  • ITEM = ' '

  • FILEMASK_MASK = ' '

  • FILEMASK_TEXT = ' '

  • FILETYPE_NO_CHANGE = ' '

  • FILEMASK_ALL = ' '

  • FILETYPE_NO_SHOW = ' '

  • LINE_EXIT = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • SILENT = 'S'

  • IMPORTING

  • FILESIZE =

  • CANCEL =

  • ACT_FILENAME =

  • ACT_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. "get-data

Look at the below links for example programs

http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm

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