In the following example the report gets refreshed time to time and the report contains four ALV grids.
TABLES:mard.
DATA v_line TYPE zzline.
CLASS cl_prod DEFINITION DEFERRED.
DATA: obj_prod TYPE REF TO cl_prod,
obj_timer TYPE REF TO cl_gui_timer.
INITIALIZATION.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS p_date TYPE budat.
SELECT-OPTIONS: s_lgort FOR mard-lgort NO-DISPLAY,
s_line FOR v_line NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
CLASS cl_prod DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF ts_zpp05,
sl_no TYPE zpp05_reason-sl_no,
prod_ord TYPE zpp05_reason-prod_ord,
plant TYPE zpp05_reason-plant,
serial_no TYPE zpp05_reason-serial_no,
seq_no TYPE zpp05_reason-seq_no,
stage TYPE zpp05_reason-stage,
status TYPE zpp05_reason-status,
posting_date TYPE zpp05_reason-posting_date,
posting_time TYPE zpp05_reason-posting_time,
END OF ts_zpp05.
DATA it_zpp5 TYPE TABLE OF ts_zpp05.
TYPES:BEGIN OF st_final,
matnr TYPE nsdm_v_mseg-matnr,
lgort TYPE nsdm_v_mseg-lgort,
text TYPE string,
wp TYPE nsdm_v_mseg-menge,
menge1 TYPE nsdm_v_mseg-menge,
menge2 TYPE nsdm_v_mseg-menge,
kw1 TYPE nsdm_v_mseg-menge,
kw2 TYPE nsdm_v_mseg-menge,
END OF st_final.
DATA:lt_final TYPE STANDARD TABLE OF st_final,
ls_final TYPE st_final,
wa_final TYPE zprd_last_day,
it_final TYPE TABLE OF zprd_last_day.
TYPES: BEGIN OF ty_asft,
ztime TYPE string,
am6_8 TYPE i,
am8_10 TYPE i,
am10_12 TYPE i,
pm12_2 TYPE i,
END OF ty_asft.
DATA: wa_asft TYPE ty_asft,
it_asft TYPE TABLE OF ty_asft.
TYPES: BEGIN OF ty_bsft,
ztime TYPE string,
pm2_4 TYPE i,
pm4_6 TYPE i,
pm6_8 TYPE i,
pm8_10 TYPE i,
END OF ty_bsft.
DATA: wa_bsft TYPE ty_bsft,
it_bsft TYPE TABLE OF ty_bsft.
TYPES: BEGIN OF ty_csft,
ztime TYPE string,
pm10_12 TYPE i,
am12_2 TYPE i,
am2_4 TYPE i,
am4_6 TYPE i,
END OF ty_csft.
DATA: wa_csft TYPE ty_csft,
it_csft TYPE TABLE OF ty_csft.
DATA:v_watt TYPE p DECIMALS 2,
it_fcat_l TYPE TABLE OF lvc_s_fcat,
it_fcat_a TYPE TABLE OF lvc_s_fcat,
it_fcat_b TYPE TABLE OF lvc_s_fcat,
it_fcat_c TYPE TABLE OF lvc_s_fcat,
wa_fcat TYPE lvc_s_fcat,
wa_lay_l TYPE lvc_s_layo,
wa_lay_a TYPE lvc_s_layo,
wa_lay_b TYPE lvc_s_layo,
wa_lay_c TYPE lvc_s_layo,
r_order TYPE RANGE OF zpp05_reason-prod_ord,
s_date TYPE RANGE OF nsdm_v_mseg-budat_mkpf,
w_date LIKE LINE OF s_date,
v_mess TYPE string.
"--Create Custom Container Object
DATA: obj_cont_last TYPE REF TO cl_gui_custom_container,
obj_cont_asft TYPE REF TO cl_gui_custom_container,
obj_cont_bsft TYPE REF TO cl_gui_custom_container,
obj_cont_csft TYPE REF TO cl_gui_custom_container.
"--Create ALV Grid Object
DATA: obj_alv_last TYPE REF TO cl_gui_alv_grid,
obj_alv_asft TYPE REF TO cl_gui_alv_grid,
obj_alv_bsft TYPE REF TO cl_gui_alv_grid,
obj_alv_csft TYPE REF TO cl_gui_alv_grid.
METHODS:
constructor,
m_last_day_calculation,
m_club_last_day,
m_order_specification,
m_get_zpp05_reason,
m_shift_table_data,
m_field_catalog,
m_alv_grid_output,
m_report_refresh FOR EVENT finished OF cl_gui_timer.
ENDCLASS.
CLASS cl_prod IMPLEMENTATION.
METHOD constructor.
IF p_date IS INITIAL.
MESSAGE 'Date is Mandatory' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN sy-dynnr.
ENDIF.
IF s_line[] IS INITIAL.
MESSAGE 'Line is Mandatory' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN sy-dynnr.
ENDIF.
ENDMETHOD.
METHOD m_last_day_calculation.
DATA:objectkey TYPE bapi1003_key-object,
it_snum TYPE TABLE OF bapi1003_alloc_values_num,
wa_num TYPE bapi1003_alloc_values_num,
it_schar TYPE TABLE OF bapi1003_alloc_values_char,
it_scurr TYPE TABLE OF bapi1003_alloc_values_curr,
return TYPE TABLE OF bapiret2.
IF p_date IS NOT INITIAL.
DATA lv_date TYPE budat.
lv_date = p_date - 1.
DATA(month) = lv_date+4(2).
DATA(year) = lv_date+0(4).
CONCATENATE year month '01' INTO DATA(p_date1).
w_date-low = p_date1.
w_date-option = 'BT'.
w_date-sign = 'I'.
w_date-high = lv_date.
APPEND w_date TO s_date.
IF s_lgort[] IS INITIAL.
DATA l_lgort LIKE LINE OF s_lgort.
l_lgort-sign = 'I'.
l_lgort-option = 'EQ'.
l_lgort-low = '1410'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2410'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2430'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2450'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '1400'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2400'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2420'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2440'.
APPEND l_lgort TO s_lgort.
ENDIF.
"-Fetching Previous Data upto Last Day
SELECT mblnr,
mjahr,
zeile,
xauto,
bwart,
matnr,
lgort,
menge,
budat_mkpf
FROM nsdm_v_mseg
INTO TABLE @DATA(lt_maton)
WHERE bwart = '321'
AND budat_mkpf IN @s_date
AND xauto = 'X'
AND lgort IN @s_lgort.
"-Fetching Current date data from 12AM to 6AM
SELECT mblnr,
mjahr,
zeile,
xauto,
bwart,
matnr,
lgort,
menge,
budat_mkpf
FROM nsdm_v_mseg
APPENDING TABLE @lt_maton
WHERE bwart = '321'
AND budat_mkpf = @p_date
AND cputm_mkpf BETWEEN '000000' AND '055959'
AND xauto = 'X'
AND lgort IN @s_lgort.
IF sy-subrc = 0.
SORT lt_maton BY matnr.
ENDIF.
ENDIF.
DATA(lt_matup) = lt_maton.
DATA(lt_mat) = lt_maton.
SORT lt_mat BY matnr lgort.
DELETE ADJACENT DUPLICATES FROM lt_mat COMPARING matnr lgort.
DELETE lt_matup WHERE budat_mkpf = lv_date. "p_date.
SORT lt_matup BY matnr.
DELETE lt_maton WHERE budat_mkpf <> lv_date. "p_date.
SORT lt_maton BY matnr.
LOOP AT lt_mat ASSIGNING FIELD-SYMBOL(<ls_mat>).
ls_final-matnr = <ls_mat>-matnr.
ls_final-lgort = <ls_mat>-lgort.
IF ls_final-lgort = '1410' OR
ls_final-lgort = '1400'.
ls_final-text = 'FAB1'.
ELSEIF ls_final-lgort = '2410' OR
ls_final-lgort = '2400'.
ls_final-text = 'PH1'.
ELSEIF ls_final-lgort = '2430' OR
ls_final-lgort = '2420'.
ls_final-text = 'PH2'.
ELSEIF ls_final-lgort = '2450'.
ls_final-text = 'MAN'.
ELSE.
ls_final-text = <ls_mat>-lgort.
ENDIF.
objectkey = <ls_mat>-matnr.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = objectkey
objecttable = 'MARA'
classnum = 'Z_FG_CLASS'
classtype = '001'
keydate = sy-datum
language = sy-langu
TABLES
allocvaluesnum = it_snum
allocvalueschar = it_schar
allocvaluescurr = it_scurr
return = return.
LOOP AT it_snum INTO wa_num
WHERE charact = 'Z_FG_WATTPEAK'
AND value_from IS NOT INITIAL.
v_watt = wa_num-value_from.
ls_final-wp = v_watt.
EXIT.
ENDLOOP.
LOOP AT lt_maton ASSIGNING FIELD-SYMBOL(<ls_maton>)
WHERE matnr = <ls_mat>-matnr
AND lgort = <ls_mat>-lgort
AND budat_mkpf = lv_date. "p_date.
ls_final-menge1 = ls_final-menge1 + <ls_maton>-menge.
ENDLOOP.
LOOP AT lt_matup ASSIGNING FIELD-SYMBOL(<ls_matup>)
WHERE matnr = <ls_mat>-matnr
AND lgort = <ls_mat>-lgort
AND budat_mkpf <> lv_date. "p_date.
ls_final-menge2 = ls_final-menge2 + <ls_matup>-menge.
ENDLOOP.
ls_final-kw1 = ( ls_final-wp * ls_final-menge1 ) / 1000.
ls_final-kw2 = ( ls_final-wp * ls_final-menge2 ) / 1000.
"--Added on 6.4.19: Sandip
ls_final-menge2 = ls_final-menge2 + ls_final-menge1.
ls_final-kw2 = ls_final-kw2 + ls_final-kw1.
"--Ended on 6.4.19: Sandip
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = ls_final-matnr
IMPORTING
output = ls_final-matnr.
APPEND ls_final TO lt_final.
CLEAR: ls_final.
ENDLOOP.
ENDMETHOD.
"--Location wise Clubbing of Quanity with Wattage (KW)
METHOD m_club_last_day.
IF lt_final IS NOT INITIAL.
SELECT lgort, trgt_qty, trgt_kw
FROM zprd_last_day INTO TABLE @DATA(lt_last)
FOR ALL ENTRIES IN @lt_final
WHERE lgort = @lt_final-lgort.
SORT lt_last BY lgort.
ENDIF.
LOOP AT lt_final ASSIGNING FIELD-SYMBOL(<ls_final>).
wa_final-lgort = <ls_final>-text.
wa_final-achv_qty = <ls_final>-menge1.
wa_final-achv_kw = <ls_final>-kw1.
COLLECT wa_final INTO it_final.
CLEAR: wa_final.
ENDLOOP.
LOOP AT it_final ASSIGNING FIELD-SYMBOL(<wa_final>).
READ TABLE lt_last ASSIGNING FIELD-SYMBOL(<ls_last>)
WITH KEY lgort = <wa_final>-lgort BINARY SEARCH.
IF sy-subrc = 0.
wa_final-trgt_qty = <ls_last>-trgt_qty.
wa_final-trgt_kw = <ls_last>-trgt_kw.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD m_order_specification.
DATA w_order LIKE LINE OF r_order.
w_order-sign = 'I'.
w_order-option = 'BT'.
LOOP AT s_line ASSIGNING FIELD-SYMBOL(<line>).
IF <line>-low = 'FAB1'.
w_order-low = '000000010000'.
w_order-high = '000000019999'.
ELSEIF <line>-low = 'PH1'.
w_order-low = '000000050000'.
w_order-high = '000000059999'.
ELSEIF <line>-low = 'PH2'.
w_order-low = '000000060000'.
w_order-high = '000000069999'.
ELSEIF <line>-low = 'MAN'.
w_order-low = '000000070000'.
w_order-high = '000000079999'.
ENDIF.
APPEND w_order TO r_order.
CLEAR: w_order-low, w_order-high.
ENDLOOP.
ENDMETHOD.
METHOD m_get_zpp05_reason.
DATA lv_date TYPE sy-datum.
REFRESH it_zpp5.
SELECT sl_no
prod_ord
plant
serial_no
seq_no
stage
status
posting_date
posting_time
FROM zpp05_reason INTO TABLE it_zpp5
BYPASSING BUFFER
WHERE prod_ord IN r_order
AND stage IN ('0010','0020','UD')
AND posting_date = p_date
AND posting_time BETWEEN '060000' AND '235959'.
lv_date = p_date + 1.
SELECT sl_no
prod_ord
plant
serial_no
seq_no
stage
status
posting_date
posting_time
FROM zpp05_reason APPENDING TABLE it_zpp5
BYPASSING BUFFER
WHERE prod_ord IN r_order
AND stage IN ('0010','0020','UD')
AND posting_date = lv_date
AND posting_time BETWEEN '000000' AND '055959'.
SORT it_zpp5 BY posting_time.
ENDMETHOD.
"----------------Shift-A,B,C Output Table
METHOD m_shift_table_data.
REFRESH: it_asft, it_bsft, it_csft.
wa_asft-ztime = 'Stringer O/P'.
APPEND wa_asft TO it_asft.
wa_asft-ztime = 'Lamination O/P'.
APPEND wa_asft TO it_asft.
wa_asft-ztime = 'Testing O/P'.
APPEND wa_asft TO it_asft.
wa_bsft-ztime = 'Stringer O/P'.
APPEND wa_bsft TO it_bsft.
wa_bsft-ztime = 'Lamination O/P'.
APPEND wa_bsft TO it_bsft.
wa_bsft-ztime = 'Testing O/P'.
APPEND wa_bsft TO it_bsft.
wa_csft-ztime = 'Stringer O/P'.
APPEND wa_csft TO it_csft.
wa_csft-ztime = 'Lamination O/P'.
APPEND wa_csft TO it_csft.
wa_csft-ztime = 'Testing O/P'.
APPEND wa_csft TO it_csft.
LOOP AT it_zpp5 ASSIGNING FIELD-SYMBOL(<lw_zpp5>).
IF <lw_zpp5>-stage = '0010'.
wa_asft-ztime = 'Stringer O/P'.
wa_bsft-ztime = 'Stringer O/P'.
wa_csft-ztime = 'Stringer O/P'.
ELSEIF <lw_zpp5>-stage = '0020'.
wa_asft-ztime = 'Lamination O/P'.
wa_bsft-ztime = 'Lamination O/P'.
wa_csft-ztime = 'Lamination O/P'.
ELSEIF <lw_zpp5>-stage = 'UD' AND <lw_zpp5>-status = 'YIELD'.
wa_asft-ztime = 'Testing O/P'.
wa_bsft-ztime = 'Testing O/P'.
wa_csft-ztime = 'Testing O/P'.
ELSE.
CONTINUE.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '060000' AND '135959'.
IF <lw_zpp5>-posting_time BETWEEN '060000' AND '075959'.
wa_asft-am6_8 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '080000' AND '095959'.
wa_asft-am8_10 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '100000' AND '115959'.
wa_asft-am10_12 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '120000' AND '135959'.
wa_asft-pm12_2 = 1.
ENDIF.
COLLECT wa_asft INTO it_asft.
CLEAR wa_asft.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '140000' AND '215959'.
IF <lw_zpp5>-posting_time BETWEEN '140000' AND '155959'.
wa_bsft-pm2_4 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '160000' AND '175959'.
wa_bsft-pm4_6 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '180000' AND '195959'.
wa_bsft-pm6_8 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '200000' AND '215959'.
wa_bsft-pm8_10 = 1.
ENDIF.
COLLECT wa_bsft INTO it_bsft.
CLEAR wa_bsft.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '220000' AND '235959'.
wa_csft-pm10_12 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '000000' AND '015959'.
wa_csft-am12_2 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '020000' AND '035959'.
wa_csft-am2_4 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '040000' AND '055959'.
wa_csft-am4_6 = 1.
ENDIF.
COLLECT wa_csft INTO it_csft.
CLEAR wa_csft.
ENDLOOP.
ENDMETHOD.
METHOD m_field_catalog.
DATA: prev_date TYPE char10,
live_date TYPE char10,
next_date TYPE char10,
lv_date TYPE sy-datum.
lv_date = p_date - 1.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = lv_date
IMPORTING
date_external = prev_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = p_date
IMPORTING
date_external = live_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
lv_date = p_date + 1.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = lv_date
IMPORTING
date_external = next_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
wa_lay_l-zebra = 'X'.
wa_lay_l-cwidth_opt = 'X'.
wa_lay_l-grid_title = 'Previous Achievement: Date-'
&& | | && prev_date.
wa_lay_a-zebra = 'X'.
wa_lay_a-cwidth_opt = 'X'.
wa_lay_a-grid_title = 'A-Shift: Date-'
&& | | && live_date. "--Shift-A Layout
wa_lay_b-zebra = 'X'.
wa_lay_b-cwidth_opt = 'X'.
wa_lay_b-grid_title = 'B-Shift: Date-'
&& | | && live_date. "--Shift-B Layout
wa_lay_c-zebra = 'X'.
wa_lay_c-cwidth_opt = 'X'.
wa_lay_c-grid_title = 'C-Shift: Date-'
&& | | && live_date &&
| - | && next_date. "--Shift-C Layout
REFRESH: it_fcat_l, it_fcat_a, it_fcat_b, it_fcat_c.
DATA lv_col TYPE i VALUE IS INITIAL.
"-------------------Previous Achievement Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'LGORT'.
wa_fcat-reptext = 'Storage'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'TRGT_QTY'.
wa_fcat-reptext = 'Target Qty'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ACHV_QTY'.
wa_fcat-reptext = 'Achieved Qty'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'TRGT_KW'.
wa_fcat-reptext = 'Target KW'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ACHV_KW'.
wa_fcat-reptext = 'Achieved KW'.
APPEND wa_fcat TO it_fcat_l.
CLEAR: wa_fcat, lv_col.
"--------------------------A Shift Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ZTIME'.
wa_fcat-reptext = 'Time'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM6_8'.
wa_fcat-reptext = '6-8 AM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM8_10'.
wa_fcat-reptext = '8-10 AM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM10_12'.
wa_fcat-reptext = '10-12 AM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM12_2'.
wa_fcat-reptext = '12-2 PM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR: wa_fcat, lv_col.
"--------------------------B Shift Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ZTIME'.
wa_fcat-reptext = 'Time'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM2_4'.
wa_fcat-reptext = '2-4 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM4_6'.
wa_fcat-reptext = '4-6 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM6_8'.
wa_fcat-reptext = '6-8 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM8_10'.
wa_fcat-reptext = '8-10 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR: wa_fcat, lv_col.
"--------------------------C Shift Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ZTIME'.
wa_fcat-reptext = 'Time'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM10_12'.
wa_fcat-reptext = '10-12 PM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM12_2'.
wa_fcat-reptext = '12-2 AM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM2_4'.
wa_fcat-reptext = '2-4 AM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM4_6'.
wa_fcat-reptext = '4-6 AM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR: wa_fcat, lv_col.
ENDMETHOD.
METHOD m_alv_grid_output.
"--ALV Grid for Previous Day Achievement
CREATE OBJECT obj_cont_last EXPORTING container_name = 'CONT_LAST'.
CREATE OBJECT obj_alv_last EXPORTING i_parent = obj_cont_last.
CALL METHOD obj_alv_last->set_table_for_first_display
EXPORTING
is_layout = wa_lay_l
CHANGING
it_fieldcatalog = it_fcat_l
it_outtab = it_final.
"--ALV Grid for A-Shift
CREATE OBJECT obj_cont_asft EXPORTING container_name = 'CONT_ASFT'.
CREATE OBJECT obj_alv_asft EXPORTING i_parent = obj_cont_asft.
CALL METHOD obj_alv_asft->set_table_for_first_display
EXPORTING
is_layout = wa_lay_a
CHANGING
it_fieldcatalog = it_fcat_a
it_outtab = it_asft.
"--ALV Grid for B-Shift
CREATE OBJECT obj_cont_bsft EXPORTING container_name = 'CONT_BSFT'.
CREATE OBJECT obj_alv_bsft EXPORTING i_parent = obj_cont_bsft.
CALL METHOD obj_alv_bsft->set_table_for_first_display
EXPORTING
is_layout = wa_lay_b
CHANGING
it_fieldcatalog = it_fcat_b
it_outtab = it_bsft.
"--ALV Grid for C-Shift
CREATE OBJECT obj_cont_csft EXPORTING container_name = 'CONT_CSFT'.
CREATE OBJECT obj_alv_csft EXPORTING i_parent = obj_cont_csft.
CALL METHOD obj_alv_csft->set_table_for_first_display
EXPORTING
is_layout = wa_lay_c
CHANGING
it_fieldcatalog = it_fcat_c
it_outtab = it_csft.
ENDMETHOD.
METHOD m_report_refresh.
IF obj_alv_asft IS NOT INITIAL AND
obj_alv_bsft IS NOT INITIAL AND
obj_alv_csft IS NOT INITIAL.
CALL METHOD: obj_prod->m_get_zpp05_reason,
obj_prod->m_shift_table_data,
obj_prod->m_field_catalog,
obj_alv_asft->refresh_table_display,
obj_alv_bsft->refresh_table_display,
obj_alv_csft->refresh_table_display.
CONCATENATE sy-uzeit+0(2) ':'
sy-uzeit+2(2) ':'
sy-uzeit+4(2)
INTO DATA(lv_uzeit).
CONCATENATE 'Last Update at' lv_uzeit
INTO v_mess SEPARATED BY space.
MESSAGE v_mess TYPE 'S'.
CALL METHOD obj_timer->run.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CREATE OBJECT: obj_prod,
obj_timer.
CALL METHOD: obj_prod->m_last_day_calculation,
obj_prod->m_club_last_day,
obj_prod->m_order_specification,
obj_prod->m_get_zpp05_reason,
obj_prod->m_shift_table_data,
obj_prod->m_field_catalog.
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'PF_9000'.
SET TITLEBAR 'T_9000'.
SET HANDLER obj_prod->m_report_refresh FOR obj_timer.
obj_timer->interval = 10.
CALL METHOD: obj_timer->run,
obj_prod->m_alv_grid_output.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
TABLES:mard.
DATA v_line TYPE zzline.
CLASS cl_prod DEFINITION DEFERRED.
DATA: obj_prod TYPE REF TO cl_prod,
obj_timer TYPE REF TO cl_gui_timer.
INITIALIZATION.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS p_date TYPE budat.
SELECT-OPTIONS: s_lgort FOR mard-lgort NO-DISPLAY,
s_line FOR v_line NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
CLASS cl_prod DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF ts_zpp05,
sl_no TYPE zpp05_reason-sl_no,
prod_ord TYPE zpp05_reason-prod_ord,
plant TYPE zpp05_reason-plant,
serial_no TYPE zpp05_reason-serial_no,
seq_no TYPE zpp05_reason-seq_no,
stage TYPE zpp05_reason-stage,
status TYPE zpp05_reason-status,
posting_date TYPE zpp05_reason-posting_date,
posting_time TYPE zpp05_reason-posting_time,
END OF ts_zpp05.
DATA it_zpp5 TYPE TABLE OF ts_zpp05.
TYPES:BEGIN OF st_final,
matnr TYPE nsdm_v_mseg-matnr,
lgort TYPE nsdm_v_mseg-lgort,
text TYPE string,
wp TYPE nsdm_v_mseg-menge,
menge1 TYPE nsdm_v_mseg-menge,
menge2 TYPE nsdm_v_mseg-menge,
kw1 TYPE nsdm_v_mseg-menge,
kw2 TYPE nsdm_v_mseg-menge,
END OF st_final.
DATA:lt_final TYPE STANDARD TABLE OF st_final,
ls_final TYPE st_final,
wa_final TYPE zprd_last_day,
it_final TYPE TABLE OF zprd_last_day.
TYPES: BEGIN OF ty_asft,
ztime TYPE string,
am6_8 TYPE i,
am8_10 TYPE i,
am10_12 TYPE i,
pm12_2 TYPE i,
END OF ty_asft.
DATA: wa_asft TYPE ty_asft,
it_asft TYPE TABLE OF ty_asft.
TYPES: BEGIN OF ty_bsft,
ztime TYPE string,
pm2_4 TYPE i,
pm4_6 TYPE i,
pm6_8 TYPE i,
pm8_10 TYPE i,
END OF ty_bsft.
DATA: wa_bsft TYPE ty_bsft,
it_bsft TYPE TABLE OF ty_bsft.
TYPES: BEGIN OF ty_csft,
ztime TYPE string,
pm10_12 TYPE i,
am12_2 TYPE i,
am2_4 TYPE i,
am4_6 TYPE i,
END OF ty_csft.
DATA: wa_csft TYPE ty_csft,
it_csft TYPE TABLE OF ty_csft.
DATA:v_watt TYPE p DECIMALS 2,
it_fcat_l TYPE TABLE OF lvc_s_fcat,
it_fcat_a TYPE TABLE OF lvc_s_fcat,
it_fcat_b TYPE TABLE OF lvc_s_fcat,
it_fcat_c TYPE TABLE OF lvc_s_fcat,
wa_fcat TYPE lvc_s_fcat,
wa_lay_l TYPE lvc_s_layo,
wa_lay_a TYPE lvc_s_layo,
wa_lay_b TYPE lvc_s_layo,
wa_lay_c TYPE lvc_s_layo,
r_order TYPE RANGE OF zpp05_reason-prod_ord,
s_date TYPE RANGE OF nsdm_v_mseg-budat_mkpf,
w_date LIKE LINE OF s_date,
v_mess TYPE string.
"--Create Custom Container Object
DATA: obj_cont_last TYPE REF TO cl_gui_custom_container,
obj_cont_asft TYPE REF TO cl_gui_custom_container,
obj_cont_bsft TYPE REF TO cl_gui_custom_container,
obj_cont_csft TYPE REF TO cl_gui_custom_container.
"--Create ALV Grid Object
DATA: obj_alv_last TYPE REF TO cl_gui_alv_grid,
obj_alv_asft TYPE REF TO cl_gui_alv_grid,
obj_alv_bsft TYPE REF TO cl_gui_alv_grid,
obj_alv_csft TYPE REF TO cl_gui_alv_grid.
METHODS:
constructor,
m_last_day_calculation,
m_club_last_day,
m_order_specification,
m_get_zpp05_reason,
m_shift_table_data,
m_field_catalog,
m_alv_grid_output,
m_report_refresh FOR EVENT finished OF cl_gui_timer.
ENDCLASS.
CLASS cl_prod IMPLEMENTATION.
METHOD constructor.
IF p_date IS INITIAL.
MESSAGE 'Date is Mandatory' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN sy-dynnr.
ENDIF.
IF s_line[] IS INITIAL.
MESSAGE 'Line is Mandatory' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN sy-dynnr.
ENDIF.
ENDMETHOD.
METHOD m_last_day_calculation.
DATA:objectkey TYPE bapi1003_key-object,
it_snum TYPE TABLE OF bapi1003_alloc_values_num,
wa_num TYPE bapi1003_alloc_values_num,
it_schar TYPE TABLE OF bapi1003_alloc_values_char,
it_scurr TYPE TABLE OF bapi1003_alloc_values_curr,
return TYPE TABLE OF bapiret2.
IF p_date IS NOT INITIAL.
DATA lv_date TYPE budat.
lv_date = p_date - 1.
DATA(month) = lv_date+4(2).
DATA(year) = lv_date+0(4).
CONCATENATE year month '01' INTO DATA(p_date1).
w_date-low = p_date1.
w_date-option = 'BT'.
w_date-sign = 'I'.
w_date-high = lv_date.
APPEND w_date TO s_date.
IF s_lgort[] IS INITIAL.
DATA l_lgort LIKE LINE OF s_lgort.
l_lgort-sign = 'I'.
l_lgort-option = 'EQ'.
l_lgort-low = '1410'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2410'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2430'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2450'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '1400'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2400'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2420'.
APPEND l_lgort TO s_lgort.
l_lgort-low = '2440'.
APPEND l_lgort TO s_lgort.
ENDIF.
"-Fetching Previous Data upto Last Day
SELECT mblnr,
mjahr,
zeile,
xauto,
bwart,
matnr,
lgort,
menge,
budat_mkpf
FROM nsdm_v_mseg
INTO TABLE @DATA(lt_maton)
WHERE bwart = '321'
AND budat_mkpf IN @s_date
AND xauto = 'X'
AND lgort IN @s_lgort.
"-Fetching Current date data from 12AM to 6AM
SELECT mblnr,
mjahr,
zeile,
xauto,
bwart,
matnr,
lgort,
menge,
budat_mkpf
FROM nsdm_v_mseg
APPENDING TABLE @lt_maton
WHERE bwart = '321'
AND budat_mkpf = @p_date
AND cputm_mkpf BETWEEN '000000' AND '055959'
AND xauto = 'X'
AND lgort IN @s_lgort.
IF sy-subrc = 0.
SORT lt_maton BY matnr.
ENDIF.
ENDIF.
DATA(lt_matup) = lt_maton.
DATA(lt_mat) = lt_maton.
SORT lt_mat BY matnr lgort.
DELETE ADJACENT DUPLICATES FROM lt_mat COMPARING matnr lgort.
DELETE lt_matup WHERE budat_mkpf = lv_date. "p_date.
SORT lt_matup BY matnr.
DELETE lt_maton WHERE budat_mkpf <> lv_date. "p_date.
SORT lt_maton BY matnr.
LOOP AT lt_mat ASSIGNING FIELD-SYMBOL(<ls_mat>).
ls_final-matnr = <ls_mat>-matnr.
ls_final-lgort = <ls_mat>-lgort.
IF ls_final-lgort = '1410' OR
ls_final-lgort = '1400'.
ls_final-text = 'FAB1'.
ELSEIF ls_final-lgort = '2410' OR
ls_final-lgort = '2400'.
ls_final-text = 'PH1'.
ELSEIF ls_final-lgort = '2430' OR
ls_final-lgort = '2420'.
ls_final-text = 'PH2'.
ELSEIF ls_final-lgort = '2450'.
ls_final-text = 'MAN'.
ELSE.
ls_final-text = <ls_mat>-lgort.
ENDIF.
objectkey = <ls_mat>-matnr.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = objectkey
objecttable = 'MARA'
classnum = 'Z_FG_CLASS'
classtype = '001'
keydate = sy-datum
language = sy-langu
TABLES
allocvaluesnum = it_snum
allocvalueschar = it_schar
allocvaluescurr = it_scurr
return = return.
LOOP AT it_snum INTO wa_num
WHERE charact = 'Z_FG_WATTPEAK'
AND value_from IS NOT INITIAL.
v_watt = wa_num-value_from.
ls_final-wp = v_watt.
EXIT.
ENDLOOP.
LOOP AT lt_maton ASSIGNING FIELD-SYMBOL(<ls_maton>)
WHERE matnr = <ls_mat>-matnr
AND lgort = <ls_mat>-lgort
AND budat_mkpf = lv_date. "p_date.
ls_final-menge1 = ls_final-menge1 + <ls_maton>-menge.
ENDLOOP.
LOOP AT lt_matup ASSIGNING FIELD-SYMBOL(<ls_matup>)
WHERE matnr = <ls_mat>-matnr
AND lgort = <ls_mat>-lgort
AND budat_mkpf <> lv_date. "p_date.
ls_final-menge2 = ls_final-menge2 + <ls_matup>-menge.
ENDLOOP.
ls_final-kw1 = ( ls_final-wp * ls_final-menge1 ) / 1000.
ls_final-kw2 = ( ls_final-wp * ls_final-menge2 ) / 1000.
"--Added on 6.4.19: Sandip
ls_final-menge2 = ls_final-menge2 + ls_final-menge1.
ls_final-kw2 = ls_final-kw2 + ls_final-kw1.
"--Ended on 6.4.19: Sandip
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = ls_final-matnr
IMPORTING
output = ls_final-matnr.
APPEND ls_final TO lt_final.
CLEAR: ls_final.
ENDLOOP.
ENDMETHOD.
"--Location wise Clubbing of Quanity with Wattage (KW)
METHOD m_club_last_day.
IF lt_final IS NOT INITIAL.
SELECT lgort, trgt_qty, trgt_kw
FROM zprd_last_day INTO TABLE @DATA(lt_last)
FOR ALL ENTRIES IN @lt_final
WHERE lgort = @lt_final-lgort.
SORT lt_last BY lgort.
ENDIF.
LOOP AT lt_final ASSIGNING FIELD-SYMBOL(<ls_final>).
wa_final-lgort = <ls_final>-text.
wa_final-achv_qty = <ls_final>-menge1.
wa_final-achv_kw = <ls_final>-kw1.
COLLECT wa_final INTO it_final.
CLEAR: wa_final.
ENDLOOP.
LOOP AT it_final ASSIGNING FIELD-SYMBOL(<wa_final>).
READ TABLE lt_last ASSIGNING FIELD-SYMBOL(<ls_last>)
WITH KEY lgort = <wa_final>-lgort BINARY SEARCH.
IF sy-subrc = 0.
wa_final-trgt_qty = <ls_last>-trgt_qty.
wa_final-trgt_kw = <ls_last>-trgt_kw.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD m_order_specification.
DATA w_order LIKE LINE OF r_order.
w_order-sign = 'I'.
w_order-option = 'BT'.
LOOP AT s_line ASSIGNING FIELD-SYMBOL(<line>).
IF <line>-low = 'FAB1'.
w_order-low = '000000010000'.
w_order-high = '000000019999'.
ELSEIF <line>-low = 'PH1'.
w_order-low = '000000050000'.
w_order-high = '000000059999'.
ELSEIF <line>-low = 'PH2'.
w_order-low = '000000060000'.
w_order-high = '000000069999'.
ELSEIF <line>-low = 'MAN'.
w_order-low = '000000070000'.
w_order-high = '000000079999'.
ENDIF.
APPEND w_order TO r_order.
CLEAR: w_order-low, w_order-high.
ENDLOOP.
ENDMETHOD.
METHOD m_get_zpp05_reason.
DATA lv_date TYPE sy-datum.
REFRESH it_zpp5.
SELECT sl_no
prod_ord
plant
serial_no
seq_no
stage
status
posting_date
posting_time
FROM zpp05_reason INTO TABLE it_zpp5
BYPASSING BUFFER
WHERE prod_ord IN r_order
AND stage IN ('0010','0020','UD')
AND posting_date = p_date
AND posting_time BETWEEN '060000' AND '235959'.
lv_date = p_date + 1.
SELECT sl_no
prod_ord
plant
serial_no
seq_no
stage
status
posting_date
posting_time
FROM zpp05_reason APPENDING TABLE it_zpp5
BYPASSING BUFFER
WHERE prod_ord IN r_order
AND stage IN ('0010','0020','UD')
AND posting_date = lv_date
AND posting_time BETWEEN '000000' AND '055959'.
SORT it_zpp5 BY posting_time.
ENDMETHOD.
"----------------Shift-A,B,C Output Table
METHOD m_shift_table_data.
REFRESH: it_asft, it_bsft, it_csft.
wa_asft-ztime = 'Stringer O/P'.
APPEND wa_asft TO it_asft.
wa_asft-ztime = 'Lamination O/P'.
APPEND wa_asft TO it_asft.
wa_asft-ztime = 'Testing O/P'.
APPEND wa_asft TO it_asft.
wa_bsft-ztime = 'Stringer O/P'.
APPEND wa_bsft TO it_bsft.
wa_bsft-ztime = 'Lamination O/P'.
APPEND wa_bsft TO it_bsft.
wa_bsft-ztime = 'Testing O/P'.
APPEND wa_bsft TO it_bsft.
wa_csft-ztime = 'Stringer O/P'.
APPEND wa_csft TO it_csft.
wa_csft-ztime = 'Lamination O/P'.
APPEND wa_csft TO it_csft.
wa_csft-ztime = 'Testing O/P'.
APPEND wa_csft TO it_csft.
LOOP AT it_zpp5 ASSIGNING FIELD-SYMBOL(<lw_zpp5>).
IF <lw_zpp5>-stage = '0010'.
wa_asft-ztime = 'Stringer O/P'.
wa_bsft-ztime = 'Stringer O/P'.
wa_csft-ztime = 'Stringer O/P'.
ELSEIF <lw_zpp5>-stage = '0020'.
wa_asft-ztime = 'Lamination O/P'.
wa_bsft-ztime = 'Lamination O/P'.
wa_csft-ztime = 'Lamination O/P'.
ELSEIF <lw_zpp5>-stage = 'UD' AND <lw_zpp5>-status = 'YIELD'.
wa_asft-ztime = 'Testing O/P'.
wa_bsft-ztime = 'Testing O/P'.
wa_csft-ztime = 'Testing O/P'.
ELSE.
CONTINUE.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '060000' AND '135959'.
IF <lw_zpp5>-posting_time BETWEEN '060000' AND '075959'.
wa_asft-am6_8 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '080000' AND '095959'.
wa_asft-am8_10 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '100000' AND '115959'.
wa_asft-am10_12 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '120000' AND '135959'.
wa_asft-pm12_2 = 1.
ENDIF.
COLLECT wa_asft INTO it_asft.
CLEAR wa_asft.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '140000' AND '215959'.
IF <lw_zpp5>-posting_time BETWEEN '140000' AND '155959'.
wa_bsft-pm2_4 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '160000' AND '175959'.
wa_bsft-pm4_6 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '180000' AND '195959'.
wa_bsft-pm6_8 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '200000' AND '215959'.
wa_bsft-pm8_10 = 1.
ENDIF.
COLLECT wa_bsft INTO it_bsft.
CLEAR wa_bsft.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '220000' AND '235959'.
wa_csft-pm10_12 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '000000' AND '015959'.
wa_csft-am12_2 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '020000' AND '035959'.
wa_csft-am2_4 = 1.
ENDIF.
IF <lw_zpp5>-posting_time BETWEEN '040000' AND '055959'.
wa_csft-am4_6 = 1.
ENDIF.
COLLECT wa_csft INTO it_csft.
CLEAR wa_csft.
ENDLOOP.
ENDMETHOD.
METHOD m_field_catalog.
DATA: prev_date TYPE char10,
live_date TYPE char10,
next_date TYPE char10,
lv_date TYPE sy-datum.
lv_date = p_date - 1.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = lv_date
IMPORTING
date_external = prev_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = p_date
IMPORTING
date_external = live_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
lv_date = p_date + 1.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = lv_date
IMPORTING
date_external = next_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
wa_lay_l-zebra = 'X'.
wa_lay_l-cwidth_opt = 'X'.
wa_lay_l-grid_title = 'Previous Achievement: Date-'
&& | | && prev_date.
wa_lay_a-zebra = 'X'.
wa_lay_a-cwidth_opt = 'X'.
wa_lay_a-grid_title = 'A-Shift: Date-'
&& | | && live_date. "--Shift-A Layout
wa_lay_b-zebra = 'X'.
wa_lay_b-cwidth_opt = 'X'.
wa_lay_b-grid_title = 'B-Shift: Date-'
&& | | && live_date. "--Shift-B Layout
wa_lay_c-zebra = 'X'.
wa_lay_c-cwidth_opt = 'X'.
wa_lay_c-grid_title = 'C-Shift: Date-'
&& | | && live_date &&
| - | && next_date. "--Shift-C Layout
REFRESH: it_fcat_l, it_fcat_a, it_fcat_b, it_fcat_c.
DATA lv_col TYPE i VALUE IS INITIAL.
"-------------------Previous Achievement Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'LGORT'.
wa_fcat-reptext = 'Storage'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'TRGT_QTY'.
wa_fcat-reptext = 'Target Qty'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ACHV_QTY'.
wa_fcat-reptext = 'Achieved Qty'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'TRGT_KW'.
wa_fcat-reptext = 'Target KW'.
APPEND wa_fcat TO it_fcat_l.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ACHV_KW'.
wa_fcat-reptext = 'Achieved KW'.
APPEND wa_fcat TO it_fcat_l.
CLEAR: wa_fcat, lv_col.
"--------------------------A Shift Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ZTIME'.
wa_fcat-reptext = 'Time'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM6_8'.
wa_fcat-reptext = '6-8 AM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM8_10'.
wa_fcat-reptext = '8-10 AM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM10_12'.
wa_fcat-reptext = '10-12 AM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM12_2'.
wa_fcat-reptext = '12-2 PM'.
APPEND wa_fcat TO it_fcat_a.
CLEAR: wa_fcat, lv_col.
"--------------------------B Shift Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ZTIME'.
wa_fcat-reptext = 'Time'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM2_4'.
wa_fcat-reptext = '2-4 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM4_6'.
wa_fcat-reptext = '4-6 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM6_8'.
wa_fcat-reptext = '6-8 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM8_10'.
wa_fcat-reptext = '8-10 PM'.
APPEND wa_fcat TO it_fcat_b.
CLEAR: wa_fcat, lv_col.
"--------------------------C Shift Field Catalog
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ZTIME'.
wa_fcat-reptext = 'Time'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'PM10_12'.
wa_fcat-reptext = '10-12 PM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM12_2'.
wa_fcat-reptext = '12-2 AM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM2_4'.
wa_fcat-reptext = '2-4 AM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'AM4_6'.
wa_fcat-reptext = '4-6 AM'.
APPEND wa_fcat TO it_fcat_c.
CLEAR: wa_fcat, lv_col.
ENDMETHOD.
METHOD m_alv_grid_output.
"--ALV Grid for Previous Day Achievement
CREATE OBJECT obj_cont_last EXPORTING container_name = 'CONT_LAST'.
CREATE OBJECT obj_alv_last EXPORTING i_parent = obj_cont_last.
CALL METHOD obj_alv_last->set_table_for_first_display
EXPORTING
is_layout = wa_lay_l
CHANGING
it_fieldcatalog = it_fcat_l
it_outtab = it_final.
"--ALV Grid for A-Shift
CREATE OBJECT obj_cont_asft EXPORTING container_name = 'CONT_ASFT'.
CREATE OBJECT obj_alv_asft EXPORTING i_parent = obj_cont_asft.
CALL METHOD obj_alv_asft->set_table_for_first_display
EXPORTING
is_layout = wa_lay_a
CHANGING
it_fieldcatalog = it_fcat_a
it_outtab = it_asft.
"--ALV Grid for B-Shift
CREATE OBJECT obj_cont_bsft EXPORTING container_name = 'CONT_BSFT'.
CREATE OBJECT obj_alv_bsft EXPORTING i_parent = obj_cont_bsft.
CALL METHOD obj_alv_bsft->set_table_for_first_display
EXPORTING
is_layout = wa_lay_b
CHANGING
it_fieldcatalog = it_fcat_b
it_outtab = it_bsft.
"--ALV Grid for C-Shift
CREATE OBJECT obj_cont_csft EXPORTING container_name = 'CONT_CSFT'.
CREATE OBJECT obj_alv_csft EXPORTING i_parent = obj_cont_csft.
CALL METHOD obj_alv_csft->set_table_for_first_display
EXPORTING
is_layout = wa_lay_c
CHANGING
it_fieldcatalog = it_fcat_c
it_outtab = it_csft.
ENDMETHOD.
METHOD m_report_refresh.
IF obj_alv_asft IS NOT INITIAL AND
obj_alv_bsft IS NOT INITIAL AND
obj_alv_csft IS NOT INITIAL.
CALL METHOD: obj_prod->m_get_zpp05_reason,
obj_prod->m_shift_table_data,
obj_prod->m_field_catalog,
obj_alv_asft->refresh_table_display,
obj_alv_bsft->refresh_table_display,
obj_alv_csft->refresh_table_display.
CONCATENATE sy-uzeit+0(2) ':'
sy-uzeit+2(2) ':'
sy-uzeit+4(2)
INTO DATA(lv_uzeit).
CONCATENATE 'Last Update at' lv_uzeit
INTO v_mess SEPARATED BY space.
MESSAGE v_mess TYPE 'S'.
CALL METHOD obj_timer->run.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CREATE OBJECT: obj_prod,
obj_timer.
CALL METHOD: obj_prod->m_last_day_calculation,
obj_prod->m_club_last_day,
obj_prod->m_order_specification,
obj_prod->m_get_zpp05_reason,
obj_prod->m_shift_table_data,
obj_prod->m_field_catalog.
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'PF_9000'.
SET TITLEBAR 'T_9000'.
SET HANDLER obj_prod->m_report_refresh FOR obj_timer.
obj_timer->interval = 10.
CALL METHOD: obj_timer->run,
obj_prod->m_alv_grid_output.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
No comments:
Post a Comment