销售分析报表

REPORT  ZSDR020.

INCLUDE ZSDR020TOP.

TABLES: ZRLB_H,ZRLB_I,KNA1,/ATU/STOREMASTER,MARA,knvv.

DATA: ls_data_out type ZSXSFX,
      lt_data_out like TABLE OF ZSXSFX WITH HEADER LINE,
      lt_data_sum like TABLE OF ZSXSFX WITH HEADER LINE,
      lt_data_tmp like TABLE OF ZSXSFX WITH HEADER LINE.

FIELD-SYMBOLS : <dyn_table> TYPE table,
                <dyn_wa> TYPE ANY,
                <dyn_field> TYPE ANY.

DATA lt_tmp LIKE TABLE OF ZSXSFX WITH HEADER LINE.

DATA:BEGIN OF T_STORE OCCURS 0,
          KUNNR LIKE KNA1-KUNNR,
          NAME1 LIKE KNA1-NAME1,
      END OF T_STORE.
DATA:LT_STORE LIKE TABLE OF T_STORE WITH HEADER LINE.

INCLUDE ZSDR020SCR.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_BUDAT FOR ZRLB_H-BUDAT DEFAULT sy-datum TO sy-datum,  "营业日期
                S_3ADCCU FOR KNA1-J_3ADCCU NO INTERVALS,
                s_KUNNR FOR KNA1-KUNNR NO INTERVALS,
                s_KTYPE FOR /ATU/STOREMASTER-/ATU/STORETYPE NO INTERVALS,
                s_KATR2 FOR KNA1-KATR2 NO INTERVALS,
                s_BRSCH FOR KNA1-BRSCH NO INTERVALS,
                s_SPART for MARA-SPART NO INTERVALS,
                s_EXTWG for MARA-EXTWG NO INTERVALS,
                s_MATNR for MARA-MATNR no INTERVALS,
                s_SIZE for ZRLB_I-J_3ASIZE no INTERVALS,
                s_ZMATNR for ZRLB_I-ZMATNR no INTERVALS,
                s_vkgrp for knvv-vkgrp NO INTERVALS,
                s_UDATE FOR ZRLB_H-UDATE.   "上传日期
SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
PARAMETERS: p_3ADCCU AS CHECKBOX DEFAULT ‘X‘,     "总店
            p_kunnr AS CHECKBOX DEFAULT ‘X‘,     "子店
            p_type AS CHECKBOX ,     "门店类型
            p_KATR2 AS CHECKBOX ,     "
            p_vkgrp    AS CHECKBOX DEFAULT ‘X‘,
            p_zmatnr AS CHECKBOX DEFAULT ‘X‘,     "大货
            p_matnr AS CHECKBOX,     "小货
            p_PRDHA AS CHECKBOX DEFAULT ‘X‘,     "产品层次
            p_PRDHB AS CHECKBOX,     "大类
            "p_MATKL AS CHECKBOX,     "物料组
            p_budat AS CHECKBOX,                 "营业日期
            p_SPART    AS CHECKBOX,
            p_EXTWG    AS CHECKBOX,
            p_SDABW    AS CHECKBOX,
            p_FORMT    AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK blk2.

SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
PARAMETERS: p_qty RADIOBUTTON GROUP a DEFAULT ‘X‘,
            p_val1 RADIOBUTTON GROUP a,
            p_val2 RADIOBUTTON GROUP a.
SELECTION-SCREEN END OF BLOCK blk3.

START-OF-SELECTION.
  PERFORM FRM_GET_DATA.
  PERFORM FRM_SHOW_ALV.

INCLUDE ZSDR020O01.

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

  SET PF-STATUS ‘1100‘.

ENDFORM.

INCLUDE ZSDR020I01.

FORM user_command USING r_ucomm LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.
  CASE r_ucomm.
    WHEN ‘ZRB‘.
      "日报
      PERFORM frm_process USING ‘正在进行日报格式处理,请稍候……‘.
      PERFORM FRM_SET_DATA_SUM USING ‘RB‘.
      PERFORM FRM_create_date_table.
      PERFORM frm_filled_date_table.
      PERFORM FRM_SHOW_SUM_ALV.

    WHEN ‘ZXB‘.
      "旬报
      PERFORM frm_process USING ‘正在进行旬报格式处理,请稍候……‘.
      PERFORM FRM_SET_DATA_SUM USING ‘XB‘.
      PERFORM FRM_create_date_table.
      PERFORM frm_filled_date_table.
      PERFORM FRM_SHOW_SUM_ALV.

    WHEN ‘ZYB‘.
      "月报
      PERFORM frm_process USING ‘正在进行月报格式处理,请稍候……‘.
      PERFORM FRM_SET_DATA_SUM USING ‘YB‘.
      PERFORM FRM_create_date_table.
      PERFORM frm_filled_date_table.
      PERFORM FRM_SHOW_SUM_ALV.

    WHEN ‘ZJB‘.
      "季报
      PERFORM frm_process USING ‘正在进行季报格式处理,请稍候……‘.
      PERFORM FRM_SET_DATA_SUM USING ‘JB‘.
      PERFORM FRM_create_date_table.
      PERFORM frm_filled_date_table.
      PERFORM FRM_SHOW_SUM_ALV.

    WHEN ‘ZNB‘.
      "年报
      PERFORM frm_process USING ‘正在进行年报格式处理,请稍候……‘.
      PERFORM FRM_SET_DATA_SUM USING ‘NB‘.
      PERFORM FRM_create_date_table.
      PERFORM frm_filled_date_table.
      PERFORM FRM_SHOW_SUM_ALV.

  ENDCASE.

ENDFORM.

INCLUDE ZSDR020F01.

FORM FRM_GET_DATA.

  DATA: LT_RLB LIKE TABLE OF ZSRLB WITH HEADER LINE.

  CALL FUNCTION ‘ZSD_POS_GET_RLB_LIST‘
    EXPORTING
      IV_MODE         = ‘A‘
      IV_SHOWPROPERTY = ‘X‘
    TABLES
      IT_BUDAT        = S_BUDAT
      IT_3ADCCU       = S_3ADCCU
      IT_KUNNR        = S_KUNNR
      IT_MATNR        = S_MATNR
      IT_ZMATNR       = S_ZMATNR
      IT_UDATE        = S_UDATE
      IT_BRSCH        = S_BRSCH
      IT_SPART        = S_SPART
      IT_EXTWG        = S_EXTWG
      IT_KTYPE        = S_KTYPE
      IT_VKGRP        = S_VKGRP
      ET_DATA         = LT_RLB.

  PERFORM FRM_SET_DATA TABLES LT_RLB.

ENDFORM.                    "FRM_GET_DATA

*&---------------------------------------------------------------------*
*&      Form  FRM_SET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->LT_DATA    text
*----------------------------------------------------------------------*
FORM FRM_SET_DATA TABLES LT_DATA STRUCTURE ZSRLB.
  DATA: LT_KUNNR LIKE TABLE OF ZSKUNNR2 WITH HEADER LINE.

  DATA: BEGIN OF LT_VKGRP OCCURS 0,
          KUNNR LIKE /ATU/STOREMASTER-/ATU/STORE_ID,
          NAME1 LIKE KNA1-NAME1,
          VKGRP LIKE KNVV-VKGRP,
          BEZEI LIKE TVGRT-BEZEI,
          KATR2 LIKE KNA1-KATR2,
          KATR2TXT LIKE TVK2T-VTEXT,
        END OF LT_VKGRP.

  DATA:LV_TABIX LIKE SY-TABIX.
  DATA: LV_STR1(20) type C,
        LV_STR2(20) type C,
        LV_STR3(20) type C.

  CLEAR: LT_STORE,LT_STORE[].

  LOOP AT LT_DATA.
    CLEAR LT_KUNNR.
    LT_KUNNR-KUNNR = LT_DATA-KUNNR.
    APPEND LT_KUNNR.
  ENDLOOP.

  SORT LT_KUNNR BY KUNNR.
  DELETE ADJACENT DUPLICATES FROM LT_KUNNR COMPARING KUNNR.

  IF LT_KUNNR[] IS NOT INITIAL.

    SELECT A~/ATU/STORE_ID B~NAME1 V~VKGRP K~BEZEI B~KATR2 K2~VTEXT
      FROM /ATU/STOREMASTER AS A
      INNER JOIN KNA1 AS B ON B~KUNNR = A~KUNNR
      INNER JOIN KNVV AS V ON A~/ATU/STORE_ID = V~KUNNR
      AND A~VKORG = V~VKORG AND A~VTWEG = V~VTWEG AND A~SPART = V~SPART
      INNER JOIN TVGRT AS K ON V~VKGRP = K~VKGRP AND K~SPRAS EQ ‘1‘
      INNER JOIN TVK2T AS K2 ON B~KATR2 = K2~KATR2 AND K2~SPRAS EQ ‘1‘
      INTO TABLE LT_VKGRP
      FOR ALL ENTRIES IN LT_KUNNR
      WHERE A~/ATU/STORE_ID = LT_KUNNR-KUNNR.

    SORT LT_VKGRP BY KUNNR.

  ENDIF.

  LOOP AT LT_DATA.
    CLEAR: ls_data_out.

    MOVE-CORRESPONDING LT_DATA to ls_data_out.

    READ TABLE LT_VKGRP WITH KEY KUNNR = ls_data_out-KUNNR BINARY SEARCH.
    IF SY-SUBRC = 0.
      ls_data_out-NAME1    = LT_VKGRP-NAME1.
      ls_data_out-VKGRP    = LT_VKGRP-VKGRP.
      ls_data_out-VKGRPTXT = LT_VKGRP-BEZEI.
      ls_data_out-KATR2    = LT_VKGRP-KATR2.
      ls_data_out-KATR2TXT = LT_VKGRP-KATR2TXT.
    ENDIF.

    if p_PRDHB eq ‘X‘.
      SEARCH ls_data_out-PRDHATXT FOR ‘_‘.
      if sy-subrc = 0.
        SPLIT ls_data_out-PRDHATXT AT ‘_‘ INTO LV_STR1 LV_STR2 LV_STR3.
        ls_data_out-PRDHBTXT   = LV_STR3.
      else.
        ls_data_out-PRDHBTXT   = ls_data_out-PRDHATXT.
      endif.
    endif.

    IF P_3ADCCU EQ ‘X‘.
      LT_STORE-KUNNR    = ls_data_out-J_3ADCCU.
      COLLECT LT_STORE.
    ENDIF.

    IF P_3ADCCU NE ‘X‘.
      clear ls_data_out-J_3ADCCU.
    ENDIF.

    IF P_KUNNR NE ‘X‘.
      clear: ls_data_out-KUNNR,
             ls_data_out-NAME1.
    ENDIF.

    if p_vkgrp NE ‘X‘.
      clear: ls_data_out-VKGRP,
             ls_data_out-VKGRPTXT.
    endif.

    IF p_KATR2 NE ‘X‘.
      clear: ls_data_out-KATR2,
             ls_data_out-KATR2TXT.
    ENDIF.

    IF P_TYPE NE ‘X‘.
      clear: ls_data_out-STORETYPE.
    ENDIF.

    IF P_ZMATNR NE ‘X‘.
      clear: ls_data_out-ZMATNR,
             ls_data_out-J_3ASIZE.
    ENDIF.

    IF P_MATNR NE ‘X‘.
      clear: ls_data_out-MATNR.
    ENDIF.

    IF P_PRDHA NE ‘X‘.
      clear: ls_data_out-PRDHA,
             ls_data_out-PRDHATXT.
    ENDIF.

    IF P_SPART NE ‘X‘.
      clear: ls_data_out-SPART,
             ls_data_out-SPARTTXT.
    ENDIF.

    IF P_EXTWG NE ‘X‘.
      clear: ls_data_out-EXTWG,
             ls_data_out-EXTWGTXT.
    ENDIF.

    IF P_SDABW NE ‘X‘.
      clear: ls_data_out-SDABW.
    ENDIF.

    IF P_FORMT NE ‘X‘.
      clear: ls_data_out-FORMT.
    ENDIF.

    "为日报准备的内表
    clear LT_DATA_TMP.
    LT_DATA_TMP = ls_data_out.
    COLLECT LT_DATA_TMP.

    IF P_BUDAT NE ‘X‘.
      clear: ls_data_out-BUDAT.
    ENDIF.

    "销售分析输出的内表
    COLLECT ls_data_out into lt_data_out.

  ENDLOOP.

  IF LINES( LT_STORE ) > 0.

    SELECT KUNNR NAME1 INTO TABLE LT_STORE
      FROM KNA1
      FOR ALL ENTRIES IN LT_STORE
    WHERE KUNNR = LT_STORE-KUNNR.

    SORT LT_STORE by KUNNR.

    LOOP AT LT_STORE.
      LV_TABIX = SY-TABIX.
      LT_DATA_OUT-ZD_NAME1 = LT_STORE-NAME1.
      MODIFY LT_DATA_OUT TRANSPORTING ZD_NAME1 WHERE J_3ADCCU = LT_STORE-KUNNR.
    ENDLOOP.

  ENDIF.
ENDFORM.                    "FRM_SET_DATA

*&---------------------------------------------------------------------*
*&      Form  FRM_SHOW_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FRM_SHOW_ALV.
  DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
        LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
        LS_LAYOUT TYPE SLIS_LAYOUT_ALV.

  SET TITLEBAR ‘1100‘ WITH s_BUDAT-low s_BUDAT-high s_matnr-low s_kunnr-low.

  CLEAR LS_LAYOUT.
  LS_LAYOUT-EDIT              = ‘‘.
  LS_LAYOUT-EDIT_MODE         = SPACE.
  LS_LAYOUT-ZEBRA             = ‘X‘.
  LS_LAYOUT-COLWIDTH_OPTIMIZE = ‘‘.

  DEFINE ADD_FIELD.
    CLEAR: LS_FIELDCAT.
    LS_FIELDCAT-FIELDNAME    = &1.
    LS_FIELDCAT-REPTEXT_DDIC = &2.
    LS_FIELDCAT-INTLEN       = &3.
    LS_FIELDCAT-DO_SUM       = &4.
    LS_FIELDCAT-NO_ZERO      = &5.
    LS_FIELDCAT-KEY          = &6.
    LS_FIELDCAT-FIX_COLUMN   = &7.
    LS_FIELDCAT-NO_OUT       = &8.
    APPEND LS_FIELDCAT TO IT_FIELDCAT.
  END-OF-DEFINITION.

  IF P_3ADCCU EQ ‘X‘.
    ADD_FIELD ‘J_3ADCCU‘ ‘总店‘     10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ADD_FIELD ‘ZD_NAME1‘ ‘总店名称‘ 20 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_KUNNR EQ ‘X‘.
    ADD_FIELD ‘KUNNR‘ ‘门店编号‘ 10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ADD_FIELD ‘NAME1‘ ‘门店名称‘ 20 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.

  ENDIF.

  if p_vkgrp eq ‘X‘.
    ADD_FIELD ‘VKGRPTXT‘ ‘主管‘ 10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  endif.

  IF P_TYPE EQ ‘X‘.
    ADD_FIELD ‘STORETYPE‘ ‘门店类型‘ 8 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_KATR2 EQ ‘X‘.
    "ADD_FIELD ‘KATR2‘ ‘店铺类型‘ 8 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ADD_FIELD ‘KATR2TXT‘ ‘店铺类型‘ 8 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_BUDAT EQ ‘X‘.
    ADD_FIELD ‘BUDAT‘ ‘营业日期‘ 10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_PRDHA EQ ‘X‘.
    ADD_FIELD ‘PRDHA‘ ‘产品层次‘ 10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ADD_FIELD ‘PRDHATXT‘ ‘产品层次描述‘ 10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  if p_PRDHB eq ‘X‘.
    ADD_FIELD ‘PRDHBTXT‘ ‘商品大类‘ 10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_SPART EQ ‘X‘.
    ADD_FIELD ‘SPART‘ ‘品牌‘ 10 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ADD_FIELD ‘SPARTTXT‘ ‘品牌描述‘ 18 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_EXTWG EQ ‘X‘.
    ADD_FIELD ‘EXTWG‘ ‘系列‘ 8 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ADD_FIELD ‘EXTWGTXT‘ ‘系列描述‘ 18 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_FORMT EQ ‘X‘.
    ADD_FIELD ‘FORMT‘ ‘货品高新标识‘ 8 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_SDABW EQ ‘X‘.
    ADD_FIELD ‘SDABW‘ ‘库存类别‘ 8 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_ZMATNR EQ ‘X‘.
    ADD_FIELD ‘ZMATNR‘ ‘小货号‘ 18 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  IF P_MATNR EQ ‘X‘.
    ADD_FIELD ‘MATNR‘ ‘大货号‘ 18 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ENDIF.

  ADD_FIELD ‘QTY‘ ‘数量‘ 10 ‘X‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ADD_FIELD ‘RVAL‘ ‘吊牌金额‘ 10 ‘X‘ ‘‘ ‘‘ ‘‘ ‘‘.
  ADD_FIELD ‘VAL‘ ‘折后金额‘ 10 ‘X‘ ‘‘ ‘‘ ‘‘ ‘‘.

  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID
      IT_FIELDCAT        = IT_FIELDCAT[]
      IS_LAYOUT          = LS_LAYOUT
      i_callback_pf_status_set = ‘SET_PF_STATUS‘
      i_callback_user_command  = ‘USER_COMMAND‘
      I_SAVE             = ‘A‘
    TABLES
      T_OUTTAB           = LT_DATA_OUT.

  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    "FRM_SHOW_ALV

FORM frm_process USING p_info .
  CALL FUNCTION ‘SAPGUI_PROGRESS_INDICATOR‘
    EXPORTING
      percentage = 100
      text       = p_info
    EXCEPTIONS
      OTHERS     = 1.
ENDFORM.

INCLUDE ZSDR020F02.   "日报,旬报,月报,季报,年报

ENDFORM.

FORM frm_filled_date_table.
  DATA fieldname(20).

  LOOP AT lt_data_sum.
    CLEAR <dyn_wa>.

    ASSIGN COMPONENT ‘J_3ADCCU‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-J_3ADCCU.
    ASSIGN COMPONENT ‘ZD_NAME1‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-ZD_NAME1.
    ASSIGN COMPONENT ‘KUNNR‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-KUNNR.
    ASSIGN COMPONENT ‘NAME1‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-NAME1.
    ASSIGN COMPONENT ‘STORETYPE‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-STORETYPE.
    ASSIGN COMPONENT ‘BUDAT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-BUDAT.
    ASSIGN COMPONENT ‘PRDHA‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-PRDHA.
    ASSIGN COMPONENT ‘SPART‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-SPART.
    ASSIGN COMPONENT ‘EXTWG‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-EXTWG.
    ASSIGN COMPONENT ‘FORMT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-FORMT.
    ASSIGN COMPONENT ‘SPARTTXT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-SPARTTXT.

    ASSIGN COMPONENT ‘EXTWGTXT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-EXTWGTXT.
    ASSIGN COMPONENT ‘PRDHATXT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-PRDHATXT.
    ASSIGN COMPONENT ‘PRDHBTXT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-PRDHBTXT.
    ASSIGN COMPONENT ‘VKGRP‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-VKGRP.
    ASSIGN COMPONENT ‘VKGRPTXT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-VKGRPTXT.
    ASSIGN COMPONENT ‘SDABW‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-SDABW.
    ASSIGN COMPONENT ‘ZMATNR‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-ZMATNR.
    ASSIGN COMPONENT ‘MATNR‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-MATNR.
    ASSIGN COMPONENT ‘J_3ASIZE‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-J_3ASIZE.
    ASSIGN COMPONENT ‘KATR2‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-KATR2.
    ASSIGN COMPONENT ‘KATR2TXT‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
    <dyn_field> = lt_data_sum-KATR2TXT.

    if p_qty eq ‘X‘.
      ASSIGN COMPONENT lt_data_sum-statdate OF STRUCTURE <dyn_wa> TO <dyn_field>.
      <dyn_field> = lt_data_sum-qty.
      ASSIGN COMPONENT ‘SUMALL‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
      <dyn_field> = lt_data_sum-qty.
    elseif p_val1 eq ‘X‘.
      ASSIGN COMPONENT lt_data_sum-statdate OF STRUCTURE <dyn_wa> TO <dyn_field>.
      <dyn_field> = lt_data_sum-RVAL.
      ASSIGN COMPONENT ‘SUMALL‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
      <dyn_field> = lt_data_sum-RVAL.
    elseif p_val2 eq ‘X‘.
      ASSIGN COMPONENT lt_data_sum-statdate OF STRUCTURE <dyn_wa> TO <dyn_field>.
      <dyn_field> = lt_data_sum-VAL.
      ASSIGN COMPONENT ‘SUMALL‘ OF STRUCTURE <dyn_wa> TO <dyn_field>.
      <dyn_field> = lt_data_sum-VAL.
    endif.

    COLLECT <dyn_wa> into <dyn_table>.

  ENDLOOP.

ENDFORM.

FORM FRM_SHOW_SUM_ALV.
  DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
        LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
        LS_LAYOUT TYPE SLIS_LAYOUT_ALV.

  CLEAR LS_LAYOUT.
  LS_LAYOUT-EDIT              = ‘‘.
  LS_LAYOUT-EDIT_MODE         = SPACE.
  LS_LAYOUT-ZEBRA             = ‘X‘.
  LS_LAYOUT-COLWIDTH_OPTIMIZE = ‘‘.

  DEFINE ADD_FIELD.
    CLEAR: LS_FIELDCAT.
    LS_FIELDCAT-FIELDNAME    = &1.
    LS_FIELDCAT-REPTEXT_DDIC = &2.
    LS_FIELDCAT-INTLEN       = &3.
    LS_FIELDCAT-DO_SUM       = &4.
    LS_FIELDCAT-NO_ZERO      = &5.
    LS_FIELDCAT-KEY          = &6.
    LS_FIELDCAT-FIX_COLUMN   = &7.
    LS_FIELDCAT-NO_OUT       = &8.
    APPEND LS_FIELDCAT TO IT_FIELDCAT.
  END-OF-DEFINITION.

  IF P_3ADCCU EQ ‘X‘.
    ADD_FIELD ‘J_3ADCCU‘ ‘总店‘     10 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
    ADD_FIELD ‘ZD_NAME1‘ ‘总店名称‘ 20 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_KUNNR EQ ‘X‘.
    ADD_FIELD ‘KUNNR‘ ‘门店编号‘ 10 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
    ADD_FIELD ‘NAME1‘ ‘门店名称‘ 20 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.

  ENDIF.

  if p_vkgrp eq ‘X‘.
    ADD_FIELD ‘VKGRPTXT‘ ‘主管‘ 10 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  endif.

  IF P_TYPE EQ ‘X‘.
    ADD_FIELD ‘STORETYPE‘ ‘门店类型‘ 8 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_KATR2 EQ ‘X‘.
    "ADD_FIELD ‘KATR2‘ ‘店铺类型‘ 8 ‘‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ADD_FIELD ‘KATR2TXT‘ ‘店铺类型‘ 8 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_PRDHA EQ ‘X‘.
    ADD_FIELD ‘PRDHA‘ ‘产品层次‘ 10 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
    ADD_FIELD ‘PRDHATXT‘ ‘产品层次描述‘ 10 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_PRDHB EQ ‘X‘.
    ADD_FIELD ‘PRDHBTXT‘ ‘商品大类‘ 10 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_SPART EQ ‘X‘.
    ADD_FIELD ‘SPART‘ ‘品牌‘ 10 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
    ADD_FIELD ‘SPARTTXT‘ ‘品牌描述‘ 18 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_EXTWG EQ ‘X‘.
    ADD_FIELD ‘EXTWG‘ ‘系列‘ 8 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
    ADD_FIELD ‘EXTWGTXT‘ ‘系列描述‘ 18 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_FORMT EQ ‘X‘.
    ADD_FIELD ‘FORMT‘ ‘货品高新标识‘ 8 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_SDABW EQ ‘X‘.
    ADD_FIELD ‘SDABW‘ ‘库存类别‘ 8 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_ZMATNR EQ ‘X‘.
    ADD_FIELD ‘ZMATNR‘ ‘小货号‘ 18 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  IF P_MATNR EQ ‘X‘.
    ADD_FIELD ‘MATNR‘ ‘大货号‘ 18 ‘‘ ‘‘ ‘‘ ‘X‘ ‘‘.
  ENDIF.

  if lt_tmp[] is not INITIAL.
    LOOP AT lt_tmp.
      add_field lt_tmp-statdate lt_tmp-statdatetxt 10 ‘X‘ ‘‘ ‘‘ ‘‘ ‘‘.
    ENDLOOP.
    add_field ‘SUMALL‘ ‘汇总‘ 10 ‘X‘ ‘‘ ‘‘ ‘‘ ‘‘.
  endif.

  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID
      IT_FIELDCAT        = IT_FIELDCAT[]
      IS_LAYOUT          = LS_LAYOUT
      I_SAVE             = ‘A‘
    TABLES
      T_OUTTAB           = <dyn_table>.

  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.
时间: 2024-10-27 07:44:24

销售分析报表的相关文章

奥威Power-BI连锁商超BI报表分析——“品牌销售分析”

作为连锁商超BI软件的销售分析类报表,“品牌销售分析”需要将各门店的销售情况及趋势等关键指标数据进行直观展示,下面小编将简单的介绍一下奥威连锁商超BI软件Power-BI的品牌销售分析报表:       (1)左上方通过饼图展示公司当前月份各门店销售占比情况,各门店的销售业绩情况一目了然:       (2)左下方则通过三个条形比例图展示商品类型.消费人群的占比情况,可快速了解商品大品类对应的消费人群:       (3)右侧则通过上下两个柱形图,展示各个门店的销售情况及毛利情况以及门店近12个

奥威服装数据分析软件Power-BI 之销售分析总览

在进行服装数据分析与监测时我们总会希望可以快速全面地了解到情况,奥威服装行业数据分析软件Power-BI 的销售分析总览驾驶舱就是起了这样的一个作用,使我们可以从多个不同的方面同时关注多个不同的指标.销售分析总览展示了当期销售的关键KPI指标:销售收入.毛利.毛利率.销售SKU.连带率.客单价等.并以周为周期展示了全年的销售趋势,以品类展示了商品的连带率,展示了各区域的门店的坪效人效.报表默认展示了当月的情况,通过时间筛选,我们可以变更默认的时间,查看看历史月份的数据.当我们在这个总览的报表发现

润乾集算报表优化应用结构之报表复杂数据源的管理

在报表项目中,常常有些复杂数据计算是为一个报表专用的,其它报表用不到.可以用SQL实现写进报表数据源中,但由于SQL无法分步计算,经常会写出非常复杂难懂的长语句,不利于调试和维护.如果用Java或者存储过程来实现,计算程序会和报表模板又会分开,不利于管理.使用润乾集算报表的脚本数据集来实现报表专用计算,既可以写出简单易懂的分步骤计算脚本,又可以将脚本存放在报表模板中利于管理.系统结构的对比如下图: 下面通过一个具体的报表例子来看一下集算报表脚本数据集的用法.<年度客户销售分析报表>可以选择年份

实现报表与算法的统一管理

在报表项目中,常常有些复杂的数据计算是一个报表专门使用的,其它报表用不到.通常,此类计算可以在报表数据源中用 SQL 实现,不过由于 SQL 无法分步计算,需要写非常复杂难懂的长语句,不利于调试和维护,因此也会使用 Java 或者存储过程来实现.但这样一来,计算程序又会和报表模板分开,不利于组织管理. 使用润乾报表的脚本数据集(结合集算器实现)来实现报表专用计算,是解决上述困境的一个有效手段,一方面既可以写出简单易懂的分步计算脚本,另一方面又可以将脚本和报表模板一起存放,利于管理. 这两种方式的

E2 2014.6.3 更新日志

增加功能 增加支持中关村获取商品信息 增加个人业绩查询功能 增加赠送和获赠查询功能 增加商品历程分析报表,资金历程分析报表,科目明细分析报表, 销售分析报表 增加服务维修明细表查询报表 完善功能 固定资产登记后,允许管理员可以删除 修件库查询,增加按维修商和客户名称查询条件,并增加快速设置维修件为已取件按钮 坏件处理窗口增加可以补打坏件标签功能. 客户信息增加客户所属业务员快速设置 服务价格表,增加分类刷新功能. 客户信息增加批量修改客户分类 客商对帐,明细增加合计 发票管理添加可以添加发票功能

永拓智造家具ERP分析进销存

****我国现在的家具企业大多数为中小企业,转化生产程度低.资源浪费严重,实行的多为家族式.经验式管理.家具行业以中小企业为多,专业化生产和信息化管理程度较低.由于小型私营家具企业占多数,管理粗放,实行的多为家族式.经验式管理.国内家具小型生产企业太多,浪费资源.管理是企业内部的重要环节,企业的兴衰体现在管理质量上多数家具生产厂家在生产管理.销售管理.库存管理.进货管理.工资管理和财务管理等环节上,没有相应的管理制度及措施.因此企业上家具ERP系统是一个必然的趋势,但是在选择ERP系统要符合自身

《奥威Power-BI基于MySQL数据源制作报表》腾讯课程开课啦

前阵子奥威公开课讲过基于oracle数据源制作报表,有些宝宝就有小情绪了:简直就是不把我MySQL放在眼里嘛!oracle和MySQL一直以来被大家对比了很多次,同属于 Oracle 旗下产品,本是同根生,相煎何太急?这oracle和MySQL各有千秋,有着不同的侧重点和各自的小成就.为了我们的MySQL铁粉们,奥威软件决定这次就来讲一讲MySQL咯! 讲师介绍:李显斯 多年的甲方.乙方工作经验,熟悉企业的业务流程,主要从事数据库.BI开发,对ETL.数据仓库技术有着丰富的经验. 直播时间:20

综合性皮具企业报表系统解决方案书

1.皮具行业 IT 系统现状 在传统的皮具行业,小手工业管理.家族式管理是其主要的管理模式,这些模式在企业创业初期确实起到了成本低.掉头快.团结一致向前进的作用.随着互联网 IT 的兴起和皮具行业不断的向前发展,产业规模链不断扩大,面对国内外日益加大的竞争压力和开拓市场的需求,信息化管理成为目前行业内各企业不可或缺的一环. 于是我们看到了这种现象,皮具企业内部不断的上线各种各样的信息系统,今天上OA,明天上ERP,后天上CRM.随着时间的增长,企业内部的信息系统不断增加,流程复杂程 度越来越高,

BI就是报表?

实际上,报表只是BI的一部分,虽然BI应用的结果通常需要通过报表来展示,但是,BI绝对不仅仅是报表.其实,大家对这些概念的理解,如同15年前的ERP一样.1998年,国内两大巨头金蝶与用友都开始宣称从财务软件进入ERP领域,于是,ERP才逐渐为世人所知,ERP到底是什么,大家开始众说纷纭.财务+进销存就是ERP?没有MRP的ERP不叫ERP?显然,国外ERP厂商与国内ERP厂商对大众理解ERP的引导是不一样的.过程曲曲折折,我们不说也罢,现在我们只总结一下15年后的今天,大家对ERP的理解还有偏