Time Management Sample -1
ENHANCEMENT 1 ZESS_LEAVE_COMBINATION. "active version
TYPES:
BEGIN OF ty_p0001,
persg TYPE persg,
persk TYPE persk,
END OF ty_p0001.
TYPES:
BEGIN OF ty_t503,
konty TYPE mopgk,
END OF ty_t503.
TYPES :
BEGIN OF ty_ptrqtmp,
item_id TYPE os_guid,
END OF ty_ptrqtmp.
DATA :
lt_im_attabs TYPE ptarq_attabsdata_tab,
lwa_im_attabs TYPE ptarq_attabsdata_struc,
lx_p2001 TYPE p2001,
lt_p2001 TYPE STANDARD TABLE OF p2001,
lx_p0001 TYPE ty_p0001,
lt_p0001 TYPE TABLE OF ty_p0001,
lv_pernr TYPE p2001-pernr,
lt_t503 TYPE TABLE OF ty_t503,
lx_t503 TYPE ty_t503,
ls_p2001 TYPE p2001,
lv_begda TYPE datum,
lv_endda TYPE datum,
lv_date TYPE datum,
lv_fdat TYPE datum,
badi_message_handler TYPE REF TO cl_hrpa_message_list,
msg TYPE symsg,
is_ok TYPE boole_d,
pernr_tab TYPE STANDARD TABLE OF pdpnr,
pernr TYPE pdpnr,
psp TYPE STANDARD TABLE OF pdpsp,
day_psp TYPE STANDARD TABLE OF pdsppsp,
lwa_day_psp TYPE pdpsp.
CONSTANTS:
new_innnn TYPE prelp VALUE '2001'.
**-- OUTTAB
TYPES :
BEGIN OF ty_outtab ,
exception TYPE lvc_exled,
request_id TYPE tim_req_id,
pernr TYPE p0001-pernr,
ename TYPE emnam,
begda TYPE ptreq_attabsdata-begda,
endda TYPE ptreq_attabsdata-endda,
subty TYPE ptreq_attabsdata-subty,
subtytext TYPE sbttx,
status TYPE ptreq_header-status,
notice_text TYPE ptreq_notice-notice_text,
descr TYPE t572b-descr,
mod_user TYPE ptreq_header-mod_user,
customer01 TYPE ptreq_attabsdata-customer01,
customer02 TYPE ptreq_attabsdata-customer02,
customer03 TYPE ptreq_attabsdata-customer03,
customer05 TYPE ptreq_attabsdata-customer05,
umskd TYPE umskd,
END OF ty_outtab .
DATA :
gt_outtab TYPE TABLE OF ty_outtab,
gt_outtab2 TYPE TABLE OF ty_outtab,
gwa_outtab TYPE ty_outtab.
DATA :
lv_subty TYPE p2001-subty.
DATA :
lt_ptreq_header TYPE TABLE OF ptreq_header ,
lt_ptreq_items TYPE TABLE OF ptreq_items ,
lt_ptreq_attabsdata TYPE TABLE OF ptreq_attabsdata.
DATA:
lwa_ptreq_attabsdata TYPE ptreq_attabsdata,
lwa_ptreq_header TYPE ptreq_header,
lwa_ptreq_items TYPE ptreq_items.
DATA:
lwa_ptrqtmp TYPE ty_ptrqtmp,
lt_ptrqtmp TYPE TABLE OF ty_ptrqtmp,
lt_resleave TYPE TABLE OF zhr_resleave,
ls_resleave LIKE LINE OF lt_resleave.
DATA:
lv_balance TYPE ptm_quonum,
lv_btime TYPE begti.
**--Get Attendances/Absences
IF im_attabs_tab IS NOT INITIAL.
MOVE im_attabs_tab TO lt_attabs_tab.
**-- Read table to get request
READ TABLE lt_attabs_tab
INTO lwa_im_attabs INDEX 1.
IF sy-subrc = 0.
lt_p2001 = lwa_im_attabs-abs_attribs.
IF lt_p2001 IS NOT INITIAL .
READ TABLE lt_p2001
INTO ls_p2001 INDEX 1.
lv_pernr = ls_p2001-pernr.
lv_subty = ls_p2001-subty.
lv_begda = ls_p2001-begda.
lv_endda = ls_p2001-endda.
ENDIF.
DATA : LV_DATE_DIFF TYPE I.
**-- Check the difference, if diff greater than 3.
LV_DATE_DIFF = ( lv_endda - lv_begda ).
if lv_date_diff GT 2. " commented to allow more leaves
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '050'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
ENDIF.
**--Get employee group and subgroup
SELECT SINGLE
persg
persk FROM pa0001 INTO lx_p0001
WHERE pernr EQ lv_pernr
AND endda GT sy-datum.
**--Get Employee Subgroup Grouping
SELECT SINGLE
konty FROM t503 INTO lx_t503
WHERE persg = lx_p0001-persg AND
persk = lx_p0001-persk.
ENDIF.
* "" Get Emp Group for Validation
lv_date = lv_begda - 1.
lv_fdat = lv_begda + 1.
IF pernr_tab IS INITIAL .
pernr-pernr = lv_pernr.
APPEND pernr TO pernr_tab.
CLEAR pernr.
ENDIF.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_attabsdata
FROM ptreq_attabsdata WHERE pernr EQ lv_pernr AND
begda GE lv_date AND
endda LE lv_fdat.
LOOP AT lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata.
lwa_ptrqtmp-item_id = lwa_ptreq_attabsdata-item_id.
APPEND lwa_ptrqtmp TO lt_ptrqtmp.
CLEAR lwa_ptrqtmp.
ENDLOOP.
IF lt_ptrqtmp[] IS NOT INITIAL.
SELECT *
FROM ptreq_items INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_items
FOR ALL ENTRIES IN lt_ptrqtmp
WHERE item_ins = lt_ptrqtmp-item_id.
IF lt_ptreq_items[] IS NOT INITIAL.
SELECT *
FROM ptreq_header INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_header
FOR ALL ENTRIES IN lt_ptreq_items
WHERE item_list_id = lt_ptreq_items-item_list_id.
* status ne 'WITHDRAWN' or status ne 'REJECTED'.
IF sy-subrc EQ 0.
ENDIF.
ENDIF.
ENDIF.
CALL FUNCTION 'HR_PERSON_READ_WORK_SCHEDULE'
EXPORTING
begin_date = lv_begda
end_date = lv_endda
TABLES
pernr_tab = pernr_tab
psp = psp
day_psp = day_psp.
CLEAR lt_p2001[].
LOOP AT lt_ptreq_header INTO lwa_ptreq_header.
READ TABLE lt_ptreq_items INTO lwa_ptreq_items WITH KEY item_list_id = lwa_ptreq_header-item_list_id.
* REad TABLE lt_ptrqtmp INTO lwa_ptrqtmp WITH KEY
READ TABLE lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata WITH KEY item_id = lwa_ptreq_items-item_ins.
CHECK sy-subrc = 0.
lx_p2001-pernr = lwa_ptreq_attabsdata-pernr.
lx_p2001-begda = lwa_ptreq_attabsdata-begda.
lx_p2001-endda = lwa_ptreq_attabsdata-endda.
lx_p2001-subty = lwa_ptreq_attabsdata-subty.
APPEND lx_p2001 TO lt_p2001.
ENDLOOP.
LOOP AT lt_p2001 INTO lx_p2001 WHERE ( begda GE lv_date AND endda LE lv_date ) OR
( begda GE lv_fdat AND endda LE lv_fdat ) .
* " Check For Previous Day Absence
* " For Regular Employees
IF lx_p2001-subty = 'RESL'.
SELECT * FROM zhr_resleave
INTO TABLE lt_resleave
WHERE fyear = new_innnn-begda+0(4)
AND begda = new_innnn-begda
AND endda = new_innnn-endda.
IF sy-subrc <> 0.
* MESSAGE ID 'ZHR' TYPE 'E'
* NUMBER '001' WITH new_innnn-begda new_innnn-endda.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '001'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
IF lx_t503-konty = 1 .
*****************half day********************************
IF lx_p2001-subty = 'ERNO' OR
lx_p2001-subty = 'HPAL' OR
lx_p2001-subty = 'OSTR' OR
lx_p2001-subty = 'CHCL' OR
lx_p2001-subty = 'CMLL' .
IF ( lx_p2001-subty = 'ERNO' OR
lx_p2001-subty = 'HPAL' OR
lx_p2001-subty = 'CMLL' ) AND ( ls_p2001-stdaz LT 7 AND ls_p2001-stdaz IS NOT INITIAL ). "28.04.2015
IF ls_p2001-subty = 'CASL'.
READ TABLE psp INTO lwa_day_psp WITH KEY datum = ls_p2001-begda.
IF sy-subrc = 0.
IF lwa_day_psp-begzt+0(2) GE 21.
lv_btime+0(2) = lwa_day_psp-endzt+0(2) - 4.
ELSE.
lv_btime+0(2) = lwa_day_psp-begzt+0(2) + 04.
ENDIF.
CONCATENATE lv_btime+0(2) lwa_day_psp-begzt+2(4) INTO lv_btime.
* IF lwa_day_psp-endzt GE ls_p2001-enduz.
* ELSE
IF ( lv_btime = ls_p2001-enduz ) OR ( ls_p2001-enduz BETWEEN lv_btime AND ls_p2001-enduz ).
IF ls_p2001-enduz GE lwa_day_psp-endzt.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '046'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '046'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* ENDIF.
ENDIF.
ENDIF.
ELSE.
**********************************
IF ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'NRAL'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
* MESSAGE E031(ZHR).
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
***added*on 22.04.2015*********************************************
if ( LX_P2001-SUBTY = 'ERNO' and LS_P2001-SUBTY = 'CHCL' )
or ( LX_P2001-SUBTY = 'HPAL' and LS_P2001-SUBTY = 'CHCL' )
or ( LX_P2001-SUBTY = 'CMLL' and LS_P2001-SUBTY = 'CHCL' )
or ( LX_P2001-SUBTY = 'CHCL' and LS_P2001-SUBTY = 'UNAL' )
or ( LX_P2001-SUBTY = 'NRAL' and LS_P2001-SUBTY = 'UNAL' )
or ( LX_P2001-SUBTY = 'OSTR' and LS_P2001-SUBTY = 'CHCL' ).
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
* MESSAGE E031(ZHR).
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
****end**********************************************
ENDIF.
ENDIF.
*********** 28.04.2015 - start " Half Pay Leave
**
**if ( ls_p2001-subty = 'CASL' OR
** ls_p2001-subty = 'SCAL' OR
** ls_p2001-subty = 'SDYL' OR
** ls_p2001-subty = 'CHCL' OR
** ls_p2001-subty = 'COFF' OR
** ls_p2001-subty = 'RESL' ) AND
** lx_p2001-subty = 'ERNO'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**
** elseif ( ls_p2001-subty = 'CASL' OR
** ls_p2001-subty = 'SCAL' OR
** ls_p2001-subty = 'SDYL' OR
** ls_p2001-subty = 'CHCL' OR
** ls_p2001-subty = 'STTL' OR
** ls_p2001-subty = 'COFF' OR
** ls_p2001-subty = 'RESL' ) AND
** lx_p2001-subty = 'HPAL'.
**
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
** elseif ( ls_p2001-subty = 'ERNO' OR
** ls_p2001-subty = 'HPAL' OR
** ls_p2001-subty = 'CMLL' OR
** ls_p2001-subty = 'EORO' OR
** ls_p2001-subty = 'SDYL' OR
** ls_p2001-subty = 'SPDL' OR
** ls_p2001-subty = 'CHCL' OR
** ls_p2001-subty = 'MATL' OR
** ls_p2001-subty = 'NRAL' OR
** ls_p2001-subty = 'UNAL' ) AND
** lx_p2001-subty = 'CASL'.
**
**
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
** ELSEIF ( ls_p2001-subty = 'CASL' OR
** ls_p2001-subty = 'CMLL' OR
** ls_p2001-subty = 'SCAL' OR
** ls_p2001-subty = 'SDYL' OR
** ls_p2001-subty = 'CHCL' OR
** ls_p2001-subty = 'MATL' OR
** ls_p2001-subty = 'RESL' OR
** ls_p2001-subty = 'COFF' ) AND
** lx_p2001-subty = 'EORO'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
** ELSEIF ( ls_p2001-subty = 'EORO' OR
**ls_p2001-subty = 'SDYL' OR
**ls_p2001-subty = 'SPDL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'MATL' OR
**ls_p2001-subty = 'NRAL' OR
**ls_p2001-subty = 'DOFF' OR
**ls_p2001-subty = 'UNAL' OR
**ls_p2001-subty = 'OSTR' ) AND
**lx_p2001-subty = 'SCAL'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**ELSEIF ( ls_p2001-subty = 'CASL' OR
**ls_p2001-subty = 'SDYL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'NRAL' OR
**ls_p2001-subty = 'COFF' OR
**ls_p2001-subty = 'RESL' OR
**ls_p2001-subty = 'OSTR' ) AND
**lx_p2001-subty = 'SPDL'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**ELSEIF ( ls_p2001-subty = 'CASL' OR
**ls_p2001-subty = 'SCAL' OR
**ls_p2001-subty = 'SDYL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'COFF' OR
**ls_p2001-subty = 'UNAL' OR
**ls_p2001-subty = 'RESL' ) AND
**lx_p2001-subty = 'CHCL'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**
**ELSEIF ( ls_p2001-subty = 'NRAL' OR
**ls_p2001-subty = 'CASL' OR
**ls_p2001-subty = 'SCAL' OR
**ls_p2001-subty = 'SDYL' OR
**ls_p2001-subty = 'SPDL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'COFF' OR
**ls_p2001-subty = 'RESL' OR
**ls_p2001-subty = 'OSTR' ) AND
**lx_p2001-subty = 'MATL'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**** -- NRAL
**ELSEIF ( ls_p2001-subty = 'SCAL' OR
**ls_p2001-subty = 'CASL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'COFF' OR
**ls_p2001-subty = 'UNAL' OR
**ls_p2001-subty = 'RESL' OR
**ls_p2001-subty = 'OSTR' ) AND
**lx_p2001-subty = 'NRAL'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**** -- COFF
**
**
**ELSEIF ( ls_p2001-subty = 'ERNO' OR
**ls_p2001-subty = 'HPAL' OR
**ls_p2001-subty = 'CMLL' OR
**ls_p2001-subty = 'EORO' OR
**ls_p2001-subty = 'SDYL' OR
**ls_p2001-subty = 'SPDL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'MATL' OR
**ls_p2001-subty = 'NRAL' OR
**ls_p2001-subty = 'UNAL' OR
**ls_p2001-subty = 'OSTR' OR
**ls_p2001-subty = 'STTL' ) AND
**lx_p2001-subty = 'COFF'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**
**ELSEIF ( ls_p2001-subty = 'CASL' OR
**ls_p2001-subty = 'SCAL' OR
**ls_p2001-subty = 'SDYL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'COFF' OR
**ls_p2001-subty = 'DOFF' OR
**ls_p2001-subty = 'RESL' ) AND
**lx_p2001-subty = 'OSTR'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**
**ELSEIF ( ls_p2001-subty = 'CASL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'COFF' OR
**ls_p2001-subty = 'UNAL' OR
**ls_p2001-subty = 'OSTR' OR
**ls_p2001-subty = 'RESL' ) AND
**lx_p2001-subty = 'UNAL'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**
**ELSEIF ( ls_p2001-subty = 'CMLL' OR
**ls_p2001-subty = 'SPDL' OR
**ls_p2001-subty = 'ERNO' OR
**ls_p2001-subty = 'EORO' OR
**ls_p2001-subty = 'HPAL' OR
**ls_p2001-subty = 'MATL' OR
**ls_p2001-subty = 'NRAL' OR
**ls_p2001-subty = 'SDYL' OR
**ls_p2001-subty = 'CHCL' OR
**ls_p2001-subty = 'STTL' OR
**ls_p2001-subty = 'UNAL' OR
**ls_p2001-subty = 'OSTR' ) AND
**lx_p2001-subty = 'DOFF'.
**** -- Error message
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
**
**
**ENDIF.
********* 28.04.2015 - end
data : lv_date10 type datum.
lv_date10 = ( ls_p2001-endda + 1 ).
**--CHCL
IF
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'SCAL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- CASL
elseif
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'UNAL' ) AND
lx_p2001-subty = 'CASL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
**-- CMLL
elseif
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'CMLL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
**-- COFF
elseif
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'UNAL' ) AND
lx_p2001-subty = 'COFF' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- DOFF
elseif
( ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'OSTR' ) AND
lx_p2001-subty = 'DOFF' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- EORO
elseif
( ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'EORO' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- ERNO
elseif
( ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'ERNO' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- hpal
elseif
( ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'HPAL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- MATL
elseif
( ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'MATL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- NRAL
elseif
( ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'NRAL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- OSTR
elseif
( ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'OSTR' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- RESL
elseif
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'UNAL' ) AND
lx_p2001-subty = 'RESL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- SCAL
elseif
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'OSTR' ) AND
lx_p2001-subty = 'SCAL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- SDYL
elseif
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' OR
ls_p2001-subty = 'OSTR' ) AND
lx_p2001-subty = 'SDYL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- SPDL
elseif
( ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'SPDL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- STTL
elseif
( ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'STTL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
** -- UNAL
elseif
( ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'DOFF' ) AND
lx_p2001-subty = 'UNAL' and lx_p2001-begda = lv_date10.
** -- Error message
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
endif.
*****added on 04,05,2015
***end of addition on 04.05.2015
* "Casual Leave- Regular
IF lx_p2001-subty = 'CASL'.
IF ls_p2001-subty = 'CASL'
AND ls_p2001-stdaz LT 7.
READ TABLE psp INTO lwa_day_psp WITH KEY datum = ls_p2001-begda.
IF sy-subrc = 0.
IF lwa_day_psp-begzt+0(2) GE 21.
lv_btime+0(2) = lwa_day_psp-endzt+0(2) - 4.
ELSE.
lv_btime+0(2) = lwa_day_psp-endzt+0(2) - 04.
ENDIF.
IF ls_p2001-beguz BETWEEN lv_btime AND ls_p2001-enduz.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '046'.
* MESSAGE E046(ZHR).
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '046'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ELSE.
IF
ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'RESL' OR
ls_p2001-subty = 'STTL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'DOFF' OR
ls_p2001-subty = 'OT2A' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'MATL' OR
* ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'CHCL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'SDYL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'HPAL' OR "added for first half
ls_p2001-subty = 'ERNO'. "added for first half CASL and ERNO.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
* "" Extra Ordinary Leave
IF lx_p2001-subty = 'EORO'.
IF lx_p2001-subty = 'EORO'
AND ls_p2001-stdaz LT 7.
IF ls_p2001-subty = 'CASL'.
READ TABLE psp INTO lwa_day_psp WITH KEY datum = ls_p2001-begda.
IF sy-subrc = 0.
IF lwa_day_psp-begzt+0(2) GE 21.
lv_btime+0(2) = lwa_day_psp-endzt+0(2) - 4.
ELSE.
lv_btime+0(2) = lwa_day_psp-begzt+0(2) + 04.
ENDIF.
CONCATENATE lv_btime+0(2) lwa_day_psp-begzt+2(4) INTO lv_btime.
* IF lwa_day_psp-endzt GE ls_p2001-enduz.
* ELSE
IF ( lv_btime = ls_p2001-enduz ) OR ( ls_p2001-enduz BETWEEN lv_btime AND ls_p2001-enduz ).
IF ls_p2001-enduz GE lwa_day_psp-endzt.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '046'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '046'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSE.
IF ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'ERNO' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
* "" Special Casual Leave
IF lx_p2001-subty = 'SCAL'.
IF ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'RESL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'OT2A' OR
ls_p2001-subty = 'CMLL' .
ELSE.
** msg-msgid = 'ZHR'."'YHBN'. "commented because of first and second half 25.04.2015
** msg-msgty = 'E'.
** msg-msgno = '031'.
** CALL METHOD message_handler->add_message
** EXPORTING
** im_type = 'E'
** im_cl = 'ZHR'
** im_number = '031'
** im_par1 = ''
** im_par2 = ''
** im_par3 = ''
** im_context = ''
** im_subcontext = ''
** im_classname = 'ZHR'
** im_methodname = 'MESSAGE'.
** RETURN.
ENDIF.
ENDIF.
* "" Special Disability Leave
IF lx_p2001-subty = 'SPDL'.
IF lx_p2001-subty = 'SPDL'
AND ls_p2001-stdaz LT 7.
IF ls_p2001-subty = 'CASL'.
READ TABLE psp INTO lwa_day_psp WITH KEY datum = ls_p2001-begda.
IF sy-subrc = 0.
IF lwa_day_psp-begzt+0(2) GE 21.
lv_btime+0(2) = lwa_day_psp-endzt+0(2) - 4.
ELSE.
lv_btime+0(2) = lwa_day_psp-begzt+0(2) + 04.
ENDIF.
CONCATENATE lv_btime+0(2) lwa_day_psp-begzt+2(4) INTO lv_btime.
* IF lwa_day_psp-endzt GE ls_p2001-enduz.
* ELSE
IF ( lv_btime = ls_p2001-enduz ) OR ( ls_p2001-enduz BETWEEN lv_btime AND ls_p2001-enduz ).
IF ls_p2001-enduz GE lwa_day_psp-endzt.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '046'.
**
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '046'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSE.
IF ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'HPAL' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
* "" Settling time leave
IF lx_p2001-subty = 'STTL'.
IF ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'RESL' OR
ls_p2001-subty = 'DOFF' OR
ls_p2001-subty = 'OT2A' OR
ls_p2001-subty = 'NRAL'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
IF lx_p2001-subty = 'COFF' OR
lx_p2001-subty = 'DOFF' OR
lx_p2001-subty = 'RESL' .
IF ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'CASL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'DOFF' OR
ls_p2001-subty = 'OT2A' OR
ls_p2001-subty = 'RESL' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
*MATL Maternity Leave
IF lx_p2001-subty = 'MATL'.
IF lx_p2001-subty = 'MATL'
AND ls_p2001-stdaz LT 7.
IF ls_p2001-subty = 'CASL'.
READ TABLE psp INTO lwa_day_psp WITH KEY datum = ls_p2001-begda.
IF sy-subrc = 0.
IF lwa_day_psp-begzt+0(2) GE 21.
lv_btime+0(2) = lwa_day_psp-endzt+0(2) - 4.
ELSE.
lv_btime+0(2) = lwa_day_psp-begzt+0(2) + 04.
ENDIF.
CONCATENATE lv_btime+0(2) lwa_day_psp-begzt+2(4) INTO lv_btime.
* IF lwa_day_psp-endzt GE ls_p2001-enduz.
* ELSE
IF ( lv_btime = ls_p2001-enduz ) OR ( ls_p2001-enduz BETWEEN lv_btime AND ls_p2001-enduz ).
IF ls_p2001-enduz GE lwa_day_psp-endzt.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '046'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '046'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSE.
IF ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'METR' OR
ls_p2001-subty = 'MEDT' OR
ls_p2001-subty = 'MEDL' OR
ls_p2001-subty = 'NRAL' .
ELSE.
msg-msgid = 'ZHR'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
*NRAL NR Absence
IF lx_p2001-subty = 'NRAL' OR
lx_p2001-subty = 'UNAL' .
IF ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'SDYL' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
**********************************************************************
* FOR Employee Group D Absence Type 2
* Leave Restriction For Labour Confirmation
**********************************************************************
ELSEIF lx_t503-konty = 2.
* ERNL Earned Leave- Reg Labour
* MEDL Medi Leave- Confirm Labour
* SPDL Special Disability Leave
* MATL Maternity Leave
* NRAL NR Absence
* UNAL Unauthorised Absence
* OSTR On Strike
* EORO Extra Ordinary Leave
IF lx_p2001-subty = 'ERNL' OR
lx_p2001-subty = 'SPDL' OR
lx_p2001-subty = 'MATL' OR
lx_p2001-subty = 'NRAL' OR
lx_p2001-subty = 'UNAL' OR
lx_p2001-subty = 'OSTR' OR
lx_p2001-subty = 'EORO' OR
lx_p2001-subty = 'MEDL' .
IF ls_p2001-subty = 'ERNL' OR
ls_p2001-subty = 'MEDL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'UNAL'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
*COFF Compensatory Off
*DOFF Dharma OFF
IF lx_p2001-subty = 'COFF' OR
lx_p2001-subty = 'DOFF' OR
lx_p2001-subty = 'SCAL' OR
lx_p2001-subty = 'CSLL' .
IF ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'CSLL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'RESL' OR
ls_p2001-subty = 'DOFF' OR
ls_p2001-subty = 'OT2A'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* Employee Sub Group 4
ELSEIF lx_t503-konty = 4 .
" Rectriction For Earned Leave Reg, Half Pay Leave
IF lx_p2001-subty = 'ELPR' OR
lx_p2001-subty = 'HPAL' OR
lx_p2001-subty = 'OSTR' OR
lx_p2001-subty = 'CHCL' OR
lx_p2001-subty = 'CMLL' .
IF ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'ELPR' OR
ls_p2001-subty = 'NRAL'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* Casual Leave- Regular
IF lx_p2001-subty = 'CSRP'.
IF ls_p2001-subty = 'CSRP' OR
ls_p2001-subty = 'RESL' OR
ls_p2001-subty = 'STTL' OR
ls_p2001-subty = 'SACL' OR
ls_p2001-subty = 'OSTR' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* "" Extra Ordinary Leave
IF lx_p2001-subty = 'EORO'.
IF ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'ERNO' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
**
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* "" Special Casual Leave
IF lx_p2001-subty = 'SCAL'.
IF ls_p2001-subty = 'CSRP' OR
ls_p2001-subty = 'RESL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'CMLL'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* Special Disability Leave
IF lx_p2001-subty = 'SPDL'.
IF ls_p2001-subty = 'ERPR' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'HPAL' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* "" Settling time leave
IF lx_p2001-subty = 'STTL'.
IF ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'OSTR' OR
ls_p2001-subty = 'RESL' OR
ls_p2001-subty = 'NRAL'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
*COFF Compensatory Off
*DOFF Dharma OFF
IF lx_p2001-subty = 'DOFF' OR
lx_p2001-subty = 'RESL' .
IF ls_p2001-subty = 'COFF' OR
ls_p2001-subty = 'CSRP' OR
ls_p2001-subty = 'SCAL' OR
ls_p2001-subty = 'RESL' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
*MATL Maternity Leave
IF lx_p2001-subty = 'MATL' .
IF ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'ELPR' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'NRAL' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
*NRAL NR Absence
IF lx_p2001-subty = 'NRAL' OR
lx_p2001-subty = 'UNAL' .
.
IF ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'ELPR' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'SDYL' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ELSEIF lx_t503-konty = 6.
* NRAL NR Absence
IF lx_p2001-subty = 'METR' OR
lx_p2001-subty = 'EORO' OR
lx_p2001-subty = 'NRAL' OR
lx_p2001-subty = 'UNAL' OR
lx_p2001-subty = 'OSTR' OR
lx_p2001-subty = 'MATL'.
IF ( lx_p2001-subty = 'METR' OR
lx_p2001-subty = 'EORO' OR
lx_p2001-subty = 'NRAL' OR
lx_p2001-subty = 'UNAL' OR
lx_p2001-subty = 'OSTR' OR
lx_p2001-subty = 'MATL' ) AND ls_p2001-stdaz LT 7.
ELSE.
IF ls_p2001-subty = 'METR' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'OSTR'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF.
IF lx_p2001-subty = 'CSRT' OR
lx_p2001-subty = 'COFF'.
IF ls_p2001-subty = 'CSRT' OR
ls_p2001-subty = 'COFF' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
* Absence Combination Restriction For Trainee Labours
ELSEIF lx_t503-konty = 5.
*MEDT Medi Leave- Labour Trainee
*EORO Extra Ordinary Leave
*MATL Maternity Leave
*MTPL MTP Leave
*UNAL Unauthorised Absence
*OSTR On Strike
IF lx_p2001-subty = 'MEDT' OR
lx_p2001-subty = 'EORO' OR
lx_p2001-subty = 'NRAL' OR
lx_p2001-subty = 'UNAL' OR
lx_p2001-subty = 'OSTR' OR
lx_p2001-subty = 'MATL' OR
lx_p2001-subty = 'SPDL' OR
lx_p2001-subty = 'MTPL'.
IF ls_p2001-subty = 'MEDT' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'MATL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'OSTR'.
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
IF lx_p2001-subty = 'CSLT' OR
lx_p2001-subty = 'COFF'.
IF ls_p2001-subty = 'CSLT' OR
ls_p2001-subty = 'COFF' .
ELSE.
msg-msgid = 'ZHR'."'YHBN'.
msg-msgty = 'E'.
msg-msgno = '031'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
ENDIF.
ENDIF.
ENDIF. " Check For Absence Type
* ENDIF.
ENDLOOP. "" Check For Dates
* ENDLOOP.
***23.04.2015*********More than 3 COFF, DOFF, OT2A all the combinations*****
clear : lv_date,
lv_fdat,
lt_ptreq_attabsdata,
lt_ptrqtmp.
**-- taking 3 previous and forward days.
lv_date = lv_begda - 3.
lv_fdat = lv_begda + 3.
** IF pernr_tab IS INITIAL .
** pernr-pernr = lv_pernr.
** APPEND pernr TO pernr_tab.
** CLEAR pernr.
** ENDIF.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_attabsdata
FROM ptreq_attabsdata WHERE pernr EQ lv_pernr AND
begda GE lv_date AND
endda LE lv_fdat.
LOOP AT lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata.
lwa_ptrqtmp-item_id = lwa_ptreq_attabsdata-item_id.
APPEND lwa_ptrqtmp TO lt_ptrqtmp.
CLEAR lwa_ptrqtmp.
ENDLOOP.
IF lt_ptrqtmp[] IS NOT INITIAL.
SELECT *
FROM ptreq_items INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_items
FOR ALL ENTRIES IN lt_ptrqtmp
WHERE item_ins = lt_ptrqtmp-item_id.
IF lt_ptreq_items[] IS NOT INITIAL.
SELECT *
FROM ptreq_header INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_header
FOR ALL ENTRIES IN lt_ptreq_items
WHERE item_list_id = lt_ptreq_items-item_list_id.
*
IF sy-subrc EQ 0.
ENDIF.
ENDIF.
ENDIF.
CALL FUNCTION 'HR_PERSON_READ_WORK_SCHEDULE'
EXPORTING
begin_date = lv_begda
end_date = lv_endda
TABLES
pernr_tab = pernr_tab
psp = psp
day_psp = day_psp.
CLEAR lt_p2001[].
LOOP AT lt_ptreq_header INTO lwa_ptreq_header.
READ TABLE lt_ptreq_items INTO lwa_ptreq_items WITH KEY item_list_id = lwa_ptreq_header-item_list_id.
* REad TABLE lt_ptrqtmp INTO lwa_ptrqtmp WITH KEY
READ TABLE lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata WITH KEY item_id = lwa_ptreq_items-item_ins.
CHECK sy-subrc = 0.
lx_p2001-pernr = lwa_ptreq_attabsdata-pernr.
lx_p2001-begda = lwa_ptreq_attabsdata-begda.
lx_p2001-endda = lwa_ptreq_attabsdata-endda.
lx_p2001-subty = lwa_ptreq_attabsdata-subty.
APPEND lx_p2001 TO lt_p2001.
ENDLOOP.
data : lv_counter type i.
data : lv_diff type i.
clear lx_p2001.
clear lv_counter.
delete ADJACENT DUPLICATES FROM lt_p2001 COMPARING ALL FIELDS.
**Checking for 3 Days Prior to Actual Leave
LOOP AT lt_p2001 INTO lx_p2001 WHERE begda GE LV_DATE and
endda le lv_BEGDA.
CHECK lx_p2001-subty = 'COFF' OR lx_p2001-subty = 'OT2A' OR lx_p2001-subty = 'DOFF'.
lv_diff = lx_p2001-endda - lx_p2001-begda.
if lv_diff eq '0'.
lv_counter = lv_counter + 1.
else.
lv_diff = lv_diff + 1.
do lv_diff times.
lv_counter = lv_counter + 1.
enddo.
endif.
ENDLOOP.
"check
if ( ls_p2001-subty = 'DOFF' ) or
( ls_p2001-subty = 'COFF' ) or
( ls_p2001-subty = 'OT2A' ).
if ls_p2001-begda eq ls_p2001-endda.
lv_counter = lv_counter + 1.
else.
lv_counter = lv_counter + 2.
endif.
endif.
if lv_counter ge '4'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '051'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
endif.
clear lv_counter.
**Checking for 3 Days POST to Actual Leave
LOOP AT lt_p2001 INTO lx_p2001 WHERE begda GE LV_BEGDA and
endda LE LV_FDAT." AND endda LE lv_fdat ).
CHECK lx_p2001-subty = 'COFF' OR lx_p2001-subty = 'OT2A' OR lx_p2001-subty = 'DOFF'.
lv_diff = lx_p2001-endda - lx_p2001-begda.
if lv_diff eq '0'.
lv_counter = lv_counter + 1.
else.
lv_diff = lv_diff + 1.
do lv_diff times.
lv_counter = lv_counter + 1.
enddo.
endif.
ENDLOOP.
"check
if ( ls_p2001-subty = 'DOFF' ) or
( ls_p2001-subty = 'COFF' ) or
( ls_p2001-subty = 'OT2A' ).
lv_counter = lv_counter + 1.
endif.
if lv_counter ge '4'.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '051'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
endif.
******************************* for month ***********************
data : lv_firstday type SY-DATUM,
lv_lastday type SY-DATUM.
data : lv_MONTH TYPE FCMNR,
lv_YEAR TYPE GJAHR.
lv_month = lv_begda+4(2).
lv_year = lv_begda+0(4).
CALL FUNCTION 'OIL_MONTH_GET_FIRST_LAST'
EXPORTING
I_MONTH = lv_month
I_YEAR = lv_year
I_DATE = lv_begda
IMPORTING
E_FIRST_DAY = lv_firstday
E_LAST_DAY = lv_lastday
EXCEPTIONS
WRONG_DATE = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_attabsdata
FROM ptreq_attabsdata WHERE pernr EQ lv_pernr AND
begda GE lv_firstday AND
endda LE lv_lastday.
LOOP AT lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata.
lwa_ptrqtmp-item_id = lwa_ptreq_attabsdata-item_id.
APPEND lwa_ptrqtmp TO lt_ptrqtmp.
CLEAR lwa_ptrqtmp.
ENDLOOP.
IF lt_ptrqtmp[] IS NOT INITIAL.
SELECT *
FROM ptreq_items INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_items
FOR ALL ENTRIES IN lt_ptrqtmp
WHERE item_ins = lt_ptrqtmp-item_id.
IF lt_ptreq_items[] IS NOT INITIAL.
SELECT *
FROM ptreq_header INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_header
FOR ALL ENTRIES IN lt_ptreq_items
WHERE item_list_id = lt_ptreq_items-item_list_id.
*
IF sy-subrc EQ 0.
ENDIF.
ENDIF.
ENDIF.
CALL FUNCTION 'HR_PERSON_READ_WORK_SCHEDULE'
EXPORTING
begin_date = lv_begda
end_date = lv_endda
TABLES
pernr_tab = pernr_tab
psp = psp
day_psp = day_psp.
CLEAR lt_p2001[].
LOOP AT lt_ptreq_header INTO lwa_ptreq_header.
READ TABLE lt_ptreq_items INTO lwa_ptreq_items WITH KEY item_list_id = lwa_ptreq_header-item_list_id.
* REad TABLE lt_ptrqtmp INTO lwa_ptrqtmp WITH KEY
READ TABLE lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata WITH KEY item_id = lwa_ptreq_items-item_ins.
CHECK sy-subrc = 0.
lx_p2001-pernr = lwa_ptreq_attabsdata-pernr.
lx_p2001-begda = lwa_ptreq_attabsdata-begda.
lx_p2001-endda = lwa_ptreq_attabsdata-endda.
lx_p2001-subty = lwa_ptreq_attabsdata-subty.
APPEND lx_p2001 TO lt_p2001.
ENDLOOP.
clear lx_p2001.
clear lv_counter.
clear lv_Date.
data : lwa_p2001 TYPE p2001.
data : lv_counter2 type i.
data : lv_date2 type datum.
data : lv_date_check type datum.
**Checking for 3 Days Prior to Actual Leave
delete ADJACENT DUPLICATES FROM lt_p2001 COMPARING ALL FIELDS.
** LOOP AT lt_p2001 INTO lx_p2001 where subty = 'COFF'.
**
** lv_diff = lx_p2001-endda - lx_p2001-begda.
** if lv_diff gt 0.
** lv_counter = lv_counter + 1.
**
** else.
** lv_counter = lv_counter + 1.
** check lv_date_check NE lx_p2001-begda.
** lv_date = lx_p2001-begda + 1.
** lv_counter = lv_counter + 1.
** read table lt_p2001 into lwa_p2001 with key begda = lv_date.
** check sy-subrc eq 0.
** lv_date = lwa_p2001-begda + 1.
** lv_counter = lv_counter + 1.
** read table lt_p2001 into lwa_p2001 with key begda = lv_date.
** check sy-subrc eq 0.
** lv_date_check = lv_date.
** endif.
**
** ENDLOOP.
data : lv_date3 type datum.
loop at lt_p2001 into lx_p2001 where subty eq 'COFF'.
IF lx_p2001-begda NE lx_p2001-endda.
lv_diff = lx_p2001-endda - lx_p2001-begda.
lv_counter = lv_counter + 1.
else.
check lv_date3 ne lx_p2001-begda.
lv_date = lx_p2001-begda + 1.
read table lt_p2001 into lwa_p2001 with key begda = lv_date.
check sy-subrc eq 0.
lv_counter = lv_counter + 1.
lv_date2 = lwa_p2001-begda + 1.
read table lt_p2001 into lwa_p2001 with key begda = lv_date2.
check sy-subrc = 0.
lv_date3 = lv_date2 - 1 .
endif.
endloop.
clear lv_diff.
if ls_p2001-subty = 'COFF'.
*lv_diff = ls_p2001-endda - ls_p2001-begda.
*check lv_diff ge 1.
lv_counter = lv_counter + 1.
endif.
if lv_counter GT 3.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '052'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
endif.
*************************year validation*****************************************************
data : lv_firstyear type SY-DATUM,
lv_lastyear type SY-DATUM.
data : lv_1yr_beg type string.
data : lv_1yr_end type string.
lv_month = lv_begda+4(2).
lv_year = lv_begda+0(4).
CONCATENATE lv_begda+0(4) '01' '01' into lv_1yr_beg.
CONDENSE lv_1yr_beg.
CONCATENATE lv_begda+0(4) '12' '31' into lv_1yr_end.
CONDENSE lv_1yr_end.
lv_firstyear = lv_1yr_beg.
lv_lastyear = lv_1yr_end.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_attabsdata
FROM ptreq_attabsdata WHERE pernr EQ lv_pernr AND
begda GE lv_1yr_beg AND
endda LE lv_1yr_end.
LOOP AT lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata.
lwa_ptrqtmp-item_id = lwa_ptreq_attabsdata-item_id.
APPEND lwa_ptrqtmp TO lt_ptrqtmp.
CLEAR lwa_ptrqtmp.
ENDLOOP.
IF lt_ptrqtmp[] IS NOT INITIAL.
SELECT *
FROM ptreq_items INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_items
FOR ALL ENTRIES IN lt_ptrqtmp
WHERE item_ins = lt_ptrqtmp-item_id.
IF lt_ptreq_items[] IS NOT INITIAL.
SELECT *
FROM ptreq_header INTO CORRESPONDING FIELDS OF TABLE lt_ptreq_header
FOR ALL ENTRIES IN lt_ptreq_items
WHERE item_list_id = lt_ptreq_items-item_list_id.
*
IF sy-subrc EQ 0.
ENDIF.
ENDIF.
ENDIF.
CALL FUNCTION 'HR_PERSON_READ_WORK_SCHEDULE'
EXPORTING
begin_date = lv_begda
end_date = lv_endda
TABLES
pernr_tab = pernr_tab
psp = psp
day_psp = day_psp.
CLEAR lt_p2001[].
LOOP AT lt_ptreq_header INTO lwa_ptreq_header.
READ TABLE lt_ptreq_items INTO lwa_ptreq_items WITH KEY item_list_id = lwa_ptreq_header-item_list_id.
* REad TABLE lt_ptrqtmp INTO lwa_ptrqtmp WITH KEY
READ TABLE lt_ptreq_attabsdata INTO lwa_ptreq_attabsdata WITH KEY item_id = lwa_ptreq_items-item_ins.
CHECK sy-subrc = 0.
lx_p2001-pernr = lwa_ptreq_attabsdata-pernr.
lx_p2001-begda = lwa_ptreq_attabsdata-begda.
lx_p2001-endda = lwa_ptreq_attabsdata-endda.
lx_p2001-subty = lwa_ptreq_attabsdata-subty.
APPEND lx_p2001 TO lt_p2001.
ENDLOOP.
clear lx_p2001.
clear lv_counter.
clear lv_Date.
**Checking for 3 Days Prior to Actual Leave
delete ADJACENT DUPLICATES FROM lt_p2001 COMPARING ALL FIELDS.
loop at lt_p2001 into lx_p2001 where subty eq 'CMLL'.
IF lx_p2001-begda NE lx_p2001-endda.
lv_diff = lx_p2001-endda - lx_p2001-begda.
lv_counter = lv_counter + 1.
else.
check lv_date3 ne lx_p2001-begda.
lv_date = lx_p2001-begda + 1.
read table lt_p2001 into lwa_p2001 with key begda = lv_date.
check sy-subrc eq 0.
lv_counter = lv_counter + 1.
lv_date2 = lwa_p2001-begda + 1.
read table lt_p2001 into lwa_p2001 with key begda = lv_date2.
check sy-subrc = 0.
lv_date3 = lv_date2.
endif.
endloop.
clear lv_diff.
if ls_p2001-subty = 'CMLL'.
*lv_diff = ls_p2001-endda - ls_p2001-begda.
*check lv_diff ge 1.
lv_counter = lv_counter + 1.
endif.
if lv_counter GT 3.
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '053'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
endif.
**************************end of year validation********************************************
***23.04.2015***************************************************************
************************ half day ********************
clear lwa_im_attabs.
loop at lt_attabs_tab into lwa_im_attabs.
lt_p2001 = lwa_im_attabs-abs_attribs.
lv_date = ( ls_p2001-begda - 1 ).
read table lt_p2001 into lwa_p2001 with key endda = lv_date.
check sy-subrc eq 0.
CHECK lwa_p2001-subty = 'CASL' AND
( ls_p2001-subty = 'ERNO' OR
ls_p2001-subty = 'HPAL' OR
ls_p2001-subty = 'CMLL' OR
ls_p2001-subty = 'SPDL' OR
ls_p2001-subty = 'NRAL' OR
ls_p2001-subty = 'UNAL' OR
ls_p2001-subty = 'EORO' OR
ls_p2001-subty = 'MATL' ).
READ TABLE PSP INTO lwa_day_psp INDEX 1.
CHECK SY-SUBRC EQ 0.
LV_DIFF = ( LWA_DAY_PSP-endzt+0(2) - LWA_DAY_PSP-begzt+0(2) ) / 2 .
lv_btime+0(2) = lwa_day_psp-begzt+0(2) + LV_DIFF.
CHECK LV_BTIME+0(2) EQ LWA_P2001-beguz+0(2).
CALL METHOD message_handler->add_message
EXPORTING
im_type = 'E'
im_cl = 'ZHR'
im_number = '031'
im_par1 = ''
im_par2 = ''
im_par3 = ''
im_context = ''
im_subcontext = ''
im_classname = 'ZHR'
im_methodname = 'MESSAGE'.
RETURN.
endloop.
ENDIF.
* ENDIF.
ENDENHANCEMENT.
No comments:
Post a Comment