SALV Output.
REPORT zmae_check MESSAGE-ID yp.
TYPE-POOLS: abap, col, icon, sym.
TABLES: yylm, yylp, yylp_fz, yylp_azt, yyll, y9l68, aufk, tka02, y9l01.
DATA: datv TYPE d,
datb TYPE d.
CONSTANTS con_min TYPE meinh VALUE 'MIN'.
*----------------------------------------------------------------------*
* SELECTION-SCREEN *
*----------------------------------------------------------------------*
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS: s_date FOR sy-datum DEFAULT datv TO datb NO-EXTENSION.
PARAMETER: p_bukrs LIKE yr90a-bukrs.
SELECT-OPTIONS s_zpern FOR yylp-zpern.
SELECTION-SCREEN: SKIP.
PARAMETERS: p_verper DEFAULT 'X' TYPE c RADIOBUTTON GROUP ver,
p_detail TYPE c RADIOBUTTON GROUP ver.
SELECTION-SCREEN: END OF BLOCK b1.
*----------------------------------------------------------------------*
* Data *
*----------------------------------------------------------------------*
DATA: ws_ucomm LIKE sy-ucomm.
DATA: auth_missing TYPE c VALUE ''.
DATA: qvk TYPE yyorges,
qnk TYPE yyorges,
n TYPE i.
DATA: fwpid TYPE yst_mlsk_rep_fwp_id,
fwpstd TYPE yst_mlsk_rep_fwp_std,
t_gesstd TYPE y_tab_mlsk_rep_fwp_std,
t_fwpstd TYPE y_tab_mlsk_rep_fwp_std.
DATA:
BEGIN OF s_out.
INCLUDE TYPE yst_mlsk_rep_fwp_std.
DATA:
exception(1) TYPE n,
diffstd TYPE yynveze,
icon(4) TYPE c, "icon_d,
END OF s_out,
t_out LIKE STANDARD TABLE OF s_out.
DATA: t_y9l68 TYPE y9l68 OCCURS 0 WITH HEADER LINE.
DATA: t_zpern TYPE TABLE OF yypern WITH HEADER LINE.
DATA: gr_table TYPE REF TO cl_salv_table.
*----------------------------------------------------------------------*
* LOAD-OF-PROGRAM *
*----------------------------------------------------------------------*
LOAD-OF-PROGRAM.
datv = sy-datum.
datv+6(2) = '01'.
SUBTRACT 1 FROM datv.
datb = datv.
datv+6(2) = '01'.
AT SELECTION-SCREEN.
ws_ucomm = sy-ucomm.
CASE ws_ucomm.
WHEN '&BACK'.
SET SCREEN 0.
EXIT.
WHEN '&EXIT'.
SET SCREEN 0.
EXIT.
WHEN '&CANC'.
SET SCREEN 0.
LEAVE TO SCREEN 0.
ENDCASE.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_fullscreen.
IF auth_missing = 'X' .
MESSAGE s144(kb) .
ENDIF .
*&---------------------------------------------------------------------*
*& Form display_fullscreen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display_fullscreen .
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = t_out ).
CATCH cx_salv_msg.
ENDTRY.
PERFORM set_metadata.
gr_table->display( ).
ENDFORM. "display_fullscreen
*&---------------------------------------------------------------------*
*& Form set_metadata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_metadata .
PERFORM set_functions.
PERFORM set_layout_settings.
PERFORM set_header.
PERFORM set_display_settings.
PERFORM set_columns.
PERFORM set_sort.
PERFORM set_aggregations.
PERFORM set_filter.
ENDFORM. "set_metadata
*&---------------------------------------------------------------------*
*& Form set_display_settings
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_display_settings.
DATA:
ls_display TYPE REF TO cl_salv_display_settings.
ls_display = gr_table->get_display_settings( ).
TRY.
ls_display->set_list_header( text-001 ).
ls_display->set_vertical_lines( abap_false ).
ls_display->set_horizontal_lines( abap_false ).
ls_display->set_striped_pattern( abap_true ).
ls_display->set_list_header_size( cl_salv_display_settings=>c_header_size_small ).
ls_display->set_suppress_empty_data( abap_true ).
CATCH cx_no_check.
ENDTRY.
ENDFORM. "set_display_settings
*&--------------------------------------------------------------------*
*& Form set_columns
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM set_columns.
DATA:
lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).
* TRY.
* lr_columns->set_exception_column( 'EXCEPTION' ).
* CATCH cx_salv_data_error.
* ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'ICON' ).
lr_column->set_icon( if_salv_c_bool_sap=>true ).
lr_column->set_long_text( 'Status' ).
lr_column->set_medium_text( 'Status' ).
lr_column->set_short_text( 'Status' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'AUFNR' ).
lr_column->set_technical( abap_true ).
lr_column ?= lr_columns->get_column( 'ARBB' ).
lr_column->set_technical( abap_true ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
IF p_detail IS INITIAL.
lr_column ?= lr_columns->get_column( 'TAG' ).
lr_column->set_visible( abap_false ).
ENDIF.
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
DATA:
ls_color TYPE lvc_s_colo.
TRY.
ls_color-col = col_key.
lr_column ?= lr_columns->get_column( 'KTOAN' ).
lr_column->set_color( ls_color ).
lr_column ?= lr_columns->get_column( 'JAHR' ).
lr_column->set_color( ls_color ).
lr_column ?= lr_columns->get_column( 'MONAT' ).
lr_column->set_color( ls_color ).
lr_column ?= lr_columns->get_column( 'TAG' ).
lr_column->set_color( ls_color ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'DIFFSTD' ).
ls_color-col = col_key .
ls_color-int = 1.
lr_column->set_color( ls_color ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
ENDFORM. "set_columns
*&--------------------------------------------------------------------*
*& Form set_sort
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM set_sort.
DATA:
lr_sorts TYPE REF TO cl_salv_sorts. "sort information
lr_sorts = gr_table->get_sorts( ).
lr_sorts->clear( ). "remove all existing sort setings
TRY.
lr_sorts->add_sort(
columnname = 'KTOAN'
position = 1
sequence = if_salv_c_sort=>sort_up ).
lr_sorts->add_sort(
columnname = 'JAHR'
position = 2
sequence = if_salv_c_sort=>sort_up ).
lr_sorts->add_sort(
columnname = 'MONAT'
position = 3
subtotal = abap_true
sequence = if_salv_c_sort=>sort_up ).
IF NOT p_detail IS INITIAL.
lr_sorts->add_sort(
columnname = 'TAG'
position = 4
sequence = if_salv_c_sort=>sort_down ).
ENDIF.
CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER
ENDTRY.
ENDFORM. "set_sort
*&--------------------------------------------------------------------*
*& Form set_aggregations
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM set_aggregations.
DATA:
lr_aggregations TYPE REF TO cl_salv_aggregations.
lr_aggregations = gr_table->get_aggregations( ).
lr_aggregations->clear( ).
TRY.
lr_aggregations->add_aggregation( columnname = 'LSTD_FWP' ).
lr_aggregations->add_aggregation( columnname = 'LSTD_KU' ).
lr_aggregations->add_aggregation( columnname = 'LSTD_ANW' ).
lr_aggregations->add_aggregation( columnname = 'LSTD_SP' ).
lr_aggregations->add_aggregation( columnname = 'DIFFSTD' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER
ENDTRY.
ENDFORM. "set_aggregations
*&--------------------------------------------------------------------*
*& Form set_filter
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM set_filter.
DATA:
lr_filters TYPE REF TO cl_salv_filters.
lr_filters = gr_table->get_filters( ).
lr_filters->clear( ).
TRY.
* lr_filters->add_filter(
* columnname = ''
* low = '' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER
ENDTRY.
ENDFORM. "set_filter
*&---------------------------------------------------------------------*
*& Form ULTIMO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_YYLL_DAZUB text
*----------------------------------------------------------------------*
FORM ultimo USING p_dat TYPE d.
p_dat+6(2) = '28'.
ADD 4 TO p_dat.
p_dat+6(2) = '01'.
SUBTRACT 1 FROM p_dat.
ENDFORM. " ULTIMO
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .
DATA: l_tol_neg LIKE yyll-versu ,
l_tol_pos LIKE yyll-versu ,
l_proz LIKE yyll-versu .
PERFORM get_param_y9l01 USING p_bukrs
'PROZ_TOL'
l_tol_pos .
l_tol_neg = l_tol_pos * -1 .
SELECT * FROM y9l68 INTO TABLE t_y9l68
WHERE datab <= s_date-low
AND datbi >= s_date-high.
SELECT zpern FROM yylp INTO TABLE t_zpern
WHERE bukrs = p_bukrs
AND zpern IN s_zpern.
CHECK sy-subrc = 0.
CLEAR: t_gesstd[].
LOOP AT t_zpern.
SELECT SINGLE * FROM yylm WHERE ktonr = t_zpern.
CHECK sy-subrc = 0.
SELECT SINGLE * FROM yylp WHERE zpern = yylm-pernr.
CHECK sy-subrc = 0.
*... Berechtigungsprüfung
AUTHORITY-CHECK OBJECT 'Z:Y-ZEIT'
ID 'ACTVT' FIELD '03'
ID 'BUKRS' DUMMY
ID 'KOSTL' FIELD yylp-zkost.
*... Keine Berechtigung zum Anzeigen der Daten
IF sy-subrc <> 0 .
auth_missing = 'X'.
CONTINUE.
ENDIF .
fwpid-bukrs = yylm-bukrs.
fwpid-ktonr = yylm-ktonr.
fwpid-zpern = yylp-zpern.
fwpid-znam1 = yylp-znam1.
fwpid-znam2 = yylp-znam2.
fwpid-zkost = yylp-zkost.
CASE yylp-zdire.
WHEN '1'.
fwpid-zdire = 'LE'.
WHEN '2'.
fwpid-zdire = 'GE'.
ENDCASE.
SELECT * FROM yyll
WHERE ktoan = yylm-ktonr
AND dazub IN s_date.
fwpstd-ktoan = yyll-ktoan.
IF p_detail IS INITIAL.
PERFORM ultimo USING yyll-dazub.
ENDIF.
fwpstd-jahr = yyll-dazub+0(4).
fwpstd-monat = yyll-dazub+4(2).
fwpstd-tag = yyll-dazub+6(2).
fwpstd-lstde = 'STD'.
fwpstd-lstd_fwp = 0.
fwpstd-lstd_ku = 0.
fwpstd-lstd_anw = 0.
fwpstd-lstd_sp = 0.
READ TABLE t_y9l68 WITH KEY aufnr = yyll-aufnr TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
COMPUTE fwpstd-lstd_fwp = yyll-orges / 60.
ELSE.
COMPUTE fwpstd-lstd_sp = yyll-orges / 60.
ENDIF.
COLLECT fwpstd INTO t_gesstd.
ENDSELECT.
CLEAR fwpstd.
*... Summe der Anwesenheits Zeiten ermitteln
SELECT * FROM yylp_azt
WHERE zpern = yylm-pernr
AND bukrs = yylm-bukrs
AND datum IN s_date
ORDER BY datum.
fwpstd-ktoan = yylm-ktonr.
IF p_detail IS INITIAL.
PERFORM ultimo USING yylp_azt-datum.
ENDIF.
fwpstd-jahr = yylp_azt-datum+0(4).
fwpstd-monat = yylp_azt-datum+4(2).
fwpstd-tag = yylp_azt-datum+6(2).
* fwpstd-lstde = yylp_azt-aeinh.
fwpstd-lstde = 'STD'.
fwpstd-lstd_fwp = 0.
fwpstd-lstd_sp = 0.
fwpstd-lstd_ku = 0.
qvk = TRUNC( yylp_azt-anwzt ).
qnk = FRAC( yylp_azt-anwzt ).
COMPUTE n = qnk / '0.05'.
COMPUTE fwpstd-lstd_anw = qvk + ( n * '0.05' ).
COLLECT fwpstd INTO t_gesstd.
ENDSELECT.
* SORT t_gesstd.
CLEAR fwpstd.
*... Summe der Anwesenheits Zeiten ermitteln
SELECT * FROM yylp_fz
WHERE zpern = yylm-pernr
AND bukrs = yylm-bukrs
AND datum IN s_date.
fwpstd-ktoan = yylm-ktonr.
IF p_detail IS INITIAL.
PERFORM ultimo USING yylp_fz-datum.
ENDIF.
fwpstd-jahr = yylp_fz-datum+0(4).
fwpstd-monat = yylp_fz-datum+4(2).
fwpstd-tag = yylp_fz-datum+6(2).
fwpstd-lstde = 'STD'.
fwpstd-lstd_fwp = 0.
fwpstd-lstd_sp = 0.
fwpstd-lstd_ku = 0.
fwpstd-lstd_anw = 0.
CASE yylp_fz-lsttyp.
WHEN 'K' OR 'U'.
IF yylp_fz-meinh = con_min.
COMPUTE fwpstd-lstd_ku = yylp_fz-orges / 60.
ELSE.
COMPUTE fwpstd-lstd_ku = yylp_fz-orges .
ENDIF.
ENDCASE.
COLLECT fwpstd INTO t_gesstd.
ENDSELECT.
ENDLOOP.
CLEAR: s_out, t_out[].
LOOP AT t_gesstd INTO fwpstd.
MOVE-CORRESPONDING fwpstd TO s_out.
s_out-diffstd = s_out-lstd_anw - s_out-lstd_fwp - s_out-lstd_sp.
IF s_out-lstd_anw <> 0 .
l_proz = s_out-diffstd / s_out-lstd_anw * 100 .
ELSE .
IF s_out-diffstd = 0.
l_proz = 0 .
ELSE.
l_proz = -100 .
ENDIF.
ENDIF .
IF l_proz > l_tol_neg AND l_proz < l_tol_pos .
s_out-icon = icon_green_light.
ELSEIF l_proz > l_tol_pos .
s_out-icon = icon_yellow_light.
ELSEIF l_proz < l_tol_neg .
s_out-icon = icon_red_light.
ENDIF .
APPEND s_out TO t_out.
ENDLOOP.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT_SETTINGS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_layout_settings .
DATA: lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
lr_layout = gr_table->get_layout( ).
ls_key-report = sy-repid.
lr_layout->set_key( ls_key ).
lr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
IF p_detail IS INITIAL.
lr_layout->set_initial_layout( '/SUM' ).
ELSE.
lr_layout->set_initial_layout( '/STD' ).
ENDIF.
ENDFORM. " SET_LAYOUT_SETTINGS
*&---------------------------------------------------------------------*
*& Form SET_FUNCTIONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_functions .
DATA: lr_functions TYPE REF TO cl_salv_functions_list.
lr_functions = gr_table->get_functions( ).
lr_functions->set_default( ).
ENDFORM. " SET_FUNCTIONS
*&---------------------------------------------------------------------*
*& Form SET_HEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_header .
*... TOP_OF_LIST
DATA: lr_header TYPE REF TO cl_salv_form_header_info.
DATA: txt(100) TYPE c,
datv(10) TYPE c,
datb(10) TYPE c.
WRITE: s_date-low TO datv.
WRITE: s_date-high TO datb.
CONCATENATE 'FWP: gebuchte Stunden Zeitraum'(002) datv ' - ' datb INTO txt SEPARATED BY space.
CREATE OBJECT lr_header
EXPORTING
text = txt.
gr_table->set_top_of_list( lr_header ).
ENDFORM. " SET_HEADER
*&---------------------------------------------------------------------*
*& Form get_param_y9l01
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_BUKRS text
* -->P_PSCHL text
* -->P_PWERT text
*----------------------------------------------------------------------*
FORM get_param_y9l01 USING p_bukrs "CON-TR-09
p_pschl
p_pwert.
SELECT SINGLE * FROM y9l01
WHERE bukrs = p_bukrs
AND pschl = p_pschl .
*... Parameter nicht vorhanden
IF sy-subrc NE 0.
MESSAGE e124 WITH p_pschl .
*... Parameter vorhanden
ELSE.
p_pwert = y9l01-pwert.
ENDIF.
ENDFORM. "get_param_y9l01
No comments:
Post a Comment