‎2008 May 31 4:48 AM
Hi Experts
I am new to the BDC, i have done a recording for CO08 transaction.
and generated the program also. can anyone edit this program, it can be helpful for me pls.
report ZTT1
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
*
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record,
data element: CO_KDAUF
KDAUF_001(010),
data element: CO_KDPOS
KDPOS_002(006),
data element: CO_MATNR
MATNR_003(018),
data element: WERKS_D
WERKS_004(004),
data element: CO_PWERK
PWERK_005(004),
data element: PP_AUFART
PP_AUFART_006(004),
data element: GAMNG
GAMNG_007(017),
data element: CO_GMEIN
GMEIN_008(003),
data element: CO_GLTRP
GLTRP_009(010),
data element: TERMKZ
TERKZ_010(001),
data element: FHORI
FHORI_011(003),
end of record.
End generated data section ***
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPLCOKO1' '0220'.
perform bdc_field using 'BDC_CURSOR'
'AFPOD-PWERK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'AFPOD-KDAUF'
record-KDAUF_001.
perform bdc_field using 'AFPOD-KDPOS'
record-KDPOS_002.
perform bdc_field using 'CAUFVD-MATNR'
record-MATNR_003.
perform bdc_field using 'CAUFVD-WERKS'
record-WERKS_004.
perform bdc_field using 'AFPOD-PWERK'
record-PWERK_005.
perform bdc_field using 'AUFPAR-PP_AUFART'
record-PP_AUFART_006.
perform bdc_dynpro using 'SAPLCOKO1' '0115'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'CAUFVD-GAMNG'.
perform bdc_field using 'CAUFVD-GAMNG'
record-GAMNG_007.
perform bdc_field using 'CAUFVD-GMEIN'
record-GMEIN_008.
perform bdc_field using 'CAUFVD-GLTRP'
record-GLTRP_009.
perform bdc_field using 'CAUFVD-TERKZ'
record-TERKZ_010.
perform bdc_field using 'CAUFVD-FHORI'
record-FHORI_011.
perform bdc_transaction using 'CO08'.
enddo.
perform close_group.
perform close_dataset using dataset.
Regards
Rajaram
‎2008 May 31 6:20 AM
Hi Raja Ram,
First of all, BDC is used to upload data into R/3 system. You recorded the Transaction and Generated program from it. Till then it is OK. But you have to upload the data, right. It should be from a flat file. You have to populate the internal table from that flat file. Then you have to loop the program generated by the SHDB Transaction. Then only data will be uploaded into R/3 system in sessions.
‎2008 May 31 6:57 AM
yea i know that, but what r the changes should be done in program and how to change inside loop.
‎2008 May 31 7:18 AM
hi
u have to do basic changes to upload data like ;
1. ur flat file (.txt file from which u will upload data) structure and ur ITAB in program must have same sequence according to fields and fields value .
2. comment all those perform statement which belongs to screen fields in which u r not required to enter data .
3.there r many techniques to modify a BDC program , i am sending u ur modified code as i use to modify my code .
check this
eport ZTT1
no standard page heading line-size 255.
include bdcrecx1.
*parameters: dataset(132) lower case.
*
o
+ DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*
*
o
+ Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record occurs 0,
* data element: CO_KDAUF
KDAUF_001(010),
* data element: CO_KDPOS
KDPOS_002(006),
* data element: CO_MATNR
MATNR_003(018),
* data element: WERKS_D
WERKS_004(004),
* data element: CO_PWERK
PWERK_005(004),
* data element: PP_AUFART
PP_AUFART_006(004),
* data element: GAMNG
GAMNG_007(017),
* data element: CO_GMEIN
GMEIN_008(003),
* data element: CO_GLTRP
GLTRP_009(010),
* data element: TERMKZ
TERKZ_010(001),
* data element: FHORI
FHORI_011(003),
end of record.
*
o
+ End generated data section ***
selection-screen begin of block blk3 with frame title text-019.
parameters : pa_fname type localfile.
selection-screen end of block blk3.
data : lv_fname type string.
at selection-screen on value-request for pa_fname.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'PA_FNAME'
importing
file_name = pa_fname.
start-of-selection.
lv_fname = pa_fname.
*perform open_dataset using dataset.
perform open_group.
call function 'GUI_UPLOAD'
exporting
filename = lv_fname
filetype = 'ASC'
has_field_separator = 'X'
tables
data_tab = RECORD
.
*do.
*read dataset dataset into record.
*if sy-subrc 0. exit. endif.
loop at record.
perform bdc_dynpro using 'SAPLCOKO1' '0220'.
perform bdc_field using 'BDC_CURSOR'
'AFPOD-PWERK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'AFPOD-KDAUF'
record-KDAUF_001.
perform bdc_field using 'AFPOD-KDPOS'
record-KDPOS_002.
perform bdc_field using 'CAUFVD-MATNR'
record-MATNR_003.
perform bdc_field using 'CAUFVD-WERKS'
record-WERKS_004.
perform bdc_field using 'AFPOD-PWERK'
record-PWERK_005.
perform bdc_field using 'AUFPAR-PP_AUFART'
record-PP_AUFART_006.
perform bdc_dynpro using 'SAPLCOKO1' '0115'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'CAUFVD-GAMNG'.
perform bdc_field using 'CAUFVD-GAMNG'
record-GAMNG_007.
perform bdc_field using 'CAUFVD-GMEIN'
record-GMEIN_008.
perform bdc_field using 'CAUFVD-GLTRP'
record-GLTRP_009.
perform bdc_field using 'CAUFVD-TERKZ'
record-TERKZ_010.
perform bdc_field using 'CAUFVD-FHORI'
record-FHORI_011.
perform bdc_transaction using 'CO08'.
*enddo.
endloop.
perform close_group.
*perform close_dataset using dataset.
check this my help u .
reward if helpful.
‎2009 May 19 12:49 PM