Chinaunix首页 | 论坛 | 博客
  • 博客访问: 85461
  • 博文数量: 26
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 302
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-10 10:04
文章分类
文章存档

2011年(2)

2010年(24)

我的朋友

分类:

2010-11-29 09:57:25

*&---------------------------------------------------------------------*
*&  Date/Author:2009/12/03 IT001
*&  TCODE : ZPP11y
*&  Report   : Z_MIC_PP_033
*&---------------------------------------------------------------
* & MODIFICATION LOG : 程式修改更新記錄
*&---------------------------------------------------------------
*& ChangeDate   Programmer    Request               Description
*& ========== ============= ============ ===
*     2009/03/25  IT04                MRPK903685      增加郵件發送,郵件地址選擇功能
*     00010             700       MRPK903672            2009.03.24 13:58:57 IT04
*     00009             700       MRPK903594            2009.03.16 14:07:01 IT04
*     00008             700       MRPK903463            2009.03.09 13:52:50 IT04
*     00007             700       MRPK903461            2009.03.09 11:30:20 IT04
*     00006             700       MRPK903247            2009.02.26 13:42:03 IT04
*     00005             700       MRPK903242            2009.02.26 10:33:04 IT04
*     00004             700       MRPK903232            2009.02.25 15:06:48 IT04
*     00003             700       MRPK903230            2009.02.25 14:12:27 IT04
*     00002             700       MRPK903226            2009.02.25 11:00:58 IT04
*     00001  S          700                             2009.02.25 10:52:19 IT04
*&---------------------------------------------------------------------*
*&  外發生產進度報表
*&
*&---------------------------------------------------------------------*

REPORT  Z_MIC_PP_033 NO STANDARD PAGE HEADING .
TABLES : EKKO , EKPO , EKET ,ZMICMAILLIST .
TYPE-POOLS : ABAP .
type-pools : slis .
data : fieldcats type slis_t_fieldcat_alv ,
       layout type slis_layout_alv .
*   MAIN DATA FOR PO .
data : BEGIN OF M1 ,
  VENDOR TYPE LIFNR ,
  PO TYPE EBELN ,
  LINE TYPE EBELP ,
  SO TYPE VBELN,
  ITEM TYPE POSNR ,
  MATERIAL TYPE MATNR ,
  DESC  TYPE CHAR40,
  QTY TYPE BSTMG ,
  UOM TYPE BSTME ,
  REQDT TYPE EINDT ,
  QT101 TYPE MENGE_D,
  QS101 TYPE MENGE_D ,
  QS161 TYPE MENGE_D ,
  RECQ  TYPE MENGE_D , "FACT RECIVE QTY
  SHIP  TYPE MENGE_D ,
  COMPONET  TYPE MATNR ,
  COMPREQ TYPE MENGE_D ,
  PUOM    TYPE MEINS ,
  QTSEND TYPE MENGE_D ,
  QSSEND TYPE MENGE_D ,
  QSRETURN TYPE MENGE_D ,
  SSHIP TYPE MENGE_D ,
  QVEND TYPE MENGE_D ,
  INFODESC TYPE STRING ,
  MBDOC TYPE MBLnr ,
  END OF M1 .
DATA : STRZ TYPE STRING , STR_INDEX TYPE I , DESC(30) TYPE C .
  STRZ = '供應商 ;采購訂單;  項目;銷售訂單;訂單項目;物料號碼;物料描述;采購數量;采購單位;需求日期;當日送貨;累計送貨;累計退貨;實際送貨;尚欠數量;元件料號;' .
  CONCATENATE STRZ '元件需求;需求單位;當日發料;累計發料;累計退料;元件尚欠;供應商存;采購內文;物料文件' INTO STRZ .

DATA BEGIN OF ITAB OCCURS 0 .
INCLUDE STRUCTURE M1 .
DATA END OF ITAB .
DATA WA LIKE TABLE OF ITAB .
DATA TMP_QTY TYPE MENGE_D .
*  HISTORY FOR PO RECIVE .
DATA : BEGIN OF M3 ,
  QTY TYPE MENGE_D ,
  CLA TYPE SHKZG ,
  DOC TYPE MBLNR ,
  END OF M3 .
DATA CLATAB LIKE M3 OCCURS 0 WITH HEADER LINE .
DATA : BEGIN OF M4 ,
  QTY TYPE MENGE_D ,
  UOM TYPE MEINS ,
  CLA TYPE SHKZG ,
  END OF M4 .
DATA MVTTAB LIKE M4 OCCURS 0 WITH HEADER LINE .

include z_mic_email_dec .
include z_mic_email_fun .
*
*     choice email
**********************************************************************
DATA  OK_CODE LIKE SY-UCOMM .
DATA:
  CONTAINER_0100 TYPE SCRFNAME VALUE 'MAIL_ITEM',
  ALV_GRID_0100 TYPE REF TO CL_GUI_ALV_GRID,
  CUSTOM_CONTAINER_0100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
  S_LAYOUT_0100 TYPE LVC_S_LAYO,
  T_CATALOG_0100 TYPE LVC_T_FCAT.
DATA : BEGIN OF MAILITEM ,
  MAILADR TYPE CHAR40,
  BOX TYPE C ,
  END OF MAILITEM ,
  MAILTAB LIKE MAILITEM OCCURS 0 WITH HEADER LINE .
DATA : TMP_MAIL TYPE CHAR40 .

*
*       input terms .
**********************************************************************
  SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
    SELECT-OPTIONS : PUR FOR EKKO-EBELN ,
                     VEN FOR EKKO-LIFNR ,
                     MAT FOR EKPO-MATNR .
    SELECTION-SCREEN SKIP 1 .
    PARAMETERS :    VDT LIKE SY-DATUM  DEFAULT  SY-DATUM  ,
                    PLANT LIKE WERKS-WERKS DEFAULT '5000' .
    SELECTION-SCREEN SKIP 1 .
    PARAMETERS :    FX AS CHECKBOX DEFAULT 'X' ,
                                   ALV RADIOBUTTON GROUP M1 DEFAULT 'X' ,
                                   MAIL RADIOBUTTON GROUP M1 .
        SELECTION-SCREEN BEGIN OF BLOCK B2  WITH FRAME TITLE  text-002.
       PARAMETERs :  SUBJECT TYPE STRING .
    SELECT-OPTIONS  EMAIL FOR ZMICMAILLIST-MAILADR .
     SELECTION-SCREEN END OF BLOCK B2 .
 SELECTION-SCREEN END OF BLOCK B1 .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR EMAIL-LOW .
  PERFORM GET_MAIL .

 START-OF-SELECTION .
IF MAIL = 'X' .
  VDT = SY-DATUM - 1 .
ENDIF .
 PERFORM QUERY_DATA .
IF ALV = 'X' .
 PERFORM SHOW_DATA .
ELSE .
  LOOP AT  EMAIL .
    maillist-email = email-low .
    APPEND maillist .
  ENDLOOP.
  IF MAILLIST[] IS NOT INITIAL .
    PERFORM SEND_MAIL TABLES WA USING SUBJECT STRZ  .
  ELSE .
    MESSAGE E001(00) WITH '沒有選擇任何的郵件地址!' .
  ENDIF .
ENDIF .

*&---------------------------------------------------------------------*
*&      Form  QUERY_DATA
*&---------------------------------------------------------------------*
*       QUERY DATA .
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM QUERY_DATA .
*  MAIN BDOY
IF FX = 'X' .
SELECT EKKO~LIFNR EKPO~EBELN EKPO~EBELP EKKN~VBELN EKKN~VBELP  EKPO~MATNR EKPO~TXZ01  EKPO~MENGE EKPO~MEINS
  INTO TABLE ITAB
  FROM EKKO INNER JOIN EKPO ON EKKO~EBELN EQ EKPO~EBELN
  LEFT JOIN EKKN ON EKPO~EBELN = EKKN~EBELN AND EKPO~EBELP = EKKN~EBELP
  WHERE EKKO~LIFNR IN VEN
  AND EKKO~EBELN IN PUR
  AND EKPO~MATNR IN MAT
  AND EKPO~WERKS EQ PLANT
  AND EKPO~PSTYP EQ '3'
  AND EKPO~ELIKZ EQ SPACE
  AND EKPO~LOEKZ EQ  SPACE
  .
ELSE .
SELECT EKKO~LIFNR EKPO~EBELN EKPO~EBELP EKKN~VBELN EKKN~VBELP EKPO~MATNR EKPO~TXZ01 EKPO~MENGE EKPO~MEINS
  INTO TABLE ITAB
  FROM EKKO INNER JOIN EKPO ON EKKO~EBELN EQ EKPO~EBELN
  LEFT JOIN EKKN ON EKPO~EBELN = EKKN~EBELN AND EKPO~EBELP = EKKN~EBELP
  WHERE EKKO~LIFNR IN VEN
  AND EKKO~EBELN IN PUR
  AND EKPO~MATNR IN MAT
  AND EKPO~WERKS EQ PLANT
  AND EKPO~PSTYP EQ '3'
  AND EKPO~LOEKZ EQ  SPACE
  .
ENDIF .
*  RECIVE AND REQUERS .
  LOOP AT ITAB .
    REPLACE ALL OCCURRENCES OF '"' IN ITAB-DESC WITH '.' .
    PERFORM GET_TXT(Z_MIC_PP_011Y_1108)  USING ITAB-PO ITAB-LINE ITAB-MATERIAL PLANT CHANGING ITAB-INFODESC .
    REPLACE ALL OCCURRENCES OF '"' IN ITAB-INFODESC WITH '.' .
*    REQUEST DATE .
    SELECT SINGLE EINDT INTO ITAB-REQDT
      FROM EKET
      WHERE EBELN = ITAB-PO
      AND   EBELP = ITAB-LINE .
*      TODAY RECIVE .
      CLEAR : CLATAB  , CLATAB[] .
      SELECT SUM( MENGE ) SHKZG
        INTO TABLE CLATAB
        FROM EKBE
        WHERE EBELN = ITAB-PO
        AND   EBELP = ITAB-LINE
        AND   ( BWART = '101' OR BWART = '102' OR BWART = '122' )
        AND   BUDAT = VDT
        GROUP BY SHKZG .
      LOOP AT CLATAB .
        CASE CLATAB-CLA.
          WHEN 'H'.
            ITAB-QT101 = ITAB-QT101 - CLATAB-QTY .
          WHEN 'S'.
            ITAB-QT101 = ITAB-QT101 + CLATAB-QTY .
        ENDCASE.
        CLEAR CLATAB .
     ENDLOOP .
*    TOTAL RECIVE .
      CLEAR : CLATAB  , CLATAB[] .
      SELECT SUM( MENGE ) SHKZG
        INTO TABLE CLATAB
        FROM EKBE
        WHERE EBELN = ITAB-PO
        AND   EBELP = ITAB-LINE
        AND   ( BWART = '101' OR BWART = '102' OR BWART = '122' )
        AND   BUDAT <= VDT
        GROUP BY SHKZG .
        LOOP AT CLATAB .
          CASE CLATAB-CLA.
            WHEN 'H'.
              ITAB-QS101 = ITAB-QS101 - CLATAB-QTY .
            WHEN 'S'.
              ITAB-QS101 = ITAB-QS101 + CLATAB-QTY .
          ENDCASE.
          CLEAR CLATAB .
        ENDLOOP .
*    TOTAL RETURN .
      CLEAR : CLATAB  , CLATAB[] .
      SELECT SUM( MENGE ) SHKZG
        INTO TABLE CLATAB
        FROM EKBE
        WHERE EBELN = ITAB-PO
        AND   EBELP = ITAB-LINE
        AND   ( BWART = '161' OR BWART = '162' )
        AND   BUDAT <= VDT
        GROUP BY SHKZG .
      LOOP AT CLATAB .
        CASE CLATAB-CLA.
          WHEN 'H'.
            ITAB-QS161 = ITAB-QS161 - CLATAB-QTY .
          WHEN 'S'.
            ITAB-QS161 = ITAB-QS161 + CLATAB-QTY .
        ENDCASE.
        CLEAR CLATAB .
     ENDLOOP .

*      FACT RECIVE .
      ITAB-RECQ = ITAB-QS101 - ITAB-QS161 .
*      BALAENCE .
      ITAB-SHIP = ITAB-QTY - ITAB-RECQ .
*      COMPOENT .
      SELECT MATNR BDMNG MEINS  INTO (ITAB-COMPONET , ITAB-COMPREQ , ITAB-PUOM )
        FROM RESB
        WHERE RSNUM IN ( SELECT RSNUM FROM EKET WHERE EBELN = ITAB-PO AND EBELP = ITAB-LINE )
        .
*      REQUEST
        CLEAR : CLATAB , CLATAB[] .
        SELECT SUM( ERFMG ) SHKZG MAX( MSEG~MBLNR ) AS DOC INTO TABLE CLATAB
          FROM MSEG INNER JOIN MKPF ON MSEG~MBLNR = MKPF~MBLNR
          WHERE MSEG~EBELN = ITAB-PO
          AND MSEG~EBELP = ITAB-LINE
          AND MSEG~MATNR = ITAB-COMPONET
          AND MSEG~XAUTO = 'X'
          AND ( BWART = '541' OR BWART = '542' OR BWART = 'Z11' OR BWART = 'Z12' )
          AND MKPF~BUDAT = VDT
          GROUP BY ERFME SHKZG .
          LOOP AT CLATAB .
            CASE CLATAB-CLA.
              WHEN 'H'.
                ITAB-QTSEND = ITAB-QTSEND - CLATAB-QTY .
              WHEN 'S'.
                ITAB-QTSEND = ITAB-QTSEND + CLATAB-QTY .
            ENDCASE.
            ITAB-MBDOC = CLATAB-DOC .
            CLEAR CLATAB .
          ENDLOOP.
          CLEAR : CLATAB , CLATAB[] .
              SELECT SUM( MSEG~ERFMG ) MSEG~SHKZG INTO TABLE CLATAB
                FROM MSEG INNER JOIN MKPF ON MSEG~MBLNR = MKPF~MBLNR
                WHERE MSEG~EBELN = ITAB-PO
                 AND MSEG~EBELP = ITAB-LINE
                AND MSEG~MATNR = ITAB-COMPONET
                AND MSEG~XAUTO = 'X'
                AND ( MSEG~BWART = '541' OR MSEG~BWART = '542' OR MSEG~BWART = 'Z11' OR MSEG~BWART = 'Z12' )
                AND MKPF~BUDAT <= VDT
                GROUP BY MSEG~SHKZG .
          LOOP AT CLATAB .
            CASE CLATAB-CLA.
              WHEN 'H'.
                ITAB-QSRETURN  = ITAB-QSRETURN + CLATAB-QTY .
              WHEN 'S'.
                ITAB-QSSEND = ITAB-QSSEND + CLATAB-QTY .
            ENDCASE.
            CLEAR CLATAB .
          ENDLOOP.
*          BALANCE
          ITAB-SSHIP = ITAB-COMPREQ - ITAB-QSSEND + ITAB-QSRETURN .
          IF ITAB-QTY > 0 .
          ITAB-QVEND = ITAB-QSSEND - ( ITAB-COMPREQ / ITAB-QTY ) * ITAB-RECQ - ITAB-QSRETURN  .
          ENDIF .
          IF FX = 'X'  .
            IF  ITAB-SHIP > 0 . APPEND ITAB TO WA . ENDIF .
          ELSE .
            APPEND ITAB TO WA .
         ENDIF .
          CLEAR : ITAB-QVEND , ITAB-SSHIP , ITAB-QTSEND , ITAB-COMPREQ ,ITAB-COMPONET , ITAB-QSRETURN , ITAB-QSSEND , ITAB-QTSEND .
      ENDSELECT .
      IF SY-SUBRC NE 0 .
          IF FX = 'X'  .
            IF  ITAB-SHIP > 0 . APPEND ITAB TO WA . ENDIF .
          ELSE .
            APPEND ITAB TO WA .
         ENDIF .
         CLEAR ITAB .
      ENDIF .
  ENDLOOP.
ENDFORM.                    " QUERY_DATA
*&---------------------------------------------------------------------*
*&      Form  SHOW_DATA
*&---------------------------------------------------------------------*
*       ALV PRINT DATA .
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SHOW_DATA .
DATA L_COUNT TYPE I .
FIELD-SYMBOLS: TYPE ABAP_COMPDESCR.
DATA DESCR_REF TYPE REF TO CL_ABAP_STRUCTDESCR.
DESCR_REF ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( M1 ).
LOOP AT DESCR_REF->COMPONENTS ASSIGNING .
  CLEAR DESC .
  L_COUNT = SY-TABIX .
  STR_INDEX = ( SY-TABIX - 1 ) * 5 .
  DESC = STRZ+STR_INDEX(4) .
  PERFORM ADD_FIELDS USING -NAME  DESC  L_COUNT .
  IF -NAME EQ 'DESC' . L_COUNT = L_COUNT + 1 . ENDIF .
ENDLOOP.
  LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM          = SY-CPROG
        IS_LAYOUT                   = LAYOUT
*        I_callback_pf_status_set    = 'SET_STATUS'
        I_DEFAULT                   = 'X'
        I_SAVE                      = 'X'
        I_CALLBACK_USER_COMMAND     = 'USER_COMMAND'
        IT_FIELDCAT                 = FIELDCATS[]
*        IT_EVENTS                   = WT_EVENTS
      TABLES
        T_OUTTAB                    = WA[] .
ENDFORM.                    " SHOW_DATA
*&---------------------------------------------------------------------*
*&      Form  GET_MVT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TYP  text
*      <--P_QX  text
*----------------------------------------------------------------------*
FORM GET_MVT  USING    TYP TYPE C
              CHANGING VALUE(QX).
  CLEAR : CLATAB  , CLATAB[] .
  CASE TYP.
    WHEN 'A'.
      SELECT SUM( BPMNG ) SHKZG
        INTO TABLE CLATAB
        FROM EKBE
        WHERE EBELN = ITAB-PO
        AND   EBELP = ITAB-LINE
*        AND   BWART IN MVTX
        AND   BUDAT <= VDT
        GROUP BY SHKZG .
    WHEN OTHERS.
      SELECT SUM( BPMNG ) SHKZG
        INTO TABLE CLATAB
        FROM EKBE
        WHERE EBELN = ITAB-PO
        AND   EBELP = ITAB-LINE
*        AND   BWART IN MVTX
        AND   BUDAT = VDT
        GROUP BY SHKZG .
  ENDCASE.
  LOOP AT CLATAB .
    CASE CLATAB-CLA.
      WHEN 'H'.
        QX = QX - CLATAB-QTY .
      WHEN 'S'.
        QX = QX + CLATAB-QTY .
    ENDCASE.
    CLEAR CLATAB .
  ENDLOOP .
ENDFORM.                    " GET_MVT
*&---------------------------------------------------------------------*
*&      Form  ADD_FIELDS
*&---------------------------------------------------------------------*
*      ADD ALV FIELDS .
*----------------------------------------------------------------------*
*      -->P__NAME  text
*----------------------------------------------------------------------*
FORM ADD_FIELDS  USING FIELDNAME DESC IX .
  DATA:  WLT_FIELDCAT LIKE LINE OF FIELDCATS.
  CLEAR WLT_FIELDCAT.
  WLT_FIELDCAT-COL_POS  =  IX .
  WLT_FIELDCAT-FIELDNAME    = FIELDNAME.
  WLT_FIELDCAT-NO_OUT       = ' '.
  WLT_FIELDCAT-NO_ZERO      = 'X'.
  WLT_FIELDCAT-SELTEXT_L    = DESC .
  IF FIELDNAME = 'INFODESC' . WLT_FIELDCAT-COL_POS  = 5 . ENDIF .
  IF FIELDNAME = 'PO'  OR FIELDNAME ='QS101' OR FIELDNAME = 'QS161' OR FIELDNAME = 'QSSEND' OR FIELDNAME = 'QSRETURN'  .
    WLT_FIELDCAT-hotspot = 'X' .
  ENDIF .
  APPEND WLT_FIELDCAT TO FIELDCATS.
ENDFORM.                    " ADD_FIELDS
 
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
  CASE UCOMM.
    WHEN '&IC1'.
      CLEAR : ITAB .
      CASE SELFIELD-SEL_TAB_FIELD.
        WHEN '1-PO' .
            READ TABLE WA INTO ITAB INDEX SELFIELD-TABINDEX.
            SET PARAMETER ID 'BES' FIELD ITAB-PO .
            SET PARAMETER ID 'BSP' FIELD ITAB-LINE  .
            CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN .
        WHEN '1-QS101' .
          READ TABLE WA INTO ITAB INDEX SELFIELD-TABINDEX.
          SET PARAMETER ID 'MAT' FIELD ITAB-MATERIAL .
          SET PARAMETER ID 'WRK' FIELD PLANT .
          SET PARAMETER ID 'LAG' FIELD SPACE .
          SET PARAMETER ID 'CHA' FIELD SPACE .
          SET PARAMETER ID 'LIF' FIELD ITAB-VENDOR .
          SET PARAMETER ID 'KUN' FIELD SPACE .
          SET PARAMETER ID 'BWA' FIELD '101' .
          CALL TRANSACTION 'MB51'  AND SKIP FIRST SCREEN .
        WHEN '1-QS161' .
          READ TABLE WA INTO ITAB INDEX SELFIELD-TABINDEX.
          SET PARAMETER ID 'MAT' FIELD ITAB-MATERIAL .
          SET PARAMETER ID 'WRK' FIELD PLANT .
          SET PARAMETER ID 'LAG' FIELD SPACE .
          SET PARAMETER ID 'CHA' FIELD SPACE .
          SET PARAMETER ID 'LIF' FIELD ITAB-VENDOR .
          SET PARAMETER ID 'KUN' FIELD SPACE .
          SET PARAMETER ID 'BWA' FIELD '161' .
          CALL TRANSACTION 'MB51'  AND SKIP FIRST SCREEN .
        WHEN '1-QSSEND' .
          READ TABLE WA INTO ITAB INDEX SELFIELD-TABINDEX.
          SET PARAMETER ID 'MAT' FIELD ITAB-COMPONET .
          SET PARAMETER ID 'WRK' FIELD PLANT .
          SET PARAMETER ID 'LAG' FIELD SPACE .
          SET PARAMETER ID 'CHA' FIELD SPACE .
          SET PARAMETER ID 'LIF' FIELD ITAB-VENDOR .
          SET PARAMETER ID 'KUN' FIELD SPACE .
          IF ITAB-COMPONET(1) = 'R' .
            SET PARAMETER ID 'BWA' FIELD '541' .
          ELSE .
            SET PARAMETER ID 'BWA' FIELD 'Z11' .
          ENDIF .
          CALL TRANSACTION 'MB51' AND SKIP FIRST SCREEN .
        WHEN '1-QSRETURN' .
          READ TABLE WA INTO ITAB INDEX SELFIELD-TABINDEX.
          SET PARAMETER ID 'MAT' FIELD ITAB-COMPONET .
          SET PARAMETER ID 'WRK' FIELD PLANT .
          SET PARAMETER ID 'LAG' FIELD SPACE .
          SET PARAMETER ID 'CHA' FIELD SPACE .
          SET PARAMETER ID 'LIF' FIELD ITAB-VENDOR .
          SET PARAMETER ID 'KUN' FIELD SPACE .
          IF ITAB-COMPONET(1) = 'R' .
            SET PARAMETER ID 'BWA' FIELD '542' .
          ELSE .
            SET PARAMETER ID 'BWA' FIELD 'Z12' .
          ENDIF .
          CALL TRANSACTION 'MB51' AND SKIP FIRST SCREEN .
       ENDCASE .
    WHEN OTHERS.
  ENDCASE.
ENDFORM .
*&---------------------------------------------------------------------*
*&      Form  GET_MAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_MAIL .
  CLEAR EMAIL[] .
  CALL SCREEN '2000' STARTING AT 10:5 .
ENDFORM.                    " GET_MAIL
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_2000 INPUT.
CASE OK_CODE .
  WHEN '&F12' .
    LEAVE TO SCREEN 0 .
  WHEN '&CAN' .
    LEAVE TO SCREEN 0 .
  WHEN '&CHO' .
    CLEAR TMP_MAIL .
    LOOP AT MAILTAB WHERE BOX = 'X' .
      IF TMP_MAIL IS INITIAL . TMP_MAIL = MAILTAB-MAILADR . ENDIF .
      EMAIL-LOW = MAILTAB-MAILADR .
      APPEND EMAIL .
      CLEAR EMAIL .
    ENDLOOP.
    EMAIL-LOW = TMP_MAIL .
    LEAVE TO SCREEN 0 .
ENDCASE .
ENDMODULE.                 " USER_COMMAND_2000  INPUT
*&---------------------------------------------------------------------*
*&      Module  STA2000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STA2000 OUTPUT.
    SET PF-STATUS 'STA_MAIL' .
  IF CUSTOM_CONTAINER_0100 IS INITIAL.
    CREATE OBJECT CUSTOM_CONTAINER_0100
      EXPORTING
        CONTAINER_NAME = CONTAINER_0100.
        PERFORM QUERY_MAIL .
    CREATE OBJECT ALV_GRID_0100
      EXPORTING
        I_PARENT = CUSTOM_CONTAINER_0100.
    PERFORM ADD_FIELD_MAIL .
    S_LAYOUT_0100-NO_TOOLBAR = 'X'.
  CALL METHOD  ALV_GRID_0100->REGISTER_EDIT_EVENT
    EXPORTING I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
    CALL METHOD ALV_GRID_0100->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        I_STRUCTURE_NAME     = 'MAILITEM'
        IS_LAYOUT            = S_LAYOUT_0100
      CHANGING
        IT_FIELDCATALOG      = T_CATALOG_0100
        IT_OUTTAB            =  MAILTAB[].
    ELSE .
      MAILTAB-BOX = SPACE .
      MODIFY MAILTAB TRANSPORTING BOX WHERE BOX = 'X' .
      CALL METHOD ALV_GRID_0100->REFRESH_TABLE_DISPLAY .
    ENDIF .
ENDMODULE.                 " STA2000  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  QUERY_MAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM QUERY_MAIL .
SELECT MAILADR FROM ZMICMAILLIST
  INTO TABLE MAILTAB
  WHERE MAILADR IN EMAIL .
ENDFORM.                    " QUERY_MAIL
*&---------------------------------------------------------------------*
*&      Form  ADD_FIELD_MAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ADD_FIELD_MAIL .
DATA: S_CATALOG TYPE LVC_S_FCAT.
  DATA: POS TYPE I VALUE 1.
  DATA: L_COUNT TYPE I.
  L_COUNT = 0.
  CLEAR S_CATALOG.
  L_COUNT = L_COUNT + 1.
  S_CATALOG-COL_POS   = L_COUNT.
  S_CATALOG-FIELDNAME = 'BOX'.
  S_CATALOG-SCRTEXT_S = '選擇'.
  S_CATALOG-OUTPUTLEN = '5'.
  S_CATALOG-KEY       = 'X' .
  S_CATALOG-EDIT      = 'X'.
  S_CATALOG-CHECKBOX  = 'X'.
  APPEND S_CATALOG TO T_CATALOG_0100.
    CLEAR S_CATALOG.
  L_COUNT = L_COUNT + 1.
  S_CATALOG-COL_POS   = L_COUNT.
  S_CATALOG-FIELDNAME = 'MAILADR'.
  S_CATALOG-SCRTEXT_S = '郵件地址'.
  S_CATALOG-OUTPUTLEN = '40'.
  APPEND S_CATALOG TO T_CATALOG_0100.
ENDFORM.                    " ADD_FIELD_MAIL
阅读(1683) | 评论(0) | 转发(0) |
0

上一篇:SAP增強

下一篇:SAP增强应用实例

给主人留下些什么吧!~~