Skip to Content
0
Former Member
Dec 01, 2005 at 09:31 PM

which to use in BDC programming ??

28 Views

Back again...

Based on your suggestions on BDC, I successfully tried BDC on a couple of insert as well update transactions with my data in a CSV file and it worked well !! thanks to all..

I have trouble understanding the different ways each one of you is adoptiong to present the solution...

I followed this and found very simple..

1. Recorded the transaction using SHDB. Created a program transferred from recording.

2. Added my file upload logic and saved data in an internal table.

3. Iterated the internal table in a loop and used itab-fieldname in palce of the constant data . so i had all perform statements inside my loop..Hoep u get it..

This I find very simple.. find attached my code on BDC for MM02.

But some of you have advised me to use BDC_INSERT, CALL_TRANSACTION etc. Whats the difference ? Are there scenarios when my simplest procedure wont work and I need to follow ur advise ??

Please explain ..

thanks

-


report ZBDC2

no standard page heading line-size 255.

include bdcrecx1.

Tables: RMMG1, MAKT.

types: begin of tdata,

rec(150) type c,

end of tdata,

begin of tmtgp,

matnr LIKE RMMG1-MATNR,

maktx LIKE MAKT-MAKTX,

end of tmtgp.

data: idata type table of tdata with header line.

data: imtgp type table of tmtgp with header line.

selection-screen begin of block b1 with frame title text-001.

parameters: p_file type localfile default 'C:\mm02_data_csv.csv'.

selection-screen end of block b1.at selection-screen on value-request

for p_file.

call function 'KD_GET_FILENAME_ON_F4'

exporting static = 'X'

changing file_name = p_file.

start-of-selection.

perform upload_data.

loop at imtgp.

perform open_group.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MATNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RMMG1-MATNR'

imtgp-matnr.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(02)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(02)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

imtgp-maktx.

perform bdc_field using 'MARA-MEINS'

'EA'.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

imtgp-maktx.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

perform bdc_transaction using 'MM02'.

perform close_group.

endloop.

form upload_data.

data: filename type string.

clear idata.

refresh idata.

filename = p_file.

call function 'GUI_UPLOAD'

exporting filename = filename

filetype = 'ASC'

tables data_tab = idata

exceptions file_open_error = 1

file_read_error = 2

no_authority = 6

others = 17.

check sy-subrc = 0.

loop at idata.

clear imtgp.

split idata at ',' into imtgp-matnr imtgp-maktx.

append imtgp.

endloop.

endform.