IBM Global Business Services
Batch Input Session
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Objectives
The participants will be able to:
Create the Batch Input part of an Inbound Interface.
Describe the Batch Input Session Method for Batch Input.
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Overview
BDC
Program
The first batch input method is to create a batch input
session. It is the processing of this batch input
session that updates the database, not the execution
of the batch input program.
External
Data
SAP
Database
Table
Batch
Input
Session
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Creating Batch Input Sessions
Open Batch Input Session
BDC_OPEN_GROUP
BDC_INSERT is
called for each
transaction
entered into the
batch input
session.
Insert Transaction Data into Session
BDC_INSERT
Close Batch Input Session
BDC_CLOSE_GROUP
4
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
BDC_OPEN_GROUP
CALL FUNCTION BDC_OPEN_GROUP
EXPORTING
CLIENT
= <client>
GROUP
= <session name>
HOLDDATE
= <lock session until date>
KEEP = <keep or delete session>
USER= <user name>
EXCEPTIONS
CLIENT_INVALID
=1
CHECK
SY-SUBRC
...
OTHERS
Data Interfaces |
= 11.
Dec-2008
IBM Corporation 2013
IBM Global Business Services
BDC_INSERT
CALL FUNCTION BDC_INSERT
EXPORTING
TCODE
= <transaction code>
POST_LOCAL
= <local update>
TABLES
DYNPROTAB
= <bdc internal table>
EXCEPTIONS
INTERNAL_ERROR
=1
...
OTHERS
Data Interfaces |
CHECK
SY-SUBRC
= 5.
Dec-2008
IBM Corporation 2013
IBM Global Business Services
BDC_INSERT (Contd.)
CALL FUNCTION BDC_INSERT
EXPORTING
TCODE
= <transaction code>
POST_LOCAL
= <local update>
TABLES
DYNPROTAB
= <bdc internal table>
EXCEPTIONS
INTERNAL_ERROR
=1
...
OTHERS
Data Interfaces |
CHECK
SY-SUBRC
= 5.
Dec-2008
IBM Corporation 2013
IBM Global Business Services
BDC_CLOSE_GROUP
CALL FUNCTION BDC_CLOSE_GROUP
EXCEPTIONS
NOT_OPEN
=1
QUEUE_ERROR = 2
OTHERS
Data Interfaces |
= 3.
CHECK
SY-SUBRC
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Batch Input Session - Structure
Header Section
Creator
Client
Session Name
Authorization User
Hold Date
Keep or Delete
Batch
Input
Session
Data Section
Transaction Data
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #1 - Change Vendor
In this example, we will create a
batch input session to add a street
address to an already existing
vendor (TEST1).
Vendor
Company Code
Address
The Change Vendor transaction is
FK02.
10
Data Interfaces |
ABAPXX-002
Name
Computers, Inc.
Street
Buyer, Inc.1
City
Philadelphia
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #1 - Declaration Section
REPORT YDIXX5_2.
DATA: BDC_TAB TYPE STANDARD TABLE OF BDCDATA
INITIAL SIZE 6 WITH HEADER LINE,
WA_BDC_TAB TYPE BDCDATA,
SESSION TYPE APQ_GRPN
VALUE 'DEMO#8'.
Step #1
** This program is continued on the next slide **
11
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #1 - Main Program
Step #2
Step #3
Step #4
Step #5
START-OF-SELECTION.
CALL FUNCTION BDC_OPEN_GROUP
EXPORTING
CLIENT
= SY-MANDT
GROUP
= SESSION
USER
= SY-UNAME
EXCEPTIONS. . . .
PERFORM FILL_BDC_TAB.
CALL FUNCTION BDC_INSERT
EXPORTING
TCODE
= FK02
TABLES
DYNPROTAB = BDC_TAB
EXCEPTIONS. . . .
CALL FUNCTION BDC_CLOSE_GROUP
EXCEPTIONS. . . .
** This program is continued on the next slide **
12
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #1 - Subroutines
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING:
1SAPMF02K
RF02K-LIFNR
RF02K-D0110
0106,
ABAPXX-002,
X,
1SAPMF02K
LFA1-STRAS
BDC_OKCODE
0110,
Buyer, Inc.1,
=UPDA.
FORM POPULATE_BDC_TAB USING
FLAG TYPE C
VAR1 TYPE C
VAR2 TYPE C.
CLEAR WA_BDC_TAB.
IF FLAG = 1.
WA_BDC_TAB-PROGRAM = VAR1.
WA_ BDC_TAB-DYNPRO= VAR2.
WA_BDC_TAB-DYNBEGIN= X.
ELSE.
WA_BDC_TAB-FNAM = VAR1.
WA_BDC_TAB-FVAL
= VAR2.
ENDIF.
APPEND WA_BDC_TAB TO BDC_TAB.
ENDFORM.
ENDFORM.
13
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #2 - Change Vendors
In this example, we will read records from a sequential file on
the application server to create a batch input session that
updates multiple vendors.
Vendor
TEST1
Company Code
X
TEST2
Company Code
X
Address
Name Computers, Inc.
Name Computer Land
Street 123 Main St.
Street 10 Walnut St.
City
14
Address
Vendor
Philadelphia
Data Interfaces |
City
Boston
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #2 - Sequential File
TEST1
123 Main St.
TEST2
10 Walnut St.
TEST3
32 Chestnut St.
TEST4
30 Market St.
TEST5
17 S. 30th St.
The sequential file we will read is set up in
records. Each record has two fields with
the following formats:
<Field1> LIKE LFA1-LIFNR
File name:
<Field2> LIKE LFA1-STRAS
/tmp/bc180_file3
15
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #2 - Declaration Section
REPORT YDIXX5_02.
Step #1
DATA: BDC_TAB TYPE STANDARD TABLE OF BDCDATA
INITIAL SIZE 6 ,
SESSION TYPE APQ_GRPN
VALUE 'DEMO#9',
INFILE(20) VALUE '/tmp/bc180_file3'.
DATA:
Step #2
BEGIN OF INREC,
VENDNUM TYPE LIFNR,
STREET TYPE STRAS_GP,
END OF INREC.
** This program is continued on the next slide **
16
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #2 - Main Program
Step #3
Step #4
Step #5
Step #6
Step #7
Step #8
Step #9
Step #10
START-OF-SELECTION.
CHECK
OPEN DATASET INFILE
SY-SUBRC
FOR INPUT IN TEXT MODE
ENCODING DEFAULT.
CALL FUNCTION BDC_OPEN_GROUP. . . .
DO.
READ DATASET INFILE INTO INREC.
IF SY-SUBRC <> 0. EXIT. ENDIF.
PERFORM FILL_BDC_TAB.
CALL FUNCTION BDC_INSERT
EXPORTING
TCODE
= FK02
TABLES
DYNPROTAB = BDC_TAB. . . .
ENDDO.
CALL FUNCTION BDC_CLOSE_GROUP. . . .
CLOSE DATASET INFILE.
** This program is continued on the next slide **
17
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Example #2 - Subroutines
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING:
1 SAPMF02K
RF02K-LIFNR
RF02K-D0110
0106,
INREC-VENDNUM,
X,
1 SAPMF02K
LFA1-STRAS
BDC_OKCODE
0110,
INREC-STREET,
=UPDA.
ENDFORM.
FORM POPULATE_BDC_TAB USING
FLAG TYPE C
VAR1 TYPE C
VAR2 TYPE C.
CLEAR WA_BDC_TAB.
IF FLAG = 1.
WA_BDC_TAB-PROGRAM = VAR1.
WA_BDC_TAB-DYNPRO
= VAR2.
WA_BDC_TAB-DYNBEGIN = X.
ELSE.
WA_BDC_TAB-FNAM
= VAR1.
WA_BDC_TAB-FVAL = VAR2.
ENDIF.
APPEND WA_BDC_TAB TO BDC_TAB.
ENDFORM.
Notice that the vendor number and street values are coming from the files
records read into the INREC structure.
18
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Demonstration
Creation of a custom batch input session program for transaction XD02 (Change
Customer).
19
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Practice
Creation of a custom batch input session program for transaction XD02 (Change
Customer).
20
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Summary
Research Transaction
Code BDC Program
Execute BDC Program
Batch Input Session Created
Process Batch Input Session
SAP Database Updated
21
Data Interfaces |
Dec-2008
IBM Corporation 2013
IBM Global Business Services
Questions
What are the function modules required to create a batch input session ?
In what sequence are they called ?
22
Data Interfaces |
Dec-2008
IBM Corporation 2013