Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

which to use in BDC programming ??

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member186741
Active Contributor
0 Kudos

Hi Rad,

basically what you done is use the 'call transaction' approach already. This is fine for low volumes or once off procedures. If you are processing high volumes or need a regular procedure BDC is the way to go. BDC allows you to create batch(es) of transactions which you can release, re-run, monitor, check logg of etc at your convenience. Transaction SM35 controls BDC sessions but you create can them in your program.

The program you have already written only needs to be changed slightly to start creating BDC sessions.

You need to use BDC_OPEN_GROUP to initiate a session (can be used only once at start of program or can be used n times say every 1000 transactions).

BDC_INSERT should be used instead of 'call transaction, this will add the current transactions screens and data to the current BDC session'.

Finally, BDC_CLOSE_GROUP can be used to close off a session (again this can be used once at end of program or at the end of each set of transactions).

Often, programmers code parameters so that they can decide which mode to run their program in and can easily toggle between 'call transaction' and BDC when testing.

Regards

Neil

4 REPLIES 4

Former Member
0 Kudos

Check out this document. This covers most aspects of BDC programming -

http://www.sappoint.com/abap/bdcconcept.pdf

former_member186741
Active Contributor
0 Kudos

Hi Rad,

basically what you done is use the 'call transaction' approach already. This is fine for low volumes or once off procedures. If you are processing high volumes or need a regular procedure BDC is the way to go. BDC allows you to create batch(es) of transactions which you can release, re-run, monitor, check logg of etc at your convenience. Transaction SM35 controls BDC sessions but you create can them in your program.

The program you have already written only needs to be changed slightly to start creating BDC sessions.

You need to use BDC_OPEN_GROUP to initiate a session (can be used only once at start of program or can be used n times say every 1000 transactions).

BDC_INSERT should be used instead of 'call transaction, this will add the current transactions screens and data to the current BDC session'.

Finally, BDC_CLOSE_GROUP can be used to close off a session (again this can be used once at end of program or at the end of each set of transactions).

Often, programmers code parameters so that they can decide which mode to run their program in and can easily toggle between 'call transaction' and BDC when testing.

Regards

Neil

0 Kudos

Thanks Neil. You explained it well..

0 Kudos

you are welcome Rad. Thanks for awarding the points!