‎2005 Jun 23 4:53 AM
Hi All,
Doing BDC on XD01. At screen 103 there is a table control to enter data related to bank.
Before this I have started a thread but I was totally confused. Kindly tell me how to handle this issue.
I am attatching my complete code.
Regards,
Dilip
report ZBDC_XD01
no standard page heading line-size 255.
include bdcrecx1.
DATA : BEGIN OF IT_DATA OCCURS 1,
KUNNR LIKE RF02D-KUNNR,
BUKRS LIKE RF02D-BUKRS,
KTOKD LIKE RF02D-KTOKD,
ANRED LIKE KNA1-ANRED,
NAME1 LIKE KNA1-NAME1,
ORT01 LIKE KNA1-ORT01,
LAND1 LIKE KNA1-LAND1,
SPRAS(2) type c ,
SORTL LIKE KNA1-SORTL,
PSTLZ LIKE KNA1-PSTLZ,
LZONE LIKE KNA1-LZONE,
AKONT LIKE KNB1-AKONT,
CD LIKE KNBK-BANKN,
CUST LIKE KNBK-BANKL ,
BANK LIKE KNBK-BANKS,
END OF IT_DATA.
DATA :X TYPE I, Y TYPE I,Z(10) TYPE C,HNAME(100) TYPE C.
DATA STR TYPE STRING.
PARAMETERS: infile LIKE rlgrap-filename OBLIGATORY .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR INFILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = INFILE.
STR = INFILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = STR
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
start-of-selection.
perform open_group.
LOOP AT IT_DATA.
perform bdc_dynpro using 'SAPMF02D' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KTOKD'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
IT_DATA-KUNNR.
perform bdc_field using 'RF02D-BUKRS'
IT_DATA-BUKRS.
perform bdc_field using 'RF02D-KTOKD'
IT_DATA-KTOKD.
perform bdc_dynpro using 'SAPMF02D' '0110'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-PSTLZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-ANRED'
IT_DATA-ANRED.
perform bdc_field using 'KNA1-NAME1'
IT_DATA-NAME1.
perform bdc_field using 'KNA1-SORTL'
IT_DATA-SORTL.
perform bdc_field using 'KNA1-ORT01'
IT_DATA-ORT01.
perform bdc_field using 'KNA1-PSTLZ'
IT_DATA-PSTLZ.
perform bdc_field using 'KNA1-LAND1'
IT_DATA-LAND1.
perform bdc_field using 'KNA1-SPRAS'
IT_DATA-SPRAS.
perform bdc_dynpro using 'SAPMF02D' '0120'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-LZONE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-LZONE'
IT_DATA-LZONE.
perform bdc_dynpro using 'SAPMF02D' '0125'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-UMJAH'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0340'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0370'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'KNA1-CIVVE'
'X'.
perform bdc_dynpro using 'SAPMF02D' '0360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0210'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-AKONT'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'KNB1-AKONT'
IT_DATA-AKONT.
perform bdc_transaction using 'XD01'.
ENDLOOP.
perform close_group.
‎2005 Jun 23 5:17 AM
Hi,
For table controls (and step loops), the field names are the same for every row. The fields must be accessed using an index e.g. <tabctrl>-field(1), <tabctrl>-field(2), and so on.
Do keep in mind that only the visible fields on the screen can be filled with data. If you have to fill fields that go beyond normal display, you will have to record paging as well. For page down, you could use function code "/23" .
Hope it helps.
Regards
Shehryar
‎2005 Jun 23 5:41 AM
Hi Shehryar,
Thanks for your reply.
Tell me if I have to insert 5 records in table control, it it required to hardcode?
Reagrds,
Dilip
‎2005 Jun 23 5:45 AM
Hi,
IF you have recorded for entering one record then the same can be used for entering multiple records for the same set of conditions, which indeed needs to be hardcoded.
Regards,
Jagath.
‎2005 Jun 23 6:54 AM
Hi Dilip,
yes you've to use an index as ... said
and NOT hardcoded:
perRFORM bdc_dynpro USING 'SAPMF02D' '0130'.
DO x TIMES. " x= 5
ADD 1 TO counter.
UNPACK counter to index."index = char02
CONCATENATE 'KNBK-BANKS(' index ')' INTO hname. "cursor
-> result: of hname in first loop = KNBK-BANKS(01)
so cursor is in line 1 of TC
...
regards Andreas
‎2005 Jun 23 8:56 AM
Hi ,
Following is my code, but it is not working in proper way. It directly goes to second screen, instead of 2nd line of table control.
Is there anything I am missing?
Regards,
Dilip
data declaration used.
DATA :X TYPE I, Y TYPE I,Z(10) TYPE C,HNAME(100) TYPE C.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
DO x TIMES.
ADD 1 TO y.
UNPACK y TO z.
CONCATENATE 'KNBK-BANKS(' z ')' INTO hname.
PERFORM bdc_field USING 'BDC_CURSOR' hname.
PERFORM bdc_field USING hname IT_DATA-BANK.
CONCATENATE 'KNBK-BANKL(' z ')' INTO hname.
PERFORM bdc_field USING hname IT_DATA-CUST.
CONCATENATE 'KNBK-BANKN(' z ')' INTO hname.
PERFORM bdc_field USING hname IT_DATA-CD.
ENDDO.
‎2005 Jun 23 9:37 AM
Hi Dilip,
where you have the multiple bank-data ?
e.g.:
Kunnr banks bankl bankn
4711 DE 12345678 12345
4711 DE 23456789 23456
...
4711 US 11111111 55555in table it_data ?
-> that table you've to loop
and replace the the do-loop
regards Andreas
‎2005 Jun 23 9:58 AM
Hi,
Do you mean that I should fetch the bank data in separate internal table?
Following is my it_data structure.
DATA : BEGIN OF IT_DATA OCCURS 1,
KUNNR LIKE RF02D-KUNNR,
BUKRS LIKE RF02D-BUKRS,
KTOKD LIKE RF02D-KTOKD,
ANRED LIKE KNA1-ANRED,
NAME1 LIKE KNA1-NAME1,
ORT01 LIKE KNA1-ORT01,
LAND1 LIKE KNA1-LAND1,
SPRAS(2) type c ,
SORTL LIKE KNA1-SORTL,
PSTLZ LIKE KNA1-PSTLZ,
LZONE LIKE KNA1-LZONE,
AKONT LIKE KNB1-AKONT,
CD LIKE KNBK-BANKN,
CUST LIKE KNBK-BANKL ,
BANK LIKE KNBK-BANKS,
END OF IT_DATA.
DATA :X TYPE I, Y TYPE I,Z(10) TYPE C,HNAME(100) TYPE C.
Regards,
Dilip
‎2005 Jun 23 10:10 AM
Hi,
data y type i value 1.
data z type c(2).
Loop at IT_DATA.
UNPACK y TO z.
CONCATENATE 'KNBK-BANKS(' z ')' INTO hname.
PERFORM bdc_field USING 'BDC_CURSOR' hname.
PERFORM bdc_field USING hname IT_DATA-BANK.
CONCATENATE 'KNBK-BANKL(' z ')' INTO hname.
PERFORM bdc_field USING hname IT_DATA-CUST.
CONCATENATE 'KNBK-BANKN(' z ')' INTO hname.
PERFORM bdc_field USING hname IT_DATA-CD.
y = y + 1.
endloop.
Check this link.In this, exactly they are doing what you want.
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Message was edited by: Jayanthi Jayaraman
‎2005 Jun 23 3:48 PM
Hi Jayanti,
As shown on the link I modify the program, but it is taking only first two fields in the text file. Here I am using GUI_UPLOAD function to upload data.
Here it-dummy contains only 2 records in first line and only first column for remaining data.
With WS_UPLOAD it is ok.
Regards,
Dilip
str type string.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = str
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
tables
data_tab = it_dummy.
‎2005 Jun 24 7:35 AM
Hi Diliip,
Did you mean it is taking only one record?In that only two fields.Could you give your complete code?Are you sure that it is working properly in WS_UPLOAD the same file you are uploading.Clarify me this point.