SlideShare a Scribd company logo
Batch Input Session
Dec-2008 Data Interfaces |
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.
Dec-2008 Data Interfaces | 2
Overview
Dec-2008 Data Interfaces | 3
SAPSAP
DatabaseDatabase
TableTable
Batch
Input
Session
BDC
Program
External
Data
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.
Creating Batch Input Sessions
Dec-2008 Data Interfaces | 4
“BDC_INSERT” is
called for each
transaction
entered into the
batch input
session.
Open Batch Input SessionOpen Batch Input Session
Close Batch Input SessionClose Batch Input Session
Insert Transaction Data into Session
BDC_OPEN_GROUP
BDC_INSERT
BDC_CLOSE_GROUP
BDC_OPEN_GROUP
Dec-2008 Data Interfaces | 5
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
. . .
OTHERS = 11.
SY-SUBRC
CHECK
BDC_INSERT
Dec-2008 Data Interfaces | 6
CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE = <transaction code>
POST_LOCAL = <local update>
TABLES
DYNPROTAB = <bdc internal table>
EXCEPTIONS
INTERNAL_ERROR = 1
. . .
OTHERS = 5.
SY-SUBRC
CHECK
BDC_INSERT (Contd.)
Dec-2008 Data Interfaces | 7
CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE = <transaction code>
POST_LOCAL = <local update>
TABLES
DYNPROTAB = <bdc internal table>
EXCEPTIONS
INTERNAL_ERROR = 1
. . .
OTHERS = 5.
SY-SUBRC
CHECK
BDC_CLOSE_GROUP
Dec-2008 Data Interfaces | 8
CALL FUNCTION ‘BDC_CLOSE_GROUP’
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
SY-SUBRC
CHECK
Batch Input Session - Structure
Dec-2008 Data Interfaces | 9
Batch
Input
Session
Data Section
Transaction Data
Header Section
Creator
Client
Session Name
Authorization User
Hold Date
Keep or Delete
Example #1 - Change Vendor
Dec-2008 Data Interfaces | 10
Vendor
Company Code
ABAPXX-002
AddressX
Name
Street
Computers, Inc.
Buyer, Inc.1
City Philadelphia
In this example, we will create a
batch input session to add a street
address to an already existing
vendor (TEST1).
The “Change Vendor” transaction is
“FK02”.
Example #1 - Declaration Section
Dec-2008 Data Interfaces | 11
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 **
Example #1 - Main Program
Dec-2008 Data Interfaces | 12
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. . . .
Step #2
Step #3
Step #4
Step #5
** This program is continued on the next slide **
Example #1 - Subroutines
Dec-2008 Data Interfaces | 13
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING:
‘1’‘SAPMF02K’ ‘0106’,
‘ ’‘RF02K-LIFNR’ ‘ABAPXX-002’,
‘ ’‘RF02K-D0110’ ‘X’,
‘1’‘SAPMF02K’ ‘0110’,
‘ ’‘LFA1-STRAS’ ‘Buyer, Inc.1’,
‘ ’‘BDC_OKCODE’ ‘=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.
Example #2 - Change Vendors
Dec-2008 Data Interfaces | 14
Vendor
Company Code
TEST1
AddressX
Name
Street
Computers, Inc.
123 Main St.
City Philadelphia
Vendor
Company Code
TEST2
AddressX
Name
Street
Computer Land
10 Walnut St.
City
Boston
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.
Example #2 - Sequential File
Dec-2008 Data Interfaces | 15
TEST1 123 Main St.
TEST2 10 Walnut St.
TEST3 32 Chestnut St.
TEST4 30 Market St.
TEST5 17 S. 30th St.
File name:
‘/tmp/bc180_file3’
The sequential file we will read is set up in
records. Each record has two fields with
the following formats:
<Field1> LIKE LFA1-LIFNR
<Field2> LIKE LFA1-STRAS
Example #2 - Declaration Section
Dec-2008 Data Interfaces | 16
REPORT YDIXX5_02.
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: BEGIN OF INREC,
VENDNUM TYPE LIFNR,
STREET TYPE STRAS_GP,
END OF INREC.
Step #1
Step #2
** This program is continued on the next slide **
Example #2 - Main Program
Dec-2008 Data Interfaces | 17
START-OF-SELECTION.
OPEN DATASET INFILE
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.
SY-SUBRC
CHECKStep #3
Step #4
Step #5
Step #6
Step #7
Step #8
Step #9
Step #10
** This program is continued on the next slide **
Example #2 - Subroutines
Dec-2008 Data Interfaces | 18
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING:
‘1’‘SAPMF02K’ ‘0106’,
‘ ’‘RF02K-LIFNR’ INREC-VENDNUM,
‘ ’‘RF02K-D0110’ ‘X’,
‘1’‘SAPMF02K’ ‘0110’,
‘ ’‘LFA1-STRAS’ INREC-STREET,
‘ ’‘BDC_OKCODE’ ‘=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 file’s
records read into the “INREC” structure.
Demonstration
• Creation of a custom batch input session
program for transaction XD02 (Change
Customer).
Dec-2008 Data Interfaces | 19
Practice
• Creation of a custom batch input session
program for transaction XD02 (Change
Customer).
Dec-2008 Data Interfaces | 20
Summary
Dec-2008 Data Interfaces | 21
Research Transaction
Code BDC Program
Execute BDC Program
Batch Input Session Created
Process Batch Input Session
SAP Database Updated
Questions
• What are the function modules required to
create a batch input session ?
• In what sequence are they called ?
Dec-2008 Data Interfaces | 22

More Related Content

What's hot

Chapter 01 user exits
Chapter 01 user exitsChapter 01 user exits
Chapter 01 user exits
Kranthi Kumar
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
Kranthi Kumar
 
Enhancement framework the new way to enhance your abap systems
Enhancement framework   the new way to enhance your abap systemsEnhancement framework   the new way to enhance your abap systems
Enhancement framework the new way to enhance your abap systems
Kranthi Kumar
 
Sap abap ale idoc
Sap abap ale idocSap abap ale idoc
Sap abap ale idoc
Bunty Jain
 
Introducing enhancement framework.doc
Introducing enhancement framework.docIntroducing enhancement framework.doc
Introducing enhancement framework.doc
Kranthi Kumar
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 

What's hot (20)

SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
Chapter 01 user exits
Chapter 01 user exitsChapter 01 user exits
Chapter 01 user exits
 
Sap abap
Sap abapSap abap
Sap abap
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
 
Bapi step-by-step
Bapi step-by-stepBapi step-by-step
Bapi step-by-step
 
Using idoc method in lsmw
Using idoc method in lsmwUsing idoc method in lsmw
Using idoc method in lsmw
 
Using infoset query ,sap query and quick viewer
Using infoset query ,sap query and quick viewerUsing infoset query ,sap query and quick viewer
Using infoset query ,sap query and quick viewer
 
Reports
ReportsReports
Reports
 
Enhancement framework the new way to enhance your abap systems
Enhancement framework   the new way to enhance your abap systemsEnhancement framework   the new way to enhance your abap systems
Enhancement framework the new way to enhance your abap systems
 
User exits
User exitsUser exits
User exits
 
Sap abap ale idoc
Sap abap ale idocSap abap ale idoc
Sap abap ale idoc
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
Introducing enhancement framework.doc
Introducing enhancement framework.docIntroducing enhancement framework.doc
Introducing enhancement framework.doc
 
Top 10 sap abap faqs-www.bigclasses.com
Top 10 sap abap faqs-www.bigclasses.comTop 10 sap abap faqs-www.bigclasses.com
Top 10 sap abap faqs-www.bigclasses.com
 
Internal tables in sap
Internal tables in sapInternal tables in sap
Internal tables in sap
 
Maximizing SAP ABAP Performance
Maximizing SAP ABAP PerformanceMaximizing SAP ABAP Performance
Maximizing SAP ABAP Performance
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Smartforms interview questions with answers
Smartforms interview questions with answersSmartforms interview questions with answers
Smartforms interview questions with answers
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
 
BADI IMPLEMENTATION.pdf
BADI IMPLEMENTATION.pdfBADI IMPLEMENTATION.pdf
BADI IMPLEMENTATION.pdf
 

Viewers also liked (15)

165373293 sap-security-q
165373293 sap-security-q165373293 sap-security-q
165373293 sap-security-q
 
Badis
Badis Badis
Badis
 
Table maintenance generator and its modifications
Table maintenance generator and its modificationsTable maintenance generator and its modifications
Table maintenance generator and its modifications
 
Chapter 03 foreign key relationships1
Chapter 03 foreign key relationships1Chapter 03 foreign key relationships1
Chapter 03 foreign key relationships1
 
About work flow
About work flowAbout work flow
About work flow
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
 
Sap script made easy
Sap script made easySap script made easy
Sap script made easy
 
Bdc details
Bdc detailsBdc details
Bdc details
 
The ABAP Query
The ABAP QueryThe ABAP Query
The ABAP Query
 
Exercise in alv
Exercise in alvExercise in alv
Exercise in alv
 
Recording steps in SAP BDC
Recording steps in SAP BDCRecording steps in SAP BDC
Recording steps in SAP BDC
 
Badi document
Badi documentBadi document
Badi document
 
Sap workflow training
Sap workflow trainingSap workflow training
Sap workflow training
 
Step by-step-to-upload-new-customer-master-record-with-lsmw
Step by-step-to-upload-new-customer-master-record-with-lsmwStep by-step-to-upload-new-customer-master-record-with-lsmw
Step by-step-to-upload-new-customer-master-record-with-lsmw
 
SAP ABAP Material
SAP ABAP MaterialSAP ABAP Material
SAP ABAP Material
 

Similar to Batch input session

Microsoft access VBA communication with RS232 Peripherals
Microsoft access VBA  communication with RS232 PeripheralsMicrosoft access VBA  communication with RS232 Peripherals
Microsoft access VBA communication with RS232 Peripherals
topomax
 
Chapter 04 sap script - output program
Chapter 04 sap script - output programChapter 04 sap script - output program
Chapter 04 sap script - output program
Kranthi Kumar
 
PT1420 Modules in Flowchart and Visual Basic .docx
PT1420 Modules in Flowchart and Visual Basic             .docxPT1420 Modules in Flowchart and Visual Basic             .docx
PT1420 Modules in Flowchart and Visual Basic .docx
amrit47
 
Schema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12cSchema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12c
uzzal basak
 
Customer bank account assignment detail report
Customer bank account assignment detail reportCustomer bank account assignment detail report
Customer bank account assignment detail report
lingaswamy vallapu
 
TS -FI-CA-CRP-002.doc
TS -FI-CA-CRP-002.docTS -FI-CA-CRP-002.doc
TS -FI-CA-CRP-002.doc
subrat42
 
BIN-ITPD-2100.04c User Reference Manual FI Module Banking
BIN-ITPD-2100.04c User Reference Manual FI Module BankingBIN-ITPD-2100.04c User Reference Manual FI Module Banking
BIN-ITPD-2100.04c User Reference Manual FI Module Banking
Sheila Andaya
 
5078977 abap-tips
5078977 abap-tips5078977 abap-tips
5078977 abap-tips
jmts1000
 
CPT275_Performance_Exam_Practice_NA_Update
CPT275_Performance_Exam_Practice_NA_UpdateCPT275_Performance_Exam_Practice_NA_Update
CPT275_Performance_Exam_Practice_NA_Update
Moneico Robinson
 

Similar to Batch input session (20)

SAP Batch data communication
SAP Batch data communicationSAP Batch data communication
SAP Batch data communication
 
CDMA1X Pilot Panorama introduction
CDMA1X Pilot Panorama introductionCDMA1X Pilot Panorama introduction
CDMA1X Pilot Panorama introduction
 
Microsoft access VBA communication with RS232 Peripherals
Microsoft access VBA  communication with RS232 PeripheralsMicrosoft access VBA  communication with RS232 Peripherals
Microsoft access VBA communication with RS232 Peripherals
 
20131028 BTUG.be - BizTalk Tracking
20131028 BTUG.be - BizTalk Tracking20131028 BTUG.be - BizTalk Tracking
20131028 BTUG.be - BizTalk Tracking
 
Sap scripts
Sap scriptsSap scripts
Sap scripts
 
Chapter 04 sap script - output program
Chapter 04 sap script - output programChapter 04 sap script - output program
Chapter 04 sap script - output program
 
Nagios Conference 2012 - Dave Josephsen - Stop Being Lazy
Nagios Conference 2012 - Dave Josephsen - Stop Being LazyNagios Conference 2012 - Dave Josephsen - Stop Being Lazy
Nagios Conference 2012 - Dave Josephsen - Stop Being Lazy
 
PT1420 Modules in Flowchart and Visual Basic .docx
PT1420 Modules in Flowchart and Visual Basic             .docxPT1420 Modules in Flowchart and Visual Basic             .docx
PT1420 Modules in Flowchart and Visual Basic .docx
 
Schema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12cSchema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12c
 
1BM_S4CLD2302_BPD_EN_US.docx
1BM_S4CLD2302_BPD_EN_US.docx1BM_S4CLD2302_BPD_EN_US.docx
1BM_S4CLD2302_BPD_EN_US.docx
 
Cbse computer science (c++) class 12 board project bank managment system
Cbse computer science (c++)  class 12 board project  bank managment systemCbse computer science (c++)  class 12 board project  bank managment system
Cbse computer science (c++) class 12 board project bank managment system
 
Customer bank account assignment detail report
Customer bank account assignment detail reportCustomer bank account assignment detail report
Customer bank account assignment detail report
 
Call session Method of BDC
Call session Method of BDCCall session Method of BDC
Call session Method of BDC
 
TS -FI-CA-CRP-002.doc
TS -FI-CA-CRP-002.docTS -FI-CA-CRP-002.doc
TS -FI-CA-CRP-002.doc
 
BIN-ITPD-2100.04c User Reference Manual FI Module Banking
BIN-ITPD-2100.04c User Reference Manual FI Module BankingBIN-ITPD-2100.04c User Reference Manual FI Module Banking
BIN-ITPD-2100.04c User Reference Manual FI Module Banking
 
Abap tips
Abap tipsAbap tips
Abap tips
 
5078977 abap-tips
5078977 abap-tips5078977 abap-tips
5078977 abap-tips
 
Basic Handover of Bill of Material(2).docx
Basic Handover of Bill of Material(2).docxBasic Handover of Bill of Material(2).docx
Basic Handover of Bill of Material(2).docx
 
BBD Hands-on with Python. Practical Hands-on Workshop about "Behaviour Driven...
BBD Hands-on with Python. Practical Hands-on Workshop about "Behaviour Driven...BBD Hands-on with Python. Practical Hands-on Workshop about "Behaviour Driven...
BBD Hands-on with Python. Practical Hands-on Workshop about "Behaviour Driven...
 
CPT275_Performance_Exam_Practice_NA_Update
CPT275_Performance_Exam_Practice_NA_UpdateCPT275_Performance_Exam_Practice_NA_Update
CPT275_Performance_Exam_Practice_NA_Update
 

More from Kranthi Kumar

Creating simple comp
Creating simple compCreating simple comp
Creating simple comp
Kranthi Kumar
 
Controllers and context programming
Controllers and context programmingControllers and context programming
Controllers and context programming
Kranthi Kumar
 
Binding,context mapping,navigation exercise
Binding,context mapping,navigation exerciseBinding,context mapping,navigation exercise
Binding,context mapping,navigation exercise
Kranthi Kumar
 
Web(abap introduction)
Web(abap introduction)Web(abap introduction)
Web(abap introduction)
Kranthi Kumar
 
Chapter 07 debugging sap scripts
Chapter 07 debugging sap scriptsChapter 07 debugging sap scripts
Chapter 07 debugging sap scripts
Kranthi Kumar
 
Chapter 06 printing sap script forms
Chapter 06 printing sap script formsChapter 06 printing sap script forms
Chapter 06 printing sap script forms
Kranthi Kumar
 
Chapter 05 sap script - configuration
Chapter 05 sap script - configurationChapter 05 sap script - configuration
Chapter 05 sap script - configuration
Kranthi Kumar
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script forms
Kranthi Kumar
 
Using folder options for page protection
Using folder options for page protectionUsing folder options for page protection
Using folder options for page protection
Kranthi Kumar
 

More from Kranthi Kumar (20)

Dynamic binding
Dynamic bindingDynamic binding
Dynamic binding
 
Data binding
Data bindingData binding
Data binding
 
Creating simple comp
Creating simple compCreating simple comp
Creating simple comp
 
Creating messages
Creating messagesCreating messages
Creating messages
 
Creating a comp
Creating a compCreating a comp
Creating a comp
 
Controllers and context programming
Controllers and context programmingControllers and context programming
Controllers and context programming
 
Context at design
Context at designContext at design
Context at design
 
Binding,context mapping,navigation exercise
Binding,context mapping,navigation exerciseBinding,context mapping,navigation exercise
Binding,context mapping,navigation exercise
 
Alv for web
Alv for webAlv for web
Alv for web
 
Web(abap introduction)
Web(abap introduction)Web(abap introduction)
Web(abap introduction)
 
Abap faq
Abap faqAbap faq
Abap faq
 
Sap abap material
Sap abap materialSap abap material
Sap abap material
 
Crm technical
Crm technicalCrm technical
Crm technical
 
control techniques
control techniquescontrol techniques
control techniques
 
Chapter 07 debugging sap scripts
Chapter 07 debugging sap scriptsChapter 07 debugging sap scripts
Chapter 07 debugging sap scripts
 
Chapter 06 printing sap script forms
Chapter 06 printing sap script formsChapter 06 printing sap script forms
Chapter 06 printing sap script forms
 
Chapter 05 sap script - configuration
Chapter 05 sap script - configurationChapter 05 sap script - configuration
Chapter 05 sap script - configuration
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script forms
 
sap script overview
sap script overviewsap script overview
sap script overview
 
Using folder options for page protection
Using folder options for page protectionUsing folder options for page protection
Using folder options for page protection
 

Batch input session

  • 1. Batch Input Session Dec-2008 Data Interfaces |
  • 2. 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. Dec-2008 Data Interfaces | 2
  • 3. Overview Dec-2008 Data Interfaces | 3 SAPSAP DatabaseDatabase TableTable Batch Input Session BDC Program External Data 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.
  • 4. Creating Batch Input Sessions Dec-2008 Data Interfaces | 4 “BDC_INSERT” is called for each transaction entered into the batch input session. Open Batch Input SessionOpen Batch Input Session Close Batch Input SessionClose Batch Input Session Insert Transaction Data into Session BDC_OPEN_GROUP BDC_INSERT BDC_CLOSE_GROUP
  • 5. BDC_OPEN_GROUP Dec-2008 Data Interfaces | 5 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 . . . OTHERS = 11. SY-SUBRC CHECK
  • 6. BDC_INSERT Dec-2008 Data Interfaces | 6 CALL FUNCTION ‘BDC_INSERT’ EXPORTING TCODE = <transaction code> POST_LOCAL = <local update> TABLES DYNPROTAB = <bdc internal table> EXCEPTIONS INTERNAL_ERROR = 1 . . . OTHERS = 5. SY-SUBRC CHECK
  • 7. BDC_INSERT (Contd.) Dec-2008 Data Interfaces | 7 CALL FUNCTION ‘BDC_INSERT’ EXPORTING TCODE = <transaction code> POST_LOCAL = <local update> TABLES DYNPROTAB = <bdc internal table> EXCEPTIONS INTERNAL_ERROR = 1 . . . OTHERS = 5. SY-SUBRC CHECK
  • 8. BDC_CLOSE_GROUP Dec-2008 Data Interfaces | 8 CALL FUNCTION ‘BDC_CLOSE_GROUP’ EXCEPTIONS NOT_OPEN = 1 QUEUE_ERROR = 2 OTHERS = 3. SY-SUBRC CHECK
  • 9. Batch Input Session - Structure Dec-2008 Data Interfaces | 9 Batch Input Session Data Section Transaction Data Header Section Creator Client Session Name Authorization User Hold Date Keep or Delete
  • 10. Example #1 - Change Vendor Dec-2008 Data Interfaces | 10 Vendor Company Code ABAPXX-002 AddressX Name Street Computers, Inc. Buyer, Inc.1 City Philadelphia In this example, we will create a batch input session to add a street address to an already existing vendor (TEST1). The “Change Vendor” transaction is “FK02”.
  • 11. Example #1 - Declaration Section Dec-2008 Data Interfaces | 11 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 **
  • 12. Example #1 - Main Program Dec-2008 Data Interfaces | 12 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. . . . Step #2 Step #3 Step #4 Step #5 ** This program is continued on the next slide **
  • 13. Example #1 - Subroutines Dec-2008 Data Interfaces | 13 FORM FILL_BDC_TAB. REFRESH BDC_TAB. PERFORM POPULATE_BDC_TAB USING: ‘1’‘SAPMF02K’ ‘0106’, ‘ ’‘RF02K-LIFNR’ ‘ABAPXX-002’, ‘ ’‘RF02K-D0110’ ‘X’, ‘1’‘SAPMF02K’ ‘0110’, ‘ ’‘LFA1-STRAS’ ‘Buyer, Inc.1’, ‘ ’‘BDC_OKCODE’ ‘=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.
  • 14. Example #2 - Change Vendors Dec-2008 Data Interfaces | 14 Vendor Company Code TEST1 AddressX Name Street Computers, Inc. 123 Main St. City Philadelphia Vendor Company Code TEST2 AddressX Name Street Computer Land 10 Walnut St. City Boston 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.
  • 15. Example #2 - Sequential File Dec-2008 Data Interfaces | 15 TEST1 123 Main St. TEST2 10 Walnut St. TEST3 32 Chestnut St. TEST4 30 Market St. TEST5 17 S. 30th St. File name: ‘/tmp/bc180_file3’ The sequential file we will read is set up in records. Each record has two fields with the following formats: <Field1> LIKE LFA1-LIFNR <Field2> LIKE LFA1-STRAS
  • 16. Example #2 - Declaration Section Dec-2008 Data Interfaces | 16 REPORT YDIXX5_02. 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: BEGIN OF INREC, VENDNUM TYPE LIFNR, STREET TYPE STRAS_GP, END OF INREC. Step #1 Step #2 ** This program is continued on the next slide **
  • 17. Example #2 - Main Program Dec-2008 Data Interfaces | 17 START-OF-SELECTION. OPEN DATASET INFILE 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. SY-SUBRC CHECKStep #3 Step #4 Step #5 Step #6 Step #7 Step #8 Step #9 Step #10 ** This program is continued on the next slide **
  • 18. Example #2 - Subroutines Dec-2008 Data Interfaces | 18 FORM FILL_BDC_TAB. REFRESH BDC_TAB. PERFORM POPULATE_BDC_TAB USING: ‘1’‘SAPMF02K’ ‘0106’, ‘ ’‘RF02K-LIFNR’ INREC-VENDNUM, ‘ ’‘RF02K-D0110’ ‘X’, ‘1’‘SAPMF02K’ ‘0110’, ‘ ’‘LFA1-STRAS’ INREC-STREET, ‘ ’‘BDC_OKCODE’ ‘=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 file’s records read into the “INREC” structure.
  • 19. Demonstration • Creation of a custom batch input session program for transaction XD02 (Change Customer). Dec-2008 Data Interfaces | 19
  • 20. Practice • Creation of a custom batch input session program for transaction XD02 (Change Customer). Dec-2008 Data Interfaces | 20
  • 21. Summary Dec-2008 Data Interfaces | 21 Research Transaction Code BDC Program Execute BDC Program Batch Input Session Created Process Batch Input Session SAP Database Updated
  • 22. Questions • What are the function modules required to create a batch input session ? • In what sequence are they called ? Dec-2008 Data Interfaces | 22

Editor's Notes

  1. In this chapter, we will cover the batch input method to create a batch input session. In this case, the batch input program is often called a BDC program. With this method, the execution of the batch input program only creates a batch input session; it does not update the SAP database. The transaction data entered into the BDC table is inserted in the batch input session. Processing (or executing) this batch input session updates the SAP database. Batch input sessions are collected and maintained by the system in the “batch input queue” (also called the “queue file”).
  2. In a BDC program, you create a batch input session. To create a batch input session, you must: Open the batch input session with the “BDC_OPEN_GROUP” function module. Insert transaction data (collected in the BDC table) into the batch input session with the “BDC_INSERT” function module. This subroutine is “called” for each transaction entered into the batch input session. Close the batch input session with the “BDC_CLOSE_GROUP” function module. The next three slides cover these function modules in detail.
  3. The “BDC_OPEN_GROUP” function module opens a batch input session. The main exporting parameters are: Client - The client in which the batch input session is to be processed. The default is the client in which the BDC program was executed. Group - The name of the batch input session. This name does not have to be unique. Hold date - The batch input session cannot be processed until this “lock date”. The default is no date, so the batch input session can be processed immediately. Keep - Flag to indicate whether the batch input session should be kept (‘X’) or deleted (‘ ’) after successful processing. The default is to delete the batch input session. User - User whose authorisations will be checked if the batch input session is processed in the background.
  4. The “BDC_INSERT” function module inserts transaction data into a batch input session. The exporting parameters are: TCODE - The transaction code that is to be executed. In other words, the information in the BDC table refers to this transaction. POST_LOCAL - if you set this parameter to ‘X’ the update will run in asynchronous mode instead of the default synchronous one (for the differences between the two update types see the chapter on CALL TRANSACTION) The only tables parameter is: DYNPROTAB (required) - The BDC table with the transaction data.
  5. The “BDC_INSERT” function module is “called” for each transaction entered into the batch input session. In our simple example where we update one vendor, we will only “call” this function module once. In a more realistic example where we will read multiple records from a sequential file, we will “call” this function module for each record. A batch input session can include data for different transactions. The “TCODE” parameter indicates the appropriate transaction code. The BDC table contents must mimic the transaction code specified or an error will occur when the batch input session is processed. For example, if you read vendor information from a sequential file, you will use the “Change Vendor” transaction (“FK02”) if the vendor already exists or the “Create Vendor” transaction (“FK01”) if the vendor does not exist. The BDC table for each of these transactions will be different because different screens are encountered and different fields must be filled.
  6. The “BDC_CLOSE_GROUP” function module closes a batch input session. There are no parameters for this function module, only exceptions. In both the “BDC_CLOSE_GROUP” and “BDC_INSERT” function modules, the batch input session name is not specified. This fact indicates that only one batch input session can be open at any given time. Depending on the number of records to be processed, you may want to split the records into multiple batch input sessions. In this case, you would close one batch input session and then open a new one before entering more transaction data.
  7. A batch input session is comprised of two sections: The heading section consists of general information about the batch input session. This information is contained in the APQI table. This general information includes: The creator of the batch input session The creation date Parameters specified in the “BDC_OPEN_GROUP” function module: Client Session name Authorisation user Hold date Keep or delete flag The data section consists of the transaction data. Information about this transaction data is contained in the APQD table.
  8. We will continue our example from the previous chapter to create a batch input session. Recall that we are using the “Change Vendor” transaction (“FK02”) to update one vendor’s record (“ABAPXX-002”) by adding a street address (“Buyer, Inc.1”).
  9. To create a batch input session, perform the following steps in a BDC program: Step #1: Create the BDC table. This internal table must be declared “TYPE BDCDATA”. These steps are continued on the next page. If you create a variable or constant for the batch input session name, it must be declared “LIKE APQI-GROUPID”; otherwise, you will encounter an error when the “BDC_OPEN_GROUP” function module is executed. This example program can be found in development class “YTRABAP46X” with the name “YDIXX5_01”. Executing this program creates a batch input session. We have to process the session to update the SAP database. Use the “System Services Batch input  Sessions” menu path to process batch input sessions (we will cover this topic in greater detail in the next chapter).
  10. Steps to create a batch input session (continued from previous page): Step #2: Open the batch input session by calling the “BDC_OPEN_GROUP” function module. Step #3: Fill the BDC table with the appropriate data for the transaction (see next page). We learned how to fill the BDC table in the previous chapter. Step #4: Insert a transaction’s data (from the BDC table) into the batch input session by calling the “BDC_INSERT” function module. Step #5: Close the batch input session by calling the “BDC_CLOSE_GROUP” function module.
  11. The two subroutines above are used to fill the BDC table. These two subroutines are executed just before the BDC table’s contents are inserted into the batch input session. You should get in the habit of using this two-subroutine method of filling the BDC table. For this simple example and others we will cover, it might seem harder and longer to use this two-subroutine method. However, when you code a more complicated batch input program (i.e.one that involves many screens and many fields), you will notice a time savings and increased maintainability by using the two-subroutine method. It is also a good habit to put comments on each entry entered into the BDC table. For example: PERFORM POPULATE_BDC_TAB USING: ‘1’‘SAPMF02K’ ‘0106’, “initial screen of change vendor ‘ ’‘RF02K-LIFNR’ ‘ABAPXX-002’, “vendor number field ‘ ’‘RF02K-D0110’ ‘X’, “address check box ‘1’‘SAPMF02K’ ‘0110’,“address screen of change vendor ‘ ’‘LFA1-STRAS’ ‘Buyer, Inc.1’, “street address field ‘ ’‘BDC_OKCODE’‘=UPDA’. “save the record
  12. The next example we will cover is more realistic to what you will be doing in the “real world”. You would never code a BDC program to update one record – it would be faster to manually go through the transaction online. In this example, we will read vendor records from a sequential file on the application server. Let’s assume that we are on an SAP project. ABC Inc. is the client installing SAP. We know that our client has a sequential file with vendor information that must be updated in the new SAP system (we have already inserted vendors into the system via batch input). This sequential file is located on the application server. We must determine the format of the sequential file (see next page).
  13. The sequential file on the application server (‘/tmp/bc180_file3’) is set up in lines (or records). This fact determines that we will open the file “IN TEXT MODE”. Each record on the file has two fields. These two fields have the following formats: &amp;lt;Field1&amp;gt; LIKE LFA1-LIFNR &amp;lt;Field2&amp;gt; LIKE LFA1-STRAS Once we determine the fields coming from the file, we can research the appropriate transaction. We have already performed this research in the previous chapter, so we’ll skip ahead to coding the BDC program (see next page).
  14. To create a batch input session with multiple records from a sequential file on the application server, perform the following steps in a BDC program: Step #1: Create the BDC table. This internal table must be declared “TYPE BDCDATA”. Step #2: Define the structure in which the file’s records will be read. The structure of the structure should match the structure of the file’s records. These steps are continued on the next page. If you create a variable or constant for the batch input session name, it must be declared “LIKE APQI-GROUPID”; otherwise, you will encounter an error when the “BDC_OPEN_GROUP” function module is executed. This example program can be found in development class “YTRABAP46X” with the name “YDIXX5_02”. Executing this program creates a batch input session. We have to process the session to update the SAP database. Use the “System Services  Batch input  Sessions” menu path to process batch input sessions (we will cover this topic in greater detail in the next chapter).
  15. Steps to create a batch input session with multiple records from a sequential file on the application server (continued from previous page): Step #3: Open the file “FOR INPUT”. Step #4: Open the batch input session by calling the “BDC_OPEN_GROUP” function module. Step #5: Read a record from the file into the structure. To read the complete file, you must code the “READ DATASET” statement in a DO loop. Step #6: Code a way out (EXIT) of the DO loop. If SY-SUBRC is not 0, the end of the file has already been reached. Step #7: Fill the BDC table with the appropriate data for the transaction (see next page)This step will be executed for each record in the sequential file. We learned how to fill the BDC table in the previous chapter. Step #8: Insert a transaction’s data (from the BDC table) into the batch input session by calling the “BDC_INSERT” function module. This step will be executed for each record in the sequential file. Step #9: Close the batch input session by calling the “BDC_CLOSE_GROUP” function module. Step #10: Close the file.
  16. The two subroutines above are used to fill the BDC table. These two subroutines are executed just before the BDC table’s contents are inserted into the batch input session. The main difference in this example and our previous one-vendor example is the values used to fill the vendor number and street address fields. In our previous example, these values were hard-coded as ‘TEST1’ and 123 Main St.’. Because we are now reading this information from a sequential file, the values change for each vendor and cannot be hard-coded. In this case, we will use the values read into the “INREC” structure for each record. When we learned how to fill the BDC table, the first step was to delete all table entries with the “REFRESH” statement. This action is important now because the “FILL_BDC_TAB” subroutine will be executed for each record. Without the “REFRESH” statement, the BDC table contents would be accumulating with each new record and the same transaction data would be inserted into the batch input session multiple times. There is no difference in the second subroutine.
  17. Throughout the last two chapters we have learned the basics of batch input and one batch input method – to create a batch input session. In the last chapter, we learned how to research a transaction and fill the BDC table. This process will be used for all batch input methods. In this chapter, we learned how to code a BDC program to create a batch input session. An important point to remember is that executing a BDC program does not update the SAP database; instead, it creates a batch input session. The SAP database is updated when the batch input session is processed. We will cover the topic of processing batch input sessions in the next chapter.