REPORT zhr_time_reason
NO STANDARD PAGE HEADING LINE-SIZE 255.
**--------------------------------------------------------------------------------**
TABLES:
pernr. " HR Master Data Reporting
NODES :
peras. " Period selection
TYPES:
BEGIN OF gty_reason,
* pernr type persno,
begda type begda,
endda type endda,
begtz TYPE tims, " Start Time
endtz TYPE tims, " End Time
shift(4) TYPE c, " Shift
id(4) TYPE c, " ID
text(100) TYPE c, " Text for reason
END OF gty_reason.
TYPES:
BEGIN OF gty_detail,
pernr TYPE persno, " Pernr
begda TYPE begda, " Begda
endda TYPE endda, " Endda
begtz TYPE tims, " Start Time
endtz TYPE tims, " End Time
shift(4) TYPE c, " Shift
id(4) TYPE c, " ID
text(100) TYPE c, " Text
END OF gty_detail.
DATA :
gt_reason TYPE TABLE OF gty_reason, " IT for selection
gwa_reason TYPE gty_reason. " Work area for selection
DATA :
gt_details TYPE TABLE OF gty_detail, " IT for final table
gwa_details TYPE gty_detail. " Work area for final table
DATA:
gt_fieldcat TYPE slis_t_fieldcat_alv , " IT for fieldcatalog
gwa_fieldcat TYPE slis_fieldcat_alv. " Work area for fieldcatalog
*----------------------------------------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-009.
PARAMETERS:r_oncall RADIOBUTTON GROUP r1,
r_shift RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.
**--------------------------------------------------------------------------------------------------*
**-- Start-of-selection
START-OF-SELECTION.
**-- Get PERNR
GET peras.
**-- Select records from table
SELECT SINGLE
* pernr
begda
endda
BEGTZ
ENDTZ
SHIFT
id
text
FROM zhr_time_reason
INTO gwa_reason
WHERE pernr EQ peras-pernr.
* AND begda EQ pn-begda
* AND endda EQ pn-endda.
**-- Move the records to final work area
move gwa_reason-begda to gwa_details-begda.
move gwa_reason-endda to gwa_details-endda.
move gwa_reason-begtz to gwa_details-begtz.
move gwa_reason-endtz to gwa_details-endtz.
move gwa_reason-shift to gwa_details-shift.
MOVE gwa_reason-id TO gwa_details-id. " ID
MOVE gwa_reason-text TO gwa_details-text. " Reason Text
* MOVE gwa_reason-pernr TO gwa_details-pernr. " Reason Text
gwa_details-pernr = peras-pernr. " Pernr
* gwa_details-begda = pn-begda. " Begda
* gwa_details-endda = pn-endda. " Endda
**--Clear work area
CLEAR gwa_reason.
**-- Append final table for display
APPEND gwa_details TO gt_details.
**--End of selection
END-OF-SELECTION.
**--Displaying final table
IF gt_details[] IS NOT INITIAL.
PERFORM build_alv. " Build Fieldcatalog
PERFORM alv_display . " Display ALV output
ELSE.
* MESSAGE text-006 TYPE 'I'.
ENDIF.
*&---------------------------------------------------------------------*
*& Form build_alv
*&---------------------------------------------------------------------*
FORM build_alv .
**--for radio button on call
if r_oncall = 'X'.
delete gt_details where begtz is initial
and endtz is initial.
**--perform for build field catalog
PERFORM build_fcat: USING 'GT_DETAILS' text-001 '1' 'PERNR' 10 . " PERNR
PERFORM build_fcat: USING 'GT_DETAILS' text-002 '2' 'BEGDA' 20 . " BEGIN DATE
PERFORM build_fcat: USING 'GT_DETAILS' text-003 '3' 'ENDDA' 20 . " END DATE
PERFORM build_fcat: USING 'GT_DETAILS' text-004 '4' 'BEGTZ' 20 . " START TIME
PERFORM build_fcat: USING 'GT_DETAILS' text-005 '5' 'ENDTZ' 20 . " END TIME
PERFORM build_fcat: USING 'GT_DETAILS' text-006 '6' 'ID' 20 . " ID
PERFORM build_fcat: USING 'GT_DETAILS' text-007 '7' 'TEXT' 20 . " REASON
**--for radio button shift
elseif r_shift = 'X'.
delete gt_details where shift = ''.
**--perform for build field catalog
PERFORM build_fcat: USING 'GT_DETAILS' text-001 '1' 'PERNR' 10 . " PERNR
PERFORM build_fcat: USING 'GT_DETAILS' text-002 '2' 'BEGDA' 20 . " START DATE
PERFORM build_fcat: USING 'GT_DETAILS' text-003 '3' 'ENDDA' 20 . " END DATE
PERFORM build_fcat: USING 'GT_DETAILS' text-008 '4' 'SHIFT' 20 . " SHIFT
PERFORM build_fcat: USING 'GT_DETAILS' text-006 '5' 'ID' 20 . " ID
PERFORM build_fcat: USING 'GT_DETAILS' text-007 '6' 'TEXT' 20 . " REASON
endif.
ENDFORM. " BUILD_ALV
*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = gt_fieldcat
TABLES
t_outtab = gt_details
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT .
ENDIF.
ENDFORM. " ALV_DISPLAY
*&---------------------------------------------------------------------*
*& Form BUILD_FCAT
*&---------------------------------------------------------------------*
FORM build_fcat USING tabname TYPE string
seltext_l TYPE string
col_pos TYPE i
fieldname TYPE string
outputlen TYPE i .
*
CLEAR gwa_fieldcat.
gwa_fieldcat-tabname = tabname.
gwa_fieldcat-seltext_l = seltext_l.
gwa_fieldcat-col_pos = col_pos.
gwa_fieldcat-fieldname = fieldname.
gwa_fieldcat-outputlen = outputlen.
APPEND gwa_fieldcat TO
gt_fieldcat.
ENDFORM. "build_fieldcat
**----------------------------------------------------------------------**