Batch Data
Batch Data
Batch Data
INTRODUCTION
Background Processing
Dispatcher
Step #1
Step #2
Defining a
background job.
Phases of Background Processing
Job
Scheduling
Job
Processing
Job
Overview
Scheduling a Background Job
Transaction Job
SM36 Scheduling
Creating Step for Background Job
Steps
Job
Scheduling
Start Criteria for Background Job
Job
Start date Scheduling
Job
Start date Scheduling
Period values
Job
Start date After Job Scheduling
Job
Start date After Event Scheduling
Job
Scheduling
Job
Processing
Job
Overview
Processing a Background Job
Job
Background
Job
Processing
Processing a Background Job
Application Server Job
Work Processes Processing
8 Online 1 Spool 3 Background
Transaction
SM50
Processing a Background Job
Job Log
Scheduler Entries from start and end
modules.
All messages issued by
job steps and system.
Start Module
PRINT SPOOL
Job Step #1
Job
Job Step #2
Processing
List
Job Step #3 All “WRITE”
statement output
from job step.
End Module
Phases of Background Processing
Job
Scheduling
Job
Processing
Job
Overview
Job Overview
Transaction
SM37
Job Status
Job
Overview
Job Analysis using Job Log
Step #2
...
IMPORT <data> FROM
MEMORY.
...
Passing Data to Subsequent Job Steps
Step #2
<id2> ...
IMPORT <data2> FROM
<data2> MEMORY ID <id2>.
...
Scheduling Job within
ABAP/4 Program
JOB_OPEN
JOB_SUBMIT
is called for
Insert Job Step
each step that
is to be added
to the job. JOB_SUBMIT
JOB_CLOSE
JOB_OPEN
Importing:
jobcount = <job #>
JOB_SUBMIT
Step #2
JOB_CLOSE
Importing:
job_was_released = Step #2
<flag2>
ABAP/4 Program Example
REPORT Y180DM01.
DATA: JOBNUM LIKE TBTCJOB-JOBCOUNT.
PARAMETERS: JOBNAME LIKE TBTCJOB-JOBNAME,
PROGRAM LIKE SY-REPID,
VARIANT LIKE RALDB-VARIANT,
USER LIKE SY-UNAME.
Open Job CALL FUNCTION ‘JOB_OPEN’
EXPORTING JOBNAME = JOBNAME
IMPORTING JOBCOUNT = JOBNUM.
Submit Step CALL FUNCTION ‘JOB_SUBMIT’
EXPORTING AUTHCKNAM = USER
JOBCOUNT = JOBNUM
JOBNAME = JOBNAME
REPORT = PROGRAM
VARIANT = VARIANT.
WRITE: / JOBNAME, JOBCOUNT, REPORT, VARIANT,
BTCHUSER.
Close Job CALL FUNCTION ‘JOB_CLOSE’
EXPORTING JOBCOUNT = JOBCOUNT
JOBNAME = JOBNAME.
Summary of Background Processing
Job Log
Step #1
Spool List
Step #2
Background
CHAPTER 2
FILE HANDLING AT
APPLICATION SERVER
Overview
In this chapter, we
will learn how to
process sequential
Database
files on an Server
application server
Application
Servers
Presentation
Servers
Processing Files
Open File
Close File
Open File
“FOR”
“IN”
INPUT
BINARY MODE
OUTPUT
TEXT MODE
APPENDING
“TRANSFER” statement
REPORT Y180DM02.
TABLES: KNA1.
PARAMETERS:
OUTFILE(20) DEFAULT ‘/tmp/bc180_file1’
LOWER CASE,
STATE LIKE KNA1-REGIO DEFAULT ‘MA’.
Step #1 DATA: BEGIN OF OUTREC,
KUNNR LIKE KNA1-KUNNR,
REGIO LIKE KNA1-REGIO,
TELF1 LIKE KNA1-TELF1,
END OF OUTREC.
REPORT Y180DM03.
TABLES: KNA1.
PARAMETERS:
OUTFILE(20) DEFAULT ‘/tmp/bc180_file1’
LOWER CASE,
STATE LIKE KNA1-REGIO DEFAULT ‘MA’.
DATA: BEGIN OF OUTREC,
The only change from the KUNNR LIKE KNA1-KUNNR,
previous example is “FOR REGIO LIKE KNA1-REGIO,
APPENDING” instead of TELF1 LIKE KNA1-TELF1,
“FOR OUTPUT”. END OF OUTREC.
REPORT Y180DM04.
PARAMETERS:
INFILE(20) DEFAULT ‘/tmp/bc180_file1’
LOWER CASE.
Step #1 DATA: BEGIN OF INREC,
KUNNR LIKE KNA1-KUNNR,
REGIO LIKE KNA1-REGIO,
TELF1 LIKE KNA1-TELF1,
END OF INREC.
A B C 1 A B C D
D E F G 2 E F G H
I J K L 3 I J K
CHAPTER 3
FILE HANDLING AT
PRESENTATION
SERVER
Overview
In this chapter, we
will learn how to
process sequential Database
files on a Server
presentation server
Application
Servers
Presentation
Servers
Use of an Internal Table
Internal Table
To create a local file,
you must transfer the
contents of an
internal table.
Internal Table
To read a local file,
you must read the
contents into an
internal table.
Create Local File
REPORT Y180DM06.
TYPES: BEGIN OF INREC,
KUNNR LIKE KNA1-KUNNR,
REGIO LIKE KNA1-REGIO,
TELF1 LIKE KNA1-TELF1,
END OF INREC.
Step #1 DATA: IN_ITAB TYPE INREC
OCCURS 10 WITH HEADER LINE.
To download an ABAP/4
ABAP/4 program to a local file,
Program use the “Utilities >
Download” menu path.
External
Data
X Checks &
SAP
Database
Validations
Table
External
Data
Online Program
Street
City Philadelphia
BDCDATA Structure
Vendor TEST1
Company Code
For our example, we
will use the “Change X Address
Vendor” transaction
(“FK02”) to add a street
address to an already
existing vendor. Name Computers, Inc.
Step #1 Step #2
Use “System > Status” Use ‘F1’ key and “Technical
menu path to determine Info” pushbutton in each
online program name screen field to be filled to
(SAPMF02K), screen determine the field name.
number (0106), and
transaction code (FK02). Step #3
Determine how to proceed
Vendor TEST1 in the transaction
Company Code (go to the next screen by
pressing the ‘Enter’ key).
X Address
Field name = RF02K-LIFNR
Field name = RF02K-D0110
Researching Transaction - 2nd Screen
Step #1 Step #2
Use “System > Status” Use ‘F1’ key and “Technical
menu path to determine Info” pushbutton in each
online program name screen field to be filled to
(SAPMF02K) and screen determine the field name.
number (0110).
Step #3
Determine how to proceed
in the transaction (save the
Name Computers, Inc. record by clicking on the
‘Save’ pushbutton or
Street 123 Main St. pressing the ‘F11’ key).
City Philadelphia
Field name = LFA1-STRAS
BDC Table Contents
FORM FILL_BDC_TAB.
CLEAR BDC_TAB.
REFRESH BDC_TAB. BDC_TAB-PROGRAM = ‘SAPMF02K’.
BDC_TAB-DYNPRO = ‘0110’.
CLEAR BDC_TAB. BDC_TAB-DYNBEGIN = ‘X’.
BDC_TAB-PROGRAM = ‘SAPMF02K’. APPEND BDC_TAB.
BDC_TAB-DYNPRO = ‘0106’.
BDC_TAB-DYNBEGIN = ‘X’. CLEAR BDC_TAB.
APPEND BDC_TAB. BDC_TAB-FNAM = ‘LFA1-STRAS’.
BDC_TAB-FVAL = ‘123 Main St.’.
CLEAR BDC_TAB. APPEND BDC_TAB.
BDC_TAB-FNAM = ‘RF02K-LIFNR’.
BDC_TAB-FVAL = ‘TEST1’. CLEAR BDC_TAB.
APPEND BDC_TAB. BDC_TAB-FNAM = ‘BDC_OKCODE’.
BDC_TAB-FVAL = ‘/11’.
CLEAR BDC_TAB. APPEND BDC_TAB.
BDC_TAB-FNAM = ‘RF02K-D0110’.
BDC_TAB-FVAL = ‘X’. ENDFORM.
APPEND BDC_TAB.
Filling BDC Table - Method #2
This two-subroutine method to fill the BDC table is preferable because the
“POPULATE_BDC_TAB” subroutine is reusable throughout all batch input programs.
Batch Input Methods
“CALL TRANSACTION
Method #2 USING” Statement
Batch
SAP
Input
Database
Session
Table
Creating Batch Input Sessions
BDC_OPEN_GROUP
“BDC_INSERT” is
called for each
transaction Insert Transaction Data into Session
entered into the
batch input BDC_INSERT
session.
BDC_CLOSE_GROUP
BDC_OPEN_GROUP
Header Section
Creator
Client
Session Name
Authorization User
Hold Date
Batch Keep or Delete
Input
Session
Data Section
Transaction Data
Example #1 - Change Vendor
REPORT Y180DM08.
DATA: BDC_TAB LIKE BDCDATA
OCCURS 6 WITH HEADER LINE,
Step #1
SESSION LIKE APQI-GROUPID
VALUE ‘DEMO #8’.
START-OF-SELECTION.
Step #2 CALL FUNCTION ‘BDC_OPEN_GROUP’
EXPORTING
CLIENT = SY-MANDT
GROUP = SESSION
USER = SY-UNAME
EXCEPTIONS. . . .
Step #3 PERFORM FILL_BDC_TAB.
Step #4 CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE = ‘FK02’
TABLES
DYNPROTAB = BDC_TAB
EXCEPTIONS. . . .
Step #5 CALL FUNCTION ‘BDC_CLOSE_GROUP’
EXCEPTIONS. . . .
X Address X Address
REPORT Y180DM09.
START-OF-SELECTION.
Step #3 OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.
Step #4 CALL FUNCTION ‘BDC_OPEN_GROUP’. . . .
DO.
Step #5 READ DATASET INFILE INTO INREC.
Step #6 IF SY-SUBRC <> 0. EXIT. ENDIF.
Step #7 PERFORM FILL_BDC_TAB.
Step #8 CALL FUNCTION ‘BDC_INSERT’
EXPORTING
TCODE = ‘FK02’
TABLES
DYNPROTAB = BDC_TAB. . . .
ENDDO.
Step #9 CALL FUNCTION ‘BDC_CLOSE_GROUP’. . . .
Step #10 CLOSE DATASET INFILE.
Notice that the vendor number and street values are coming
from the file’s records read into the “INREC” field string.
Summary
Research Transaction
Process
Batch Batch
Input SAP
Input
Session Database
Session
Table
Process
Batch
Session Overview
Transaction Code “SM35”
Input OR
Session “System→ Services→ Batch input→ Sessions” menu path
Processing Modes
/bdel
/n
/bda
/bde
/bend
Session Overview Options
Process
Select block
Batch Delete
Input
Session Session
Statistics
Log
Session Status
Background sessions
** This is not an analysis of the batch input session from the previous page **
Timing Issue
Execute
program
“RSBDCSUB”
BDC Table
When is the
How are errors
SAP database
handled?
updated?
Automatically by the
Create batch During the processing
system during the
input session of the batch input
processing of the
(BDC Program): session
batch input session
X Address X Address
REPORT Y180DM10.
START-OF-SELECTION.
Step #3 OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.
DO.
Step #4 READ DATASET INFILE INTO INREC.
Step #5 IF SY-SUBRC <> 0. EXIT. ENDIF.
Step #6 PERFORM FILL_BDC_TAB.
Step #7 CALL TRANSACTION ‘FK02’
USING BDC_TAB
MODE DISPMODE
UPDATE UPDAMODE.
Step #8 IF SY-SUBRC <> 0.
WRITE: / ‘Error’.
ENDIF.
ENDDO.
Step #9 CLOSE DATASET INFILE.
Notice that the vendor number and street values are coming
from the file’s records read into the “INREC” field string.
Error Handling
DO. DO.
... ...
PERFORM FILL_BDC_TAB. PERFORM FILL_BDC_TAB.
CALL TRANSACTION ‘FK02’ CALL TRANSACTION ‘FK02’
USING BDC_TAB USING BDC_TAB
MODE ‘N’ MODE ‘N’
UPDATE ‘S’. UPDATE ‘A’.
IF SY-SUBRC <> 0. IF SY-SUBRC <> 0.
WRITE: / ‘Error’. WRITE: / ‘Transaction error’.
ENDIF. ENDIF.
ENDDO. ENDDO.
REPORT Y180DM11.
Notice that the vendor number and street values are coming
from the file’s records read into the “INREC” field string.
“CALL TRANSACTION”
versus “CALL DIALOG”
CALL
Update occurs after
TRANSACTION
each transaction is
completed.
Timing of
Update
Update occurs on
“COMMIT WORK”
CALL statement.
DIALOG