ABAP - My Common Function SAP HR
Step 1 : Put in Main program as Include
REPORT zhrictr MESSAGE-ID zhrmsg.
INCLUDE zhrictr_top. "Data Declaration
INCLUDE zhrictr_sel. "Selection Screen
INCLUDE zhrictr_f01. "Common Fuction Include
INCLUDE zhrictr_f02. "Report Function Include
INCLUDE zhrictr_alv. "Display ALV Functions Include
INCLUDE zhrictr_xls. "Download XLS Functions Include
INCLUDE zhrictr_mai. "Main Include
Step 2 : Create INCLUDE zhrictr_f01.
*----------------------------------------------------------------------*
* INCLUDE ZHRICTR_F01 *
*----------------------------------------------------------------------*
* Macro
*DATA: PNP-SW-FOUND(1) TYPE C,
*data: PNP-SY-TABIX LIKE SY-TABIX.
DEFINE zprovide_last.
* ZPROVIDE_LAST INFTY BEGDA ENDDA
pnp-sw-found = '0'.
clear pnp-sy-tabix.
loop at &1.
if &1-begda le &3 and &1-endda ge &3.
pnp-sw-found = '1'.
exit.
endif.
if &1-begda le &3 and &1-endda ge &2.
pnp-sy-tabix = sy-tabix.
endif.
endloop.
if pnp-sw-found eq '0'.
if pnp-sy-tabix ne 0.
pnp-sw-found = '1'.
read table &1 index pnp-sy-tabix.
else.
clear &1.
endif.
endif.
END-OF-DEFINITION.
*---------------------------------------------------------------------*
* FORM zget_location *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_PKOSTL *
* --> P_SACHZ *
* --> P_BEGDA *
* --> P_ENDDA *
* --> P_BUILDING *
* --> P_STREET *
* --> P_NUMBER *
* --> P_CITY *
*---------------------------------------------------------------------*
FORM zget_location USING p_pkostl p_sachz p_begda p_endda
CHANGING p_building p_street p_number p_city.
DATA: zpa001 LIKE zhrpa001 OCCURS 0 WITH HEADER LINE.
SELECT * FROM zhrpa001 INTO TABLE zpa001
WHERE kostl = p_pkostl AND sachz = p_sachz.
IF sy-subrc NE 0.
DATA: ztmp(70) TYPE c.
ztmp = p_pkostl.
CALL FUNCTION 'CAD_CONVERT_TO_EXTERNAL'
EXPORTING
name = 'CSKT-KOSTL'
value = ztmp
IMPORTING
value_external = ztmp.
SELECT * FROM zhrpa001 INTO TABLE zpa001
WHERE kostl = ztmp AND sachz = p_sachz.
ENDIF.
zprovide_last zpa001 p_begda p_endda.
p_building = zpa001-name2.
p_street = zpa001-stras.
p_number = zpa001-locat.
p_city = zpa001-ort01.
ENDFORM.
*---------------------------------------------------------------------*
* FORM divcodename_getby_cc *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_KOSTL *
* --> P_BEGDA *
* --> P_ENDDA *
* --> P_DIVCODE *
* --> P_DIVNAME *
*---------------------------------------------------------------------*
FORM divcodename_getby_cc USING p_kostl p_begda p_endda
CHANGING p_divcode p_divname.
DATA: zdummy(20) TYPE c.
PERFORM div_getby_cc USING p_kostl p_begda p_endda
CHANGING p_divcode zdummy zdummy zdummy zdummy zdummy zdummy
zdummy zdummy zdummy zdummy zdummy zdummy zdummy zdummy
zdummy zdummy.
PERFORM div_getnameby_code USING p_divcode CHANGING p_divname.
ENDFORM.
*---------------------------------------------------------------------*
* FORM div_getby_cc *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_KOSTL *
* --> P_BEGDA *
* --> P_ENDDA *
* --> P_DIV *
* --> P_OI *
* --> P_F01 *
* --> P_F02 *
* --> P_F03 *
* --> P_F04 *
* --> P_F05 *
* --> P_F06 *
* --> P_F07 *
* --> P_F08 *
* --> P_F09 *
* --> P_F10 *
* --> P_F11 *
* --> P_F12 *
* --> P_F13 *
* --> P_F14 *
* --> P_F15 *
*---------------------------------------------------------------------*
FORM div_getby_cc USING p_kostl p_begda p_endda
CHANGING p_div p_oi p_f01 p_f02 p_f03 p_f04 p_f05 p_f06 p_f07
p_f08 p_f09 p_f10 p_f11 p_f12 p_f13 p_f14 p_f15.
DATA: lf1(20) TYPE c, lf2(20) TYPE c, o_n(2) TYPE n.
DATA: tpad003 LIKE zpad003 OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS: , .
DATA: ztmp(70) TYPE c.
ztmp = p_kostl.
CALL FUNCTION 'CAD_CONVERT_TO_EXTERNAL'
EXPORTING
name = 'CSKT-KOSTL'
value = ztmp
IMPORTING
value_external = ztmp.
FREE tpad003.
SELECT * FROM zpad003 INTO TABLE tpad003
WHERE kostl = ztmp.
zprovide_last tpad003 p_begda p_endda.
p_div = tpad003-ffield.
p_oi = tpad003-oicode.
DO 15 TIMES.
o_n = sy-index.
CONCATENATE 'TPAD003-F' o_n INTO lf1.
CONCATENATE 'P_F' o_n INTO lf2.
ASSIGN (lf1) TO .
ASSIGN (lf2) TO .
= .
ENDDO.
ENDFORM.
*---------------------------------------------------------------------*
* FORM div_getnameby_code *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_DIVCODE *
* --> P_NAME *
*---------------------------------------------------------------------*
FORM div_getnameby_code USING p_divcode CHANGING p_name.
CLEAR p_name.
SELECT SINGLE divname FROM zpad001 INTO p_name WHERE divcode =
p_divcode.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_massn_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PMASSN *
* --> PMASSNTXT *
*---------------------------------------------------------------------*
FORM get_massn_text USING pmassn CHANGING pmassntxt.
SELECT SINGLE mntxt FROM t529t INTO pmassntxt
WHERE sprsl = 'EN' AND massn = pmassn.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_massg_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PMASSN *
* --> PMASSG *
* --> PMASSGTXT *
*---------------------------------------------------------------------*
FORM get_massg_text USING pmassn pmassg CHANGING pmassgtxt.
SELECT SINGLE mgtxt FROM t530t INTO pmassgtxt
WHERE sprsl = 'EN' AND massn = pmassn
AND massg = pmassg.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_eestatus_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PSTAT2 *
* --> PSTATT *
*---------------------------------------------------------------------*
FORM get_eestatus_text USING pstat2 CHANGING pstatt.
SELECT SINGLE text1 FROM t529u INTO pstatt
WHERE sprsl = 'EN' AND statn = '2'
AND statv = pstat2.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_bukrs_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PBUKRS *
* --> PBUKRST *
*---------------------------------------------------------------------*
FORM get_bukrs_text USING pbukrs CHANGING pbukrst.
SELECT SINGLE butxt FROM t001 INTO pbukrst
WHERE bukrs = pbukrs.
ENDFORM.
*---------------------------------------------------------------------*
* FORM Get_persa_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PWERKS *
* --> PWERKST *
*---------------------------------------------------------------------*
FORM get_persa_text USING pwerks CHANGING pwerkst.
SELECT SINGLE name1 FROM t500p INTO pwerkst
WHERE persa = pwerks AND molga = '34'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_persg_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PPERSG *
* --> PPERSGT *
*---------------------------------------------------------------------*
FORM get_persg_text USING ppersg CHANGING ppersgt.
SELECT SINGLE ptext FROM t501t INTO ppersgt
WHERE sprsl = 'EN' AND persg = ppersg.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_persk_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PPERSK *
* --> PPERSKT *
*---------------------------------------------------------------------*
FORM get_persk_text USING ppersk CHANGING pperskt.
SELECT SINGLE ptext FROM t503t INTO pperskt
WHERE sprsl = 'EN' AND persk = ppersk.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_btrtl_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PWERKS *
* --> PBTRTL *
* --> PBTRTLT *
*---------------------------------------------------------------------*
FORM get_btrtl_text USING pwerks pbtrtl CHANGING pbtrtlt.
SELECT SINGLE btext FROM t001p INTO pbtrtlt
WHERE molga = '34' AND werks = pwerks
AND btrtl = pbtrtl.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_kostl_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PKOSTL *
* --> PBEGDA *
* --> PKOSTLT *
*---------------------------------------------------------------------*
FORM get_kostl_text USING pkostl pbegda CHANGING pkostlt.
SELECT SINGLE ltext FROM cskt INTO pkostlt
WHERE spras = 'EN' AND kokrs = 'CPI0'
AND kostl = pkostl
AND datbi >= pbegda.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_plans_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PPLANS *
* --> PENDDA *
* --> PPLANST *
*---------------------------------------------------------------------*
FORM get_plans_text USING pplans pendda CHANGING pplanst.
SELECT SINGLE mc_stext FROM hrp1000 INTO pplanst
WHERE plvar = '01' AND otype = 'S' AND istat = '1'
AND langu = 'EN'
AND begda <= pendda AND endda >= pendda
AND objid = pplans.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_stell_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PSTELL *
* --> PENDDA *
* --> PSTELLT *
*---------------------------------------------------------------------*
FORM get_stell_text USING pstell pendda CHANGING pstellt.
SELECT SINGLE stext FROM hrp1000 INTO pstellt
WHERE plvar = '01' AND otype = 'C'
AND objid = pstell
AND begda <= pendda AND endda >= pendda.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_natio_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PNATIO *
* --> PNATIOT *
*---------------------------------------------------------------------*
FORM get_natio_text USING pnatio CHANGING pnatiot.
SELECT SINGLE landx FROM t005t INTO pnatiot
WHERE spras = 'EN' AND land1 = pnatio.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_famst_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PFAMST *
* --> PFAMSTT *
*---------------------------------------------------------------------*
FORM get_famst_text USING pfamst CHANGING pfamstt.
SELECT SINGLE ftext FROM t502t INTO pfamstt
WHERE sprsl = 'EN' AND famst = pfamst.
ENDFORM.
*---------------------------------------------------------------------*
* FORM get_abkrs_text *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PABKRS *
* --> PABKRST *
*---------------------------------------------------------------------*
FORM get_abkrs_text USING pabkrs CHANGING pabkrst.
SELECT SINGLE atext FROM t549t INTO pabkrst
WHERE sprsl = 'EN' AND abkrs = pabkrs.
ENDFORM.
No comments:
Post a Comment