Skip to Content
author's profile photo Former Member
Former Member

Facing problem in Fetching Employee details

Hello All,

i need to write a abap coding to fetch the employee details from the corresponding table,i worte a code but its is not fetching the details of the employess in to the output,am sending my code along with this thread its great if any body help me out in ths regard,thanks in advance...

************************************************************************

  • NAME : Chandeep Singh

  • DESCRIPTION : TO GENERATE SIMPLE REPORT USING HR ABAP

  • LOGICAl DATABASE- PNP .

  • ************************************************************************

    REPORT zchandeep_hr_prog_1

    LINE-SIZE 200 .

    ****************************

    *Database Table

    ****************************

    TABLES: pernr, " Pernr structure for Logical database

    pa0001, " Actions

    pa0002. " Personnel Info

    ****************************

    *Infotypes

    ****************************

    INFOTYPES: 0001, " Actions

    0002. " personnel info

    ****************************

    *Variable Declaration

    ****************************

    DATA: form_nam LIKE p0001-ename,

    v_age(5) TYPE c, "variable for calculating age in days

    v_ctr1 TYPE i VALUE 0, "counter

    v_ctr2 TYPE i VALUE 0, "counter

    var(5) TYPE c , " variable to store btrtl

    var1(5) TYPE c . " variable to store werks

    *****************************

    *Internal Table Decalartion

    *****************************

    DATA: BEGIN OF i_tab1 OCCURS 0,

    pernr LIKE pa0001-pernr, "employee number

    ename LIKE pa0001-ename, "employee name

    begda LIKE pa0002-begda, "employee join date

    werks LIKE pa0001-werks, "personnel area

    btrtl LIKE pa0001-btrtl, "personnel sub area

    persg LIKE pa0001-persg, "employee group

    persk LIKE pa0001-persk, "employee sub-group

    plans LIKE pa0001-plans, "position

    gbdat LIKE p0002-gbdat, "date of birth

    END OF i_tab1.

    ******************************

    *START-OF-SELECTION

    ******************************

    START-OF-SELECTION .

    GET pernr .

    rp-provide-from-last p0001 space pn-begda pn-endda . " Macro for IFT-0001

    rp-provide-from-last p0002 space pn-begda pn-endda . " Macro for IFT-0002

    **--> Populate internal table

    MOVE p0001-pernr TO i_tab1-pernr .

    MOVE p0001-ename TO i_tab1-ename .

    MOVE p0002-begda TO i_tab1-begda .

    MOVE p0001-werks TO i_tab1-werks .

    MOVE p0001-btrtl TO i_tab1-btrtl .

    MOVE p0001-persg TO i_tab1-persg .

    MOVE p0001-persk TO i_tab1-persk .

    MOVE p0001-plans TO i_tab1-plans .

    MOVE p0002-gbdat TO i_tab1-gbdat .

    **--> Append data to internal table

    APPEND i_tab1 .

    CLEAR i_tab1 . " Clear header I_TAB1******************************

    *END-OF-SELECTION

    ******************************

    END-OF-SELECTION.

    *****sorting the internal table on personnel area & personnel sub-area

    SORT i_tab1 BY werks btrtl.

    ******************************

    *TOP_OF_PAGE

    ******************************

    PERFORM top_of_page.

    ******************************

    *Output Display

    • LOOP AT I_TAB1.

    *for calculating the age in days

    v_age = sy-datum - i_tab1-gbdat.

    *control break on Personal Sub Area

    LOOP.

    AT NEW pnpbtrtl .

    IF sy-tabix NE 1.

    FORMAT COLOR COL_NORMAL ON.

    WRITE:/5 'Total Number of Employees for personnel Sub-Area:',

    var , 'is ',

    v_ctr1.

    CLEAR v_ctr1.

    FORMAT COLOR OFF.

    ENDIF.

    ENDAT .

    ENDLOOP.

    **Control Break on personnel Area

    LOOP.

    AT NEW pnpwerks.

    IF sy-tabix NE 1.

    FORMAT COLOR COL_TOTAL ON.

    WRITE:/5 'Total Number of Employees for Personal Area: ',

    var1 ,'is ', v_ctr2. "color col_total. CLEAR V_CTR2.

    SKIP 1.

    FORMAT COLOR OFF.

    ENDIF.

    ENDAT .

    WRITE:/5

    i_tab1-pernr, "personnel number

    16 i_tab1-ename, "emp name

    47 i_tab1-begda, "join date

    60 v_age, "age in days

    74 i_tab1-werks, "P area

    84 i_tab1-btrtl, "P sub Area

    94 i_tab1-persg, "emp group

    104 i_tab1-persk, "emp sub group

    114 i_tab1-plans. "position

    v_ctr1 = v_ctr1 + 1.

    v_ctr2 = v_ctr2 + 1.

    var = i_tab1-btrtl .

    var1 = i_tab1-werks .

    ENDLOOP.

    &----


    *& Form top_of_page

    &----


    • Header Output

    ----


    ----


    FORM top_of_page.

    FORMAT COLOR COL_HEADING ON.

    WRITE:/5 'Employee',

    16 'Employee',

    47 'Join Date',

    62 'Age',

    74 'Personal',

    84 'Personal',

    94 'Employee',

    104 'Employee',

    114 'Position ',

    /5 'Number',

    16 'Name',

    60 '(In Days)',

    74 'Area',

    84 'Sub-Area',

    94 'Group',

    104 'Sub-Group'.

    FORMAT COLOR OFF.

    SKIP 1.

    ENDFORM. " top_of_page

    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    2 Answers

    • author's profile photo Former Member
      Former Member
      Posted on May 26, 2009 at 06:50 AM

      After tables pernr.

      write this code :

      GET PERNR.

      and check the program

      Regards,

      Srinivas

      Add a comment
      10|10000 characters needed characters exceeded

    • author's profile photo Former Member
      Former Member
      Posted on May 26, 2009 at 07:40 AM

      Hi,

      i have checked ur coding...after perform top-of-page....

      just try like

      LOOP AT i_tab1.

      WRITE:/5 i_tab1-pernr, 16 i_tab1-ename..........etc

      ENDLOOP.

      Add a comment
      10|10000 characters needed characters exceeded

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.