Nothing Special   »   [go: up one dir, main page]

Data Transfer

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 39

ABAP Training

Data Transfer
ABAP Training Data Transfer 2

Data Transfer Into SAP System


 For reasons of efficiency, large volumes of data cannot be transferred
manually from an external system into the R/3 system. A data transfer is
required that transfers the data automatically in the background.
 A transfer is required, for example, when:
 A new SAP system is installed and data has to be transferred from

another system.
 Data is regularly transferred from external systems into the SAP

system.
Example: if the data in some areas of the company is created in
external systems and this data has to be integrated into the SAP
system.
 A way has to be found to transport the data into the R/3 system.
 External data cannot be directly imported into the R/3 database because
data integrity is not guaranteed.
ABAP Training Data Transfer 3

Types of External Interfaces in SAP


 Communication through sequential files:
Batch input, call transaction, direct input

 Program to program communication:


RFC, ole

 Distributed component architecture:


Idocs, BAPI
ABAP Training Data Transfer 4

Choosing an Interfacing Method


ABAP Training Data Transfer 5

Using Interfaces to Transfer Data


ABAP Training Data Transfer 6

Using Interfaces to Transfer Data


 Data integrity has to be guaranteed when transferring data from another
SAP System or from an external system.
 The same checks that are used online have to be carried out for the data
transfer.
 As the online checks are very extensive in the transactions and are
partly cross-application, it is very difficult to carry these checks out
yourself.
 SAP provides special interfaces for data transfer. These partly use the
transactions and their checks to transfer data into the SAP System.
ABAP Training Data Transfer 7

Batch Input
ABAP Training Data Transfer 8

Batch Input
 Batch input is a standard technique used to transfer data into the R/3
System. The transaction process is simulated and the data is transferred
as if it had been entered online. The advantage of this process is that all
the transaction checks are carried out and therefore data consistency is
assured.
 The batch input process runs in two phases:
1.) A batch input session is created containing all the relevant data.
2.) The batch input session is processed and the data contained in it is
imported into the R/3 System.
 Most of the SAP standard data transfer programs use batch input.
 The online transaction is used for importing, checking and transferring
the data into the R/3 database.
ABAP Training Data Transfer 9

Call Transaction
ABAP Training Data Transfer 10

Call Transaction
 Call transaction is a standard technique used to transfer data into the
R/3 system. The transaction flow is simulated and the data is transferred
as if it had been entered online. The advantage of this procedure is that
all transaction checks are carried out, thereby guaranteeing data
consistency.
 Call transaction posts the data directly via the online transaction.
 This method provides the same functions as with batch input.
 The online transaction is used for importing and checking.
ABAP Training Data Transfer 11

Procedural Steps in Data Migration


Data Analysis

Generate SAP structures


Data
Transfer
Develop Transfer Program Program

Create Sequential File

Create Batch Input Program


BDC
Program
Process Batch Input Data

Analyze Results

Analyze Error Session


ABAP Training Data Transfer 12

Batch Data Communication (BDC)


 Batch input, also known as Batch Data Communication (BDC) is an
automated process used for dialog-free transfer of data to the SAP
System.
 In order to ensure the same checks and updates are executed as in
dialog processing, a user dialog is simulated.
 The central component of this method is the batch input session.
 These sessions are created using a batch input program and contain all
data necessary to simulate the user dialog.
 After the batch input sessions are created, you use the batch input
monitor to process the sessions. During processing, the online
transactions are used to transfer the data to the R/3 database.
ABAP Training Data Transfer 13

Batch Input Program


 The data is transferred into the session by batch input programs. For
standard transfer these programs are provided in the DX-WB and for
individual transfers they have to be created.
 Batch input programs have the following functions:
 They provide structured work areas for the data to be transferred in the
form of an internal table (BDC table).
 They import the data.
 They put the imported data into the BDC table.
 They transfer the filled BDC table into the session.
 The BDC table has always the same structure and contains the relevant
transaction data for the data transfer.
ABAP Training Data Transfer 14

Creating Batch Input Session


ABAP Training Data Transfer 15

Creating Batch Input Session


 Each batch input session must be opened and closed.
 The data for the application functions (transactions) is inserted into the
batch input session.
 The batch input session contains screen data from individual
transactions.
 Data is inserted into the batch input session for each transaction. One
transaction is inserted at at ime into the session header.
 A batch input program can create one or more batch input sessions in
succession.
 Batch input sessions cannot be created in parallel.
ABAP Training Data Transfer 16

Recording
1. Use the Transaction Code - SM35 to get to the BDC Input screen.
2. Press Recording to initiate the recording session.
3. Enter the name of the recording session [start always with Z ] and use
the create function.
4. A popup appears requesting the transaction code to be used in the
session. Enter the T/Code and press Enter.
5. The T/Code takes you to the corresponding screen in SAP. Enter the
required data and make any changes if necessary. [Do not repeat any
cursor movements, i.e., do not go back to a field where data has been
changed or entered]. Save the current transaction. During this whole
process, the BDC records the movements of the cursor and the data
changes made in these fields.
6. Finally, a Batch Input: Recording screen appears, listing the screens, data
fields, etc recorded.
ABAP Training Data Transfer 17

Recording

7. Press get transaction. Save the recording.


8. Go back [F3] to the previous screen. Press overview and the recording:
overview appears. Choose the recording done and press generate
program. A popup appears and enter the program name [start the name
with Z always] and press enter.
9. Enter the title of the program in the attributes of the program. Enter the
other attributes - Type - 1[Online program], Status - T[Test program] &
Application - *[Not application-specific]. Save the attributes of the
program and create the object as a local object.
10. Press Source Code and the code generated by the program is displayed.
ABAP Training Data Transfer 18

Recording
11. To check the program created, change the data back to the original
values as in the original record. Check the program for any syntax
errors. Use the menu path - Program à Execute. Enter the name of the
session and the authorization group for the session. Press Execute [F8].
Use the T/Code - SM35 to go back to the BDC session overview. Choose
the session and process in the background. Go back to the record to see
the changes made by the current BDC session.
ABAP Training Data Transfer 19

Structure of BDC Table


 The data is structured within a BDCDATA table according to the screens
in the transaction. Each screen that is processed in the transaction must
be identified in a BDCDATA record. This record uses the fields
PROGRAM, DYNPRO and DYNBEGIN. A separate BDCDATA record for
each value that can be entered in a field comes after this record. These
records use the fields FNAM and FVAL.
 The field name for the OK code is always BDC_OKCODE for all screens.
The field value of the OK code when a function key is pressed is made
up of the backslash '/' and the number of the function button (e.g. '/11').
For other types of application actions (menu choices, pressing the SAVE
icon etc.) the field value of the OK code is an ‘=‘ followed by the
function code (e.g. ‘=save’).
ABAP Training Data Transfer 20

Structure of BDC Table

The BDCDATA structure is defined in the ABAP Dictionary as follows:


Field Name Data Element Type Length Short Description
PROGRAM BDC_PROG CHAR 40 BDC Module pool
DYNPRO BDC_DYNR NUMC 4 BDC Screen number
DYNBEGIN BDC_START CHAR 1 BDC Start of Screen
FNAM FNAM_____4 CHAR 132 BDC Field name
FVAL BDC_FVAL CHAR 132 BDC Field value
ABAP Training Data Transfer 21

BDC Table
Structured work areas for the data to be transferred in
the form of an internal tables
PROGRAM - Name of the program

DYNPRO - No of Screens
DYNBEGIN - Indicates the first record of the screen.
Set this field to X only in the first record
for the screen. Set ‘ ‘(space) for the rest
of thefields.

FNAM - Name of the field in the screen

FVAL - Values of the field in FNAM


ABAP Training Data Transfer 22

Program Structure
ABAP Training Data Transfer 23

Program Structure
ABAP Training Data Transfer 24

Function modules for Batch Input


ABAP Training Data Transfer 25

Function modules for Batch Input


 The following function modules are provided for creating batch input
sessions (function group SBDC):
 BDC_OPEN_GROUP
Creates a new session and contains general data for the whole
session.
 BDC_INSERT
Inserts all the data for a transaction into the session. The transferred
internal table with the structure BDCDATA must contain all the data
required for fully processing the transaction.
 BDC_CLOSE_GROUP
Closes the session after all the data has been inserted. As soon as
the session has been closed, it can be processed.
 The internal table with the structure BDCDATA can only contain batch
input data for one single transaction run. So the individual transactions
are inserted into the batch input session in a loop, using several
BDC_INSERT calls.
ABAP Training Data Transfer 26

BDC_OPEN_GROUP
 Opens batch sessions
 Import parameters
 Client

 Group

 HOLDDATE

 Keep

 User

KEEP – retains the session after successful processing


GROUP – name of session
HOLDDATE – the session is locked and cannot be processed until after
the date you specify.
ABAP Training Data Transfer 27

BDC_INSERT
 Used to add a transaction to BDC input session
 Here we have to provide BDCDATA table that contains all of the data
required to process the transaction completely
 Import parameters
 TCODE transaction code

 POST_LOCAL local update

 Tables
 DYNPROTAB table for screens of a transaction
ABAP Training Data Transfer 28

BDC_CLOSE_GROUP
 Used for closing the session
 No parameters to be passed
 Exceptions
 Not_open = 1
 Queue_error = 2
ABAP Training Data Transfer 29

Filling BDC Table


 The BDC table is filled with data from the recording. The subroutines
BDC_DYNPRO and BDC_FIELD are used for this.
 The subroutines are called in the required structure or sequence.
ABAP Training Data Transfer 30

Batch Input Vs. Call Transaction


ABAP Training Data Transfer 31

Call Transaction
 In contrast to batch input, you can use call transaction to directly pass
data to the dialog interface, without using a batch input session. You use
an internal table (BDC table, same structure and layout as batch input)
to temporarily store your screen data. Then you call the desired
transaction in your program.
 In contrast to batch input, there is no error logging (error sessions)
here. For processing the called transaction, the system uses the
authorizations of the user that called the transaction. The BDC table can
only hold data for one transaction run at a time. Before another
transaction is called and its data can be added, you must execute a
REFRESH for the BDC table.
ABAP Training Data Transfer 32

Call Transaction - Mode


ABAP Training Data Transfer 33

Call Transaction - Mode


 With the parameter MODE you can select a specific display mode for
processing the transaction. The following three modes are available:
 A (Display all)
If you execute the program, all the screens and all their data are
displayed. This is the default value for the MODE in CALL TRANSACTION.
 N (Display nothing)
The screens are not displayed at all, regardless of whether any of them
contained errors. As soon as the transaction has been fully processed,
control is returned to your program. (The value of the parameter
UPDATE determines whether database updates are executed or not).
 E (Display errors only)
As soon as an error occurs in a screen, the transaction is switched to
display mode so that you can correct the errors.
 These display modes are the same as those in the batch input session
processing.
ABAP Training Data Transfer 34

Call Transaction - Update


ABAP Training Data Transfer 35

Call Transaction - Update


 With the parameter UPDATE you can control how database updates
arising from a transaction are carried out. There are three options:
 A (asynchronous updating) The called transaction does not wait until the
database has been updated, it simply forward the updates to the SAP
update service. This usually speeds up the CT program. This processing
mode is NOT recommended for large data sets as the called transaction
does not receive a completion message from the update module.
The calling CT program therefore cannot tell if the transaction has been
successfully completed. You should use the updating administration
function (transaction SM13) to determine whether updating was
terminated early. The error analysis /correction functions for are less
helpful than with synchronous updating.
ABAP Training Data Transfer 36

Call Transaction - Update


 S (synchronous updating) With synchronous updating the
called transaction waits until all the updates have been
completed. So processing is slower than with synchronous
updating. The called transaction can however report any
updating errors to the program, which makes error
analysis/correction easier.
 L (local updating) with local updating the database is not
updated in a separate process , it is updated in the caller‘s
process (see application help documentation for the ABAP
keyword SET UPDATE TASK LOCAL)
ABAP Training Data Transfer 37

Call Transaction - Messages


 MESSAGES specifies that all system messages that are output during the
execution of a CALL TRANSACTION are written to the internal table
<MESSTAB>. The internal table must have the structure BDCMSGCOLL.
 Unlike the classical batch input processing with sessions CALL
TRANSACTION does not offer any special processing procedures for
transactions containing errors. There are no restart functions for
transactions that contain errors or that cause updating terminations.
ABAP Training Data Transfer 38

Standard Utility Reports for Batch Input


 RSBDCREO
 Deletes all sessions which are flagged as successful and still in the

system, together with their logs


 Physically deletes all logs for which there are no sessions

 Reorganises the log file (file is reduced if logs have been deleted)

 Function integrated in SM35

 RSBDCLOG
 Generates a list of batch input logs, selected by session name

 Can display or delete logs and, if sessions exist, activate the

analysis function integrated in SM35


ABAP Training Data Transfer 39

Standard Utility Reports Contd..


 RSBDCDRU
 Allows you to print out the contents of selected sessions

 Function integrated in SM35

 RSBDCSUB
 To start a session in background processing submit this report in

background.
 If several sessions have the same name, RSBDCSUB starts them all.

You might also like