LDB Sorting..

Hi Gurus
   Can we sort the LDB data in program ? If yes, then How ?
Quick help is appreciated.
Regards,
Gajanan

Hi,
The data is not stored in the internal table, it is a standard pgm and they are writing in Loop.  Endloop.  without an internal table.
The LDB is not related to HR it is Check printing PYF. and i don't want the sort on the primary key...i want the sort on some other field in the table which is retrieved
in the LDB..
Srini

Similar Messages

  • LDB-Sort

    Hello All,
    After a long long time i am working on 3.1I and am using a LDB - BRF.
    In my code i am using
    GET BKPF Fields
    BUKRS
    BELNR
    GJAHR.
    (at this step - can i SORT the BKPF data by BUKRS BELNR? before i go to BSEG)
    and then use
    GET BSEG FIELDS
    X
    Y
    Z.
    Please let me know the syntax.
    Regards,
    - PSK

    Hello,
    seems to be difficult, what this 'Get'-statment does.
    At the GET statment you don't read the Table BKPF, but it is the event,when you get one (only one !) entry of table BKPF.
    Since the fields BUKRS,BELNR,GJAHR are the primary keys of that table, a sort does not make sense.
    At 'GET BSEG' you get the first position, then the next and so on to that BKPF entry.
    Could be usefull to try this logic:
    GET BKPF.
    Write: / BKPF-BUKRS, BKPF-BELNR, BKPF-GJAHR.
    GET BSEG.
    WRite: / BSEG-BUKRS, BSEG-BELNR, BSEG-GJAHR, BSEG-BUZEI.
    And test it with a selection of ten FI-documents.
    If you wish to sort in your program, you would use the old extract-logic. Look to the commands FIELD-GROUPS and EXTRACT.
    Regards,
    Wolfgang

  • PNP LDB Sort Order Customization

    Hi all,
    I need to add a custom field to the list of "Sort Order" fields available on PNP LDB Selection screen. Any idea how can we achieve this??

    Hi Markus,
    No, the Sort Order has not been removed in  PNPCE.. which report are you using? If it is tied to the Report Category PNPCE, the Sort Order icon is displayed 4th from the left on the tool bar.. You can alos use the CTRL + F1 keys option.
    Regards,
    Suresh Datti

  • Want to have own selection screen  in HR-ABAP report using LDB

    Hi experts,
            I am working on HR-ABAP report using LDB pnp and infotypes..But, here we get the built in selection criterion..but I want my own selection screen to be displayed..whats the solution for this??? Is it possible to create my own selection screen instead of default one..and how???
    Please help me..its very urgent..

    Hi,
    chk this out:
    Create Report Categories                                                                               
    In this step, you define the report categories and determine the layout
       of the standard selection screen for these report categories. You can 
       create report categories for programs or queries that are based on the
       PNP or PNPCE logical databases.                                                                               
    The definition of report categories is divided into two sections:                                                                               
    o   In the Change Report Category view, you define general attributes 
           such as sort order, input fields for date, and so on.                                                                               
    o   In the Change Selection Criteria view, you define which selection 
           fields of the logical database should be avaliable on the selection
           screen.                                                                               
    Example                                                                               
    You want to set up your system so that your employees can only start  
       evaluation reports for Payroll if they use a payroll area. Within a   
       payroll area, you should be able to select according to personnel     
       number. Additional selection criteria should not be possible and you  
       should not be allowed to enter a sort sequence.                       
    Standard settings                                                                               
    The standard system already contains report categories. You can find the 
    attributes of the report categories in the table.                                                                               
    Note the following five report categories in particular:                                                                               
    o   Report category ' ' is the SAP default report category for     
        programs that are based on the PNP logical database.                                                                               
    o   Report category PNPCE is the SAP default category for programs that  
        are based on the PNPCE logical database.                                                                               
    o   Report category '00000000' is the customer-specific default category 
        for programs that are based on the PNP logical database.                                                                               
    o   Report category '0PNPCE' is the customer-specific default category   
        for programs that are based on the PNPCE logical database.                                                                               
    o   Report category __X2001 is the default category for Queries  that    
        are based on an InfoSet of the PNP LDB.                                                                               
    o   Report category QUEPNPCE is the default category for queries that    
        are based on an InfoSet of the PNPCE LDB.                                                                               
    The default report categories are used when a report is called if    
        the report has not been assigned a report category.                  
    Parameters and Options for Report Categories of the LDB PNP and PNPCE  
    Parameters and Options in Screen Area General Data                     
       If you activate this parameter, you can only enter data on the data
       selection period if you use reports that have been assigned. The   
       same date entries are then used for the person selection as for the
       date selection.                                                                               
    o   Matchcode allowed                                                  
       If you activate this parameter, you have use of a Matchcode        
       pushbutton (search help) if you use reports that have been assigned.
       This pushbutton enables you to perform the person selection.                                                                               
    o   Sort allowed                                                       
       If you activate this parameter, you have use of a Sort pushbutton if
       you use report that have been assigned. This pushbutton enables you
       to define a sort order before you execute the report.                                                                               
    o   Organizational structure allowed                                   
       If you activate this parameter, you have use of an Org.Structure   
       pushbutton if you use reports that have been assigned. This        
       pushbutton enables you to perform the person selection.            
       Note:                                                              
       For more information about these options, see the online           
       documentation under this path:                                     
       SAP Library -> Human Resources -> Reporting in Human Resources     
       Management -> Standard HR Reports -> Report Selection Screen in    
       Human Resources Management.                                                                               
    Parameters and Options in Screen Areas Data Selection Period/Person    
    Selection Period/Payroll Area/Period/Year                                                                               
    o   Options for data selection period and person selection period (key 
        date and so on)                                                    
        Here you define which options for date and person selection are    
        available for reports that have been assigned.                                                                               
    o   Options for payroll area/period/year                               
        Here you define which options for selection using payroll          
        area/period/year are available for reports that have been assigned.                                                                               
    Parameters and Options in Screen Area Selection View                                                                               
    o   Type/Name                                                          
        This parameter enables you to use selection views to define report 
        categories. You use the selection view selected here to determine  
        which fields are available in the Dynamic Selectionsy.                                                                               
    Note:                                                              
        You create selection views for the PNP and PNPCE logical databases 
        in the Object Navigator (SE80):                                    
        1. Start the Object Navigator (SE80)                               
        2. Choose Workbench -> Edit Object.                                
        3. Choose the More... tab page and the Selection view on this tab  
        page.                                                              
        4. Choose Create.                                                  
        5. In the Create Selection View dialog box, choose the For any     
        tables option.                                                     
        6. In the Name of view field, enter a name for your selection view.
        7. In the Tables dialog box, enter the name of the table from which
        you want to use fields.                                            
        Note:                                                              
        When you enter the table name, observe the naming convention in    
        Personnel Administration:                                          
        Infotype number: nnnn -> table name: PAnnnn                        
        8. Choose Continue.                                                
        9. In the Functional groups area, define functional groups by      
        assigning a name and a number.                                     
        10. Assign fields from the selected tables to the functional groups
        by entering the number of the desired functional group in front of 
        each field.                                                        
        11. Save your entries.                                                                               
    For more information about adjusting the dynamic selections using 
    your own selection views, see the online documentation under the  
    following menu path:                                              
    SAP Library -> Human Resources -> Reporting in Human Resources    
    Management -> HR Standard Reports -> Report Selection Screen in   
    Human Resources Management -> Enhancing the Selection Screen -    
    Dynamic Selections.                                                                               
    If you do not want to offer dynamic selections, make the following
    settings:                                                                               
    -   LDB PNP: In the Selection view field, enter PNP_NO_FREE_SEL.  
    -   LDB PNPCE: Leave the Selection view field empty.                                                                               
    Parameters and Options in Screen Area Data Selection Period/Person   
    Selection Period/Payroll Area/Period/Year                                                                               
    o   Available input parameters, date or period entry (today, key date,
       all, and so on), and standard value.                             
       Using the Standard value option, you define which of the selected
       options is shown.                                                                               
    Parameters and Options in Screen Area CE Selection Fields                                                                               
    o   CE selection fields (external person ID, grouping reason, grouping
       value)                                                           
       Using the options in this area, you define whether the external  
       person Id, grouping reason, or grouping value are available on the
       selection screen.                                                
       Note:                                                            
       These parameters are only relevant for you if you implement      
       Concurrent Employment (see also note 517071).                                                                               
    Parameters and Options in Screen Area Selection view                                                                               
    o   Dynamic selections as dialog box                                  
        If this switch is set, you can call the dynamic selections as a   
        dialog box.                                                                               
    o   Dynamic selections active                                         
        If this switch is set, the dynamic selections of the logical      
        database are active at the start of the report.                                                                               
    Note that the following combinations are possible for the last two
        options mentioned:                                                                               
    Dyn.Sel. as dialog box/Dyn.Sel. active: inactive/inactive         
        Dyn.Sel. as dialog box/Dyn.Sel. active: inactive/active           
        Dyn.Sel. as dialog box/Dyn.Sel. active: active/inactive                                                                               
    Activities                                                                               
    1.  Choose Edit -> New entries.                                                                               
    2.  Enter an abbreviation and a long text for the report category.         
        The customer name range for report categories is 0-9.                                                                               
    3.  Select the For the PNPCE logical database checkbox, if you want to     
        create a report category for a program or for queries of the PNPCE     
        logical database.                                                                               
    4.  In the General Data screen area, choose the desired options.           
        If you want to use selection IDs, you must have first created and      
        grouped selection Ids. The IMG path to do this is given in the         
        parameter description section.                                                                               
    5.  In the Data selection period/person selection period or Selection      
        period screen area, choose the desired options.                                                                               
    6.  In the Selection view screen area, choose the desired options.                                                                               
    7.  In the CE selection fields screen area, choose the desired (only       
        possible for report categories of the LDB PNPCE).                                                                               
    8.  Save your entries.                                                                               
    9.  Choose the subactivity Permitted selection criteria.                                                                               
    10. Choose Edit -> New entries.                                                                               
    11. In the Select option field, use the input help to select each field    
        that should be available on the selection screen.                                                                               
    12. Select the checkbox in the 1.page column, if you want this selection   
        field to be available directly when you call the selection screen.                                                                               
    Further notes                                                                               
    13. If you want to copy entries, you still have to enter the selection     
        parameters again in the subsequent screen.                                                                               
    o   If you create the report category '000000000', a selection screen is   
        generated according to report category '00000000'for all reports for   
        which a report category has not explicitly been assigned.                                                                               
    Assign Report Categories                                                                               
    In this step, you assign a report category to your reports.                                                                               
    Example                                                                               
    You have created your own report, for example ZPCTEST1, and would like
        it to have the selection screen that corresponds to that of the       
        evaluation report for Payroll, which is assigned to report category   
        '__M00001'.                                                           
        Assign report category '__M00001' to the report.                                                                               
    Requirements                                                                               
    You must have defined the Report Categories.                                                                               
    Standard settings                                                                               
    SAP Standard Reports:                                                                               
    In the standard system, reports are assigned a report category. If you
        want to override these assignments, perform the activities described  
        here. If you want to assign report categories to standard reports using
        SE38, this represents a modification.                                                                               
    Customer-Specific Reports:                                                                               
    For reports you have developed yourself, you can either assign report 
        categories by performing the activities described here or directly in SE38.
    Recommendation                                                                               
    Only assign a report category if you have created your own reports or if  
    the selection screens in the standard system do not meet your             
    requirements.                                                                               
    Activities                                                                               
    1.  Choose Edit -> New entries.                                                                               
    2.  Perform the required assignment using the Program name and Report     
       category fields.                                                                               
    3.  Save your entries.                   
    reward if helpful
    regards,
    madhumitha

  • LDB   in abap hr

    Hi,
        I am new to Abap Hr.Can anyone plz provide me with a sample program for a logical database.
    Regards,
    Subha

    Hi
    See the sample report using PNP LDB
    LDB is attached in the attributes of the program
    report zporgr0100
           line-size 252
           line-count 60(1)
           no standard page heading
           message-id zx.
    Database Tables & Infotypes
    tables: pcl1,        " HR Cluster1
            pcl2,        " HR Cluster1
            pa0003,      " Master data - Payroll Status
            cskt,        " Cost Center Texts
            t528t,       " Positions Texts
            t513s,       " Job Titles
            pernr,       " Logical PNP
            t001p,       " Personnel Subarea
            t500p,       " Personnel Area
            t501,        " Employee Group
            t503k,       " Employee Subgroup
            csks.        " Cost Center
    infotypes:0000,0001.
    *include rpclst00.
    include rpc2rx00.
    include rpc2rxx0.
    include rpc2cd00.
    *include rpc2ps00.
    *include rpc2pt00.
    *include rpcfvp00.
    *include rpcfdc10.
    *include rpcfdc00.
    include rpppxd00.
    include rpppxd10.
    Declaration of Internal Tables
    Internal Table for Output Data
    data: begin of rep_tab occurs 0,
            kostl like pa0001-kostl,      " Cost Center
            pernr like pa0001-pernr,      " Personal Number
            ename like pa0001-ename,      " Employee Name
            ctext like cskt-ltext,        " Cost Center Text
            ptext like t528t-plstx,       " Position Text
            ot1   type p decimals 2,      " Jan OT Amount
            ot2   type p decimals 2,      " Feb OT Amount
            ot3   type p decimals 2,      " Mar OT Amount
            ot4   type p decimals 2,      " Apr OT Amount
            ot5   type p decimals 2,      " May OT Amount
            ot6   type p decimals 2,      " Jun OT Amount
            ot7   type p decimals 2,      " Jul OT Amount
            ot8   type p decimals 2,      " Aug OT Amount
            ot9   type p decimals 2,      " Sep OT Amount
            ot10  type p decimals 2,      " Oct OT Amount
            ot11  type p decimals 2,      " Nov OT Amount
            ot12  type p decimals 2,      " Dec OT Amount
            ott   type p decimals 2,      " Total OT Amount
          end of rep_tab.
    Declaration of Variables
    data: v_mon(2) type n,                   " Month
          v_no     type i,                   " Data Lines
          v_year(4)  type c,                 " Year
          v_date   like sy-datum,            " Date
          v_date1  like sy-datum,            " Date
          v_seqnr  like  pc261-seqnr.        " Sequence No.
    Declaration of Constants
    data: c_type   like hrp1001-otype  value 'S',  " Object Type
          c_kokrs  like cskt-kokrs value '1000',   " Controlling Area
          c_date1  like sy-datum value '18000101', " Date
          c_date2  like sy-datum value '99991231', " Date
          c_x       type c value 'X',              " Sign
         c_mon(2)  type c value '01',             " Month
          c_val1(2) type c value '31',             " Date
          c_val2(2) type c value '12',             " Month Type
          c_val    like p0041-dar01 value '01',    " Date Type
          c_lgart1 like p0008-lga01 value '0722',  " Wage Type
          c_lgart2 like p0008-lga01 value '0723',  " Wage Type
          c_1(2)   type n value '01',                           " Month1
          c_2(2)   type n value '02',                           " Month2
          c_3(2)   type n value '03',                           " Month3
          c_4(2)   type n value '04',                           " Month4
          c_5(2)   type n value '05',                           " Month5
          c_6(2)   type n value '06',                           " Month6
          c_7(2)   type n value '07',                           " Month7
          c_8(2)   type n value '08',                           " Month8
          c_9(2)   type n value '09',                           " Month9
          c_10(2)  type n value '10',                           " Month10
          c_11(2)  type n value '11',                           " Month11
          c_12(2)  type n value '12'.                           " Month12
    Selection-screen
    parameters:
      p_year like pc2b0-pabrj obligatory.       " Payroll Year
    At selection-screen
    at selection-screen.
    Validate the Selection Screen fields
      perform validate_screen.
    Start-of-Selection
    start-of-selection.
    Selection of Period
      perform get_period.
    Get PERNR from LDB
    get pernr.
    Get the Master data from infotype 0001
      perform get_master_data.
    Top-of-page
    top-of-page.
    Write the Report and Column Headings
      perform top_of_page.
    End-of-Page
    end-of-page.
      write /1(252) sy-uline.
    End-of-Selection
    end-of-selection.
    Display the Output Report.
      perform display_report.
    Form-Routines
    *&      Form  validate_screen
    Validation of selection Screen fields
    form validate_screen.
    Validation of Cost Center
      clear csks.
      if not pnpkostl[] is initial.
        select single kostl
          into csks-kostl
          from csks
          where kostl in pnpkostl.
        if sy-subrc <> 0.
          message e999 with 'Invalid Cost Center'(003).
        endif.
      endif.
    Validation of Personnel Number
      clear pa0003.
      if not pnppernr[] is initial.
        select pernr
        from pa0003 up to 1 rows
          into pa0003-pernr
          where pernr in pnppernr.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Personal Number Entered'(002).
        endif.
      endif.
    Validation of Personnel Area
      clear t500p.
      if not pnpwerks[] is initial.
        select persa
        from t500p up to 1 rows
          into t500p-persa
          where persa in pnpwerks.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Personnel Area Entered'(001).
        endif.
      endif.
    Validation of Personnel Sub Area
      clear t001p.
      if not pnpbtrtl[] is initial.
        select btrtl
        from t001p up to 1 rows
          into t001p-btrtl
          where btrtl in pnpbtrtl.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Personnel Sub Area Entered'(037).
        endif.
      endif.
    Validation of Employee Group
      clear t501.
      if not pnppersg[] is initial.
        select persg
        from t501 up to 1 rows
          into t501-persg
          where persg in pnppersg.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Employee Group Entered'(038).
        endif.
      endif.
    Validation of Employee Sub Group
      clear t503k.
      if not pnppersk[] is initial.
        select persk
        from t503k up to 1 rows
          into t503k-persk
          where persk in pnppersk.
        endselect.
        if sy-subrc <> 0.
          message e999 with 'Incorrect Employee Sub Group Entered'(039).
        endif.
      endif.
    endform.                  "validate_screen
    *&      Form  get_period
    Get the Correct Period based on Selection screen selection
    form get_period.
      clear: v_year,v_mon, v_date, v_date1.
      v_year = sy-datum+0(4).
      v_mon  = sy-datum+4(2).
      if pnptimr1 = c_x.      " Current Date
        pnpbegda = sy-datum.
        pnpendda = sy-datum.
      elseif pnptimr2 = c_x.  " Current Month
        concatenate v_year v_mon c_val into v_date.
        concatenate v_year v_mon c_val1 into v_date1.
        pnpbegda = v_date.
        pnpendda = v_date1.
      elseif pnptimr3 = c_x.  " Current Year
        concatenate v_year c_val c_val into v_date.
        concatenate v_year c_val2 c_val1 into v_date1.
        pnpbegda = v_date.
        pnpendda = v_date1.
      elseif pnptimr4 = c_x.  " Upto Today
        pnpbegda = c_date1.
        pnpendda = sy-datum.
      elseif pnptimr5 = c_x.  " From Today
        pnpbegda = sy-datum.
        pnpendda = c_date2.
      else.
        if ( pnpbegda is initial and pnpendda is initial ).
          pnpbegda = c_date1.
          pnpendda = c_date2.
        elseif pnpbegda is initial and not pnpendda is initial.
          pnpbegda = c_date1.
          pnpendda = pnpendda.
        elseif not ( pnpbegda is initial and pnpendda is initial ).
          pnpbegda = pnpbegda.
          pnpendda = pnpendda.
        endif.
      endif.
    endform.              "get_period
    *&      Form  get_master_data
    Get the Master Data from Database Tables PA0001,0002,0003
    form get_master_data.
    Get data from Respective Infotypes
      rp_provide_from_last p0001 space pnpbegda pnpendda.
      if p0001-kostl in pnpkostl.
        rep_tab-kostl = p0001-kostl.
        rep_tab-pernr = p0001-pernr.
        rep_tab-ename = p0001-ename.
    Get the Position Text
        clear t528t-plstx.
        select single plstx into t528t-plstx from t528t
                where plans = p0001-plans and
                      otype = c_type and
                      sprsl = sy-langu.
        if sy-subrc = 0.
          rep_tab-ptext = t528t-plstx.
        endif.
    Get the Cost Center Text
        clear cskt-ltext.
        select single ltext into cskt-ltext from cskt
                where spras = sy-langu and
                      kokrs = c_kokrs and
                      kostl = p0001-kostl.
        if sy-subrc = 0.
          rep_tab-ctext = cskt-ltext.
        endif.
    Get the Overtime Payment Data
        perform get_ot_data.
        rep_tab-ott = rep_tab-ot1 + rep_tab-ot2 + rep_tab-ot3 +
                      rep_tab-ot4 + rep_tab-ot5 + rep_tab-ot6 +
                      rep_tab-ot7 + rep_tab-ot8 + rep_tab-ot9 +
                      rep_tab-ot10 + rep_tab-ot11 + rep_tab-ot12.
        append rep_tab.
        clear  rep_tab.
      endif.
      sort rep_tab by kostl pernr.
      delete rep_tab where kostl = ' '.
      delete rep_tab where ott = 0.
    endform.                 "get_master_data
    *&      Form  get_ot_data
    Get the Overtime Payment Data
    form get_ot_data.
      cd-key = pernr-pernr.
      rp-imp-c2-cd.
      sort rgdir by seqnr.
    To get sequence number for the payroll period
      loop at rgdir where void     is initial
                        and reversal is initial
                        and outofseq is initial
                        and srtza    eq 'A'.
        if rgdir-fpper+0(4) = p_year.
    To consider offcycle run data
          if not rgdir-ocrsn is initial.
            v_seqnr = rgdir-seqnr.
            exit.
          endif.
          v_seqnr = rgdir-seqnr.
        endif.
        if not v_seqnr is initial.
          perform import_rx.
        endif.
        perform process_wagetypes.
      endloop.
    endform.                 "get_ot_data
    include rpppxm00.
    *&      Form  Import_rx
    Import the RX data from Clusters
    form import_rx.
      rx-key-pernr = cd-key-pernr.
      rx-key-seqno = v_seqnr.
      rp-init-buffer.
      rp-imp-c2-rx.
    endform.                    " Import_rx
    *&      Form  Process_wagetypes
    Calculate the Overtime Amount based on Wage types
    form process_wagetypes.
      loop at rt.
        if  rt-lgart = c_lgart1 or rt-lgart = c_lgart2.
          if rgdir-fpper+0(4) = p_year.
            v_mon = rgdir-fpper+4(2).
            case v_mon .
              when c_1.
                rep_tab-ot1 = rep_tab-ot1 + rt-betrg.
              when c_2.
                rep_tab-ot2 = rep_tab-ot2 + rt-betrg.
              when c_3.
                rep_tab-ot3 = rep_tab-ot3 + rt-betrg.
              when c_4.
                rep_tab-ot4 = rep_tab-ot4 + rt-betrg.
              when c_5.
                rep_tab-ot5 = rep_tab-ot5 + rt-betrg.
              when c_6.
                rep_tab-ot6 = rep_tab-ot6 + rt-betrg.
              when c_7.
                rep_tab-ot7 = rep_tab-ot7 + rt-betrg.
              when c_8.
                rep_tab-ot8 = rep_tab-ot8 + rt-betrg.
              when c_9.
                rep_tab-ot9 = rep_tab-ot9 + rt-betrg.
              when c_10.
                rep_tab-ot10 = rep_tab-ot10 + rt-betrg.
              when c_11.
                rep_tab-ot11 = rep_tab-ot11 + rt-betrg.
              when c_12.
                rep_tab-ot12 = rep_tab-ot12 + rt-betrg.
            endcase.
          endif.
        endif.
      endloop.
    endform.          "process_wagetypes
    *&      Form  top_of_page
    Write the Report and Column Headings
    form top_of_page.
      format color col_heading on.
      write: /1(252) 'NATIONAL DRILLING COMPANY'(010) centered,
             /1(252) 'Overtime Payments Details'(011) centered.
      format color off.
      if pnptimr1 = c_x.      " Current Date
        write: /2 'Period From     :'(036), sy-datum, 'To:'(006), sy-datum.
      elseif pnptimr2 = c_x.  " Current Month
        write: /2 'Period From     :'(036), v_date, 'To:'(006), v_date1.
      elseif pnptimr3 = c_x.  " Current Year
        write: /2 'Period From     :'(036), v_date, 'To:'(006), v_date1.
      elseif pnptimr4 = c_x.  " Upto Today
        write: /2 'Period From     :'(036), c_date1, 'To:'(006), sy-datum.
      elseif pnptimr5 = c_x.  " From Today
        write: /2 'Period From     :'(036), sy-datum, 'To:'(006), c_date2.
      else.
        if ( pnpbegda is initial and pnpendda is initial ).
          write: /2 'Period From     :'(036), c_date1, 'To:'(006), c_date2.
        elseif pnpbegda is initial and not pnpendda is initial.
          write: /2 'Period From     :'(036), c_date1, 'To:'(006), pnpendda.
        elseif not ( pnpbegda is initial and pnpendda is initial ).
          write: /2 'Period From     :'(036), pnpbegda,
                   'To:'(006), pnpendda.
        endif.
      endif.
      write: 219 'Report Run Date:'(018), sy-datum.
      if not pnpkostl[] is initial.
        if pnpkostl-high is initial.
          write: /2 'Cost Center     :'(004), pnpkostl-low,
                219 'Time           :'(020), sy-uzeit.
        else.
          write: /2 'Cost Center From:'(005), pnpkostl-low+7(3),
                                    'To:'(006), pnpkostl-high,
                219 'Time           :'(020), sy-uzeit.
        endif.
      else.
        write: /219  'Time           :'(020), sy-uzeit.
      endif.
      if not pnppernr[] is initial.
        if pnppernr-high is initial.
          write: /2 'Personal Number :'(007), pnppernr-low,
                 219 'User           :'(021), sy-uname.
        else.
          write: /2 'Personal No.From:'(008),  pnppernr-low,
                                    'To:'(006), pnppernr-high,
                 219 'User           :'(021), sy-uname.
        endif.
      else.
        write: /219 'User           :'(021), sy-uname.
      endif.
      write: /219 'Page No        :'(022), sy-pagno.
      format color col_heading.
      write /1(252) sy-uline.
      write:/1 sy-vline, 10 sy-vline,
            41 sy-vline,
            67 sy-vline, 68(167) 'Overtime Payments(Dirhams)'(013) centered,
           235 sy-vline,252 sy-vline.
      format color col_heading.
      write:/1 sy-vline,  2(8)  'Emp #'(019) centered,
            10 sy-vline, 11(30) 'Employee Name'(012) centered,
            41 sy-vline, 42(25) 'Position'(014) centered,
            67 sy-vline, 68(167)  sy-uline,
           235 sy-vline,236(16)  'Total'(017) centered,
           252 sy-vline.
      write:/1 sy-vline, 10 sy-vline,
            41 sy-vline,
            67 sy-vline, 68(13)  'JANUARY'(024) centered,
            81 sy-vline, 82(13)  'FEBRUARY'(025) centered,
            95 sy-vline, 96(13)  'MARCH'(026) centered,
           109 sy-vline,110(13)  'APRIL'(027) centered,
           123 sy-vline,124(13)  'MAY'(028) centered,
           137 sy-vline,138(13)  'JUNE'(029) centered,
           151 sy-vline,152(13)  'JULY'(030) centered,
           165 sy-vline,166(13)  'AUGUST'(031) centered,
           179 sy-vline,180(13)  'SEPTEMBER'(032) centered,
           193 sy-vline,194(13)  'OCTOBER'(033) centered,
           207 sy-vline,208(13)  'NOVEMBER'(034) centered,
           221 sy-vline,222(13)  'DECEMBER'(035) centered,
           235 sy-vline,252 sy-vline.
      format color off.
      write /1(252) sy-uline.
    endform.            "top_of_page
    *&      Form  Display_report
    Write the Report Output
    form display_report.
      clear v_no.
      describe table rep_tab lines v_no.
      if v_no = 0.
        message i999 with
         'No Data found for the entered Selection'(015).
      endif.
      loop at rep_tab.
        format color 3.
        at new kostl.
          read table rep_tab index sy-tabix.
          write:/1 sy-vline, 2(12) 'Cost Center:'(009),
                 14(10) rep_tab-kostl,
                 25(30) rep_tab-ctext,
                252 sy-vline.
          format color off.
          write /1(252) sy-uline.
        endat.
        format color col_normal.
        write: /1 sy-vline, 2(8)   rep_tab-pernr,
              10 sy-vline, 11(30)  rep_tab-ename,
              41 sy-vline, 42(25)  rep_tab-ptext,
              67 sy-vline, 68(13)  rep_tab-ot1 no-zero,
              81 sy-vline, 82(13)  rep_tab-ot2 no-zero,
              95 sy-vline, 96(13)  rep_tab-ot3 no-zero,
             109 sy-vline,110(13)  rep_tab-ot4 no-zero,
             123 sy-vline,124(13)  rep_tab-ot5 no-zero,
             137 sy-vline,138(13)  rep_tab-ot6 no-zero,
             151 sy-vline,152(13)  rep_tab-ot7 no-zero,
             165 sy-vline,166(13)  rep_tab-ot8 no-zero,
             179 sy-vline,180(13)  rep_tab-ot9 no-zero,
             193 sy-vline,194(13)  rep_tab-ot10 no-zero,
             207 sy-vline,208(13)  rep_tab-ot11 no-zero,
             221 sy-vline,222(13)  rep_tab-ot12 no-zero,
             235 sy-vline,236(16)  rep_tab-ott no-zero,
             252 sy-vline.
        at end of kostl.
          write /1(252) sy-uline.
        endat.
        format color off.
        at last.
          sum.
          format color 1.
          write: /1 sy-vline,
                10 sy-vline, 11(30) 'Total'(017) centered,
                41 sy-vline,
                67 sy-vline, 68(13)  rep_tab-ot1 no-zero,
                81 sy-vline, 82(13)  rep_tab-ot2 no-zero,
                95 sy-vline, 96(13)  rep_tab-ot3 no-zero,
               109 sy-vline,110(13)  rep_tab-ot4 no-zero,
               123 sy-vline,124(13)  rep_tab-ot5 no-zero,
               137 sy-vline,138(13)  rep_tab-ot6 no-zero,
               151 sy-vline,152(13)  rep_tab-ot7 no-zero,
               165 sy-vline,166(13)  rep_tab-ot8 no-zero,
               179 sy-vline,180(13)  rep_tab-ot9 no-zero,
               193 sy-vline,194(13)  rep_tab-ot10 no-zero,
               207 sy-vline,208(13)  rep_tab-ot11 no-zero,
               221 sy-vline,222(13)  rep_tab-ot12 no-zero,
               235 sy-vline,236(16)  rep_tab-ott no-zero,
               252 sy-vline.
          write /1(252) sy-uline.
        endat.
        format color off.
      endloop.
    endform.          "display_report
    Reward points if useful
    Regards
    Anji

  • Can I change the select option text for pnp ldb ?

    hi Akll,
    I am using a pnp logical database in my report and I have created my own hr category because i wanted to use field ename from the ldb in the selection screen. Now the problem with ename is I cant do a case sensitive search.
    So I have replaced it with sname, so now my screen has sname instead of ename, however I want to change the selection text for select option ( at present it is 'EE name can be sorted' )
    Kindly advise,
    thanks,
    GV

    I guess the text cannot be changed.. anyways you can add the field as an additional field by normal coding in your report

  • Usage of LDB

    I want to try a report where I can use LDB.So tried as follows
    Report zgldb.
    Nodes:pap.
    When I just compile it says 'PAP is not a node of Logical database _S'..
    what does this mean.How to use LDB in a report?
    Thank you

    Dear Gopi,
    Logical Databases
    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.
    There are two ways of using a logical database: Either by linking it with an executable program, or by using the function module LDB_PROCESS in any ABAP program.
    When you link a logical database to an executable program, the user can enter values on the selection screen, and the data read by the logical database is passed back to the program using the interface work areas. If you call the logical database using a function module, the selection screen is not displayed. The calling program does not have to provide interface work areas. Instead, it uses special subroutines called callback routines, which are called by the function module and filled with the required data.
    Linking a Logical DB to an Executable Program
    When you link an executable program to a logical database by entering the name of the logical database in the program attributes, the subroutines of the logical database program and the event blocks of the executable program form a modularized program for reading and processing data. The individual processing blocks are called in a predefined sequence by the runtime environment (see the diagram in the section Logical Databases and Contexts). The runtime sequence is controlled by the structure, selections, and PUT statements in the logical database, and by the GET statements in the executable program.
    Selection Screen
    If you specify a logical database in the attributes of an executable program, this affects the standard selection screen of the program. It contains both the selection fields from the logical database and those from the program itself. You can specify which of the logical database selections are relevant for your program, and should therefore appear on the screen, by declaring interface work areas for the relevant nodes.
    Runtime Behavior
    The following list shows the sequence in which the ABAP runtime environment calls the subroutines of the logical database and the event blocks in the executable program. The runtime environment executes a series of processors (selection screen processor, reporting processor). The ABAP code listed below shows the processing blocks that belong to the individual steps.
    Initialization before the selection screen is processed.
    Subroutine:
    FORM INIT
    This subroutine is called once only before the selection screen is first displayed.
    Event block:
    INITIALIZATION.
    This event occurs once only before the selection screen is first displayed.
    PBO of the Selection screen Initialization before each occasion on which the selection screen is displayed (for example, to supply default values for key fields).
    Subroutine:
    FORM PBO.
    This subroutine is called each time the selection screen is sent (before it is displayed).
    Event block:
    AT SELECTION-SCREEN OUTPUT.
    This event is called each time the selection screen is sent (before it is displayed).
    The selection screen is displayed at the presentation server, and the user can enter data in the input fields.
    Input help (F4) or field help (F1) requests.
    Subroutines:
    FORM <par>_VAL.
    FORM <selop>_VAL.
    FORM <selop>-LOW_VAL.
    FORM <selop>-HIGH_VAL.
    If the user requests a list of possible entries for database-specific parameters <par> or selection criteria <selop>, these subroutines are called as required.
    If the user requests field help for these parameters, the subroutines are called with the ending _HLP instead of _VAL.
    Event blocks:
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR <par>.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR <selop>-LOW.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR <selop>-HIGH.
    If the user requests a list of possible entries for database-specific parameters <par> or selection criteria <selop>, these events are triggered as required.
    If the user requests field help for these parameters, the events with the addition ON HELP-REQUEST occurs instead of ON VALUE-REQUEST.
    PAI of the selection screen. Checks to see whether the user has entered correct, complete, and plausible data. Also contains authorization checks. If an error occurs, you can program a user dialog and make the relevant fields ready for input again.
    Subroutines:
    FORM PAI USING FNAME MARK.
    The interface parameters FNAME and MARK are passed by the runtime environment.
    FNAME contains the name of a selection criterion or parameter on the selection screen.
    If MARK = SPACE, the user has entered a simple single value or range selection.
    If MARK = '*', the user has also entered selections on the Multiple Selection screen.
    Using the combination FNAME = '*' and MARK = 'ANY', you can check all entries at once when the user chooses a function or presses ENTER.
    Event blocks:
    AT SELECTION-SCREEN ON <fname>.
    Event for processing a particular input field.
    AT SELECTION-SCREEN ON END OF <fname>.
    Event for processing multiple selections.
    AT SELECTION-SCREEN.
    Event for processing all user input.
    Processing before reading data.
    Subroutine:
    BEFORE EVENT 'START-OF-SELECTION'.
    The logical database can use this subroutine for necessary actions before reading data, for example, initializing internal tables.
    Event block:
    START-OF-SELECTION.
    First event in an executable program after the selection screen has been processed. You can use this event block to prepare the program for processing data.
    Reading data in the logical database and processing in the executable program.
    Subroutine:
    FORM PUT_<node>
    The logical database reads the selected data of the node <node>.
    Event block:
    GET <table> [LATE].
    This event is triggered by the PUT statement in the above subroutine. This event block allows you to process the data read for <node> in the corresponding interface work area.
    Processing after reading data.
    Subroutine:
    AFTER EVENT 'END-OF-SELECTION'.
    The logical database can use this subroutine for necessary actions after reading data, for example, releasing memory space.
    Event block:
    END-OF-SELECTION.
    Last reporting event. You can use this event block to process the temporary dataset that you have created (for example, sort it).
    If a list was generated during the above steps, the list processor in the runtime environment takes control of the program and displays the list.
    Suppose TABLE1 is the root node and TABLE2 is its only subordinate node in a logical database. The processing steps for reading and processing data would then have the following hierarchical order:
    START-OF-SELECTION.
      FORM PUT_TABLE1.
      GET TABLE1.
        FORM PUT_TABLE2.
        GET TABLE2.
      GET TABLE1 LATE.
    END-OF-SELECTION.
    Authorization Checks in Logical Databases
    It makes sense to use authorization checks using the AUTHORITY-CHECK statement in the following subroutines in the database program or event blocks of the executable program:
    Subroutines in the database program:
    - PAI
    - AUTHORITY_CHECK_<table>
    Event blocks in the executable program:
    - AT SELECTION-SCREEN
    - AT SELECTION-SCREEN ON <fname>
    - AT SELECTION-SCREEN ON END OF <fname>
    - GET <table>
    Whether you place the authorization checks in the database program or in the executable program depends on the following:
    The structure of the logical database.
    For example, you should only check authorizations for company code if you actually read lines containing the company code at runtime.
    Performance
    Avoid repetitive checks (for example, within a SELECT loop).
    The separation of database access and application logic allows you to program all of your authorization checks centrally in the logical database program. This makes it easier to maintain large programming systems.
    Calling a Logical Database Using a Function Module
    From Release 4.5A it is possible to call logical databases independently from any ABAP program. Previously it was only possible to link a logical database to an executable program, in which the processing blocks of the logical database and the program were controlled by the ABAP runtime environment.
    To call a logical database from another program, use the function module LDB_PROCESS. This allows you to use the logical database as a routine for reading data. You can call more than one logical database from the same program. You may also call the same logical database more than once from the same program. In the past, it was only possible to use a logical database more than once or use more than one logical database by calling a further executable program using SUBMIT. These programs had to be linked to the corresponding logical database, and the data had to be passed to the calling program using ABAP memory or a similar technique.
    When you call a logical database using the function module LDB_PROCESS, its selection screen is not displayed. Instead, you fill the selections using the interface parameters of the function module. The logical database does not trigger any GET events in the calling program, but passes the data back to the caller in callback routines. Calling a logical database using LDB_PROCESS thus decouples the actual data retrieval from the preceding selection screen processing and the subsequent data processing.
    There is no need to adapt a logical database for use with LDB_PROCESS, except in the following cases: If you do not adapt a logical database, it is not possible to use the function module to call the same logical database more than once. The PAI subroutine is not called when you use LDB_PROCESS. This means that none of the checks for selections programmed in it are performed. You can work around these restrictions by including the subroutines LDB_PROCESS_INIT and LDB_PROCESS_CHECK_SELECTIONS in the database program.
    Runtime Behavior
    The subroutines in the logical database are called in the following sequence when you call the function module LDB_PROCESS:
    LDB_PROCESS_INIT
    INIT
    LDB_PROCESS_CHECK_SELECTIONS
    PUT <node>.
    None of the subroutines used to process the selection screen when you link the logical database to an executable program are called, neither does the runtime environment trigger any reporting events in the calling program. Instead, the PUT statements in the logical database trigger actions in the function module that call callback routines in the calling program. In other words, the function module catches the events that are otherwise processed by the runtime environment.
    Parameters of LDB_PROCESS
    The function module has the following import parameters:
    LDBNAME
    Name of the logical database you want to call.
    VARIANT
    Name of a variant to fill the selection screen of the logical database. The variant must already be assigned to the database program of the logical database. The data is passed in the same way as when you use the WITH SELECTION-TABLE addition in a SUBMIT statement.
    EXPRESSIONS
    In this parameter, you can pass extra selections for the nodes of the logical database for which dynamic selections are allowed. The data type of the parameter RSDS_TEXPR is defined in the type group RSDS. The data is passed in the same way as when you use the WITH FREE SELECTION addition in a SUBMIT statement.
    FIELD_SELECTION
    You can use this parameter to pass a list of the required fields for the nodes of the logical database for which dynamic selections are allowed. The data type of the parameter is the deep internal table RSFS_FIELDS, defined in the type group RSFS. The component TABLENAME contains the name of the node and the deep component FIELDS contains the names of the fields that you want to read.
    The function module has the following tables parameters:
    CALLBACK
    You use this parameter to assign callback routines to the names of nodes and events. The parameter determines the nodes of the logical database for which data is read, and when the data is passed back to the program and in which callback routine.
    SELECTIONS
    You can use this parameter to pass input values for the fields of the selection screen of the logical database. The data type of the parameter corresponds to the structure RSPARAMS in the ABAP Dictionary. The data is passed in the same way as when you use the WITH SELECTION-TABLE addition in a SUBMIT statement.
    If you pass selections using more than one of the interface parameters, values passed in SELECTIONS and EXPRESSIONS overwrite values for the same field in VARIANT.
    Read Depth and Callback Routines
    When you link a logical database with an executable program, the GET statements determine the depth to which the logical database is read. When you call the function module LDB_PROCESS, you determine the depth by specifying a node name in the CALLBACK parameter. For each node for which you request data, a callback routine can be executed at two points. These correspond to the GET and GET LATE events in executable programs. In the table parameter CALLBACK, you specify the name of the callback routine and the required execution point for each node. A callback routine is a subroutine in the calling program or another program that is to be executed at the required point.
    For the GET event, the callback routine is executed directly after the data has been read for the node, and before the subordinate nodes are processed. For the GET_LATE event, the callback routine is processed after the subordinate nodes have been processed.
    The line type of the table parameter CALLBACK is the flat structure LDBCB from the ABAP Dictionary. It has the following components:
    LDBNODE
    Name of the node of the logical database to be read.
    GET
    A flag (contents X or SPACE), to call the corresponding callback routine at the GET event.
    GET_LATE
    A flag (contents X or SPACE), to call the corresponding callback routine at the GET LATE event.
    CB_PROG
    Name of the ABAP program in which the callback routine is defined.
    CB_FORM
    Name of the callback routine.
    If you pass an internal table to the CALLBACK parameter, you must fill at least one of the GET or GET_LATE columns with X for each node (you may also fill both with X).
    A callback routine is a subroutine that must be defined with the following parameter interface:
    FORM <subr> USING <node> LIKE LDBCB-LDBNODE
                      <wa>   [TYPE <t>]
                      <evt>
                      <check>.
    The parameters are filled by the function module LDB_PROCESS. They have the following meaning:
    <node> contains the name of the node.
    <wa> is the work area of the data read for the node. The program that calls the function module LDB_PROCESS and the program containing the callback routine do not have to declare interface work areas using NODES or TABLES. If the callback routine is only used for one node, you can use a TYPE reference to refer to the data type of the node in the ABAP Dictionary. Only then can you address the individual components of structured nodes directly in the subroutine. If you use the callback routine for more than one node, you cannot use a TYPE reference. In this case, you would have to address the components of structured nodes by assigning them one by one to a field symbol.
    <evt> contains G or L, for GET or GET LATE respectively. This means that the subroutine can direct the program flow using the contents of <evt>.
    <check> allows the callback routine to influence how the program is processed further (but only if <evt> contains the value G). The value X is assigned to the parameter when the subroutine is called. If it has the value SPACE when the subroutine ends, this flags that the subordinate nodes of the logical database should not be processed in the function module LDB_PROCESS. This is the same as leaving a GET event block using CHECK in an executable program. If this prevents unnecessary data from being read, it will improve the performance of your program.
    Exceptions of LDB_PROCESS
    LDB_ALREADY_RUNNING
    A logical database may not be called if it is still processing a previous call. If this occurs, the exception LDB_ALREADY_RUNNING is triggered.
    LDB_NOT_REENTRANT
    A logical database may only be called repeatedly if its database program contains the subroutine LDB_PROCESS_INIT, otherwise, this exception is triggered.
    LDB_SELECTIONS_NOT_ACCEPTED
    Error handling in the subroutine LDB_PROCESS_CHECK_SELECTIONS of the database program can trigger this exception. The error message is placed in the usual system fields SY-MSG....
    For details of further exceptions, refer to the function module documentation in the Function Builder.
    Example
    TABLES SPFLI.
    SELECT-OPTIONS S_CARR FOR SPFLI-CARRID.
    TYPE-POOLS: RSDS, RSFS.
    DATA: CALLBACK TYPE TABLE OF LDBCB,
          CALLBACK_WA LIKE LINE OF CALLBACK.
    DATA: SELTAB TYPE TABLE OF RSPARAMS,
          SELTAB_WA LIKE LINE OF SELTAB.
    DATA: TEXPR TYPE RSDS_TEXPR,
          FSEL  TYPE RSFS_FIELDS.
    CALLBACK_WA-LDBNODE     = 'SPFLI'.
    CALLBACK_WA-GET         = 'X'.
    CALLBACK_WA-GET_LATE    = 'X'.
    CALLBACK_WA-CB_PROG     = SY-REPID.
    CALLBACK_WA-CB_FORM     = 'CALLBACK_SPFLI'.
    APPEND CALLBACK_WA TO CALLBACK.
    CLEAR CALLBACK_WA.
    CALLBACK_WA-LDBNODE     = 'SFLIGHT'.
    CALLBACK_WA-GET         = 'X'.
    CALLBACK_WA-CB_PROG     = SY-REPID.
    CALLBACK_WA-CB_FORM     = 'CALLBACK_SFLIGHT'.
    APPEND CALLBACK_WA TO CALLBACK.
    SELTAB_WA-KIND = 'S'.
    SELTAB_WA-SELNAME = 'CARRID'.
    LOOP AT S_CARR.
      MOVE-CORRESPONDING S_CARR TO SELTAB_WA.
      APPEND SELTAB_WA TO SELTAB.
    ENDLOOP.
    CALL FUNCTION 'LDB_PROCESS'
         EXPORTING
              LDBNAME                     = 'F1S'
              VARIANT                     = ' '
              EXPRESSIONS                 = TEXPR
              FIELD_SELECTION             = FSEL
         TABLES
              CALLBACK                    = CALLBACK
              SELECTIONS                  = SELTAB
         EXCEPTIONS
              LDB_NOT_REENTRANT           = 1
              LDB_INCORRECT               = 2
              LDB_ALREADY_RUNNING         = 3
              LDB_ERROR                   = 4
              LDB_SELECTIONS_ERROR        = 5
              LDB_SELECTIONS_NOT_ACCEPTED = 6
              VARIANT_NOT_EXISTENT        = 7
              VARIANT_OBSOLETE            = 8
              VARIANT_ERROR               = 9
              FREE_SELECTIONS_ERROR       = 10
              CALLBACK_NO_EVENT           = 11
              CALLBACK_NODE_DUPLICATE     = 12
              OTHERS                      = 13.
    IF SY-SUBRC <> 0.
      WRITE: 'Exception with SY-SUBRC', SY-SUBRC.
    ENDIF.
    FORM CALLBACK_SPFLI USING NAME  TYPE LDBN-LDBNODE
                              WA    TYPE SPFLI
                              EVT   TYPE C
                              CHECK TYPE C.
      CASE EVT.
       WHEN 'G'.
          WRITE: / WA-CARRID, WA-CONNID, WA-CITYFROM, WA-CITYTO.
          ULINE.
        WHEN 'L'.
          ULINE.
      ENDCASE.
    ENDFORM.
    FORM CALLBACK_SFLIGHT USING NAME  TYPE LDBN-LDBNODE
                                WA    TYPE SFLIGHT
                                EVT   TYPE C
                                CHECK TYPE C.
      WRITE: / WA-FLDATE, WA-SEATSOCC, WA-SEATSMAX.
    ENDFORM.
    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.
    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.
    A program-specific selection screen is defined at the beginning of the program. This requires the TABLES statement. Next, the required variables are defined for the interface.
    The internal table CALLBACK is filled so that various callback routines are called in the program for the two nodes SPFLI and SFLIGHT. For SPFLI, the routine is to be called for GET and GET_LATE, for SFLIGHT, only at the GET event.
    The internal table SELTAB is filled with values for the node SPFLI from the selection table S_CARR from the program-specific selection screen.
    The program then calls the function module LDB_PROCESS with these parameters.
    The subroutines CALLBACK_SPFLI and CALLBACK_SFLIGHT serve as callback routines. The interface parameter WA is fully typed, so you can address the individual components of the work areas. The events GET and GET LATE are handled differently in CALLBACK_SPFLI.
    Regards,
    Rajesh K Soman
    <b>Please reward points if found helpful</b>

  • Need example report program using PNPCE LDB in SAP HR

    Need example report program using PNPCE LDB in SAP HR.
    and how to create a report category in sap hr for using it as cutomised selection screen.

    Hi,
    Go through the following links, i hope it will help you.....
    /people/alvaro.tejadagalindo/blog/2006/02/19/how-to-deal-with-hr-payroll-reports
    http://sap.ittoolbox.com/groups/technical-functional/sap-r3-dev/893908#
    A sample prog with LDB PNP
    *& Report ZH_REPT_PAYMENT *
    report zh_rept_payment line-size 80 no standard page
    heading.
    tables: pernr, " Standard Selections for HR Master Data Reporting
    pcl1, " HR Cluster 1
    pcl2, " HR Cluster 2
    pa0009,
    PA9001,
    PA9006,
    pa0002,
    pc260 , " Cluster Directory for Payroll Results
    bnka .
    Infotypes
    infotypes: 0001. " Organizational Assignment
    Declaration of Internal Tables
    data : bnka1 like bnka occurs 0 with header line .
    data: begin of t_int_rep occurs 100,
    bankl like pc209-bankl, " Bank Number
    zlsch like pc209-zlsch, " Payment method
    pernr like pernr-pernr, " Employee Number
    ename like pernr-ename, " Employee Name
    bankn like pc209-bankn, " Bank Account Number
    betrg like pc209-betrg, " Amount to be transfered
    zweck like pa0009-zweck, " Purpose
    end of t_int_rep.
    data: begin of int_rep occurs 100,
    bankl like pc209-bankl, " Bank Number
    zlsch like pc209-zlsch, " Payment method
    pernr like pernr-pernr, " Employee Number
    ename like pernr-ename, " Employee Name
    bankn like pc209-bankn, " Bank Account Number
    betrg like pc209-betrg, " Amount to be transfered
    zweck like pa0009-zweck, " Purpose
    begda like pa0009-begda, "Begin date
    end of int_rep.
    Declaration of Data Variables
    data: ws_betrg like pc209-betrg, " BT Amount
    w_val like spell occurs 0 with header line,
    int_rep1(6), " TYPE I, " Employee Number
    cnt type i value 0, " Counter
    calcmolga like t500l-molga value '40', " Country Grouping
    v_id(15),
    calc_currency like t001-waers value 'INR'. " Currency
    data : ctr type i,
    dt_merge like pa0009-begda.
    data: ws_totemp(6) type c,
    ws_totamt(20) type c,
    r_mth(9) type c,
    ws_fpbeg(6) type c,
    ws_fpend(6) type c,
    ws_mthyr(6) type c,
    ws_mthyr_r(14) type c,
    r_mth_t(3) type c,
    ws_amt(8) type c,
    ws_bankl(14) type c,
    ws_date(6) type c,
    amount_word(500),
    total_page type i,
    pages type i,
    remain type i.
    data begin of i_spell.
    include structure spell .
    data end of i_spell .
    data : c_molga type t500l-molga value '40',
    c_banks type bnka-banks value 'IN'.
    Standard Includes
    include rpc2cd09. "Cluster CD data definition
    include pc2rxin0.
    include rpc2rx09.
    include rpppxd00. " Data Definition buffer PCL1/PCL2
    include rpppxd10. " Common Part buffer PCL1/PCL2
    include rpppxm00. " Buffer Handling RoutinePCL1/PCL2
    include zrpc2rox2. " Data Definition POCLSTERS (not J,K,U)
    Selection Screen
    selection-screen begin of block b1 with frame title text-001.
    parameter: pa_mth(2) type c default sy-datum+4(2) obligatory,
    pa_year(4) type c default sy-datum(4) obligatory,
    p_bankl like pc209-bankl, " Bank Number
    p_zlsch like pc209-zlsch. " Payment method
    selection-screen end of block b1.
    save_calc_currency = calc_currency.
    count_top = 0.
    get_pernr_flag = 0.
    Top-Of-Page
    top-of-page.
    perform convert_month using pa_mth(2) r_mth.
    ws_mthyr_r = r_mth.
    concatenate ws_mthyr_r pa_year into ws_mthyr_r separated by space.
    SKIP 5.
    skip 1.
    skip 4.
    if int_rep-bankl eq ' '.
    if int_rep-zlsch eq 'C' or int_rep-zlsch eq 'E' or
    int_rep-zlsch eq ' '.
    write: /1(85) 'CHEQUE PAYMENT STATEMENT'(047) centered.
    elseif int_rep-zlsch eq 'L'.
    write: /1(85) 'DEMAND DRAFT STATEMENT'(047) centered.
    endif.
    else.
    write: /1(85) 'BANK TRANSFER STATEMENT'(002) centered.
    endif.
    skip.
    write: /34 ws_mthyr_r,
    62 'Page :'(008),69(2) sy-pagno intensified off,
    ' Of ',78(2) pages intensified off.
    clear pages.
    read table bnka1 with key bankl = int_rep-bankl .
    if sy-subrc = 0.
    if int_rep-zlsch eq 'T'.
    write:/03(10) 'Bank Name : ', bnka1-banka.
    write:/03(10) 'Branch : ', bnka1-brnch.
    write:/03(10) 'Address : ', bnka1-stras.
    endif.
    endif.
    skip.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 2(5) 'Sl.No'(002),
    7 sy-vline, 8(8) 'Emp.No.'(003),
    16 sy-vline,17(35) 'Employee Name'(004).
    *--added for Demand Draft
    if ( int_rep-zlsch = 'l' or int_rep-zlsch = 'L' ).
    write : 47 sy-vline, 48(15) 'Payable at'(005).
    else.
    write : 47 sy-vline,48(15) 'Account No.'(005).
    endif.
    write: 63 sy-vline,64(16) 'Amount'(006),
    80 sy-vline.
    write:/1(80) sy-uline.
    end-of-page.
    write:/1(80) sy-uline.
    write:/2 'Printed on ', sy-datum.
    Start-of-selection.
    start-of-selection.
    *perform h_headr.
    ctr = 0.
    set margin 5.
    call function 'RP_GET_CURRENCY'
    exporting
    molga = calcmolga
    importing
    waers = calc_currency
    exceptions
    others.
    if sy-subrc ne 0.
    calc_currency = 'DEM'.
    calc_currency = save_calc_currency.
    endif.
    get pernr.
    cd-key-pernr = pernr-pernr.
    perform import_cluster.
    get_pernr_flag = 1.
    check : ocd-version-molga eq calcmolga.
    The table 'tabpernr' is filled with the personnel numbers
    and is used after selection is finished.
    move-corresponding pernr to tabpernr.
    append tabpernr.
    The table 'tab_rgdir' is filled
    loop at rgdir.
    rx-key-pernr = pernr-pernr.
    unpack rgdir-seqnr to rx-key-seqno.
    perform int_tab. "fill tab_rgdir
    perform import_bt.
    perform validate.
    endloop.
    End of Selection
    end-of-selection.
    *perform h_headr.
    perform convert_date_a using pa_mth r_mth_t.
    sort int_rep by bankl zlsch pernr betrg descending.
    delete adjacent duplicates from int_rep
    comparing bankl zlsch pernr .
    sort int_rep by bankl zlsch bankn . "PERNR.
    loop at int_rep.
    at new bankl.
    select single * into bnka1 from bnka
    where banks = c_banks and
    bankl = int_rep-bankl .
    append bnka1.
    clear bnka1.
    endat.
    endloop.
    for Demand Draft - purpose added
    loop at int_rep.
    concatenate pa_year(4) pa_mth(2) '01' into dt_merge.
    select single * "zweck into int_rep-zweck
    from pa0009 where
    pernr = int_rep-pernr and
    bankl = int_rep-bankl and
    zlsch = int_rep-zlsch
    and begda <= dt_merge and
    endda >= dt_merge .
    if sy-subrc = 0.
    int_rep-zweck = pa0009-zweck.
    modify int_rep.
    endif.
    endloop.
    *-for DD and Chq sorted by PAyable at and EMPNO wise
    if p_zlsch = 'T' .
    sort int_rep by bankl zlsch bankn . "PERNR.
    else. "added for "payable at" for DD/Chq
    else.
    sort int_rep by zweck pernr . "PERNR.
    endif.
    *delete adjacent duplicates from int_rep.
    t_int_rep] = int_rep[.
    loop at int_rep.
    *-for page of page no.
    total_page = 0.
    loop at t_int_rep where bankl = int_rep-bankl
    and zlsch = int_rep-zlsch.
    total_page = total_page + 1.
    endloop.
    pages = total_page div 25.
    remain = total_page mod 25.
    comment bcoz its adding one extra page no.
    done as on 29/11/2004
    if remain > 0.
    pages = pages + 1.
    endif.
    **-end
    at new bankl.
    ctr = 0 .
    new-page.
    endat.
    at new zlsch.
    ctr = 0 .
    new-page.
    endat.
    clear v_id.
    select single natio
    into pa0002-natio
    from pa0002
    where pernr eq int_rep-pernr.
    *-testing......for soma
    if ctr > 24.
    ctr = 0 .
    write:/1(80) sy-uline.
    new-page .
    endif.
    ctr = ctr + 1 .
    cnt = cnt + 1.
    pack int_rep-pernr to int_rep1.
    write:/1 sy-vline, 2(3) cnt intensified off,
    7 sy-vline, 9(6) int_rep1 intensified off,
    16 sy-vline,17(35) int_rep-ename intensified off .
    if ( int_rep-zlsch = 'l' or int_rep-zlsch = 'L' ).
    write : 47 sy-vline,48(15) int_rep-zweck intensified off.
    else.
    write:
    47 sy-vline,48(15) int_rep-bankn intensified off .
    endif.
    write: 63 sy-vline,64(16) int_rep-betrg
    intensified off currency 'INR',
    80 sy-vline.
    ws_betrg = ws_betrg + int_rep-betrg.
    *-testing......for soma
    skip.
    write :
    /1 sy-vline, 7 sy-vline ,16 sy-vline ,47 sy-vline,63 sy-vline,80
    sy-vline .
    *-end testing......for soma
    at end of zlsch.
    if int_rep-bankl = ' '.
    call function 'HR_IN_CHG_INR_WRDS'
    exporting
    amt_in_num = ws_betrg
    importing
    amt_in_words = amount_word
    EXCEPTIONS
    DATA_TYPE_MISMATCH = 1
    OTHERS = 2
    w_val-word = amount_word.
    concatenate 'INR.' w_val-word into w_val-word
    separated by space.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 7 'Total transfer:'(009),
    64(16) ws_betrg intensified off currency 'INR',
    80 sy-vline.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 3 w_val-word+0(76) intensified off,
    80 sy-vline.
    write :/1 sy-vline, 10 w_val-word+76(70) intensified off,
    80 sy-vline.
    write:/1(80) sy-uline.
    clear: ws_betrg,cnt.
    skip 2.
    write: /2 'Prepared by :'(010), '_______________'(013),
    45 'Checked by :'(011),'_______________'(013).
    skip 2.
    write: /2 'Printed On ', sy-datum,
    45 'Approved by :'(012),'_______________'(013).
    clear sy-pagno.
    endif.
    endat.
    at end of bankl.
    if int_rep-bankl ' '.
    call function 'HR_IN_CHG_INR_WRDS'
    exporting
    amt_in_num = ws_betrg
    importing
    amt_in_words = amount_word
    EXCEPTIONS
    DATA_TYPE_MISMATCH = 1
    OTHERS = 2
    w_val-word = amount_word.
    concatenate 'INR.' w_val-word into w_val-word
    separated by space.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 7 'Total transfer:'(009),
    64(16) ws_betrg intensified off currency 'INR',
    80 sy-vline.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 3 w_val-word+0(76) intensified off,
    80 sy-vline.
    write :/1 sy-vline, 10 w_val-word+76(70) intensified off,
    80 sy-vline.
    write:/1(80) sy-uline.
    clear: ws_betrg,cnt.
    skip 2.
    write: /2 'Prepared by :'(010), '_______________'(013),
    45 'Checked by :'(011),'_______________'(013).
    skip 2.
    write: /2 'Printed on ', sy-datum,
    45 'Approved by :'(012),'_______________'(013).
    clear sy-pagno.
    NEW-PAGE.
    endif.
    endat.
    endloop.
    End of Page
    end-of-page.
    write: /2 'Prepared by :'(010), '_______________',
    45 'Checked by :'(011),'_______________'.
    *& Form IMPORT_CLUSTER
    Importing Data from Cluster *
    form import_cluster.
    sy-subrc = 0.
    rp-imp-c2-cd.
    if sy-subrc eq 0.
    if cd-version-number ne ocd-version-number.
    endif.
    endif. " SY-SUBRC EQ 0
    endform. " IMPORT_CLUSTER
    *& Form INT_TAB
    Filling internal table tab_rgdir form int_tab.
    *Fill internal table tab_rgdir.
    move-corresponding rgdir to tab_rgdir.
    tab_rgdir-pernr = pernr-pernr.
    append tab_rgdir.
    endform. " INT_TAB
    *& Form IMPORT_bt
    Import Values from Bank Transactions Table (BT) form import_bt.
    rp-init-buffer.
    RP-IMP-C2-RX.
    rp-imp-c2-in.
    if rp-imp-in-subrc eq 0.
    if in-version-number ne oin-version-number.
    write: / 'Schlüssel des Clusters RX:'(015),
    rx-key-pernr, rx-key-seqno.
    write: / 'The imported version of the cluster'(016), 'RX',
    'is not current'(017).
    write: / 'Imported version :'(018),
    oin-version-number.
    write: / 'Current version of cluster :'(019),
    in-version-number.
    stop.
    else.
    sy-subrc = 0.
    endif.
    else.
    sy-subrc = 8.
    write: /
    'Inconsistencies between cluster directory and directory for'(020).
    write: /
    'No payroll results found for data in cluster directory'(021).
    write : /
    'Please contact hotline to solve the current problem'(022).
    endif.
    ws_fpbeg(2) = versc-fpbeg+4(2).
    ws_fpbeg+2(4) = versc-fpbeg(4).
    ws_fpend(2) = versc-fpend+4(2).
    ws_fpend+2(4) = versc-fpend(4).
    ws_mthyr(2) = pa_mth.
    ws_mthyr+2(4) = pa_year.
    check ws_mthyr = ws_fpbeg.
    check ws_mthyr = ws_fpend.
    loop at bt. "from pc209
    int_rep-pernr = pernr-pernr.
    int_rep-ename = pernr-ename.
    int_rep-bankl = bt-bankl.
    int_rep-bankn = bt-bankn.
    int_rep-betrg = bt-betrg.
    int_rep-zlsch = bt-zlsch.
    append int_rep.
    endloop.
    IF P_BANKL ' ' AND P_ZLSCH ' '.
    DELETE INT_REP WHERE BANKL P_BANKL.
    ELSEIF P_BANKL = ' ' AND P_ZLSCH ' '.
    DELETE INT_REP WHERE ZLSCH P_ZLSCH.
    ELSEIF P_BANKL ' ' AND P_ZLSCH = ' '.
    DELETE INT_REP WHERE BANKL P_BANKL.
    ENDIF.
    endform. " IMPORT_BT
    *& Form CONVERT_MONTH
    Fetching Month Text form convert_month using mth t_mth.
    case mth.
    when '01'.
    t_mth = 'January'(023).
    when '02'.
    t_mth = 'February'(024).
    when '03'.
    t_mth = 'March'(025).
    when '04'.
    t_mth = 'April'(026).
    when '05'.
    t_mth = 'May'(027).
    when '06'.
    t_mth = 'June'(028).
    when '07'.
    t_mth = 'July'(029).
    when '08'.
    t_mth = 'August'(030).
    when '09'.
    t_mth = 'September'(031).
    when '10'.
    t_mth = 'October'(032).
    when '11'.
    t_mth = 'November'(033).
    when '12'.
    t_mth = 'December'(034).
    endcase.
    endform. " CONVERT_MONTH
    *& Form CONVERT_DATE_A
    Fetching Month Text * form convert_date_a using mth_t t_mth_t.
    case mth_t.
    when '01'.
    t_mth_t = 'Jan.'(035).
    when '02'.
    t_mth_t = 'Feb.'(036).
    when '03'.
    t_mth_t = 'Mar.'(037).
    when '04'.
    t_mth_t = 'Apr.'(038).
    when '05'.
    t_mth_t = 'May.'(039).
    when '06'.
    t_mth_t = 'Jun.'(040).
    when '07'.
    t_mth_t = 'Jul.'(041).
    when '08'.
    t_mth_t = 'Aug.'(042).
    when '09'.
    t_mth_t = 'Sep.'(043).
    when '10'.
    t_mth_t = 'Oct.'(044).
    when '11'.
    t_mth_t = 'Nov.'(045).
    when '12'.
    t_mth_t = 'Dec.'(046).
    endcase.
    endform. " CONVERT_DATE_A
    *& Form VALIDATE
    text
    --> p1 text
    <-- p2 text form validate .
    if p_bankl <> ' ' and p_zlsch ' '.
    delete int_rep where bankl p_bankl.
    elseif p_bankl = ' ' and p_zlsch ' '.
    delete int_rep where zlsch p_zlsch.
    elseif p_bankl ' ' and p_zlsch = ' '.
    delete int_rep where bankl p_bankl.
    endif.
    endform. " VALIDATE
    check this weblog.....
    /people/dj.adams/blog/2003/11/13/food-for-thought-ldbs-and-abap-objects
    Also , check the following link too.
    http://www.datamanagementgroup.com/Resources/Articles/Article_1005_2.asp
    Regards,
    Harish

  • LDB files or log files in ORACLE database ?

    Hi Experts,
    Like LDB files in MIcrosoft Access do we have any sort of files in ORACLE which records the transactions and updates done in a particular database.
    Pls help me if you have any idea on this.
    Thanks in advance.

    If you are comparing Access with Oracle, then you are in for many shocks and surprises. In Oracle we have a database, in which there are logiical things called as tablespaces which have data files, a physical file at operating system level, which store data, and then transactions are also protected by the redo logs and for the old image we have undo tablespaces and so on...
    regards

  • Regarding using of LDB PNPCE  in sap hr

    Can some one please tell me how to disable some of the selection screen fields and blocks of LDB PNPCE selection-screen which are not used in my report selection-screen?
    Thanks,
    Phanisreedhar.L

    *: Report:  ZP_POSTCODE                                                :
    *: Author:  www.SAPDev.co.uk                                           :
    *: Date  :  2004                                                       :
    *: Description: Displays report of employees by postcode area,         :
    *:              includes current travelling allowances (i.e. parking   :
    *:              permit or transport card etc..)                        :
    *: Use:         Help encourage the use of car sharing and public       :
    *:              transport where appropriate.                           :
    REPORT  zp_postcode.
    type-pools: slis.                                      "ALV Declarations
    NODES: pernr.
    INFOTYPES: 0000, 0001, 0002, 0006, 0008, 0014, 0105, 0121.
    SELECTION-SCREEN BEGIN OF BLOCK pcode WITH FRAME TITLE text-s01.
    SELECT-OPTIONS: so_pcode FOR p0006-pstlz.
    SELECTION-SCREEN END OF BLOCK pcode.
    TYPES: BEGIN OF t_output,
      pernr       TYPE p0001-pernr,   "personnel name
      anredtxt    TYPE t522t-atext,   "title (based on p0002-anred)
      fname       TYPE p0002-vorna,   "first name
      lname       TYPE p0002-nachn,   "last name
      orgtx       TYPE t527x-orgtx,   "dept
      fte         TYPE p0008-bsgrd,   "fte
      parking(20) TYPE c,
      payslip     TYPE t526-sachn,        "payslip address
      telno       TYPE p0105-usrid_long,  "tel number(p0105-usrty = 0020)
      email       TYPE p0105-usrid_long,  "email (p0105-usrty = MAIL)
      postcode    type p0006-pstlz,
    END OF t_output.
    DATA: it_output TYPE STANDARD TABLE OF t_output INITIAL SIZE 0,
          wa_output TYPE t_output.
    *ALV data declarations
    data: fieldcatalog   type slis_t_fieldcat_alv with header line,
          gd_tab_group   type slis_t_sp_group_alv,
          gd_layout      type slis_layout_alv,
          gd_repid       like sy-repid,
          gt_events      type slis_t_event,
          gd_prntparams  type slis_print_alv,
          gd_count(6)    type n,
          gd_outtext(70) type c,
          gd_lines       type i.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    clear: gd_count.
    GET pernr.
    Infotype 0121 is used to store multiple contracts for personnel.
    Field p0121-hpern contains the personnel number for the main contract.
      PROVIDE * from p0121 between pn-begda and pn-endda.
      Check if main contract
        if p0121-pernr ne p0121-hpern.
          reject.
        endif.
      ENDPROVIDE.
      add 1 to gd_count.
      concatenate 'Processing personnel data'(m10) gd_count into gd_outtext
                separated by ' '.
    Display indicator for employee count
      perform progress_indicator using gd_outtext.
    Retrieve datd from infotypes
      rp_provide_from_last p0000 space pn-begda pn-endda.
      rp_provide_from_last p0001 space pn-begda pn-endda.
      rp_provide_from_last p0002 space pn-begda pn-endda.
      rp_provide_from_last p0006 space pn-begda pn-endda.
      rp_provide_from_last p0008 space pn-begda pn-endda.
      rp_provide_from_last p0014 space pn-begda pn-endda.
    Check post code
      CHECK p0006-pstlz IN so_pcode.  "cp
    Post code
      wa_output-postcode = p0006-pstlz.
    Personnel number
      wa_output-pernr = pernr-pernr.
    Personnel title
      SELECT SINGLE atext
        FROM t522t
        INTO wa_output-anredtxt
       WHERE sprsl EQ sy-langu AND
             anred EQ p0002-anred.
    First name
      wa_output-fname = p0002-vorna.
    Last name
      wa_output-lname = p0002-nachn.
    Organizational Unit text (dept)
      SELECT SINGLE orgtx
        FROM t527x
        INTO wa_output-orgtx
       WHERE sprsl EQ sy-langu AND
             orgeh EQ p0001-orgeh AND
             endda GE sy-datum.
    FTE
      wa_output-fte = p0008-bsgrd.
    Parking / travel deducted?
      CASE p0014-lgart.
        WHEN '7180' OR '7181' OR '7182'.
          wa_output-parking = text-002.
        WHEN '7183'.
          wa_output-parking = text-001.
        WHEN '7171' OR '7172' or '7173' or '7174' or
             '7175' or '7176' or '7177' or '7178'.
          wa_output-parking = text-003.
      ENDCASE.
    Payslip Address
      SELECT SINGLE sachn
        FROM t526
        INTO wa_output-payslip
       WHERE werks EQ p0001-werks AND
             sachx EQ p0001-sacha.
      PROVIDE * from p0105 between pn-begda and pn-endda.
      Telephone numbers
        if p0105-usrty = '0020'.
           wa_output-telno = p0105-usrid_long.
        endif.
      Email address
        if p0105-usrty = 'MAIL'.
           wa_output-email = p0105-usrid_long.
        endif.
      ENDPROVIDE.
      append wa_output to it_output.
      clear: wa_output.
    *END-OF-SELECTION.
    END-OF-SELECTION.
    describe table it_output lines gd_lines.
    if gd_lines gt 0.
      perform build_fieldcatalog.
      perform build_layout.
      perform display_alv_report.
    else.
      message i003(zp) with 'No records found'.
    endif.
    *&      Form  PROGRESS_INDICATOR
          Displays progress indicator on SAP screen
    form progress_indicator using p_text.
      call function 'SAPGUI_PROGRESS_INDICATOR'
          exporting
            PERCENTAGE = 0
               text       = p_text.
    endform.                    " PROGRESS_INDICATOR
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
      fieldcatalog-fieldname   = 'PERNR'.
      fieldcatalog-seltext_m   = 'Personnel No.'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
    fieldcatalog-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'ANREDTXT'.
      fieldcatalog-seltext_m   = 'Title'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'FNAME'.
      fieldcatalog-seltext_m   = 'First Name'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'LNAME'.
      fieldcatalog-seltext_m   = 'Last Name'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'ORGTX'.
      fieldcatalog-seltext_m   = 'Department'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'FTE'.
      fieldcatalog-seltext_m   = 'FTE'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PARKING'.
      fieldcatalog-seltext_m   = 'Parking/Metrocard'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PAYSLIP'.
      fieldcatalog-seltext_m   = 'Payslip Add.'.
      fieldcatalog-col_pos     = 7.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'TELNO'.
      fieldcatalog-seltext_m   = 'Telephone'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EMAIL'.
      fieldcatalog-seltext_m   = 'E-mail'.
      fieldcatalog-col_pos     = 9.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'POSTCODE'.
      fieldcatalog-seltext_m   = 'Post code'.
      fieldcatalog-col_pos     = 10.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_layout-zebra             = 'X'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_output
           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.
    endform.                    " DISPLAY_ALV_REPORT
    The following program allows you to retrieve all the individuall sickpay values for a given period and person.This data is then exported to memory using the memory id entered on the selection screen. This thereforeallows you to submit this program from another program and then process the data within the calling programby importing the data from memory.  Click here for example .
    Report:  ZSXP_ABSENCE_DATA                                           **                                                                      ** Author:  www.SAPdev.co.uk                                            **                                                                      ** Date  :  12.02.2003                                                  **                                                                      ** Description: Retrieve maternaty/Sickness Absence data*                                                                      ************************************************************************REPORT ZSXP_ABSENCE_DATA      LINE-SIZE 100 NO STANDARD PAGE HEADING                MESSAGE-ID 5g.TABLES: t554s, pernr, pcl1, pcl2.INCLUDE rpclst00.INCLUDE rpc2rx09.                      "Payroll results datadefns-Intl.INCLUDE rpc2rxx0.                      "Payroll results datadefns-Intl.INCLUDE rpc2rgg0.                      "Payroll results datadefns-GBINCLUDE rpcfdcg0.                      "Payroll results datadefns-GBINCLUDE rpcdatg0.INCLUDE rpc2cd00.                      "Cluster Directory defns.INCLUDE rpc2ps00.                      "Cluster: Generierte SchematasINCLUDE rpc2pt00.INCLUDE rpcfdc10.INCLUDE rpcfdc00.INCLUDE rpppxd00.INCLUDE rpppxd10.INCLUDE rpcfvp09.INCLUDE rpcfvpg0.INCLUDE rpppxm00.INFOTYPES: 0001,                       "Organisational assignment           0002,                       "Personal Data           0003,                       "Payroll Status           0088,                                            "SMP           2001,                       "Absences           0086.                       "SSP/SMP ExlclusionsDATA:   ssp_weeks TYPE p DECIMALS 2 VALUE 0.DATA:   ssp_total TYPE p DECIMALS 2 VALUE 0,        total_val TYPE p DECIMALS 2 VALUE 0,        smp_weeks TYPE p DECIMALS 2 VALUE 0,        smp_value TYPE p DECIMALS 2 VALUE 0,        gross     LIKE pc207-betrg,        dis_gross TYPE p DECIMALS 2 VALUE 0.DATA: gd_begda(10) TYPE c,      gd_endda(10) TYPE c.DATA: ld_orgtxt LIKE t527x-orgtx.DATA: name(30).DATA: BEGIN OF itab OCCURS 0,      pernr LIKE p0002-pernr,      perid LIKE p0002-perid,      name  LIKE name,      END OF itab.TYPES: BEGIN OF t_report,   pernr   TYPE pernr-pernr,   "8   name    TYPE name,          "30   awart   TYPE p2001-awart,   "4   begda   TYPE p2001-begda,   "10   endda   TYPE p2001-endda,   "10   wkspaid TYPE p DECIMALS 2,  "10   amtpaid TYPE p DECIMALS 2,  "10  END OF t_report.DATA: it_report TYPE STANDARD TABLE OF t_report INITIAL SIZE 0,      wa_report TYPE t_report.DATA: moabw LIKE t001p-moabw.DATA: printheader TYPE i VALUE 1,      gd_success  TYPE i. NCALE declarationsTYPES : BEGIN OF pfra0_pcale,           annee(4) TYPE c.        INCLUDE STRUCTURE pcint.TYPES : END OF pfra0_pcale.TYPES : pfra0_tab_pcale  TYPE  pfra0_pcale  OCCURS 0.DATA:  it_ncale TYPE STANDARD TABLE OF pcnat INITIAL SIZE 0,       wa_ncale TYPE pcnat,       it_pcale TYPE  pfra0_tab_pcale,       pcale  TYPE  pfra0_tab_pcale.* SMP/SSP absence datadata begin of it_msa occurs 0.        include structure pc27j.data end of it_msa.parameters: p_memid type char30.************************************************************************STAR-OF-SELECTIONSTART-OF-SELECTION.gd_begda = pn-begda.gd_endda = pn-endda.gd_begda6(2) = '01'.gd_endda6(2) = '01'.refresh: it_msa.clear:   it_msa.GET pernr.*    PERFORM IMPORT_PC USING GD_SUCCESs.  PERFORM get_rgdir.  while gd_begda le gd_endda.    PERFORM get_new_rg USING gd_begda.    CALL FUNCTION 'CALCULATE_DATE'        EXPORTING*             DAYS        = '0'             MONTHS      = '1'             START_DATE  = gd_begda        IMPORTING             RESULT_DATE = gd_begda.  endwhile.  msa[] = it_msa[].  EXPORT msa TO MEMORY ID p_memid.&---------------------------------------------------------------------&      Form  GET_RGDIR&-------------------------------------------------------------------FORM get_rgdir.  rp-init-buffer.  CLEAR rgdir.  REFRESH rgdir.  MOVE pernr-pernr(8) TO cd-key-pernr.  rp-imp-c2-cd.  IF rp-imp-cd-subrc = 0.                                "rgdir success    SORT rgdir BY seqnr ASCENDING.    CLEAR rgdir.  ENDIF.ENDFORM.-----------------------------------------------------------------**       FORM get_new_rg                                               **-----------------------------------------------------------------**       ........                                                      **-------------------------------------------------------------------**  >  search_date                                                   **-----------------------------------------------------------------FORM get_new_rg USING search_date.  DATA: rg_day TYPE d,        rgbeg  TYPE d,        rgend  TYPE d.  MOVE: search_date TO rg_day.  CLEAR: msa.  LOOP AT rgdir WHERE void NE 'V'.    MOVE: rgdir-fpbeg TO rgbeg,          rgdir-fpend TO rgend.    IF ( rgbeg <= rg_day ) AND       ( rgend >= rg_day ) AND       rgdir-srtza = 'A'.        "Must be periods actual set of results      EXIT.    ENDIF.  ENDLOOP.  UNPACK rgdir-seqnr TO rx-key-seqno.  MOVE pernr-pernr(8) TO rx-key-pernr(8).  rp-imp-c2-rg.  append lines of msa to it_msa.  IF rp-imp-rg-subrc <> 0.   rg fail  ELSE.*   rg success  ENDIF.ENDFORM.Text elements------------------------------------------------------*  001     Sickness History for SSP 1*  002     Employee Name.*  003     National Insurance Number.*  004     Payroll Number.*  005     Sickness Start Date*  006     Sickness End Date*  007     Number of weeks paid*  008     system-error:*  009     No SSP / SMP record found*  010     Absence type*  011     No. weeks paid*  012     Amount*  013     Organisation Unit.*  T01     Sickness Absence typesSelection texts--------------------------------------------------------* SO_SAP          SAP Att./absence types* SO_SMP          SMP Att./absence types* SO_SPP          SPP Att./absence types* SO_SSP          SSP Att./absence types
    Uses Logical database 'PNP'(entered in program attributes) to retrieve various personnel data and downloadit to an excel / tab delimited file.
    .......................................................................: Report:  ZDOWNEMPDATA                                               ::                                                                     :: Author:  www.SAPDev.co.uk                                           ::                                                                     :: Date  :  2004                                                       ::                                                                     :: Description: Downloads employee data to TAB delimited flat files    ::                                                                     ::.....................................................................:.......................................................................: Report:  ZDOWNEMPDATA                                               ::                                                                     :: Author:  www.SAPDev.co.uk                                           ::                                                                     :: Date  :  2004                                                       ::                                                                     :: Description: Downloads employee data to TAB delimited flat files    ::                                                                     ::.....................................................................:REPORT  zdownempdata                                         .INFOTYPES: 0000, 0001, 0007, 0008, 0121, 0615.NODES: pernr.TABLES: t001p.TYPES: BEGIN OF t_employee,*        INCLUDE STRUCTURE hrms_biw_io_occupancy.  begda     TYPE begda,  endda     TYPE endda,  pernr     TYPE pernr_d,  rfpnr     TYPE rfpnr,  bukrs     TYPE bukrs,  werks     TYPE persa,  btrtl     TYPE btrtl,  persg     TYPE persg,  persk     TYPE persk,  orgeh     TYPE orgeh,  stell     TYPE stell,  plans     TYPE plans,  kokrs     TYPE mast_coar,  kostl     TYPE mast_cctr,  abkrs     TYPE abkrs,  molga     TYPE molga,  trfar     TYPE trfar,  trfgb     TYPE trfgb,  trfkz     TYPE trfkz,  trfgr     TYPE trfgr,  trfst     TYPE trfst,  bsgrd     TYPE bsgrd,  ansal     TYPE ansal_15,  ancur     TYPE ancur,  empct     TYPE empct,  stat2     TYPE stat2,  ncsdate     TYPE hiredate,  sltyp     TYPE p_sltyp,  slreg     TYPE p_slreg,  slgrp     TYPE p_slgrp,  sllev     TYPE p_sllvl,  ansvh     TYPE ansvh,  vdsk1     TYPE vdsk1,  sname     TYPE smnam, END OF t_employee.DATA: it_employee TYPE STANDARD TABLE OF t_employee INITIAL SIZE 0,      wa_employee TYPE t_employee.TYPES: BEGIN OF t_emptexts,*        INCLUDE STRUCTURE hrms_bw_txt_employee.  DATEFROM     TYPE RSDATEFROM,  DATETO     TYPE RSDATETO,  PERNR     TYPE PERSNO,  TXTMD     TYPE EMNAM, END OF t_emptexts.DATA: it_emptexts TYPE STANDARD TABLE OF t_emptexts INITIAL SIZE 0,      wa_emptexts TYPE t_emptexts.TYPES: BEGIN OF t_contract,*        INCLUDE STRUCTURE pa0615.  pernr TYPE p0615-pernr,  begda TYPE p0615-begda,  endda TYPE p0615-endda,  aedtm TYPE p0615-aedtm,  ctype TYPE p0615-ctype,  cbeg  TYPE p0615-cbeg,  cend  TYPE p0615-cend, END OF t_contract.DATA: it_contract TYPE STANDARD TABLE OF t_contract INITIAL SIZE 0,      wa_contract TYPE t_contract.DATA: it_tabemp TYPE filetable,      gd_subrcemp TYPE i,      it_tabempt TYPE filetable,      gd_subrcempt TYPE i,      it_tabcont TYPE filetable,      gd_subrccont TYPE i.DATA: gd_downfile TYPE string.SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.PARAMETERS: p_emp   LIKE rlgrap-filename,            p_empt  LIKE rlgrap-filename,            p_cont LIKE rlgrap-filename.SELECTION-SCREEN END OF BLOCK block1.***********************************************************************at selection-screenAT SELECTION-SCREEN ON VALUE-REQUEST FOR p_emp.  REFRESH: it_tabemp.  CALL METHOD cl_gui_frontend_services=>file_open_dialog    EXPORTING      window_title      = 'Select File'      default_filename  = '.xls'      initial_directory = 'C:\'      multiselection    = ' '  "No multiple selection    CHANGING      file_table        = it_tabemp      rc                = gd_subrcemp.  LOOP AT it_tabemp INTO p_emp.  ENDLOOP.***********************************************************************at selection-screenAT SELECTION-SCREEN ON VALUE-REQUEST FOR p_empt.  REFRESH: it_tabemp.  CALL METHOD cl_gui_frontend_services=>file_open_dialog    EXPORTING      window_title      = 'Select File'      default_filename  = '.xls'      initial_directory = 'C:\'      multiselection    = ' '  "No multiple selection    CHANGING      file_table        = it_tabempt      rc                = gd_subrcempt.  LOOP AT it_tabempt INTO p_empt.  ENDLOOP.***********************************************************************at selection-screenAT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cont.  REFRESH: it_tabcont.  CALL METHOD cl_gui_frontend_services=>file_open_dialog    EXPORTING      window_title      = 'Select File'      default_filename  = '.xls'      initial_directory = 'C:\'      multiselection    = ' '  "No multiple selection    CHANGING      file_table        = it_tabcont      rc                = gd_subrccont.  LOOP AT it_tabcont INTO p_cont.  ENDLOOP.************************************************************************START-OF-SELECTION.START-OF-SELECTION.GET pernr. Selecting the latest infotype record  rp_provide_from_last p0000 space pn-begda pn-endda.  rp_provide_from_last p0001 space pn-begda pn-endda.  rp_provide_from_last p0007 space pn-begda pn-endda.  rp_provide_from_last p0008 space pn-begda pn-endda.  rp_provide_from_last p0121 space pn-begda pn-endda.  rp_provide_from_last p0615 space pn-begda pn-endda.  MOVE-CORRESPONDING p0001 TO wa_employee.  wa_employee-rfpnr = p0121-rfp01. "?????  MOVE-CORRESPONDING p0007 TO wa_employee.  MOVE-CORRESPONDING p0008 TO wa_employee.  MOVE-CORRESPONDING p0000 TO wa_employee.  SELECT SINGLE molga    FROM t001p    INTO wa_employee-molga   WHERE werks EQ p0001-werks AND         btrtl EQ p0001-btrtl.  SELECT SINGLE trfkz    FROM t503    INTO wa_employee-trfkz   WHERE persg EQ p0001-persg AND         persk EQ p0001-persk.  CALL FUNCTION 'HR_ENTRY_DATE'    EXPORTING      persnr                     = pernr-pernr*   RCLAS                      =*   BEGDA                      = '18000101'*   ENDDA                      = '99991231'*   VARKY                      =   IMPORTING      entrydate                  = wa_employee-ncsdate* TABLES*   ENTRY_DATES                = EXCEPTIONS   ENTRY_DATE_NOT_FOUND       = 1   PERNR_NOT_ASSIGNED         = 2   OTHERS                     = 3            .  IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  ENDIF.* append employee data  APPEND wa_employee TO it_employee.  CLEAR: wa_employee.  wa_emptexts-datefrom = p0001-begda.  wa_emptexts-dateto   = p0001-endda.  wa_emptexts-pernr    = p0001-pernr.  wa_emptexts-txtmd    = p0001-ename.* append employee texts data  APPEND wa_emptexts TO it_emptexts.  CLEAR: wa_emptexts.  MOVE-CORRESPONDING p0615 TO wa_contract.* append employee contract data  APPEND wa_contract TO it_contract.  CLEAR: wa_contract.************************************************************************END-OF-SELECTION.END-OF-SELECTION. download employee data  IF NOT p_emp IS INITIAL.    gd_downfile = p_emp.    CALL FUNCTION 'GUI_DOWNLOAD'      EXPORTING        filename              = gd_downfile        filetype              = 'ASC'        write_field_separator = 'X'      TABLES        data_tab              = it_employee.    IF sy-subrc EQ 0.      WRITE:/ 'Employee file downloaded to',              gd_downfile.    ELSE.      WRITE:/ 'There was an error downloading Employee file to',              gd_downfile.    ENDIF.  ENDIF.* download employee texts data  IF NOT p_empt IS INITIAL.    gd_downfile = p_empt.    CALL FUNCTION 'GUI_DOWNLOAD'      EXPORTING        filename              = gd_downfile        filetype              = 'ASC'        write_field_separator = 'X'      TABLES        data_tab              = it_emptexts.    IF sy-subrc EQ 0.      WRITE:/ 'Employee text file downloaded to',              gd_downfile.    ELSE.      WRITE:/ 'There was an error downloading Employee text file to',              gd_downfile.    ENDIF.  ENDIF.* download contract data  IF NOT p_cont IS INITIAL.    gd_downfile = p_cont.    CALL FUNCTION 'GUI_DOWNLOAD'      EXPORTING        filename              = gd_downfile        filetype              = 'ASC'        write_field_separator = 'X'      TABLES        data_tab              = it_contract.    IF sy-subrc EQ 0.      WRITE:/ 'Employee contract file downloaded to',              gd_downfile.    ELSE.      WRITE:/ 'There was an error downloading Employee contract file to',              gd_downfile.    ENDIF.  ENDIF.

  • Can i make changes to standered ldb to z ldb.

    Hi Friends ,
                    Presently iam working with sales tax register , inthe attributes section logical database  is mentioned as BRF(document segmet) , the data is retrived according to document no ,and posting date .
    now i need to retrive the data according to vendor wise , my doubt is, can i copy the logical database  to z ldb and make changes to it , root node for this ldb is bosg . when i am trying to make changes inthe report it is not effecting in any wayz ,. please try to give me the solution , for retriving the data according to vendor wise. in the report the ldb is called by keyword get.

    Hi,
    pardon - it is only spare information you gave.
    A report is linked to a ldb by its properties.
    Moreover you can use a ldb by function ldb_process.
    Perhaps there is another way without changing the ldb.
    First fill an internal table with data you need.
    After that sort it and do your processing.
    Separating I/O from processing is a good approach in general.
    With kind regards
    Walter Habich

  • LDB sample program (Hr abap)

    Hi,
      iam learning HR Abap i want to write a program in ldb's..for example i want to fetch the following
    data P0001-WERKS,P0105-USRID,P0002-CNAME,P0000-STAT2,PA0001-PERNR into one internal table
    in ldb PNP.how to write the code.please send me the sample coding..
    Thx..

    Hi Swetha Rishi,
    TABLES : PERNR.
    * Infpotypes Declartion
    INFOTYPES : 0000,0001,0002,0105.
    * Structure Declartion
    TYPES : BEGIN OF TY_ITAB,
              PERNR TYPE P0001-PERNR ,
              WERKS TYPE P0001-WERKS ,
              CNAME TYPE P0002-CNAME ,
              STAT2 TYPE P0000-STAT2 ,
              USRID TYPE P0105-USRID ,
             END OF TY_ITAB.
    DATA : ITAB TYPE TABLE OF TY_ITAB,
           WA TYPE TY_ITAB .
    START-OF-SELECTION.
    GET PERNR.
    * macro definition
    RP-PROVIDE-FROM-LAST P0001 SPACE PN-BEGDA PN-ENDDA.
    RP-PROVIDE-FROM-LAST P0002 SPACE PN-BEGDA PN-ENDDA.
    RP-PROVIDE-FROM-LAST P0105 SPACE PN-BEGDA PN-ENDDA.
    RP-PROVIDE-FROM-LAST P0000 SPACE PN-BEGDA PN-ENDDA.
    MOVE-CORRESPONDING P0001 TO WA.
    MOVE-CORRESPONDING P0002 TO WA.
    MOVE-CORRESPONDING P0105 TO WA.
    MOVE-CORRESPONDING P0000 TO WA.
    APPEND WA TO ITAB.
    CLEAR WA.
    END-OF-SELECTION.
    SORT ITAB BY PERNR.
    PERFORM TOP-OF-PAGE.
    LOOP AT ITAB INTO WA.
       SHIFT WA-PERNR LEFT DELETING LEADING '0'.
       WRITE : /5 WA-PERNR,
                16 WA-WERKS,
                25 WA-CNAME,
                35 WA-STAT2,
                45 WA-USRID.
    ENDLOOP.
    *&      Form  TOP-OF-PAGE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM TOP-OF-PAGE .
       FORMAT COLOR COL_HEADING ON.
       WRITE : /5 'PERNR',
                16 'WERKS',
                25 'CNAME',
                35 'STAT2',
                45 'USRID'.
       FORMAT COLOR OFF.
    ENDFORM.                    " TOP-OF-PAGE

  • LDB in HR

    hi friends,
              I am having a doubt, why LDB (HR PNP...) is used in HR, and why not Open sql statements for Reports.
              what is the difference between LDB and open sql statement, in what way it is benificial ?
              if possible any one send me documents  how to use LDB in HR ? to this mail id [email protected]
    thank u HR consultants

    LDB - is a SET of programs which provide u its own selection screen and commands to deal with HR data.
    Hence for HR u can prefer LDB instead of SQL..
    u can acheive the same thing via SQL but LDB is more easier as u need not write much code.
    u have to specify in the attributes of the program ,LDb name..
    like PNP,PCH etc..
    here is a sample program using LDB  -
    REPORT  ZPPL_PREVEMPLOYERS   message-id rp
                                 line-size 250
                                 line-count 65.
    *Program logic :- This Report is used to Download all the Previous
    Employer (IT0023) records of the employees
    *eject
    *& Tables and Infotypes                                                *
    tables: pernr.
    infotypes: 0000,
               0001,
               0002,
               0023.
    *eject
    *& Constants                                                           *
    constants: c_1(1)       type c               value '1'   ,
               c_3(1)       type c               value '3'   ,
               c_i(1)       type c               value 'I'   ,
               c_x(1)       type c               value 'X'   ,
               c_eq(2)      type c               value 'EQ'  ,
               c_pl03       like p0001-werks     value 'PL03'.
    *eject
    *& Selection-Screen                                                    *
    parameters: p_file  like rlgrap-filename default 'C:\Temp\ABC.xls',
                p_test  as checkbox default c_x               .
    *eject
    *& Internal tables                                                     *
    Internal Table for Output
    data: begin of t_output occurs 0    ,
           pernr like pernr-pernr       ,
           nachn like p0002-nachn       ,
           vorna like p0002-vorna       ,
           orgeh_stext like p1000-stext ,
           plans_stext like p1000-stext ,
           begda like p0023-begda       ,
           endda like p0023-endda       ,
           land1 like p0023-land1       ,
           arbgb like p0023-arbgb       ,
           ort01 like p0023-ort01   .
    data: end of t_output           .
    *eject
    *& Variables                                                           *
    data: o_stext like p1000-stext,
          p_stext like p1000-stext.
    *eject
    *& Initialization                                                      *
    Initialization.
    Initialize Selection-Screen values
      perform init_selction_screen.
    *eject
    *& AT Selection-screen                                                 *
    at selection-screen .
    Check if Test run selected, download file name should be entered
      if p_test is initial.  "
        if p_file is initial.
          message e016 with 'Please enter file name'
                            'specifying complete path'.
        endif.
      endif.
    *eject
    *& Start-of Selection                                                  *
    Start-of-selection.
    get pernr.
      clear t_output.
    Read Infotype 0
      rp-provide-from-last p0000 space pn-begda pn-endda.
      check pnp-sw-found eq c_1.
    Check if employee is active
      check p0000-stat2 in pnpstat2.      "pernr Active
    Read Infotype 1
      rp-provide-from-last p0001 space pn-begda pn-endda.
      check pnp-sw-found eq c_1.
    check if employee belongs to PL03
      check p0001-werks in pnpwerks.  "belongs to PL03
    Check if emp belongs to Active Group
      check p0001-persg in pnppersg.
    Read Infotype 2
      rp-provide-from-last p0002 space pn-begda pn-endda.
      check pnp-sw-found eq c_1.
    Read Org Unit Text.
    CALL FUNCTION 'HR_READ_FOREIGN_OBJECT_TEXT'
         EXPORTING
              OTYPE                   = 'O'
              objid                   = p0001-orgeh
              begda                   = p0001-begda
              endda                   = p0001-endda
              reference_date          = p0001-begda
         IMPORTING
              object_text             = o_stext
          EXCEPTIONS
              nothing_found           = 1
              wrong_objecttype        = 2
              missing_costcenter_data = 3
              missing_object_id       = 4
              OTHERS                  = 5.
    *Read Position Text.
    CALL FUNCTION 'HR_READ_FOREIGN_OBJECT_TEXT'
         EXPORTING
              OTYPE                   = 'S'
              objid                   = p0001-plans
              begda                   = p0001-begda
              endda                   = p0001-endda
              reference_date          = p0001-begda
         IMPORTING
              object_text             = p_stext
         EXCEPTIONS
              nothing_found           = 1
              wrong_objecttype        = 2
              missing_costcenter_data = 3
              missing_object_id       = 4
              OTHERS                  = 5.
    Gather all the required information related to the emp
      move: pernr-pernr to t_output-pernr,
            o_stext to t_output-orgeh_stext,
            p_stext to t_output-plans_stext,
            p0002-nachn to t_output-nachn,
            p0002-vorna to t_output-vorna.
    Gather previous Employee details
      loop at p0023.
        move-corresponding p0023 to t_output.
        append t_output.
      endloop.
    *eject
    *& End-of Selection                                                    *
    end-of-selection.
      perform print_report.
    Downlaod the file
      if not t_output[] is initial.
        if p_test eq space.
          perform download_file.
        endif.
      else.
        write: 'No records selected' color col_negative.
      endif.
    *eject
    *& Top-of-page                                                         *
    Top-of-page.
    Print Header
      perform print_header.
    *eject
    *&      Form  download_file
    Description :
    FORM download_file .
      DATA: full_file_name    TYPE string,
            z_akt_filesize    TYPE i     .
      full_file_name = p_file.
    download table into file on presentation server
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                = full_file_name
          filetype                = 'DAT'
          NO_AUTH_CHECK           = c_x
          codepage                = '1160'
        IMPORTING
          FILELENGTH              = z_akt_filesize
        CHANGING
          data_tab                = t_output[]
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          not_supported_by_gui    = 22
          error_no_gui            = 23
          OTHERS                  = 24.
      IF  sy-subrc               NE        0.
        MESSAGE e016 WITH 'Download-Error; RC:' sy-subrc.
      ENDIF.
    ENDFORM.                    " download_file
    *eject
    *&      Form  print_report
    *Description:
    FORM print_report .
      data: i       type i,
            w_count type i.
      sort t_output.
    Print the report
      loop at t_output.
        i = sy-tabix mod 2.
        if i eq 0.
          format color col_normal intensified on.
        else.
          format color col_normal intensified off.
        endif.
        write:/1     t_output-pernr          ,
               10     t_output-vorna(25)     ,
               35    t_output-nachn(25)      ,
               61   t_output-orgeh_stext     ,
               102  t_output-plans_stext     ,
               143  t_output-begda           ,
               154   t_output-endda          ,
               168   t_output-land1          ,
               178   t_output-arbgb(40)      ,
               219   t_output-ort01          ,
               249   space              .
      endloop.
      uline.
      Describe table t_output lines w_count.
      Skip 2.
      Write:/ 'Total No of Records Downloaded: ' color col_total,
              w_count.
    ENDFORM.                    " print_report
    *eject
    *&      Form  print_header
    *Description:
    FORM print_header .
      skip 1.
      Uline.
      format Intensified on color col_heading.
      write:/1   'Pers. #'        ,
             10   'Last Name'     ,
             35   'First Name'    ,
             61   'Org Unit'      ,
             102  'Position'      ,
             143  'Beg Date'      ,
            154   'End Date'      ,
            168   'Cntry Key'     ,
            178   'Prev Employer' ,
            219  'City'           ,
            249   space          .
      format intensified off color off.
      uline.
    ENDFORM.                    " print_header
    *eject
    *&      Form  init_selction_screen
    *Description:
    FORM init_selction_screen .
      refresh: pnpwerks,
               pnppersg,
               pnpstat2.
      clear:   pnpwerks,
               pnppersg,
               pnpstat2.
      pnpwerks-sign   = c_i.
      pnpwerks-option = c_EQ.
      pnpwerks-low    = c_pl03.
      append pnpwerks.
      pnppersg-sign   = c_i.
      pnppersg-option = c_EQ.
      pnppersg-low    = c_1.
      append pnppersg.
      pnpstat2-sign   = c_i.
      pnpstat2-option = c_EQ.
      pnpstat2-low    = c_3.
      append pnpstat2.
    ENDFORM.                    " init_selction_screen

  • Regarding ldb pnpce and my customized infotype

    i have created my own infotype name '9777' and with the help of
    'hr_infotype_operation' i m inserting the data into this infotype
    now i m creating a report in which i m using ldb pnpce,
    but after the execution of GET PERAS the infotype table p9777
    is not populating but except this other infotypes tables are populating
    ,plz help me to sort out this problem.

    hi after the bapi did you used the commit .
    use this for the creation of an employee
    BAPI_EMPLCOMM_CREATE
    o give  your code here

  • LDB..

    Hii All,
    Any one pls send me some interview ques on LDBs??
    Regards,
    Kavitha

    Hi Kavitha,
    pls find here some general ques for interview,
    1.     Preparation of the data records by the L.D.B and reading of the data records in the actual report are accomplished with the command pair Put and Get.
    2.     The three main elements of LDB are Structure, Selections, and Database Program.
    3.     In LDB what determines hierarchy of the tables?
    Structure.
    4.     In general what are the two ways in which one can retrieve data from tables?
    Using Select statements, Database Program.
    5.     With LDB one can modify the pre-generated selection screen to their needs (T/F).
    Yes.
    6.     Logical databases are programs that read data from Database tables (Dictionary Structures).
    7.     The event Get<table name> LATE process all tables that are hierarchically superior to the <table name>. (True/False)
    False.  It processes all tables that are hierarchically inferior to the <table name>.
    8. The Database Program of LDB is a collection of SUBROUTINES, which selects data and passes it to the report.
    9.     The layout of the Database program is determined by both Structure and Selections.
    10.      The order in which data is made available to the report depends on Structure of the LDB.
    11.     Apart from the structure and selections of the LDB the GET statements in the report determines the behavior of the database at runtime.
    12.     Node at the highest level in the structure is known as Root.
    13.     There can be more than one node at the highest level in the structure. (T/F)
    False.  One can define only one node at the highest level in the structure on LDB.
    14.     All nodes in the structure of LDB need not be defined in the ABAP/4 Dictionary (T/F).
    False.  One has to define all nodes in the Dictionary or one has to select all nodes that are defined in the Dictionary.
    15.     It is not possible to use ABAP/4 Dictionary Structures without an underlying database using LDB. (T/F)
    True.  One can use additionally related tables, along with the tables defined in the structure of LDB.
    16.     Dynamic selections allow the user to define further selections for database access in addition to the selection criteria already defined in the LDB selections.
    17.     Check statement can be used along with the event GET in the report for checking the selections, which are not table-specific values.
    18.     In sense of Database Management System (DBMS) LOGICAL DATABASE is a database Structure. (T/F).
    False.
    19.     It is not necessary to maintain the Parent-Child relationship between the tables in Logical Database Structure. (T/F)
    False.  One has to maintain the Parent-Child relationship.
    20.     Is it possible to extract data from tables without using the event ‘GET’ in the report with an appropriate LDB. (T/F).
    False.  One can extract data from tables using Select statements in a report, though the report is having a LDB attribute.
    21.     What sorts of tables one can se in designing the hierarchy of a LDB?
    Tables, which are having Foreign Key relations.
    22.     A report program, which uses only SELECT statements, is called SQL Report.
    23.     One cannot use SELECT statements in a report program linked to a Logical Database (T/F).  False.
    24.     Is it true that the Logical Database reads the data from the database tables using Select Statements (T/F).
    Yes. We are coding that in Database part of LDB.
    25.     In a report with an LDB attribute, you do not have to define how the information should be retrieved from the database tables, but only how the data should be represented on the screen. (T/F).
    True.
    26.     One can use the event GET in a report without LDB attribute. (T/F).
    False.
    27.     The last character of the LDB name denotes Application.
    28.     The structure of Logical Databases reflects the Foreign Key dependencies of hierarchical tables in the SAP system.
    29.     It is mandatory that for each table in the LDB hierarchy there should exist one GET statement in the report. (T/F).
    False.  It is not necessary.
    30.     What happens if a report does not contain a GET statement for a particular node of a Logical Database.
    Process will transfer to the next event.
    31.     In a Logical Database, one can define input fields on the selection screen with Select-Options and Parameters statements.
    32.     Suppose a logical database program contains the following lines:
    SELECT-OPTIONS CONNID FOR SPFLI-CONNID.
    PARAMETERS CARRID LIKE SFLIGHT-CARRID FOR TABLE SFLIGHT.
    What will be the output, for the above two statements?
    Only select-options connid for spfli-carrid will be displayed on the screen.
    33.     Consider a report with F1S attribute, what will be the output for the following code.  Whether you will get the data from spfli and sflight or not, with corresponding tables statement,
         GET SPFLI.
         GET SFLIGHT.
         Write:/ spfli-carrid, spfli-connid, sflight-fldate, sbook-bookid.
         Yes, you will get the data from spfli and sflight.
    34.     Consider a report with F1S attribute, what will be the output of the following code.  Whether you will get the data from sbook or not, with corresponding tables statement.
    GET SPFLI.
    GET SFLIGHT.
    Write:/ spfli-carrid, spfli-connid, sflight-fldate, sbook-bookid.
    You cannot extract data from sbook.
    35.     Identify any errors in the following code and correct the same, and what will be the output.  If there exists corresponding tables statement, for spfli, sflight, sbook.
    GET SPFLI.
    GET SBOOK.
    Write:/ spfli-carrid, spfli-connid, sflight-fldate, sbook-bookid, sbook-class.
    No syntax errors.  You will get data from all the three tables.
    36.     Does the following two statements do the same task?  If so which one takes less time and which one is recommended.
         Select * from spfli where spfli-carrid = ‘LH’ and spfli-connid = ‘400’.
         Endselect.
         Select * from spfli. Check: spfli-carrid = ‘LH’ and spflid-connid = ‘400’.
         Endselect.
        -Yes they will do the same task.  Second Select statement takes less time and is recommended.
    37.     If you want to improve the response time (time to access data) Logical Databases permits you to achieve this using VIEWS.
    38.     Is there any upper limit (max) to the possible number of nodes in a logical database structure? If so what is the limit?
    Yes, there is an upper limit for defining number of nodes in a Logical Database Structure.
    Maximum nodes = 1200 / length where length = max. Length of name in the structure.
    39.     In the structure of Logical Database nodes at different levels are displayed in the same columns. (T/F) If false what types of nodes are displayed in the same columns. If true what type of nodes are not displayed in the same columns.
    False.  Nodes at same levels are displayed in the same columns.
    40.     What are the advantages of Logical Databases?
    It offers an easy-to-use selection screens.  You can modify the pre-generated selection screen to your needs.  It offers check functions to check whether user input is complete, correct, and plausible.  It offers reasonable data selections.  It contains central authorization checks for data base accesses.  Enhancements such as improved performance immediately apply to all report programs that use the logical database.
    41.     Though all the ABAP/4 Dictionary Structures that exists in the structure of the LDB, being defined in Database Program, we are defining the Dictionary Structures in the Report.  What is the reason for such declaration?
    By declaring so we are providing work areas for data passing between Logical Database and Report.  In addition, the logical database configures the selection screen depending on the selection of database tables.
    42.     Is it mandatory to declare all the tables in Report by the key word tables for all the tables that exist in the structure of LDB, and are being defined in the Database part of LDB.
    No, It is not mandatory to declare all tables in report.
    <b>
    Rewards points if useful</b>
    rgrds
    shazia

Maybe you are looking for

  • How to find out what is causing an error in a BPM process

    I have a very basic question and I can't figure it out from help.sap.com I have a BPM process deployed to a SAP NW Java BPM 7.40 system. It can be triggered with a web service call. It goes into error immediately. I go to NW Administrator > Operation

  • My Time Capsule no longer backups my MacBook automatically.

    I use my Time Capsule to back up two MacBook Pro's. It seems to work fine one moment and then not at all the next moment. For example, several days ago I was using both MadBooks and they were being backed up regularly by the time capsule. Yesterday a

  • Need to repair Rosetta

    In an attempt to free up some hard drive space i was searching the net and came upon this site for a program called Monolingual http://monolingual.sourceforge.net/ The program claimed to remove unnecessary languages from my mac and in turn free up sp

  • Alternative items during MRP run

    Hi,    I have seen discussion on alternative items in BOM. Thanks for all for sharing your knowledge. I knew alternative items will be choosen while creating / release of production order (material availability check) Requirement:       For material

  • Converting String to ISO-8859-1 html charset

    i want to convert string to ISO-8859-1 html charset or vice versa For example i need to replace "ö" as  "ö" How can i do that? http://www.unicodetools.com/unicode/utf8-to-latin-converter.php