Calling LDB (logical Database)  into ALV output

h1.Dear Experts,
h3.I have called LDB AFI in my Z program.
h3.My requirement is in program i have to call LDB and output it in ALV  display.
h3.But in output only one entry get displayed .
h3.Here is my code......
REPORT  ZLDB_PROGRAM1                           .
NODES: DIAUFK.
GET DIAUFK.
TYPE-POOLS: SLIS.
*ALV data declarations
data : begin of itab occurs 0,
aufnr like diaufk-aufnr,
auart like diaufk-auart,
erdat like diaufk-erdat,
ustxt like diaufk-ustxt,
sttxt like diaufk-sttxt,
tplnr like diaufk-tplnr,
end of itab.
data : fieldcatalog type slis_t_fieldcat_alv with header line,
      gd_layout    type slis_layout_alv,
      gd_repid     like sy-repid.
data: gt_events type slis_t_event.
DATA: report_id LIKE sy-repid.
move-corresponding diaufk to itab.
append itab.
  fieldcatalog-fieldname   = 'AUFNR'.
  fieldcatalog-seltext_m   = 'Order Number'.
  fieldcatalog-col_pos     = 0.
  fieldcatalog-outputlen   = 10.
  fieldcatalog-emphasize   = 'X'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
  fieldcatalog-fieldname   = 'AUART'.
  fieldcatalog-seltext_m   = 'Order Type'.
  fieldcatalog-col_pos     = 1.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
  fieldcatalog-fieldname   = 'ERDAT'.
  fieldcatalog-seltext_m   = 'Created On'.
  fieldcatalog-col_pos     = 2.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
  fieldcatalog-fieldname   = 'USTXT'.
  fieldcatalog-seltext_m   = 'User Status Line'.
  fieldcatalog-col_pos     = 3.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
  fieldcatalog-fieldname   = 'STTXT'.
  fieldcatalog-seltext_m   = 'System Status Line'.
  fieldcatalog-col_pos     = 4.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
report_id = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
  I_INTERFACE_CHECK              = ' '
  I_BYPASSING_BUFFER             =
  I_BUFFER_ACTIVE                = ' '
   I_CALLBACK_PROGRAM             = report_id
  I_CALLBACK_PF_STATUS_SET       = ' '
  I_CALLBACK_USER_COMMAND        = ' '
  I_STRUCTURE_NAME               =
  IS_LAYOUT                      =
   IT_FIELDCAT                    = fieldcatalog[]
  IT_EXCLUDING                   =
  IT_SPECIAL_GROUPS              =
  IT_SORT                        =
  IT_FILTER                      =
  IS_SEL_HIDE                    =
  I_DEFAULT                      = 'X'
  I_SAVE                         = ' '
  IS_VARIANT                     =
  IT_EVENTS                      =
  IT_EVENT_EXIT                  =
  IS_PRINT                       =
  IS_REPREP_ID                   =
  I_SCREEN_START_COLUMN          = 0
  I_SCREEN_START_LINE            = 0
  I_SCREEN_END_COLUMN            = 0
  I_SCREEN_END_LINE              = 0
IMPORTING
  E_EXIT_CAUSED_BY_CALLER        =
  ES_EXIT_CAUSED_BY_USER         =
  TABLES
    T_OUTTAB                       = itab
EXCEPTIONS
  PROGRAM_ERROR                  = 1
  OTHERS                         = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Please reply.

hi,
Populate one more field in field catalog for each entry  and try.
fieldcatalog-fieldname = 'AUFNR'.
fieldcatalog-tabname = 'itab'.
fieldcatalog-seltext_m = 'Order Number'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
Regards,
Lokeswari.

Similar Messages

  • How to get the selection parameters from logical database into one of the t

    Hi Sap ABAP Champians,
    How to get the selection parameters from logical database into one of the tab in the tabstrip selection-screen.
    Please help me for this
    Thanks
    Basu

    Hi
    Thanks, that will work, but then I'll have to insert code into all my reports.
    I can see that "Application Server Control Console" is able to rerun a report.
    This must mean that the Report Server has access to the runtime parameters.
    But how?
    Cheers
    Nils Peter

  • Getting results from LDB (Logical Database)

    Hi All,
    I have a requirement where i need to pass LDB results to external application. It can be any LDB. Like in SE36 we put the LDB name and execute and final results are shown in ALV. I dont need it to display in ALV but from my custom program, need that output table which stores these results.
    I tried using LDB_PROCESS but that need custom subroutine names to pass in that, i tried  passing the same and results also came but thing is every logical database will have different tables in that, it'll be impossible to create those many subroutine to handle each and every table. So i need a generalized solution like se36 processes the data for any LDB.
    Is anyone knows how can i achieve this?
    Regards
    Munish Garg
    9041793217

    Hello
    Generally any LDB will have a event which triggers the data to be populated in the tables/memory. Now these data retrieval is written in a sub-routine "Perform PUT_<eventnamt>". So any LDB will have the sub-routine named "PUT_<eventname>" in its main program. May be you can create the sub-routine name dynamically using this method.
    Regards
    Ranganath

  • LDB (Logical Database) results

    Dear All,
    I have an requirement where I have get the selection screen fields list of logical database(LDB) in my custom program.
    Also after getting the selection screen fields, whatever criteria is filled in those, once again i have to take those inputs and get the  results by executing the LDB.
    Is anyone can help me......
    Regards
    Munish Garg

    You will need to call LDB_PROCESS, but you will have to map the data from LDB to internal table (how do your report "knows" which nodes and which fields from those nodes are to be included in the internal table ?)
    So many dynamic statements like CREATE DATA <dref> TYPE REF TO (LBDA-DDIC_TYPE) using the parameter <formname> = LBDA-LDBNODE in a generic FORM <formname> USING <nodename> LIKE LDBCB-LDBNODE and then many ASSIGN statements to map the desired fields to the returned internal table records. At each call of this generic FORM, map each and every "corresponding" fields, add the record to the internal table at the lower level node.
    Regards,
    Raymond

  • LDB(Logical Database) selection screen

    Dear Contributors,
    I am hopefull for finding solution to my problem from one of you.
    My requirement is i would like to pass all the elements of the selection screen of LDB to non-sap application so as they can replicate and show all those parameters there. Once those are filled from there then i need to take them and process the LDB.
    My question is i dont know how to get the selection screen parameters. I tried using FM 'RPY_DYNPRO_READ' and passed progname and screen number in that. It gave back all the parameters but we cant co-relate which parameter is from which table (like we say MATNR like MARA-MATNR).
    Without having Technical details of field, non-sap application could not able to process it or show the required F4 help etc
    Anyone know about it, can guide me....
    Regards
    Munish Garg

    call function 'LDB_CONVERT_LDBNAME_2_DBPROG'
           exporting  ldb_name             = headsg-logdb "#EC DOM_EQUAL
                      flag_existence_check = space
           importing  db_name              = logdbprog
           exceptions others               = 1.
      if sy-subrc eq 0.
        call function 'SELOPTS_AND_PARAMS'
             exporting  program              = logdbprog
             tables     selpars              = dbselpars
             exceptions program_non_existent = 1
                        subroutine_pool      = 2
                        load_problems        = 3
                        others               = 4.
    endif.

  • LDB(logical database)

    Hello all,
    I have LDB is BAM. This BAM is used in ME57(RM06BZ00)...when we execute ME57 the selection screen is coming from LDB..My req is i have to insert the new field like POGROUP in ME57 selection screen...so wat i did ultimately i was inserted the new field , which is in LDB select-options...when i execute the LDB inserted newfield is displying in the screen.....
    But my problem is when i used the same LDB(which new field inserted) in ME57(RM06BZ00) program this newly inserted Field(POGROUP) is not displying....
    Please anyone tell me how to insert the new field in ME57.....

    You will need to call LDB_PROCESS, but you will have to map the data from LDB to internal table (how do your report "knows" which nodes and which fields from those nodes are to be included in the internal table ?)
    So many dynamic statements like CREATE DATA <dref> TYPE REF TO (LBDA-DDIC_TYPE) using the parameter <formname> = LBDA-LDBNODE in a generic FORM <formname> USING <nodename> LIKE LDBCB-LDBNODE and then many ASSIGN statements to map the desired fields to the returned internal table records. At each call of this generic FORM, map each and every "corresponding" fields, add the record to the internal table at the lower level node.
    Regards,
    Raymond

  • Logical Database o/p in ALV

    Dear Expert.
    I have to call AFI logical database in ZPROGRAM. If I write GET DIAUFK (root node)
    How do I fetch data form parent and child node?
    O/p should come as ALV on that alv pop-up will come on that pop up list of transaction displayed which will work on click.
    Please suggest.
    START-OF-SELECTION.
    GET DIAUFK  .
    *get late
    *GET DIIHPA.
    GET DIIFLO .
    *GET DIQMEL.
      MOVE-CORRESPONDING DIAUFK TO ITAB.
    *MOVE-CORRESPONDING DIQMEL TO ITAB.
      APPEND ITAB.
    GET DIAUFK LATE.
    IF S_ERDAT NE SPACE AND S_WERKS NE SPACE.
      ITAB-ERDAT = S_ERDAT .
      ITAB-WERKS = S_WERKS .
    ENDIF.
    END-OF-SELECTION.
      LOOP AT ITAB.
        IT_FINAL = ITAB.
        APPEND IT_FINAL.
      ENDLOOP.

    Try exploring FM 'LDB_PROCESS'
    <removed by moderator>
    Edited by: Thomas Zloch on Aug 9, 2010 2:56 PM - don't ask for ...

  • Multiple calling logical database ADA

    Hello,
    I need to call logical database ADA two times in my program. I use calling logical database using LDB_PROCESS function module. I need to call LDB for depreciation areas 01 and 60. If I call second time, I get exception  LDB_NOT_REENTRANT. I found, that for multiple calls of LDB, there should be LDB_PROCESS_INIT subroutine in logical database proram. In this case, program is SAPDBADA and in this program, LDB_PROCESS_INIT is missing.
    Could you pls. help me, how to call ADA logical database two times?
    Thanks&regards,
    Jirka

    The exception LDB_NOT_REENTRANT means: The logical database is not prepared to accept several successive calls within a transaction. So obviously you can't use LDB_PROCESS  for your purpose.
    Perhaps your goal is possible if you use a sequence of commands
    GET <ldb_node_1>.
    GET <ldb_node_1> LATE.
    GET <ldb_node_2>.
    GET <ldb_node_2> LATE.
    etc...
    where  ldb_node_1, ldb_node_2, etc... are some nodes included in logical database ADA. As I am not familiar with this particular LDB I can't tell which nodes are required to achieve your goal.

  • How to call logical database

    hi friends,
        plz explain me how to call logical database in a report program?

    hi,
    Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.
    However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.
    Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.
    Logical Databases - Views of Data
    A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.
    The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.
    Advantages of Logical database -
    1) No need of programming for retrieval , meaning for data selection
    2) Easy to use standard user interface, have check completeness of user input.
    Disadvantages
    1) Fast in case of lesser no. of tables But if the table is in the lowest level of hierarchy, all upper level tables should be read so performance is slower.
    GO THROUGH THE LINKS
    http://www.sap-basis-abap.com/saptab.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
    /people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
    Re: **LDB**
    www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html
    www.sap-img.com/abap/abap-interview-question.htm
    www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm
    Use Tcode SE36 For creating Logical Database.
    Here is a simple Program on Logical database.
    NODES: spfli,sflight.
    START-OF-SELECTION.
    WRITE 'Test Program for GET'.
    *Fetching SPFLI table
    GET spfli.
    WRITE: / 'Carrid:', spfli-carrid,
    'Connid:', spfli-connid.
    *Fetching SFLIGHT table
    GET sflight.
    SKIP 5.
    WRITE: / 'Carrid:', sflight-carrid,
    'Connid:', sflight-connid.
    logical database
    logical database
    http://help.sap.com/saphelp_nw04/helpdata/en/60/183d78163011d2953c0000e8353423/frameset.htm
    general
    example program
    http://help.sap.com/saphelp_nw04s/helpdata/en/9f/db9be035c111d1829f0000e829fbfe/frameset.htm
    regards,
    pavan
    REWARD POINTS IF USEFUL

  • HR Logical database PNP. OO to fill table dynamic table  from PNP  ?

    Hi all
    I want to get some stuff from the HR logical database into a dynamic table
    Here's a real simple example that writes info out to a normal list.
    (report is based on using Logical DB PNP)
    tables: pernr.
    INFOTYPES: 0001,                     "Organizational Assignment
               0002.                     "Personal Data
    SELECT-OPTIONS: language FOR p0002-sprsl.
    INITIALIZATION.
      pnptimed = 'D'.
    GET pernr.
      PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.
        CHECK language.
        WRITE: / p0002-pernr,
                 sy-vline,
                 p0001-ename,
                 sy-vline,
                 p0002-sprsl,
                 sy-vline,
                 p0002-gbdat.
      ENDPROVIDE.
    endform.
    Now what I want to do is replace the write stuff by appending the entries into a dynamic table which I will display as an ALV Grid.
    so I add my structure in the data declarations
    types:  begin of s_elements,
       pernr  type  p0002-pernr,
       ename  type p0001-ename,
       sprsl  type p0002-sprsl,
       gbdat   type p0002-gbdat.
      drop_down_handle  type int4.
    types: end of    s_elements.
    include zz_jimbo_incl.
    build the dynamic table
    create data dref type s_elements.
      assign dref->* to <fs>.
      i_routine = 'POPULATE_DYNAMIC_ITAB'.*
    i_names   = 'NAME_COLUMNS'.
      i_gridtitle = 'HR  TEST'.
    invoker = sy-repid.
    i_zebra = 'X '.
    i_edit = '  '.
    call function 'ZZ_CALL_SCREEN'
         exporting
              invoker     = invoker
              my_line     = <fs>
              i_gridtitle = i_gridtitle
              i_edit      = i_edit
              i_zebra     = i_zebra
              i_names     = i_names
              i_routine   = i_routine
         importing
              z_object    = z_object
              dy_table    = dy_table.
    Now to populate the dynamic Itab the routine below is entered.
    form populate_dynamic_itab changing dy_table.
      assign dy_table->* to <dyn_table>.
      create data dy_line like line of <dyn_table>.
      assign dy_line->* to <dyn_wa>.
    However I can't use GET / PROVIDE / ENDPROVIDE in a Form.
    Anyway round this ---seems HR has an aversion to OO.
    Cheers
    jimbo

    Hi,
    well, GET_PERNR is a so called event_statement. It has nothing to do with ABAP 00.
    Normally it will be like this:
    START-OF-SELECTION.
    GET_PERNR.
    PROVIDE ....
    END-OF-SELECTION.
    -> and here the CALL SCREEN NNNN for ALV-Display.
    Provide-statements you can use in forms of course, and as many times you want during GET and END-OF-SELECTION.
    But as I understood : you just want to save the write-statements?
    I always develop a DDIC-Structure, declarate the data objects in the programm, read the data via Provide into the infotypes, and then make a move-corresponding to my structure. and display it.
    Normally no problem.
    kind regards
    maik

  • What are structures of logical database.

    hi
    what are structures of logical database.

    Dear Chaitanya,
    The structure of LDB can be divided into three sections:
    >Structure
    >Selection
    >Database Program
    STRUCTURE:
    The structure defines the data view of the logical database. It adopts the hierarchy of the database tables defined by their foreign key relationships. This also controls the sequence in which the tables are accessed. It determines the structure of the other components and the behavior of the logical database at runtime.
    The structure of a logical database is usually based on the foreign key relationships between hierarchical tables in the SAP System. Logical databases have a tree-like structure, which can be defined as follows:
    · There is a single node at the highest level. This is known as the root node.
    · Each node can have one or several branches.
    · Each node is derived from one other node.
    The nodes must be structures defined in the ABAP Dictionary or data types from a type group. Normally, these are the structures of database tables which the logical database reads and passes to the user for further evaluation. However, it is also possible, and sometimes useful, to use ABAP Dictionary structures without an underlying database. For technical reasons, the maximum number of nodes allowed in the structure of a logical database is 300.
    Any executable ABAP program that has a logical database linked to it can contain a GET statement for each node of the structure. When you run the program, the corresponding event blocks are processed in the sequence prescribed by the hierarchical structure of the logical database. If a program does not contain a GET statement for every node of a logical database, the processing passes through all the nodes that lie in the path from the root to the nodes specified by GET statements.
    If you call a logical database using the function module LDB_PROCESS, the depth to which the system reads is controlled by an interface parameter.
    SELECTIONS:
    The selections define a selection screen, which forms the user interface of the executable programs that use the logical database. Its layout is usually determined by the structure. You can adapt the selections to your own requirements and also add new ones. When you link a logical database to an executable program, the selections of the logical database become part of the standard selection screen of the program (screen number 1000). If you call a logical database using the function module LDB_PROCESS, the selections are filled using interface parameters.
    The selections in a logical database are defined using the normal statements for defining selection screens, that is, PARAMETERS, SELECT-OPTIONS and SELECTION-SCREEN. In a logical database, you can also use the additions VALUE-REQUEST and HELP-REQUEST to define specific input and value help. You define the selection screen in a special include program known as the selection include.
    When you write programs using a logical database, you can also add your own program specific selections. The standard selection screen then contains the database-specific selections, followed by the program-specific selections that you have defined.
    When the system generates the selection screen for an executable program, database-specific selection criteria and parameters are only displayed if you have declared an interface work area for them in your program using the NODES or TABLES statement.
    Suppose you have a selection include containing the following lines:
    SELECT-OPTIONS slifnr FOR lfa1-lifnr.
    PARAMETERS pbukrs LIKE lfb1-bukrs FOR TABLE lfb1.
    The selection criterion SLIFNR is linked to table LFA1, the parameter PBUKRS to table LFB1. If the TABLES statement in an executable program (report) declares LFA1 but not LFB1, SLIFNR is displayed on the selection screen, but PBUKRS does not appear.
    The selection screen of a logical database can contain dynamic selections as well as static ones. Dynamic selections are extra, user-defined selections that the user can make as well as using the static selections defined in the selection include. To improve performance, you should always use this option instead of reading more data than you need and then sorting it out in the application program.
    To make dynamic selections available for the node nodeof a logical database, the selection include must contain the following statement:
    SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE|TABLE node.
    If the node node is requested by the user of the logical databases, the dynamic selections are included in the selection screen. A user can then choose Dynamic selections to enter extra selections for the corresponding fields. If you call the logical database using the function module LDB_PROCESS, you can pass a corresponding parameter. You can use these selections in dynamic statements in the logical database program to read data. The values of the program-specific selection criteria that you defined for a node for which dynamic selections were available are also passed to the logical database. The user can also define the fields for dynamic selections as a selection view for the logical database.
    The selection screen of a logical database is part of the standard selection screen (number 1000) of the executable program to which the logical database is attached. It has a standardized layout - the selection criteria and parameters appear on separate lines in the order in which they were declared. You can change the layout using the SELECTION-SCREENstatement.
    The runtime environment generates the selection screen with number 1000 for every program in which the attributes do not contain a different selection screen version. You can prevent certain input fields from the selection screen of a logical database from appearing on the selection screen by defining selection screen versions with a screen number lower than 1000 in the selection include, and entering this version number in the program attributes. By pressing F4 there, you can get an overview of the selection screen versions defined in the logical database concerned. To define a selection screen version, use the statements SELECTION-SCREEN BEGIN|END OF VERSION. Within these statements you can use SELECTION-SCREEN EXCLUDEto specify fields that you do not want to appear on the selection screen.
    If the attributes of an executable program contain the number of a selection screen version, the version is used in the standard selection screen. Although the input fields that you excluded from the selection screen are not displayed, the corresponding selections still exist, and you can still edit them in the program or by calling the function module LDB_PROCESS.
    DATABASE PROGRAM:
    The database program contains the ABAP statements used to read the data and pass it to the user of the logical database. There is a container for special subroutines into which, amongst other things, the data from the database tables is read. These subroutines are called by the reporting processor in the runtime environment in a sequence that has been predefined by the structure. The database program is determined by the structure and selections and can be adapted or expanded to meet your requirements.
    The name of the database program of a logical database ldbconforms to the naming convention SAPDBldb. It serves as a container for subroutines, which the ABAP runtime environment calls when a logical database is processed. The sequence of the calls and their interaction with the events in executable programs or the function module LDB_PROCESS depends on the structure of the logical database.
    A logical database program usually contains the following subroutines:
    · FORM LDB_PROCESS_INIT
    Called once only before the logical database is processed. It prepares it to be called more than once by the function module LDB_PROCESS.
    · FORM INIT
    Called once only before the selection screen is processed.
    · FORM PBO
    Called before the selection screen is displayed, each time it is displayed. Consequently, it is only called when you use the logical database with an executable program, not with the function module LDB_PROCESS.
    · FORM PAI
    Called when the user interacts with the selection screen. Consequently, it is only called when you use the logical database with an executable program, not with the function module LDB_PROCESS. The interface parameters FNAME and MARK are passed to the subroutine.
    FNAME contains the name of a selection criterion or parameter on the selection screen.
    MARK describes the selection made by the user: MARK = space means that the user has entered a simple single value or range selection. MARK = '*' means that the user has also made entries on the Multiple Selection screen.
    · FORM LDB_PROCESS_CHECK_SELECTIONS
    Called instead of the subroutine PAI if the logical database is called using the function module LDB_PROCESS without a selection screen. This subroutine can check the selections passed in the function module interface.
    · FORM PUT_node
    Called in the sequence defined in the structure. Reads the data from the node nodeand uses the
    PUT node.
    statement to trigger a corresponding GETevent in the ABAP runtime environment. The PUT statement is the central statement in this subroutine: It can only be used within a subroutine of a logical database. The logical database must contain the node node, and the subroutine name must begin with PUT_node. The PUT statement directs the program flow according to the structure of the logical database. The depth to which the logical database is read is determined by the GET statements in the application program or the interface parameter CALLBACK of the function module LDB_PROCESS.
    First, the subroutine PUT_root is executed for the root node. The PUT statement then directs the program flow as follows:
    i. If the database program contains the subroutine AUTHORITY_CHECK_node, the first thing the PUT_node statement does is to call it.
    ii. Next, the PUT statement triggers a GET event in the runtime environment. If there is a corresponding GET nodestatement in the executable program to which the logical database is linked, the associated event block is processed. If the CALLBACK parameter of the function module LDB_PROCESS is filled accordingly, the corresponding callback routine is called.
    iii. The PUT statement directs the program flow
    (a) To the next subroutine of a node that follows directly, if a lower-level node (not necessarily the very next) in the same subtree is requested by GET in the executable program or in the function module.
    (b) To the subroutine of a node at the same level, if the preceding node branches to such a node and if a GET statement exists for such a node in the executable program or the function module.
    The PUT statement in that subroutine starts again at step (i). In the subroutine of the lowest node in a subtree to be processed using GET, the program control does not branch further. Instead, the current subroutine is processed further. When a subroutine PUT_node has been executed in its entirety, the program flow returns to the PUTstatement from which it branched to the subroutine PUT_node.
    iv. When control has returned from a lower-level subroutine PUT_node, the PUTstatement triggers the event GET node LATEin the runtime environment.
    · FORM AUTHORITY_CHECK_node
    Called automatically by the PUT node statement. In this subroutine, you can specify authorization checks for the appropriate node node from the structure of the logical database.
    · FORM PUT_ldb_SP
    Called when the user makes a selection using a search help to process the key chosen in the search help. ldb is the name of the logical database. From this subroutine, you can use the entries in the search help tables to read the relevant entries from the root node root. The processing in the program can then be triggered using PUT root. The subroutine PUT_root is then not called automatically.
    · FORM BEFORE_EVENT
    Called before an event, the name of which is passed in the parameter EVENT. Currently, the EVENT field can only contain the value START-OF-SELECTION, to call a subroutine before this event.
    · FORM AFTER_EVENT
    Called after an event, the name of which is passed in the parameter EVENT. Currently, the EVENT field can only contain the value END-OF-SELECTION, to call a subroutine after this event.
    · FORM par_VAL, selop_VAL, selop-LOW_VAL, selop-HIGH_VAL
    Called when the user calls possible values help for the parameter par or the selection criterion selop. These must belong to the selections in the logical database.
    · FORM par_HLP, selop_HLP, selop-LOW_HLP, selop-HIGH_HLP
    Called when the user calls possible values help for the parameter par or the selection criterion selop. These must belong to the selections in the logical database.
    Example
    Suppose that in the logical database structure, LFB1 is a branch of LFA1.
    and that the following selection criteria are defined in the selection include:
    SELECT-OPTIONS: slifnr FOR lfa1-lifnr,
    sbukrs FOR lfb1-bukrs.
    A section of the database program would then read:
    FORM put_lfa1.
    SELECT * FROM lfa1
    WHERE lifnr IN slifnr.
    PUT lfa1.
    ENDSELECT.
    ENDFORM.
    FORM put_lfb1.
    SELECT * FROM lfb1
    WHERE lifnr = lfa1-lifnr.
    AND bukrs IN sbukrs.
    PUT lfb1.
    ENDSELECT.
    ENDFORM.
    An executable program (report) linked to the logical database could contain the lines:
    GET lfa1.
    WRITE lfa1-lifnr.
    GET lfb1.
    WRITE lfb1-bukrs.
    In this example, the runtime environment calls the routine put_lfa1 after the event START-OF-SELECTION. The event GET lfa1 is triggered by the statement PUT lfa1.
    Once the corresponding event block in the program is complete, PUT lfa1 branches to the subroutine put_lfb1.
    From this subroutine, the event GET lfb1 is triggered in the application program. If LFB1 is the last node to be read, processing resumes with the SELECTloop in put_lfb1. Otherwise, the program flow moves to the subroutine put_node of the next node. At the end of the SELECT loop of the last node, processing resumes in the SELECTloop of the node at the next level up. The example of programming using nested SELECT loops is only used to make the program flow clearer. In a real logical database, you would avoid doing this in order to minimize the number of database accesses.
    Regards,
    Rajesh K Soman
    Please reward points if helpful.

  • HR Logical Database

    Hi,
      Is it common to use logical database for HR report??  How about other module such as SD/MM??
    Regards,
    Kit

    Hi,
    Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.
    However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.
    Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.
    Logical Databases - Views of Data
    A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.
    The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.
    The diagram illustrates how the R/3 System might represent the structure of a company. A logical database can read the lines of these tables one after the other into an executable program in a sequence which is normally defined by the hierarchical structure. The term logical database is sometimes used to mean not only the program itself, but also the data that it can procure.
    Tasks of Logical Databases
    As well as allowing you to read data from the database, logical databases also allow you to program other tasks centrally, making your application programs less complicated. They can be used for the following tasks:
    Reading the same data for several programs.
    The individual programs do not then need to know the exact structure of the relevant database tables (and especially not their foreign key relationships). Instead, they can rely on the logical database to read the database entries in the right order during the GET event.
    Defining the same user interface for several programs.
    Logical databases have a built-in selection screen. Therefore, all of the programs that use the logical database have the same user interface.
    Central authorization checks
    Authorization checks for central and sensitive data can be programmed centrally in the database to prevent them from being bypassed by simple application programs.
    Improving performance
    If you want to improve response times, logical databases permit you to take a number of measures to achieve this (for example, using joins instead of nested SELECT statements). These become immediately effective in all of the application programs concerned and save you from having to modify their source code
    Reward Points if useful
    Raghunath.S
    9986076729

  • Idea about Logical DataBase

    Hi,
    <u>Can, programming with LDB, be considered as an object programming.. just VB, which is an object programming language.</u>
    That is we r creating an Object directly and using when ever we want. It is different from OOP where we create a class and instantiate the class to create an object.
    My next question is:
    There are 2 transactions which we will create, which are basically same except for a text field.
    <i>First transaction is posting. And the second one is a reverse posting. In the second transaction we have the reason for reverse posting.</i>
    I think in this case we can use LDB and it is the typical scenario where we can apply LDB concept.
    Please evaluate me.
    -Naveen.

    <b>Hi NaveenKumar,</b>
           Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is  to read data from database tables by linking them to executable ABAP programs.
           However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this.
           Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.
    <b>Tasks of Logical Databases</b>
    1.Reading the same data for several programs.
    2.Defining the same user interface for several programs.
    3.Central authorization checks
    4.Improving performance
    <b>First part of your question</b>
    <b>
         So,if i am not wrong, LDB cannot be completely considered as object oriented programmming.</b>
         I have highlighted some important points above
    For understanding this in detail you can go through the sap help .(if you donot know go through the below path
    sap library
      + Basis Components
          -Abap Programing and runtime enviornment
               -BC-ABAP Programming(noe serach for ldb 
    <b>Now your second part of question</b>.
         In the scenario which you have mentioned we can use ldb.But i am not sure whether it is a typical scenario of ldb.LDB is just a specific access routine to support database access for some application (report generation) needs.We can define a logical database to shorten our ABAP coding .
         Here I am mentioning a link which shows a complete implementation of an LDB.
    <b>http://homepages.wmich.edu/~r2raviko/HandsOnQuest/HO9.doc</b>
         I suppose after going through the  reply(or sap help) and the link mentioned above all your doubts regarding LDB will be cleared.   
    Thanks & Regards
    <b>Pawan P. Khilari
    *Please Mark Helpful Answer</b>

  • How to execute the logical database.

    how to execute the logical database.

    There are two ways of using a logical database - either by linking it with the executable program(specify the LDB name in the program attributes) or by using the function module LDB_PROCESS.
    1.Data read by the logical database is passed back to the program using the interface work areas.Use GET statements in the report.
    GET events are implemented internally as FORM routines.
    2.If you call the logical database using the above function module, the selection screen of LDB is not displayed.It uses special subroutines called callback routines, which are called by the function module and filled with the required data.
    Please refer the following link for more details.
    http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm

  • Selection part of Logical Database

    I read about logical database somewhere on the net but it was not so clear. Can anyone explain to me about the selection part of the logical database???

    Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables and linking them to executable ABAP programs while setting the program contents. You edit logical databases using the Logical Database Builder in the ABAP Workbench.
    However, since Release 4.5A, it has also been possible to call logical databases independently of this tool using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for executable programs, allowing them to use more than one logical database and process a database more than once.
    Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm
    A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables.
    GO THROUGH LINKS -
    http://www.sap-basis-abap.com/saptab.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
    /people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
    Re: **LDB**
    www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html
    www.sap-img.com/abap/abap-interview-question.htm
    www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm
    Logical databases are SAP standard programs that are desinged with selections screens that helps easy retrival and access of data from various tables in and efficient manner.
    You can get to know more about the logical databases from the SAP documentation or the following links.
    A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables.
    Advantages of Logical database -
    1) No need of programming for retrieval , meaning for data selection
    2) Easy to use standard user interface, have check completeness of user input.
    Disadvantages
    1) Fast in case of lesser no. of tables But if the table is in the lowest level of hierarchy, all upper level tables should be read so performance is slower.
    GO THROUGH LINKS -
    http://www.sap-basis-abap.com/saptab.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
    1. A logical database is in fact
    a program only.
    2. This LDB provides two main things :
    a) a pre-defined selection screen
    which handles all user inputs and validations
    b) pre defined set of data
    based upon the user selection.
    3. So we dont have to worry about from
    which tables to fetch data.
    4. Moreover, this LDB Program,
    handles all user-authorisations
    and is efficient in all respects.
    5. tcode is SLDB
    good info about Logical Database. you can check the link.
    http://www.geekinterview.com/question_details/1506
    http://help.sap.com/saphelp_46c/helpdata/EN/35/2cd77bd7705394e10000009b387c12/frameset.htm
    Re: How to Create and Use ldb in reports?
    Re: Logical databases
    http://help.sap.com/saphelp_46c/helpdata/en/9f/db9bed35c111d1829f0000e829fbfe/frameset.htm
    Functions for displaying and changing logical databases:
    Call Transaction SE36 or
    Choose ABAP Workbench -> Development -> Programming environ. -> Logical databases
    Interaction between database program and report:
    During program processing, subroutines are performed in the database program and events are executed in the report.
    To read data from a database tables we use logical database.
    A logical database provides read-only access to a group of related tables to an ABAP/4 program.
    advantages:-
    The programmer need not worry about the primary key for each table.Because Logical database knows how the different tables relate to each other,and can issue the SELECT command with proper where clause to retrieve the data.
    i)An easy-to-use standard user interface.
    ii)check functions which check that user input is complete,correct,and plausible.
    iii)meaningful data selection.
    iv)central authorization checks for database accesses.
    v)good read access performance while retaining the hierarchical data view determined by the application logic.
    disadvantages:-
    i)If you donot specify a logical database in the program attributes,the GET events never occur.
    ii)There is no ENDGET command,so the code block associated with an event ends with the next event
    statement (such as another GET or an END-OF-SELECTION).
    1. transaction code SLDB.
    2.enter name z<ldb-name>
    3.create
    4.short text
    5.create
    6. name of root node (here Ekko)
    7. enter short text (f6)
    8.node type -> data base table.
    9.create
    10 change logical DB
    riht click on ekko and insert node
    here node name ekpo
    11.create
    12. click on selections
    13. press no Should the changed structure of Z<ldb name> be saved first.
    14.select tables which you want to join.
    15.transfer
    16 now you have to o to coding part.
    17. save
    activate.
    19.click to src code
    double click on first include and activate
    Regards
    Vasu

Maybe you are looking for