‎2009 Jan 11 10:18 AM
HI,
How to do BDC with table control.
I found the out the code from SDN but,
How to do the scrolling of the table control?.
From the code I found out I could only enter the data into the control until its not scrolled.
How to pass the excess data,
Please help me.
Regards
‎2009 Jan 11 2:19 PM
HI .. this is the simple program for table control in BDC ..
report ZBDC_XK01N
no standard page heading line-size 255.
DATA: BEGIN OF ITAB OCCURS 0,
lifnr like LFA1-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,
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
BANKS LIKE LFBK-BANKS,
BANKL LIKE LFBK-BANKL,
BANKN LIKE LFBK-BANKN,
KOINH LIKE LFBK-KOINH,
END OF ITAB2.
DATA COUNT TYPE CHAR2 .
DATA: T_BANKS(20), T_BANKL(20), T_BANKN(20), T_KOINH(20).
include bdcrecx1.
start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Documents and Settings\Administrator\Desktop\VENDOR.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = ITAB[].
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Documents and Settings\Administrator\Desktop\BANK.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = ITAB2[].
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform open_group.
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-BEGRU'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR count .
LOOP AT ITAB2 WHERE LIFNR = ITAB-LIFNR.
COUNT = COUNT + 1 .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = COUNT
IMPORTING
OUTPUT = COUNT.
CONCATENATE 'LFBK-BANKS(' COUNT ')' INTO T_BANKS .
CONCATENATE 'LFBK-BANKL(' COUNT ')' INTO T_BANKL .
CONCATENATE 'LFBK-BANKN(' COUNT ')' INTO T_BANKN .
CONCATENATE 'LFBK-KOINH(' COUNT ')' INTO T_KOINH .
CONDENSE: T_BANKS(20), T_BANKL(20), T_BANKN(20), T_KOINH(20).
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using T_BANKS
ITAB2-banks.
perform bdc_field using T_BANKL
ITAB2-BANKL.
perform bdc_field using T_BANKN
itab2-bankn.
perform bdc_field using T_KOINH
ITAB2-KOINH.
perform bdc_dynpro using 'SAPLBANK' '0100'.
perform bdc_field using 'BDC_OKCODE'
'/E'.
perform bdc_field using 'BDC_CURSOR'
'BNKA-BANKA'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'LFBK-BANKS(01)'
'IN'.
perform bdc_field using 'LFBK-BANKL(01)'
'YFFF'.
*
*
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(05)'.
perform bdc_field using 'BDC_OKCODE'
'ENTR'.
perform bdc_field using 'LFBK-BANKS(02)'
'in'.
perform bdc_field using 'LFBK-BANKS(03)'
'in'.
perform bdc_field using 'LFBK-BANKL(01)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(02)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(03)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(04)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(05)'
'YFFF'.
perform bdc_field using 'LFBK-BANKN(02)'
'768567577'.
perform bdc_field using 'LFBK-BANKN(03)'
'768567578'.
perform bdc_field using 'LFBK-BANKN(04)'
'768567579'.
perform bdc_field using 'LFBK-BANKN(05)'
'768567580'.
perform bdc_field using 'LFBK-KOINH(02)'
'kumar'.
perform bdc_field using 'LFBK-KOINH(03)'
'Arun'.
perform bdc_field using 'LFBK-KOINH(04)'
'abbc'.
perform bdc_field using 'LFBK-KOINH(05)'
'Sankar'.
perform bdc_field using 'LFBK-BANKS(04)'
'in'.
perform bdc_field using 'LFBK-BANKS(05)'
'in'.
IF COUNT = '05'.
CLEAR COUNT .
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=P+'.
ENDIF .
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'LFBK-BANKS(01)'
'in'.
perform bdc_field using 'LFBK-BANKL(01)'
'YFFF'.
perform bdc_field using 'LFBK-BANKN(01)'
'768567581'.
perform bdc_field using 'LFBK-KOINH(01)'
'Lgh'.
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'
'160000'.
perform bdc_field using 'LFB1-FDGRV'
'a1'.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFB1-ZTERM'
''.
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'
'=UPDA'.
perform bdc_field using 'LFM1-WAERS'
'inr'.
perform bdc_transaction using 'XK01'.
ENDLOOP.
perform close_group.
‎2009 Jan 11 11:20 AM
Hi ,
Yes initially u can ente data till the last row in the screen.If you want to add additional rows you have to write code for scroll bar.Just count the total no of current screen rows .If the data exceeds the total then do the page up.If you record u can get the code for page up.
‎2009 Jan 11 11:46 AM
hi,
Thnk for the answer,
How can I count the number of lines?
It varies from system to sytem.
It depends on the resolution of the screen
how can I get the values dynamically?
regards
‎2009 Jan 11 11:50 AM
Hi,
Instead of counting the number of lines getting displayed on the screen,
better do a page down for each record so that it will always give you the first visible line to enter the data.
This may help you better in resolving entering the data .... what ever may be number of lines in the internal table, the latest record will be displayed in the top line..........
Regards,
Venkatesh
‎2009 Jan 11 12:57 PM
hi,
I tried the same way but the problem is that
the first record is being changed everytime but did not go to next line.
i am getting the status message that
'SCROLLING IS POSSIBLE ONLY IF ALL LINES ARE FILLED'
regards
‎2009 Jan 11 1:57 PM
Hi,
Yes, a BDC made for a table control will work on that system only i.e., it depends on the number of lines in the table control, so that the screen may be scrolled to next page for further entries.
So, you can try executing BDC on your table control in module pool programming because you can take a specified number of lines and code appropiately.
Hope this helps you.
Thanks & Regards,
Tarun Gambhir
‎2009 Jan 11 2:17 PM
Hi Gambhir,
Ur ans is a bit convincing,
but the problem is that I am doing that for Vendor master update as there is no FM available for that to do in Backgrount task
could you help me in this regard
‎2009 Jan 11 2:19 PM
HI .. this is the simple program for table control in BDC ..
report ZBDC_XK01N
no standard page heading line-size 255.
DATA: BEGIN OF ITAB OCCURS 0,
lifnr like LFA1-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,
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
BANKS LIKE LFBK-BANKS,
BANKL LIKE LFBK-BANKL,
BANKN LIKE LFBK-BANKN,
KOINH LIKE LFBK-KOINH,
END OF ITAB2.
DATA COUNT TYPE CHAR2 .
DATA: T_BANKS(20), T_BANKL(20), T_BANKN(20), T_KOINH(20).
include bdcrecx1.
start-of-selection.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Documents and Settings\Administrator\Desktop\VENDOR.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = ITAB[].
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Documents and Settings\Administrator\Desktop\BANK.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = ITAB2[].
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform open_group.
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-BEGRU'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR count .
LOOP AT ITAB2 WHERE LIFNR = ITAB-LIFNR.
COUNT = COUNT + 1 .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = COUNT
IMPORTING
OUTPUT = COUNT.
CONCATENATE 'LFBK-BANKS(' COUNT ')' INTO T_BANKS .
CONCATENATE 'LFBK-BANKL(' COUNT ')' INTO T_BANKL .
CONCATENATE 'LFBK-BANKN(' COUNT ')' INTO T_BANKN .
CONCATENATE 'LFBK-KOINH(' COUNT ')' INTO T_KOINH .
CONDENSE: T_BANKS(20), T_BANKL(20), T_BANKN(20), T_KOINH(20).
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using T_BANKS
ITAB2-banks.
perform bdc_field using T_BANKL
ITAB2-BANKL.
perform bdc_field using T_BANKN
itab2-bankn.
perform bdc_field using T_KOINH
ITAB2-KOINH.
perform bdc_dynpro using 'SAPLBANK' '0100'.
perform bdc_field using 'BDC_OKCODE'
'/E'.
perform bdc_field using 'BDC_CURSOR'
'BNKA-BANKA'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'LFBK-BANKS(01)'
'IN'.
perform bdc_field using 'LFBK-BANKL(01)'
'YFFF'.
*
*
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(05)'.
perform bdc_field using 'BDC_OKCODE'
'ENTR'.
perform bdc_field using 'LFBK-BANKS(02)'
'in'.
perform bdc_field using 'LFBK-BANKS(03)'
'in'.
perform bdc_field using 'LFBK-BANKL(01)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(02)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(03)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(04)'
'YFFF'.
perform bdc_field using 'LFBK-BANKL(05)'
'YFFF'.
perform bdc_field using 'LFBK-BANKN(02)'
'768567577'.
perform bdc_field using 'LFBK-BANKN(03)'
'768567578'.
perform bdc_field using 'LFBK-BANKN(04)'
'768567579'.
perform bdc_field using 'LFBK-BANKN(05)'
'768567580'.
perform bdc_field using 'LFBK-KOINH(02)'
'kumar'.
perform bdc_field using 'LFBK-KOINH(03)'
'Arun'.
perform bdc_field using 'LFBK-KOINH(04)'
'abbc'.
perform bdc_field using 'LFBK-KOINH(05)'
'Sankar'.
perform bdc_field using 'LFBK-BANKS(04)'
'in'.
perform bdc_field using 'LFBK-BANKS(05)'
'in'.
IF COUNT = '05'.
CLEAR COUNT .
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=P+'.
ENDIF .
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'LFBK-BANKS(01)'
'in'.
perform bdc_field using 'LFBK-BANKL(01)'
'YFFF'.
perform bdc_field using 'LFBK-BANKN(01)'
'768567581'.
perform bdc_field using 'LFBK-KOINH(01)'
'Lgh'.
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'
'160000'.
perform bdc_field using 'LFB1-FDGRV'
'a1'.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFB1-ZTERM'
''.
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'
'=UPDA'.
perform bdc_field using 'LFM1-WAERS'
'inr'.
perform bdc_transaction using 'XK01'.
ENDLOOP.
perform close_group.
‎2009 Jan 11 2:57 PM
Hi,
Thnks for the code
But the point is that I dont have the value of COUNT
how can I get the value dynamically?
Is there any system variable which captures the default lines of Tbale control.
‎2009 Jan 11 11:28 PM
Dynamically ? No you must force the screen size :
You will know the number of rows of the table control by looking at the dynpro source (SE51). When you run the CALL TRANSACTION, force to use the standard screen size like this :
DATA ls_options TYPE CTU_PARAMS.
ls_options-defsize = 'X'.
CALL TRANSACTION 'XXX'
USING ...
OPTIONS FROM ls_options.For more information, see [abap documentation for DEFSIZE|http://help.sap.com/abapdocu/en/ABAPCALL_TRANSACTION_BDC_OPTIONS.htm]
‎2009 Jan 12 6:39 AM
hello
please check this link
https://wiki.sdn.sap.com/wiki/display/ABAP/bdcontable+control
thnaks
geeta gupta