Difference between revisions of "SAP HCM BADI"
From SapWiki
Line 1: | Line 1: | ||
==<nowiki>BADI HRPAD00INFTY (Tarea actualiz./Actualiz.infotipo)</nowiki> == | ==<nowiki>BADI HRPAD00INFTY (Tarea actualiz./Actualiz.infotipo)</nowiki> == | ||
===ejemplo de IN_UPDATE === | ===ejemplo de IN_UPDATE === | ||
+ | * enviar datos a sistema externo al crear, modificar o borrar registros de IT2001 y IT2002 | ||
+ | <nowiki>METHOD if_ex_hrpad00infty~in_update. | ||
+ | DATA: lt_p0001 TYPE TABLE OF p0001, | ||
+ | ls_p0001 TYPE p0001. | ||
+ | |||
+ | DATA: lt_oper TYPE TABLE OF psoper, | ||
+ | ls_oper TYPE psoper, | ||
+ | ls_prel TYPE prelp, | ||
+ | ls_prel_old TYPE prelp. | ||
+ | |||
+ | DATA: ls_t503 TYPE t503, | ||
+ | ls_t001p TYPE t001p. | ||
+ | |||
+ | DATA l_f(1). | ||
+ | |||
+ | CHECK ipspar-infty = '2001' OR ipspar-infty = '2002'. | ||
+ | |||
+ | CLEAR: ls_oper. | ||
+ | LOOP AT new_image INTO ls_oper WHERE infty = '2001' or infty = '2002'. | ||
+ | APPEND ls_oper TO lt_oper. | ||
+ | ENDLOOP. | ||
+ | |||
+ | sort lt_oper by opera. "primero borrar 'D' => después insertar 'I' | ||
− | + | CLEAR: ls_oper. | |
− | + | LOOP AT old_image INTO ls_oper WHERE infty = '2001' or infty = '2002'. | |
− | + | MOVE-CORRESPONDING ls_oper TO ls_prel_old. | |
− | + | EXIT. | |
− | + | ENDLOOP. | |
− | + | ||
− | + | CALL FUNCTION 'HR_READ_INFOTYPE' | |
− | + | EXPORTING | |
− | + | pernr = ipspar-pernr | |
− | + | infty = '0001' | |
− | + | TABLES | |
− | + | infty_tab = lt_p0001 | |
− | + | EXCEPTIONS | |
− | + | infty_not_found = 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. | |
− | + | ||
− | + | LOOP AT lt_p0001 INTO ls_p0001 WHERE begda <= ipspar-endda AND | |
− | + | endda >= ipspar-begda. | |
− | + | ENDLOOP. | |
− | + | ||
− | + | SELECT SINGLE * INTO ls_t503 FROM t503 | |
− | + | WHERE persg = ls_p0001-persg | |
− | + | AND persk = ls_p0001-persk. | |
− | + | ||
− | + | SELECT SINGLE * INTO ls_t001p FROM t001p | |
− | + | WHERE werks = ls_p0001-werks | |
− | + | AND btrtl = ls_p0001-btrtl. | |
− | + | ||
− | + | LOOP AT lt_oper INTO ls_oper. | |
− | + | MOVE-CORRESPONDING ls_oper TO ls_prel. | |
− | + | ||
− | + | CALL FUNCTION 'Z_HCM_ENVIA_DATA' | |
+ | EXPORTING | ||
+ | tclas = ipspar-tclas | ||
+ | innnn = ls_prel | ||
+ | i001p = ls_t001p | ||
+ | i_opera = ls_oper-opera | ||
EXCEPTIONS | 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. | |
− | + | ENDLOOP. | |
− | + | ||
− | + | ENDMETHOD.</nowiki> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===ejemplo de AFTER_INPUT=== | ===ejemplo de AFTER_INPUT=== |
Revision as of 21:37, 4 April 2020
Contents
BADI HRPAD00INFTY (Tarea actualiz./Actualiz.infotipo)
ejemplo de IN_UPDATE
- enviar datos a sistema externo al crear, modificar o borrar registros de IT2001 y IT2002
METHOD if_ex_hrpad00infty~in_update. DATA: lt_p0001 TYPE TABLE OF p0001, ls_p0001 TYPE p0001. DATA: lt_oper TYPE TABLE OF psoper, ls_oper TYPE psoper, ls_prel TYPE prelp, ls_prel_old TYPE prelp. DATA: ls_t503 TYPE t503, ls_t001p TYPE t001p. DATA l_f(1). CHECK ipspar-infty = '2001' OR ipspar-infty = '2002'. CLEAR: ls_oper. LOOP AT new_image INTO ls_oper WHERE infty = '2001' or infty = '2002'. APPEND ls_oper TO lt_oper. ENDLOOP. sort lt_oper by opera. "primero borrar 'D' => después insertar 'I' CLEAR: ls_oper. LOOP AT old_image INTO ls_oper WHERE infty = '2001' or infty = '2002'. MOVE-CORRESPONDING ls_oper TO ls_prel_old. EXIT. ENDLOOP. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING pernr = ipspar-pernr infty = '0001' TABLES infty_tab = lt_p0001 EXCEPTIONS infty_not_found = 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. LOOP AT lt_p0001 INTO ls_p0001 WHERE begda <= ipspar-endda AND endda >= ipspar-begda. ENDLOOP. SELECT SINGLE * INTO ls_t503 FROM t503 WHERE persg = ls_p0001-persg AND persk = ls_p0001-persk. SELECT SINGLE * INTO ls_t001p FROM t001p WHERE werks = ls_p0001-werks AND btrtl = ls_p0001-btrtl. LOOP AT lt_oper INTO ls_oper. MOVE-CORRESPONDING ls_oper TO ls_prel. CALL FUNCTION 'Z_HCM_ENVIA_DATA' EXPORTING tclas = ipspar-tclas innnn = ls_prel i001p = ls_t001p i_opera = ls_oper-opera 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. ENDLOOP. ENDMETHOD.
ejemplo de AFTER_INPUT
- validar fechas al actualizar IT0041
method IF_EX_HRPAD00INFTY~AFTER_INPUT. DATA: ls_p0041 TYPE p0041, lv_date TYPE begda, lv_date2 TYPE begda, lv_date3 TYPE begda, lv_years(4) type n. DATA: datar_0041 TYPE datar, date_0041 TYPE datum. ** Check country code CHECK i001p-molga EQ '39'. "CL Chile ** Check infotype CHECK new_innnn-infty EQ '0041'. ** No check for Delete operation CHECK NOT ipsyst-ioper = 'DEL'. ** Convert to structure CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn EXPORTING prelp = new_innnn IMPORTING pnnnn = ls_p0041. DO 12 TIMES VARYING datar_0041 FROM ls_p0041-dar01 NEXT ls_p0041-dar02 VARYING date_0041 FROM ls_p0041-dat01 NEXT ls_p0041-dat02. IF datar_0041 = '07'. "vacaciones legales lv_date = date_0041. ELSEIF datar_0041 = '02'. "antiguedad lv_date2 = date_0041. ELSEIF datar_0041 = '04'. "progresivos lv_date3 = date_0041. * ELSEIF date_0041 IS INITIAL. * EXIT. ENDIF. ENDDO. if lv_date <> lv_date2. MESSAGE e016(RP) WITH 'Fecha Vac. Legales' lv_date 'distinto a Fecha Antigüedad' lv_date2. endif. if lv_date3(4) < lv_date2(4). lv_years = lv_date2(4) - lv_date3(4). if lv_years > 10. message e016(RP) WITH 'Fecha Progresivos' 'permite el reconocimiento máximo de 10 años' 'respecto a Fecha Antigüedad' lv_date2. ELSEIF lv_date3+4(4) NE lv_date2+4(4). message e016(RP) WITH 'Mes y día de progresivos deben ser' 'igual al de antigüedad legal'. endif. endif. endmethod.
BADI HRFORM_HRF02
Como obtener el PDF de un recibo de sueldo creado vía trn. HRFORMS y formulario definido como Smartform:
- Implementar badi HRFORM_HRF02 método GET_FDATA
method IF_EX_HRFORM_HRF02~GET_FDATA. CALL FUNCTION 'Z_GET_FDATA' EXPORTING i_fdata = fdata . endmethod.
- Crear grupo de Función ZHCM_PAYSLIP y crear la función
FUNCTION z_get_fdata. *"---------------------------------------------------------------------- *"*"Interfase local *" IMPORTING *" REFERENCE(I_FDATA) TYPE ANY *"---------------------------------------------------------------------- * ver BADI HRFORM_HRF02_CL method get_data DATA ls_fdata TYPE /1pyxxfo/zpayslip_cl. MOVE i_fdata TO ls_fdata. *gt_data definido como global en el grupo de función *data gt_fdata type TABLE OF /1PYXXFO/ZPAYSLIP_CL. APPEND ls_fdata TO gt_fdata. EXPORT gt_fdata TO MEMORY ID 'ZPAYSLIP_CL'. ENDFUNCTION.
- Copiar programa HINU_HRFORMS_MAIL (ver nota 2004408 - HR-IN: HRForms Payslip via e-mail), al final del proceso(después de los SUBMIT (gv_report) ) obtener el fdata y obtener PDF del smartform, algo equivalente a:
* ver BADI HRFORM_HRF02_CL method get_data * obtiene datos de la impresión del recibo de sueldo IMPORT gt_fdata TO gt_fdata FROM MEMORY ID 'ZPAYSLIP_CL'. loop at gt_fdata into data(wa). .... .... .... CALL FUNCTION ld_func_module_name EXPORTING control_parameters = ls_control_parameters output_options = ls_output_options user_settings = space hrdata = wa IMPORTING job_output_info = ls_output EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. ... ... ... endloop.