2007 Dec 20 5:59 AM
Hi Experts,
I am new to table control in BDC.
So would you like to tell me why to use thsi and how to?
Any document if you have pls send me.
Thanks
2007 Dec 20 6:04 AM
Hi Sandeep.,
Table controls are used to display the data in tabular fashion for better visibility and for easy understanding in Screens as well as in reports.
syntax:
CONTROLS .
if you only want to determine the row of the table control. SY´-SUBRC allows you to check if the cursor is placed in a row of a table control.
u need to comment the performs of table control fields and write ur own perform statements. And u have to declare the table control fields as separate internal tables.
Go through this urls.
Check the below links.
just refer to the link below
http://www.sapmaterial.com/tablecontrol_sap.html
step by step procedure with screen shots
http://www.planetsap.com/howdo_a.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/content.htm
http://sap.niraj.tripod.com/id25.html
Also you can see the below examples...
Go to se38 and give demodynpro and press F4.
YOu will get a list of demo module pool programs.
One more T-Code is ABAPDOCU.
YOu can find more examples there.
See the prgrams:
DEMO_DYNPRO_TABLE_CONTROL_1 Table Control with LOOP Statement
DEMO_DYNPRO_TABLE_CONTROL_2 Table Control with LOOP AT ITAB
http://www.geocities.com/ZSAPcHAT
http://www.allsaplinks.com/files/using_table_in_screen.pdf
Check the below link.
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
THis is example to upload the Bank details of the Vendor which has the TC.
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: irst1.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.
Regards
Anji
Through Dialog prog
You can go through this document...
http://esnips.com/doc/48bd95e8-facc-4932-b923-465ba59bad24/Table-Control.pdf
refer this program.....
TABLES: kna1,knbk.
DATA: v_kunnr LIKE kna1-kunnr.
DATA: v_check TYPE c.
DATA: BEGIN OF it_knbk OCCURS 0,
banks LIKE knbk-banks,
bankl LIKE knbk-bankl,
bankn LIKE knbk-bankn,
bkont LIKE knbk-bkont,
koinh LIKE knbk-koinh,
chk TYPE c,
END OF it_knbk.
DATA: v_ucomm TYPE sy-ucomm,
v_dynnr TYPE sy-dynnr.
DATA: l_index TYPE sy-index.
data: count type i.
CONTROLS: tc1 TYPE TABLEVIEW USING SCREEN 0200.
*&----
*
*& Module STATUS_0100 OUTPUT
*&----
*
text
*----
*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ABC'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&----
*
*& Module USER_COMMAND_0100 INPUT
*&----
*
text
*----
*
MODULE user_command_0100 INPUT.
v_ucomm = sy-ucomm.
CASE v_ucomm.
WHEN 'DISP' OR 'CHNG'.
IF v_kunnr <> space.
SELECT banks
bankl
bankn
bkont
koinh
FROM knbk
INTO TABLE it_knbk
WHERE kunnr = v_kunnr.
LEAVE TO SCREEN '0200'.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&----
*
*& Module MOD_KUNNR INPUT
*&----
*
text
*----
*
MODULE mod_kunnr INPUT.
IF NOT v_kunnr IS INITIAL.
SELECT SINGLE
kunnr
FROM kna1
INTO v_kunnr
WHERE kunnr = v_kunnr.
IF sy-subrc <> 0.
MESSAGE e000(zz) WITH 'INCORRECT CUSTOMER NUMBER'.
ENDIF.
ENDIF.
IF v_kunnr IS INITIAL.
MESSAGE e000(zz) WITH 'PLEASE ENTER A VALUE'.
ENDIF.
ENDMODULE. " MOD_KUNNR INPUT
*&----
*
*& Module STATUS_0200 OUTPUT
*&----
*
text
*----
*
MODULE status_0200 OUTPUT.
SET PF-STATUS 'ABC1'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0200 OUTPUT
*&----
*
*& Module SCREENMOD OUTPUT
*&----
*
text
*----
*
MODULE screenmod OUTPUT.
IF v_ucomm = 'DISP'.
LOOP AT SCREEN.
screen-input = 0.
MODIFY SCREEN.
ENDLOOP.
ELSE."if v_UCOMM = 'CHNG'.
LOOP AT SCREEN.
IF screen-group1 = 'G1'.
screen-input = 0.
ELSE.
screen-input = 1.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
endif.
if sy-ucomm = 'INSE'.
loop at screen.
IF ( tc1-current_line <> tc1-lines ).
screen-input = 0.
else.
screen-input = 1.
modify screen.
endif.
endloop.
endif.
ENDMODULE. " SCREENMOD OUTPUT
*&----
*
*& Module EXIT2 INPUT
*&----
*
text
*----
*
MODULE exit2 INPUT.
LEAVE TO SCREEN 0.
ENDMODULE. " EXIT2 INPUT
*&----
*
*& Module modify INPUT
*&----
*
text
*----
*
MODULE modify INPUT.
IF v_check = 'X'.
it_knbk-chk = 'X'.
MODIFY it_knbk index tc1-current_line.
ELSE.
CLEAR it_knbk-chk .
ENDIF.
ENDMODULE. " modify INPUT
*&----
*
*& Module USER_COMMAND_0200 INPUT
*&----
*
text
*----
*
MODULE user_command_0200 INPUT.
v_ucomm = sy-ucomm.
CASE v_ucomm.
WHEN 'DELE'.
DELETE it_knbk where chk eq 'X'.
DESCRIBE TABLE it_knbk LINES tc1-lines.
WHEN 'INSE'.
CLEAR it_knbk.
APPEND it_knbk.
DESCRIBE TABLE it_knbk LINES tc1-lines.
WHEN 'LIST'.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN '0200'.
WRITE 'Report'.
WHEN 'BACK'.
LEAVE TO SCREEN '0100'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*&----
*
*& Module validate INPUT
*&----
*
text
*----
*
module validate input.
IF IT_KNBK IS INITIAL.
MESSAGE E000(ZZ) WITH 'A BLANK LINE CANNOT BE SAVED'.
ENDIF.
endmodule. " validate INPUT
Reward points if useful
2007 Dec 20 6:04 AM
the table conntrol in bdc is for storing n no of line items
As the line items are numerous we have incorporated a scroll facility
The BDc code needs the following changes :
CONCATENATE 'EQUK-BDATU(' lv_max1 ')' INTO lv_fnam.
PERFORM bdc_field USING lv_fnam
lv_bdatu1.
this will insert the value in lv_bdatu1 into EQUK_BDATU(01)
EQUK_BDATU(02)
2007 Dec 20 6:10 AM
Hi,
Each and every row of a table control is identified in BDC as,
Table_control_name(row_no).
coloumn as ,
Table_control_name(row_no)-coloumn.
Hence to populate values, u need to declare a variable of type Num.. Keep incrementing this value for each and every record.
concatenate the table name ( number ) - couloumn, and pass the value,
Regards,
Niyaz