Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding code in ABAP Query(ABAP HR)

Former Member
0 Kudos

I have created an ABAP Query for getting the Absence details of employee within a specified period.I am populating the fields

Employee number, Organization Unit,Absence start date,Absence hours, Absence enddate.

If an employee is in leave for 10 days, this information will be stored in PA2001 table,and this table is not Organization specific.

During the specified period(20 days), if an employee is under two Organization units(5 days in 1st Org Unit,15 days in 2nd Org Unit). The query is extracting two records for the same employee, because of two Organization units. And while populating the data, the query is getting the Absence information from PA2001 table, and this is causing overlapping of data. So it is showing the Absence details for that employee as 40 days(20 days in 1st Org Unit and 20 days in 2nd Org Unit,Instead of total 20 days). So i would like to add validation over here after extraction of data from the PA2001 table,before displaying the data.

I have tried adding the code in the infoset, at END OF SELECTION Event,but i am not able to change the list, as i am not able to access the tables used by the Query.

Can anybody suggest me where to add the code in the Query, so that i will be able to solve this issue, instead of changing the code in the Report program generated by the Query.

3 REPLIES 3

former_member186143
Active Contributor
0 Kudos

you can look at BAPI_PTIMEOVERVIEW_GET

this gives the output back for the selected period so you don't get alle the records back from you're pa2001 table. (only this overview doesn't take into considerationd the distiction the difference between leave and illness)

further on if you consider using the pa2001 table you can loop through the begda and endda and add 1 day for each record and programm the logic how you want to intrepet each day you'reself

I use the data from perws which comes from the function HR_PERSONAL_WORK_SCHEDULE

(which is also used in the BAPI mentioned above)

and from PA0001 you can retrieve how long somebody was in 1 org unit !!


  LOOP AT it_2001 WHERE begda BETWEEN i_begda AND i_endda
                    OR endda BETWEEN i_begda AND i_endda.
      h_datum = it_2001-begda.

      IF it_2001-awart BETWEEN '0100' AND '0199'.
        WHILE h_datum <= it_2001-endda.
          READ TABLE it_perws WITH KEY datum = h_datum.
          IF sy-subrc = 0.

* you're logic

   
          ENDIF.
          CALL FUNCTION 'FKK_DTE_ADD'
            EXPORTING
              i_base_date               = h_datum
             i_periode                 = 'D'
             i_period_factor           = 1
*       I_USE_FACCAL              = ' '
*       I_WORKDAY_INDICATOR       = '-'
            IMPORTING
              e_datum                   = h_datum
*     EXCEPTIONS
*       ERROR_OCCURED             = 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.

        ENDWHILE.

kind regards

arthur de smidt

Edited by: A. de Smidt on Jul 16, 2008 8:47 AM

Former Member
0 Kudos

Hi Arthur,

Can you please tell me where do i need to add the code in the ABAP Query, for getting the correct absence data.

Regards,

Jaya

0 Kudos

do you mean that you build a query with sq01 ?? or build an abap programm ??

and as mentionend get the period for each org unit from PA0001.

is it not an easy programm to build but the bapi mentioned makes it a lot easier (but you can't use that in sq01) I think you can better write an abap programm for this

kind regards

arthur de smidt