15-Batch Data Communication
15-Batch Data Communication
Call Transaction.
Session Method.
We need to handle the errors and the success messages by declaring an internal table of
type BDCMSGCOLL.
BDCDATA is a structure defined with below fields in data dictionary, it holds the information
related to each screen field .
Use of BDCDATA
It is a structure which holds the information related to each screen i.e. program name, screen no,
field name, field values, information of that particular screen to be transferred into the SAP.
In simple words, it holds all the screen related information and field information to be transferred
into corresponding SAP transaction. Program Dynpro Dynbegin Fnam Fval
SAPLGMM 0060 "X"
RMMG1-MATNR "1011"
RMMG1-MBRSH "FOOD"
RMMG1-MTART "FERT"
SAPLGMM 0070 "X" RZSEL "X"
To find the above information for each field, press F1 on particular field It will display help
information.
Click on the button "technical information".
It will show the entire technical information of a screen.
Please note down the program name, screen number, screen field name.
This procedure has to be repeated for each field on a SAP screen.Since, it is very difficult to note
down the technical information for each field, we have an alternate and easy method called as
"RECORDING METHOD".
Update: There are two types of updates are available.
Asynchronous update (COMMIT).
Synchronous update (COMMIT & WAIT).
DIALOG WORK PROCESS: A work process which is dedicated to process screen information is
called "Dialog work process".
There will be 6 to 7 dialog work processes.
These dialog work processes are defined by basis consultant.
UPDATE WORK PROCESS: This work process is responsible for updating the data into the
database.
There will be always only "1" update work process.
In this type the call transaction screens will communicate with the update work process to
It immediately starts to process the next record without waiting for the update to be
finished.
It is generally not recommended for the large amount of data, because the called
transaction does not return any success or error messages.
In this mode, the called transaction communicates with the update work process to
update the data into database.
Once the update is finished, then it continues to process the next record.
It is generally recommended for large amount of data because it returns success and
error messages.
MODE:
It specifies the type of the mode to execute the transaction.
There are 3 options for mode
RECORDING METHOD:
Since, it is very difficult to find technical information of each field on the screen, we go for a
method called as "Recording method".
The recording method is going to record all the fields in the transaction and it generated the
technical information such as program name, screen no, field name, field value for each field on
the SAP screen.
By using the recording method, it is very easy to create a BDC program.
A pop up will open, provide a recording name ZSAPN_MM01, provide transaction code as MM01
and click recording.
Click Save, go back, you will go to recording overview screen and click on program button to
create a program for this.
Save it in a local object, you will find the below code in the program
report ZSAPN_MM01
no standard page heading line-size 255.
include bdcrecx1.
*
* 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
*
***
start-of-selection.
do.
perform bdc_dynpro
perform bdc_field
'RMMG1-MTART'.
perform bdc_field
using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field
using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field
using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field
using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro
perform bdc_field
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field
using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_dynpro
perform bdc_field
'RMMG1-MATNR'.
perform bdc_field
using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field
using 'RMMG1-MATNR'
record-MATNR_005.
perform bdc_field
using 'RMMG1-MBRSH'
record-MBRSH_006.
perform bdc_field
using 'RMMG1-MTART'
record-MTART_007.
perform bdc_dynpro
perform bdc_field
using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field
using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_008.
perform bdc_dynpro
perform bdc_field
'/00'.
perform bdc_field
using 'MAKT-MAKTX'
record-MAKTX_009.
perform bdc_field
using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field
using 'MARA-MEINS'
record-MEINS_010.
perform bdc_dynpro
perform bdc_field
'=YES'.
perform bdc_transaction using 'MM01'.
enddo.
perform close_group.
perform close_dataset using dataset.
'RMMG1-MTART'.
perform bdc_field
using 'BDC_OKCODE'
'ENTR'.
perform bdc_field
using 'RMMG1-MATNR'
record-MATNR_001. "pass material no
perform bdc_field
using 'RMMG1-MBRSH'
record-MBRSH_002. "pass industry sector
perform bdc_field
using 'RMMG1-MTART'
record-MTART_003. "pass material type
perform bdc_dynpro
perform bdc_field
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field
perform bdc_field
using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004. "basic view1 pass 'X'
perform bdc_dynpro
perform bdc_field
'=BU'.
perform bdc_field
using 'MAKT-MAKTX'
record-MAKTX_005. "material description
perform bdc_field
using 'BDC_CURSOR'
'MARA-MEINS'. "base unit of meassure
perform bdc_field
using 'MARA-MEINS'
record-MEINS_006.
END OF TY_MARA.
DATA : IT_MARA TYPE TABLE OF TY_MARA, "mara internal table
WA_MARA TYPE TY_MARA. "mara work area
DATA: IT_BDCDATA TYPE TABLE OF BDCDATA . "BDCDATA
DATA: WA_BDCDATA TYPE BDCDATA . "work area BDCDATA
DATA : BDCMSG TYPE TABLE OF BDCMSGCOLL. "BDC message table
DATA:FILE TYPE STRING. "file name
PARAMETERS : P_FILE TYPE RLGRAP-FILENAME. "input parameter for file upload
= IT_MARA.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
'RMMG1-MTART'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'ENTR'.
PERFORM BDC_FIELD
USING 'RMMG1-MATNR'
USING 'RMMG1-MBRSH'
USING 'RMMG1-MTART'
'MSICHTAUSW-DYTXT(01)'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD
'X'.
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
'=BU'.
PERFORM BDC_FIELD
USING 'MAKT-MAKTX'
USING 'BDC_CURSOR'
'MARA-MEINS'.
PERFORM BDC_FIELD
USING 'MARA-MEINS'
ENDLOOP.
The filnal BDC for migrating Material Master basic data is below
REPORT ZSAPN_BDC
NO STANDARD PAGE HEADING LINE-SIZE 255.
START-OF-SELECTION.
IF P_FILE IS NOT INITIAL.
FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD' "upload flat file
EXPORTING
FILENAME
FILETYPE
= IT_MARA.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
LOOP AT IT_MARA INTO WA_MARA. "loop all records and pass one by one to BDC
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
'RMMG1-MTART'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'ENTR'.
PERFORM BDC_FIELD
USING 'RMMG1-MATNR'
USING 'RMMG1-MBRSH'
USING 'RMMG1-MTART'
'MSICHTAUSW-DYTXT(01)'.
PERFORM BDC_FIELD
USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD
'X'.
PERFORM BDC_DYNPRO
PERFORM BDC_FIELD
'=BU'.
PERFORM BDC_FIELD
USING 'MAKT-MAKTX'
USING 'BDC_CURSOR'
'MARA-MEINS'.
PERFORM BDC_FIELD
USING 'MARA-MEINS'
ENDLOOP.