Saturday 14 March 2015

BDC (Batch Data Communication) or Interface Programming


(Batch means collection of data/number of records)
BDC program is to communicate system to system which act like an interface between two types of system. In BDC we have two types of interface system.


•      OUT BOUND INTERFACE PROGRAM  [SAP TO NON-SAP SYSTEM]


•      IN BOUND INTERFACE PROGRAM       [NON-SAP TO SAP SYSTEM] 



NOTE: BDC IS AN INBOUND DATA TRANSFER TECHNIQUE
We can create flat file in a three different types of formats in local system.
FIXED LENGTH                     (As per the SAP field length or internal table field length)
TAB-DELIMITED                   (Each field value separated by tab)
SPECIAL CHARACTER DELIMITED (Each field value in file separated by Special Character i.e. @,|,-, _, etc…)                                           

NOTE: In Ms-Excel we can store maximum of 60,000 Records only.
TIP: If we want to store huge amount of data from SAP system to Non-SAP system there is a transfer called FTP (File Transfer Protocol).
FTP: It is a secured gateway to transfer huge no. of files.

About Application Server: 
To access application server the transaction code is “AL11”.
File in application server is called as data set or sequential file.
We can create two different format files in application server TEXT and BINARY. · By default any file in application server will stored in “ Dict-Dir_Home ” 

Flat file have two locations:
1. pc or local system.
2. Sap application server.

Type of flat files:
1. Text file or notepad.
2. Excel.

TIP: We can’t create file in all directresses of App. Server. In some files they have restrictions in real time company will give the App. Server directresses to store the file in specification document.
In specification document we get all technical details i.e. fields, type, length… and also sample flat file.


NOTE: We can’t transfer/copy data from one data base to another data base because structure is different form database to database.
In bound interface: Reading the data from Non-SAP to SAP system in this we have two steps     
I                                 file handling and Uploading data to transaction
File Handling: Reading the data from flat file to internal table is called file handling.




To get technical information of any SAP screen there is two ways
Press F1 and click on technical information icon
Recording 
Recording: It is to find out any SAP screen technical details. Transaction code for recording is “SHDB” There is predefining internal table behind recording screen this screen elements attributes or properties will dynamically store in system internal table “BDCDATA”. 

In Inbound we have two different methods to upload the data.
Call Transaction Method
Session Method
Difference between call transaction & session: In case of call transaction manually handles the exceptions programmatically we need to declare but in session method automatically generates message in output.


Call Transaction Method: It is the processing of transferring the data from flat file to sap by calling transaction through a series of sequence of steps.



Properties: 
1. This method is used for transferring less amount of data [<10 p="" records.="">
2. In call transaction we have two types Asynchronies and Synchronize   
Asynchronies:  It doesn’t check the check table validations.
Synchronize:    If we say synchronize it will check in master database table whether it is     u    update or not while updating in secondary database table.    
3. This method will update db immediately.
4. We need to handle the errors and success message by declare an internal table of type BDCMSGCOLL.
5. This method is very fast.
Syntax: CALL TRANSACTION 'XK01' using it_bdcdata update 'A'

                                                                                               Mode ‘N’ messages into it_messages.

TIP: In case of call transaction how we handle exceptions/errors. For this we have internal table called “BDCMSGCOLL”. 
TIP: Mode is to see how data is inserting in screen fields while execution  
          MODE ‘A’     All screen (It is for programmers to test how data is populating in fields)  
                       ‘E’      Error (Only those screens are displayed wherein error occurs)
                       ‘N’     No screen (No screen is displayed when executing the transaction)  

 NOTE: After using ‘A’ in mode testing is done we have to change it as ‘N’. 




TIP: In front of screen called FOREGROUND. Maximum compelling time is 300sec if the execution time is more than 300sec it go for runtime error. Behind the screen called as BACKGROUNG for this there is no limitation of time.

Session Method: Generally we use this method for transfer huge records, it is a temporarily 
                              File/location.
 Properties: This method is used to transferring large amount of data [> 10,000 to 10 lakh] records.
It is basically 2 steps.
A. Create Session
B. process Session.
Session: It contains group of records transfer into sap.
Transaction code SM35        Session Overview and Processing 
Transaction code SM36       
Transaction code SM37        to see Background Process
NOTE: Any background process is done in Application server.
NOTE: When we do downloading or uploading data from local system we can’t run it in background process because file path which we given exists in local system but the background process done only in application layer i.e. in SAP server, so server unable to recognize file path of local system for this we need to download file into application server.

In front of screen is called fore ground, maximum compelling time is 300 sec if the execution time is more than 300 sec it go for runtime error.

To create session we have function modules:
bdc_open_group : create session.
bdc_insert: To transfer the data from bdc data structure into session

bdc_closegroup: close session.



LSMW (Legacy System Migration Workbench):

NOTE: To upload the data for each transaction in LSMW we have separate program behind LSMW.
1. It is a tool which is used to transfer the data from legacy system to sap.
2. Very less amount of data [> 5000].
3. It will do by functional consultant.

There are four methods.
1. Direct input method.
2. Recording method.
3. Bapi method.

4. Ale/idoc method.


lsmw 14 steps.
1. Maintain Object Attributes
2. Maintain Source Structures
3. Maintain Source Fields
4. Maintain Structure Relations
5. Maintain Field Mapping and Conversion Rules
6. Maintain Fixed Values, Transaction, User-Define Routines
7. Specify Files
 8. Assign Files
9. Read Data
10. Display Read Data
11. Convert Data
12. Display Converted Data
13. Create Batch Input Session
14. Run Batch Input Session 



BDC Reports are used to transfer data from legacy system into SAP system during SAP Implementation. Based on the functional requirements you have to now write a BDC report to upload the legacy data into SAP system. 

To Perform Data transfer, we will perform 3 tasks:
Task 1: Do a recording for the transaction by supplying sample data.
Task 2: Create an ABAP report based on the recording done. 
Task 3: Now write ABAP code to fetch data from legacy system and store into SAP System.

1.  Analysis and cleanup of data in the non-SAP system
2.  Extraction of data from the non-SAP system
3.  Mapping the data in SAP format
4.  Transferring the data to the SAP System 
5.  Checking the data
Call transaction 
Asynchronous processing takes place and the transaction is called every time.

Session method 
Synchronous processing takes place and a session is prepared, which is to be handled through SM35. Moreover, in Batch Input processing system log is maintained for every transaction. In Call transaction method messages have to be captured at runtime.

Direct input

This is an SAP supplied conversion program that allows very fast loading of certain objects.  The disadvantage is that it is not customizable. 

1.  Give transaction SHDB (Transaction Recorder), this is used to record our transaction. 

Press New Recording, Give Recording name,  Give Transaction,  And Press Start Recording. 


 1.  You will get the following screen,   Give the selection screen inputs as below,  finally      Save. 

1.  The following screen comes when you save,   this shows table name and filed name       which stores the data given in respected selection screen of transaction. Next Press       F3 to come back.



Now select your Recording and press Create program icon.

You will be asked to fill the following selection screens .

Using SE11 get the Length of the fields. It must be supplied in MS-Excel  
Now we are going to upload the following fields in 
First Screen 
Vendor No,   Company Code,   Account Group 
Second Screen 
Name,    Search Parameter,   Street, House No, City, Country Code, Region, PO Box Language, Telephone 
Final Screen
Recon Account, Cash Mgmt Group.



Now Four Steps in ABAP Editor: 
Create an internal table for above fields in the report after Include bdcrecx1.


1.  Next call upload function after start-of-selection.



1.  Put Loop after perform open group.



1.  Now replace the constants in perform statement within loop by internal table name With field name. Make the values used in recording in “. Then Save, Activate.



This is your data in MS-Excel. This order must be in the internal table of ABAP report.Unformatted Excel.


Now Give respected Length for each fields. By placing Cursor in each column, Right Click, Select Column Width.  



Since LIFNR are 16 give that width.



After that save the excel file.   And save a copy as Formatted text space delimited.


Give OK, Yes, Then Close Excel by giving No.  
Now come to ABAP editor and run the report, you will get the screen.  
Select Call transaction Radio Button, and run in a mode.  Press F8.


Now in next screen give the .prn file you saved previously.   (.prn must be selected)  Then press Transfer.   



You will get following screen, Just Check for correct order of data, if yes, Press Enter  .



Next Screen comes, Press Enter.  




The vendor created.   And system shows log.   If small errors you can select that from F4 help and run the report.   
FK03 -> Give Vendor no, Comp code.  Enter.  Select desired radio button and enter.







No comments:

Post a Comment