Skip to Content
-1

how to get "Day1",."Day31" into datewise like - "01-01-2018".."31-01-2018"..?

I have created an alv report, but need to do some changes..Like-

1. Change the Row in columns.

2. In columns where is "Day1", "Day2" is coming there should to come 4 extra column for "Day1" , "Days" ... "Day31"/

3. and each "Days" should come in date format.

Anyone can help me for doing this..?

My code is below -

*&---------------------------------------------------------------------*
*& Report ZPP_PLAN_VS_ACT_RPT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZPP_PLAN_VS_ACT_RPT.
TABLES : ZPPPLAN, MARC.
TYPES : SLIS_POOL.

TYPES : BEGIN OF TY_FINAL,
PMONTH TYPE ZPPPLAN-PMONTH,
PYEAR TYPE ZPPPLAN-PYEAR,
TYPE TYPE STRING,
WORKCENTER TYPE ZPPPLAN-WORKCENTER,
KTEXT TYPE CRTX-KTEXT,
MATNR TYPE ZPPPLAN-MATNR,
MAKTX TYPE MAKT-MAKTX,
DISPO TYPE MARC-DISPO,
PLAN_TOT TYPE ZPPPLAN-DAY1,
UP_TOT TYPE ZPPPLAN-DAY1,
TOTAL TYPE ZPPPLAN-DAY1,
DAY1 TYPE ZPPPLAN-DAY1,
DAY2 TYPE ZPPPLAN-DAY2,
DAY3 TYPE ZPPPLAN-DAY3,
DAY4 TYPE ZPPPLAN-DAY4,
DAY5 TYPE ZPPPLAN-DAY5,
DAY6 TYPE ZPPPLAN-DAY6,
DAY7 TYPE ZPPPLAN-DAY7,
DAY8 TYPE ZPPPLAN-DAY8,
DAY9 TYPE ZPPPLAN-DAY9,
DAY10 TYPE ZPPPLAN-DAY10,
DAY11 TYPE ZPPPLAN-DAY11,
DAY12 TYPE ZPPPLAN-DAY12,
DAY13 TYPE ZPPPLAN-DAY13,
DAY14 TYPE ZPPPLAN-DAY14,
DAY15 TYPE ZPPPLAN-DAY15,
DAY16 TYPE ZPPPLAN-DAY16,
DAY17 TYPE ZPPPLAN-DAY17,
DAY18 TYPE ZPPPLAN-DAY18,
DAY19 TYPE ZPPPLAN-DAY19,
DAY20 TYPE ZPPPLAN-DAY20,
DAY21 TYPE ZPPPLAN-DAY21,
DAY22 TYPE ZPPPLAN-DAY22,
DAY23 TYPE ZPPPLAN-DAY23,
DAY24 TYPE ZPPPLAN-DAY24,
DAY25 TYPE ZPPPLAN-DAY25,
DAY26 TYPE ZPPPLAN-DAY26,
DAY27 TYPE ZPPPLAN-DAY27,
DAY28 TYPE ZPPPLAN-DAY28,
DAY29 TYPE ZPPPLAN-DAY29,
DAY30 TYPE ZPPPLAN-DAY30,
DAY31 TYPE ZPPPLAN-DAY31,
END OF TY_FINAL.

TYPES : BEGIN OF TY_CRHD,
OBJID TYPE CRHD-OBJID,
ARBPL TYPE CRHD-ARBPL,
END OF TY_CRHD.

TYPES : BEGIN OF TY_AFRU,
RUECK TYPE AFRU-RUECK,
RMZHL TYPE AFRU-RMZHL,
ARBID TYPE AFRU-ARBID,
BUDAT TYPE AFRU-BUDAT,
AUFNR TYPE AFRU-AUFNR,
END OF TY_AFRU.

TYPES : BEGIN OF TY_MATDOC,
KEY1 TYPE MATDOC-KEY1,
KEY2 TYPE MATDOC-KEY2,
KEY3 TYPE MATDOC-KEY3,
KEY4 TYPE MATDOC-KEY4,
KEY5 TYPE MATDOC-KEY5,
KEY6 TYPE MATDOC-KEY6,
AUFNR TYPE MATDOC-AUFNR,
BUDAT TYPE MATDOC-BUDAT,
BWART TYPE MATDOC-BWART,
ERFMG TYPE MATDOC-ERFMG,
MATNR TYPE MATDOC-MATNR,
END OF TY_MATDOC.

TYPES : BEGIN OF TY_MAKT,
MATNR TYPE MAKT-MATNR,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END OF TY_MAKT.


TYPES : BEGIN OF TY_CRTX,
OBJID TYPE CRTX-OBJID,
SPRAS TYPE CRTX-SPRAS,
KTEXT TYPE CRTX-KTEXT,
END OF TY_CRTX.

TYPES : BEGIN OF TY_MARC,
MATNR TYPE MARC-MATNR,
WERKS TYPE MARC-WERKS,
DISPO TYPE MARC-DISPO,
END OF TY_MARC.

DATA : IT_ZPPPLAN TYPE STANDARD TABLE OF ZPPPLAN,
WA_ZPPPLAN TYPE ZPPPLAN,
IT_ZPPPLAN_UP TYPE STANDARD TABLE OF ZPPPLAN_UP,
WA_ZPPPLAN_UP TYPE ZPPPLAN_UP,
IT_UNPLAN TYPE STANDARD TABLE OF ZPPPLAN_UP,
WA_UNPLAN TYPE ZPPPLAN_UP,
IT_CRHD TYPE STANDARD TABLE OF TY_CRHD,
WA_CRHD TYPE TY_CRHD,
IT_AFRU TYPE STANDARD TABLE OF TY_AFRU,
WA_AFRU TYPE TY_AFRU,
IT_MATDOC TYPE STANDARD TABLE OF TY_MATDOC,
WA_MATDOC TYPE TY_MATDOC,
IT_MAKT TYPE STANDARD TABLE OF TY_MAKT,
WA_MAKT TYPE TY_MAKT,
IT_FINAL TYPE STANDARD TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL,
IT_CRTX TYPE STANDARD TABLE OF TY_CRTX,
WA_CRTX TYPE TY_CRTX,
IT_CRTX_01 TYPE STANDARD TABLE OF TY_CRTX,
WA_CRTX_01 TYPE TY_CRTX,
IT_CRHD_01 TYPE STANDARD TABLE OF TY_CRHD,
WA_CRHD_01 TYPE TY_CRHD,
IT_MARC TYPE STANDARD TABLE OF TY_MARC,
WA_MARC TYPE TY_MARC.



DATA : WA_MONTH TYPE RSDSSELOPT,
WA_YEAR TYPE RSDSSELOPT,
NEW_BUDAT TYPE STANDARD TABLE OF RSDSSELOPT,
WA_BUDAT TYPE RSDSSELOPT,
PAR_MONTH TYPE T009B-BUMON,
PAR_YEAR TYPE T009B-BDATJ,
PAR_DAYS TYPE T009B-BUTAG,
IV_DATE TYPE D,
BEGIN_DATE TYPE D,
END_DATE TYPE D.
""data declarations for ALV Main list
DATA : IT_FCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
********************************************************************************************************************************END HERE

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

SELECT-OPTIONS : P_MONTH FOR ZPPPLAN-PMONTH NO INTERVALS NO-EXTENSION OBLIGATORY,
P_YEAR FOR ZPPPLAN-PYEAR NO INTERVALS NO-EXTENSION OBLIGATORY,
P_WORKC FOR ZPPPLAN-WORKCENTER,
P_DISPO FOR MARC-DISPO.

SELECTION-SCREEN : END OF BLOCK B1.

START-OF-SELECTION.

PERFORM GETDATA.
PERFORM CREATE_FCAT.

END-OF-SELECTION.
PERFORM DISP_ALV.
*&---------------------------------------------------------------------*
*& Form GETDATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM GETDATA .

READ TABLE P_MONTH INTO WA_MONTH INDEX 1.
PAR_MONTH = WA_MONTH-LOW+0(2).
READ TABLE P_YEAR INTO WA_YEAR INDEX 1.
PAR_YEAR = WA_YEAR-LOW+0(4).

CONCATENATE PAR_YEAR PAR_MONTH '01' INTO IV_DATE .



CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
IV_DATE = IV_DATE
IMPORTING
EV_MONTH_BEGIN_DATE = BEGIN_DATE
EV_MONTH_END_DATE = END_DATE.

WA_BUDAT-LOW = BEGIN_DATE.
WA_BUDAT-HIGH = END_DATE.
WA_BUDAT-SIGN = 'I'.
WA_BUDAT-OPTION = 'BT'.
APPEND WA_BUDAT TO NEW_BUDAT.



SELECT * FROM ZPPPLAN INTO TABLE IT_ZPPPLAN WHERE PMONTH IN P_MONTH AND PYEAR IN P_YEAR AND WORKCENTER IN P_WORKC.

SELECT * FROM ZPPPLAN_UP INTO TABLE IT_ZPPPLAN_UP WHERE PMONTH IN P_MONTH AND PYEAR IN P_YEAR AND WORKCENTER IN P_WORKC.

LOOP AT IT_ZPPPLAN_UP INTO WA_ZPPPLAN_UP.
CLEAR : WA_ZPPPLAN_UP-ERDAT.
COLLECT WA_ZPPPLAN_UP INTO IT_UNPLAN.
CLEAR : WA_ZPPPLAN_UP.

ENDLOOP.




IF IT_ZPPPLAN IS NOT INITIAL.
SELECT MATNR
SPRAS
MAKTX
FROM MAKT INTO TABLE IT_MAKT
FOR ALL ENTRIES IN IT_ZPPPLAN
WHERE MATNR = IT_ZPPPLAN-MATNR AND SPRAS = 'EN'.

SELECT MATNR
WERKS
DISPO FROM MARC INTO TABLE IT_MARC
FOR ALL ENTRIES IN IT_ZPPPLAN
WHERE MATNR = IT_ZPPPLAN-MATNR .

ENDIF.


""""""
LOOP AT IT_ZPPPLAN INTO WA_ZPPPLAN.

MOVE-CORRESPONDING WA_ZPPPLAN TO WA_FINAL.
WA_FINAL-TYPE = 'PLAN'.

READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_ZPPPLAN-MATNR.
IF SY-SUBRC = 0.
WA_FINAL-MAKTX = WA_MAKT-MAKTX.
ENDIF.


READ TABLE IT_MARC INTO WA_MARC WITH KEY MATNR = WA_ZPPPLAN-MATNR.
IF SY-SUBRC = 0.
WA_FINAL-DISPO = WA_MARC-DISPO.
ENDIF.

SELECT OBJID
ARBPL FROM CRHD INTO TABLE IT_CRHD_01
WHERE ARBPL = WA_FINAL-WORKCENTER.

IF IT_CRHD_01 IS NOT INITIAL.

SELECT OBJID
SPRAS
KTEXT FROM CRTX INTO TABLE IT_CRTX_01
FOR ALL ENTRIES IN IT_CRHD_01
WHERE OBJID = IT_CRHD_01-OBJID AND SPRAS = 'EN'.

ENDIF.


READ TABLE IT_CRHD_01 INTO WA_CRHD_01 WITH KEY ARBPL = WA_ZPPPLAN-WORKCENTER.
IF SY-SUBRC = 0.


READ TABLE IT_CRTX_01 INTO WA_CRTX_01 WITH KEY OBJID = WA_CRHD_01-OBJID.
IF SY-SUBRC = 0.
WA_FINAL-KTEXT = WA_CRTX_01-KTEXT.
ENDIF.
ENDIF.


WA_FINAL-PLAN_TOT = WA_FINAL-DAY1 + WA_FINAL-DAY2 + WA_FINAL-DAY3 + WA_FINAL-DAY4 + WA_FINAL-DAY5 + WA_FINAL-DAY6 + WA_FINAL-DAY7 + WA_FINAL-DAY8 +
WA_FINAL-DAY9 + WA_FINAL-DAY10 + WA_FINAL-DAY11 + WA_FINAL-DAY12 + WA_FINAL-DAY13 + WA_FINAL-DAY14 + WA_FINAL-DAY15 + WA_FINAL-DAY16 +
WA_FINAL-DAY17 + WA_FINAL-DAY18 + WA_FINAL-DAY19 + WA_FINAL-DAY20 + WA_FINAL-DAY21 + WA_FINAL-DAY22 + WA_FINAL-DAY23 + WA_FINAL-DAY24 +
WA_FINAL-DAY25 + WA_FINAL-DAY26 + WA_FINAL-DAY27 + WA_FINAL-DAY28 + WA_FINAL-DAY29 + WA_FINAL-DAY30 + WA_FINAL-DAY31.

READ TABLE IT_UNPLAN INTO WA_UNPLAN WITH KEY MATNR = WA_ZPPPLAN-MATNR WORKCENTER = WA_ZPPPLAN-WORKCENTER .

IF SY-SUBRC = 0.
WA_FINAL-UP_TOT = WA_UNPLAN-DAY1 + WA_UNPLAN-DAY2 + WA_UNPLAN-DAY3 + WA_UNPLAN-DAY4 + WA_UNPLAN-DAY5 + WA_UNPLAN-DAY6 + WA_UNPLAN-DAY7 + WA_UNPLAN-DAY8
+ WA_UNPLAN-DAY9 + WA_UNPLAN-DAY10 + WA_UNPLAN-DAY11 + WA_UNPLAN-DAY12 + WA_UNPLAN-DAY13 + WA_UNPLAN-DAY14 + WA_UNPLAN-DAY15 +
WA_UNPLAN-DAY16 + WA_UNPLAN-DAY17 + WA_UNPLAN-DAY18 + WA_UNPLAN-DAY19 + WA_UNPLAN-DAY20 + WA_UNPLAN-DAY21 + WA_UNPLAN-DAY22
+ WA_UNPLAN-DAY23 + WA_UNPLAN-DAY24 + WA_UNPLAN-DAY25 + WA_UNPLAN-DAY26 + WA_UNPLAN-DAY27 + WA_UNPLAN-DAY28 + WA_UNPLAN-DAY29 +
WA_UNPLAN-DAY30 + WA_UNPLAN-DAY31 .

ENDIF.

WA_FINAL-TOTAL = WA_FINAL-PLAN_TOT + WA_FINAL-UP_TOT.


APPEND WA_FINAL TO IT_FINAL.
CLEAR :WA_FINAL.
""""""""

WA_FINAL-PMONTH = WA_ZPPPLAN-PMONTH.
WA_FINAL-PYEAR = WA_ZPPPLAN-PYEAR.
WA_FINAL-TYPE = 'Actual'.
WA_FINAL-WORKCENTER = WA_ZPPPLAN-WORKCENTER.
WA_FINAL-MATNR = WA_ZPPPLAN-MATNR.


READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_ZPPPLAN-MATNR.
IF SY-SUBRC = 0.
WA_FINAL-MAKTX = WA_MAKT-MAKTX.
ENDIF.


READ TABLE IT_MARC INTO WA_MARC WITH KEY MATNR = WA_ZPPPLAN-MATNR.
IF SY-SUBRC = 0.
WA_FINAL-DISPO = WA_MARC-DISPO.
ENDIF.

SELECT OBJID
ARBPL FROM CRHD INTO TABLE IT_CRHD
WHERE ARBPL = WA_ZPPPLAN-WORKCENTER.
IF IT_CRHD IS NOT INITIAL.

SELECT RUECK
RMZHL
ARBID
BUDAT
AUFNR FROM AFRU INTO TABLE IT_AFRU
FOR ALL ENTRIES IN IT_CRHD
WHERE ARBID = IT_CRHD-OBJID.

SELECT OBJID
SPRAS
KTEXT FROM CRTX INTO TABLE IT_CRTX
FOR ALL ENTRIES IN IT_CRHD
WHERE OBJID = IT_CRHD-OBJID AND SPRAS = 'EN'.


IF IT_AFRU IS NOT INITIAL.

SELECT KEY1
KEY2
KEY3
KEY4
KEY5
KEY6
AUFNR
BUDAT
BWART
ERFMG
MATNR FROM MATDOC INTO TABLE IT_MATDOC
FOR ALL ENTRIES IN IT_AFRU
WHERE AUFNR = IT_AFRU-AUFNR
AND ( BWART = '101' OR BWART = '102' )
AND BUDAT IN NEW_BUDAT.

ENDIF.


READ TABLE IT_CRHD INTO WA_CRHD WITH KEY ARBPL = WA_ZPPPLAN-WORKCENTER.
IF SY-SUBRC = 0.


READ TABLE IT_CRTX INTO WA_CRTX WITH KEY OBJID = WA_CRHD-OBJID.
IF SY-SUBRC = 0.
WA_FINAL-KTEXT = WA_CRTX-KTEXT.
ENDIF.
ENDIF.


LOOP AT IT_MATDOC INTO WA_MATDOC WHERE MATNR = WA_FINAL-MATNR.

IF WA_MATDOC-BUDAT+6(2) = 1.
WA_FINAL-DAY1 = WA_FINAL-DAY1 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 2.
WA_FINAL-DAY2 = WA_FINAL-DAY2 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 3.
WA_FINAL-DAY3 = WA_FINAL-DAY3 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 4.
WA_FINAL-DAY4 = WA_FINAL-DAY4 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 5.
WA_FINAL-DAY5 = WA_FINAL-DAY5 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 6.
WA_FINAL-DAY6 = WA_FINAL-DAY6 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 7.
WA_FINAL-DAY7 = WA_FINAL-DAY7 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 8.
WA_FINAL-DAY8 = WA_FINAL-DAY8 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 9.
WA_FINAL-DAY9 = WA_FINAL-DAY9 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 10.
WA_FINAL-DAY10 = WA_FINAL-DAY10 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 11.
WA_FINAL-DAY11 = WA_FINAL-DAY11 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 12.
WA_FINAL-DAY12 = WA_FINAL-DAY12 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 13.
WA_FINAL-DAY13 = WA_FINAL-DAY13 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 14.
WA_FINAL-DAY14 = WA_FINAL-DAY14 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 15.
WA_FINAL-DAY15 = WA_FINAL-DAY15 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 16.
WA_FINAL-DAY16 = WA_FINAL-DAY16 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 17.
WA_FINAL-DAY17 = WA_FINAL-DAY17 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 18.
WA_FINAL-DAY18 = WA_FINAL-DAY18 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 19.
WA_FINAL-DAY19 = WA_FINAL-DAY19 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 20.
WA_FINAL-DAY20 = WA_FINAL-DAY20 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 21.
WA_FINAL-DAY21 = WA_FINAL-DAY21 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 22.
WA_FINAL-DAY22 = WA_FINAL-DAY22 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 23.
WA_FINAL-DAY23 = WA_FINAL-DAY23 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 24.
WA_FINAL-DAY24 = WA_FINAL-DAY24 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 25.
WA_FINAL-DAY25 = WA_FINAL-DAY25 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 26.
WA_FINAL-DAY26 = WA_FINAL-DAY26 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 27.
WA_FINAL-DAY27 = WA_FINAL-DAY27 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 28.
WA_FINAL-DAY28 = WA_FINAL-DAY28 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 29.
WA_FINAL-DAY29 = WA_FINAL-DAY29 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 30.
WA_FINAL-DAY30 = WA_FINAL-DAY30 + WA_MATDOC-ERFMG .
ENDIF.


IF WA_MATDOC-BUDAT+6(2) = 31.
WA_FINAL-DAY31 = WA_FINAL-DAY31 + WA_MATDOC-ERFMG .
ENDIF.
ENDLOOP.

WA_FINAL-TOTAL = WA_FINAL-DAY1 + WA_FINAL-DAY2 + WA_FINAL-DAY3 + WA_FINAL-DAY4 + WA_FINAL-DAY5 + WA_FINAL-DAY6 + WA_FINAL-DAY7 + WA_FINAL-DAY8 +
WA_FINAL-DAY9 + WA_FINAL-DAY10 + WA_FINAL-DAY11 + WA_FINAL-DAY12 + WA_FINAL-DAY13 + WA_FINAL-DAY14 + WA_FINAL-DAY15 + WA_FINAL-DAY16 +
WA_FINAL-DAY17 + WA_FINAL-DAY18 + WA_FINAL-DAY19 + WA_FINAL-DAY20 + WA_FINAL-DAY21 + WA_FINAL-DAY22 + WA_FINAL-DAY23 + WA_FINAL-DAY24 +
WA_FINAL-DAY25 + WA_FINAL-DAY26 + WA_FINAL-DAY27 + WA_FINAL-DAY28 + WA_FINAL-DAY29 + WA_FINAL-DAY30 + WA_FINAL-DAY31.

ENDIF.

APPEND WA_FINAL TO IT_FINAL.
CLEAR : IT_CRHD,IT_AFRU,IT_MATDOC,IT_CRTX,IT_CRHD_01,IT_CRTX_01.

ENDLOOP.

IF P_DISPO IS NOT INITIAL.
DELETE IT_FINAL WHERE DISPO NOT IN P_DISPO.
ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_FCAT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CREATE_FCAT .
WA_LAYOUT-ZEBRA = 'X'.

DATA: V_POS TYPE CHAR10,
LV_FNAME TYPE STRING,
LV_DAY TYPE STRING.

V_POS = 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'PMONTH' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Month' .
WA_FCAT-KEY = 'X'.
WA_FCAT-OUTPUTLEN = '5'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .

V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'PYEAR' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Year' .
WA_FCAT-KEY = 'X'.
WA_FCAT-OUTPUTLEN = '5'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'TYPE' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Type' .
WA_FCAT-OUTPUTLEN = '7'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .

V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'WORKCENTER' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Workcenter' .
WA_FCAT-OUTPUTLEN = '20'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'KTEXT' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Workcenter Des' .
WA_FCAT-OUTPUTLEN = '20'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .

V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'MATNR' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Material' .
WA_FCAT-OUTPUTLEN = '20'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'MAKTX' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Material Desc' .
WA_FCAT-OUTPUTLEN = '30'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'DISPO' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'MRP Controller' .
WA_FCAT-OUTPUTLEN = '15'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'PLAN_TOT' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Planned Tot.' .
WA_FCAT-OUTPUTLEN = '15'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'UP_TOT' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Unplanned Tot.' .
WA_FCAT-OUTPUTLEN = '15'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .

V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = 'TOTAL' .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = 'Total' .
WA_FCAT-OUTPUTLEN = '15'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .

CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'
EXPORTING
PAR_MONTH = PAR_MONTH
PAR_YEAR = PAR_YEAR
IMPORTING
PAR_DAYS = PAR_DAYS.

DO PAR_DAYS TIMES.

LV_DAY = SY-INDEX.
CONCATENATE 'DAY' LV_DAY INTO LV_FNAME .

V_POS = V_POS + 1 .
WA_FCAT-COL_POS = V_POS .
WA_FCAT-FIELDNAME = LV_FNAME .
WA_FCAT-TABNAME = 'IT_FINAL' .
WA_FCAT-SELTEXT_M = LV_FNAME .
WA_FCAT-OUTPUTLEN = '10'.
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .
ENDDO.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISP_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM DISP_ALV .


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_USER_COMMAND = 'U_COMM'
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.



ENDFORM.

FORM TOP-OF-PAGE.
*ALV Header declarations
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE WA_HEADER-INFO,
LD_LINES TYPE I,
LD_LINESC(10) TYPE C.

* Title
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'Plan Vs Actual Report'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.

"Date
WA_HEADER-TYP = 'S'.
WA_HEADER-KEY = 'Planned Month:'.
WA_HEADER-INFO = PAR_MONTH.

DATA : STR1 TYPE STRING,
STR2 TYPE STRING.

* READ TABLE P_ERDAT INDEX 1.
* IF P_ERDAT-HIGH IS NOT INITIAL.
* CONCATENATE P_ERDAT-LOW+6(2) P_ERDAT-LOW+4(2) P_ERDAT-LOW+0(4)
* INTO STR1 SEPARATED BY '.'.
* CONCATENATE P_ERDAT-HIGH+6(2) P_ERDAT-HIGH+4(2) P_ERDAT-HIGH+0(4)
* INTO STR2 SEPARATED BY '.'.
*
* CONCATENATE STR1 'to' STR2 INTO WA_HEADER-INFO SEPARATED BY ' '.
* ELSE.
* CONCATENATE P_ERDAT-LOW+6(2) P_ERDAT-LOW+4(2) P_ERDAT-LOW+0(4)
* INTO STR1 SEPARATED BY '.'.
* WA_HEADER-INFO = STR1.
* ENDIF.

APPEND WA_HEADER TO T_HEADER.
CLEAR: WA_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.

ENDFORM.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 08, 2018 at 10:16 AM
    • Did you try to change the header text during field catalog creation?
    • Why do you build a new report with old REUSE FM when more up-to-date classes are available?
    • Did you try tp reduce your code length by using some assign statements in place of so many hard coded values (from '01' to '31')
    • ...

    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.