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 0HRPOSITION_ATTR data source with additional attributes.
As you can see in the above picture(Pic-1), I need to enhance few attributes whose information is available in various info type tables in SAP.
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 0HRPOSITION_ATTR data source in ERP side to extract the following additional information.
Pic-1. RSA6 - Enhanced fields |
As you can see in the above picture(Pic-1), I need to enhance few attributes whose information is available in various info type tables in SAP.
in the next step i will write ABAP code in CMOD to populate these fields with correct attribute values.
Note:If you have BADI implementation active in your landscape, you can use the same code with some minor adjustments as per your requirement.
Pic-2 - CMOD Code |
I did not write entire code in CMOD. instead I created an include program and placed all my code related to 0HRPOSITION_ATTR in ZBW_EXIT_0HR_POSITION_ATTR program.
zbw_exit_0hr_position_attr
Once activated the program, go to RSA3 - Extractor Checker and test your data.
DATA: it_str1 LIKE hrms_bw_io_position. " Work areaDATA: v_defhrs LIKE hrp1011-dyavg, " standard work hours per 2 weekv_wkday LIKE hrp1011-wkavg, " standard work day per weekv_moday LIKE hrp1011-moavg, " standard work day per monthv_yrday LIKE hrp1011-yravg, " standard work day per yearv_workhrs LIKE hrp1011-dyavg,v_wkhrs LIKE hrp1011-wkavg,v_mohrs LIKE hrp1011-moavg,v_zzfte LIKE hrp1011-zzfte, " Position FTE Calcv_trfkz LIKE hrp1005-trfkz,v_empsgrp LIKE hrp1013-persk.CLEAR: it_str1.CALL FUNCTION 'RH_T77S0_WORKTIME_DEFAULTS_GET'IMPORTING* ACT_PERCK =* ACT_DECNO =* act_daily = v_defhrs " hours per dayact_daywk = v_wkday " day per weekact_daymt = v_moday " day per monthact_dayyr = v_yrday " day per year* ACT_MINHR =* ACT_MAXHR =EXCEPTIONSt77s0_entry_not_found = 1OTHERS = 2.LOOP AT i_t_data INTO it_str1.l_tabix = sy-tabix.* Get default working hours from Position Emp. SubGrpSELECT SINGLE persk FROM hrp1013 INTO v_empsgrpWHERE plvar = '01'AND otype = 'S'AND objid = it_str1-plansAND istat = '1'AND begda LE it_str1-enddaAND endda GE it_str1-endda.CASE v_empsgrp.WHEN '01' OR '02' OR '09' OR '15'.v_defhrs = 70. " Work hours per fortnight.WHEN OTHERS.v_defhrs = 76. " Work hours per fortnight.ENDCASE.* Get working hours per day, per week per month of the position.* Get Position FTE from HRP1011SELECT SINGLE dyavg wkavg moavg zzfte FROM hrp1011INTO (v_workhrs, v_wkhrs, v_mohrs, v_zzfte)WHERE plvar = '01'AND otype = 'S'AND objid = it_str1-plansAND istat = '1'AND begda LE it_str1-enddaAND endda GE it_str1-endda.IF v_wkhrs NE 0. " if work hours per week is not initialv_workhrs = v_wkhrs / v_wkday. " compute hours per day.ELSE. "Else use work hours per month.v_workhrs = v_mohrs / v_moday. "compute hours per dayv_wkhrs = v_workhrs * v_wkday. "compute hours per weekENDIF.it_str1-zzdyavg = v_workhrs. " work hours per day.it_str1-zzwkavg = v_workhrs * v_wkday. " Work hours per weekit_str1-zzmoavg = v_workhrs * v_moday. " Work hours per monthit_str1-zzyravg = v_workhrs * v_yrday. " Work hours per year* Position FTEit_str1-zzweightpct = v_zzfte. " Position FTE* Add routine for Fund Center and CodeSELECT SINGLE fincode fistl FROM zhrv1018INTO (it_str1-zzfincode, it_str1-zzfistl)WHERE plvar = '01'AND otype = 'S'AND objid = it_str1-plansAND subty = ''AND istat = '1'AND datefrom LE it_str1-enddaAND dateto GE it_str1-endda.* Routines here* Get Company code, Personnel Area and personnel sub area from HRP1008SELECT SINGLE bukrs persa btrtl FROM hrp1008INTO (it_str1-zzbukrs, it_str1-zzpersa, it_str1-zzbtrtl)WHERE plvar = '01'AND otype = 'S'AND objid = it_str1-plansAND begda LE it_str1-enddaAND endda GE it_str1-endda.* Get information from infotype HRP1005SELECT SINGLE trfar trfgb trfg1 trfg2 trfs1 trfs2 trfkz FROM hrp1005INTO (it_str1-zztrfar, it_str1-zztrfgb, it_str1-zztrfg1,it_str1-zztrfg2, it_str1-zztrfs1, it_str1-zztrfs2, v_trfkz)WHERE plvar = '01'AND otype = 'S'AND objid = it_str1-plansAND begda LE it_str1-enddaAND endda GE it_str1-endda.* Get Min salary for this pay scale1SELECT SINGLE betrg FROM t510 INTO it_str1-zzcpminWHERE molga = '13'AND trfar = it_str1-zztrfarAND trfgb = it_str1-zztrfgbAND trfkz = v_trfkzAND trfgr = it_str1-zztrfg1AND trfst = it_str1-zztrfs1AND begda LE it_str1-enddaAND endda GE it_str1-endda.* Get Max salary for pay scale2SELECT SINGLE betrg FROM t510 INTO it_str1-zzcpmaxWHERE molga = '13'AND trfar = it_str1-zztrfarAND trfgb = it_str1-zztrfgbAND trfkz = v_trfkzAND trfgr = it_str1-zztrfg2AND trfst = it_str1-zztrfs2AND begda LE it_str1-enddaAND endda GE it_str1-endda.MODIFY i_t_data FROM it_str1 INDEX l_tabix.CLEAR: it_str1.ENDLOOP.
Once activated the program, go to RSA3 - Extractor Checker and test your data.
1 comment:
Hi,
Many thanks for this great post. It was of great help.
I just have a question, how did you define (data element) the salary fields ZZPCMAX, ZZPCMIN.
Thanks,
LAntonio
Post a Comment