自制收发料程序

原创 2013年12月03日 16:19:53
************************************************************************
* Program Title: 
*
* Created by:
*
* Description:
* Module name: 无
* Type: REPORT
* Special note: None
**----------------------------------------------------------------------
* Associated program: No programs are associated
*-----------------------------------------------------------------------
* Restriction:  No restriction
************************************************************************

************************************************************************

REPORT  ZPP_ISSUE NO STANDARD PAGE HEADING.

*----------------------------------------------------------------------*
* TABLE DECLARATION
*----------------------------------------------------------------------*
TYPE-POOLS:SLIS.
*INCLUDE <ICON>.
TYPE-POOLS VRM.
TABLES :
         SSCRFIELDS,
         MARA,
         ZZTPP_ZSTZ_HEAD,
         ZSCRAP,
         MKPF.

*&---------------------------------------------------------------------*
* STRUCTURE DECLARATION
*&---------------------------------------------------------------------*
TYPES :
      BEGIN OF T_SCRAP.
        INCLUDE STRUCTURE ZSCRAP.
TYPES : MAKTX TYPE MAKTX,
        AMOUNT TYPE ZLABST,
        NAME1 TYPE NAME1_GP,"供应商名称
        TEXT TYPE CHAR50,
        MARK TYPE C.
TYPES :END OF T_SCRAP.

*货币码F4帮助
TYPES : BEGIN OF T_TCURT,
          WAERS  TYPE WAERS_CURC ,
          LTEXT TYPE LTEXT,
          KTEXT  TYPE KTEXT_CURT,
        END OF T_TCURT.
*批次号F4帮助
TYPES : BEGIN OF T_CHARG,
          MATNR TYPE MATNR,
          MAKTX TYPE MAKTX,
          CHARG  TYPE CHARG_D,
          LABST  TYPE ZLABST,
        END OF T_CHARG.

* Type for Search help
TYPESBEGIN OF T_SHLP_MATNR,
        MATNR TYPE MATNR,
        MAKTX TYPE MAKTX,
        WERKS TYPE WERKS_D,
       END OF T_SHLP_MATNR.

TYPES:BEGIN OF TY_MESSAGE,
      MESSAGE(500TYPE C,
      END OF TY_MESSAGE.

*&---------------------------------------------------------------------*
* INTERNAL TABLE DECLARATION
*&---------------------------------------------------------------------*
DATA :
*物料号F4帮助
     I_SEARCH_M TYPE STANDARD TABLE OF  T_SHLP_MATNR,
*批次号F4帮助
      I_CHARG TYPE STANDARD TABLE OF  T_CHARG,
*货币代码F4帮助
      I_SEARCH TYPE STANDARD TABLE OF T_TCURT,
*确认收货
      I_RECEIVE TYPE STANDARD TABLE OF T_SCRAP,
*输入发货
      I_ISSUE TYPE STANDARD TABLE OF T_SCRAP,
*历史收货
      I_IN TYPE STANDARD TABLE OF T_SCRAP,
*历史售出
      I_OUT TYPE STANDARD TABLE OF T_SCRAP,
*历史余留
      I_LEFT TYPE STANDARD TABLE OF T_SCRAP,
*当前库存
      I_STOCK TYPE STANDARD TABLE OF T_SCRAP,
*冲销内表
      I_WF TYPE STANDARD TABLE OF T_SCRAP.

*&---------------------------------------------------------------------*
* WORK AREA DECLARATION
*&---------------------------------------------------------------------*
DATA :
*确认收货
      WA_RECEIVE TYPE T_SCRAP,
*输入发货
      WA_ISSUE TYPE T_SCRAP,

      WA_FCAT TYPE LVC_S_FCAT,

      WA_WF TYPE T_SCRAP.

**** Object variable for ALV Container
DATA:
   GV_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
   GV_CONTAINER2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
   GV_CONTAINER3 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
   GV_GRID1 TYPE REF TO CL_GUI_ALV_GRID,
   GV_GRID2 TYPE REF TO CL_GUI_ALV_GRID,
   GV_GRID3 TYPE REF TO CL_GUI_ALV_GRID,
   I_FCAT1 TYPE LVC_T_FCAT,
   I_FCAT2 TYPE LVC_T_FCAT,
   I_FCAT3 TYPE LVC_T_FCAT,
   I_SORT1 TYPE LVC_T_SORT,
   I_SORT2 TYPE LVC_T_SORT,
   I_SORT3 TYPE LVC_T_SORT,
   GV_LAYOUT1 TYPE LVC_S_LAYO,
   GV_LAYOUT2 TYPE LVC_S_LAYO,
   GV_LAYOUT3 TYPE LVC_S_LAYO.

**** ALV
DATA :
*ALV Fieldcat
      I_FIELDCATS TYPE SLIS_T_FIELDCAT_ALV,
*排序条件
      I_SORT TYPE SLIS_T_SORTINFO_ALV,
*Event
      I_EVENT TYPE SLIS_T_EVENT,
*ALV头信息
      I_TITLE TYPE SLIS_T_LISTHEADER,
*ALV布局
      GV_LAYOUT TYPE SLIS_LAYOUT_ALV,
*ALV头
      T_HEADER TYPE SLIS_T_LISTHEADER,
*ALV头工作区
      WA_HEADER TYPE SLIS_LISTHEADER.

*&---------------------------------------------------------------------*
* VARIANT DECLARATION
*&---------------------------------------------------------------------*
DATA :
      OK_CODE1 TYPE SY-UCOMM,
      OK_CODE2 TYPE SY-UCOMM,
      OK_CODE3 TYPE SY-UCOMM,
      OK_CODE4 TYPE SY-UCOMM,
      OK_CODE5 TYPE SY-UCOMM,
      OK_CODE6 TYPE SY-UCOMM,
      OK_CODE7 TYPE SY-UCOMM,
*选择屏幕校验
      GV_CFLAG TYPE C,

*------Screen 9000
      GV_RECDATE TYPE D,
      GV_INFLAG1 TYPE C,
      GV_REMARK1 TYPE ZREMARK,

*------Screen 9001
      GV_ISSDATE TYPE MKPF-BUDAT,
      GV_INFLAG2 TYPE C,
      GV_REMARK2 TYPE ZREMARK,
      GV_TOTAL TYPE ZVMSAL,
      GV_SABST TYPE ZSABST,
      GV_LABST TYPE ZLABST,

*------Screen 9003
      GV_MONTH TYPE CHAR50,
      GV_START TYPE D,
      GV_FINISH TYPE D,
      GV_NAME TYPE BUTXT,

*------Screen 9008
      GV_WFMESSAGE TYPE CHAR255,
*消息Bapi
       GW_MESSAGE TYPE TY_MESSAGE.

*&---------------------------------------------------------------------*
* Constant DECLARATION
*&---------------------------------------------------------------------*
CONSTANTS :
           C_RATE(16TYPE P DECIMALS 2 VALUE '0.93',
           C_PLANT TYPE WERKS_D VALUE '1201',
           C_RECEIVE TYPE C VALUE 'I',
           C_ISSUE TYPE C VALUE 'O'.

*&---------------------------------------------------------------------*
* SELECTION SCREEN DECLARATION
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BK1 WITH FRAME TITLE TEXT-T01.
SELECTION-SCREEN FUNCTION KEY 1.
* Receive - 收货
SELECTION-SCREEN COMMENT /1(30TEXT-001 MODIF ID SC1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
PARAMETERS P_R1  RADIOBUTTON GROUP RAD1 USER-COMMAND UC DEFAULT 'X'.
SELECTION-SCREEN COMMENT 6(30TEXT-004  FOR FIELD P_R1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(12TEXT-007.
SELECT-OPTIONS: S_BTBHA FOR ZZTPP_ZSTZ_HEAD-BTBHA NO INTERVALS
                MATCHCODE OBJECT ZBTBHA MODIF ID M1 NO-EXTENSION .
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

* Issue - 售出
SELECTION-SCREEN COMMENT /1(30TEXT-002 MODIF ID SC1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
PARAMETERS P_R2  RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT 6(30TEXT-005  FOR FIELD P_R2.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

* Subcontract - 委外
SELECTION-SCREEN COMMENT /1(30TEXT-016 MODIF ID SC1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
PARAMETERS P_R5  RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT 6(30TEXT-017  FOR FIELD P_R5.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

* Stock - 存货
SELECTION-SCREEN COMMENT /1(30TEXT-003 MODIF ID SC1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
PARAMETERS P_R3  RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT 6(30TEXT-006  FOR FIELD P_R3.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.
*选择条件行次
*年月
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(12TEXT-009.
SELECT-OPTIONS: S_MONTH FOR ZSCRAP-ERDAT+0(6) MODIF ID M2 NO-EXTENSION
  DEFAULT SY-DATUM+0(6).
SELECTION-SCREEN END OF LINE.
*物料号
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(12TEXT-008.
SELECT-OPTIONS: S_MATNR FOR ZSCRAP-MATNR MODIF ID M2 NO-EXTENSION.
SELECTION-SCREEN END OF LINE.
*批次
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(12TEXT-022.
SELECT-OPTIONS: S_CHARG FOR ZSCRAP-CHARG MODIF ID M3 NO-EXTENSION.
SELECTION-SCREEN END OF LINE.
*库位
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(12TEXT-031.
SELECT-OPTIONS: S_LGORT FOR ZSCRAP-LGORT
  MATCHCODE OBJECT H_T001L MODIF ID M3 NO-EXTENSION.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

*当前库存
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
PARAMETERS P_R4 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT 6(30TEXT-015  FOR FIELD P_R4.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

* Merge - 批次合并
SELECTION-SCREEN COMMENT /1(30TEXT-027 MODIF ID SC1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
PARAMETERS P_R7  RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT 6(50TEXT-028  FOR FIELD P_R7.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

* Write-off - 冲销
SELECTION-SCREEN COMMENT /1(30TEXT-020 MODIF ID SC1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
PARAMETERS P_R6  RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT 6(30TEXT-021  FOR FIELD P_R6.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 2.

SELECTION-SCREEN PUSHBUTTON 5(24) BUT USER-COMMAND CLI.

SELECTION-SCREEN END OF BLOCK BK1 .

SELECTION-SCREEN COMMENT 1(82TEXT-029.
SELECTION-SCREEN SKIP 1.

*&---------------------------------------------------------------------*
* INITIALIZATION
*&---------------------------------------------------------------------*
INITIALIZATION.
  "按钮文本
  BUT = TEXT-019.

  CLEAR : GV_CFLAG.
  REFRESH :
*确认收货
       I_RECEIVE,
*输入发货
       I_ISSUE ,
*历史收货
       I_IN ,
*历史售出
       I_OUT,
*历史余留
       I_LEFT,
*当前库存
       I_STOCK.
  SSCRFIELDS-FUNCTXT_01 = TEXT-032.

*&---------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
*屏幕初始化
  PERFORM FRM_SET_SCREEN.

*&---------------------------------------------------------------------*
* AT SELECTION-SCREEN
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.
  DATA:
        LT_RSPAR  TYPE TABLE OF RSPARAMS,
        LW_LINE LIKE LINE OF LT_RSPAR.

  IF SSCRFIELDS-UCOMM = 'FC01'.
    REFRESH LT_RSPAR.
    LW_LINE-SELNAME = 'MATNR'.
    LW_LINE-KIND    = 'S'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = '000000003010300000'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'MATNR'.
    LW_LINE-KIND    = 'S'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = '000000003010400000'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'MATNR'.
    LW_LINE-KIND    = 'S'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = '000000003100100000'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'MATNR'.
    LW_LINE-KIND    = 'S'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = '000000003100300000'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'MATNR'.
    LW_LINE-KIND    = 'S'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = '000000003100900000'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'WERKS'.
    LW_LINE-KIND    = 'S'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = '1201'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'PA_SOND'.
    LW_LINE-KIND    = 'P'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = 'X'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'NEGATIV'.
    LW_LINE-KIND    = 'P'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = ''.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'XMCHB'.
    LW_LINE-KIND    = 'P'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = 'X'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'NOZERO'.
    LW_LINE-KIND    = 'P'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = 'X'.
    APPEND LW_LINE TO LT_RSPAR.
    LW_LINE-SELNAME = 'NOVALUES'.
    LW_LINE-KIND    = 'P'.
    LW_LINE-SIGN    = 'I'.
    LW_LINE-OPTION  = 'EQ'.
    LW_LINE-LOW     = ''.
    APPEND LW_LINE TO LT_RSPAR.

    SUBMIT RM07MLBS VIA SELECTION-SCREEN WITH SELECTION-TABLE LT_RSPAR AND RETURN.
  ENDIF.
  IF SY-UCOMM = 'CLI'.
    CALL SCREEN 9002 STARTING AT 20 5 ENDING AT 100 12.
  ENDIF.

*选择屏幕校验
  PERFORM FRM_CHECK_SCREEN.

* search help for material number
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MATNR-LOW.
  PERFORM FRM_F4_HELP.
* search help for material number
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MATNR-HIGH.
  PERFORM FRM_F4_HELP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MONTH-LOW.
  PERFORM FRM_F4_DATE1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MONTH-HIGH.
  PERFORM FRM_F4_DATE2.

*&---------------------------------------------------------------------*
* START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  DATA :
        LV_ANSWER TYPE C.

  SELECT SINGLE BUTXT
    INTO GV_NAME
    FROM T001
    WHERE BUKRS = '1200'.

  CHECK GV_CFLAG = ''.
  IF P_R1 = 'X'.

    PERFORM FRM_GET_DATA.
    IF I_RECEIVE IS NOT INITIAL.
      CALL SCREEN 9000.
    ELSE.
      MESSAGE '没有需要确认的收货!' TYPE 'S' DISPLAY LIKE 'E'.
      EXIT.
    ENDIF.

  ELSEIF P_R2 = 'X'.

    CALL SCREEN 9001"售出废料

  ELSEIF P_R5 = 'X'.

    CALL SCREEN 9007.  "委外加工

  ELSEIF P_R3 = 'X'.

* show the current activity and the progress
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        TEXT = '正在处理,请稍等......'.       "Preparing list output
*取’年月‘选择条件
    PERFORM FRM_GET_DATE CHANGING GV_START GV_FINISH.
    CALL SCREEN 9003.

  ELSEIF P_R4 = 'X'.

    CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
      EXPORTING
*       DEFAULTOPTION        = 'Y'
        DIAGNOSETEXT1        = '此操作为查看现有废铜棉的数量'
       DIAGNOSETEXT2         = '可能会存在大量记录,请确认是否查看!'
*       DIAGNOSETEXT3        = ' '
        TEXTLINE1            = '确认查看,请点击<是>,返回点击<取消>!'
*       TEXTLINE2            = ' '
        TITEL                = '友情提示'
*       START_COLUMN         = 25
*       START_ROW            = 6
*       CANCEL_DISPLAY       = 'X'
     IMPORTING
       ANSWER               = LV_ANSWER
              .

    IF LV_ANSWER = 'J'.
* show the current activity and the progress
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          TEXT = '正在处理,请稍等......'.       "Preparing list output
      PERFORM GET_CURRENT_STOCK.
      IF I_STOCK IS INITIAL.
        MESSAGE '此刻没有废铜棉库存!' TYPE 'S' DISPLAY LIKE 'E'.
        EXIT.
      ELSE.
        PERFORM FRM_SHOW_STOCK.
      ENDIF.
    ENDIF.

  ELSEIF P_R6 = 'X'.
    PERFORM FRM_WRITEOFF_RECEIVE.
    IF I_WF IS NOT INITIAL.
      CALL SCREEN 9008.
    ELSE.
      MESSAGE GV_WFMESSAGE TYPE 'S' DISPLAY LIKE 'E'.
      EXIT.
    ENDIF.

  ELSEIF P_R7 = 'X'.
    PERFORM FRM_GET_MERGE_INFO.
    IF I_STOCK IS INITIAL.
      MESSAGE '没有查询到您所输入的物料库存,请核实!' TYPE 'S' DISPLAY LIKE 'E'.
      EXIT.
    ELSE.
      PERFORM FRM_SHOW_STOCK.
    ENDIF.
  ENDIF.
*&---------------------------------------------------------------------*
* END-OF-SELECTION
*&---------------------------------------------------------------------*
END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATE
*&---------------------------------------------------------------------*
*       选择屏幕上的年月条件
*----------------------------------------------------------------------*
*      <--P_LV_START  text
*      <--P_LV_FINISH  text
*----------------------------------------------------------------------*
FORM FRM_GET_DATE  CHANGING P_START TYPE D
                              P_FINISH TYPE D.
  DATA :
        LV_STR1 TYPE CHAR10,
        LV_STR2 TYPE CHAR10.

  IF S_MONTH-LOW IS NOT INITIAL AND S_MONTH-HIGH IS INITIAL.
    CONCATENATE S_MONTH-LOW '01' INTO P_START.
    CALL FUNCTION 'FIMA_DATE_CREATE'
      EXPORTING
        I_DATE                        = P_START
*   I_FLG_END_OF_MONTH            = ' '
*   I_YEARS                       = 0
       I_MONTHS                      = 0
*   I_DAYS                        = 0
*   I_CALENDAR_DAYS               = 0
       I_SET_LAST_DAY_OF_MONTH       = 'X'
     IMPORTING
   E_DATE                        = P_FINISH
*   E_FLG_END_OF_MONTH            =
*   E_DAYS_OF_I_DATE              =
              .
    CONCATENATE S_MONTH-LOW+0(4'/' S_MONTH-LOW+4(2)
      INTO LV_STR1.
    GV_MONTH = LV_STR1.
  ELSEIF S_MONTH-LOW IS NOT INITIAL AND S_MONTH-HIGH IS NOT INITIAL.
    CONCATENATE S_MONTH-LOW '01' INTO P_START.
    CONCATENATE S_MONTH-HIGH '01' INTO P_FINISH.
    CALL FUNCTION 'FIMA_DATE_CREATE'
          EXPORTING
            I_DATE                        = P_FINISH
*   I_FLG_END_OF_MONTH            = ' '
*   I_YEARS                       = 0
           I_MONTHS                      = 0
*   I_DAYS                        = 0
*   I_CALENDAR_DAYS               = 0
           I_SET_LAST_DAY_OF_MONTH       = 'X'
         IMPORTING
       E_DATE                        = P_FINISH
*   E_FLG_END_OF_MONTH            =
*   E_DAYS_OF_I_DATE              =
                  .
    CONCATENATE S_MONTH-LOW+0(4'/' S_MONTH-LOW+4(2)
      INTO LV_STR1.
    CONCATENATE S_MONTH-HIGH+0(4'/' S_MONTH-HIGH+4(2)
      INTO LV_STR2.
    CONCATENATE LV_STR1 '~' LV_STR2
      INTO GV_MONTH SEPARATED BY SPACE.
  ENDIF.
ENDFORM.                    " FRM_GET_DATE
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_SCREEN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_SET_SCREEN .
  LOOP AT SCREEN.
    IF P_R1 = 'X'.
      IF SCREEN-GROUP1 = 'M2' OR SCREEN-GROUP1 = 'M3'.
        SCREEN-INPUT = 0.
      ELSE.
        SCREEN-INPUT = 1.
      ENDIF.
      MODIFY SCREEN.

    ELSEIF P_R2 = 'X' OR P_R4 = 'X' OR P_R5 = 'X'.
      IF SCREEN-GROUP1 = 'M2' OR SCREEN-GROUP1 = 'M1' OR SCREEN-GROUP1 = 'M3'.
        SCREEN-INPUT = 0.
      ELSE.
        SCREEN-INPUT = 1.
      ENDIF.
      MODIFY SCREEN.

    ELSEIF P_R3 = 'X'.
      IF SCREEN-GROUP1 = 'M1' OR SCREEN-GROUP1 = 'M3'.
        SCREEN-INPUT = 0.
      ELSE.
        SCREEN-INPUT = 1.
      ENDIF.
      MODIFY SCREEN.

    ELSEIF P_R6 = 'X'.
      IF SCREEN-NAME = 'S_BTBHA-LOW'
        OR SCREEN-NAME = 'S_MONTH-LOW'
        OR SCREEN-NAME = 'S_MONTH-HIGH'
        OR SCREEN-NAME = 'S_LGORT-LOW'
        OR SCREEN-NAME = 'S_LGORT-HIGH'.
        SCREEN-INPUT = 0.
      ELSE.
        SCREEN-INPUT = 1.
      ENDIF.
      MODIFY SCREEN.

    ELSEIF P_R7 = 'X'.
      IF SCREEN-NAME = 'S_BTBHA-LOW'
        OR SCREEN-NAME = 'S_MONTH-LOW'
        OR SCREEN-NAME = 'S_MONTH-HIGH'
        OR  SCREEN-NAME = 'S_CHARG-HIGH'
        OR SCREEN-NAME = 'S_CHARG-LOW'
        OR SCREEN-NAME = 'S_MATNR-HIGH'.
        SCREEN-INPUT = 0.
      ELSE.
        SCREEN-INPUT = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.

    IF SCREEN-GROUP1 = 'SC1'.
      SCREEN-INTENSIFIED = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " FRM_SET_SCREEN
*&---------------------------------------------------------------------*
*&      Form  FRM_CHECK_SCREEN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CHECK_SCREEN .
  GV_CFLAG = ''.

  IF P_R1 = 'X'.
    IF S_BTBHA IS INITIAL.
      GV_CFLAG = 'X'.
      SET CURSOR FIELD 'S_BTBHA-LOW'.
      MESSAGE '请输入需要确认的台班编号!' TYPE 'S' DISPLAY LIKE 'E'.
      EXIT.
    ELSE.
      SELECT SINGLE *
        FROM  ZZTPP_ZSTZ_HEAD
        WHERE BTBHA IN S_BTBHA.
      IF SY-SUBRC <> 0.
        GV_CFLAG = 'X'.
        SET CURSOR FIELD 'S_BTBHA-LOW'.
        MESSAGE '请输入正确的台班编号!' TYPE 'S' DISPLAY LIKE 'E'.
        EXIT.
      ENDIF.
    ENDIF.
  ELSEIF P_R3 = 'X'.
    IF S_MONTH IS INITIAL.
      GV_CFLAG = 'X'.
      SET CURSOR FIELD 'S_MONTH-LOW'.
      MESSAGE '请输入查询年月!' TYPE 'S' DISPLAY LIKE 'E'.
      EXIT.
    ENDIF.

    IF S_MATNR IS NOT INITIAL.
      SELECT SINGLE *
        FROM MARA
        WHERE MATNR IN S_MATNR.
      IF SY-SUBRC <> 0.
        GV_CFLAG = 'X'.
        SET CURSOR FIELD 'S_MATNR-LOW'.
        MESSAGE '请输入正确的物料编号!' TYPE 'S' DISPLAY LIKE 'E'.
        EXIT.
      ENDIF.
    ENDIF.
  ELSEIF P_R6 = 'X'.
    IF S_MATNR IS INITIAL OR S_CHARG IS INITIAL.
      GV_CFLAG = 'X'.
      MESSAGE '请输入冲销条件:物料号跟批次号!' TYPE 'S' DISPLAY LIKE 'E'.
      EXIT.
    ENDIF.
  ELSEIF P_R7 = 'X'.
    IF S_MATNR IS INITIAL.
      GV_CFLAG = 'X'.
      MESSAGE '请输入需要批次合并的物料代码!' TYPE 'S' DISPLAY LIKE 'E'.
      EXIT.
    ENDIF.
  ENDIF.
ENDFORM.                    " FRM_CHECK_SCREEN

*&SPWizard: Data incl. inserted by SP Wizard. DO NOT CHANGE THIS LINE!
INCLUDE ZPP_ISSUE_TBL4 .
INCLUDE ZPP_SUBCONTRACT_TBL .
INCLUDE ZPP_ISSUE_SCRIP .
INCLUDE ZPP_ISSUE_TBL .
*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
  SET PF-STATUS '9000'.
  SET TITLEBAR 'TITLE' WITH '确认收货'.

*初始化
  IF GV_INFLAG1 = ''.
    CLEAR ZZTPP_ZSTZ_HEAD.
    SELECT SINGLE *
      FROM ZZTPP_ZSTZ_HEAD
      WHERE BTBHA IN S_BTBHA.
*    GV_RECDATE = SY-DATUM.
    GV_RECDATE = ZZTPP_ZSTZ_HEAD-BUDAT.
    GV_INFLAG1 = 'X'.
  ENDIF.
ENDMODULE.                 " STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
  CASE OK_CODE1.
    WHEN 'BACK' OR 'EXIT'.
      LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
      LEAVE PROGRAM.
    WHEN 'CONFIRM'.
*确认收货
      PERFORM FRM_CONFIRM_RECEIVE.
    WHEN 'GIVEUP'.
      LEAVE TO SCREEN 0.
  ENDCASE.
  CLEAR : OK_CODE1.
ENDMODULE.                 " USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       取台班中待确认的废铜棉信息
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
  IF S_BTBHA IS NOT INITIAL.
    SELECT YLDM  AS  MATNR
           YLPH  AS  CHARG
           LGORT AS  LGORT
           YLMS  AS  MAKTX
           YLZL  AS  LABST
      FROM ZZTPP_ZSTZ_BODY4
      INTO CORRESPONDING FIELDS OF TABLE I_RECEIVE
      WHERE BTBHA IN S_BTBHA
        AND GZ = ''
      .
    LOOP AT I_RECEIVE INTO WA_RECEIVE.
      WA_RECEIVE-MEINS = 'KG'.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = WA_RECEIVE-MATNR
        IMPORTING
          OUTPUT = WA_RECEIVE-MATNR.

      MODIFY I_RECEIVE FROM WA_RECEIVE.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " FRM_GET_DATA
*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE EXIT INPUT.
  LEAVE TO SCREEN 0.
ENDMODULE.                 " EXIT  INPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_9001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9001 OUTPUT.
  DATA :
       LV_LINE TYPE I.

  SET PF-STATUS '9001'.
  SET TITLEBAR 'TITLE' WITH '输入发货'.

  PERFORM FRM_SET_LISTBOX.

*初始化
  IF GV_INFLAG2 = ''.
    GV_ISSDATE = SY-DATUM.
    GV_REMARK2 = '直接销售废铜棉......'.
    GV_INFLAG2 = 'X'.
  ENDIF.

*输入一行确认后定位到下一行
  IF GV_ISSDATE IS NOT INITIAL.
    LV_LINE = LINES( I_ISSUE ).
    LV_LINE = LV_LINE + 1.
    SET CURSOR FIELD 'WA_ISSUE-MATNR' LINE LV_LINE.
  ENDIF.

ENDMODULE.                 " STATUS_9001  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9001 INPUT.
  DATA :
*函数返回标记
         LV_RETURN TYPE C.

  CASE OK_CODE2.
*返回屏幕
    WHEN 'BACK' OR 'EXIT'.
      IF I_ISSUE IS NOT INITIAL.
        PERFORM FRM_POPUP_INFO USING TEXT-018 TEXT-011  CHANGING LV_RETURN.
        IF LV_RETURN = 'J'.
          LEAVE TO SCREEN 0.
        ENDIF.
      ELSE.
        LEAVE TO SCREEN 0.
      ENDIF.
*退出程序
    WHEN 'CANCEL'.
      IF I_ISSUE IS NOT INITIAL.
        PERFORM FRM_POPUP_INFO USING TEXT-018 TEXT-011  CHANGING LV_RETURN.
        IF LV_RETURN = 'J'.
          LEAVE PROGRAM.
        ENDIF.
      ELSE.
        LEAVE PROGRAM.
      ENDIF.
*确认售出
    WHEN 'SAVE' OR 'VERIFY'.
      PERFORM FRM_SELL_OUT.
*清空项目
    WHEN 'EMPTY'.
      PERFORM FRM_CLEAR_ITEMS.
*取消发货
    WHEN 'ABOLISH'.
      PERFORM FRM_CANCEL_ISSUE.
  ENDCASE.

  CLEAR : OK_CODE2.
ENDMODULE.                 " USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*&      Form  CHECK_TBL_INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CHECK_TBL_INPUT .
  DATA:
         LV_CURRLINE TYPE I,
         WA_TEMP LIKE LINE OF I_ISSUE,
         LV_LINES TYPE I,
         LV_MATNR TYPE MATNR.

*光标位置
  LV_LINES = TBL2-CURRENT_LINE - TBL2-TOP_LINE + 1.

  LV_CURRLINE = TBL2-CURRENT_LINE - 1.

  LOOP AT I_ISSUE INTO WA_TEMP FROM TBL2-TOP_LINE TO LV_CURRLINE.
    IF WA_TEMP-MATNR = WA_ISSUE-MATNR AND WA_TEMP-CHARG = WA_ISSUE-CHARG.
      SET CURSOR FIELD 'WA_ISSUE-CHARG' LINE LV_LINES.
      MESSAGE '此记录已经存在表格中!' TYPE 'E'.
    ENDIF.
  ENDLOOP.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      INPUT  = WA_ISSUE-MATNR
    IMPORTING
      OUTPUT = LV_MATNR.

  SELECT SINGLE *
    FROM ZSCRAP
    WHERE MATNR = LV_MATNR
      AND CHARG = WA_ISSUE-CHARG
      AND FLAG = C_RECEIVE
      AND SFLAG = ''.
  IF SY-SUBRC <> 0.
    SET CURSOR FIELD 'WA_ISSUE-MATNR' LINE LV_LINES.
    MESSAGE '该项目不存在!' TYPE 'E'.
  ELSE.
    SELECT SINGLE MAKTX
      FROM MAKT
      INTO WA_ISSUE-MAKTX
      WHERE MATNR = LV_MATNR
        AND SPRAS = SY-LANGU.

    WA_ISSUE-LGORT = ZSCRAP-LGORT.
    WA_ISSUE-AMOUNT = ZSCRAP-LABST.
*    WA_ISSUE-LABST = ZSCRAP-LABST.
    WA_ISSUE-MEINS = 'KG'.

*校验售出废铜棉数量
    IF WA_ISSUE-LABST IS INITIAL.
*      SET CURSOR FIELD 'WA_ISSUE-LABST' LINE LV_LINES.
*      MESSAGE '请输入需售出的废铜棉数量!' TYPE 'E'.
      WA_ISSUE-LABST = WA_ISSUE-AMOUNT.
    ELSEIF WA_ISSUE-LABST < 0 OR WA_ISSUE-LABST > WA_ISSUE-AMOUNT .
      SET CURSOR FIELD 'WA_ISSUE-LABST' LINE LV_LINES.
      MESSAGE '请输入合理的售出数量!' TYPE 'E'.
    ENDIF.

    IF WA_ISSUE-STPRS IS INITIAL.
      SET CURSOR FIELD 'WA_ISSUE-STPRS' LINE LV_LINES.
      MESSAGE '请输入单位标准价格!' TYPE 'E'.
    ELSE.
      WA_ISSUE-PEINH = 1.
      WA_ISSUE-TOTAL = WA_ISSUE-STPRS * WA_ISSUE-LABST * WA_ISSUE-PEINH.
      WA_ISSUE-WAERS = 'CNY'.
    ENDIF.
  ENDIF.
ENDFORM.                    " CHECK_TBL_INPUT
*&---------------------------------------------------------------------*
*&      Module  F4_HELP  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE F4_HELP_WAERS INPUT.

  IF I_SEARCH IS INITIAL.
    SELECT DISTINCT *
        FROM TCURT
        INTO CORRESPONDING FIELDS OF TABLE I_SEARCH
        WHERE SPRAS = SY-LANGU.
  ENDIF.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*   DDIC_STRUCTURE         = ' '
      RETFIELD               = 'WAERS'
*   PVALKEY                = ' '
      DYNPPROG               = SY-REPID
      DYNPNR                 = SY-DYNNR
      DYNPROFIELD            = 'WA_ISSUE-WAERS'
*   STEPL                  = 0
*   WINDOW_TITLE           =
*   VALUE                  = ' '
      VALUE_ORG               = 'S'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
    TABLES
      VALUE_TAB              = I_SEARCH
*   FIELD_TAB              =
*   RETURN_TAB             =
*   DYNPFLD_MAPPING        =
EXCEPTIONS
 PARAMETER_ERROR        = 1
 NO_VALUES_FOUND        = 2
 OTHERS                 = 3
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDMODULE.                 " F4_HELP  INPUT

*&---------------------------------------------------------------------*
*&      Module  F4_HELP_CHARG  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE F4_HELP_CHARG INPUT.
  DATA :
        LV_MATNR TYPE MATNR,
        LV_WA_CHARG TYPE T_CHARG.

*  IF I_CHARG IS INITIAL.

  DATA: DYNPFIELDS TYPE TABLE OF DYNPREAD WITH HEADER LINE.
  CLEAR: DYNPFIELDS, DYNPFIELDS[].
  DYNPFIELDS-FIELDNAME = 'WA_ISSUE-MATNR'"填入需要读值的字段名
  APPEND DYNPFIELDS.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      DYNAME             = SY-REPID
      DYNUMB             = SY-DYNNR
      TRANSLATE_TO_UPPER = 'X'
    TABLES
      DYNPFIELDS         = DYNPFIELDS
    EXCEPTIONS
      OTHERS             = 9.
  IF SY-SUBRC = 0.
    READ TABLE DYNPFIELDS WITH KEY FIELDNAME = 'WA_ISSUE-MATNR'.
    LV_MATNR = DYNPFIELDS-FIELDVALUE. "备注
  ENDIF.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      INPUT  = LV_MATNR
    IMPORTING
      OUTPUT = LV_MATNR.

  SELECT  MATNR CHARG LABST
    INTO CORRESPONDING FIELDS OF TABLE I_CHARG
    FROM ZSCRAP
   WHERE FLAG = C_RECEIVE
     AND MATNR = LV_MATNR
     AND SFLAG <> 'X'
    .
  LOOP AT I_CHARG INTO LV_WA_CHARG.
    SELECT SINGLE MAKTX
      FROM MAKT
      INTO LV_WA_CHARG-MAKTX
      WHERE MATNR = LV_WA_CHARG-MATNR
        AND SPRAS = SY-LANGU.
    MODIFY I_CHARG FROM LV_WA_CHARG.
  ENDLOOP.
*  ENDIF.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*   DDIC_STRUCTURE         = ' '
      RETFIELD               = 'CHARG'
*   PVALKEY                = ' '
      DYNPPROG               = SY-REPID
      DYNPNR                 = SY-DYNNR
      DYNPROFIELD            = 'WA_ISSUE-CHARG'
*   STEPL                  = 0
*   WINDOW_TITLE           =
*   VALUE                  = ' '
      VALUE_ORG               = 'S'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
    TABLES
      VALUE_TAB              = I_CHARG
*   FIELD_TAB              =
*   RETURN_TAB             =
*   DYNPFLD_MAPPING        =
EXCEPTIONS
 PARAMETER_ERROR        = 1
 NO_VALUES_FOUND        = 2
 OTHERS                 = 3
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDMODULE.                 " F4_HELP_CHARG  INPUT

*&---------------------------------------------------------------------*
*&      Module  STATUS_9003  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9003 OUTPUT.
  SET PF-STATUS '9003'.
  SET TITLEBAR 'TITLE' WITH '显示库存'.

ENDMODULE.                 " STATUS_9003  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9003  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9003 INPUT.
  CASE OK_CODE3.
    WHEN 'BACK' OR 'EXIT'.
      PERFORM FRM_FREE_CONTAINER.
      LEAVE TO SCREEN 0.
    WHEN 'CANCEL'.
      PERFORM FRM_FREE_CONTAINER.
      LEAVE PROGRAM.
  ENDCASE.
  CLEAR : OK_CODE3.
ENDMODULE.                 " USER_COMMAND_9003  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_CONFIRM_RECEIVE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CONFIRM_RECEIVE .
  DATA :
          LV_MATNR TYPE MATNR,
          LV_CHARG TYPE CHARG_D,
          LV_RETURN TYPE C,
          LV_WA_BTBHA TYPE ZZTPP_ZSTZ_BODY4,
          LV_I_BTBHA TYPE STANDARD TABLE OF ZZTPP_ZSTZ_BODY4,
          LV_WA_INSERT TYPE ZSCRAP,
          LV_I_INSERT TYPE STANDARD TABLE OF ZSCRAP.

*Bapi参数
  DATA:LW_P3_GOODSMVT_HEADER  TYPE BAPI2017_GM_HEAD_01,
       LW_P3_GOODSMVT_HEADRET TYPE BAPI2017_GM_HEAD_RET,
       LW_P3_MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC,
       LW_P3_MATDOCUMENTYEAR  TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR,
       LT_P3_GOODSMVT_ITEM    TYPE STANDARD TABLE OF   BAPI2017_GM_ITEM_CREATE,
       LW_P3_GOODSMVT_ITEM    TYPE BAPI2017_GM_ITEM_CREATE,
       LT_P3_RETURN           TYPE STANDARD TABLE OF   BAPIRET2,
       LW_P3_RETURN           TYPE BAPIRET2.

*取成品信息
  DATA :GW_BODY3_SUM TYPE ZZTPP_ZSTZ_BODY3-YLCCHJ,
        GT_BODY3 TYPE STANDARD TABLE OF ZZTPP_ZSTZ_BODY3,
        LW_P3_BODY3 TYPE ZZTPP_ZSTZ_BODY3.

*校验一下批次
  LOOP AT I_RECEIVE INTO WA_RECEIVE.
    CLEAR : LV_MATNR.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = WA_RECEIVE-MATNR
      IMPORTING
        OUTPUT = LV_MATNR.
    SELECT SINGLE CHARG
     FROM ZSCRAP
     INTO LV_CHARG
     WHERE MATNR = LV_MATNR
       AND CHARG = WA_RECEIVE-CHARG.
    IF SY-SUBRC = 0 OR LV_CHARG IS NOT INITIAL.
      MESSAGE '该物料的批次已经存在,请告知生产部相关人员确认!' TYPE 'E'.
    ENDIF.
  ENDLOOP.

  PERFORM FRM_POPUP_INFO USING TEXT-010 TEXT-011  CHANGING LV_RETURN.
  IF LV_RETURN = 'J'.
*收货到系统--------------------- 1、

*Bapi抬头参数
    CLEAR ZZTPP_ZSTZ_HEAD.
    SELECT SINGLE *
      FROM ZZTPP_ZSTZ_HEAD
      INTO ZZTPP_ZSTZ_HEAD
      WHERE BTBHA IN S_BTBHA.
    CLEAR LW_P3_GOODSMVT_HEADER.
    IF ZZTPP_ZSTZ_HEAD-BUDAT IS NOT INITIAL.
      LW_P3_GOODSMVT_HEADER-PSTNG_DATE = ZZTPP_ZSTZ_HEAD-BUDAT.
      LW_P3_GOODSMVT_HEADER-DOC_DATE   = ZZTPP_ZSTZ_HEAD-BUDAT.
    ELSE.
      LW_P3_GOODSMVT_HEADER-PSTNG_DATE = SY-DATUM.
      LW_P3_GOODSMVT_HEADER-DOC_DATE   = SY-DATUM.
    ENDIF.
    LW_P3_GOODSMVT_HEADER-PR_UNAME   = SY-UNAME.
    LW_P3_GOODSMVT_HEADER-HEADER_TXT = ZZTPP_ZSTZ_HEAD-BTBHA."台班编号

    REFRESH LT_P3_GOODSMVT_ITEM.
    REFRESH LT_P3_RETURN.
    CLEAR :
          LW_P3_RETURN,
          LW_P3_GOODSMVT_HEADRET,
          LW_P3_MATERIALDOCUMENT,
          LW_P3_MATDOCUMENTYEAR,
          LW_P3_GOODSMVT_ITEM.

    SELECT *
      FROM ZZTPP_ZSTZ_BODY3
      INTO CORRESPONDING FIELDS OF TABLE GT_BODY3
      WHERE  BTBHA IN S_BTBHA.

* 原料产出合计
    CLEAR: LW_P3_BODY3,GW_BODY3_SUM.
    LOOP AT GT_BODY3 INTO LW_P3_BODY3.
      GW_BODY3_SUM = GW_BODY3_SUM + LW_P3_BODY3-YLCCHJ.
    ENDLOOP.

    LOOP AT I_RECEIVE INTO WA_RECEIVE.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = WA_RECEIVE-MATNR
        IMPORTING
          OUTPUT = WA_RECEIVE-MATNR.
      "低值废铜棉不过账到系统
      IF WA_RECEIVE-MATNR+8 = '3100900000'.
        CONTINUE.
      ENDIF.

      LOOP AT GT_BODY3 INTO LW_P3_BODY3.
        IF LW_P3_BODY3-YLCCHJ = 0 OR LW_P3_BODY3-YLCCHJ IS INITIAL.
          CONTINUE.
        ENDIF.
        LW_P3_GOODSMVT_ITEM-PLANT     = '1201'."工厂

        LW_P3_GOODSMVT_ITEM-STGE_LOC  = WA_RECEIVE-LGORT."库存地点

        LW_P3_GOODSMVT_ITEM-MOVE_TYPE = '531'."移动类型

*        LW_P3_GOODSMVT_ITEM-ENTRY_QNT = WA_RECEIVE-LABST.
        LW_P3_GOODSMVT_ITEM-ENTRY_QNT =
              WA_RECEIVE-LABST * (  LW_P3_BODY3-YLCCHJ / GW_BODY3_SUM ).

        LW_P3_GOODSMVT_ITEM-ENTRY_UOM = 'KG'."单位

        LW_P3_GOODSMVT_ITEM-ORDERID   = LW_P3_BODY3-CPDDH."订单号

        LW_P3_GOODSMVT_ITEM-MATERIAL  = WA_RECEIVE-MATNR."物料代码

        LW_P3_GOODSMVT_ITEM-BATCH     = WA_RECEIVE-CHARG."批号

        SELECT SINGLE  RSNUM RSPOS              " 预留编号,预留项目编号
          INTO (LW_P3_GOODSMVT_ITEM-RESERV_NO,LW_P3_GOODSMVT_ITEM-RES_ITEM)
          FROM RESB
        WHERE AUFNR = LW_P3_BODY3-CPDDH
          AND MATNR = WA_RECEIVE-MATNR.
        IF SY-SUBRC <> 0.
          CLEAR : LW_P3_GOODSMVT_ITEM-RESERV_NO,
                  LW_P3_GOODSMVT_ITEM-RES_ITEM.
        ENDIF.
        APPEND LW_P3_GOODSMVT_ITEM TO LT_P3_GOODSMVT_ITEM.
      ENDLOOP.
    ENDLOOP.

    IF LT_P3_GOODSMVT_ITEM IS NOT INITIAL.
                                                            "分摊数量为0的行次
      DELETE LT_P3_GOODSMVT_ITEM WHERE ENTRY_QNT = 0.

      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          GOODSMVT_HEADER  = LW_P3_GOODSMVT_HEADER
          GOODSMVT_CODE    = '05'                           "MB1C
        IMPORTING
          GOODSMVT_HEADRET = LW_P3_GOODSMVT_HEADRET
          MATERIALDOCUMENT = LW_P3_MATERIALDOCUMENT
          MATDOCUMENTYEAR  = LW_P3_MATDOCUMENTYEAR
        TABLES
          GOODSMVT_ITEM    = LT_P3_GOODSMVT_ITEM
          RETURN           = LT_P3_RETURN.
      IF LW_P3_MATERIALDOCUMENT IS INITIAL.
        ROLLBACK WORK.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
        SORT LT_P3_RETURN BY TYPE ID NUMBER.
        DELETE ADJACENT DUPLICATES FROM LT_P3_RETURN COMPARING TYPE ID NUMBER.
        CLEAR LW_P3_RETURN.
        LOOP AT LT_P3_RETURN INTO LW_P3_RETURN .
          IF GW_MESSAGE IS INITIAL.
            GW_MESSAGE-MESSAGE =  LW_P3_RETURN-MESSAGE.
          ELSE.
            CONCATENATE GW_MESSAGE-MESSAGE ';' LW_P3_RETURN-MESSAGE
                 INTO GW_MESSAGE-MESSAGE  .
          ENDIF.
        ENDLOOP.
        MESSAGE GW_MESSAGE-MESSAGE TYPE 'I'.
        EXIT.
      ENDIF.
    ENDIF.

*保存记录到数据库---------------- 2、
    REFRESH LV_I_INSERT.
    LOOP AT I_RECEIVE INTO WA_RECEIVE.
      CLEAR : LV_WA_INSERT.
      MOVE-CORRESPONDING WA_RECEIVE TO LV_WA_INSERT.
      LV_WA_INSERT-BUDAT = GV_RECDATE.
      LV_WA_INSERT-WERKS = C_PLANT.
      LV_WA_INSERT-FLAG = C_RECEIVE.
      LV_WA_INSERT-REMARK = GV_REMARK1.
      LV_WA_INSERT-OABST = WA_RECEIVE-LABST. " 原始入库数量
      LV_WA_INSERT-ERDAT = SY-DATUM.
      LV_WA_INSERT-ERZET = SY-UZEIT.
      LV_WA_INSERT-ERNAM = SY-UNAME.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = LV_WA_INSERT-MATNR
        IMPORTING
          OUTPUT = LV_WA_INSERT-MATNR.
      APPEND LV_WA_INSERT TO LV_I_INSERT.
    ENDLOOP.
    INSERT ZSCRAP FROM TABLE LV_I_INSERT.
    IF SY-SUBRC <> 0.
      ROLLBACK WORK.
      EXIT.
    ENDIF.

*更新台班中的废铜棉的状态----------- 3、
    SELECT *
      FROM ZZTPP_ZSTZ_BODY4
      INTO CORRESPONDING FIELDS OF TABLE LV_I_BTBHA
      WHERE BTBHA IN S_BTBHA
        AND GZ = ''
      .

    DATA : LV_FLG TYPE C.
    CLEAR LV_FLG.

    LOOP AT LV_I_BTBHA INTO LV_WA_BTBHA.
      LV_WA_BTBHA-GZ = 'Y'.
      LV_WA_BTBHA-ROWCOLOR = 'C410'.
      "物料凭证
      IF LV_WA_BTBHA-YLDM+8 <> '3100900000'.
        LV_WA_BTBHA-MBLNR = LW_P3_MATERIALDOCUMENT.
      ENDIF.
*      MODIFY LV_I_BTBHA FROM LV_WA_BTBHA.

      UPDATE ZZTPP_ZSTZ_BODY4
      SET GZ = LV_WA_BTBHA-GZ
          ROWCOLOR = LV_WA_BTBHA-ROWCOLOR
          MBLNR =  LV_WA_BTBHA-MBLNR
      WHERE YLDM = LV_WA_BTBHA-YLDM
        AND YLPH = LV_WA_BTBHA-YLPH
        AND LGORT = LV_WA_BTBHA-LGORT.
      IF SY-SUBRC <> 0.
        LV_FLG = 'X'.
        ROLLBACK WORK.
      ENDIF.
    ENDLOOP.

    IF LV_FLG = 'X'.
      EXIT.
    ENDIF.
*    MODIFY ZZTPP_ZSTZ_BODY4 FROM TABLE LV_I_BTBHA.
*    IF SY-SUBRC <> 0.
*      ROLLBACK WORK.
*      EXIT.
*    ENDIF.

    COMMIT WORK.
    MESSAGE '项目已成功确认,请告知台账录入人员!' TYPE 'S'.
    LEAVE TO SCREEN 0.
  ENDIF.
ENDFORM.                    " FRM_CONFIRM_RECEIVE

*&---------------------------------------------------------------------*
*&      Form  frm_popup_info
*&---------------------------------------------------------------------*
*        弹出框信息
*----------------------------------------------------------------------*
*      -->P_TEXT1    text
*      -->P_TEXT2    text
*      -->P_RETURN   text
*----------------------------------------------------------------------*
FORM FRM_POPUP_INFO USING P_TEXT1 P_TEXT2
                    CHANGING P_RETURN.
  CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'                     "#EC *
       EXPORTING
         DEFAULTOPTION  = 'Y'
         TEXTLINE1      = P_TEXT1
         TITEL          = P_TEXT2
         CANCEL_DISPLAY = ''
       IMPORTING
         ANSWER         = P_RETURN.
ENDFORM.                    "FRM_POPUP_INFO
*&---------------------------------------------------------------------*
*&      Form  FRM_CLEAR_ITEMS
*&---------------------------------------------------------------------*
*       清空所有行项目
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CLEAR_ITEMS .
  DATA :
      LV_RETURN TYPE C.

  IF I_ISSUE IS NOT INITIAL.
    PERFORM FRM_POPUP_INFO USING TEXT-012 TEXT-011  CHANGING LV_RETURN.
    IF LV_RETURN = 'J'.
      REFRESH I_ISSUE.
      CLEAR :
             GV_LABST,
             GV_TOTAL,
             GV_REMARK2.
    ENDIF.
  ENDIF.

ENDFORM.                    " FRM_CLEAR_ITEMS
*&---------------------------------------------------------------------*
*&      Form  FRM_CANCEL_ISSUE
*&---------------------------------------------------------------------*
*       取消操作,返回
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CANCEL_ISSUE .
  DATA :
       LV_RETURN TYPE C.

  IF I_ISSUE IS NOT INITIAL.
    PERFORM FRM_POPUP_INFO USING TEXT-013 TEXT-011  CHANGING LV_RETURN.
    IF LV_RETURN = 'J'.
      LEAVE TO SCREEN 0.
    ENDIF.
  ELSE.
    LEAVE TO SCREEN 0.
  ENDIF.

ENDFORM.                    " FRM_CANCEL_ISSUE
*&---------------------------------------------------------------------*
*&      Form  FRM_SELL_OUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_SELL_OUT .
  DATA :
*函数返回标记
         LV_RETURN TYPE C,
*更新出错标记
         LV_FLAG TYPE C,
*剩余数量
         LV_LEFT TYPE ZLABST,
*插入行次
         LV_LINE TYPE ZLINES,
*处理工作区
         LV_WA_RECEIVE TYPE ZSCRAP.

  IF I_ISSUE IS NOT INITIAL.
    PERFORM FRM_POPUP_INFO USING TEXT-014 TEXT-011  CHANGING LV_RETURN.
    IF LV_RETURN = 'J'.
*售出纪录保存到数据库中----- 1、
      LOOP AT I_ISSUE INTO WA_ISSUE.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = WA_ISSUE-MATNR
          IMPORTING
            OUTPUT = WA_ISSUE-MATNR.
        "查看是否已经有售出或者委外记录
        CLEAR : LV_LINE.
        SELECT MAXLINE )
          FROM ZSCRAP
          INTO LV_LINE
          WHERE MATNR = WA_ISSUE-MATNR
            AND CHARG = WA_ISSUE-CHARG
            AND FLAG = C_ISSUE .
        IF SY-SUBRC <> 0 .
          WA_ISSUE-LINE = '01'.
        ELSE.
          WA_ISSUE-LINE = LV_LINE + 1.
        ENDIF.

        WA_ISSUE-BUDAT = GV_ISSDATE.
        WA_ISSUE-WERKS = C_PLANT.
        WA_ISSUE-FLAG  = C_ISSUE. " O 发
        WA_ISSUE-REMARK = GV_REMARK2.
        WA_ISSUE-ERDAT = SY-DATUM.
        WA_ISSUE-ERZET = SY-UZEIT.
        WA_ISSUE-ERNAM = SY-UNAME.
        WA_ISSUE-SORT = '1'" 直接售出

        MODIFY I_ISSUE FROM WA_ISSUE.
      ENDLOOP.

      INSERT ZSCRAP FROM TABLE I_ISSUE.
      IF SY-SUBRC <> 0.
        ROLLBACK WORK.
        EXIT.
      ENDIF.

      CLEAR : LV_FLAG.
*更新库存标示或扣减更新---------------- 2、
      LOOP AT I_ISSUE INTO WA_ISSUE.
        "库存已售出
        IF WA_ISSUE-AMOUNT = WA_ISSUE-LABST.
          CLEAR : LV_LEFT.
          LV_LEFT = WA_ISSUE-AMOUNT - WA_ISSUE-LABST.
          UPDATE ZSCRAP
          SET SFLAG = 'X' "已售出
              LABST = LV_LEFT
          WHERE MATNR = WA_ISSUE-MATNR
            AND CHARG = WA_ISSUE-CHARG
            AND FLAG = C_RECEIVE " I
            .
          IF SY-SUBRC <> 0.
            LV_FLAG = 'X'.
            ROLLBACK WORK .
            EXIT.
          ENDIF.
        ELSE.
          "库存依旧有剩余
          CLEAR : LV_LEFT.
          LV_LEFT = WA_ISSUE-AMOUNT - WA_ISSUE-LABST.
          UPDATE ZSCRAP
             SET SFLAG = ''
                 LABST = LV_LEFT
             WHERE MATNR = WA_ISSUE-MATNR
               AND CHARG = WA_ISSUE-CHARG
               AND FLAG = C_RECEIVE " I
               .
          IF SY-SUBRC <> 0.
            LV_FLAG = 'X'.
            ROLLBACK WORK .
            EXIT.
          ENDIF.
        ENDIF.
      ENDLOOP.

      IF LV_FLAG = ''.
        COMMIT WORK.
        MESSAGE '已成功发货,操作完成!' TYPE 'S'.
        LEAVE TO SCREEN 0.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    " FRM_SELL_OUT
*&---------------------------------------------------------------------*
*&      Module  INIT_CONTAINER  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE INIT_CONTAINER OUTPUT.
  IF GV_GRID1 IS INITIAL.
* Object for container1
    CREATE OBJECT GV_CONTAINER1
      EXPORTING
        CONTAINER_NAME              = 'CONTAINER1'
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5
        OTHERS                      = 6.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
* Object for Alv grid1
    CREATE OBJECT GV_GRID1
      EXPORTING
        I_PARENT          = GV_CONTAINER1
      EXCEPTIONS
        ERROR_CNTL_CREATE = 1
        ERROR_CNTL_INIT   = 2
        ERROR_CNTL_LINK   = 3
        ERROR_DP_CREATE   = 4
        OTHERS            = 5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.

  IF GV_GRID2 IS INITIAL.
* Object for container1
    CREATE OBJECT GV_CONTAINER2
      EXPORTING
        CONTAINER_NAME              = 'CONTAINER2'
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5
        OTHERS                      = 6.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
* Object for Alv grid1
    CREATE OBJECT GV_GRID2
      EXPORTING
        I_PARENT          = GV_CONTAINER2
      EXCEPTIONS
        ERROR_CNTL_CREATE = 1
        ERROR_CNTL_INIT   = 2
        ERROR_CNTL_LINK   = 3
        ERROR_DP_CREATE   = 4
        OTHERS            = 5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.

  IF GV_GRID3 IS INITIAL.
* Object for container1
    CREATE OBJECT GV_CONTAINER3
      EXPORTING
        CONTAINER_NAME              = 'CONTAINER3'
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5
        OTHERS                      = 6.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
* Object for Alv grid1
    CREATE OBJECT GV_GRID3
      EXPORTING
        I_PARENT          = GV_CONTAINER3
      EXCEPTIONS
        ERROR_CNTL_CREATE = 1
        ERROR_CNTL_INIT   = 2
        ERROR_CNTL_LINK   = 3
        ERROR_DP_CREATE   = 4
        OTHERS            = 5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.

ENDMODULE.                 " INIT_CONTAINER  OUTPUT

*&---------------------------------------------------------------------*
*&      Form  FRM_FREE_CONTAINER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FRM_FREE_CONTAINER .
* Free the object of container
  IF  NOT GV_CONTAINER1 IS INITIAL
   OR NOT GV_CONTAINER2 IS INITIAL
   OR NOT GV_CONTAINER3 IS INITIAL.
    CALL METHOD GV_CONTAINER1->FREE
      EXCEPTIONS
        CNTL_SYSTEM_ERROR = 1
        CNTL_ERROR        = 2.

    CALL METHOD GV_CONTAINER2->FREE
      EXCEPTIONS
        CNTL_SYSTEM_ERROR = 1
        CNTL_ERROR        = 2.

    CALL METHOD GV_CONTAINER3->FREE
      EXCEPTIONS
        CNTL_SYSTEM_ERROR = 1
        CNTL_ERROR        = 2.

    CLEAR:
          GV_CONTAINER1,
          GV_CONTAINER2,
          GV_CONTAINER3,
          GV_GRID1,
          GV_GRID2,
          GV_GRID3.
  ENDIF.
ENDFORM.                    " FRM_FREE_CONTAINER
*&---------------------------------------------------------------------*
*&      Module  STATUS_0110  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0110 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0110  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  GET_RECEIVE  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_RECEIVE OUTPUT.
  DATA : LV_WA_IN TYPE T_SCRAP.
  DATA : LS_SORT1 TYPE LVC_S_SORT .

  SELECT *
    FROM ZSCRAP
    INTO CORRESPONDING FIELDS OF TABLE I_IN
    WHERE BUDAT BETWEEN GV_START AND GV_FINISH
      AND MATNR IN S_MATNR
      AND FLAG = C_RECEIVE.

  LOOP AT I_IN INTO LV_WA_IN.
    SELECT SINGLE MAKTX
        FROM MAKT
        INTO LV_WA_IN-MAKTX
        WHERE MATNR = LV_WA_IN-MATNR
          AND SPRAS = SY-LANGU.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        INPUT  = LV_WA_IN-MATNR
      IMPORTING
        OUTPUT = LV_WA_IN-MATNR.

    MODIFY I_IN FROM LV_WA_IN.
  ENDLOOP.

  REFRESH I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 1 'MATNR'  '废铜棉代码'    'C411'  10  ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 2 'MAKTX'  '描述'          ''  20  ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 3 'CHARG'  '批号'          ''  10  ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 4 'BUDAT'  '收货日期'      ''  10  ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 5 'WERKS'  '工厂'          ''  4   ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 6 'LGORT'  '库存地点'      ''  8   ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 7 'OABST'  '收获数量'      ''  15  'R'.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 8 'MEINS'  '单位'          ''  4   ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 9 'ERNAM'  '责任人'        ''  10  ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 10 'ERDAT' '处理日期'       ''  10  ''.
  APPEND WA_FCAT TO I_FCAT1.
  PERFORM FRM_ALV_FIELD USING 11 'ERZET' '处理时间'       ''  10  ''.
  APPEND WA_FCAT TO I_FCAT1.

  LOOP AT I_FCAT1 INTO WA_FCAT.
    IF WA_FCAT-FIELDNAME = 'MEINS'.
      WA_FCAT-REF_FIELD = 'MEINS'.
      WA_FCAT-REF_TABLE = 'ZSCRAP'.
    ENDIF.

    IF WA_FCAT-FIELDNAME = 'OABST'.
      WA_FCAT-QFIELDNAME = 'MEINS'.
      WA_FCAT-DO_SUM = 'X'.
    ENDIF.
    MODIFY I_FCAT1 FROM WA_FCAT.
  ENDLOOP.

  CLEAR : GV_LAYOUT1.
  GV_LAYOUT1-SEL_MODE = 'D'.
  GV_LAYOUT1-ZEBRA = 'X' .
*  GV_LAYOUT1-CTAB_FNAME = 'CELLCOLORS'.
*  GV_LAYOUT1-INFO_FNAME = 'ROWCOLOR'.
  GV_LAYOUT1-GRID_TITLE = '期间确认收货' .
  GV_LAYOUT1-SMALLTITLE = 'X' .

  CLEAR : LS_SORT1.
  LS_SORT1-SPOS = '1' .
  LS_SORT1-FIELDNAME = 'MATNR' .
  LS_SORT1-UP = 'X' .
  LS_SORT1-DOWN = SPACE .
  APPEND LS_SORT1 TO I_SORT1 .

  CLEAR : LS_SORT1.
  LS_SORT1-SPOS = '2' .
  LS_SORT1-FIELDNAME = 'MAKTX' .
  LS_SORT1-UP = 'X' .
  LS_SORT1-DOWN = SPACE .
  LS_SORT1-SUBTOT = 'X'.
  APPEND LS_SORT1 TO I_SORT1 .

*AVL的显示
  CALL METHOD GV_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      IS_LAYOUT                     = GV_LAYOUT1
      I_SAVE                        = 'A'
    CHANGING
      IT_OUTTAB                     = I_IN
      IT_FIELDCATALOG               = I_FCAT1
      IT_SORT                       = I_SORT1
    EXCEPTIONS
      INVALID_PARAMETER_COMBINATION = 1
      PROGRAM_ERROR                 = 2
      TOO_MANY_LINES                = 3
      OTHERS                        = 4.

ENDMODULE.                 " GET_RECEIVE  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  GET_ISSUE  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_ISSUE OUTPUT.
  DATA : LV_WA_OUT TYPE T_SCRAP.
  DATA : LS_SORT2 TYPE LVC_S_SORT .
  DATA :
        LV_I_VALUE TYPE STANDARD TABLE OF DD07V,
        LV_WA_DOMTAB TYPE DD07V.

*出库区分域
  CALL FUNCTION 'DD_DOMVALUES_GET'
    EXPORTING
      DOMNAME        = 'ZSORT'
      TEXT           = 'X'
      LANGU          = SY-LANGU
    TABLES
      DD07V_TAB      = LV_I_VALUE
    EXCEPTIONS                                              "#EC FB_RC
      WRONG_TEXTFLAG = 1
      OTHERS         = 2.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  SELECT *
    FROM ZSCRAP
    INTO CORRESPONDING FIELDS OF TABLE I_OUT
    WHERE BUDAT BETWEEN GV_START AND GV_FINISH
      AND MATNR IN S_MATNR
      AND FLAG = C_ISSUE.

  LOOP AT I_OUT INTO LV_WA_OUT.
    CLEAR LV_WA_DOMTAB.
    READ TABLE LV_I_VALUE INTO LV_WA_DOMTAB
    WITH KEY DOMVALUE_L = LV_WA_OUT-SORT.
    IF SY-SUBRC = 0.
      LV_WA_OUT-TEXT = LV_WA_DOMTAB-DDTEXT.
    ENDIF.

    SELECT SINGLE MAKTX
        FROM MAKT
        INTO LV_WA_OUT-MAKTX
        WHERE MATNR = LV_WA_OUT-MATNR
          AND SPRAS = SY-LANGU.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        INPUT  = LV_WA_OUT-MATNR
      IMPORTING
        OUTPUT = LV_WA_OUT-MATNR.

    IF LV_WA_OUT-LIFNR IS NOT INITIAL.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = LV_WA_OUT-LIFNR
        IMPORTING
          OUTPUT = LV_WA_OUT-LIFNR.

      SELECT SINGLE NAME1
        FROM LFA1
        INTO LV_WA_OUT-NAME1
        WHERE LIFNR = LV_WA_OUT-LIFNR
          AND SPRAS = SY-LANGU.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = LV_WA_OUT-LIFNR
        IMPORTING
          OUTPUT = LV_WA_OUT-LIFNR.
    ENDIF.

    MODIFY I_OUT FROM LV_WA_OUT.
  ENDLOOP.

  REFRESH I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 1 'MATNR'  '废铜棉代码'    'C411'  10  ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 2 'MAKTX'  '描述'          ''  20  ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 3 'CHARG'  '批号'          ''  10  ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 4 'BUDAT'  '出库日期'      ''  10  ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 5 'TEXT'  '出库区分'      ''  10  ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 6 'WERKS'  '工厂'          ''  4   ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 7 'LGORT'  '库存地点'      ''  8   ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 8 'LABST'  '出库数量'      ''  15  'R'.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 9 'SABST'  '预计收货'      ''  15  'R'.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 10 'MEINS'  '单位'         ''  4   ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 11 'STPRS'  '标准价格'     ''  10   'R'.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 12 'PEINH'  '价格单位'      ''  6   'R'.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 13 'TOTAL'  '金额'          ''  15   'R'.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 14 'WAERS'  '货币'          ''  4   ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 15 'NAME1'  '供应商'        ''  30   ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 16 'ERNAM'  '责任人'        ''  10  ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 17 'ERDAT' '处理日期'       ''  10  ''.
  APPEND WA_FCAT TO I_FCAT2.
  PERFORM FRM_ALV_FIELD USING 18 'ERZET' '处理时间'       ''  10  ''.
  APPEND WA_FCAT TO I_FCAT2.

  LOOP AT I_FCAT2 INTO WA_FCAT.
    IF WA_FCAT-FIELDNAME = 'MEINS'.
      WA_FCAT-REF_FIELD = 'MEINS'.
      WA_FCAT-REF_TABLE = 'ZSCRAP'.
    ENDIF.

    IF WA_FCAT-FIELDNAME = 'LABST'
      OR WA_FCAT-FIELDNAME = 'SABST'.
      WA_FCAT-QFIELDNAME = 'MEINS'.
      WA_FCAT-DO_SUM = 'X'.
    ENDIF.

    IF WA_FCAT-FIELDNAME = 'WAERS'.
      WA_FCAT-REF_FIELD = 'WAERS'.
      WA_FCAT-REF_TABLE = 'ZSCRAP'.
    ENDIF.

    IF WA_FCAT-FIELDNAME = 'TOTAL'.
      WA_FCAT-QFIELDNAME = 'WAERS'.
      WA_FCAT-DO_SUM = 'X'.
    ENDIF.

    IF WA_FCAT-FIELDNAME = 'LABST'
      OR WA_FCAT-FIELDNAME = 'SABST'
      OR WA_FCAT-FIELDNAME = 'TOTAL'
      OR WA_FCAT-FIELDNAME = 'STPRS'
      OR WA_FCAT-FIELDNAME = 'PEINH'.
      WA_FCAT-NO_ZERO = 'X'.
    ENDIF.

    MODIFY I_FCAT2 FROM WA_FCAT.
  ENDLOOP.

  CLEAR : GV_LAYOUT2.
  GV_LAYOUT2-SEL_MODE = 'D'.
  GV_LAYOUT2-ZEBRA = 'X' .
  GV_LAYOUT2-GRID_TITLE = '期间售出库存' .
  GV_LAYOUT2-SMALLTITLE = 'X' .

  CLEAR : LS_SORT2.
  LS_SORT2-SPOS = '1' .
  LS_SORT2-FIELDNAME = 'MATNR' .
  LS_SORT2-UP = 'X' .
  LS_SORT2-DOWN = SPACE .
  APPEND LS_SORT2 TO I_SORT2 .

  CLEAR : LS_SORT2.
  LS_SORT2-SPOS = '2' .
  LS_SORT2-FIELDNAME = 'MAKTX' .
  LS_SORT2-UP = 'X' .
  LS_SORT2-DOWN = SPACE .
  LS_SORT2-SUBTOT = 'X'.
  APPEND LS_SORT2 TO I_SORT2 .

*AVL的显示
  CALL METHOD GV_GRID2->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      IS_LAYOUT                     = GV_LAYOUT2
      I_SAVE                        = 'A'
    CHANGING
      IT_OUTTAB                     = I_OUT
      IT_FIELDCATALOG               = I_FCAT2
      IT_SORT                       = I_SORT2
    EXCEPTIONS
      INVALID_PARAMETER_COMBINATION = 1
      PROGRAM_ERROR                 = 2
      TOO_MANY_LINES                = 3
      OTHERS                        = 4.
ENDMODULE.                 " GET_ISSUE  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  GET_LEFT  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_LEFT OUTPUT.
  DATA : LV_WA_LEFT TYPE T_SCRAP.
  DATA : LS_SORT3 TYPE LVC_S_SORT .

  SELECT *
      FROM ZSCRAP
      INTO CORRESPONDING FIELDS OF TABLE I_LEFT
      WHERE BUDAT BETWEEN GV_START AND GV_FINISH
        AND MATNR IN S_MATNR
        AND FLAG = C_RECEIVE
        AND SFLAG = ''.

  LOOP AT I_LEFT INTO LV_WA_LEFT.
    SELECT SINGLE MAKTX
        FROM MAKT
        INTO LV_WA_LEFT-MAKTX
        WHERE MATNR = LV_WA_LEFT-MATNR
          AND SPRAS = SY-LANGU.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        INPUT  = LV_WA_LEFT-MATNR
      IMPORTING
        OUTPUT = LV_WA_LEFT-MATNR.

    MODIFY I_LEFT FROM LV_WA_LEFT.
  ENDLOOP.

  REFRESH I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 1 'MATNR'  '废铜棉代码'    'C411'  10  ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 2 'MAKTX'  '描述'          ''  20  ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 3 'CHARG'  '批号'          ''  10  ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 4 'BUDAT'  '收货日期'      ''  10  ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 5 'WERKS'  '工厂'          ''  4   ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 6 'LGORT'  '库存地点'      ''  8   ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 7 'LABST'  '数量'          ''  15  'R'.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 8 'MEINS'  '单位'          ''  4   ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 9 'ERNAM'  '责任人'        ''  10  ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 10 'ERDAT' '处理日期'       ''  10  ''.
  APPEND WA_FCAT TO I_FCAT3.
  PERFORM FRM_ALV_FIELD USING 11 'ERZET' '处理时间'       ''  10  ''.
  APPEND WA_FCAT TO I_FCAT3.

  LOOP AT I_FCAT3 INTO WA_FCAT.
    IF WA_FCAT-FIELDNAME = 'MEINS'.
      WA_FCAT-REF_FIELD = 'MEINS'.
      WA_FCAT-REF_TABLE = 'ZSCRAP'.
    ENDIF.

    IF WA_FCAT-FIELDNAME = 'LABST'.
      WA_FCAT-QFIELDNAME = 'MEINS'.
      WA_FCAT-DO_SUM = 'X'.
    ENDIF.
    MODIFY I_FCAT3 FROM WA_FCAT.
  ENDLOOP.

  CLEAR : GV_LAYOUT3.
  GV_LAYOUT3-SEL_MODE = 'D'.
  GV_LAYOUT3-ZEBRA = 'X' .
  GV_LAYOUT3-GRID_TITLE = '期间结余存货' .
  GV_LAYOUT3-SMALLTITLE = 'X' .

  CLEAR : LS_SORT3.
  LS_SORT3-SPOS = '1' .
  LS_SORT3-FIELDNAME = 'MATNR' .
  LS_SORT3-UP = 'X' .
  LS_SORT3-DOWN = SPACE .
  APPEND LS_SORT3 TO I_SORT3 .

  CLEAR : LS_SORT3.
  LS_SORT3-SPOS = '2' .
  LS_SORT3-FIELDNAME = 'MAKTX' .
  LS_SORT3-UP = 'X' .
  LS_SORT3-DOWN = SPACE .
  LS_SORT3-SUBTOT = 'X'.
  APPEND LS_SORT3 TO I_SORT3 .

*AVL的显示
  CALL METHOD GV_GRID3->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      IS_LAYOUT                     = GV_LAYOUT3
      I_SAVE                        = 'A'
    CHANGING
      IT_OUTTAB                     = I_LEFT
      IT_FIELDCATALOG               = I_FCAT3
      IT_SORT                       = I_SORT3
    EXCEPTIONS
      INVALID_PARAMETER_COMBINATION = 1
      PROGRAM_ERROR                 = 2
      TOO_MANY_LINES                = 3
      OTHERS                        = 4.
ENDMODULE.                 " GET_LEFT  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  alv_field
*&---------------------------------------------------------------------*
*       设置ALV显示属性
*----------------------------------------------------------------------*
*      -->COL_POS    text
*      -->FIELDNAME  text
*      -->COLTEXT    text
*      -->SELTEXT    text
*      -->EMPHASIZE  text
*----------------------------------------------------------------------*
FORM FRM_ALV_FIELD  USING COL_POS
                      FIELDNAME
                      COLTEXT
                      EMPHASIZE
                      LENGTH
                      JUST.
  CLEAR WA_FCAT.
  WA_FCAT-COL_POS = COL_POS.
  WA_FCAT-FIELDNAME = FIELDNAME.
  WA_FCAT-COLTEXT = COLTEXT.
  WA_FCAT-EMPHASIZE = EMPHASIZE.
  WA_FCAT-OUTPUTLEN = LENGTH.
  WA_FCAT-JUST = JUST.
ENDFORM.                    " frm_alv_field
*&---------------------------------------------------------------------*
*&      Form  GET_CURRENT_STOCK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_CURRENT_STOCK .
  DATA : LV_WA_STOCK TYPE T_SCRAP.

  SELECT *
      FROM ZSCRAP
      INTO CORRESPONDING FIELDS OF TABLE I_STOCK
      WHERE FLAG = C_RECEIVE
        AND SFLAG = ''.

  LOOP AT I_STOCK INTO LV_WA_STOCK.
    SELECT SINGLE MAKTX
        FROM MAKT
        INTO LV_WA_STOCK-MAKTX
        WHERE MATNR = LV_WA_STOCK-MATNR
          AND SPRAS = SY-LANGU.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        INPUT  = LV_WA_STOCK-MATNR
      IMPORTING
        OUTPUT = LV_WA_STOCK-MATNR.

    MODIFY I_STOCK FROM LV_WA_STOCK.
  ENDLOOP.

  SORT I_STOCK BY MATNR CHARG.

  DELETE I_STOCK WHERE LABST = 0.

ENDFORM.                    " GET_CURRENT_STOCK
*&---------------------------------------------------------------------*
*&      Form  FRM_SHOW_STOCK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_SHOW_STOCK .
  DATA:
          L_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          L_COL_POS  TYPE I,
          L_SORT TYPE SLIS_SORTINFO_ALV,
          LV_REPID LIKE SY-REPID.

  IF P_R7 = 'X'.
    CLEAR L_FIELDCAT.
    L_COL_POS = L_FIELDCAT-COL_POS + 1.
    L_FIELDCAT-FIELDNAME = 'MARK'.
    L_FIELDCAT-SELTEXT_M = '选择'.
    L_FIELDCAT-OUTPUTLEN = 8.
    L_FIELDCAT-CHECKBOX = 'X'.
    APPEND L_FIELDCAT TO I_FIELDCATS.
  ENDIF.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'MAKTX'.
  L_FIELDCAT-SELTEXT_M = '废铜棉'.
  L_FIELDCAT-OUTPUTLEN = 20.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'MATNR'.
  L_FIELDCAT-SELTEXT_M = '物料代码'.
  L_FIELDCAT-OUTPUTLEN = 10.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'CHARG'.
  L_FIELDCAT-SELTEXT_M = '批号'.
  L_FIELDCAT-OUTPUTLEN = 10.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'BUDAT'.
  L_FIELDCAT-SELTEXT_M = '收货日期'.
  L_FIELDCAT-OUTPUTLEN = 10.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'WERKS'.
  L_FIELDCAT-SELTEXT_M = '工厂'.
  L_FIELDCAT-OUTPUTLEN = 4.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'LGORT'.
  L_FIELDCAT-SELTEXT_M = '库存地点'.
  L_FIELDCAT-OUTPUTLEN = 8.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'LABST'.
  L_FIELDCAT-SELTEXT_M = '数量'.
  L_FIELDCAT-OUTPUTLEN = 15.
  L_FIELDCAT-JUST = 'R'.
  L_FIELDCAT-DO_SUM = 'X'.
  L_FIELDCAT-QFIELDNAME = 'MEINS'.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'MEINS'.
  L_FIELDCAT-SELTEXT_M = '单位'.
  L_FIELDCAT-OUTPUTLEN = 4.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'REMARK'.
  L_FIELDCAT-SELTEXT_M = '备注'.
  L_FIELDCAT-OUTPUTLEN = 30.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'ERNAM'.
  L_FIELDCAT-SELTEXT_M = '责任人'.
  L_FIELDCAT-OUTPUTLEN = 10.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'ERDAT'.
  L_FIELDCAT-SELTEXT_M = '处理日期'.
  L_FIELDCAT-OUTPUTLEN = 12.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  CLEAR L_FIELDCAT.
  L_COL_POS = L_FIELDCAT-COL_POS + 1.
  L_FIELDCAT-FIELDNAME = 'ERZET'.
  L_FIELDCAT-SELTEXT_M = '处理时间'.
  L_FIELDCAT-OUTPUTLEN = 10.
  APPEND L_FIELDCAT TO I_FIELDCATS.

  GV_LAYOUT-GET_SELINFOS = 'X'.
  GV_LAYOUT-F2CODE = '&ETA'.
  GV_LAYOUT-EDIT_MODE = 'D'.
  GV_LAYOUT-DETAIL_POPUP = 'X'.
  GV_LAYOUT-DETAIL_TITLEBAR = '详细内容' .
  IF P_R4 = 'X'.
    GV_LAYOUT-WINDOW_TITLEBAR = '当前库存'.
  ELSEIF P_R7 = 'X'.
    GV_LAYOUT-WINDOW_TITLEBAR = '物料批次合并'.
  ENDIF.

  IF P_R4 = 'X'.
    L_SORT-FIELDNAME = 'MAKTX'.
    L_SORT-SPOS      = 1.
    L_SORT-UP        = 'X'.
    L_SORT-DOWN      = ''.
    L_SORT-SUBTOT    = 'X'.
    L_SORT-EXPA      = 'X'.
    APPEND L_SORT TO I_SORT.
  ENDIF.

*Display
  LV_REPID = SY-REPID.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
*         i_interface_check        = 'X'
             I_CALLBACK_PROGRAM       = LV_REPID
             I_CALLBACK_PF_STATUS_SET = 'ALV_PF_STATUS_SET'
             I_CALLBACK_USER_COMMAND  = 'ALV_USER_COMMAND'
             I_CALLBACK_TOP_OF_PAGE   = 'TOP-OF-PAGE'
*         I_STRUCTURE_NAME         =
             IS_LAYOUT                = GV_LAYOUT
             IT_FIELDCAT              = I_FIELDCATS
*         IT_EXCLUDING             =
*         IT_SPECIAL_GROUPS        =
             IT_SORT                  = I_SORT
*         IT_FILTER                =
*         IS_SEL_HIDE              =
*         I_DEFAULT                = 'X'
             I_SAVE                   = 'A'
*           IS_VARIANT               = IS_VARIANT
             IT_EVENTS                = I_EVENT
        TABLES
             T_OUTTAB                 = I_STOCK
        EXCEPTIONS
             PROGRAM_ERROR            = 1
             OTHERS                   = 2
             .
  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_STOCK
*---------------------------------------------------------------------*
*       FORM ALV_PF_STATUS_SET
*---------------------------------------------------------------------*
FORM ALV_PF_STATUS_SET
USING RT_EXTAB TYPE SLIS_T_EXTAB.
  IF P_R4 = 'X'.
    APPEND 'COMBIN' TO RT_EXTAB.
    APPEND 'REFRESH' TO RT_EXTAB.
    SET PF-STATUS 'STANDARD_TOOLS' EXCLUDING RT_EXTAB.
  ELSEIF P_R7 = 'X'.
    SET PF-STATUS 'STANDARD_TOOLS'." EXCLUDING RT_EXTAB.
  ENDIF.
ENDFORM.                    "alv_pf_status_set
*---------------------------------------------------------------------*
*       FORM ALV_USER_COMMAND
*---------------------------------------------------------------------*
FORM ALV_USER_COMMAND
                  USING R_UCOMM LIKE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.
  DATA : LV_NUM TYPE I.

  IF R_UCOMM = 'COMBIN'.
    CLEAR LV_NUM.
    DESCRIBE TABLE I_STOCK LINES LV_NUM.
    IF LV_NUM <= 1.
      MESSAGE '记录数小于等于1条,无需合并批次!' TYPE 'I'.
    ELSE.
      CLEAR : ZSCRAP.
      CALL SCREEN 9009 STARTING AT 20 15 ENDING AT 100 25.
    ENDIF.
  ELSEIF R_UCOMM = 'REFRESH'.
    PERFORM FRM_GET_MERGE_INFO.
    RS_SELFIELD-REFRESH = 'X'"设置刷新标记
  ENDIF.

ENDFORM.                    "alv_user_command
*&---------------------------------------------------------------------*
*&      Form  TOP-OF-PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM TOP-OF-PAGE.

  CLEAR: T_HEADER, WA_HEADER.
  WA_HEADER-TYP = 'H'.
  IF P_R4 = 'X'.
    WA_HEADER-INFO = '废铜棉库存一览'.
  ELSEIF P_R7 = 'X'.
    WA_HEADER-INFO = '待批次合并的物料库存一览'.
  ENDIF.
  APPEND WA_HEADER TO T_HEADER.

  CLEAR: WA_HEADER.
  WA_HEADER-TYP = 'S'.
  WA_HEADER-KEY = '公司:'.
  WA_HEADER-INFO = GV_NAME.
  APPEND WA_HEADER TO T_HEADER.

  CLEAR: WA_HEADER.
  WA_HEADER-TYP = 'S'.
  WA_HEADER-KEY = '单位:'.
  WA_HEADER-INFO = 'KG'.
  APPEND WA_HEADER TO T_HEADER.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY       = T_HEADER
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .
ENDFORM.                    "TOP-OF-PAGE
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_LISTBOX
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_SET_LISTBOX .
  DATA :
            LV_I_LIST TYPE VRM_VALUES,
            LV_WA_LIST LIKE LINE OF LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3010300000'.
  LV_WA_LIST-TEXT =  '粉碎黄铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3010400000'.
  LV_WA_LIST-TEXT =  '粉碎紫铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3100100000'.
  LV_WA_LIST-TEXT =  '振切紫铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3100300000'.
  LV_WA_LIST-TEXT =  '振切青铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3100900000'.
  LV_WA_LIST-TEXT =  '低值废铜棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = 'WA_ISSUE-MATNR'
      VALUES          = LV_I_LIST
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.
  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_SET_LISTBOX
*&---------------------------------------------------------------------*
*&      Form  FRM_F4_HELP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_F4_HELP .
  DATA :
        WA_SEARCH TYPE T_SHLP_MATNR.

  IF I_SEARCH_M IS INITIAL.
    CLEAR : WA_SEARCH.
    WA_SEARCH-MATNR = '3010300000'.
    APPEND WA_SEARCH TO I_SEARCH_M .

    CLEAR : WA_SEARCH.
    WA_SEARCH-MATNR = '3010400000'.
    APPEND WA_SEARCH TO I_SEARCH_M .

    CLEAR : WA_SEARCH.
    WA_SEARCH-MATNR = '3100100000'.
    APPEND WA_SEARCH TO I_SEARCH_M .

    CLEAR : WA_SEARCH.
    WA_SEARCH-MATNR = '3100300000'.
    APPEND WA_SEARCH TO I_SEARCH_M .

    CLEAR : WA_SEARCH.
    WA_SEARCH-MATNR = '3100900000'.
    APPEND WA_SEARCH TO I_SEARCH_M .

    LOOP AT I_SEARCH_M INTO WA_SEARCH.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = WA_SEARCH-MATNR
        IMPORTING
          OUTPUT = WA_SEARCH-MATNR.
      SELECT SINGLE MAKTX
        FROM MAKT
        INTO WA_SEARCH-MAKTX
        WHERE MATNR = WA_SEARCH-MATNR
          AND SPRAS = SY-LANGU.

      SELECT SINGLE WERKS
        FROM MARD
        INTO WA_SEARCH-WERKS
        WHERE MATNR = WA_SEARCH-MATNR.

      MODIFY I_SEARCH_M FROM WA_SEARCH.
    ENDLOOP.
  ENDIF.


  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        RETFIELD         = 'MATNR'
        DYNPPROG         = SY-REPID
        DYNPNR           = SY-DYNNR
        DYNPROFIELD      = 'S_MATNR-LOW'
        VALUE_ORG        = 'S'
        CALLBACK_PROGRAM = SY-REPID
*      CALLBACK_FORM    = 'FRM_BO_CALLBACK1'
      TABLES
        VALUE_TAB        = I_SEARCH_M
*      RETURN_TAB       = IL_RETURN_TAB
      EXCEPTIONS                                            "#EC FB_RC
        PARAMETER_ERROR  = 1
        NO_VALUES_FOUND  = 2
        OTHERS           = 3.
  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_F4_HELP
*&---------------------------------------------------------------------*
*&      Module  STATUS_9002  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9002 OUTPUT.
  SET PF-STATUS '9002'.
  SET TITLEBAR 'TITLE' WITH '月末低值废铜棉的录入'.

  PERFORM FRM_SET_LISTBOX_MATNR.
  ZSCRAP-REMARK = '月末低值废铜棉的录入'.
  ZSCRAP-BUDAT = SY-DATUM.
ENDMODULE.                 " STATUS_9002  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9002  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9002 INPUT.
  CASE OK_CODE4.
    WHEN 'CANCEL'.
      LEAVE TO SCREEN 0.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
    WHEN 'ADD'.
      PERFORM FRM_ADD_RECORD.
    WHEN OTHERS.
  ENDCASE.
  CLEAR : OK_CODE4.

ENDMODULE.                 " USER_COMMAND_9002  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_ADD_RECORD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_ADD_RECORD .
  DATA :
        LV_WA_INSERT TYPE ZSCRAP.

  CLEAR LV_WA_INSERT.

  MOVE-CORRESPONDING ZSCRAP TO LV_WA_INSERT.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      INPUT  = LV_WA_INSERT-MATNR
    IMPORTING
      OUTPUT = LV_WA_INSERT-MATNR.

  LV_WA_INSERT-FLAG = C_RECEIVE.
  LV_WA_INSERT-OABST = LV_WA_INSERT-LABST. " 原始数量
  LV_WA_INSERT-WERKS = '1201'.
  LV_WA_INSERT-MEINS = 'KG'.
  LV_WA_INSERT-ERDAT = SY-DATUM.
  LV_WA_INSERT-ERZET = SY-UZEIT.
  LV_WA_INSERT-ERNAM = SY-UNAME.
  LV_WA_INSERT-SFLAG = ''.
  LV_WA_INSERT-WAERS = ''.
  LV_WA_INSERT-TOTAL = ''.
  LV_WA_INSERT-PEINH = ''.
  LV_WA_INSERT-STPRS = ''.

  INSERT ZSCRAP FROM LV_WA_INSERT.

  IF SY-SUBRC <> 0.
    ROLLBACK WORK.
    MESSAGE '记录插入失败!' TYPE 'S' DISPLAY LIKE 'E'.
  ELSE.
    COMMIT WORK.
    CLEAR : ZSCRAP.
    CLEAR LV_WA_INSERT.
    MESSAGE '记录插入成功!' TYPE 'S'.
  ENDIF.
ENDFORM.                    " FRM_ADD_RECORD

*&---------------------------------------------------------------------*
*&      Form  FRM_SET_LISTBOX_matnr
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FRM_SET_LISTBOX_MATNR .
  DATA :
            LV_I_LIST TYPE VRM_VALUES,
            LV_WA_LIST LIKE LINE OF LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3010300000'.
  LV_WA_LIST-TEXT =  '粉碎黄铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3010400000'.
  LV_WA_LIST-TEXT =  '粉碎紫铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3100100000'.
  LV_WA_LIST-TEXT =  '振切紫铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3100300000'.
  LV_WA_LIST-TEXT =  '振切青铜废棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CLEAR : LV_WA_LIST.
  LV_WA_LIST-KEY =  '3100900000'.
  LV_WA_LIST-TEXT =  '低值废铜棉'.
  APPEND LV_WA_LIST TO LV_I_LIST.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = 'ZSCRAP-MATNR'
      VALUES          = LV_I_LIST
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.
  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_SET_LISTBOX
*&---------------------------------------------------------------------*
*&      Module  STATUS_9007  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9007 OUTPUT.
  DATA :
         LV_INDEX TYPE I.

  SET PF-STATUS '9001'.
  SET TITLEBAR 'TITLE' WITH '外协加工'.

  PERFORM FRM_SET_LISTBOX.

*初始化
  IF GV_INFLAG2 = ''.
    GV_ISSDATE = SY-DATUM.
    GV_REMARK2 = '委外加工成原材料......'.
    GV_INFLAG2 = 'X'.
  ENDIF.

*输入一行确认后定位到下一行
  IF GV_ISSDATE IS NOT INITIAL.
    LV_INDEX = LINES( I_ISSUE ).
    LV_INDEX = LV_INDEX + 1.
    SET CURSOR FIELD 'WA_ISSUE-MATNR' LINE LV_INDEX.
  ENDIF.

ENDMODULE.                 " STATUS_9007  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9007  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9007 INPUT.
  CASE OK_CODE5.
*返回屏幕
    WHEN 'BACK' OR 'EXIT'.
      IF I_ISSUE IS NOT INITIAL.
        PERFORM FRM_POPUP_INFO USING TEXT-018 TEXT-011  CHANGING LV_RETURN.
        IF LV_RETURN = 'J'.
          LEAVE TO SCREEN 0.
        ENDIF.
      ELSE.
        LEAVE TO SCREEN 0.
      ENDIF.
*退出程序
    WHEN 'CANCEL'.
      IF I_ISSUE IS NOT INITIAL.
        PERFORM FRM_POPUP_INFO USING TEXT-018 TEXT-011  CHANGING LV_RETURN.
        IF LV_RETURN = 'J'.
          LEAVE PROGRAM.
        ENDIF.
      ELSE.
        LEAVE PROGRAM.
      ENDIF.
*确认委外
    WHEN 'SAVE' OR 'VERIFY'.
      PERFORM FRM_SUBCONTRACT.
*清空项目
    WHEN 'EMPTY'.
      PERFORM FRM_CLEAR_ITEMS.
*取消发货
    WHEN 'ABOLISH'.
      PERFORM FRM_CANCEL_ISSUE.
  ENDCASE.

  CLEAR : OK_CODE5.
ENDMODULE.                 " USER_COMMAND_9007  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_SUBCONTRACT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_SUBCONTRACT .
  DATA :
*函数返回标记
           LV_RETURN TYPE C,
*更新出错标记
           LV_FLAG TYPE C,
*剩余数量
           LV_LEFT TYPE ZLABST,
*插入行次
           LV_LINE TYPE ZLINES,
*处理工作区
           LV_WA_RECEIVE TYPE ZSCRAP.

  IF I_ISSUE IS NOT INITIAL.
    PERFORM FRM_POPUP_INFO USING TEXT-014 TEXT-011  CHANGING LV_RETURN.
    IF LV_RETURN = 'J'.
*售出纪录保存到数据库中----- 1、
      LOOP AT I_ISSUE INTO WA_ISSUE.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = WA_ISSUE-MATNR
          IMPORTING
            OUTPUT = WA_ISSUE-MATNR.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            INPUT  = WA_ISSUE-LIFNR
          IMPORTING
            OUTPUT = WA_ISSUE-LIFNR.
        "查看是否已经有售出或者委外记录
        CLEAR : LV_LINE.
        SELECT MAXLINE )
          FROM ZSCRAP
          INTO LV_LINE
          WHERE MATNR = WA_ISSUE-MATNR
            AND CHARG = WA_ISSUE-CHARG
            AND FLAG = C_ISSUE .
        IF SY-SUBRC <> 0 .
          WA_ISSUE-LINE = '01'.
        ELSE.
          WA_ISSUE-LINE = LV_LINE + 1.
        ENDIF.

        WA_ISSUE-BUDAT = GV_ISSDATE.
        WA_ISSUE-WERKS = C_PLANT.
        WA_ISSUE-FLAG  = C_ISSUE.
        WA_ISSUE-REMARK = GV_REMARK2.
        WA_ISSUE-ERDAT = SY-DATUM.
        WA_ISSUE-ERZET = SY-UZEIT.
        WA_ISSUE-ERNAM = SY-UNAME.
        "出库区分
        WA_ISSUE-SORT = '2'.

        MODIFY I_ISSUE FROM WA_ISSUE.
      ENDLOOP.

      INSERT ZSCRAP FROM TABLE I_ISSUE.
      IF SY-SUBRC <> 0.
        ROLLBACK WORK.
        EXIT.
      ENDIF.

      CLEAR : LV_FLAG.
*更新库存标示---------------- 2、
      LOOP AT I_ISSUE INTO WA_ISSUE.
        "库存已售出
        IF WA_ISSUE-AMOUNT = WA_ISSUE-LABST.
          CLEAR : LV_LEFT.
          LV_LEFT = WA_ISSUE-AMOUNT - WA_ISSUE-LABST.
          UPDATE ZSCRAP
          SET SFLAG = 'X'
              LABST = LV_LEFT
          WHERE MATNR = WA_ISSUE-MATNR
            AND CHARG = WA_ISSUE-CHARG
            AND FLAG = C_RECEIVE
            .
          IF SY-SUBRC <> 0.
            LV_FLAG = 'X'.
            ROLLBACK WORK .
            EXIT.
          ENDIF.
        ELSE.
          "库存依旧有剩余
          CLEAR : LV_LEFT.
          LV_LEFT = WA_ISSUE-AMOUNT - WA_ISSUE-LABST.
          UPDATE ZSCRAP
             SET SFLAG = ''
                 LABST = LV_LEFT
             WHERE MATNR = WA_ISSUE-MATNR
               AND CHARG = WA_ISSUE-CHARG
               AND FLAG = C_RECEIVE " I
               .
          IF SY-SUBRC <> 0.
            LV_FLAG = 'X'.
            ROLLBACK WORK .
            EXIT.
          ENDIF.
        ENDIF.
      ENDLOOP.

      IF LV_FLAG = ''.
        COMMIT WORK.
        MESSAGE '已成功发货,操作完成!' TYPE 'S'.
        LEAVE TO SCREEN 0.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    " FRM_SUBCONTRACT
*&---------------------------------------------------------------------*
*&      Form  CHECK_TBL3_INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CHECK_TBL3_INPUT .
  DATA:
           LV_CURRLINE TYPE I,
           WA_TEMP LIKE LINE OF I_ISSUE,
           LV_LINES TYPE I,
           LV_LIFNR TYPE LIFNR,
           LV_MATNR TYPE MATNR.

*光标位置
  LV_LINES = TBL3-CURRENT_LINE - TBL3-TOP_LINE + 1.

  LV_CURRLINE = TBL3-CURRENT_LINE - 1.

  LOOP AT I_ISSUE INTO WA_TEMP FROM TBL3-TOP_LINE TO LV_CURRLINE.
    IF WA_TEMP-MATNR = WA_ISSUE-MATNR AND WA_TEMP-CHARG = WA_ISSUE-CHARG.
      SET CURSOR FIELD 'WA_ISSUE-CHARG' LINE LV_LINES.
      MESSAGE '此记录已经存在表格中!' TYPE 'E'.
    ENDIF.
  ENDLOOP.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      INPUT  = WA_ISSUE-MATNR
    IMPORTING
      OUTPUT = LV_MATNR.

  SELECT SINGLE *
    FROM ZSCRAP
    WHERE MATNR = LV_MATNR
      AND CHARG = WA_ISSUE-CHARG
      AND FLAG = C_RECEIVE
      AND SFLAG = ''.
  IF SY-SUBRC <> 0.
    SET CURSOR FIELD 'WA_ISSUE-MATNR' LINE LV_LINES.
    MESSAGE '该项目不存在!' TYPE 'E'.
  ELSE.
    SELECT SINGLE MAKTX
      FROM MAKT
      INTO WA_ISSUE-MAKTX
      WHERE MATNR = LV_MATNR
        AND SPRAS = SY-LANGU.

    WA_ISSUE-LGORT = ZSCRAP-LGORT.
    WA_ISSUE-AMOUNT = ZSCRAP-LABST.
*    WA_ISSUE-LABST = ZSCRAP-LABST.
*    WA_ISSUE-SABST = WA_ISSUE-LABST * C_RATE.
    WA_ISSUE-MEINS = 'KG'.

    IF WA_ISSUE-LABST IS INITIAL.
      SET CURSOR FIELD 'WA_ISSUE-LABST' LINE LV_LINES.
      MESSAGE '请输入委外加工数量!' TYPE 'E'.
    ELSE.
      IF WA_ISSUE-LABST < 0  OR WA_ISSUE-LABST > WA_ISSUE-AMOUNT.
        SET CURSOR FIELD 'WA_ISSUE-LABST' LINE LV_LINES.
        MESSAGE '请输入合理的委外加工数量!' TYPE 'E'.
      ELSE.
        WA_ISSUE-SABST = WA_ISSUE-LABST * C_RATE.           " 0.93
      ENDIF.
    ENDIF.


    IF WA_ISSUE-LIFNR IS NOT INITIAL.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = WA_ISSUE-LIFNR
        IMPORTING
          OUTPUT = LV_LIFNR.

      SELECT SINGLE NAME1
        FROM LFA1
        INTO WA_ISSUE-NAME1
        WHERE LIFNR = LV_LIFNR
          AND SPRAS = SY-LANGU.
      IF SY-SUBRC <> 0.
        SET CURSOR FIELD 'WA_ISSUE-LIFNR' LINE LV_LINES.
        MESSAGE '请输入正确的外委供应商代码!' TYPE 'E'.
      ENDIF.
    ELSE.
      SET CURSOR FIELD 'WA_ISSUE-LIFNR' LINE LV_LINES.
      MESSAGE '请输入外委供应商代码!' TYPE 'E'.
    ENDIF.
  ENDIF.
ENDFORM.                    " CHECK_TBL3_INPUT

*&---------------------------------------------------------------------*
*&      Module  F4_HELP_DATE  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE F4_HELP_DATE INPUT.
  CALL FUNCTION 'F4_DATE'
   EXPORTING
     DATE_FOR_FIRST_MONTH               = SY-DATUM
*   DISPLAY                            = ' '
*   FACTORY_CALENDAR_ID                = ' '
*   GREGORIAN_CALENDAR_FLAG            = ' '
*   HOLIDAY_CALENDAR_ID                = ' '
*   PROGNAME_FOR_FIRST_MONTH           = ' '
   IMPORTING
     SELECT_DATE                        = GV_ISSDATE
*   SELECT_WEEK                        =
*   SELECT_WEEK_BEGIN                  =
*   SELECT_WEEK_END                    =
   EXCEPTIONS
     CALENDAR_BUFFER_NOT_LOADABLE       = 1
     DATE_AFTER_RANGE                   = 2
     DATE_BEFORE_RANGE                  = 3
     DATE_INVALID                       = 4
     FACTORY_CALENDAR_NOT_FOUND         = 5
     HOLIDAY_CALENDAR_NOT_FOUND         = 6
     PARAMETER_CONFLICT                 = 7
     OTHERS                             = 8
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDMODULE.                 " F4_HELP_DATE  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_F4_DATE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_F4_DATE1 .
*年月的搜索帮助
  DATA:L_DATE TYPE SY-DATUM.

  CALL FUNCTION 'F4_DATE'
    EXPORTING
      DATE_FOR_FIRST_MONTH         = SY-DATUM
    IMPORTING
      SELECT_DATE                  = L_DATE
    EXCEPTIONS
      CALENDAR_BUFFER_NOT_LOADABLE = 1
      DATE_AFTER_RANGE             = 2
      DATE_BEFORE_RANGE            = 3
      DATE_INVALID                 = 4
      FACTORY_CALENDAR_NOT_FOUND   = 5
      HOLIDAY_CALENDAR_NOT_FOUND   = 6
      PARAMETER_CONFLICT           = 7
      OTHERS                       = 8.

  IF SY-SUBRC = 0.
    S_MONTH-LOW = L_DATE+0(6).
  ENDIF.
ENDFORM.                    " FRM_F4_DATE
*&---------------------------------------------------------------------*
*&      Form  FRM_F4_DATE2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_F4_DATE2 .
*年月的搜索帮助
  DATA:L_DATE TYPE SY-DATUM.

  CALL FUNCTION 'F4_DATE'
    EXPORTING
      DATE_FOR_FIRST_MONTH         = SY-DATUM
    IMPORTING
      SELECT_DATE                  = L_DATE
    EXCEPTIONS
      CALENDAR_BUFFER_NOT_LOADABLE = 1
      DATE_AFTER_RANGE             = 2
      DATE_BEFORE_RANGE            = 3
      DATE_INVALID                 = 4
      FACTORY_CALENDAR_NOT_FOUND   = 5
      HOLIDAY_CALENDAR_NOT_FOUND   = 6
      PARAMETER_CONFLICT           = 7
      OTHERS                       = 8.

  IF SY-SUBRC = 0.
    S_MONTH-HIGH = L_DATE+0(6).
  ENDIF.
ENDFORM.                    " FRM_F4_DATE2
*&---------------------------------------------------------------------*
*&      Module  F4_HELP_DATE1  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE F4_HELP_DATE1 INPUT.
  CALL FUNCTION 'F4_DATE'
     EXPORTING
       DATE_FOR_FIRST_MONTH               = SY-DATUM
*   DISPLAY                            = ' '
*   FACTORY_CALENDAR_ID                = ' '
*   GREGORIAN_CALENDAR_FLAG            = ' '
*   HOLIDAY_CALENDAR_ID                = ' '
*   PROGNAME_FOR_FIRST_MONTH           = ' '
     IMPORTING
       SELECT_DATE                        = GV_RECDATE
*   SELECT_WEEK                        =
*   SELECT_WEEK_BEGIN                  =
*   SELECT_WEEK_END                    =
     EXCEPTIONS
       CALENDAR_BUFFER_NOT_LOADABLE       = 1
       DATE_AFTER_RANGE                   = 2
       DATE_BEFORE_RANGE                  = 3
       DATE_INVALID                       = 4
       FACTORY_CALENDAR_NOT_FOUND         = 5
       HOLIDAY_CALENDAR_NOT_FOUND         = 6
       PARAMETER_CONFLICT                 = 7
       OTHERS                             = 8
              .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDMODULE.                 " F4_HELP_DATE1  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_WRITEOFF_RECEIVE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRITEOFF_RECEIVE .
  DATA : LV_WA_WF TYPE T_SCRAP.
  CLEAR : GV_WFMESSAGE.

  SELECT *
    FROM ZSCRAP
    INTO CORRESPONDING FIELDS OF TABLE I_WF
    WHERE MATNR IN S_MATNR
      AND CHARG IN S_CHARG.
  IF SY-SUBRC <> 0.
    REFRESH I_WF.
    GV_WFMESSAGE = TEXT-023.
    EXIT.
  ELSE.
    READ TABLE I_WF INTO LV_WA_WF WITH KEY FLAG = 'O'.
    IF SY-SUBRC = 0.
      REFRESH I_WF.
      GV_WFMESSAGE = TEXT-024.
      EXIT.
    ENDIF.
  ENDIF.

  LOOP AT I_WF INTO LV_WA_WF.
    SELECT SINGLE MAKTX
      FROM MAKT
      INTO LV_WA_WF-MAKTX
      WHERE MATNR = LV_WA_WF-MATNR
        AND SPRAS = SY-LANGU.
    MODIFY  I_WF FROM LV_WA_WF.
  ENDLOOP.

ENDFORM.                    " FRM_WRITEOFF_RECEIVE
*&---------------------------------------------------------------------*
*&      Module  STATUS_9008  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9008 OUTPUT.
  SET PF-STATUS '9008'.
  SET TITLEBAR 'TITLE' WITH TEXT-025.

ENDMODULE.                 " STATUS_9008  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9008  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9008 INPUT.
  CASE OK_CODE6.
    WHEN 'SAVE'  OR 'WF'.
      PERFORM FRM_CONFIRM_WRITEOFF.
    WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
      LEAVE TO SCREEN 0.
    WHEN OTHERS .

  ENDCASE.
  CLEAR OK_CODE6.
ENDMODULE.                 " USER_COMMAND_9008  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_CONFIRM_WRITEOFF
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CONFIRM_WRITEOFF .
  DATA : LV_RETURN TYPE C.
  READ TABLE I_WF INTO WA_WF WITH KEY MARK = 'X'.
  IF SY-SUBRC <> 0.
    MESSAGE '请选中需要冲销的行项目!' TYPE 'I'.
    EXIT.
  ELSE.

  ENDIF.

  PERFORM FRM_POPUP_INFO USING TEXT-026 TEXT-011  CHANGING LV_RETURN.
  IF LV_RETURN = 'J'.
    "从数据库中删除此条记录
    DELETE FROM ZSCRAP WHERE MATNR = WA_WF-MATNR
                         AND CHARG = WA_WF-CHARG
                         AND BUDAT = WA_WF-BUDAT
                         AND FLAG = 'I'.
    IF SY-SUBRC = 0.
      COMMIT WORK .
      MESSAGE '冲销成功!' TYPE 'S'.
      LEAVE TO SCREEN 0.
    ELSE.
      ROLLBACK WORK .
      MESSAGE '冲销失败!'  TYPE 'I'.
    ENDIF.
  ENDIF.
ENDFORM.                    " FRM_CONFIRM_WRITEOFF
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_MERGE_INFO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_GET_MERGE_INFO .
  DATA : LV_WA_STOCK TYPE T_SCRAP.

  SELECT *
      FROM ZSCRAP
      INTO CORRESPONDING FIELDS OF TABLE I_STOCK
      WHERE FLAG = C_RECEIVE
        AND SFLAG = ''
        AND MATNR IN S_MATNR
        AND LGORT IN S_LGORT.

  LOOP AT I_STOCK INTO LV_WA_STOCK.

    SELECT SINGLE MAKTX
        FROM MAKT
        INTO LV_WA_STOCK-MAKTX
        WHERE MATNR = LV_WA_STOCK-MATNR
          AND SPRAS = SY-LANGU.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        INPUT  = LV_WA_STOCK-MATNR
      IMPORTING
        OUTPUT = LV_WA_STOCK-MATNR.

    LV_WA_STOCK-MARK = 'X'.

    MODIFY I_STOCK FROM LV_WA_STOCK.
  ENDLOOP.

  SORT I_STOCK BY MATNR CHARG.

  DELETE I_STOCK WHERE LABST = 0.
ENDFORM.                    " FRM_GET_MERGE_INFO
*&---------------------------------------------------------------------*
*&      Module  STATUS_9009  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9009 OUTPUT.
  DATA : LV_WA_STOCK TYPE T_SCRAP.
  DATA : LV_LABST TYPE ZLABST.

  SET PF-STATUS '9009'.
  SET TITLEBAR 'TITLE' WITH '物料批次的合并'.

*  CLEAR : ZSCRAP.
  ZSCRAP-ERDAT = SY-DATUM.
  ZSCRAP-ERZET = SY-UZEIT.
  ZSCRAP-ERNAM = SY-UNAME.
  ZSCRAP-REMARK = '物料批次合并行记录'.

  READ TABLE I_STOCK INTO LV_WA_STOCK INDEX 1.
  ZSCRAP-MATNR = LV_WA_STOCK-MATNR.
  CLEAR LV_LABST.
  LOOP AT I_STOCK INTO LV_WA_STOCK.
    LV_LABST = LV_LABST + LV_WA_STOCK-LABST.
  ENDLOOP.
  ZSCRAP-LABST = LV_LABST.

ENDMODULE.                 " STATUS_9009  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9009  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9009 INPUT.
  CASE OK_CODE7.
    WHEN 'CANCEL'.
      LEAVE TO SCREEN 0.
    WHEN 'NOMERGE'.
      LEAVE TO SCREEN 0.
    WHEN 'MERGE'.
      PERFORM FRM_MATERIAL_MERGE.
    WHEN OTHERS.
  ENDCASE.
  CLEAR : OK_CODE7.
ENDMODULE.                 " USER_COMMAND_9009  INPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_MATERIAL_MERGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_MATERIAL_MERGE .
  DATA :
*函数返回标记
           LV_RETURN TYPE C,
*更新出错标记
           LV_FLAG TYPE C,
*剩余数量
           LV_LEFT TYPE ZLABST,
*插入行次
           LV_LINE TYPE ZLINES,
*处理工作区
           LV_WA_STOCK TYPE T_SCRAP.

  DATA : I_MERGE TYPE STANDARD TABLE OF ZSCRAP.
  DATA : WA_MERGE TYPE ZSCRAP.

  IF I_STOCK IS NOT INITIAL.
    PERFORM FRM_POPUP_INFO USING TEXT-030 TEXT-011  CHANGING LV_RETURN.
    IF LV_RETURN = 'J'.
*1\---------------------合并纪录保存到数据库中
      CLEAR : LV_FLAG.
      REFRESH I_MERGE.
      LOOP AT I_STOCK INTO LV_WA_STOCK.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = LV_WA_STOCK-MATNR
          IMPORTING
            OUTPUT = LV_WA_STOCK-MATNR.
        MOVE-CORRESPONDING LV_WA_STOCK TO WA_MERGE.

        "查看是否已经有售出或者委外记录
        CLEAR : LV_LINE.
        SELECT MAXLINE )
          FROM ZSCRAP
          INTO LV_LINE
          WHERE MATNR = LV_WA_STOCK-MATNR
            AND CHARG = LV_WA_STOCK-CHARG
            AND FLAG = 'O' .
        IF SY-SUBRC <> 0 .
          WA_MERGE-LINE = '01'.
        ELSE.
          WA_MERGE-LINE = LV_LINE + 1.
        ENDIF.

        WA_MERGE-BUDAT = ZSCRAP-BUDAT.
        WA_MERGE-WERKS = C_PLANT.
        WA_MERGE-FLAG  = C_ISSUE. " O 发
        WA_MERGE-REMARK = '合并批次的出库记录'.
        WA_MERGE-ERDAT = SY-DATUM.
        WA_MERGE-ERZET = SY-UZEIT.
        WA_MERGE-ERNAM = SY-UNAME.
        WA_MERGE-OABST = 0.
        WA_MERGE-SABST = 0.
        WA_MERGE-SORT = '3'" 直接售出

        APPEND WA_MERGE TO I_MERGE.
      ENDLOOP.

      INSERT ZSCRAP FROM TABLE I_MERGE.
      IF SY-SUBRC <> 0.
        LV_FLAG = 'X'.
        ROLLBACK WORK.
        MESSAGE '操作失败,请联系管理员!' TYPE 'I'.
        EXIT.
      ENDIF.

*2\--------------------------更新库存标示
      LOOP AT I_STOCK INTO LV_WA_STOCK.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = LV_WA_STOCK-MATNR
          IMPORTING
            OUTPUT = LV_WA_STOCK-MATNR.
        "库存已全部合并
        UPDATE ZSCRAP
        SET SFLAG = 'X' "已售出
            LABST = 0
        WHERE MATNR = LV_WA_STOCK-MATNR
          AND CHARG = LV_WA_STOCK-CHARG
          AND FLAG = C_RECEIVE " I
          .
        IF SY-SUBRC <> 0.
          LV_FLAG = 'X'.
          ROLLBACK WORK .
          MESSAGE '操作失败,请联系管理员!' TYPE 'I'.
          EXIT.
        ENDIF.
      ENDLOOP.

*3\---------------------------插入合并后的记录
      ZSCRAP-FLAG = C_RECEIVE.
      ZSCRAP-WERKS = C_PLANT.
      ZSCRAP-MEINS = 'KG'.
      ZSCRAP-OABST = ZSCRAP-LABST.
      ZSCRAP-SABST = 0.
      CLEAR WA_MERGE .
      MOVE-CORRESPONDING ZSCRAP TO WA_MERGE.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = WA_MERGE-MATNR
        IMPORTING
          OUTPUT = WA_MERGE-MATNR.
      INSERT ZSCRAP FROM WA_MERGE.
      IF SY-SUBRC <> 0.
        LV_FLAG = 'X'.
        ROLLBACK WORK.
        MESSAGE '操作失败,请联系管理员!' TYPE 'I'.
        EXIT.
      ENDIF.

      IF LV_FLAG = ''.
        COMMIT WORK.
        MESSAGE '物料批次已成功合并,操作完成!' TYPE 'S'.
        PERFORM FRM_GET_MERGE_INFO.
        LEAVE TO SCREEN 0.
      ELSE.
        ROLLBACK WORK.
        MESSAGE '操作失败,请联系管理员!' TYPE 'S' DISPLAY LIKE 'E'.
        LEAVE TO SCREEN 0.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    " FRM_MATERIAL_MERGE
*&---------------------------------------------------------------------*
*&      Module  FRM_CHECK_9002BATCH  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE FRM_CHECK_9002BATCH INPUT.
  DATA : LV_CHARG1 TYPE CHARG_D.

  IF ZSCRAP-MATNR IS NOT  INITIAL AND ZSCRAP-CHARG IS NOT INITIAL.
    CLEAR LV_CHARG1 .
    SELECT SINGLE CHARG
      FROM ZSCRAP
      INTO LV_CHARG1
      WHERE MATNR = ZSCRAP-MATNR
        AND CHARG = ZSCRAP-CHARG.
    IF SY-SUBRC = 0 OR LV_CHARG1 IS NOT INITIAL.
      MESSAGE '该物料的批次已经存在,请重新录入!' TYPE 'E'.
    ENDIF.
  ENDIF.

ENDMODULE.                 " FRM_CHECK_9002BATCH  INPUT
*&---------------------------------------------------------------------*
*&      Module  FRM_CHECK_9009BATCH  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE FRM_CHECK_9009BATCH INPUT.
  DATA : LV_CHARG2 TYPE CHARG_D.
  DATA : LV_MATNR1 TYPE MATNR.

  IF ZSCRAP-MATNR IS NOT  INITIAL AND ZSCRAP-CHARG IS NOT INITIAL.
    CLEAR LV_CHARG2.
    CLEAR LV_MATNR1.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = ZSCRAP-MATNR
      IMPORTING
        OUTPUT = LV_MATNR1.
    SELECT SINGLE CHARG
      FROM ZSCRAP
      INTO LV_CHARG2
      WHERE MATNR = LV_MATNR1
        AND CHARG = ZSCRAP-CHARG.
    IF SY-SUBRC = 0 OR LV_CHARG2 IS NOT INITIAL.
      MESSAGE '该物料的批次已经存在,请重新录入!' TYPE 'E'.
    ENDIF.
  ENDIF.

ENDMODULE.                 " FRM_CHECK_9009BATCH  INPUT
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

stm32f103串口1串口2收发程序

#include "stm32f10x.h"   #include "string.h" #include "stdio.h"   void delay(void);   void GPIO_...

一对轻便小巧的收发器程序(ruby实现)

单位由于安全考虑需要做内外网彻底隔离,在内网有数据库服务器DB_SVR, 外网一台WEB_SVR需要将数据库中的数据显示在网页上。于是中间插入一台 “中转”服务器,如下图所示: writer...
  • mydo
  • mydo
  • 2012年11月18日 14:38
  • 1281

Dbus简介与简单的收发示例程序

http://linux.chinaunix.net/techdoc/beginner/2009/08/11/1129569.shtml                     ...
  • lwpping
  • lwpping
  • 2011年09月09日 15:15
  • 371

[CSR8] 分享一个CSR8670串口收发程序

[CSR8] 分享一个CSR8670串口收发程序 最近在调试csr8670串口收发程序,为了方便大家使用,下面就介绍下怎么使用8670的串口。 介绍前,先吐槽下CSR,也许是以前没用过CSR芯片,尼...
  • jgw2008
  • jgw2008
  • 2017年04月21日 11:29
  • 434

基于UDP的数据包收发程序(C#语言描述)

题目 摘要: 1)按照UDP协议数据包发送方式实现用户端之间的通信。 2)统计包的发送和接收数,计算数据包的丢失数。 3)设计美观易用的图形界面。   关键字:      UDP协议、数据包、通信、图...

3年前的一个小项目经验,分享给菜鸟兄弟们(公文收发小软件:程序开发部分)

跟客户也达成了一致的意见,我心里还想,就这么简单的东西,三下两下就搞定不就可以了吗?还是偷偷乐了一下, 很久没玩过这样的小项目,做小项目有成就感,而且比较简单,也算是一个成果物。 价格都商定好了,...

dsp控制DM9000实现802.3数据收发第三篇,调试过程程序第三版;采用外部引脚中断方式获取中断,优化掉帧现象

//-------------------------------------------------------------------------------------------- - /...

串口以及USB转串口收发程序(16进制数的读取发送)

#include #include   #include   #include   #include   #include   #include   #include   #inclu...

程冬冬 2010.12.22 C语言程序-收发EMAIL

作者:2008级嵌入式  程冬冬前言:局域网中启动一个服务器,客户端要想访问服务器要必须知道服务器的IP地址和端口号,在客户端登陆界面设计要输入端口号和IP,这样即麻烦,界面也不美观,通过互联网的上一...
  • ztguang
  • ztguang
  • 2016年03月30日 10:15
  • 420

基本功练习_3_1_之(sim300 GPRS数据收发程序)

//int openport(char *Dev) //打开串口 //int setport(int fd, int baud,int databits,int stopbits,int parit...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:自制收发料程序
举报原因:
原因补充:

(最多只允许输入30个字)