This Badi enhancement will execute based on run time filter value.
Badi Name: HRSFI_B_COMP_FIELD_EXTRACTOR
1. Filter1
Implemented Method:
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA :lt_p0001 TYPE TABLE OF p0001,
ls_p0001 TYPE p0001.
DATA lv_werks_t TYPE t500p-name1. "hrsfi_custom.
*--Fetch the infotype 0001 data
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas = 'A'
pernr = IV_LEADING_PERNR
infty = '0001'
begda = iv_keydate
endda = iv_keydate
TABLES
infty_tab = lt_p0001.
*--To get the latest personnel area.
SORT lt_p0001 BY endda DESCENDING.
READ TABLE lt_p0001 INTO ls_p0001 INDEX 1.
IF sy-subrc = 0.
CALL FUNCTION 'HRWPC_RFC_WERKS_TEXT_GET'
EXPORTING
werks = ls_p0001-werks
IMPORTING
werks_text = lv_werks_t.
*-Move personnel area text to return value
ev_field_value = lv_werks_t.
ENDIF.
ENDMETHOD.
2.. Filter2
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA: lv_doj TYPE p0041-dat01,
is_ok TYPE boole_d,
msg_han TYPE REF TO if_hrpa_message_handler.
*--To read the 41 datespecification data & DOJ
CALL FUNCTION 'HR_ECM_GET_DATETYP_FROM_IT0041'
EXPORTING
pernr = iv_leading_pernr
keydt = iv_keydate
datar = 'Z9'
message_handler = msg_han
IMPORTING
date = lv_doj
is_ok = is_ok.
IF sy-subrc = 0 AND lv_doj IS NOT INITIAL.
CONCATENATE lv_doj+6(2) lv_doj+4(2) lv_doj+0(4) INTO ev_field_value SEPARATED BY '.'.
ENDIF.
ENDMETHOD.
3. Filter3
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA lv_trfgr TYPE p0008-trfgr.
CLEAR lv_trfgr.
SELECT SINGLE trfgr FROM pa0008 INTO lv_trfgr WHERE pernr = iv_leading_pernr
AND begda LE sy-datum
AND endda GE sy-datum.
IF sy-subrc = 0.
MOVE lv_trfgr TO ev_field_value.
ENDIF.
ENDMETHOD.
4. Filter4
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA : lv_objid TYPE hrp1001-objid,
lv_objid1 TYPE hrp1001-sobid,
lv_objid_text TYPE char40.
SELECT SINGLE plans FROM pa0001 INTO lv_objid WHERE pernr = iv_leading_pernr
AND begda LE sy-datum
AND endda GE sy-datum.
IF sy-subrc = 0.
DO 4 TIMES.
IF sy-index = 1.
SELECT SINGLE sobid FROM hrp1001 INTO lv_objid1 WHERE otype = 'S'
AND objid = lv_objid
AND plvar = '01'
AND rsign = 'A'
AND relat = '003'
AND istat = '1'.
IF sy-subrc = 0.
lv_objid = lv_objid1.
ELSE.
EXIT.
ENDIF.
ELSE.
SELECT SINGLE sobid FROM hrp1001 INTO lv_objid1 WHERE otype = 'O'
AND objid = lv_objid
AND plvar = '01'
AND rsign = 'A'
AND relat = '002'
AND istat = '1'.
IF sy-subrc = 0.
lv_objid = lv_objid1.
ELSE.
EXIT.
ENDIF.
ENDIF.
ENDDO.
SELECT SINGLE stext FROM hrp1000 INTO lv_objid_text WHERE plvar = '01'
AND otype = 'O'
AND objid = lv_objid
AND istat = '1'.
IF sy-subrc = 0.
ev_field_value = lv_objid_text.
ENDIF.
ENDIF.
ENDMETHOD.
5. Filter5
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA : lv_objid TYPE hrp1001-objid,
lv_objid1 TYPE hrp1001-sobid,
lv_objid_text TYPE char40.
SELECT SINGLE plans FROM pa0001 INTO lv_objid WHERE pernr = iv_leading_pernr
AND begda LE sy-datum
AND endda GE sy-datum.
IF sy-subrc = 0.
DO 3 TIMES.
IF sy-index = 1.
SELECT SINGLE sobid FROM hrp1001 INTO lv_objid1 WHERE otype = 'S'
AND objid = lv_objid
AND plvar = '01'
AND rsign = 'A'
AND relat = '003'
AND istat = '1'.
IF sy-subrc = 0.
lv_objid = lv_objid1.
ELSE.
EXIT.
ENDIF.
ELSE.
SELECT SINGLE sobid FROM hrp1001 INTO lv_objid1 WHERE otype = 'O'
AND objid = lv_objid
AND plvar = '01'
AND rsign = 'A'
AND relat = '002'
AND istat = '1'.
IF sy-subrc = 0.
lv_objid = lv_objid1.
ELSE.
EXIT.
ENDIF.
ENDIF.
ENDDO.
SELECT SINGLE stext FROM hrp1000 INTO lv_objid_text WHERE plvar = '01'
AND otype = 'O'
AND objid = lv_objid
AND istat = '1'.
IF sy-subrc = 0.
ev_field_value = lv_objid_text.
ENDIF.
ENDIF.
ENDMETHOD.
6. Filter6
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA lv_client TYPE p9011-client.
SELECT SINGLE client FROM pa9011 INTO lv_client WHERE pernr = iv_leading_pernr
AND begda LE sy-datum
AND endda GE sy-datum.
IF sy-subrc = 0.
MOVE lv_client TO ev_field_value.
ENDIF.
ENDMETHOD.
7. Filter7
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA lv_team TYPE p9011-team.
SELECT SINGLE team FROM pa9011 INTO lv_team WHERE pernr = iv_leading_pernr
AND begda LE sy-datum
AND endda GE sy-datum.
IF sy-subrc = 0.
MOVE lv_team TO ev_field_value.
ENDIF.
ENDMETHOD.
8. Filter8
method IF_HRSFI_COMP_FIELD_EXTRACTOR~GET_FIELD_VALUE.
data:gt_p0008 type standard table of pa0008,
gs_p0008 like line of gt_p0008,
lv_ansal type pa0008-ansal,
lv_date type pa0008-begda.
select * from pa0008 into table gt_p0008 where pernr = iv_leading_pernr.
if sy-subrc = 0.
sort gt_p0008 descending by endda.
loop at gt_p0008 into gs_p0008.
if sy-tabix = 1.
lv_ansal = gs_p0008-ansal.
lv_date = gs_p0008-begda.
else.
if lv_ansal = gs_p0008-ansal.
clear lv_date.
lv_date = gs_p0008-begda.
endif.
endif.
endloop.
if lv_date is not initial.
concatenate lv_date+06(02) '.' lv_date+04(02) '.' lv_date+0(04) into ev_field_value.
endif.
endif.
CLEAR:gs_p0008,gt_p0008[].
endmethod.
9. Filter9
method if_hrsfi_comp_field_extractor~get_field_value.
if is_p0001-plans is not initial.
select single stext into ev_field_value from hrp1000 where plvar = '01' and otype = 'S' and objid = is_p0001-plans.
endif.
endmethod.
10. Filter10
method IF_HRSFI_COMP_FIELD_EXTRACTOR~GET_FIELD_VALUE.
data:gt_p0008 type standard table of pa0008,
gs_p0008 like line of gt_p0008,
lv_ansal type pa0008-ansal,
lv_date type pa0008-begda.
select * from pa0008 into table gt_p0008 where pernr = iv_leading_pernr.
if sy-subrc = 0.
sort gt_p0008 descending by endda.
loop at gt_p0008 into gs_p0008.
if sy-tabix = 1.
lv_ansal = gs_p0008-ansal.
lv_date = gs_p0008-begda.
else.
if lv_ansal = gs_p0008-ansal.
clear lv_date.
lv_date = gs_p0008-begda.
endif.
endif.
endloop.
if lv_date is not initial.
concatenate lv_date+06(02) '.' lv_date+04(02) '.' lv_date+0(04) into ev_field_value.
endif.
endif.
CLEAR:gs_p0008,gt_p0008[].
endmethod.
11. Filter11
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA : lv_objid TYPE hrp1001-objid,
lv_objid1 TYPE hrp1001-sobid,
lv_objid_text TYPE char40.
SELECT SINGLE plans FROM pa0001 INTO lv_objid WHERE pernr = iv_leading_pernr
AND begda LE sy-datum
AND endda GE sy-datum.
IF sy-subrc = 0.
DO 2 TIMES.
IF sy-index = 1.
SELECT SINGLE sobid FROM hrp1001 INTO lv_objid1 WHERE otype = 'S'
AND objid = lv_objid
AND plvar = '01'
AND rsign = 'A'
AND relat = '003'
AND istat = '1'.
IF sy-subrc = 0.
lv_objid = lv_objid1.
ELSE.
EXIT.
ENDIF.
ELSE.
SELECT SINGLE sobid FROM hrp1001 INTO lv_objid1 WHERE otype = 'O'
AND objid = lv_objid
AND plvar = '01'
AND rsign = 'A'
AND relat = '002'
AND istat = '1'.
IF sy-subrc = 0.
lv_objid = lv_objid1.
ELSE.
EXIT.
ENDIF.
ENDIF.
ENDDO.
SELECT SINGLE stext FROM hrp1000 INTO lv_objid_text WHERE plvar = '01'
AND otype = 'O'
AND objid = lv_objid
AND istat = '1'.
IF sy-subrc = 0.
ev_field_value = lv_objid_text.
ENDIF.
ENDIF.
ENDMETHOD.
12. Filter12
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA : ls_0001 TYPE pa0001,
ls_t527x TYPE t527x.
SELECT SINGLE * FROM pa0001 INTO ls_0001 WHERE pernr = iv_leading_pernr
AND begda LE iv_keydate
AND endda GE iv_keydate.
IF sy-subrc = 0.
SELECT SINGLE * FROM t527x INTO ls_t527x WHERE sprsl = sy-langu
AND orgeh = ls_0001-orgeh
AND endda GE iv_keydate.
IF sy-subrc = 0.
CONCATENATE ls_t527x-orgtx '(' ls_0001-orgeh ')' INTO ev_field_value SEPARATED BY space.
ENDIF.
ENDIF.
ENDMETHOD.
13. Filter13
METHOD if_hrsfi_comp_field_extractor~get_field_value.
DATA : ls_0041 TYPE pa0041,
lv_date_type TYPE pa0041-dar01,
lv_date TYPE pa0041-dat01.
SELECT SINGLE * FROM pa0041 INTO ls_0041 WHERE pernr = iv_leading_pernr
AND begda LE iv_keydate
AND endda GE iv_keydate.
IF sy-subrc = 0.
DO 12 TIMES VARYING lv_date_type FROM ls_0041-dar01 NEXT ls_0041-dar02
VARYING lv_date FROM ls_0041-dat01 NEXT ls_0041-dat02 .
IF lv_date_type = 'Z6'.
CONCATENATE lv_date+06(02) '.' lv_date+04(02) '.' lv_date+0(04) INTO ev_field_value.
* ev_field_value = lv_date.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDMETHOD.
14. Filter14
METHOD if_hrsfi_comp_field_extractor~get_field_value.
ev_field_value = iv_leading_pernr.
ENDMETHOD.
No comments:
Post a Comment