Logical Databse

  • View
    218

  • Download
    0

Embed Size (px)

Text of Logical Databse

  • 7/30/2019 Logical Databse

    1/32

    Logical Database

  • 7/30/2019 Logical Databse

    2/32

    What is Logical Database ?

    A logical database is a special ABAP/4 program

    which combines the contents of certain databasetables.

    Using logical databases facilitates the process of

    reading database tables.

  • 7/30/2019 Logical Databse

    3/32

    Logical Databases - Views of DataA logical database provides a particular view ofdatabase tables in the R/3 System.

    The data structure in a logical database is

    hierarchical.Many tables in the R/3 System are linked to eachother using foreign key relationships.

    Some of these dependencies form tree-like

    hierarchical structures. LDBs read data fromdatabase tables that are part of these structures.

  • 7/30/2019 Logical Databse

    4/32

    Using LDB

    There are two ways of using a LDB :

    By linking it with an executable program.

    By using the function module LDB_PROCESS in any

    ABAP program.

  • 7/30/2019 Logical Databse

    5/32

    Linking LDB with executable program

    By entering the name of the logical database in the

    program attributes

    The subroutines of the logical database program andthe event blocks of the executable program form a

    modularized program for reading and processing

    data.

    The runtime sequence is controlled by the structure,selections, and PUT statements in the LDB, and by

    the GET statements in the executable program.

  • 7/30/2019 Logical Databse

    6/32

    Events in LDB Programming

    GET

    GET LATE

  • 7/30/2019 Logical Databse

    7/32

    GET EventThis is the most important event for executableprograms that use a LDB.

    It occurs when the logical database has read a line

    from the node and made it available to theprogram in the work area declared using thestatement NODES .

    You can process the data in the work area in thisevent block. For example, you can write it directly toa list, or store it in a sequential dataset (internal tableor extract) so that you can process it later.

  • 7/30/2019 Logical Databse

    8/32

    Get Late Event

    This event is triggered when all of the data records

    for a node of the logical database have been read.

    You can use the event block for processing steps that

    should occur at the end of the block, like, for

    example, calculating statistics.

  • 7/30/2019 Logical Databse

    9/32

    HR LDBs

    PNP - Evaluates all HR Master Data and time data.

    PAP - Applicant Master Data

    PCH - Personnel Planning

  • 7/30/2019 Logical Databse

    10/32

    Functions

    Standard Selection Screen

    Data Retrieval

    Authorization check

  • 7/30/2019 Logical Databse

    11/32

    Selection Screen

    LDB provides a standard selection screen

    which gives standard look and feel throughoutall programs

  • 7/30/2019 Logical Databse

    12/32

    Date Selection

    Date selection delimits the time period for which data

    is evaluated.

    GET PERNR retrieves all records of the relevant

    infotypes from the database . When you enter a

    date selection period, the PROVIDE loop retrieves

    the infotype records whose validity period overlapswith at least one day of this period.

  • 7/30/2019 Logical Databse

    13/32

    Person selection

    Person selection is the 'true' selection of choosing a

    group of employees for whom the report is to run.

  • 7/30/2019 Logical Databse

    14/32

    Sorting Data

    The standard sort sequence lists personnel numbers in

    ascending order.

    SORT function allows you to sort the report data

    otherwise. All the sorting fields are from infotype

    0001.

  • 7/30/2019 Logical Databse

    15/32

    Report Class

    You can suppress input fields which are not used on

    the selection screen by assigning a report class toyour program.

    If SAP standard delivered report classes do not satisfy

    your requirements, you can create your own report

    class through the IMG.

  • 7/30/2019 Logical Databse

    16/32

    Report CategorySelection Screen can be customised by use of Report

    Category

    Able to show/remove/hide certain standard selection

    criteria

    Able to set selection periods eg As At Date

    Able to turn Org Structure button on/off.

    In SE38

    Change Program Attributes

    Click HRReport Category Create

    This button only appears in PNP

  • 7/30/2019 Logical Databse

    17/32

    Report CategorySteps to create new:

    Click new entries

    Enter report category and descriptionCheck Org Structure allowed for org struc button

    Interval for Date period range.

    Double click Allowable Selection Criteria

    Click New EntriesSelect entries from pull down list

  • 7/30/2019 Logical Databse

    18/32

    Report Category

    Selections which are not available must be coded in

    your program as additional selection criteria.

    Save

    Back

    Include report category in your program

    Re-activate program

    Run and test it out.

  • 7/30/2019 Logical Databse

    19/32

    Programming using LDB

    An HR report which uses the LDB has the followingbasic structure.

    Report sampleTables: PERNR.

    INFOTYPES: 0001.

    GET PERNR.

    PROVIDE * from p0001 between pn-begdaand pn-ennda.

    Write : / p0001-pernr, p0001-stell, p0001-begda.

    END PROVIDE.

  • 7/30/2019 Logical Databse

    20/32

    PERNR

    Pernr is a data dictionary structure without a

    database. You must declare this structure in thereport using the tables statement.

  • 7/30/2019 Logical Databse

    21/32

    All infotypes to be processed in the report are listed

    in the abap INFOTYPES keyword.

    The database usually contains several records with

    different validity periods and not just one record for

    each infotype and personnel number.

    Therefore, the infotypes statement is used to create

    an internal table for each of the listed infotypes. The

    structure of this table corresponds to that of therelevant infotype.

    Infotype declaration

  • 7/30/2019 Logical Databse

    22/32

    Data Retrieval

    Data is retrieved at the GET PERNR event. The Get

    pernr action is executed for all personnel numbers

    that were selected on the basis of selection screen

    entries.It fills the internal tables of infotypes that are

    declared for each employee using the infotypes

    statement.

    The internal infotype table is filled with all recordsexisting between the lowest and highest system date.

    The internal table has the name pnnnn, where nnnn

    is the infotype number.

  • 7/30/2019 Logical Databse

    23/32

    After the Get pernr event, the internal tables of the

    infotypes contain records and are ready for

    processing.

    Internal tables are generally processed line-by-line

    using the loop statement

  • 7/30/2019 Logical Databse

    24/32

    Processing Infotype Records

    Processing of infotype records is time-dependent, by

    this we mean dependent on the data selection and

    period entered on the processed at the same time

    and made available for a specific partial period.It is processed with the provide statement.

    The syntax is,

    Provide * from pnnnn between pn-begda and pn-

    endda.

    Write : / pnnnn-field.

    Endprovide.

  • 7/30/2019 Logical Databse

    25/32

    Nnnn stands for the four digit infotype number. The

    relationship between the infotype and the dataselection period of the selection screen is established

    using the pn-begda and pn-endda variables.

    In the provide loop, the data of an infotype record is

    available for processing in the pnnnn structure.

  • 7/30/2019 Logical Databse

    26/32

    You often only require the most recent or earliest

    infotype record, not all infotype records.

    In this case, use one of the following statements,RP-PROVIDE-FROM-LAST pnnnn space pn-begda

    pn-endda.

    Or

    RP-PROVIDE-FROM-FIRST pnnnn space pn-begdapn-endda.

  • 7/30/2019 Logical Databse

    27/32

    These statements make the most recent of earliest

    record in the pn-begda to pn-endda data selection

    period available in the structure pnnnn for infotype

    nnnn.

    If the infotype has subtypes, replace the space

    parameter by the appropriate subtype number

    When a record has been successfully read, the return

    code PNP-SW-FOUND = 1 is returned.

  • 7/30/2019 Logical Databse

    28/32

    Example report

    Report sample.

    Tables : pernr.

    Infotypes : 0001.

    Get pernr.RP-PROVIDE-FROM-LAST P0001 SPACE PN-BEGDA

    PN-ENDDA.

    If PNP-SW-FOUND = 1.

    Write : / p0001-stell, pn-begda, pn-endda.Else.

    Reject.

    Endif.

  • 7/30/2019 Logical Databse

    29/32

    HR Transactions

  • 7/30/2019 Logical Databse

    30/32

    HR Master Data

    PA40 Personnel Events

    PA30 Maintain HR Master DataPA10 Personnel File

    PA20 Display HR Master Data

  • 7/30/2019 Logical Databse

    31/32

    Applicant Master Data

    PB10 Init.entry of applicant master data

    PB20 Display applicant master dataPB30 Maintain applicant master data

    PB40 Applicant events

  • 7/30/2019 Logical Databse

    32/32

    THANK YOU