BDC AND LSMW COMPARISION

Posted by Krishh Webworld | 6:14 PM | | 0 comments »

Batch Data Communication (BDC) is the oldest batch interfacing technique that SAP provided since the early versions of R/3. BDC is not a
typical integration tool, in the sense that, it can be only be used for uploading data into R/3 and so it is not bi-directional.
BDC works on the principle of simulating user input for transactional screen, via an ABAP program. Typically the input comes in the form
of a flat file. The ABAP program reads this file and formats the input data screen by screen into an internal table (BDCDATA). The
transaction is then started using this internal table as the input and executed in the background.

In Call Transaction・ the transactions are triggered at the time of processing itself and so the ABAP program must do the error handling.
It can also be used for real-time interfaces and custom error handling & logging features. Whereas in Batch Input Sessions, the ABAP
program creates a session with all the transactional data, and this session can be viewed, scheduled and processed (using
Transaction SM35) at a later time. The latter technique has a built-in error processing mechanism too.

Batch Input (BI) programs still use the classical BDC approach but doesnt require an ABAP program to be written to format the
BDCDATA. The user has to format the data using predefined structures and store it in a flat file. The BI program then reads this and
invokes the transaction mentioned in the header record of the file.

Direct Input (DI) programs work exactly similar to BI programs. But the only difference is, instead of processing screens they validate
fields and directly load the data into tables using standard function modules. For this reason, DI programs are much faster (RMDATIND - Material Master DI program works at least 5 times faster) than the BDC counterpart and so ideally suited for loading large volume data. DI programs are
not available for all application areas.


LSMW is an encapsulated data transfer tool. It can provide the same functionality as BDC infact much more but when coming to techinical perspective most the parameters are encapulated. To listout some of the differences :

LSMW is basicaly designed for a fuctional consultant who do not do much coding but need to explore the fuctionality while BDC is designed for a technical consultant.

LSMW offers different techinque for migrating data: Direct input ,BAPI,Idoc,Batch input recording. While bdc basically uses recording.

LSMW mapping is done by SAP while in BDC we have to do it explicitly .

LSMW is basically for standard SAP application while bdc basically for customized application.

Coding can be done flexibly in BDC when compared to LSMW.



BDC and LSMW are the two data migration techniques (from legacy to SAP) . BDC technique is usually done by ABAPers. It consists of three methods.
1) Call Dialog Method
2) Session Method
3) Call Transaction Method


In the case of Session Method , a BDC Session is created , which has the data and info to run it in batch mode. When the user runs this session, every transactions are run in batch mode and tables are updated.
WHile in call transaction, no session is created. Instead , a report prog is created , which takes input from the file and calls the transaction in Batch mode.

Call dialog method is similar to call transaction, except that updation is done by the calling program itself.This method is obsolete.


Advantages of Batch Input Method are
1)Can process large data volumes
2) data integrity is maintained


LSMW and BDC are vastly different.
BDC (Batch Data Communication) is a technology used for data transfer. it is meant for transferring data thru SAP transactions itself. when u use BDC for data transfer, the sequence of steps is the same as when u use standard sap transaction screens for data upload. the only difference is that u can use different options for foreground/backgrou nd processing.

LSMW on the other hand is a tool that helps migrate data from a legacy system (non-sap system ) to SAP system. it offers u various options to use either batch input, direct input, BAPIs or idocs. it involves a series of some 17-18 steps to migrate data.

BDC:
Batch Data Communication (BDC) is the process of transferring data from one SAP System to another SAP system or from a non-SAP system to SAP System.

Features :
BDC is an automatic procedure.
This method is used to transfer large amount of data that is available in electronic medium.
BDC can be used primarily when installing the SAP system and when transferring data from a legacy system (external system).
BDC uses normal transaction codes to transfer data.

Types of BDC :
CLASSICAL BATCH INPUT (Session Method)
CALL TRANSACTION

BATCH INPUT METHOD:
This method is also called as ‘CLASSICAL METHOD’.
Features:
Asynchronous processing.
Synchronous Processing in database update.
Transfer data for more than one transaction.
Batch input processing log will be generated.
During processing, no transaction is started until the previous transaction has been written to the database.

CALL TRANSACTION METHOD :
This is another method to transfer data from the legacy system.

Features:
Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
Updating the database can be either synchronous or asynchronous. The program specifies the update type.
Transfer data for a single transaction.
Transfers data for a sequence of dialog screens.
No batch input processing log is generated.

LSMW:

The LSM Workbench is an R/3-based tool that supports You when transferring data from non-SAP systems ("Legacy Systems") to R/3 once or periodically.
The tool supports conversion of data of the legacy system in a convenient way. The data can then be imported into the R/3 system via batch input, direct input, BAPIs or IDocs.
Furthermore, the LSM Workbench provides a recording function that allows to generate a "data migration object" in an entry or change transaction.

The main advantages of the LSM Workbench:
• Part of R/3 and thus independent of individual platforms
• A variety of technical possibilities of data conversion:
• Data consistency due to standard import techniques:
Batch input
Direct input
BAPIs (Business Application Programming Interfaces)
IDocs (Intermediate Documents)
The import technique to be used in an individual case depends on the business object.
• Generation of the conversion program on the basis of defined rules
• Clear interactive process guide
• Interface for data in spreadsheet format
• Creation of data migration objects on the basis of recorded transactions
• Charge-free for SAP customers and SAP partners

TABLE CONTROL IN BDC

Posted by Krishh Webworld | 6:13 PM | | 0 comments »

Steploop and table contol is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen?

Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction 'ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP')

we can determine the number of visible lines on Transaction Screen from our Calling BDC program.

Demo ABAP code has two purposes:

1. how to determine number of visible lines and how to calculte page number;
(the 'calpage' routine has been modify to meet general purpose usage)

2. using field symbol in BDC program, please pay special attention to the difference
in Static ASSIGN and Dynamic ASSIGN.


Step1: go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop.

Then have a look at steploop itselp, one entry of it will occupy two lines.
(Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line)
Now we have : FixedLine = 9
LoopLine = 2(for table control, LoopLine is always equal to 1)

Step2: go to transaction itself(ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input.
Now we have: FirstLine = 0
or FirstLine = 1 ( in our case, FirstLine is 1 because the first line of new page is fulfilled)

Step3: write a subroutine calcalculating number of pages
(here, the name of actual parameter is the same as formal parameter)

global data: FixedLine type i, " number of fixed line on a certain screen
LoopLine type i, " the number of lines occupied by one steploop item
FirstLine type i, " possbile value 0 or 1, 0 stand for the first line of new " scrolling screen is empty, otherwise is 1
Dataline type i, " number of items you will use in BDC, using DESCRIBE to get
pageno type i, " you need to scroll screen how many times.
line type i, " number of lines appears on the screen.
index(2) type N, " the screen index for certain item
begin type i, " from parameter of loop
end type i. " to parameter of loop

*in code sample, the DataTable-linindex stands for the table index number of this line


form calpage using FixedLine type i (see step 1)
LoopLine type i (see step 1)
FirstLine type i (see step 2)
DataLine type i ( this is the item number you will enter in transaction)
changing pageno type i (return the number of page, depends on run-time visible line in table control/ Step Loop)
changing line type i.(visible lines one the screen)
data: midd type i,
vline type i, "visible lines
if DataLine eq 0.
Message eXXX.
endif.

vline = ( sy-srows - FixedLine ) div LoopLine.
*for table control, you should compare vline with maximum line of
*table control, then take the small one that is min(vline, maximum)
*here only illustrate step loop

if FirstLine eq 0.
pageno = DataLine div vline.

if pageno eq 0.
pageno = pageno + 1.
endif.
elseif FirstLine eq 1.
pageno = ( DataLine - 1 ) div ( vline - 1 ) + 1.
midd = ( DataLine - 1 ) mod ( vline - 1).
if midd = 0 and DataLine gt 1.
pageno = pageno - 1.
endif.
endif.

line = vline.

endform.

Step4 write a subroutine to calculate the line index for each item.

form calindex using Line type i (visible lines on the screen)
FirstLine type i(see step 2)
LineIndex type i(item index)
changing Index type n. (index on the screen)

if FirstLine = 0.
index = LineIndex mod Line.
if index = '00'.
index = Line.
endif.
elseif FirstLine = 1.
index = LineIndex mod ( Line - 1 ).
if ( index between 1 and 0 ) and LineIndex gt 1.
index = index + Line - 1.
endif.
if Line = 2.
index = index + Line - 1.
endif.
endif.

endform.

Step5 write a subroutine to calculate the loop range.

form calrange using Line type i ( visible lines on the screen)
DataLine type i
FirstLine type i
loopindex like sy-index
changing begin type i
end type i.

If FirstLine = 0.
if loopindex = 1.
begin = 1.
if DataLine <= Line. end = DataLine. else. end = Line. endif. elseif loopindex gt 1. begin = Line * ( loopindex - 1 ) + 1. end = Line * loopindex. if end gt DataLine. end = DataLine. endif. endif. elseif FirstLine = 1. if loopindex = 1. begin = 1. if DataLine <= Line. end = DataLine. else. end = Line. endif. elseif loop index gt 1. begin = ( Line - 1 ) * ( loopindex - 1 ) + 2. end = ( Line - 1 ) * ( loopindex - 1 ) + Line. if end gt DataLine. end = DataLine. endif. endif. endif. endform. Step6 using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index in steploop/Table Control form creat_bdc. field-symbols: , , .

data: name1(14) value 'EKPO-EMATN(XX)',
name2(14) value 'EKPO-MENGE(XX)',
name3(15) value 'RM06E-SELKZ(XX)'.
assign: name1 to ,
name2 to ,
name3 to .
.
do pageno times.

if sy-index gt 1

*insert scroll page ok_code"

endif.
.
.
perform calrange using Line DataLine FirstLine sy-index
changing begin end.
.
.
loop at DataTable from begin to end.
perform calindex using Line FirstLine DataTable-LineIndex changing Index.
name1+11(2) = Index.
name2+11(2) = Index.
name3+12(2) = Index.
.
.
perform bdcfield using DataTable-matnr.
perform bdcfield using DataTable-menge.
perform bdcfield using DataTable-indicator.
.
.
.

endloop.

enddo.

BDC 1

Posted by Krishh Webworld | 6:12 PM | | 0 comments »

(1) BATCH INPUT CONCEPTS:

The SAP System offers two primary methods for transferring data into the System from other SAP Systems and non-SAP Systems. These two methods are collectively called "batch input" or "batch data communication."

basic technique for data transfer with batch input.

Both batch input methods work by carrying out normal SAP transactions, just as a user would. However, batch-input can execute the transactions automatically and is therefore suitable for entering large amounts of data that are already available in electronic form.
The batch input technique offers these advantages for transferring data:


No manual interaction is required during data transfer. If the data to be transferred is already available in electronic form (on a tape, for example), then you can enter the data automatically into the SAP System using batch input.

Batch input ensures data integrity. Batch input enters data into the SAP System using the same transactions that interactive users do. Batch input data is therefore submitted to all of the checks and controls that apply to data entered by normal interactive means.

The batch input methods.

There are several ways to process batch input data in the SAP System.


Batch input processing methods.

The first processing method could be called "classical batch input." In it, an ABAP/4 program reads the external data that is to be entered in the SAP System and stores the data in a "batch-input session." A session stores the actions that are required to enter your data using normal SAP transactions.

When the program has finished generating the session, you can run the session to execute the SAP transactions in it. You can either explicitly start and monitor a session with the batch-input management function (System --> Services --> Batch input) or have the session run in the background processing system.
This method uses the function modules BDC_OPEN, BDC_INSERT, and BDC_CLOSE to generate sessions.

In the second method, your program uses the ABAP/4 CALL TRANSACTION USING statement to run an SAP transaction. Batch-input data does not have to be deposited in a session for later processing. Instead, the entire batch-input process takes place inline in your program.

There is a third batch-input method using the ABAP/4 CALL DIALOG statement. However, SAP recommends against using this method unless necessary. The CALL DIALOG method is now outdated and is more complex and less comfortable to use than the other techniques.
All three batch-input methods use a common data structure for holding the instructions and data for SAP transactions. This structure is defined as structure BDCDATA in the ABAP/4 Dictionary.

For help in selecting the method to use, please see SELECTING A BATCH-INPUT METHOS (11).

Typical uses of batch input.

Uses of batch input include the following:

transferring data from another system when you install your SAP System
regularly transferring data that is captured by a non-SAP system in your company into the SAP System. Assume, for example, that data collection in some areas of your company is still performed by a non-SAP system. You can still consolidate all of your data in the SAP System by exporting the data from the other system and reading it into the SAP System with batch input.

You can also use batch input to transfer data between two R/3 Systems. However, there are more direct methods for doing this, such as RFC (remote function calls).

application support for batch-input.

The SAP applications provide pre-programmed support for batch input transfers for many of SAP's business objects.
To implement one of the supported data transfers, you must often write the program that exports the data from your non-SAP System. This program, known as a "data transfer" program must map the data from the external system into the data structure required by the SAP batch input program.
Should you wish to write a transfer program that executes outside the SAP System, then the SAP applications provide definitions of the required data formats for the exports. From these definitions, you can generate code for the data structures to include in your export program. You can also write such programs in ABAP/4, which lets you take advantage of the comfort and conveniences of the SAP Development Workbench.
Once you have exported the data, you can then use a standard, pre-programmed SAP report to import the data. This program uses one of the batch input methods to process the data and add it to the SAP System.

You can find information on pre-defined batch-input programs in the SAP Customizing System. Choose Tools --> Customizing. Then display either your Enterprise IMG (Implementation Guide) projects or the SAP standard IMG. In the project display, use the Expand function to display all nodes in the project. You can then search for relevant topics with the keywords batch input and transfer.

(2) TRANSFERING DATA : BATCH INPUT PROCEDURE IN OVERVIEW.

Transferring data with batch input requires the steps shown in the illustration and list below.
Note that SAP standard batch-input programs take care of several of these steps for you. For more information, please see BATCH INPUT CONCEPTS (1).



The procedure:

1. Analyze the data that is to be transferred to the SAP System.

Goal: Determine how your existing data should be mapped to the SAP data structure.
Method: You'll need to determine the structure of the data that is to be transferred into the system. Using the SAP data structure that you generate in step 2, you'll need to determine how the data to be transferred must be mapped to the SAP structure. You'll also need to determine whether any data type or data length conversions are required.

For more information, please see DATA CONVERSIONS(6).

2. Generate SAP data structures for incorporation into your data export program.

Method: Use the data structure generation function of the ABAP/4 dictionary to generate data structures for SAP tables in any of several programming languages.
If you are using one of SAP's standard batch input programs, then use of this function is required. The standard batch input programs generally require that you use a special pre-defined data structure.

For more information, please see GENERATING AN SAP DATA STRUCTURE(5).

If you're writing your own batch input procedure, then you will need to determine the data structure on your own. You'll need to analyze the SAP transactions to find the names of the fields that the transaction requires. For more information, please see ANALYSING SAP TRANSACTIONS(4).

3. Code your data transfer program. You can write the program in ABAP/4 or as an external program. You'll find more information in WRITING A DATA TRANSFER PROGRAM(3).

4. Export the data that is to be transferred to a sequential file.

Requirements:

The file must use the logical format required by the batch-input program that will import the file (step 6).

Reading and interpreting the file is much easier if you write it in ASCII or EBCDIC
(character) format rather than, for example, writing numeric data in hexadecimal format.

Character format is required by the pre-defined SAP batch input programs.

5. If necessary, code the ABAP/4 batch input program that will read in the data to be transferred from your file.

SAP supplies ready-to-run batch-input programs for most of the SAP applications.

For more information on writing your own program, see WRITING A BATCH INPUT PROGRAM : PROCEDURE IN OVERVIEW(10).

6. Process the data and add it to the SAP System. You can do this either by:

GENERATING A BATCH-INPUT SESSION(A) ; or
by processing data directly in your batch-input program with the ABAP/4 statement
CALL TRANSACTION USING (19).

7. Check that all data has been successfully processed.

Method: Analyze the batch input processing log. If you are using CALL TRANSACTION USING, then you will need to analyze the processing messages collected by your program.
You'll find more information on running and analyzing sessions and logs in MANAGING BATCH-INPUT SESSIONS(B).

8. Correct and re-process erroneous data.

Method: You can use the batch-input management function to process erroneous transactions interactively. You can correct data during this interactive processing.



A.GENERATING A BATCH-INPUT SESSION.


One of the two recommended ways to process batch input data is to store the data in a batch input session. This session can then be run in the SAP System to enter the batch input data into the system.

In general, preparing a session is the best and most comfortable way to process batch input data. However, you may wish to use the alternate method, CALL TRANSACTION USING, if your batch input sessions cannot be run quickly enough. For more information on choosing the best batch input method, see SELECTING A BATCH-INPUT METHOD(11).

Creating, Filling, and Closing a Batch Input Session

To create a session, program the following procedure using the following BDC_ function modules:

1. Open the batch input session using function module BDC_OPEN_GROUP (15) .
2. For each transaction in the session:

a. Fill the BDCDATA structure with values for all screens and fields that must be
processed in the transaction. For more information, please see USING THE
BATCH-INPUT DATA STRUCTURE (12).

b. Transfer the transaction to the session with BDC_INSERT (16) .

3. Close the batch input session with BDC_CLOSE_GROUP (17).

The following topics describe these function modules. See SAMPLE BATCH INPUT PROGRAM(22) for an example of how the function modules are used.

BDC 2

Posted by Krishh Webworld | 6:11 PM | | 0 comments »

B.MANAGING BATCH-INPUT SESSION.

Batch input sessions enter data non-interactively into an R/3 System. Batch input is typically used to transfer data from non-R/3 Systems to R/3 Systems or to transfer data between R/3 Systems.

This section describes how to manage batch input sessions.
To reach the main menu of the batch input system, select System --> Services --> Batch input.

Overview and Concepts

a) Task Overview: Batch Input
b) Batch Input: Concepts

Working with Batch Input Sessions

c) Processing Sessions Automatically
d) Selecting Sessions
e) Running Sessions
f) Correcting a Session
g) Deleting Sessions
h) Locking and Unlocking Sessions
i) Releasing and Restarting an Interrupted Session

Information and Analysis

j) Displaying Queue Management Information
k) Displaying Session Logs
l) Reorganizing the Log File
m) Analyzing Sessions

a) Task Overview: Batch Input.

With the functions of the batch input management system, you can do the following:

Start batch input sessions to enter data into an R/3 System.
For debugging sessions that contain errors, the batch input system offers two modes for running sessions interactively.

Schedule the background program that automatically submits sessions for processing in
the background.

Lock a session until a specified date.
Locking a session prevents it from being run.

Delete batch input sessions.

Release a session for re-execution if it has been aborted by a system failure or
shutdown while being created or executed.

Analyze a batch input session before or after it has run.
The analysis function lets you display data entered in the transactions in a session. You can:

display the screens called by the session with the session data filled in.
display listings of input fields by field name, with the session data for each field.

Display the log produced by a batch input session.

Functionally:


For help in generating sessions, please see the Basis Programming Interfaces manual.

b) Batch Input: Concepts:

Processing Sessions

A batch input session is a set of one or more calls to transactions along with the data to be processed by the transactions. The system normally executes the transactions in a session non-interactively, allowing rapid entry of bulk data into an R/3 System.

A session simulates on-line entry of transactions and data. It calls transactions and enters data using most of the facilities that are available to interactive users.

For example, the data that a session enters into transaction screens is subject to the same consistency checking as in normal interactive operation. Further, batch input sessions are subject to the user-based authorization checking that is performed by the system.

Generating Sessions

To transfer data with batch-input, the system that is sending the data uses a data transfer interface provided by an R/3 application program in the receiving system. The interface program in the application then produces a batch input session.

The interface program in an application is an ABAP/4 program that sets up the transaction calls and data that make up a session. If the batch input session contains data from an external source, the program also reformats the data to meet the requirements of the input fields in which the data is to be entered. Usually, such programs are provided by the R/3 applications. For more information, please see the documentation of the R/3 applications.

Authorizations

When a session is generated, a client and user are associated with it. If the session is run in background-processing mode, the system uses this user for authorization checking as the session runs. This authorization testing applies whether you sent the job for batch execution or the session was started by a background job.

Sessions that you process in one of the interactive modes are run with your authorizations. The interactive modes are described later in this section.

c) Processing Sessions Automatically:

In most systems, sessions are started non-interactively with a background job that periodically checks for and starts any sessions that have not yet been run. Running sessions interactively is usually reserved for testing sessions or correcting sessions.

To start batch input sessions automatically, schedule the ABAP/4 program RSBDCSUB for repeated execution. The program schedules sessions for immediate execution in the background processing system.

With RSBDCSUB, you can use all of the selection criteria offered on the batch input main menu to select sessions to run:

session name
date and time of generation
status: ready to run or held in the queue because of errors

d) Selecting Sessions:

To reach the main menu for managing batch input sessions, select System --> Service -->
Batch input. On the main menu, you can select sessions using any or all of the following criteria:

session name
date on which the session was generated (entered into the session queue)
session status

You can also select from one of two actions:

To display the session queue, select Session --> Overview.
You can start, analyze, or delete sessions in the queue.

To display session log files, select Session --> Logs.

All sessions generate a log when they are run. From the list of session logs, you can take further actions, such as analyzing a session.

The Session Queue

The information in the session queue includes the following:

Date and Time: The date and time when a session was generated (entered in the
session queue).
Locked: If a session is locked, this column shows the date upon which the system
releases the session. A locked session cannot be started.
Created by: The user who generated the session.
Tran. and Screen: The number of transactions and screens, respectively, that remain to be processed in a session.

Auth. user: The user under whose authorizations the session will be run if it is submitted for batch execution.

You can display statistics on the transactions in any session by marking the session and using the Statistics function.

Session Sorting and Status

Sessions in the session queue are sorted by date and time of generation and are grouped in different lists according to their status.

possible statuses are as follows:

not yet processed

The Tran. and Screen fields in the display show how many transactions and screens,
respectively, the session contains.

held in the session queue because of errors in transactions (Errors in sessions)

Transactions that contained errors are aborted; all correct transactions are processed.
The Tran. and Screen fields in the session display show how many incorrect
transactions were found in the session.
You can restart a session and correct the erroneous transactions with one of the interactive execution modes offered by the batch input system. For more information, please see Correcting a Session(f).

processed

For further information on a session that has been successfully run, you can display the log generated by the session. All completed sessions generate a log. You cannot run a completed session a second time.

Only sessions that were generated with the KEEP option are held in the queue after
processing. Other sessions are deleted after they are successfully completed.

in generation

You will usually see this status only if you happen to display the queue while a session is being generated (entered into the session queue).

You can also encounter this status if a system failure has interrupted the generation of a session. If you suspect that a session has been interrupted, please see Releasing and Restarting an Interrupted Session(i) for more information.

in process

You will usually see this status only if you happen to display the queue while a session is being run.

You can also encounter this status if a system failure has interrupted the execution of a session. If you suspect that a session has been interrupted, please see Releasing and Restarting an Interrupted Session(i) for more information.

e) Running Sessions:

Running a batch input session executes the transactions in the session and enters data into an R/3 System.
To start a session, select Session ® Overview from the main batch input screen. Then mark the session(s) that you wish to start and select Session ® Process or ® Process in batch.
You can start any session in the not yet processed list that is not locked. With Process/foreground or mode, you can also re-start transactions that have the status Incorrect. Sessions with the status Processed cannot be run again.

Run Modes

There are three ways to run a session:


Process/foreground: You can interactively correct transactions that contained errors and step through transactions that have not yet been executed.

Display errors only: This mode is like Process/foreground except that transactions that have not yet been run and which do not contain errors are run non-interactively.

If an error occurs, processing stops and the screen upon which the error occurred is displayed.

Process in Batch: Use batch mode to schedule a session for immediate processing in the batch facility.

You receive control of your terminal again as soon as the session has been passed to the batch system.

Note that your session is automatically released for processing in the background processing system. You need not explicitly release the session for processing.
A completed session is handled in one of three ways:

The system deletes a session from the queue when it has been successfully completed. You can check on the outcome of the session by displaying the session log file.
If the KEEP option was set when the session was generated, then the system leaves a session in the queue, even if it was run successfully. The status is changed to Processed.

You cannot run the session a second time. You must manually delete it when you no longer need it.

If a transaction in the session contained an error, the incorrect transaction is aborted. All other transactions are completed. The session remains in the queue and is held in the Errors section of the list. You can correct the session in one of the interactive modes and run it to completion.

A transaction contains an error if it issues a message of type E (error) or type A (abnormal termination). Other messages are ignored and do not affect the execution of a session..
A session also is held in the queue in the Errors list if the session was ended with the /bend OK code. Please see Correcting a Session(f).

For more information on correcting sessions with the display-all or error-display mode, please see Correcting a Session(f).


f) Correcting a Session:

When a session is run in background-processing mode, the system marks transactions that contain errors as incorrect. All other transactions in the session are completed. The session itself is kept in the session queue in the Errors section of the list.
A transaction contains an error if it generates an error message of type E (error) or type A (abnormal termination). Messages of other types are ignored and do not affect the execution of a session.
You can correct and re-execute the incorrect transactions in an "Errors" session. There are two ways to do so:

1. Re-run the session in display-all or error-display mode. These modes offer the following advantages:

The system skips transactions that were successfully completed. Only incorrect transactions or transactions that have not been executed are run.
You can change inputs and add missing screens interactively as incorrect transactions run.

The following topic provides more information on using display-all mode or error-display mode to correct a transaction.

2. As an alternative, you can analyze the session to determine what the error was. With the analysis displays, you can check the screen that contained the error and the values that were entered in it. You can then correct the program that generated the session and regenerate the session.

You must ensure that the new session does not include transactions that were successfully completed. Otherwise, the updates made by the transactions will be performed again.

Using Display-All Mode

When you use display-all mode to re-start a session that contains an incorrect transaction, the system skips to the first screen of the incorrect transaction. Completed transactions are not re-executed.

options when you run a session interactively.

To correct a transaction, you can:

use the ENTER key to step through the screens recorded in the session

As in normal operation, pressing the ENTER key starts a dialog step. As long as you simply press ENTER, the system processes the screens and data recorded in the session.

change or add values in any screen

When you press ENTER, the system processes the data as altered by you.

branch off from the transaction flow recorded in the session

You can use any function that you wish within the transaction that is currently running. You can, for example, branch off to enter data on a screen that was omitted from the session.
To resume executing the session, return to the screen that was expected by the session.
It holds the data for the screen recorded in the session until you have returned to that screen. It then resumes normal execution of the session.

Interrupting a Session

You can interrupt the interactive execution of a session by entering the /bend OK code on any screen. /bend terminates the transaction currently being executed in the session and marks the transaction with the status Incorrect. The session is kept in the queue and is displayed in the Errors in sessions section of the list.
You can use /bend when testing sessions. For example, you may wish to run the first two transactions of a large session in display-all mode to make sure that the session has been generated correctly.

If the transactions are correct, you can then terminate the run with /bend and then submit the session for background execution. The transactions that have already been run will not be run again.

Deleting a Transaction

You can delete a transaction from a session during interactive execution by entering the /bdel OK code. The transaction is removed from the session. The deleted transaction cannot be run even if you restart the session, and you cannot take back the deletion.

The transaction is, however, available for analysis if the session was generated with the KEEP option set. The transaction is marked with the status Deleted in the analysis display. The deletion also is recorded in the log generated by the session.


g) Deleting Sessions:

You can delete any session from the session queue. Deleting a session discards the session. If the session has already been run, you also delete the session log.

Normally, sessions are deleted from the session queue automatically when they are completed. However, if a session was generated with the KEEP option, it is kept in the session queue. You must explicitly delete the session when you no longer need it.

A session is also kept in the queue if it contained an error or was broken off with the /bend OK code. Such a session is deleted when you finish processing it, unless it was generated with the KEEP option.

To delete a session from the session queue, mark the sessions to be deleted and select Edit --> Delete.

h) Locking and Unlocking Sessions:

You can lock sessions in the session queue by marking the sessions and selecting Edit ® Lock.
Locking a session prevents a session from being started until after the date recorded in the lock. For example, a session locked until the eleventh of November can be started only after that date.
You may wish to lock a session for such reasons as

holding a session until a specified date
preventing a session that contains errors from being re-started
preventing a session that requires a special resource, such as printer forms or a specific tape, from being started unintentionally.

You can unlock a session by changing the lock date to the present date or by entering a space as the lock date.


i) Releasing and Restarting an Interrupted Session:

If a system problem occurs while a session is being generated or is being run, the session is terminated abnormally. Typical causes of an abnormal termination might include shutdown of the R/3 System while a session is running or termination of a SAPGUI presentation process while a session is being run interactively.

In the session queue, a session that was terminated while it was being generated remains in the Being generated section of the list. A session that was terminated while it was running remains in the Active list.

You can recognize that a session has terminated abnormally because the status of the session does not change. If, for example, you find a session that was run the previous night still in the Active list, then it is likely that the session was interrupted.

If a session was to run in the background, you can check the status of the session's job in the background processing system. If the session was aborted, then the background job log contains the reason for the abnormal termination.

Before you can restart (or start) a session that terminated abnormally, you must release it. Releasing the aborted session sets its status to Being processed. Reset the status by marking the session or sessions and selecting Edit --> Release.

You can safely restart a session that was interrupted while it was being run. When you restart the session, all transactions that were successfully completed before the problem occurred will be skipped. The transaction that was executing when the problem occurred will be re-executed.


caution

Release an active session only if you are sure that it has been interrupted and is no longer running.. Sessions also have the status Active while they are running.

caution
Restarting after abnormal termination during generation: You can start a session that was interrupted while it was being generated. The session is guaranteed to contain only complete transactions and to be runnable.

However, there is no guarantee that the session contains all of the transactions that were to be included in it. You may therefore wish to delete and regenerate such a session.



j) Displaying Queue Management Information:

Should you ever need to review the internal queue-management information on a particular entry, you can display this information by marking an entry and selecting Analysis --> Queue.
Not all of the queue management fields displayed are used by the batch input system; the queue management functions are used by other queues in the system as well. The fields that are used by the batch input system are as follows:

Client: The client in which a session is to run.
Groupid: The session name.
QID: The internal ID of a session. The ID is used for queue management with System -> Services --> Queue.
QSTATE: A character indicating the status of the batch input session.
QERASE: If marked, indicates that the KEEP option is set. If KEEP is set, the system does not delete the session after it is successfully run.
USERID: User to be used for authorization testing if a session is submitted for background execution.
displaying Session Logs:

Every batch input session generates a log when it runs. To display a log, you can either:

select Session --> Logs from the batch input main menu; or
put the cursor on a particular session in the session queue and select Goto --> Log.

A session log contains any error messages issued by transactions in the session. It also includes batch input error messages reporting any problems in running transactions, together with the transaction and screen at which the problem occurred. Finally, a log contains a set of summary statistics.


l) Reorganizing the Log File:

You should periodically use the ABAP/4 program RSBDCREO to reorganize the batch input log file. You can run RSBDCREO in the background or interactively.

Running the program reduces the size of the log file, BI, in the shared R/3 directory "global" in the host system to the minimum possible size. Deleting a session marks a session log for deletion, but the storage held for the log is returned to the host only by a reorganization.

The program will delete a log only if the session to which the log belongs has been deleted.


m) Analyzing Sessions:

Use the analysis functions to check on the actions performed by a batch input session. The analysis functions allow you to display the transactions, screens, and data in a session.

You can use these functions before or after a session has been run.

note
Analysis of sessions that have been run is available only for sessions that contained an error or which were generated with the KEEP option. The KEEP option prevents the system from deleting a session that has been successfully run.

You can analyze a session by marking the session in the session queue and selecting Goto --> Analysis --> Session or by selecting Analysis from the session log screen.

Analysis Blocks

Reading very long sessions from the database can cause time-outs to occur. For this reason, the system reads sessions for analysis in blocks.

Blocks do not restrict your ability to display a long session. You can switch forward and backward from block to block with function keys.

A block always contains only complete transactions. A block boundary cannot fall in the middle of a transaction.

Session Summary

The first analysis screen lists the transactions and screens recorded in the session.

Screens are identified by the name of the program and the number of the screen. Statuses are identical to those of the session queue, except that transactions that were deleted with the /bdel OK code have the status Deleted.

Session Data

You can display the data entered on each screen of a session by selecting Analysis ® Data from the first analysis screen.

You can have the data presented to you in two formats:

• The first data display presents data in list format by field name.
• Alternatively, you can switch to the screen called by the session with the session data shown on it.

You can switch back and forth from one form of display to the other.

BDC 3

Posted by Krishh Webworld | 6:11 PM | | 0 comments »

(3) WRITING A DATA TRANSFER PROGRAM:

The data transfer program is responsible for doing the following:

Converting the data that is to be transferred into the SAP System as required by the SAP data structure or transactions that you are using.

The data structure may be generated from the standard SAP data structures (see Generating an SAP Data Structure(5)). This is required if you are working with a standard SAP batch input program. Or, if you are creating your own batch input procedure, you may have developed the data structure yourself by analyzing the SAP transactions with which the data is to be entered.

A conversion may be necessary for data type and length. The data type required by all standard SAP batch input programs is C, character data. You can find the required field lengths either in your analysis of the SAP data entry transactions or in the data structures that you generate in the ABAP/4 Dictionary.

Exporting the data in SAP format to a sequential file. The batch input program in the SAP System reads the data in from this file.

Task Overview

The tasks involved in writing a data transfer program are shown in the diagram and list below.


Writing a Transfer Program

The procedure:

1. Analyze the structure of your existing data and specify the conversions that are required to fill the SAP data structures.
2. Generate the SAP data structure in code form and insert it into your program.

If the program is written in ABAP/4, you need only include the required tables in your program with the TABLES statement.

3. Initialize the SAP data structure.
4. Fill the structure with data, performing any conversions and error-checking that are required.
5. Write the sequential file that is typically required for making the data available to the batch input program in the SAP System.


(4) ANALYZING SAP TRANSACTIONS:

If you are creating your own batch input procedure, then you will need to analyze the SAP transaction(s) with which the batch input data is to be entered into the SAP System.

The purpose of the analysis is to gather the following information:

the transaction code, if you do not already know it
which fields require input
which fields you can allow to default to standard values
the names, types, and lengths of the fields that are used by a transaction
the identifiers of the functions that you will need to call to have the transaction process the batch input data.



Collecting Transaction Data

To analyze a transaction, do the following:

1. Start the transaction by menu or by entering the transaction code in the command field.

You can determine the transaction name by choosing System --> Status.

2. Step through the transaction, entering the data and performing the functions that will be required for processing your batch input data.

3. On each screen, note the program name and screen (dynpro) number.

Display these by choosing System --> Status. The relevant fields are Program (dynpro)and Dynpro number.

If pop-up windows occur during execution, you can get the program name and screen number by pressing F1 on any field or button on the screen. The Technical info pop-up shows not only the field information but also the program and screen.

4. For each field, check box, and radio button on each screen, press F1 (help) and then choose Technical info.

Note the following information:

The field name for batch input, which you'll find in its own box.
The length and data type of the field. You can display this information by double- clicking on the Data element field.

5. Find out the identification code for each function (button or menu) that you must execute to process the batch input data.

Put the cursor on the button or menu entry while holding down the left mouse button. Then press F1. In the pop-up window that follows, choose Technical info and note the code that is shown in the Function field.

You can also run any function that is assigned to a function key by way of the function key number. To display the list of available function keys, click on the right mouse button. Note the key number that is assigned to the functions you want to run.


Getting Screen and Field Information in the Transaction Interface

Using the Screen Painter and Menu Painter to Get Field and Function Info

You can also obtain field and function information from the screen and menu definitions in the ABAP/4 screen painter and menu painter. For example, you can quickly display field information in the screen painter by displaying the screen in the Fullscreen editor and using the Attribs. for 1 field button for each field.



Getting Field Information in the Screen Painter

Similarly, you can get function and menu codes from the CUA definition of a screen in the menu painter.
See the ABAP/4 Development Workbench documentation for more information on using these tools.

BDC 4

Posted by Krishh Webworld | 6:10 PM | | 0 comments »

(5) GENERATING AN SAP DATA STRUCTURE:

You can use the ABAP/4 Dictionary to generate data structures for SAP tables in any of the following programming languages:

Cobol
PL/1
C

You can then incorporate these data structures in your data conversion program.

For most of the standard SAP batch input programs, SAP has also provided special data structure identifiers. With such an identifier, you can generate a listing of all of the table fields that are required by the corresponding batch input program. You do not need to find out which tables are required for the batch input program and generate their structures individually. If you are creating your own batch input procedure, you may be able to use the standard field listings as well.

The names of the special data structure identifiers are documented in the SAP Customizing system. For information on finding the relevant documentation, please see Batch Input Concepts(1).

Data Transfer Programs in ABAP/4

If your data transfer program is written in ABAP/4, you can include data structures of tables in your program with the TABLES instruction. The structure is then read directly from the ABAP/4 Dictionary.

In this case, you cannot use the special data structure identifiers provided by the SAP applications. The identifier names are not recognized by the TABLES instruction. Instead, you can find the required table names by checking the transactions that your batch input procedure will be using to enter data. Or you can find the table names in the listings generated by the special identifiers.

The diagram below shows the structures of transfer programs in ABAP/4 and as external programs written in other languages.


Including Table Structures in Transfer Programs: ABAP/4 and Other Languages

Procedure

To generate a data structure, do the following:

1. Choose Tools --> ABAP/4 Workbench and then ABAP/4 Dictionary.
2. In the ABAP/4 Dictionary, select Environment --> Generate table description.

With this function, you can generate the structures of one or a group of SAP tables in programming code. You can then add this code to your data transfer program.

3. Specify the programming language in which the structure should be generated and identify the tables to be included.

If you wish to use a special structure identifier for a standard SAP batch input report,then enter the identifier in the Key in TSRCG field. Example: The identifier AM-ANLA generates the data structure required for data transfers for the asset management application.

4. The system displays the data structure in list form, as in this example in PL/1 from the asset management application (AM-ANLA):

******************************************************************
* MEMBER GENERATED FROM SAP DATA DICTIONARY *
* T A B L E BALTD *
* DATE: 08.12.1995 TIME: 17:47:16 *
* PLEASE DO NOT CHANGE MANUALLY *
******************************************************************
*
01 BALTD.
*
* Client (Old Assets Data Takeover AM)
05 MANDT PIC X(3)
VALUE SPACE.
* Company code
05 BUKRS PIC X(4)
VALUE SPACE.
* Asset class
05 ANLKL PIC X(8)
VALUE SPACE.

Choose System --> List --> Save --> File to download the data structure to your workstation or PC.



6) DATA CONVERSIONS:

Use the field descriptions that you obtained in Analyzing SAP Transactions(4) or Generating an SAP Data Structure(5) to determine the following:

which fields can be taken over directly from your existing data. That is, there is a direct match between an existing data field and the corresponding SAP data field.

for which fields a conversion procedure is necessary for mapping your existing data to the requirements of the SAP System.

CoNverting Data from Old Format to SAP Format

Your program must format batch input values just as an on-line user would when typing them in. In particular:

The data must be character format.
No piece of data may be longer than its target SAP field.
If the data is shorter than the target field, you must left-justify it within the SAP field (pad it with blanks at the right end).

(7) INITIALIZING AN SAP DATA STRUCTURE:

Standard SAP batch input programs require that every field in a data structure contains either:

a value; or
a special NODATA marker, which indicates that the no batch input data is required for the field.

If you are writing your own data transfer program, you should therefore initialize all of the fields in your batch input data structure with the NODATA character. The NODATA character must occupy the first position in the field, as shown in the figure below.

By default, the NODATA character is the forward slash. To initialize a field to NODATA, you must write this character as the first character in the field value.



If a batch input program finds NODATA in a field, then the program allows the field to default to its standard value in the SAP transaction that contains the field.

Setting the NODATA marker: You can freely select another character as the NODATA marker. Define the new character in the batch input program that reads the data in the BGR00-NODATA field:

Data: like bgr00.
-NODATA = ''.

GENERATING A SEQUENTIAL FILE:

If you are transferring data from a non-SAP System, then you will probably need to use a file as the transfer medium for the data. (For data transfer between SAP Systems, you may be able to use RFC or CPI-C to process data directly in the target SAP System.)

The file that you generate should have the following characteristics:

All data should be in character format. This is required by the standard SAP batch input programs.

Data must have the logical structure expected by the batch input program.

For a standard SAP batch input program, this requirement means that you have generated the data structure defined for the batch input program. For more information, see Generating an SAP Data Structure(5).

You'll find sample code for reading from and writing to a sequential file in Sample Program: Data Transfer(9) .



(9) SAMPLE PROGRAM: DATA TRANSFER:

The following ABAP/4 program demonstrates the data transfer process. The program does the following:

reads customer address data from a sequential file
checks the data for unacceptable records
performs conversions on the data
writes the data back out to a sequential file using the format required by the SAP standard batch input program Batch Input Interface for Customers (ABAP/4 program RFBIDE00).


EXAMPLE:

REPORT BITFER.

* SAP structures for batch input processing:
TABLES: BGR00, BKN00, BKNA1.

* Structure of existing data to be transferred:
DATA: BEGIN OF OLDREC,
TELE1(10) TYPE C,
CUSTNR(8) TYPE C,
TITLE(2) TYPE C,
NAME1(30) TYPE C,
END OF OLDREC.

* Auxiliary structure for initializing fields:
DATA: BEGIN OF AUXREC.
INCLUDE STRUCTURE BKNA1.
DATA: END OF AUXREC.

* SAP fields for converted data:
DATA: CUSTNR LIKE BKN00-KUNNR,
NAME1 LIKE BKNA1-NAME1,
TELE1 LIKE BKNA1-TELF1.

* For initializing fields:
DATA: N TYPE I.
FIELD-SYMBOLS .

* File and session names, NODATA character:
PARAMETERS:
OLDFILE(20) DEFAULT '/tmp/oldfile' LOWER CASE,
SAPFILE(20) DEFAULT '/tmp/sapfile' LOWER CASE,
ERRFILE(20) DEFAULT '/tmp/errfile' LOWER CASE,
SESSION(20) DEFAULT 'ADDRDAT' LOWER CASE,
NODATA DEFAULT '/' LOWER CASE.

START-OF-SELECTION.
OPEN DATASET: OLDFILE FOR INPUT IN TEXT MODE,
SAPFILE FOR OUTPUT IN TEXT MODE,
ERRFILE FOR OUTPUT IN TEXT MODE.

* Open batch input session as first SAPFILE entry:
* program:
MOVE: 'O' TO BGR00-STYPE,
SESSION TO BGR00-GROUP,
SY-MANDT TO BGR00-MANDT,
SY-UNAME TO BGR00-USNAM,
NODATA TO BGR00-NODATA.
TRANSFER BGR00 TO SAPFILE.

* Initialize data fields with NODATA:
DO.
ADD 1 TO N.
ASSIGN COMPONENT N OF STRUCTURE AUXREC TO .
IF SY-SUBRC NE 0. EXIT. ENDIF.
MOVE BGR00-NODATA TO .
ENDDO.
MOVE AUXREC TO BKNA1.

* Read and convert existing data:
DO.
" Read data record:
READ DATASET OLDFILE INTO OLDREC.
IF SY-SUBRC NE 0. EXIT. ENDIF.
" Check data and transfer only certain records:
IF OLDREC-CUSTNR(5) NE 'AABBC'
OR OLDREC-CUSTNR(6) EQ 'AABBCD'
OR OLDREC-TELE1 EQ SPACE.
TRANSFER OLDREC TO ERRFILE.
* TEXT-001: 'Data not transferred for customer:'
WRITE: / TEXT-001, OLDREC-CUSTNR.
ELSE.
" Convert the customer number to SAP convention:
IF OLDREC-CUSTNR+5(1) = 'C'.
IF OLDREC-CUSTNR+5(1) = 'D'.
ENDIF.
" Convert abbreviations to full words:
CASE OLDREC-TITLE.
WHEN 'Co'. BKNA1-TITLE = 'Company'.
WHEN 'Corp'. BKNA1-TITLE = 'Corporation'.
WHEN OTHERS. BKNA1-TITLE = NODATA.
ENDCASE.
" Convert records from old format to SAP format:
MOVE: OLDREC-CUSTNR TO CUSTNR,
OLDREC-NAME1 TO NAME1,
OLDREC-TELE1 TO TELE1.
" Fill SAP structures:
MOVE: '1' TO BKNOO-STYPE,
'XD02' TO BKNOO-TCODE,
CUSTNR TO BKNOO-CKUNNR.
MOVE: '2' TO BKNA1-STYPE,
'BKNA1' TO BKNA1-TBNAM,
'TELE1 TO BKNA1-TELF1,
NODATA TO BNKA1-SENDE.
" Transfer data to SAPFILE:
TRANSFER: BKNOO TO SAPFILE,
BKNA1 TO SAPFILE.
* TEXT-02: 'Data was transferred for customer:'
WRITE: / TEXT-002, OLDREC-CUSTNR, BKNOO-CUSTNR.
ENDIF.
ENDDO.
CLOSE DATASET: OLDFILE, SAPFILE, ERRFILE.





(10) WRITING A BATCH INPUT PROGRAM: PROCEDURE IN OVERVIEW:

In general, you can transfer data from an existing system into the SAP System with pre-defined batch input programs, delivered with the SAP System.

In some cases, however, you will need to write your own batch input program. For example, the standard SAP batch input programs in an application may not have foreseen the data transfer requirement you have, or you may wish to customize the standard data transfer procedure.

To write your own batch input program, you'll need to do the following:

1. Analyze the transaction(s) that you will use to process your batch input data.

You may have already done this when you wrote your data transfer program. Please see Writing a Data Transfer Program(3) and Analyzing SAP Transactions(4) for more information.

2. Decide on the batch-input method that you wish to use.

"Classical" batch input -- by way of a batch input session -- is more comfortable. Restart-capability and detailed logging are supported by the batch input management transaction for batch input sessions.

Batch input by way of CALL TRANSACTION USING offers faster processing if you need it to get your batch input done in the time slot that is available for it. CALL TRANSACTION USING offers, however, less support for error recovery and management of batch input.

For detailed information, please see Selecting a Batch-Input Method(11) .

3. Write the batch input program.

Your program will need to do the following:

read data in, often from a sequential file that has been exported from another system or prepared by a data transfer program
if necessary, perform data conversions or error-checking
prepare the data for batch input processing by storing the data in the batch input data structure, BDCDATA.
generate a batch input session for classical batch input, or process the data directly with CALL TRANSACTION USING.

BDC 5

Posted by Krishh Webworld | 6:09 PM | | 0 comments »

(11) SELECTING A BATCH-INPUT METHOD:

When you generate batch input in ABAP/4, you have three options for submitting the data to batch input processing. Only the first two methods can be recommended without reservation. The third method, by way of CALL DIALOG, is outmoded. CALL DIALOG Is less comfortable than the other methods. You should use it only if you must.


Create a session on the batch input queue.

Summary: Standard method. Offers management of sessions, support for playing back and correcting sessions that contain errors, and detailed logging.

Your program prepares the data and stores it in a batch input session. A session is a collection of transaction data for one or more transactions. Batch input sessions are maintained by the system in the batch input queue. You can process batch input sessions in the background processing system.

Your program must open a session in the queue before transferring data to it, and must close it again afterwards. All of these operations are performed by making function module calls from the ABAP/4 program.

The most important aspects of the session interface are:

Asynchronous processing
Transfers data for multiple transactions
Synchronous database update

During processing, no transaction is started until the previous transaction has been written to the database.

A batch input processing log is generated for each session
Sessions cannot be generated in parallel

The batch input program must not open a session until it has closed the preceding session.

Use the CALL TRANSACTION USING statement

Summary:

Offers faster processing of data than batch input sessions. Recommended if you're having problems getting data entered into your SAP System quickly enough. The playback, interactive correction, and logging facilities offered for batch input sessions are not available for CALL TRANSACTION USING.
Your program prepares the data and calls the desired transaction for immediate processing.

The most important aspects of the CALL TRANSACTION USING interface are:

Synchronous processing
Transfers data for a single transaction
Synchronous and asynchronous database updating both possible
The program specifies which kind of updating is desired.
Separate LUW for the transaction
The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
No batch input processing log is generated

Use the CALL DIALOG statement

Summary:

Not recommended if you can enter data by way of sessions or CALL TRANSACTION USING.
Your program prepares data for a sequence of dialog screens, and calls a dialog module for immediate processing.

The most important aspects of the CALL DIALOG interface are:

Synchronous processing
Transfers data for a sequence of dialog screens
No separate database update for the dialog
A database update occurs only when the calling program executes a commit operation.

Shares LUW with calling program
No batch input processing log is generated

(12) USING THE BATCH INPUT DATA STRUCTURE:

The batch input structure stores the data that is to be entered into SAP System and the actions that are necessary to process the data. You can think of the structure as storing the script that the SAP System is to follow in processing batch input data.

The batch input structure is used by all of the batch input methods. You can use the same structure for all types of batch input, regardless of whether you are creating a session in the batch input queue or using CALL TRANSACTION USING or CALL DIALOG.

The diagram below shows how to declare the structure in your ABAP/4 program and the fields contained in the structure.



BDCDATA Structure

Information structure: A BDCDATA structure can contain the batch input data for only a single run of a transaction. The typical processing loop in a program is therefore as follows:

Create a BDCDATA structure
Write the structure out to a session or process it with CALL TRANSACTION USING; and then

Create a BDCDATA structure for the next transaction that is to be processed.

Within a BDCDATA structure, data is organized by the screens in a transaction. Each screen that is processed in the course of a transaction must be identified with a BDCDATA record. This record uses the Program, Dynpro, and Dynbegin fields of the structure:

The screen identifier record is followed by a separate BDCDATA record for each value that is to be entered into a field. These records use the FNAM and FVAL fields of the BDCDATA structure. Values to be entered in a field can be any of the following:

data that is entered into screen fields
function codes that are entered into the command field. Such function codes execute functions in a transaction, such as Save.
cursor-positioning commands.

The transaction to which a BDCDATA structure refers is identified separately. If your program writes data to a batch input session, then the transaction is specified in the call to the BDC_INSERT function module. This function module writes a BDCDATA structure out to the session. If your program processes data with CALL TRANSACTION USING, then the transaction is specified directly in this statement.

The following table shows what the contents of a BDCDATA structure might look like. This BDCDATA structure would add a line to a report in transaction SE38, the ABAP/4 Editor:

BDCDATA Structure for Adding a Line to a Report (Transaction SE38)

PROGRAM DYNPRO DYNBEGIN FNAM FVAL
----------------- ------------- ----------------- -------------------------- ----------
SAPMS38M 0100 X
RS38M-PROGRAMM
RS38M-FUNC_EDIT X
BDC_OKCODE =CHAP (Change function code)
SAPMSEDT 2310 X
RSTXP-TDLINECOM(1) B-
SAPMSEDT 2310 X
BDC_CURSOR RSTXP- TDLINECOM(1)
RSTXP-TDLINE(1) BDC Test Text
BDC_OKCODE /11 (Save function key)
SAPMSEDT 2310 X
BDC_OKCODE /3 (Back function key)
SAPMS38M 0100 X
BDC_OKCODE /15 (Quit function key)

Fields: The fields in the BDCDATA structure are as follows:

PROGRAM

Name of the program. Length (8). The PROGRAM field is not case-sensitive. Set this field only in the first record for the screen.

DYNPRO

Number of the screen. Length (4). Set this field only in the first record for the screen.

DYNBEGIN

Indicates the first record for the screen. Length (1). Set this field to X only in the first record for the screen. (Reset to ' ' (blank) for all other records.)

FNAM

Name of a field in the screen. Length (35). The FNAM field is not case-sensitive.

FVAL

Value for the field named in FNAM. Length (132). The FVAL field is case-sensitive. Values assigned to this field are always padded on the right if they are less than 132 characters. Values must be in character format.

Finding function codes and program and field names: Please see Analyzing SAP Transactions(4) for more information.

Data formatting requirements: Please see Data Conversions(6) for more information.

BDC 6

Posted by Krishh Webworld | 6:08 PM | | 0 comments »

(13) PROGRAMMING TECHNIQUES :

ENTERING DATA AND EXECUTING

FUNCTIONS:

a)Sample Code: Filling the BDCDATA Structure
b)Identifying a Screen
c)Entering a Value in a Field
d)Executing a Function
e)Entering Values in Loop Fields
f)Positioning the Cursor
g)Ending a Transaction

a)Sample Code: Filling the BDCDATA Structure:

The following form routine shows how the BDCDATA structure should be filled. Build the structure line by line using MOVE and APPEND statements. Before building each line, reset the header line of the internal table with the CLEAR statement.

Special techniques, such as placing the cursor, are not shown in this example.

Example:

Assume in this example that the BDCDATA structure has been declared as BDCDAT in the ABAP/4 program:

FORM Fill-BDC-Table
REFRESH BDCDAT

" Start new DYNPRO
CLEAR BDCDAT
MOVE: TO BDCDAT-PROGRAM.
TO BDCDAT-DYNPRO.
'X' TO BDCDAT-DYNBEGIN.
APPEND BDCDAT.

" Enter fields and values for DYNPRO
CLEAR BDCDAT.
MOVE: TO BDCDAT-FNAM.
TO BDCDAT-FVAL.
APPEND BDCDAT.
CLEAR BDCDAT.
MOVE: TO BDCDAT-FNAM.
TO BDCDAT-FVAL.
APPEND BDCDAT.
...
...
" Start next DYNPRO
CLEAR BDCDAT.
MOVE: TO BDCDAT-PROGRAM.
TO BDCDAT-DYNPRO.
'X' TO BDCDAT-DYNBEGIN.
APPEND BDCDAT.
ENDFORM.


b) Identifying a Screen:

The first record for each screen must contain information that identifies the screen: program name, screen name and a start-of-screen indicator. You record this information in the PROGRAM, DYNPRO, and DYNBEGIN fields of the BDCDATA structure.

This sample BDCDATA starts a screen. The record specifies the program and screen identifiers. With BDCDATA-DYNBEGIN, the record shows that batch input data for a new screen is starting:

Example:

BDCDATA-PROGRAM = 'sapms38m'.
BDCDATA-DYNPRO = '0100'.
BDCDATA-DYNBEGIN = 'x'.
APPEND BDCDATA.





c) Entering a Value in a Field:

After the dynpro-start record, you must add a record for each field that is to receive a value. You need fill only the FNAM and FVAL fields.

This sample BDCDATA enters a value into a field. The FNAM field identifies the target field by its table and field names. FVAL specifies the value that is to be entered:

Example:

BDCDATA-FNAM = 'RS38M-FUNC_EDIT'.
BDCDATA-FVAL = 'x'.
APPEND BDCDATA.



d)Executing a Function:

You can execute a function in a transaction by entering the function code or function key number in the command field of an SAP session. You use the FNAM and FVAL fields to enter this information, just as you would for normal screen fields.

The command field is identified by a special name in batch input, BDC_OKCODE. This name is constant and always identifies the command field.

This sample record would execute the save function. It uses the function key assignment of save, which is F11. A function key number must be prefixed with the / (slash) character:

Example:

BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '/11'.

This sample record also executes save, but uses the function code instead of the function key assignment. All functions, whether they are displayed in menus or as buttons, are identified by function codes. A function code must be prefixed with the = character.

Example:

BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '=UPDA'.




e)Entering Values in Loop Fields

Some screen fields need multiple values, one on each line. To provide input to one of these loop fields, you must use an explicit line index :

Example:

BDCDATA-FNAM = 'fieldx(5)'.
BDCDATA-FVAL = 'value'.

The line index (in the example: (5), line 5) indicates in which loop line on the screen values are to appear.



f)Positioning the Cursor:

To position the cursor on a particular field, you must use the special cursor field:

Example:

BDCDATA-FNAM = 'BDC_CURSOR'.
BDCDATA-FVAL = 'fieldx'.

To position the cursor on a loop field, you must use again an index:

Example:

BDCDATA-FNAM = 'BDC_CURSOR'.
BDCDATA-FVAL = 'fieldy(5)'.




g)Ending a Transaction:

You can successfully complete processing of a transaction in batch input in either of two ways:

leave the transaction and return to the SAP main menu.
trigger an update of the database.


Ending a Transaction

Example:

Returning to the SAP main menu: From the text input screen in the ABAP/4 editor, for example, the following BDCDATA records are necessary to leave the transaction:

BDCDATA-PROGRAM = 'SAPMSEDT'. "Leave text input field
BDCDATA-DYNPRO = '2310'.
BDCDATA-DYNBEGIN = 'X'.

BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '/3'. "Back function key

BDCDATA-PROGRAM = 'SAPMS38M'. "Leave ABAP/4 editor
BDCDATA-DYNPRO = '0100'.
BDCDATA-DYNBEGIN = 'X'.

BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '/15'. "Quit function key

Archives

Subscribe Now: Feed Icon