sap r3 abap4 batch data communication

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Slide 1: 

BATCH DATA COMMUNICATION www.1000projects.com www.chetanasprojects.com www.campusmiles.com

Presentation Overview : 

Presentation Overview Duration 90 minutes Objectives Getting the clear concept of BDC How to use BDC effectively? To know the significance of BDC Pre-Requisites Knowledge of Dialog Programming Little Functional overview Contents Introduction to BDC. Method of Batch Input. Batch Data Procedures. Writing BDC programs. Creating Batch input Session. Batch Input Recording. File Transfer and File Handling Demo 30 minutes

Introduction : 

Introduction Method of transferring data into the System from other SAP and non-SAP Systems. Work by carrying out normal SAP transactions just as a user would. Execute the transaction automatically. Suitable for entering large amount of data. No manual interaction .

Methods of Batch Input : 

Methods of Batch Input SAP provide two basic methods for transferring legacy data in to the R/3 System. Classical Batch Input method. Call Transaction Method. Classical Batch Input method An ABAP/4 program reads the external data to the SAP System and stores in a batch input session. After creating the session, you can run the session to execute the SAP transaction in it. You can either monitor the session or run it in the background. This method uses the function modules BDC_ OPEN, BDC_INSERT and BDC_CLOSE

Classical Batch Input method : 

Classical Batch Input method Batch input sessions can be processed in various ways: In the foreground In the background During processing, with error display You should process batch input sessions in the foreground or using the error display if you want to test the data transfer. If you want to execute the data transfer or test its performance, you should process the sessions in the background.

Classical Batch Input Method : 

Classical Batch Input Method Asynchronous processing Transfer data for multiple transactions. Synchronous database update. A batch input process log is generated for each session. Session cannot be generated in parallel.

Methods of Batch Input : 

Methods of Batch Input 2. Call Transaction Method. ABAP/4 program uses CALL TRANSACTION USING statement to run an SAP transaction. Entire batch input process takes place online in the program

CALL TRANSACTION Method : 

CALL TRANSACTION Method Using CALL TRANSACTION USING statement Faster processing of data Synchronous processing Transfer data for a single transaction. No batch input processing log is generated.

Batch input procedures : 

Batch input procedures Analysis of the legacy data. Determine how the data to be transferred is to be mapped in to the SAP Structure. Also take note of necessary data type or data length conversions. Generate SAP data structures for using in export programs.

Batch input procedures : 

Batch input procedures 4 Export the data in to a sequential file. Note that character format is required by predefined SAP batch input programs. If the SAP supplied BDC programs are not used, code your own batch input program. Choose an appropriate batch input method according to the situation. 6 Process the data and add it to the SAP System. 7 Analyze the process log. For the CALL TRANSACTION method, where no proper log is created, use the messages collected by your program. 8 From the results of the process analysis, correct and reprocess the erroneous data.

Writing BDC program : 

Writing BDC program Analyze the transaction(s) to process batch input data. Decide on the batch input method to use. Read data from a sequential file Perform data conversion or error checking. Storing the data in the batch input structure,BDCDATA. Generate a batch input session for classical batch input,or process the data directly with CALL TRANSACTION USING statement.

Batch input data structure : 

Batch input data structure Declaration of batch input data structure DATA : BEGIN OF < bdc table> OCCURS <occurs parameters>. INCLUDE STRUCTURE BDCDATA. DATA:END OF <bdc table>. BDCDATA structure Field name Type Length Description PROGRAM CHAR 8 Module pool DYNPRO NUMC 4 Dynpro number DYNBEGIN CHAR 1 Starting a dynpro FNAM CHAR 35 Field name FVAL CHAR 80 Field value

Creating Batch input session : 

Creating Batch input session Open the batch input session session using function module BDC_OPEN_GROUP. For each transaction in the session: a. Fill the BDCDATA with values for all screens and fields processed in the transaction. b. Transfer the transaction to the session with BDC_INSERT. Close the batch input session with BDC_CLOSE_GROUP.

Format of BDC_OPEN_GROUP : 

Format of BDC_OPEN_GROUP CALL FUNCTION ‘BDC_OPEN_GROUP’ EXPORTING CLIENT = <client> GROUP = <session name> HOLDATA = <lock data> KEEP = <deletion indicator> USER = <batch user name> EXCEPTIONS RUNNING QUEUE_ERROR = 1 CLIENT_INVALID = 2 GROUP_INVALID = 3 .

Format for ‘BDC_INSERT’ and BDC_CLOSE_GROUP : 

Format for ‘BDC_INSERT’ and BDC_CLOSE_GROUP CALL FUNCTION ‘BDC_INSERT’ EXPORTING TCODE = <trans code> TABLES DYNPROTAB = <bdc_table> EXCEPTIONS INTERNAL_ERROR = 1 NOT_OPEN = 2 QUEUE_ERROR = 3 TCODE_INVALID = 4 CALL FUNCTION ‘BDC_CLOSE_GROUP’ EXCEPTIONS NOT_OPEN = 1 QUEUE_ERROR = 2 Note : Close the session after opening it

Using CALL TRANSACTION USING for batch input : 

Using CALL TRANSACTION USING for batch input CALL TRANSACTION <transaction code> USING <bdc table> MODE <display mode> UPDATE <UPDATE MODE> MESSAGES INTO messtab DISPLAY MODE: A :display all(default setting) E :Display only error N :No display Update mode S : continue processing when update is completed(synchronous) A : continue processing immediately. Note: messtab,an internal table must have a structure BDCMSGCOLL.

Batch Input Recorder : 

Batch Input Recorder

Batch Input Recorder : 

Batch Input Recorder Batch input recorder records transactions which are manually entered and create a batch input session which can be executed later using SM35. Begin the batch input recorder by selecting the Recording pushbutton from the batch input initial screen. The recording name is a user defined name and can match the batch input session name which can be created from the recording. Enter a SAP transaction and begin posting the transaction. After you have completed posting a SAP transaction you either choose Get Transaction and Save to end the recording or Next Transaction and post another transaction. Once you have saved the recording you can create a batch input session from the recording and/or generate a batch input program from the recording. The batch input session you created can now be analyzed just like any other batch input session. The program which is generated by the function of the batch input recorder is a powerful tool for the data interface programmer. It provides an solid base which can then be altered according to customer requirements.

BDC Program : 

BDC Program report zbdc05 . tables: ztrg_em05. data: begin of itab occurs 0, emplno(6), empl_name like ztrg_em05-empl_name, deptno(3), end of itab. data: bdctab like bdcdata occurs 0 with header line. call function 'WS_UPLOAD' exporting filename = 'C:\DEMO.TXT' filetype = 'DAT' tables data_tab = itab exceptions ---- call function 'BDC_OPEN_GROUP' exporting client = sy-mandt group = 'TEST' user = sy-uname exceptions

BDC Program : 

BDC Program loop at itab. refresh bdctab. clear bdctab. perform bdcfill using : 'X' '9000' 'SAPMZ705', ' ' 'BDC_OKCODE' '/5', 'X' '9000' 'SAPMZ705', ' ' 'ZTRG_EM05-EMPLNO' itab-emplno, ' ' 'ZTRG_EM05-EMPL_NAME' itab-empl_ ' ' 'ZTRG_EM05-DEPTNO' itab-deptno, 'X' '9000' 'SAPMZ705', ' ' 'BDC_OKCODE' '/11'. call function 'BDC_INSERT' exporting tcode = 'Z705' tables dynprotab = bdctab exceptions ---- write 'BDC inserted'. endloop. call function 'BDC_CLOSE_GROUP' exceptions ----

FILE TRANSFER & FILE HANDLING : 

FILE TRANSFER & FILE HANDLING OPEN DATASET dsn. Additions: 1. ... FOR OUTPUT 2. ... FOR INPUT 3. ... FOR APPENDING 4. ... IN BINARY MODE 5. ... IN TEXT MODE 6. ... AT POSITION pos 7. ... TYPE ctrl 8. ... MESSAGE mess 9. ... FILTER

FILE TRANSFER & FILE HANDLING : 

FILE TRANSFER & FILE HANDLING Opens the specified file. If no addition is specified, the file is opened for reading and in binary mode . The return code is set as follows: SY-SUBRC = 0: The file was opened. SY-SUBRC = 8: The file could not be opened.

FILE TRANSFER & FILE HANDLING : 

FILE TRANSFER & FILE HANDLING Example DATA: DSN(20) VALUE '/usr/test', RECORD(80). OPEN DATASET DSN. DO. READ DATASET DSN INTO RECORD. IF SY-SUBRC NE 0. EXIT. ELSE. WRITE: / RECORD. ENDIF. ENDDO. CLOSE DATASET DSN.

FILE TRANSFER & FILE HANDLING : 

FILE TRANSFER & FILE HANDLING TRANSFER f TO dsn. Transfers the field f (usually a field string) to the sequential file specified in dsn (this may be a literal or a field). Example DATA REC(80). TRANSFER REC TO '/usr/test'.

Slide 25: 

Thank You