ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Enhancement: 更改生产定单的日志

Enhancement: 更改生产定单的日志

原创 Linux操作系统 作者:ytfsrs2008 时间:2009-04-03 03:00:57 0 删除 编辑
* --------  Log Work Order Change
        CALL FUNCTION 'ZFPP_WO_LOG'
             TABLES
                  header_table        = header_table
                  header_table_old    = header_table_old
                  component_table     = component_table
                  component_table_old = component_table.
*---------------------------


FUNCTION ZFPP_WO_LOG.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  TABLES
*"      HEADER_TABLE STRUCTURE  CAUFVDB
*"      HEADER_TABLE_OLD STRUCTURE  CAUFVDB
*"      COMPONENT_TABLE STRUCTURE  RESBB
*"      COMPONENT_TABLE_OLD STRUCTURE  RESBB
*"----------------------------------------------------------------------
*&---------------------------------------------------------------------*
*&  ??              ZXCO1U01                                         *
*&---------------------------------------------------------------------*
TABLES:caufv,resb,zpp013.
DATA: BEGIN OF old_resb  OCCURS 0,  "RESB.
        aufnr LIKE resb-aufnr,
        posnr LIKE resb-posnr,
        matnr LIKE resb-matnr,
        rsnum LIKE resb-rsnum,
        rspos LIKE resb-rspos,
        xloek LIKE resb-xloek,
        bdmng LIKE resb-bdmng,
        objnr LIKE resb-objnr,
        END OF old_resb.

DATA: BEGIN OF new_resb OCCURS 0.  "RESB.
       INCLUDE STRUCTURE old_resb.
DATA: END OF new_resb.
DATA: BEGIN OF obj_resb OCCURS 0.  "RESB
       INCLUDE STRUCTURE old_resb.
DATA: END OF obj_resb.

DATA: i_zpp013 LIKE zpp013 OCCURS 0 WITH HEADER LINE.
DATA: i_temp   LIKE zpp013 OCCURS 0 WITH HEADER LINE.

DATA: iporg LIKE msxxlist-hostadr,
     ipdec(16) TYPE c,
     host(18)  TYPE c.
DATA: char1(20) TYPE c,
     char2(20) TYPE c.

DATA: inst_flg TYPE c value 'N',
     chan_had TYPE c value 'N'.

*BREAK-POINT.

CHECK sy-tcode  EQ 'CO02'.
**  Get user IP,hostname
CALL FUNCTION 'TH_USER_INFO'    " Get user IP,hostname
 IMPORTING
   hostaddr = iporg
   terminal = host
 EXCEPTIONS
   OTHERS   = 1.
**"Conv.IP addr to format 'xxx.xxx.xxx.xxx'
CALL FUNCTION 'ZWY_IPADR2STRING'  "Conv.IP addr
 EXPORTING
   ipadr   = iporg
 IMPORTING
   string  = ipdec.
***Common var.
MOVE: sy-mandt TO i_temp-mandt,
     sy-uname TO i_temp-aenam,
     sy-datum TO i_temp-laeda,
     sy-uzeit TO i_temp-times,
     sy-tcode TO i_temp-tcode,
        ipdec TO i_temp-hostip,
         host TO i_temp-host,
         header_table-aufnr TO i_temp-aufnr.

SELECT SINGLE gamng gltrp INTO (caufv-gamng, caufv-gltrp)
        FROM caufv WHERE aufnr EQ header_table-aufnr.
**qty
IF header_table-gamng NE caufv-gamng.
 MOVE: caufv-gamng TO char1, header_table-gamng TO char2.
 MOVE-CORRESPONDING i_temp TO i_zpp013.
 MOVE: 'Change Total Qty' TO i_zpp013-filed,
       'U'            TO i_zpp013-chnid,
       char1          TO i_zpp013-value_old,
       char2          TO i_zpp013-value_new.
 APPEND i_zpp013.
 inst_flg = 'Y'.
 chan_had = 'Y'.
ENDIF.
**date
IF header_table-gltrp NE caufv-gltrp.
 MOVE-CORRESPONDING i_temp TO i_zpp013.
 MOVE: 'Change Fin Date' TO i_zpp013-filed,
       'U'        TO i_zpp013-chnid,
       caufv-gltrp        TO i_zpp013-value_old,
       header_table-gltrp TO i_zpp013-value_new.
 APPEND i_zpp013.
 inst_flg = 'Y'.
ENDIF.

IF inst_flg = 'Y'.
 INSERT zpp013 FROM TABLE i_zpp013 ACCEPTING DUPLICATE KEYS.
 inst_flg = 'N'.
ENDIF.
*DELETE component_table WHERE vbkz EQ 'I'.
LOOP AT component_table WHERE vbkz EQ 'U'
                          OR vbkz EQ 'I'
                          OR vbkz EQ 'D'.
 CASE component_table-vbkz.
   WHEN 'I'.
    IF HEADER_TABLE-FLG_MD = 0.
       MOVE-CORRESPONDING i_temp TO i_zpp013.
       MOVE: 'ADD' TO i_zpp013-filed,
             'I'        TO i_zpp013-chnid,
             ''         TO i_zpp013-value_old, "old_resb-matnr
            component_table-matnr TO i_zpp013-value_new,
           'New Component'   TO i_zpp013-matnr.
            APPEND i_zpp013.
            inst_flg = 'Y'.
    ELSEIF component_table-ch_proc = '1'.
       MOVE-CORRESPONDING i_temp TO i_zpp013.
       MOVE: 'Update' TO i_zpp013-filed,
             'U'        TO i_zpp013-chnid,
             ''         TO i_zpp013-value_old, "old_resb-matnr
            component_table-matnr TO i_zpp013-value_new,
            component_table-matnr   TO i_zpp013-matnr.
       APPEND i_zpp013.
       inst_flg = 'Y'.
    ENDIF.

   WHEN 'D'.
     IF HEADER_TABLE-FLG_MD = 0.
       MOVE-CORRESPONDING i_temp TO i_zpp013.
       MOVE: 'DEL' TO i_zpp013-filed,
             'D'        TO i_zpp013-chnid,
             resb-xloek TO i_zpp013-value_old,
              component_table-xloek TO i_zpp013-value_new,
              component_table-matnr TO i_zpp013-matnr.
        APPEND i_zpp013.
       inst_flg = 'Y'.
     ENDIF.

   WHEN 'U'.
     SELECT SINGLE matnr bdmng INTO  (resb-matnr, resb-bdmng)
              FROM resb  WHERE aufnr EQ component_table-aufnr
                           AND posnr EQ component_table-posnr
                           AND rsnum EQ component_table-rsnum
                           AND rspos EQ component_table-rspos.
     IF sy-subrc = 0.
      IF component_table-matnr NE resb-matnr.
        MOVE-CORRESPONDING i_temp TO i_zpp013.
        MOVE: 'UPDATE' TO i_zpp013-filed,
              'U'        TO i_zpp013-chnid,
              resb-matnr TO i_zpp013-value_old,
              component_table-matnr TO i_zpp013-value_new,
              'Changed Component' TO i_zpp013-matnr.
        APPEND i_zpp013.
        inst_flg = 'Y'.

       ELSEIF component_table-bdmng NE resb-bdmng.
          CHECK chan_had NE 'Y' OR component_table-ch_proc = '1'.
          MOVE: component_table-bdmng TO char1, resb-bdmng TO char2.
          MOVE-CORRESPONDING i_temp TO i_zpp013.
          MOVE: 'Requiremnet Qty' TO i_zpp013-filed,
                'U'   TO i_zpp013-chnid,
                char2 TO i_zpp013-value_old,
                char1 TO i_zpp013-value_new,
               component_table-matnr TO i_zpp013-matnr.
           APPEND i_zpp013.
           inst_flg = 'Y'.

        ENDIF.
     ELSE.
         MOVE-CORRESPONDING i_temp TO i_zpp013.
         MOVE: 'Re-Read Update' TO i_zpp013-filed,
               'U'        TO i_zpp013-chnid,
               component_table-matnr TO i_zpp013-value_old,
               component_table-matnr TO i_zpp013-value_new,
               'Changed Component Or Qty' TO i_zpp013-matnr.
         APPEND i_zpp013.
         inst_flg = 'Y'.

     ENDIF.
 ENDCASE.
ENDLOOP.

IF inst_flg = 'Y'.
 INSERT zpp013 FROM TABLE i_zpp013 ACCEPTING DUPLICATE KEYS.
 IF sy-subrc EQ 0.
   inst_flg = 'N'.
   chan_had = 'N'.
 ENDIF.
ENDIF.

ENDFUNCTION.

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

请登录后发表评论 登录
全部评论

注册时间:2008-10-31

  • 博文量
    52
  • 访问量
    50791