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
177

Iam new for table control in bdc.Please send small example.I tried with example from http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm.but i didnt get cler idea.Please help regarding this.

thanxs,

Abdul

1 ACCEPTED SOLUTION

FredericGirod
Active Contributor
0 Kudos
119

Hi,

table control have lines, you could address a particular line using a little addition at the end of the field.

For example, instead of LFBK-KOINH, if you would like to write in the first line you will use LFBK-KOINH(01), Second line LFBK-KOINH(02), ...

The first line in this case is not the first line of the table, but the first line visible. For example, some screen after inserting the first line, if you press ENTER, the second line will appear in the first (display) line. So you will have always to insert in the first line and use the key ENTER.

Rgd

Frédéric

4 REPLIES 4

Former Member
0 Kudos
119

Hi

When you need to fill a record of tc by BDC you have to indicate the index of the record.

For example if my tc has 10 records:

1 -


2 -


3 -


4 -


.......

10 -


If I need to fill the field FIELD of TC of record number 4:

PERFORM BDC_FIELD USING 'FIELD(04)'

VALUE.

If you have to fill several records

DATA: INDEX(2) TYPE N.

LOOP AT ITAB.

  • Here create the index

MOVE SY-TABIX TO INDEX.

CONCATENATE 'FIELD(' INDEX ')' INTO FIELD_NAME.

PERFORM BDC_FIELD USING 'FIELD(04)'

ITAB-VALUE.

ENDLOOP.

The problem is it can't often navigate (page down/up) in table control by BDC.

So in this case it usually works on the first line of tc.

Max

Former Member
0 Kudos
119

Hello Adbul,

U can try with this code.

REPORT zprataptable2

NO STANDARD PAGE HEADING LINE-SIZE 255.

DATA : BEGIN OF itab OCCURS 0,

i1 TYPE i,

lifnr LIKE rf02k-lifnr,

bukrs LIKE rf02k-bukrs,

ekorg LIKE rf02k-ekorg,

ktokk LIKE rf02k-ktokk,

anred LIKE lfa1-anred,

name1 LIKE lfa1-name1,

sortl LIKE lfa1-sortl,

land1 LIKE lfa1-land1,

akont LIKE lfb1-akont,

fdgrv LIKE lfb1-fdgrv,

waers LIKE lfm1-waers,

END OF itab.

DATA : BEGIN OF jtab OCCURS 0,

j1 TYPE i,

banks LIKE lfbk-banks,

bankl LIKE lfbk-bankl,

bankn LIKE lfbk-bankn,

END OF jtab.

DATA : cnt(4) TYPE n.

DATA : fdt(20) TYPE c.

DATA : c TYPE i.

INCLUDE bdcrecx1.

START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'C:\first1.txt'

filetype = 'DAT'

TABLES

data_tab = itab.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'C:\second.txt'

filetype = 'DAT'

TABLES

data_tab = jtab.

LOOP AT itab.

PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF02K-KTOKK'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RF02K-LIFNR'

itab-lifnr.

PERFORM bdc_field USING 'RF02K-BUKRS'

itab-bukrs.

PERFORM bdc_field USING 'RF02K-EKORG'

itab-ekorg.

PERFORM bdc_field USING 'RF02K-KTOKK'

itab-ktokk.

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-LAND1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFA1-ANRED'

itab-anred.

PERFORM bdc_field USING 'LFA1-NAME1'

itab-name1.

PERFORM bdc_field USING 'LFA1-SORTL'

itab-sortl.

PERFORM bdc_field USING 'LFA1-LAND1'

itab-land1.

PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-KUNNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKN(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

cnt = 0.

LOOP AT jtab WHERE j1 = itab-i1.

cnt = cnt + 1.

CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fdt.

PERFORM bdc_field USING fdt jtab-banks.

CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fdt.

PERFORM bdc_field USING fdt jtab-bankl.

CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fdt.

PERFORM bdc_field USING fdt jtab-bankn.

IF cnt = 5.

cnt = 0.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=P+'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKN(02)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

ENDIF.

ENDLOOP.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFB1-FDGRV'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFB1-AKONT'

itab-akont.

PERFORM bdc_field USING 'LFB1-FDGRV'

itab-fdgrv.

PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFB1-ZTERM'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFB5-MAHNA'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFM1-WAERS'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFM1-WAERS'

itab-waers.

PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF02K-LIFNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=YES'.

PERFORM bdc_transaction USING 'XK01'.

ENDLOOP.

PERFORM close_group.

FIle1:

1 63190 0001 0001 0001 mr bal188 b in 31000 a1 inr

2 63191 0001 0001 0001 mr bal189 b in 31000 a1 inr

File 2:

1 in sb 11000

1 in sb 12000

1 in sb 13000

1 in sb 14000

1 in sb 15000

1 in sb 16000

1 in sb 17000

1 in sb 18000

1 in sb 19000

1 in sb 20000

1 in sb 21000

1 in sb 22000

2 in sb 21000

2 in sb 22000

Don' forget to award points.

Regards,

Vasanth

Former Member
0 Kudos
119

Hai Abdul

Check the following Code

report Z_TAB_CONTRL_01

no standard page heading line-size 255.

data : begin of it_kna1 occurs 0,

kunnr like RF02D-KUNNR,

D0130 like RF02D-D0130,

end of it_kna1.

data : begin of it_kna2 occurs 0,

kunnr like RF02D-KUNNR,

BANKS like KNBK-BANKS,

BANKL like KNBK-BANKL,

BANKN like KNBK-BANKN,

koinh like KNBK-koinh,

end of it_kna2.

data : V_Count(2) type n.

data : V_Val(15).

include bdcrecx1.

start-of-selection.

perform Get_Data1.

perform Get_Data2.

perform open_group.

loop at it_kna1.

V_Count = '04'.

perform bdc_dynpro using 'SAPMF02D' '0106'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-D0130'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

'10002103'.

perform bdc_field using 'RF02D-D0130'

'X'.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_dynpro using 'SAPMF02D' '0130'.

loop at it_kna2 where kunnr = it_kna1-kunnr.

if v_count = '10'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_dynpro using 'SAPMF02D' '0130'.

v_count = '00'.

endif.

V_Count = V_Count + 1.

concatenate 'KNBK-KOINH(' V_Count ')' into V_Val.

perform bdc_field using 'BDC_CURSOR'

'KNBK-KOINH(09)'.

concatenate 'KNBK-BANKS(' V_Count ')' into V_Val.

perform bdc_field using V_Val

it_kna2-BANKS.

concatenate 'KNBK-BANKL(' V_Count ')' into V_Val.

perform bdc_field using V_Val

it_kna2-BANKL.

concatenate 'KNBK-BANKN(' V_Count ')' into V_Val.

perform bdc_field using V_Val

it_kna2-BANKN.

concatenate 'KNBK-KOINH(' V_Count ')' into V_Val.

perform bdc_field using V_Val

it_kna2-KOINH.

endloop.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_transaction using 'FD02'.

clear : it_kna1,it_kna2.

endloop.

perform close_group.

&----


*& Form Get_Data1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM Get_Data1 .

CALL FUNCTION 'UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = 'C:\tab_contl.txt'

FILETYPE = 'ASC'

  • 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 = it_kna1

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

&----


*& Form Get_Data2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM Get_Data2 .

CALL FUNCTION 'UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = 'C:\tab_cont1.txt'

FILETYPE = 'ASC'

  • 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 = it_kna2

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

Thanks & Regards

Sreenivasulu P

FredericGirod
Active Contributor
0 Kudos
120

Hi,

table control have lines, you could address a particular line using a little addition at the end of the field.

For example, instead of LFBK-KOINH, if you would like to write in the first line you will use LFBK-KOINH(01), Second line LFBK-KOINH(02), ...

The first line in this case is not the first line of the table, but the first line visible. For example, some screen after inserting the first line, if you press ENTER, the second line will appear in the first (display) line. So you will have always to insert in the first line and use the key ENTER.

Rgd

Frédéric