BDC in ABAP for Data Migration
BDC in ABAP for Data Migration
The purpose of BDC is to transfer data from Non-SAP( Legacy ) system to SAP system.
BDC works on the principle of Screen recording, i.e. We can record the steps of
Implementation and then we can reuse it in the program for large scale migration.
BDC Methods
1. Call Transaction Method
2. Session Method
Note :-
Call transaction method and session method are called as Batch Input Methods.
Press Enter and select Basic data 1 and click on Okay button.
Provide the short description and basic unit of measurement as EU and click on save
button.
Give a program name and Select Transfer from recording radio button.
Click on source code and assign the package and transport request.
Above is the 5 records that we will migrate, the various columns that we can see here are
Material Number, Industry Sector, Industry Type, Material Description, Basic unit of
measure etc.
Step 2 :- We will use At Selection Screen on Value Request event to apply a F4 Help and
then we will use F4_FILENAME function module to pick local file from our PC.
Step 3 :- Now to upload this file to SAP System we will use GUI_UPLOAD function
module to upload file into the SAP System which will return the data into our desired
internal table.
Step 5 :- Now we will use the a loop statement to loop for all our records.
Step 7 :- Now, Inside our loop we can see we have two perform BDC_DYNPRO and
BDC_FIELD, so for that we are required to created Form (Subroutines) as well, so for that
purpose, we will go inside this below include.
Step 11 :- Now we will go to the subroutines and check the internal table and work area
accordingly, and also remove the if statement from the BDC_FIELD subroutine.
Processing Nodes
1. A → All Screen ( It will show screen by screen processing )
2. N → No Screen ( It will not show any screen, directly we will get a output ).
Update Nodes
1. A → Asynchronous( COMMIT WORK )
The called transaction does not wait for any updates to be completed.
2. S → Synchronous( Sync between the sender and receiver, COMMIT WORK and WAIT)
This called transaction waits for any updates than it produces to be completed.
Execution is slower than with asynchronous updating because called transactions wait
for updating to be completed.
3. L → Local Update
If the data is updated locally, the update of the database will not be processed in a
separate process, the update functions are run in the same dialog process.
Implementation
Step 1 :- Just before the end of loop we will call the Call transaction method using the
internal table of BDCDATA.
Step 2 :- We will use the processing node, update nodes and message internal table to
process all the data.
For the message tab we will go again to the include to fetch its type.
Step 3 :- Now to see the contents of messages we will call the MESSAGE_TEXT_BUILD
function module to display the messages.
Code
REPORT ZAR_BDC
NO STANDARD PAGE HEADING LINE-SIZE 255.
START-OF-SELECTION.
LO_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LO_FILE
* FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = LT_MARA
* INCLUDE BDCRECX1.
*
*start-of-selection.
*
WRITE :/ LV_MESSAGE.
ENDLOOP.
*---------------------------------------------------------------
* Insert field
*---------------------------------------------------------------
FORM BDC_FIELD USING FNAM FVAL.
CLEAR LS_BDCDATA.
LS_BDCDATA-FNAM = FNAM.
LS_BDCDATA-FVAL = FVAL.
APPEND LS_BDCDATA to LT_BDCDATA.
ENDFORM.
Output