‎2007 Jan 30 10:00 AM
Hi All,
Could you please help out me for a sample BDC (Upload Program)
using DATA SETS i.e. the data should be retrieved from the Application Server for any one Transaction
Note: not through the Uploads from Desktop.
Thanks & Regards,
Rajesh.K
‎2007 Jan 30 10:06 AM
types:
Begin of ty_input,
line(100),
end of ty_input,
begin of ty_mat,
mtart type mara-mtart,
mbrsh type mara-mbrsh,
maktx type makt-maktx,
meins type mara-meins,
end of ty_mat.
data:
it_input type standard table of ty_input with header line,
it_mat type standard table of ty_mat with header line,
it_bdcdata type standard table of bdcdata with header line.
data:
v_file type string value '/usr/tmp/a.txt'.
start-of-selection.
open dataset v_file for input in text mode default encoding.
if sy-subrc <> 0.
exit.
else.
do.
read dataset v_file into it_input.
if sy-subrc <> 0.
exit.
else.
append it_input.
clear it_input.
endif.
enddo.
endif.
close dataset v_file.
******
Loop at it_input.
split it_input-line at ',' into it_mat-mbrsh it_mat-mtart it_mat-maktx it_mat-meins
into it_mat.
append it_mat.
endloop.
********
loop at it_mat.
Perform mapping.
call transaction 'MM01' using it_bdcdata
mode <A/E/N>
update <S/A/L>.
refresh it_bdcdata.
endloop.
‎2007 Jan 30 11:01 AM
see the below thread, it will have the sample code also for MM01 BDC
http://www.sap-img.com/abap/learning-bdc-programming.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/fa/097119543b11d1898e0000e8322d00/frameset.htm
http://myweb.dal.ca/hchinni/sap/bdc_home.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&;
http://www.sap-img.com/abap/learning-bdc-programming.htm
http://www.sapdevelopment.co.uk/bdc/bdchome.htm
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
‎2007 Jan 30 11:12 AM
Hi,
1)OPEN DATASET stmt is used to open a file on applicaiton server either for reading or writing.
2)READ DATASET - when we open a file for reading/uploading we use READ DATASET stmt.
Eg: READ DATASET <dsn> INTO <wa>.
TRANSFER - is the statement we use for writing data to a file.
3)Source Code:
a)Reading Data from Application Server:
open dataset fname for input in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', fname.
else.
do.
read datasset fname into <wa>.
if sy-subrc ne o.
exit.
else.
append <wa> to itab.
endif.
close dataset fname.
enddo.
endif.
b)Writing Data to Application Server:
open dataset fname for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', fname.
else.
loop at itab.
transfer itab to fname.
endloop.
close dataset fname.
endif.
Look at the below link, it is having the code with the use of OPEN DATA SET(Application Server)
http://www.sap-img.com/abap/sample-abap-code-on-bapi-po-change.htm
<b>*Transfer the data to application server
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT IT_VENDOR INTO WA_VENDOR.
TRANSFER WA_VENDOR TO FNAME.
ENDLOOP.
CLOSE DATASET FNAME.
again data is read from the application server to interna table
OPEN DATASET FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
READ DATASET FNAME INTO STR.
SPLIT STR AT HORIN INTO WA_VENDOR-LIFNR WA_VENDOR-BUKRS WA_VENDOR-EKORG WA_VENDOR-KTOKK.
APPEND WA_VENDOR TO IT_VENDOR .
CLOSE DATASET FNAME.
After writing the data into application server goto transaction AL11 & see ur txt file there
</b>
‎2007 Jan 30 11:14 AM
Hi rajesh,
YOu requirement can be split into two parts.
1) Get the data from the application server into an Internal table and
2) Do a BDC for any transaction.
For step 1, you have to use OPEN DATASET <File name> for input in text mode.
then use READ dataset to get the data into the internal table and finally close the file using close dataset.
open dataset dsn for input in text mode.
if sy-subrc = 0.
do.
read dataset dsn into itab-data.
if sy-subrc = 0.
append itab.
clear itab.
else.
exit.
endif.
enddo.
close dataset dsn.
endif.
For 2, refer this example
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Regards,
Ravi