Chapter 04_Batch Input Methods

21
IBM Global Business Services © IBM Corporation 2013 Data Interfaces | Dec-2008 Batch Input Methods

description

Chapter 04_Batch Input Methods

Transcript of Chapter 04_Batch Input Methods

Batch Input MethodsResearch a transaction for the BDC purpose.
Describe the contents of a BDC table.
Declare a BDC table and how to fill the BDC table.
Data Interfaces |
Batch Input
Data Interfaces |
In the remaining chapters, we will learn the batch input procedure. Batch input is used to transfer large amounts of data into the SAP system. In this chapter, we will learn the basics of batch input.
When transferring data into the SAP system, we can refer to two types of transfers:
Conversions - This type of transfer refers to a one-time transfer from a legacy system to the SAP system. In this case, the “legacy” system is the old system that is being replaced by the SAP system.
For example, the old system being replaced has data for 2,000 vendors that must be transferred to the SAP system.
Interfaces - This type of transfer refers to an ongoing transfer from a complementary system to the SAP system. In this case, the “complementary” system is a system that will run along side with the SAP system.
For example, customer orders may be created in another system. For the SAP system to reflect accurate information, these orders must be transferred to the SAP system every night.
Batch input is also referred to as BDC (Batch Data Communication).
IBM Global Business Services
Data Interfaces |
Batch input is used to transfer large amounts of data into the SAP system.
The external data should not be transferred directly into the SAP database tables; instead the data should be checked and validated before being transferred into the SAP system.
IBM Global Business Services
City
Philadelphia
To check and validate the external data, user dialogue is simulated through an SAP transaction
(i.e., an online program).
Data Interfaces |
Data passes through checks and validations when a user enters the data online through a transaction (i.e., an online program).
Automatic checks are performed on each screen of an online program:
Required fields
Proper formats
Valid values
The checks programmed into the online program are also performed on the data as the transaction progresses.
To ensure that data passes through these checks during batch input, you must simulate the user dialogue by passing the data through an online program.
IBM Global Business Services
in a batch input program to collect this information for
an entire transaction.
Data Interfaces |
To simulate user dialogue (i.e., to pass data through an online program), you must know the following information:
Online program name
Screen numbers
Field names
Field values
When you code a batch input program, the ABAP Dictionary structure “BDCDATA” is used to collect this information. The “BDCDATA” structure includes the following fields:
PROGRAM [CHAR 40] - Online program name.
DYNPRO [NUMC 4] - Screen number.
DYNBEGIN [CHAR 1] - Flag to indicate the start of a new screen.
FNAM [CHAR 132] - Field name of a screen field to be filled with data.
FVAL [CHAR 132] - The actual value to be filled into the specified screen field.
To collect this information for an entire transaction, the “BDCDATA” structure will be used to create an internal table in the batch input program.
IBM Global Business Services
City
Philadelphia
For our example, we will use the “Change Vendor” transaction (“FK02”) to add a street address to an already existing vendor.
Data Interfaces |
To demonstrate the use of the “BDCDATA” structure, we will work through a “change vendor” example.
Ultimately, we want to perform batch input to change already existing vendor records. Specifically, we will add a street address to each vendor.
Before coding a batch input program, you must research the appropriate transaction. This research consists of determining the online program name, screen numbers, and field names for the entire transaction.
In our example, this transaction would be the “Change Vendor” transaction. This transaction can be accessed via the menu path “Accounting->Financial accounting->Accounts payable->Master records->Change” (or transaction code “FK02”).
IBM Global Business Services
Step #1
Use “System > Status” menu path to determine online program name (SAPMF02K), screen number (0106), and transaction code (FK02).
Step #2
Use ‘F1’ key and “Technical Info” pushbutton in each screen field to be filled to determine the field name.
Step #3
(go to the next screen by
pressing the ‘Enter’ key).
Data Interfaces |
When you come to the first screen of the transaction to research, perform the following steps:
Step #1: Use the “System > Status” menu path to determine the online program name, the screen number, and, if unknown, the transaction code.
In our example, the online program name is “SAPMF02K”, the screen number is “0106”, and the transaction code is “FK02”.
Step #2: In each screen field that you want to fill with data, determine the field name by placing the cursor in the field and pressing the ‘F1’ key. When the ‘Help’ dialogue box pops up, click on the “Technical info” pushbutton. On the ‘Technical Info’ dialogue box, the field labeled “Field description for batch input” will give the appropriate field name.
In our example, we will need to fill the vendor number field with an already existing vendor. This field name is “RF02K-LIFNR”. We will also have to check the address check box. This field name is “RF02K-D0110”.
Step #3: Determine how to proceed in the transaction. The “command field” of each screen is used to capture the user’s actions (i.e., clicking on a pushbutton or pressing a function key). The field name for this “command field” is “BDC_OKCODE”.
In our example, we can press the ‘Enter’ key to move on to the next screen. This action does not require a value in the “command field”. We could use a “/00” value in the “BDC_OKCODE” field, but it
is not necessary.
Step #1
Use “System > Status” menu path to determine online program name (SAPMF02K) and screen number (0110).
Step #2
Use ‘F1’ key and “Technical Info” pushbutton in each screen field to be filled to determine the field name.
Step #3
Determine how to proceed in the transaction (save the record by clicking on the ‘Save’ pushbutton or pressing the ‘CTRL+S ’ key).
Field name = LFA1-STRAS
Data Interfaces |
When you come to the next screen of the transaction, perform the following steps:
Step #1: Use the “System > Status” menu path to determine the online
program name and the screen number.
The online program name will not always be the same
throughout a transaction.
In our example, the online program name is “SAPMF02K” again and the screen number is “0110”.
Step #2: In each screen field that you want to fill with data, determine the field name by placing the cursor in the field and pressing the ‘F1’ key. When the ‘Help’ dialogue box pops up, click on the “Technical info” pushbutton. On the ‘Technical Info’ dialogue box, the field labeled “Field description for batch input” will give the appropriate field name.
In our example, we will need to fill the street field. This field name
is “LFA1-STRAS”.
Step #1
Use “System > Status” menu path to determine online program name (SAPMF02K) and screen number (0110).
Step #2
Use ‘F1’ key and “Technical Info” pushbutton in each screen field to be filled to determine the field name.
Step #3
Determine how to proceed in the transaction (save the record by clicking on the ‘Save’ pushbutton or pressing the ‘CTRL+S ’ key).
Field name = LFA1-STRAS
Step #3: Determine how to proceed in the transaction.
In our example, we want to save the record. We can click on the ‘Save’ pushbutton or press (CTRL+S) key to save the record.
In the “command field” of a screen, we can use a forward slash (“/”)
followed by the function key number to mimic pressing a function key.
In our example, we will use a “=UPDA” in the “command field” to save the record.
Remember that this command field is referenced with the “BDC_OKCODE” field name.
IBM Global Business Services
determine the contents of the BDC table.
PROGRAM
DYNPRO
DYNBEGIN
FNAM
FVAL
SAPMF02K
0106
X
RF02K-LIFNR
TEST1
RF02K-D0110
X
BDC_OKCODE
/00
SAPMF02K
0110
X
LFA1-STARS
BDCDATA INITIAL SIZE 6 .
DATA: WA_BDC_TAB TYPE BDCDATA.
The internal table used to collect the transaction’s information must be declared “TYPE BDCDATA”.
Data Interfaces |
Once you have determined the contents of the BDC table, you can begin coding the batch input program.
In a batch input program, you must declare the BDC table as an internal table with the following statement:
DATA: <bdc table> TYPE STANDARD TABLE OF BDCDATA
INITIAL SIZE <n> [WITH HEADER LINE].
The <bdc table> must be declared “TYPE BDCDATA”.
After determining the contents of the <bdc table> (see previous page), you can determine the number <n> in the “INITIAL SIZE” clause.
This internal table does not have to be created with a header line.
Once you have declared the BDC table, you can fill it with the appropriate values for one transaction at a time. In the next two slides, we will cover two methods that can be used to fill the BDC table.
IBM Global Business Services
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
CLEAR WA_BDC_TAB.
WA_BDC_TAB-PROGRAM =‘SAPMF02K’.
WA_BDC_TAB-DYNPRO = ‘0106’.
WA_BDC_TAB-DYNBEGIN = ‘X’.
CLEAR WA_BDC_TAB.
WA_BDC_TAB-FNAM = ‘LFA1-STRAS’.
CLEAR WA_BDC_TAB.
WA_BDC_TAB-FNAM = ‘BDC_OKCODE’.
WA_BDC_TAB-FVAL = ‘=UPDA’.
Step #1: Delete all table entries with the “REFRESH” statement.
This statement becomes important when we use the BDC table for multiple records. The BDC table can only hold information for one transaction at a time; therefore, it must be cleared out before a new transaction is being entered into it.
Step #2: Initialise the header line (or staging area) with the
“CLEAR” statement.
This statement is important because you do not want an old entry’s information carried over to the next entry. Specifically, you do not
want the “X” in DYNBEGIN carried over to other entries.
Step #3: Fill the header line (or staging area) with the
appropriate information.
For a “new screen” entry, fill the PROGRAM, DYNPRO, and
DYNBEGIN fields.
For a “field” entry, fill the FNAM and FVAL fields.
IBM Global Business Services
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
CLEAR WA_BDC_TAB.
WA_BDC_TAB-PROGRAM =‘SAPMF02K’.
Data Interfaces |
Step #4: Append the header line (or staging area) to the internal table with the “APPEND” statement.
Step #5: Repeat steps 2 through 4 for each entry entered into the BDC table.
The subroutine above performs these steps for our example (assume that this subroutine is “called” from the “START-OF-SELECTION” event).
IBM Global Business Services
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
ENDFORM.
This two-subroutine method to fill the BDC table is preferable because the “POPULATE_BDC_TAB” subroutine is reusable throughout all batch input programs.
Data Interfaces |
The previous page shows the one-subroutine method for filling the BDC table. The two-subroutine method shown above is preferable because the second subroutine is reusable throughout all batch input programs.
The two-subroutine method uses the same steps listed on the previous page.
The first subroutine deletes all table entries.
Then, this first subroutine “calls” the second subroutine for each entry to be entered into the BDC table.
Each time this second subroutine is “called”, it is sent three variables.
The first one (FLAG) indicates whether the entry is for a new screen (FLAG = ‘1’) or new field (FLAG = ‘ ’).
If the entry is for a new screen, the other two variables will be the online program name (VAR1) and screen number (VAR2).
If the entry is for a new field, the other two variables will be the field name (VAR1) and field value (VAR2).
IBM Global Business Services
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
ENDFORM.
This two-subroutine method to fill the BDC table is preferable because the “POPULATE_BDC_TAB” subroutine is reusable throughout all batch input programs.
Data Interfaces |
In the second subroutine, the first line of code clears out the header line
(or staging area).
The “IF” statement in the second subroutine fills the appropriate header line (or staging area) fields based on the flag.
The last line of code in the second subroutine appends the header line
(or staging area) to the internal table.
In the example above, how many times will the “POPULATE_BDC_TAB” subroutine be executed? __________
IBM Global Business Services
Method #1
“CALL TRANSACTION
USING” Statement
Method #2
Data Interfaces |
So far, we have only filled the BDC table. We have not actually performed batch input to update an SAP database.
In a batch input program, the contents of the BDC table can be used three ways to perform batch input:
Use the BDC table to create a batch input session.
In this case, the batch input program is often called a BDC program.
Use the BDC table in a “CALL TRANSACTION USING” statement.
Use the BDC table in a “CALL DIALOG” statement. (outdated)
In the next two chapters, we will cover the method of creating a batch input session. In Chapter 7, we will cover the other two batch input methods.
IBM Global Business Services
Demonstration
Creation of a custom BDC program using call transaction method for transaction XD02 (Change Customer).
Data Interfaces |
Practice
Creation of a custom BDC program using call transaction method for transaction XD02 (Change Customer).
Data Interfaces |
The <bdc table> must be declared “TYPE BDCDATA”.
To fill the BDC table delete all entries first with the “REFRESH” statement
Initialize the Work-area with “CLEAR” statement.
Fill the header line (or staging area) with the
appropriate information. For a “new screen” entry, fill the PROGRAM, DYNPRO, and and DYNBEGIN fields. For a “field” entry, fill the FNAM and FVAL fields
Data Interfaces |
What are the different Batch Input methods.
Data Interfaces |