此博客为原创博客,都是个人工作经历所得,转载请注明出处

YTST_CX_0001(ALV栏位汇总)

***********************************************************************
* Title           : X                           *
* Application     : X                          *
* Subject         : X                           *
* Requested by    : X                           *
* Execution       : X                           *
* Ref no:         : X                           *
* Author          : X                           *
* Req Date        : X                           *
***********************************************************************
*                 设计主要逻辑与原理说明                          *
***********************************************************************
* 1.XXX            *
*   XXX            *
*   XXX            *
*                                                                     *
***********************************************************************
* MODIFICATIONS (latest entry at the top)                             *
* ------------------------------------------------------------------- *
* REL  DATE    NAME (COMPANY)   DESCRIPTION               TASK-NO     *
* ---  ----    ---- ---------     -----------             -------     *
* *
***********************************************************************
REPORT  YTST_CX_0001 NO STANDARD PAGE HEADING
                     LINE-COUNT 65
                     LINE-SIZE 135
                     MESSAGE-ID YTCX_01.


*----------------------------------------------------------------------
*                          TYPE-POOLS
*----------------------------------------------------------------------
TYPE-POOLSSLIS.   "ALV
*----------------------------------------------------------------------
*                          TABLES/Structure
*----------------------------------------------------------------------
TABLESMARA,
        MBEW.

*----------------------------------------------------------------------
*                          TYPES
*----------------------------------------------------------------------
TYPES:BEGIN OF T_ITAB,
      MATNR LIKE MARA-MATNR,
      ERSDA LIKE MARA-ERSDA,
      MATKL LIKE MARA-MATKL,
      LBKUM LIKE MBEW-LBKUM,
      SALK3 LIKE MBEW-SALK3,
     END OF T_ITAB.

*----------------------------------------------------------------------
*                          Internal table
*----------------------------------------------------------------------
DATA:ITAB TYPE TABLE OF T_ITAB WITH HEADER LINE.
DATA:G_LEN TYPE I.

*======================================================================
*                          SELECTION-SCREEN
*======================================================================
SELECTION-SCREEN BEGIN OF BLOCK BLOK WITH FRAME TITLE TXT1.
SELECT-OPTIONSMATNR FOR MARA-MATNR.

SELECTION-SCREEN END OF BLOCK BLOK.



*----------------------------------------------------------------------
*  INITIALIZATION
*----------------------------------------------------------------------
INITIALIZATION.

  TXT1 '请输入选择条件'.

*&G1 初始化数据
  PERFORM FRM_INITIAL.

*----------------------------------------------------------------------
*  AT SELECTION-SCREEN
*----------------------------------------------------------------------
AT SELECTION-SCREEN.

*G2 权限检查部分
  PERFORM FRM_CHECK_AUTHOR.


*======================================================================
*                          MAIN PROGRAM
*======================================================================
*  START-OF-SELECTION
*----------------------------------------------------------------------
START-OF-SELECTION.
*&G3 获取数据
  PERFORM FRM_GET_DATA.
*&G4 ALV展示输出
  PERFORM FRM_ALV_OUTPUT.

*======================================================================
*  END-OF-SELECTION
*----------------------------------------------------------------------
END-OF-SELECTION.
**&G3 获取数据
*  PERFORM FRM_GET_DATA.
**&G4 ALV展示输出
*  PERFORM FRM_ALV_OUTPUT.

TOP-OF-PAGE.

END-OF-PAGE.



*&---------------------------------------------------------------------*
*&      Form  FRM_INITIAL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_INITIAL .

ENDFORM.                    " FRM_INITIAL

*&---------------------------------------------------------------------*
*&      Form  FRM_CHECK_AUTHOR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CHECK_AUTHOR .

ENDFORM.                    " FRM_CHECK_AUTHOR

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .

  SELECT MARA~MATNR
         MARA~ERSDA
         MARA~MATKL
         MBEW~LBKUM
         MBEW~SALK3
    INTO TABLE ITAB
    FROM MARA
    JOIN MBEW ON MARA~MATNR MBEW~MATNR AND MBEW~BWKEY '1000' )
   WHERE MARA~MATNR IN MATNR
   ORDER BY MARA~MATNR.

  DESCRIBE TABLE ITAB LINES G_LEN.
  IF G_LEN EQ 0.
    MESSAGE E000 WITH '没有找到符合条件的数据!'.
  ELSE.
    MESSAGE S002 WITH '找到符合条件数据' G_LEN '条!'.
  ENDIF.



ENDFORM.                    " FRM_GET_DATA

*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_ALV_OUTPUT .
DATA:IT_FIELDCAT     TYPE SLIS_T_FIELDCAT_ALV,
     IS_VARIANT      LIKE DISVARIANT,
     IT_EVENTS       TYPE SLIS_T_EVENT,
     IS_LAYOUT       TYPE SLIS_LAYOUT_ALV,"ALV的格式
     I_LIST_COMMENTS TYPE SLIS_T_LISTHEADER,
     I_CALLBACK_PROGRAM TYPE SY-REPID,
     TITLE              TYPE LVC_TITLE,
     IT_SORT            TYPE SLIS_T_SORTINFO_ALV.

  PERFORM FIELDCAT_INIT USING IT_FIELDCAT."输出列表控件表头
* PERFORM layout_init USING is_layout.
* PERFORM eventtab_build USING it_events.
  PERFORM E02_LAYOUT_SORT_BUILD CHANGING IT_SORT.

  I_CALLBACK_PROGRAM SY-REPID.
  TITLE '测试'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM I_CALLBACK_PROGRAM
      I_GRID_TITLE       TITLE
      IS_LAYOUT          IS_LAYOUT
      IT_FIELDCAT        IT_FIELDCAT
      IT_EVENTS          IT_EVENTS
      IT_SORT            IT_SORT[]
    TABLES
      T_OUTTAB           ITAB
    EXCEPTIONS
      PROGRAM_ERROR      1
      OTHERS             2.
  IF SY-SUBRC <> 0.
  ENDIF.

ENDFORM.                    " FRM_ALV_OUTPUT



*&---------------------------------------------------------------------*
*&      Form  FIELDCAT_INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM FIELDCAT_INIT USING IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
  DATALS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

  LS_FIELDCAT-FIELDNAME    'MATNR'.
  LS_FIELDCAT-REPTEXT_DDIC '物料号'.
  LS_FIELDCAT-NO_ZERO      'X'.
  APPEND LS_FIELDCAT TO IT_FIELDCAT.
  CLEAR LS_FIELDCAT.

  LS_FIELDCAT-FIELDNAME    'ERSDA'.
  LS_FIELDCAT-REPTEXT_DDIC '创建日期'.
  APPEND LS_FIELDCAT TO IT_FIELDCAT.
  CLEAR LS_FIELDCAT.

  LS_FIELDCAT-FIELDNAME    'MATKL'.
  LS_FIELDCAT-REPTEXT_DDIC '物料组'.
  APPEND LS_FIELDCAT TO IT_FIELDCAT.
  CLEAR LS_FIELDCAT.

  LS_FIELDCAT-FIELDNAME    'LBKUM'.
  LS_FIELDCAT-REPTEXT_DDIC '总评估的库存'.
  LS_FIELDCAT-DO_SUM       'X'.
  APPEND LS_FIELDCAT TO IT_FIELDCAT.
  CLEAR LS_FIELDCAT.

  LS_FIELDCAT-FIELDNAME    'SALK3'.
  LS_FIELDCAT-REPTEXT_DDIC '估价的总库存价值'.
  LS_FIELDCAT-DO_SUM 'X'.
  APPEND LS_FIELDCAT TO IT_FIELDCAT.
  CLEAR LS_FIELDCAT.

ENDFORM" fieldcat_init


*&---------------------------------------------------------------------*
*&      Form  E02_LAYOUT_SORT_BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_IT_SORT  text
*----------------------------------------------------------------------*
FORM E02_LAYOUT_SORT_BUILD CHANGING LT_SORT TYPE SLIS_T_SORTINFO_ALV.
  DATA LS_SORT TYPE SLIS_SORTINFO_ALV.

  CLEAR LS_SORT.
  LS_SORT-FIELDNAME 'ERSDA'.                              "#EC *
  LS_SORT-SPOS 1.
  LS_SORT-UP 'X'.
  LS_SORT-SUBTOT 'X'.
  APPEND LS_SORT TO LT_SORT.

  CLEAR LS_SORT.
  LS_SORT-FIELDNAME 'MATKL'.                              "#EC *
  LS_SORT-SPOS 1.
  LS_SORT-UP 'X'.
  LS_SORT-SUBTOT 'X'.
  APPEND LS_SORT TO LT_SORT.

ENDFORM" e02_layout_sort_build

posted @ 2014-03-10 15:04  Rainystuday  阅读(388)  评论(0编辑  收藏  举报