‎2007 Aug 07 11:11 AM
‎2007 Aug 07 11:26 AM
Hi,
yes we can write BDC program in a report
basically we use reports to do BDC's
reward points if helpful
thanks & regards,
venkatesh
‎2007 Aug 07 11:26 AM
Hi,
yes we can write BDC program in a report
basically we use reports to do BDC's
reward points if helpful
thanks & regards,
venkatesh
‎2007 Aug 07 11:26 AM
‎2007 Aug 07 11:28 AM
Hi,
you can use
call transaction tcode using bdcdata
mode 'N' update 'S' messages into bdcmsgcoll
or
use fms
bdc_opengroup
bdc_insert
bdc_closegroup for session methods,
reward points if helpful
thanks & regards,
venkatesh
‎2007 Aug 07 11:38 AM
Hi Pradeep,
BDC can be done in following ways.
You can do BDC recording from SHDB transaction and use that source code in your report.
or
Create a table for bdc with BDCDATA strucutre and message class with BDCMSGCOLL strucuture and call transaction you want.
or
use function module..
bdc_open_group
bdc_insert_group
Bdc_close_group
to create BDC session and user can execute from SM35 Tcode.
Reward points if it helps,
cheers,
phani
‎2007 Aug 07 11:50 AM
this is code for BDC upload in Report:
Procedure
Give the t-code shdb in the command field.
Click the new recording button.
Give a name to the recording and the t-code you want to record.
E.g.:
Recording : ZMAT_UPLOAD
Transaction code : MM01
When you click save, it takes you to t-code (MM01) you would like to do recording for upload.
Record carefully. Fill in the details you want to upload. In this case I have entered the material no, industry sector, material type, material description and basic unit of measure.
Then the Transaction recorder edit recording ZMAT_UPLOAD screen is displayed. You can edit your recording or just save it and click back button.
Select your recording and click create program button.
Enter the program name say ZMAT_UPLOAD.Select the transfer from recording option. Save it.Give the program title, type as executable program and click source code button at the bottom.
The following piece of code is generated automatically.
report ZMAT_UPLOAD
no standard page heading line-size 255.
include bdcrecx1.
start-of-selection.
perform open_group.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
'MYMATERIAL10'.
perform bdc_field using 'RMMG1-MBRSH'
'P'.
perform bdc_field using 'RMMG1-MTART'
'ZOH'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
'MY MATERIAL10'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
'G'.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
perform bdc_transaction using 'MM01'.
Perform close_group.
From the above code it is clear that recording has been created using matnr = mymaterial10 , industry sector = p , material type = zoh , description = my material10 , basic unit of measure = g. For our case I have assumed industry sector and material type to be constant and have not included in flat file.
The colored lines in the below code are the changes made to the sap generated program , to upload our data.
Programmed by : Kavitha Bhuvaneswaran..................................
Description : program to upload new materials...........................
Technique used : BDC recording.................................................
report ZMAT_UPLOAD
no standard page heading line-size 255.
types declaration..........................................................................
types : begin of t_mat,
matnr(20),
desc(50),
uom(5),
end of t_mat.
internal table and workarea declaration.......................................
data : i_mat type table of t_mat.
data : wa_mat type t_mat.
include bdcrecx1.
start-of-selection.
moving the flat file content to internal table................................
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
data_tab = i_mat
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform open_group.
loop at i_mat into wa_mat.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
wa_mat-matnr.
perform bdc_field using 'RMMG1-MBRSH'
'P'.
perform bdc_field using 'RMMG1-MTART'
'ZOH'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
wa_mat-desc.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
wa_mat-uom.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
perform bdc_transaction using 'MM01'.
endloop.
Perform close_group.
Test the above modified program. We get a selection screen as below.
We can choose either the session or call transaction method. In our case we continue with session method. Give a name to session say ZMAT_UPLOAD and execute. Then we get the prompt as below.
Enter your flat file name and click transfer.
We get the below list.
Then go to SM35 and select your session and click process.