Data Migration Part 4
Data Migration Part 4
In the previous part, we discussed how we can transfer data to SAP using
BAPI.
In this part we will see the implementation part step by step using BAPI.
Suppose, I have this above material data and I want to transfer it to my SAP
and store it in the database using BAPI.
Solution :-
Step 1 :- Create a executable program in ABAP Editor ( SE38 ).
Now, Our data from our local file is stored into LT_MATERIAL internal table. So,
we will pass our each record one at a time into the
BAPI_MATERIAL_SAVEDATA.
At last BAPI will return a message which will be of type BAPIRET2, we will
stored it.
Code :-
*&--------------------------------------------------------------
*& Report ZAR_BAPI_MATERIAL_SAVE
*&--------------------------------------------------------------
*&
START-OF-SELECTION.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_table
rc = lo_rc
endif.
lv_file = lo_file.
ls_header-material = ls_material-matnr.
ls_header-IND_SECTOR = ls_material-mbrsh.
ls_header-MATL_TYPE = ls_material-mtart.
ls_header-BASIC_VIEW = 'X'.
ls_material_desc-MATL_DESC = ls_material-maktx.
ls_material_desc-langu = sy-langu.
append ls_material_desc to lt_material_Desc.
clear ls_material_desc.
ls_clientdata-BASE_UOM = ls_material-meins.
ls_clientdatax-BASE_UOM = 'X'.
refresh : lt_material_desc.
append ls_return to lt_return.
clear : ls_return, ls_clientdata, ls_clientdatax, ls_header.
ENDLOOP.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = IF_SALV_C_BOOL_SAP=>FALSE
* r_container =
click on allow.
Now, we can go to MARA table to see the contents for these material numbers.