ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Water fall 报表

Water fall 报表

原创 Linux操作系统 作者:ytfsrs2008 时间:2009-02-14 09:50:39 0 删除 编辑

REPORT ZRPP0013 NO STANDARD PAGE HEADING.
TABLES:MARC,
       ZPP015,
       PBIM,
       PBED.
*******************ALV Define pool************************
TYPE-POOLS:SLIS.
DATA:ITAB_FIELD    TYPE SLIS_FIELDCAT_ALV.
DATA:ITAB_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
*******************ALV CATALOG****************************
DATA:LINEOBJ TYPE ZPP015.
DATA:ITAB_FCST TYPE TABLE OF ZPP015.

Data:WEEK  LIKE SCAL-WEEK,
     START_DATE LIKE SY-DATUM,
     END_DATE LIKE SY-DATUM,
     REQ_DATE  LIKE SY-DATUM,
     DAT_CUTOFF LIKE SY-DATUM,
     START_WEEK LIKE SCAL-WEEK,
     END_WEEK LIKE SCAL-WEEK,
     DE TYPE I,
     TEMPDATE LIKE SY-DATUM,
     TEMPWEEK LIKE SCAL-WEEK,
     NUM_STRING(10) type c,
     RESULTWEEK(6) TYPE C,
     WEEK1 LIKE SCAL-WEEK,
     RESULT(6) TYPE C.

DATA:BEGIN OF FCSTLINE,
     MATNR TYPE PBIM-MATNR,
     WERKS TYPE PBIM-WERKS,
     PLNMG TYPE PBED-PLNMG,
     MEINS TYPE PBED-MEINS,
     PDATU TYPE PBED-PDATU,
     PERXX TYPE PBED-PERXX,
     END OF FCSTLINE.
DATA:FCST LIKE TABLE OF FCSTLINE.

DATA:BEGIN OF FCSTLINE1,
     MATNR TYPE PBIM-MATNR,
     WERKS TYPE PBIM-WERKS,
     PLNMG TYPE PBED-PLNMG,
     MEINS TYPE PBED-MEINS,
     PERXX TYPE PBED-PERXX,
     BACKWEEK TYPE PBED-PERXX,
     END OF FCSTLINE1.

data:fcst1 LIKE table of  FCSTLINE1.

DATA:BEGIN OF ALV_LINE.
    include structure ZPP003.
DATA:END OF ALV_LINE.

DATA:ALV_TAB LIKE TABLE OF ALV_LINE WITH NON-UNIQUE  KEY MATNR WERKS
BACKWEEK.
DATA:ALV_LINE1 LIKE ALV_LINE.
SELECTION-SCREEN BEGIN OF BLOCK M1A WITH FRAME. TITLE TEXT-001.
SELECT-OPTIONS : DB_MATNR FOR MARC-MATNR MEMORY ID MAT.
PARAMETERS: XWERKS  LIKE MARC-WERKS MEMORY ID WRK.
SELECTION-SCREEN END OF BLOCK M1A.

SELECTION-SCREEN BEGIN OF BLOCK M2A WITH FRAME. TITLE TEXT-002.
PARAMETERS: CUR_PER  LIKE SY-DATUM  DEFAULT SY-DATUM.
PARAMETERS: B_WEEK(2) TYPE N DEFAULT 04.
parameters: F_WEEK(2) TYPE N DEFAULT 09.
SELECTION-SCREEN END OF BLOCK M2A.

START-OF-SELECTION.
  CUR_PER = SY-DATUM.
  DE = -1.
  PERFORM. GET_WEEK USING CUR_PER
                   CHANGING WEEK.

  CALL FUNCTION 'WEEK_GET_FIRST_DAY'
       EXPORTING
            WEEK         = WEEK
       IMPORTING
            DATE         = REQ_DATE
       EXCEPTIONS
            WEEK_INVALID = 1
            OTHERS       = 2.

  END_DATE   = REQ_DATE + ( F_WEEK * 7 ) - 1.
  START_DATE = REQ_DATE - B_WEEK * 7.

  PERFORM. GET_WEEK USING START_DATE
                   CHANGING START_WEEK.
  PERFORM. GET_WEEK USING END_DATE
                   CHANGING END_WEEK.

  PERFORM. GET_DETIAL_DATA.
  PERFORM. GET_PARAMS.
  PERFORM. DISPLAY_ALV.

FORM. GET_DETIAL_DATA.
data:i_time type i.
 i_time = b_week + 1.
 DO i_time TIMES.
    DE = DE + 1.
    TEMPDATE = START_DATE + DE * 7.
    PERFORM. GET_WEEK USING TEMPDATE
                     CHANGING TEMPWEEK.
    SELECT * FROM ZPP015 INTO TABLE ITAB_FCST
             WHERE BACKWEEK = TEMPWEEK AND MATNR IN DB_MATNR
             AND PERXX >= START_WEEK AND WERKS = XWERKS.
    IF SY-SUBRC = 4.
         CONTINUE.
    ELSE.
       CLEAR ALV_LINE.
       SORT ITAB_FCST BY MATNR PERXX.
       LOOP AT ITAB_FCST INTO LINEOBJ.
         CLEAR ALV_LINE.
         READ TABLE ALV_TAB  INTO ALV_LINE1 WITH KEY
         MATNR = LINEOBJ-MATNR BACKWEEK = LINEOBJ-BACKWEEK WERKS =
         LINEOBJ-WERKS.
         CLEAR ALV_LINE1.
         IF SY-SUBRC <> 0.
           CLEAR ALV_LINE.
           ALV_LINE-MATNR = LINEOBJ-MATNR.
           ALV_LINE-WERKS = LINEOBJ-WERKS.
           ALV_LINE-BACKWEEK = LINEOBJ-BACKWEEK.
           PERFORM. GET_WEEKNO USING LINEOBJ-PERXX.
           PERFORM. FILL_DBFIELD USING RESULTWEEK LINEOBJ-PLNMG.
           APPEND ALV_LINE TO ALV_TAB.
         ELSEIF SY-SUBRC = 0.
           CLEAR ALV_LINE.
           ALV_LINE-MATNR = LINEOBJ-MATNR.
           ALV_LINE-WERKS = LINEOBJ-WERKS.
           ALV_LINE-BACKWEEK = LINEOBJ-BACKWEEK.
           PERFORM. GET_WEEKNO USING LINEOBJ-PERXX.
           PERFORM. FILL_DBFIELD USING RESULTWEEK LINEOBJ-PLNMG.
           PERFORM. MODIFY_DATA USING RESULTWEEK.
         ENDIF.
       ENDLOOP.
    ENDIF.
 ENDDO.
*
 SELECT PBIM~MATNR PBIM~WERKS
        PBED~PLNMG PBED~MEINS
        PBED~PDATU PBED~PERXX
        FROM PBIM  INNER JOIN PBED
        ON PBIM~BDZEI = PBED~BDZEI
        INTO CORRESPONDING FIELDS OF TABLE FCST
        WHERE PBIM~WERKS = XWERKS AND PBIM~LOEVR <> 'D'
        AND   PBED~PLNMG <> 0 AND MATNR IN DB_MATNR.
LOOP AT FCST into fcstline.
     CLEAR LINEOBJ.
     FCSTLINE1-MATNR = FCSTLINE-MATNR.
     FCSTLINE1-WERKS = FCSTLINE-WERKS.
     FCSTLINE1-PLNMG = FCSTLINE-PLNMG.
     FCSTLINE1-MEINS = FCSTLINE-MEINS.
     IF FCSTLINE-PERXX = SPACE.
       CALL FUNCTION 'DATE_GET_WEEK'
       EXPORTING
            DATE         = FCSTLINE-PDATU
       IMPORTING
            WEEK         = WEEK1
       EXCEPTIONS
            DATE_INVALID = 1.
      FCSTLINE1-PERXX = WEEK1.
     ELSE.
      FCSTLINE1-PERXX = FCSTLINE-PERXX.
     ENDIF.
      FCSTLINE1-BACKWEEK = WEEK.
    COLLECT FCSTLINE1 INTO FCST1.
endloop.
LOOP AT FCST1 INTO FCSTLINE1 WHERE PERXX >= START_WEEK AND PERXX <=
END_WEEK.
         CLEAR ALV_LINE.
         READ TABLE ALV_TAB  INTO ALV_LINE1 WITH KEY
         MATNR = FCSTLINE1-MATNR BACKWEEK = FCSTLINE1-BACKWEEK WERKS =
         FCSTLINE1-WERKS.
         CLEAR ALV_LINE1.
         IF SY-SUBRC <> 0.
           CLEAR ALV_LINE.
           ALV_LINE-MATNR = FCSTLINE1-MATNR.
           ALV_LINE-WERKS = FCSTLINE1-WERKS.
           ALV_LINE-BACKWEEK = FCSTLINE1-BACKWEEK.
           PERFORM. GET_WEEKNO USING FCSTLINE1-PERXX.
           PERFORM. FILL_DBFIELD USING RESULTWEEK FCSTLINE1-PLNMG.
           APPEND ALV_LINE TO ALV_TAB.
         ELSEIF SY-SUBRC = 0.
           CLEAR ALV_LINE.
           ALV_LINE-MATNR = FCSTLINE1-MATNR.
           ALV_LINE-WERKS = FCSTLINE1-WERKS.
           ALV_LINE-BACKWEEK = FCSTLINE1-BACKWEEK.
           PERFORM. GET_WEEKNO USING FCSTLINE1-PERXX.
           PERFORM. FILL_DBFIELD USING RESULTWEEK FCSTLINE1-PLNMG.
           PERFORM. MODIFY_DATA USING RESULTWEEK.
         ENDIF.
ENDLOOP.
ENDFORM.

FORM. MODIFY_DATA USING RESULTNO.
           CASE RESULTNO.
                WHEN 'WEEK01'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK01.
                WHEN 'WEEK02'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK02.
                WHEN 'WEEK03'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK03.
                WHEN 'WEEK04'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK04.
                WHEN 'WEEK05'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK05.
                WHEN 'WEEK06'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK06.
                WHEN 'WEEK07'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK07.
                WHEN 'WEEK08'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK08.
                WHEN 'WEEK09'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK09.
                WHEN 'WEEK10'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK10.
                WHEN 'WEEK11'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK11.
                WHEN 'WEEK12'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK12.
                WHEN 'WEEK13'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK13.
                WHEN 'WEEK14'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK14.
                WHEN 'WEEK15'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK15.
                WHEN 'WEEK16'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK16.
                WHEN 'WEEK17'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK17.
                WHEN 'WEEK18'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK18.
                WHEN 'WEEK19'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK19.
                WHEN 'WEEK20'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK20.
                WHEN 'WEEK21'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK21.
                WHEN 'WEEK22'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK22.
                WHEN 'WEEK23'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK23.
                WHEN 'WEEK24'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK24.
                WHEN 'WEEK25'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK25.
                WHEN 'WEEK26'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK26.
                WHEN 'WEEK27'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK27.
                WHEN 'WEEK28'.
                MODIFY TABLE ALV_TAB FROM ALV_LINE TRANSPORTING WEEK28.
           ENDCASE.
ENDFORM.

form. fill_dbfield using pl_dbfield pl_qty.
  NUM_STRING = pl_qty.
  if pl_qty = 0. NUM_STRING = ''. endif.
  case pl_dbfield.
    when 'WEEK01'. alv_line-week01 = NUM_STRING.
    when 'WEEK02'. alv_line-week02 = NUM_STRING.
    when 'WEEK03'. alv_line-week03 = NUM_STRING.
    when 'WEEK04'. alv_line-week04 = NUM_STRING.
    when 'WEEK05'. alv_line-week05 = NUM_STRING.
    when 'WEEK06'. alv_line-week06 = NUM_STRING.
    when 'WEEK07'. alv_line-week07 = NUM_STRING.
    when 'WEEK08'. alv_line-week08 = NUM_STRING.
    when 'WEEK09'. alv_line-week09 = NUM_STRING.
    when 'WEEK10'. alv_line-week10 = NUM_STRING.
    when 'WEEK11'. alv_line-week11 = NUM_STRING.
    when 'WEEK12'. alv_line-week12 = NUM_STRING.
    when 'WEEK13'. alv_line-week13 = NUM_STRING.
    when 'WEEK14'. alv_line-week14 = NUM_STRING.
    when 'WEEK15'. alv_line-week15 = NUM_STRING.
    when 'WEEK16'. alv_line-week16 = NUM_STRING.
    when 'WEEK17'. alv_line-week17 = NUM_STRING.
    when 'WEEK18'. alv_line-week18 = NUM_STRING.
    when 'WEEK19'. alv_line-week19 = NUM_STRING.
    when 'WEEK20'. alv_line-week20 = NUM_STRING.
    when 'WEEK21'. alv_line-week21 = NUM_STRING.
    when 'WEEK22'. alv_line-week22 = NUM_STRING.
    when 'WEEK23'. alv_line-week23 = NUM_STRING.
    when 'WEEK24'. alv_line-week24 = NUM_STRING.
    when 'WEEK25'. alv_line-week25 = NUM_STRING.
    when 'WEEK26'. alv_line-week26 = NUM_STRING.
    when 'WEEK27'. alv_line-week27 = NUM_STRING.
    when 'WEEK28'. alv_line-week28 = NUM_STRING.
  endcase.
endform.

FORM. GET_WEEK USING T_DATE TYPE SY-DATUM
              CHANGING TEMP_WEEK LIKE SCAL-WEEK.
  CALL FUNCTION 'DATE_GET_WEEK'
       EXPORTING
            DATE         = T_DATE
       IMPORTING
            WEEK         = TEMP_WEEK
       EXCEPTIONS
            DATE_INVALID = 1.
ENDFORM.

FORM. GET_WEEKNO USING TEMP_WEEK1.
DATA:i_a(2) type n.
    clear resultweek.
    i_a = ( temp_week1 - start_week ) + 1.
    CONCATENATE 'WEEK' i_a into resultweek.
ENDFORM.

*********************************************************
* Display data by Alv function.
*********************************************************
form. display_alv.
  data: repid like sy-repid.
  repid = sy-repid.
  SORT ALV_TAB BY MATNR WERKS BACKWEEK.
  call function 'REUSE_ALV_GRID_DISPLAY'
  exporting
    i_interface_check                 = ''
    i_callback_program                = repid
    it_fieldcat                       = ITAB_FIELDCAT
    i_default                         = 'X'
    i_save                            = 'A'
   tables
     t_outtab                          = ALV_TAB
  exceptions
    program_error                     = 1
    others                            = 2 .
endform.

********************************************************
* set Alv report header text
*********************************************************
form. get_params.
  data: l_title(6) type c,
        l_title_d like sy-datum,
        l_week(2) type n,
        l_dbfield(6) type c,
        i_times(2) type n.

  ITAB_FIELD-ref_tabname = 'ZPP003'.
  ITAB_field-fieldname = 'WERKS'.
  ITAB_field-REPTEXT_DDIC = 'Plant'.
  ITAB_field-col_pos = sy-tabix.
  ITAB_field-just = 'C'.
  append ITAB_field TO ITAB_FIELDCAT.

  ITAB_FIELD-ref_tabname = 'ZPP003'.
  ITAB_field-fieldname = 'MATNR'.
  ITAB_field-REPTEXT_DDIC = 'Material'.
  ITAB_field-col_pos = sy-tabix.
  ITAB_field-just = 'C'.
  append ITAB_field TO ITAB_FIELDCAT.

  ITAB_FIELD-ref_tabname = 'ZPP003'.
  ITAB_field-fieldname = 'BACKWEEK'.
  ITAB_field-REPTEXT_DDIC = 'PERIOD'.
  ITAB_field-col_pos = sy-tabix.
  ITAB_field-just = 'C'.
  append ITAB_field TO ITAB_FIELDCAT.

  l_week = 1.
  i_times = b_week + f_week + 1.
  do i_times times.
    concatenate 'WEEK' l_week into l_dbfield.
    l_title_d = START_DATE + ( l_week - 1 ) * 7.
    PERFORM. GET_WEEK USING l_title_d
                     CHANGING TEMPWEEK.
    l_title = tempweek.
    ITAB_FIELD-ref_tabname = 'ZPP003'.
    ITAB_field-fieldname = l_dbfield.
    ITAB_field-REPTEXT_DDIC = l_title.
    ITAB_field-col_pos = sy-tabix.
    ITAB_field-just = 'C'.
    append ITAB_field TO ITAB_FIELDCAT.
    l_week = l_week + 1.
  enddo.
endform.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15117617/viewspace-551899/,如需转载,请注明出处,否则将追究法律责任。

上一篇: MPS报表
下一篇: Water fall备份数据
请登录后发表评论 登录
全部评论

注册时间:2008-10-31

  • 博文量
    52
  • 访问量
    50102