Monday, June 1, 2015

0EMPLOYEE_ATTR Data Source Enhancements

As a BW Consultant, in your project you may require to enhancement the standard master data info objects as per your business requirements. This happens more often in HR space. Here I am providing you with an example of how easily you can enhance 0EMPLOYEE_ATTR data source with additional attributes.

I will not list all the necessary steps involved in this process. but i will provide you a working ABAP user exit code which you can use as a reference in your projects.




I've the requirement to enhance 0EMPLOYEE_ATTR data source in ERP side to extract the following additional information.

Pic-1 - Employee Attributes Data Source

As you can see from the above pic-1 i would like to enhance 0employee_attr data source with these additional attributes to make the data more meaningful. My scenario is to identify these additional attributes when an employee is acting on a different position (higher duties).






I wrote my ABAP code in an include program instead of directly in the CMOD include. 


*----------------------------------------------------------------------*
*   INCLUDE ZBW_EXIT_0EMPLOYEE_ATTR                                    *
*----------------------------------------------------------------------*
CONSTANTS:
           c_missing(10)    VALUE '-1',
           c_end_date       LIKE sy-datum VALUE '99991231'.


DATA: wa_emp  LIKE hrms_biw_io_occupancy,   "Work area
      wa_p509 LIKE pa0509,
      v_sobid LIKE hrp1001-sobid,          "Object ID
      w_hda_exist(1).                       "HD flag

DATA: w_seqno(3)             TYPE n,
      w_salary(5)            TYPE p DECIMALS 2,
      w_ind                  LIKE p0008-ind01.

DATA: w_lga01 LIKE p0008-lga01.

* Annual salary wage type details
DATA: BEGIN OF t_ptbindbw OCCURS 0,
        seqnr(3) TYPE n.
        INCLUDE STRUCTURE ptbindbw.
DATA: END OF t_ptbindbw.

CLEAR: wa_emp.


LOOP AT i_t_data INTO wa_emp.
  l_tabix = sy-tabix.

* Clear the HDA exist flag
  clear: w_hda_exist.

* Check if emp has a higher duty entry in PA0509.
  CLEAR: wa_p509.
  SELECT SINGLE * FROM pa0509 INTO wa_p509
         WHERE pernr = wa_emp-pernr
           AND begda LE wa_emp-endda
           AND endda GE wa_emp-endda.

  IF sy-subrc EQ 0.   "Higher Duty exists
    w_hda_exist = 'X'.
* Get company code, controlling area and cost centre
    SELECT SINGLE bukrs kokrs kostl FROM zhrv1018
    INTO (wa_emp-zzhdcoid, wa_emp-zzhdkokrs, wa_emp-zzhdkostl)
    WHERE plvar = '01'
      AND otype = 'S'
      AND objid = wa_p509-plans
      AND subty = ''
      AND istat = '1'
      AND dateto = '99991231'.

* Get Position's Org unit
    SELECT SINGLE sobid FROM hrp1001
    INTO v_sobid
    WHERE otype = 'S'
      AND objid = wa_p509-plans
      AND plvar = '01'
      AND rsign = 'A'
      AND relat = '003'
      AND istat = '1'
      AND begda LE wa_p509-endda
      AND endda GE wa_p509-endda.

    IF sy-subrc EQ 0.
      wa_emp-zzhdorgeh = v_sobid(8).
    ENDIF.

* Assign Higher Duty attributes to work area

    wa_emp-zzhdwerks = wa_p509-werks.
    wa_emp-zzhdbtrtl = wa_p509-btrtl.
    wa_emp-zzhdpersg = wa_p509-persg.
    wa_emp-zzhdpersk = wa_p509-persk.
    wa_emp-zzhdplans = wa_p509-plans.
    wa_emp-zzhdtrfar = wa_p509-trfar.
    wa_emp-zzhdtrfgb = wa_p509-trfgb.
    wa_emp-zzhdtrfgr = wa_p509-trfgr.
    wa_emp-zzhdtrfst = wa_p509-trfst.
    wa_emp-zzhdreacd = wa_p509-reacd.
    wa_emp-zzhdempct = wa_p509-empct.

  ENDIF.
  wa_emp-zzhdansal = w_salary.

  MODIFY  i_t_data FROM wa_emp INDEX l_tabix.

  CLEAR wa_emp.
ENDLOOP. 










No comments: