ABAP – Program for getting Holidays information

In ABAP we can get the complete information about the holidays for an employee. That can be done as follows:

 

REPORT ZTEST.

INFOTYPES : 0001.
TABLES: PERNR.

data: l_hcalno type HIDENT,
count TYPE i  .
Data: it_holidays TYPE STANDARD TABLE OF ISCAL_DAY.

START-OF-SELECTION.

GET PERNR.

rp_provide_from_last p0001 space pn-begda pn-endda.

IF sy-subrc = 0.
SELECT SINGLE mofid FROM t001p INTO l_hcalno WHERE werks = p0001-werks
AND btrtl = p0001-btrtl.
ENDIF.

REFRESH: it_holidays.
CALL FUNCTION ‘HOLIDAY_GET’
EXPORTING
holiday_calendar           = l_hcalno
date_from                  = pn-begda
date_to                    = pn-endda
TABLES
holidays                   = it_holidays
EXCEPTIONS
factory_calendar_not_found = 1
holiday_calendar_not_found = 2
date_has_invalid_format    = 3
date_inconsistency         = 4
OTHERS                     = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

count = lines( it_holidays ).

WRITE: ‘Number of holidays’, count.

 

Output will displays the number of holidays for the employee in his working period.

 

0 Comments

Leave A Reply