Chapter 01_Background Processing

download Chapter 01_Background Processing

of 37

description

Background Processing

Transcript of Chapter 01_Background Processing

  • 5/22/2018 Chapter 01_Background Processing

    1/37

    IBM Global Services

    2005 IBM CorporationData Interfaces | 7.01 March-2005

    Background Processing

  • 5/22/2018 Chapter 01_Background Processing

    2/37

    IBM Global Services

    2005 IBM Corporation2 March-2005Data Interfaces | 7.01

    Objectives

    The participants will be able to:

    Describe how the SAP system handles background processing.

    Create variants for ABAP programs.

    Create, schedule, and analyze a job using transactions SM36 and SM37.

    Explain the purpose of background processing.

  • 5/22/2018 Chapter 01_Background Processing

    3/37

    IBM Global Services

    2005 IBM Corporation3 March-2005Data Interfaces | 7.01

    Background Processing

    Phases of Background Processing.

    Passing Data to Subsequent Job Steps.

    Scheduling Job within ABAP Program.

  • 5/22/2018 Chapter 01_Background Processing

    4/37

    IBM Global Services

    2005 IBM Corporation4 March-2005Data Interfaces | 7.01

    Work Processes

    Dispatcher

    Background

    EnqueueUpdate SpoolDialog

    Transaction

    SM50

  • 5/22/2018 Chapter 01_Background Processing

    5/37

    IBM Global Services

    2005 IBM Corporation5 March-2005Data Interfaces | 7.01

    The Background Work Process

    Background

    Defining a

    background job (SM36)

    Background Job A

    Step #1

    Step #2

  • 5/22/2018 Chapter 01_Background Processing

    6/37

    IBM Global Services

    2005 IBM Corporation6 March-2005Data Interfaces | 7.01

    Phases of Background Processing

    Job

    Processing

    Job

    Scheduling

    Job

    Overview

  • 5/22/2018 Chapter 01_Background Processing

    7/37

    IBM Global Services

    2005 IBM Corporation7 March-2005Data Interfaces | 7.01

    Scheduling a Background Job

    Job

    Scheduling

    Transaction

    SM36

  • 5/22/2018 Chapter 01_Background Processing

    8/37

    IBM Global Services

    2005 IBM Corporation8 March-2005Data Interfaces | 7.01

    Creating Step for Background Job

    JobScheduling

    Steps

    ABAP External program

  • 5/22/2018 Chapter 01_Background Processing

    9/37

    IBM Global Services

    2005 IBM Corporation9 March-2005Data Interfaces | 7.01

    Start Criteria for Background Job

    Jobs can be scheduled to

    run immediately or at a

    particular date/time.

    Jobs can be

    scheduled to run

    after another job has

    been completed.

    Jobs can be scheduled

    to run after an event has

    been triggered/raised.

    If you start a job based on a date/time or an event, you

    can schedule the job to run at regular intervals, not just

    at a particular time.

    Job

    Scheduling

    Immediate After EventAfter JobDate/Time

    Start Condition

  • 5/22/2018 Chapter 01_Background Processing

    10/37

    IBM Global Services

    2005 IBM Corporation10 March-2005Data Interfaces | 7.01

    Scheduling a Periodic Job

    Job

    Scheduling

    With the Period

    Values pushbutton,

    you can schedule

    the job to run hourly,

    daily, weekly,

    monthly, etc.

    By checking the

    Periodic Job option,you can specify

    that the job run at

    regular intervals.

    Periodic jobX

    Start date

    Period values

  • 5/22/2018 Chapter 01_Background Processing

    11/37

    IBM Global Services

    2005 IBM Corporation11 March-2005Data Interfaces | 7.01

    Scheduling Job After Another Job

    If you check the Start status-depend.

    option, this job will run only if the

    specified job ends successfully.

    After Job

    Start status-depend.X

    After clicking on the

    After Job pushbutton,you must specify the

    name of the job that must

    be completed before this

    job will run.

    Start date

    Job

    Scheduling

  • 5/22/2018 Chapter 01_Background Processing

    12/37

    IBM Global Services

    2005 IBM Corporation12 March-2005Data Interfaces | 7.01

    Scheduling Job After an Event

    Job

    SchedulingAfter EventStart date

    After clicking on the After Event

    pushbutton, you must specify thename of the event that must be

    raised before this job will run. You

    can distinguish between different

    occurrences of a particular event

    by specifying a parameter.

    If you check the Periodic Job option, the

    system starts a new job each time the

    specified event is raised.

  • 5/22/2018 Chapter 01_Background Processing

    13/37

    IBM Global Services

    2005 IBM Corporation13 March-2005Data Interfaces | 7.01

    Triggering/Raising Events

    CALL FUNCTION BP_EVENT_RAISEEXPORTING

    EVENTID =

    EVENTPARM =

    TARGET_INSTANCE =

    EXCEPTIONS

    BAD_EVENTID = 1

    EVENTID_DOES_NOT_EXIST = 2EVENTID_MISSING = 3

    RAISE_FAILED = 4

    OTHERS = 5.

    The only required

    exporting parameter is the

    name of the event to raise.

    To trigger/raise an event from within an ABAP program, you

    must call the BP_EVENT_RAISE function module.

  • 5/22/2018 Chapter 01_Background Processing

    14/37

    IBM Global Services

    2005 IBM Corporation14 March-2005Data Interfaces | 7.01

    Phases of Background Processing

    Job

    Scheduling

    Job

    Processing

    Job

    Overview

  • 5/22/2018 Chapter 01_Background Processing

    15/37

    IBM Global Services

    2005 IBM Corporation15 March-2005Data Interfaces | 7.01

    Processing a Background Job

    Background

    Dispatcher

    Job

    Processing

    JobScheduler

    Job

  • 5/22/2018 Chapter 01_Background Processing

    16/37

    IBM Global Services

    2005 IBM Corporation16 March-2005Data Interfaces | 7.01

    Processing a Background Job

    Transaction

    SM50

    JobProcessing

    Application ServerWork Processes

    1 Spool8 Online 3 Background

  • 5/22/2018 Chapter 01_Background Processing

    17/37

    IBM Global Services

    2005 IBM Corporation17 March-2005Data Interfaces | 7.01

    Processing a Background Job

    Scheduler

    Start Module

    Job Step #1

    Job Step #2

    Job Step #3

    Job Log

    Entries from start and endmodules.

    All messages issued by job

    steps and system.

    Job

    Processing

    List

    All WRITEstatement output

    from job step.

    PRINT SPOOL

    End Module

  • 5/22/2018 Chapter 01_Background Processing

    18/37

    IBM Global Services

    2005 IBM Corporation18 March-2005Data Interfaces | 7.01

    Phases of Background Processing

    Job

    Scheduling

    Job

    Processing

    Job

    Overview

  • 5/22/2018 Chapter 01_Background Processing

    19/37

    IBM Global Services

    2005 IBM Corporation19 March-2005Data Interfaces | 7.01

    Transaction

    SM37

    Job

    Overview

    Job Status

    Job Overview

    Spool List

    IBM Gl b l S i

  • 5/22/2018 Chapter 01_Background Processing

    20/37

    IBM Global Services

    2005 IBM Corporation20 March-2005Data Interfaces | 7.01

    Job Analysis Using Job Log

    Job

    OverviewSystem and Program

    Messages

    You can use this Job Log to analyze each step of a finished or

    cancelled background job.

    IBM Gl b l S i

  • 5/22/2018 Chapter 01_Background Processing

    21/37

    IBM Global Services

    2005 IBM Corporation21 March-2005Data Interfaces | 7.01

    Job Analysis Using Job Spool

    Display

    Report

    IBM Gl b l S i

  • 5/22/2018 Chapter 01_Background Processing

    22/37

    IBM Global Services

    2005 IBM Corporation22 March-2005Data Interfaces | 7.01

    Other BackgroundProcessing Topics

    Passing Data to Subsequent Job Steps

    Scheduling Job within ABAP Program

    IBM Gl b l S i

  • 5/22/2018 Chapter 01_Background Processing

    23/37

    IBM Global Services

    2005 IBM Corporation23 March-2005Data Interfaces | 7.01

    Scheduling Job withinABAP Program

    Open Background Job

    JOB_OPEN

    Insert Job Step

    JOB_SUBMIT

    Close Background Job

    JOB_CLOSE

    JOB_SUBMIT iscalled for each

    step that is to be

    added to the job

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    24/37

    IBM Global Services

    2005 IBM Corporation24 March-2005Data Interfaces | 7.01

    JOB_OPEN

    JOB_OPEN Background Job

    Exporting:

    jobname =

    Importing:

    jobcount =

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    25/37

    IBM Global Services

    2005 IBM Corporation25 March-2005Data Interfaces | 7.01

    JOB_SUBMIT

    JOB_SUBMIT

    Background Job`Exporting:

    authcknam =

    jobcount =

    jobname =

    report = variant =

    Step #1

    Step #2

    Exporting:

    authcknam =

    jobcount = jobname =

    report =

    variant =

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    26/37

    IBM Global Services

    2005 IBM Corporation26 March-2005Data Interfaces | 7.01

    JOB_CLOSE

    JOB_CLOSE Background Job

    Exporting:

    jobcount =

    jobname =

    sdlstrtdt = sdlstrttm =

    strtimmed =

    Importing:job_was_released =

    Step #1

    Step #2

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    27/37

    IBM Global Services

    2005 IBM Corporation27 March-2005Data Interfaces | 7.01

    ABAP Program Example

    REPORT YDI00001.

    DATA: JOBNUM LIKE TBTCJOB-JOBCOUNT.

    PARAMETERS: JOBNAME LIKE TBTCJOB-JOBNAME,

    PROGRAM LIKE SY-REPID,

    VARIANT LIKE RALDB-VARIANT,

    USER LIKE SY-UNAME.

    CALL FUNCTION JOB_OPEN

    EXPORTING JOBNAME = JOBNAME

    IMPORTING JOBCOUNT = JOBNUM.

    CALL FUNCTION JOB_SUBMIT

    EXPORTING AUTHCKNAM = USER

    JOBCOUNT = JOBNUM

    JOBNAME = JOBNAMEREPORT = PROGRAM

    VARIANT = VARIANT.

    CALL FUNCTION JOB_CLOSE

    EXPORTING JOBCOUNT = JOBNUM

    JOBNAME = JOBNAME.

    Open Job

    Submit Step

    Close Job

    SY-SUBRC

    CHECK

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    28/37

    IBM Global Services

    2005 IBM Corporation28 March-2005Data Interfaces | 7.01

    Passing Data to SubsequentJob Steps

    Background Job

    Step #1

    . . .

    EXPORT TO DATABASE

    ID .

    EXPORT < obj1 objn>TO DATASET

    ID .

    Step #2

    . . .

    IMPORT < obj1 objn> FROM DATABASE

    ID .

    IMPORT < obj1 objn> FROM DATASET

    ID .

    DBTABLE

    id1 data1

    .

    .

    FILENAME

    id2 data2

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    29/37

    IBM Global Services

    2005 IBM Corporation29 March-2005Data Interfaces | 7.01

    Passing Data to SubsequentJob Steps (Contd.)

    Background Job

    Step #1

    . . .

    EXPORT TO DATABASE

    ID .

    EXPORT < obj1 objn>TO DATASET

    ID .

    Step #2

    . . .

    IMPORT < obj1 objn> FROM DATABASE

    ID .

    IMPORT < obj1 objn> FROM DATASET

    ID .

    DBTABLE

    id1 data1

    .

    .

    FILENAME

    id2 data2

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    30/37

    IBM Global Services

    2005 IBM Corporation30 March-2005Data Interfaces | 7.01

    Background JobStep #1TABLES: INDX.

    DATA: var1(9) TYPE p

    DECIMALS 2.

    . . .

    EXPORT var1 TO DATABASEindx(st) ID 12345

    Step #2

    TABLES: INDX.

    DATA: var1(9) TYPE pDECIMALS 2.

    . . .

    IMPORT var1 FROM

    DATABASE indx(st) ID

    12345.

    INDX

    MANDT RELID SRTFD CLUSTR

    800

    800

    800

    800

    SP

    ST

    ST

    TM

    .. CLUSTD

    SPH_I

    12345

    ABCL

    KVERM

    254

    53

    73

    97

    FF05010102

    FF05016876

    FF05075372

    FF03578902

    Using the Database to Pass Data between Job Steps

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    31/37

    IBM Global Services

    2005 IBM Corporation31 March-2005Data Interfaces | 7.01

    Background JobStep #1TABLES: INDX.

    DATA: var1(9) TYPE p

    DECIMALS 2.

    . . .

    EXPORT var1 TO DATABASEindx(st) ID 12345

    Step #2

    TABLES: INDX.

    DATA: var1(9) TYPE pDECIMALS 2.

    . . .

    IMPORT var1 FROM

    DATABASE indx(st) ID

    12345.

    INDX

    MANDT RELID SRTFD CLUSTR

    800

    800

    800

    800

    SP

    ST

    ST

    TM

    .. CLUSTD

    SPH_I

    12345

    ABCL

    KVERM

    254

    53

    73

    97

    FF05010102

    FF05016876

    FF05075372

    FF03578902

    Using the Database to Pass Data between Job Steps (Contd.)

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    32/37

    IBM Global Services

    2005 IBM Corporation32 March-2005Data Interfaces | 7.01

    INDX

    MANDT RELID SRTFD CLUSTR

    800

    800

    800

    800

    SP

    ST

    ST

    TM

    ... CLUSTD

    SPH_I

    12345

    ABCL

    KVERM

    254

    53

    73

    97

    FF0501010254787

    FF0501687618710

    FF0507110005472

    FF0357890541472

    Structure of the Data Cluster Table

    SRTF2

    0

    0

    0

    0

    Client

    Area

    Key fields touniquely identify

    Data Cluster

    ClusterLength

    Cluster

    Data

    Fields to store information pertaining tocluster data, not automatically updated byexport, need to be explicitly set before the

    export statement

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    33/37

    IBM Global Services

    2005 IBM Corporation33 March-2005Data Interfaces | 7.01

    Structure of the Data Cluster Table (Contd.)

    INDX

    MANDT RELID SRTFD CLUSTR

    800

    800

    800

    800

    SP

    ST

    ST

    TM

    ... CLUSTD

    SPH_I

    12345

    ABCL

    KVERM

    254

    53

    73

    97

    FF0501010254787

    FF0501687618710

    FF0507110005472

    FF0357890541472

    SRTF2

    0

    0

    0

    0

    Client

    Area

    Key fields touniquely identify

    Data Cluster

    ClusterLength

    Cluster

    Data

    Fields to store information pertaining tocluster data, not automatically updated byexport, need to be explicitly set before the

    export statement

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    34/37

    IBM Global Services

    2005 IBM Corporation34 March-2005Data Interfaces | 7.01

    Demonstration

    Creation, scheduling and analyzing a background job using transactions SM36and SM37.

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    35/37

    2005 IBM Corporation35 March-2005Data Interfaces | 7.01

    Practice

    Creation, scheduling and analyzing a background job using transactions SM36and SM37.

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    36/37

    2005 IBM Corporation36 March-2005Data Interfaces | 7.01

    Step #1

    Step #2

    Background

    Job Log

    Spool List

    JobScheduling

    JobProcessing

    JobOverview

    Summary

    IBM Global Services

  • 5/22/2018 Chapter 01_Background Processing

    37/37

    Questions

    What are the various types of work processes present in the R/3 system ?

    What are the main phases of background processing ?

    What are the main function modules used to create background job through

    ABAP program ?