Hi,
Though there are lots of links and blog are available ,I have written this article .
· Topics
· Call transaction
· Session
· BAPI
· Difference between them
· Recording process.
Hohope this will help the abap developers
I have screen shots in my documents but i am unable to publish in pdf format how to insert my proper document.
Regards,
vanamala kashavena
-------------------------------------------------------------------------------------------------------
Author: Vanamala Kasheven
Senior ABAP Consultant
This article will give the brief over view of the data transfer techniques present in the SAP and their functionalities,
Also basic steps for recording the tcode and example for call transaction method.
DATA TRANSFER TECHNIQUES
1. BATCH DATA COMMUNICATION:
2. BAPI
3. LSMW
4. IDOC
BATCH DATA COMMUNICATION:
Batch Data Communication or BDC is a batch interfacing technique that SAP developed. It is mainly used for uploading legacy data into the SAP R/3 system.
There are 3 methods in BDC.
Call transaction
Session method
Direct input method
For all the above methods recording is Mandatory. Recording means ruining the tcode with one test data so that we can capture all the required screen details of that tcode by using these screen details we can upload the data into the sap system. Tcode for Recording is SHDB
File types:
Local files: Files which are stored on desk top on the on the local system.
Sequential files: Files which are stored on application server.
Prerequisites for any Data Transfer Program:
Analyzing data from local file: This process involves arranging the data on the file means header details item details, default data etc.., we can take file format in excel, notepad etc..
Analyzing the transaction: In this we need to see which field are mandatory, which fields we want to pass as by default etc...
Uploading the master data or transactional data into database table of sap system is not done directly; it has to go through the respective Tcode so that the particular record or transaction will be stored in the data base. Going through the transaction code involves recording process that we have discussed above
For example if we are storing the sales order data, we need to record the va01 which is the sales order Tcode. While recording we can see the related tables fields, length of that fields, and also mandatory fields which are the main fields for master data.
There is a structure called BDCDATA provided by sap in this, we can see the fields PROGRAM, DYNPRO, DYNBEGIN, FNAM, and FVAL.
PROGRAM: This field wills holds the module pool program name associated with that screen.
DYNPRO: screen number associated with that module pool programming screen.
DYNBEGIN: Indicates the BDC screen start indicator and set this field to ‘X’ only for the first record ,reset to blank for all the other record.
FNAM: name of the field in the screen
FVAL: value of the field that we are passing this field is case sensitive.
Direct method is no one is using now.
Screen Resolution Problem
In order to avoid this screen resolution problem we use CTU-PARAMS Structure
DISMODE: using this parameter we can decide whether we can handle in all screen mode or error screen mode etc
A->Display all screens,
E->Display errors
N->Background processing
P->Background processing; debugging possible
UPDMODE: we can in which mode we can update the data in sap database.
L- >Local
S- >Synchronous
A->Asynchronous
CATTMODE: CATT mode (controlling a CATT procedure), The CATT mode can have the following values:
' ‘ ->No CATT procedure active
'N'-> CATT procedure without single screen control
'A' ->CATT procedure with single screen control
DEFSIZE: setting the screens of the called transaction is displayed in the standard screen size.
"X" (standard size),
‘ ‘ (current size).
RACOMMIT: setting the COMMIT WORK statement terminates batch input processing or not.
‘X’->Yes
‘ ‘->No
NOBINP: sy-binpt.
‘ ’ ->sy-binpt contains in the called transaction "X".
"X" ->sy-binpt contains in the called transaction ‘ ‘
NOBIEND: sy-binpt
" " ->sy-binpt contains "X" after the end of the batch input data in the called transaction
"X" ->sy-binpt contains " " after the end of the batch input data in the called transaction.
Call transaction:
Syntax:
CALL TRANSACTION <TCODE> USING <bdcdata>
MODE <all screens/no screen/error screen>
UPDATE<synchronous/ asynchronous>
MESSAGES INTO <bdcmsgcoll >
If we use the CTU_PARAMS
Syntax:
data: lw_option type ctu_params.
lw_option-dismode = 'E'. lw_option-updmode = 'A'. lw_option-defsize = 'X'. CALL TRANSACTION <TCODE> USING <bdcdata>
OPTIONS FROM <LW_OPTION>
MESSAGES INTO <bdcmsgcoll >.
Synchronous means sy-subrc will be return after all the related tables are get updated, i.e. system will wait until all the tables get updated, and it will always verifies all the data gets updated correctly or not.
Asynchronous means system will not wait until all the tables get updated. It will move on.
It is compatible for small amount of data
Using this method we can choose whether we can upload the data in synchronously or asynchronously.
Error handling is done explicitly by using BDCMSGCOLL structure.
It can handle only one application at a time
Simple example for call transaction:
In this example I am uploading the data in MK01 tcode.
Recording method:
Tcode for recording is SHDB, Click on new recording button in the shown in the below screen on application tool bar.
Enter the details shown below, and click on start recording button , it will enter in to the MK01 tcode.
As the vendor number creation is set as internal number generation we are I am not filling the vendor value, I have given the Purchasing organization, account group. And press enter, it will enter into the next screen, in the next screen I am filling the title, search term, country language key. And press enter click enter till end and save the tcode
When you click on save u can see this below recording details, then click on save and back.
When you click on the back button u can see below screen with the recorded entry. Select that entry and click on program ,it will create program with the recorded details.
This is the flat file that we want to upload into the sap system using call transaction method
Create program in se38.
I have highlighted the work area fields that I have passed in the recording part to pass the values in to the BDCDATA Structure.
*&---------------------------------------------------------------------*
*& Include ZFETCHINGLOGIC
*&---------------------------------------------------------------------*
gf_fpath = pa_fpath.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = gf_fpath
i_begin_col = 1
i_begin_row = 2
i_end_col = 60
i_end_row = 10000
TABLES
intern = gt_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT gt_excel ASSIGNING <gw_excel>.
CASE <gw_excel>-col.
WHEN '0001'.
gw_mk01-ekorg = <gw_excel>-value.
WHEN '0002'.
gw_mk01-ktokk = <gw_excel>-value.
WHEN '0003'.
gw_mk01-anred = <gw_excel>-value.
WHEN '0004'.
gw_mk01-name1 = <gw_excel>-value.
WHEN '0005'.
gw_mk01-sortl = <gw_excel>-value.
WHEN '0006'.
gw_mk01-land1 = <gw_excel>-value.
WHEN '0007'.
gw_mk01-spras = <gw_excel>-value.
APPEND gw_mk01 TO gT_mk01.
ENDCASE.
ENDLOOP.
LOOP AT gt_mk01 INTO gw_mk01.
*-----------begin of copied code from the recording part--------------------------*
PERFORM bdc_dynpro USING 'SAPMF02K' '0107'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-EKORG' gw_mk01-ekorg.
PERFORM bdc_field USING 'RF02K-KTOKK' gw_mk01-ktokk.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-LAND1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED' gw_mk01-anred.
PERFORM bdc_field USING 'LFA1-NAME1' gw_mk01-name1.
PERFORM bdc_field USING 'LFA1-SORTL' gw_mk01-sortl.
PERFORM bdc_field USING 'LFA1-LAND1' gw_mk01-land1.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0380'.
PERFORM bdc_field USING 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPDA'.
*---------End of copied code from the recorded program--------------------------------------------------*
CALL TRANSACTION 'MK01' USING gt_bdcdata MODE 'A' UPDATE 'S' MESSAGES INTO gt_bdcmsgcoll.
CLEAR gw_mk01.
REFRESH gt_bdcdata.
ENDLOOP.
LOOP AT gt_bdcmsgcoll ASSIGNING <gw_bdcmsgcoll> .
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = <gw_bdcmsgcoll>-msgid
lang = sy-langu
no = <gw_bdcmsgcoll>-msgnr
v1 = <gw_bdcmsgcoll>-msgv1
v2 = <gw_bdcmsgcoll>-msgv2
v3 = <gw_bdcmsgcoll>-msgv3
v4 = <gw_bdcmsgcoll>-msgv4
IMPORTING
msg = gw_sucess_message
EXCEPTIONS
not_found = 1
OTHERS = 2.
CONCATENATE gw_text <gw_bdcmsgcoll> INTO gw_bdc_error SEPARATED BY space.
APPEND gw_bdc_error TO gt_bdc_error.
ENDLOOP.
LOOP AT gt_bdc_error INTO gw_bdc_error .
WRITE: / gw_bdc_error-text.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0050 text
* -->P_0051 text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR: gw_bdcdata.
gw_bdcdata-program = program.
gw_bdcdata-dynpro = dynpro.
gw_bdcdata-dynbegin = 'X'.
APPEND gw_bdcdata TO gt_bdcdata.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0135 text
* -->P_0136 text
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR gw_bdcdata.
gw_bdcdata-fnam = fnam.
gw_bdcdata-fval = fval.
CONDENSE gw_bdcdata-fval.
APPEND gw_bdcdata TO gt_bdcdata.
ENDFORM. " BDC_FIELD
*-----------------------------------------------------------------------------------------------------------------------------------------*
Activate the program and run.
Select the excel file saved on the desk top. And execute it.
As we have written the call transaction in all screen mode we can see the creation of the vendor creation with the flat file details.
Now second record
Like that all the record present in the flat file will be up loaded in to the sap.
Session Method:
This method involves 3 function modules
BDC_OPEN_GROUP
BDC_INSERT
BDC_CLOSE_GROUP
We can use this method for large amount of data
Data will be uploaded in synchronous and asynchronously.
Multiple tcode can be handled by using this method
We can check the session in tcode sm35, here we can process the session.
In session method data will be store along with screen details
LSMW:
This method is mainly used by functional people and is only for one time process.
BUSINESS APPLICATION PROGRAMMING INTARFACE (BAPI ):
BAPI = (SE37+SWO1)
It is RFC function module.
In case of enjoy transactions like ME21N the BDC concept will be difficult , these tcodes can be handled by BAPIs
The main advantage of BAPI is recording is not required.
Less coding
It will be protected from version upgrades.
BAPI structures are frizzed
Synchronous updating will be done
Error handling is easy
IDOC:
This method comes under cross applications.
Using this method we can transfer data from sap to sap and sap to non-sap.
IDOC is a 16 digit number. Structure of IDOC contains 3 parts
Control records: It contains the type of IDOC, port of the partner, release of SAP R/3 which produced the IDOC etc
Data record: It will contains the data to be transfer
Status record: It containing the status of the IDOC transfer details like 'IDoc posted or not’, ‘data passed to port’.
Written By:
Vanamala Kashavena