Skip to Content
author's profile photo Former Member
Former Member

regarding HR-abap Attendence Sheet for Employee

Hello Friends,

i am working on attendence sheet for employee please help me possible send me sample coding ASAP.

Thanks

REDDY.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 11:11 AM

    Check out this report we have created for the Attendence. Reward points if it is useful.

    REPORT ZHR_ATTENDANCE_RPT MESSAGE-ID ZHR.

    ----


    • T Y P E P O O L S *

    ----


    TYPE-POOLS : SLIS.

    ----


    • T A B L E *

    ----


    TABLES : TEVEN,

    PA0000,

    PA0001,

    T503K,

    T500P.

    ----


    • I N T E R N A L T A B L E D E C L A R A T I O N *

    ----


    DATA : BEGIN OF IT_PA0001 OCCURS 0,

    PERNR TYPE PA0001-PERNR,

    ENDDA TYPE PA0001-ENDDA,

    WERKS TYPE PA0001-WERKS,

    BTRTL TYPE PA0001-BTRTL,

    ORGEH TYPE PA0001-ORGEH,

    PERSK TYPE T503T-PERSK,

    ENAME TYPE PA0001-ENAME,

    END OF IT_PA0001.

    DATA : BEGIN OF IT_PA0000 OCCURS 0,

    PERNR TYPE PA0000-PERNR,

    END OF IT_PA0000.

    DATA : BEGIN OF IT_TEVEN OCCURS 0,

    PERNR TYPE TEVEN-PERNR,

    LDATE TYPE TEVEN-LDATE,

    LTIME TYPE TEVEN-LTIME,

    SATZA TYPE TEVEN-SATZA,

    END OF IT_TEVEN.

    DATA : IT_TEVEN1 LIKE IT_TEVEN OCCURS 0 WITH HEADER LINE.

    DATA : BEGIN OF IT_T527X OCCURS 0,

    ORGEH LIKE T527X-ORGEH,

    ORGTX LIKE T527X-ORGTX,

    END OF IT_T527X.

    DATA : BEGIN OF IT_T503T OCCURS 0,

    PERSK TYPE T503T-PERSK,

    PTEXT TYPE T503T-PTEXT,

    END OF IT_T503T.

    DATA : BEGIN OF IT_FINAL OCCURS 0,

    PERNR LIKE PA0001-PERNR,

    ENAME LIKE PA0001-ENAME,

    LDATE LIKE TEVEN-LDATE,

    TPROG LIKE PTPSP-TPROG,

    LTIMEI LIKE TEVEN-LTIME,

    LTIMEO LIKE TEVEN-LTIME,

    ORGTX LIKE T527X-ORGTX,

    PTEXT TYPE T503T-PTEXT,

    ATEXT TYPE ABWTXT,

    END OF IT_FINAL.

    DATA : IT_PTPSP LIKE PTPSP OCCURS 0 WITH HEADER LINE.

    *Table to get Holiday

    DATA : IT_ISCAL_DAY LIKE ISCAL_DAY OCCURS 0 WITH HEADER LINE.

    DATA : IT_T554T TYPE T554T OCCURS 0 WITH HEADER LINE.

    *ALV data declarations

    DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,

    X_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,

    GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

    GD_REPID LIKE SY-REPID.

    *For ALV Events

    DATA : IT_EVENT1 TYPE SLIS_T_EVENT.

    *For ALV Events

    DATA : IT_EVENT TYPE SLIS_ALV_EVENT.

    *For ALV top of page

    DATA : IT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

    *For top of page heading

    DATA : IT_LINE TYPE SLIS_LISTHEADER.

    ----


    • Variables declaration *

    ----


    DATA : V_SHIFT LIKE PTPSP-TPROG,

    V_TEMP TYPE I,

    V_DATE TYPE DATUM,

    V_LDATE TYPE SY-DATUM,

    V_MODIF TYPE HIDENT,

    V_SUBTY TYPE PA2002-SUBTY,

    V_ENDDA TYPE CHAR10.

    ----


    • SELECTION SCREEN *

    ----


    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    SELECT-OPTIONS : S_PERNR FOR TEVEN-PERNR,

    S_DATE FOR TEVEN-LDATE,

    S_ORGEH FOR PA0001-ORGEH,

    S_WERKS FOR PA0001-WERKS,

    S_BTRTL FOR PA0001-BTRTL,

    S_PERSK FOR PA0001-PERSK,

    S_STAT2 FOR PA0000-STAT2.

    SELECTION-SCREEN END OF BLOCK B1.

    ----


    • A T S E L E C T I O N S C R E E N *

    ----


    *validatating Selection Screen

    AT SELECTION-SCREEN ON S_PERNR.

    *Validate the User entered year

    PERFORM VALIDATE_PERNR.

    AT SELECTION-SCREEN ON S_DATE.

    *Validate the User entered date

    PERFORM VALIDATE_DATE_LOW.

    AT SELECTION-SCREEN ON S_ORGEH.

    *Validate the User entered year

    PERFORM VALIDATE_ORGEH.

    AT SELECTION-SCREEN ON S_PERSK.

    *Validate the User entered year

    PERFORM VALIDATE_PERSK.

    AT SELECTION-SCREEN ON S_WERKS.

    *Validate the User entered Personnel area

    PERFORM VALIDATE_WERKS.

    ----


    • START OF SELECTION *

    ----


    START-OF-SELECTION.

    *Get data

    PERFORM GET_DATA.

    *Process data

    PERFORM PROCESS_DATA.

    ----


    • E N D O F S E L E C T I O N *

    ----


    END-OF-SELECTION.

    PERFORM BUILD_FIELDCATALOG.

    PERFORM BUILD_LAYOUT.

    *For ALV Events

    PERFORM ALV_EVENTS.

    PERFORM DISPLAY_ALV_REPORT.

    &----


    *& Form VALIDATE_YEAR

    &----


    • Validating the year

    ----


    FORM VALIDATE_PERNR .

    IF NOT S_PERNR IS INITIAL.

    SELECT SINGLE * FROM PA0001 WHERE PERNR IN S_PERNR. "#EC *

    IF SY-SUBRC <> 0.

    MESSAGE E000 WITH 'Enter valid Employee Number'(002).

    ENDIF.

    ENDIF.

    ENDFORM. " VALIDATE_pernr

    &----


    *& Form VALIDATE_YEAR

    &----


    • Validating the year

    ----


    FORM VALIDATE_ORGEH .

    DATA: V_ORGEH LIKE T527X-ORGEH.

    IF NOT S_ORGEH IS INITIAL.

    SELECT SINGLE ORGEH FROM T527X INTO V_ORGEH WHERE ORGEH IN S_ORGEH.

    IF SY-SUBRC <> 0.

    MESSAGE E000 WITH 'Enter Valid Organization Unit'(003).

    ENDIF.

    ENDIF.

    ENDFORM. " VALIDATE_orgeh

    &----


    *& Form GET_DATA

    &----


    • Get data

    ----


    FORM GET_DATA.

    SELECT PERNR

    FROM PA0000

    INTO TABLE IT_PA0000

    WHERE PERNR IN S_PERNR

    AND ENDDA GE S_DATE-LOW

    AND BEGDA LE S_DATE-HIGH

    AND STAT2 IN S_STAT2.

    IF SY-SUBRC = 0.

    DELETE ADJACENT DUPLICATES FROM IT_PA0000 COMPARING PERNR.

    SORT IT_PA0000.

    ENDIF.

    IF NOT IT_PA0000[] IS INITIAL.

    SELECT PERNR

    ENDDA

    WERKS

    BTRTL

    ORGEH

    PERSK

    ENAME

    FROM PA0001

    INTO TABLE IT_PA0001

    FOR ALL ENTRIES IN IT_PA0000

    WHERE PERNR = IT_PA0000-PERNR

    AND ENDDA GE S_DATE-LOW

    AND BEGDA LE S_DATE-HIGH

    AND ORGEH IN S_ORGEH

    AND WERKS IN S_WERKS

    AND PERSK IN S_PERSK

    AND BTRTL IN S_BTRTL.

    IF SY-SUBRC = 0.

    SORT IT_PA0001 BY PERNR ENDDA DESCENDING.

    DELETE ADJACENT DUPLICATES FROM IT_PA0001 COMPARING PERNR.

    SORT IT_PA0001 BY PERNR.

    ENDIF.

    ENDIF.

    IF NOT IT_PA0001[] IS INITIAL.

    SELECT PERNR

    LDATE

    LTIME

    SATZA

    FROM TEVEN

    INTO TABLE IT_TEVEN

    FOR ALL ENTRIES IN IT_PA0001

    WHERE PERNR = IT_PA0001-PERNR

    AND SATZA = 'P10'

    AND LDATE IN S_DATE

    AND STOKZ NE 'X'.

    IF SY-SUBRC = 0.

    SORT IT_TEVEN BY PERNR LDATE.

    ENDIF.

    ENDIF.

    IF NOT IT_PA0001[] IS INITIAL.

    SELECT PERNR

    LDATE

    LTIME

    SATZA

    FROM TEVEN

    INTO TABLE IT_TEVEN1

    FOR ALL ENTRIES IN IT_PA0001

    WHERE PERNR = IT_PA0001-PERNR

    AND SATZA = 'P20'

    AND LDATE IN S_DATE

    AND STOKZ NE 'X'.

    IF SY-SUBRC = 0.

    SORT IT_TEVEN1 BY PERNR LDATE.

    ENDIF.

    ENDIF.

    IF NOT IT_PA0001[] IS INITIAL.

    SELECT ORGEH

    ORGTX

    FROM T527X

    INTO TABLE IT_T527X

    FOR ALL ENTRIES IN IT_PA0001

    WHERE ORGEH = IT_PA0001-ORGEH.

    IF SY-SUBRC = 0.

    SORT IT_T527X BY ORGEH.

    ENDIF.

    ENDIF.

    IF NOT IT_PA0001[] IS INITIAL.

    SELECT PERSK

    PTEXT

    FROM T503T

    INTO TABLE IT_T503T

    FOR ALL ENTRIES IN IT_PA0001

    WHERE PERSK = IT_PA0001-PERSK

    AND SPRSL = 'E'.

    IF SY-SUBRC = 0.

    SORT IT_T503T BY PERSK.

    ENDIF.

    ENDIF.

    SELECT *

    FROM T554T

    INTO TABLE IT_T554T

    WHERE SPRSL = 'EN'

    AND MOABW = '40'.

    ENDFORM. " GET_DATA

    &----


    *& Form PROCESS_DATA

    &----


    • Process data

    ----


    FORM PROCESS_DATA .

    V_TEMP = S_DATE-HIGH - S_DATE-LOW.

    V_TEMP = V_TEMP + 1.

    LOOP AT IT_PA0001.

    V_DATE = S_DATE-LOW.

    DO V_TEMP TIMES.

    *Get employee work schedule

    IF IT_PTPSP[] IS INITIAL.

    PERFORM GET_SCHEDULE.

    ENDIF.

    *Get holiday calendar

    IF IT_ISCAL_DAY[] IS INITIAL.

    PERFORM GET_HOLIDAY.

    ENDIF.

    CLEAR : V_SUBTY.

    SELECT SINGLE SUBTY

    FROM PA2001

    INTO V_SUBTY

    WHERE PERNR = IT_PA0001-PERNR

    AND ENDDA GE V_DATE

    AND BEGDA LE V_DATE.

    IF SY-SUBRC = 0.

    READ TABLE IT_T554T WITH KEY AWART = V_SUBTY.

    IT_FINAL-ATEXT = IT_T554T-ATEXT.

    ENDIF.

    IF V_SUBTY IS INITIAL.

    SELECT SINGLE SUBTY

    FROM PA2002

    INTO V_SUBTY

    WHERE PERNR = IT_PA0001-PERNR

    AND ENDDA GE V_DATE

    AND BEGDA LE V_DATE.

    IF SY-SUBRC = 0.

    IF V_SUBTY = '1000' OR V_SUBTY = '2000'.

    IT_FINAL-ATEXT = 'Training'.

    ELSEIF V_SUBTY = '3000'.

    IT_FINAL-ATEXT = 'Tour'.

    ENDIF.

    ENDIF.

    ENDIF.

    *Get the employee shift schedule for that date

    CLEAR : V_SHIFT.

    READ TABLE IT_PTPSP WITH KEY DATUM = V_DATE.

    IF SY-SUBRC = 0.

    V_SHIFT = IT_PTPSP-TPROG.

    IF IT_PTPSP-TAGTY = '1'.

    V_SHIFT = 'NOFF'.

    ENDIF.

    ENDIF.

    IF V_SHIFT = ''.

    CLEAR IT_FINAL.

    CONTINUE.

    ENDIF.

    *Check for holiday

    IT_FINAL-TPROG = V_SHIFT.

    READ TABLE IT_ISCAL_DAY WITH KEY DATE = V_DATE.

    IF SY-SUBRC = 0.

    IT_FINAL-TPROG = 'H'.

    ENDIF.

    IT_FINAL-PERNR = IT_PA0001-PERNR.

    IT_FINAL-ENAME = IT_PA0001-ENAME.

    IT_FINAL-LDATE = V_DATE.

    *To get the organization unit

    READ TABLE IT_T527X WITH KEY ORGEH = IT_PA0001-ORGEH

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    IT_FINAL-ORGTX = IT_T527X-ORGTX.

    ENDIF.

    CLEAR IT_T503T.

    READ TABLE IT_T503T WITH KEY PERSK = IT_PA0001-PERSK

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    IT_FINAL-PTEXT = IT_T503T-PTEXT.

    ENDIF.

    *To get Punch-in.

    READ TABLE IT_TEVEN WITH KEY PERNR = IT_PA0001-PERNR

    LDATE = V_DATE

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    IT_FINAL-LTIMEI = IT_TEVEN-LTIME.

    *To get Punch-out

    READ TABLE IT_TEVEN1 WITH KEY PERNR = IT_TEVEN-PERNR

    LDATE = IT_TEVEN-LDATE

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    IF IT_TEVEN1-LTIME > IT_FINAL-LTIMEI.

    IT_FINAL-LTIMEO = IT_TEVEN1-LTIME.

    ELSE.

    SELECT SINGLE LTIME

    FROM TEVEN

    INTO IT_FINAL-LTIMEO

    WHERE PERNR = IT_TEVEN-PERNR

    AND LDATE = IT_TEVEN-LDATE

    AND LTIME > IT_TEVEN1-LTIME

    AND SATZA = 'P20'

    AND STOKZ NE 'X'.

    ENDIF.

    ENDIF.

    IF IT_FINAL-LTIMEO IS INITIAL.

    IF V_SHIFT = 'NNIG' OR V_SHIFT = 'NAFT'..

    V_LDATE = IT_TEVEN-LDATE + 1.

    READ TABLE IT_TEVEN1 WITH KEY PERNR = IT_TEVEN-PERNR

    LDATE = V_LDATE

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    IT_FINAL-LTIMEO = IT_TEVEN1-LTIME.

    ENDIF.

    ENDIF.

    ENDIF.

    APPEND IT_FINAL.

    ELSE.

    *If holiday or OFF or Tour or Absent

    IF V_SHIFT = 'NOFF' OR IT_FINAL-TPROG = 'H' .

    APPEND IT_FINAL.

    ELSEIF IT_FINAL-ATEXT IS NOT INITIAL.

    APPEND IT_FINAL.

    ELSE.

    IT_FINAL-ATEXT = 'Absent'.

    APPEND IT_FINAL.

    ENDIF.

    ENDIF.

    CLEAR : IT_FINAL.

    V_DATE = V_DATE + 1.

    ENDDO.

    CLEAR : IT_PTPSP[],

    IT_ISCAL_DAY[].

    ENDLOOP.

    SORT IT_FINAL BY PERNR LDATE.

    LOOP AT IT_FINAL.

    TRANSLATE IT_FINAL-ATEXT TO UPPER CASE.

    MODIFY IT_FINAL INDEX SY-TABIX.

    ENDLOOP.

    ENDFORM. " PROCESS_DATA

    &----


    *& Form GET_SCHEDULE

    &----


    • Get employee work schedule

    ----


    FORM GET_SCHEDULE.

    CALL FUNCTION 'HR_PERSONAL_WORK_SCHEDULE'

    EXPORTING

    PERNR = IT_PA0001-PERNR

    BEGDA = S_DATE-LOW

    ENDDA = S_DATE-HIGH

    TABLES

    PERWS = IT_PTPSP

    EXCEPTIONS

    ERROR_OCCURED = 1

    ABORT_OCCURED = 2

    OTHERS = 3.

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDFORM. " GET_SCHEDULE

    &----


    *& Form build_fieldcatalog

    &----


    FORM BUILD_FIELDCATALOG .

    X_FIELDCATALOG-COL_POS = 1.

    X_FIELDCATALOG-FIELDNAME = 'PERNR'.

    X_FIELDCATALOG-SELTEXT_L = 'Personnel No'(006).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 2.

    X_FIELDCATALOG-FIELDNAME = 'ENAME'.

    X_FIELDCATALOG-SELTEXT_L = 'Employee Name'(007).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 5.

    X_FIELDCATALOG-FIELDNAME = 'LDATE'.

    X_FIELDCATALOG-SELTEXT_L = 'Date'(008).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 6.

    X_FIELDCATALOG-FIELDNAME = 'TPROG'.

    X_FIELDCATALOG-SELTEXT_L = 'Planned Shift'(009).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 7.

    X_FIELDCATALOG-FIELDNAME = 'LTIMEI'.

    X_FIELDCATALOG-SELTEXT_L = 'Attended Time-In'(010).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 8.

    X_FIELDCATALOG-FIELDNAME = 'LTIMEO'.

    X_FIELDCATALOG-SELTEXT_L = 'Attended Time-Out'(011).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 3.

    X_FIELDCATALOG-FIELDNAME = 'ORGTX'.

    X_FIELDCATALOG-SELTEXT_L = 'Organization Unit'(005).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 4.

    X_FIELDCATALOG-FIELDNAME = 'PTEXT'.

    X_FIELDCATALOG-SELTEXT_L = 'Emp Subgroup'(016).

    X_FIELDCATALOG-DDICTXT = 'L'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    X_FIELDCATALOG-COL_POS = 9.

    X_FIELDCATALOG-FIELDNAME = 'ATEXT'.

    X_FIELDCATALOG-SELTEXT_L = 'Leaves/Tours'(015).

    X_FIELDCATALOG-DDICTXT = 'L'.

    X_FIELDCATALOG-OUTPUTLEN = '25'.

    APPEND X_FIELDCATALOG TO FIELDCATALOG.

    CLEAR X_FIELDCATALOG.

    ENDFORM. " build_fieldcatalog

    &----


    *& Form build_layout

    &----


    FORM BUILD_LAYOUT.

    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

    GD_LAYOUT-ZEBRA = 'X'.

    ENDFORM. " build_layout

    &----


    *& Form ALV_EVENTS

    &----


    • For ALV Events

    ----


    FORM ALV_EVENTS .

    IT_EVENT-NAME = 'TOP_OF_PAGE'.

    IT_EVENT-FORM = 'TOP_OF_PAGE'.

    APPEND IT_EVENT TO IT_EVENT1.

    ENDFORM. " ALV_EVENTS

    &----


    *& Form TOP_OF_PAGE

    &----


    • ALV TOP-OF-PAGE

    ----


    FORM TOP_OF_PAGE. "#EC CALLED

    REFRESH : IT_LIST_TOP_OF_PAGE.

    CLEAR : IT_LINE.

    IT_LINE-TYP = 'H'.

    IT_LINE-INFO = 'Attendance Report for the Period'(013).

    APPEND IT_LINE TO IT_LIST_TOP_OF_PAGE.

    CONCATENATE S_DATE-LOW6(2) '.' S_DATE-LOW4(2) '.' S_DATE-LOW+0(4)

    INTO IT_LINE-INFO.

    CONCATENATE S_DATE-HIGH6(2) '.' S_DATE-HIGH4(2) '.' S_DATE-HIGH+0(4) INTO V_ENDDA.

    CONCATENATE IT_LINE-INFO '-' V_ENDDA INTO IT_LINE-INFO SEPARATED BY SPACE.

    APPEND IT_LINE TO IT_LIST_TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LIST_TOP_OF_PAGE.

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form display_alv_report

    &----


    FORM DISPLAY_ALV_REPORT.

    GD_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = GD_REPID

    IT_EVENTS = IT_EVENT1

    IS_LAYOUT = GD_LAYOUT

    IT_FIELDCAT = FIELDCATALOG

    TABLES

    T_OUTTAB = IT_FINAL

    EXCEPTIONS

    PROGRAM_ERROR = 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.

    ENDFORM. "display_alv_report

    &----


    *& Form VALIDATE_PERSK

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM VALIDATE_PERSK .

    IF NOT S_PERSK IS INITIAL.

    SELECT SINGLE * FROM T503K WHERE PERSK IN S_PERSK. "#EC *

    IF SY-SUBRC <> 0.

    MESSAGE E000 WITH 'Enter valid Employee subgroup'(012).

    ENDIF.

    ENDIF.

    ENDFORM. " VALIDATE_PERSK

    &----


    *& Form VALIDATE_WERKS

    &----


    • Validate user Entered Personnel area

    ----


    FORM VALIDATE_WERKS .

    IF S_WERKS[] IS NOT INITIAL.

    SELECT SINGLE * FROM T500P WHERE PERSA IN S_WERKS.

    IF SY-SUBRC <> 0.

    MESSAGE E000 WITH 'Enter valid Personnel Area'(014).

    ENDIF.

    ENDIF.

    ENDFORM. " VALIDATE_WERKS

    &----


    *& Form VALIDATE_DATE_LOW

    &----


    • Validate user Entered Date

    ----


    FORM VALIDATE_DATE_LOW .

    IF S_DATE-LOW IS INITIAL.

    MESSAGE E000 WITH 'Enter Date'(004).

    ENDIF.

    IF S_DATE-HIGH IS INITIAL.

    MESSAGE E000 WITH 'Enter Date'(004).

    ENDIF.

    ENDFORM. " VALIDATE_DATE_LOW

    &----


    *& Form GET_HOLIDAY

    &----


    • Get Holiday

    ----


    FORM GET_HOLIDAY .

    CLEAR V_MODIF.

    SELECT SINGLE MOFID

    FROM T001P

    INTO V_MODIF

    WHERE WERKS = IT_PA0001-WERKS

    AND BTRTL = IT_PA0001-BTRTL.

    CALL FUNCTION 'HOLIDAY_GET'

    EXPORTING

    HOLIDAY_CALENDAR = V_MODIF

    DATE_FROM = S_DATE-LOW

    DATE_TO = S_DATE-HIGH

    TABLES

    HOLIDAYS = IT_ISCAL_DAY

    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.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDFORM. " GET_HOLIDAY

    Reward points if useful.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.