自己OJT时的一本代码

这是中文环境下做的程序, 复制过来,代码间的空格错开了,下面的OJT变成日文的了,到时候再贴出来。


文本消息

000复数选择
001仓库保
002管场所
003出库路径
004出库预定日
005个别选择
006出库凭证番号
007入出库预定
008I/F
009印刷
010打印设备
011预处理
012送货
013送货(无偿)
014紧急送货
015紧急送货(无偿)
016输出
017移送
018移管
019上海大金空调有限公司
020再印刷
021提  货  单
022经销店名称
023提货预定日
024经销店编号
025出库凭证
026经销店电话
027出库路径
028订单号
029运货车号
030交易者号
031品名代码
032管区
033数量
034机种类别
035机型管理
036提货仓库
037签名
038印刷时间
039第
040页
041共
042送  货  单
043送货地址
044仓库名称
045仓库
046移送移管的指令传票

 

*& -- -------------------------------------------------------------------*
*&  程序名     :ZMMR10040_3_A140
*&  分类          :物流ー出荷管理                                
*&  机能番号 :MM - L012        
*&  机能名称 :货单输出
*&  作成者      :
*&  作成日      : 2005 / 07 / 18
*&  版本          : 1.0
*& -- -------------------------------------------------------------------*
*&
*&
*& -- -------------------------------------------------------------------*
REPORT ZMMR10040_3_A140
       NO STANDARD PAGE HEADING
       MESSAGE
- ID ZXX001.
* -- --------------------------------------------------------------------*
* -- ----数据表申明
TABLES: MSEG,                          "凭证段:物料
                  MKPF,                         "抬头:物料凭证
        
          LIKP.                            "SD凭证:交货抬头数据

* -- -------------------------------------------------------------------*
* -- ----屏幕参数定义
SELECTION - SCREEN  BEGIN   OF  BLOCK BL1.
* 复数选择
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN POSITION  3 .
    PARAMETERS  P_RDO1 RADIOBUTTON
                  
GROUP  GRP1
                  
DEFAULT   ' X '
                  
USER - COMMAND RADI.
    SELECTION
- SCREEN COMMENT  5 ( 8 TEXT - 000 .
  SELECTION
- SCREEN  END   OF  LINE.
* 仓库
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN COMMENT  10 ( 8 TEXT - 001 .
    SELECTION
- SCREEN POSITION  23 .
    PARAMETERS PA_WERKS 
LIKE  MSEG - WERKS .
  SELECTION
- SCREEN  END   OF  LINE.
* 保管场所
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN COMMENT  10 ( 8 TEXT - 002 .
    SELECTION
- SCREEN POSITION  23 .
    PARAMETERS  PA_LGORT 
LIKE  MSEG - LGORT .
  SELECTION
- SCREEN  END   OF  LINE.
* 出库路径
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN COMMENT  10 ( 8 TEXT - 003 .
    SELECTION
- SCREEN POSITION  20 .
    
SELECT - OPTIONS SE_VSBED  FOR  LIKP - VSBED.
  SELECTION
- SCREEN  END   OF  LINE.
* 出库预定日
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN COMMENT  10 ( 10 TEXT - 004 .
    SELECTION
- SCREEN POSITION  20 .
    
SELECT - OPTIONS SE_DATUM  FOR  MKPF - BUDAT.
  SELECTION
- SCREEN  END   OF  LINE.
  SELECTION
- SCREEN  SKIP  1 .
* 个别选择
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN POSITION  3 .
    PARAMETERS P_RDO2 RADIOBUTTON
                 
GROUP  GRP1.
    SELECTION
- SCREEN COMMENT  5 ( 8 TEXT - 005 .
  SELECTION
- SCREEN  END   OF  LINE.
* 出库凭证番号
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN COMMENT  10 ( 12 TEXT - 006 .
    SELECTION
- SCREEN POSITION  20 .
    
SELECT - OPTIONS SE_VBELN  FOR  LIKP - VBELN.
  SELECTION
- SCREEN  END   OF  LINE.
* 入出库预定
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN COMMENT  10 ( 10 TEXT - 007 .
    SELECTION
- SCREEN POSITION  20 .
    
SELECT - OPTIONS SE_RSNUM  FOR  MKPF - MBLNR.
  SELECTION
- SCREEN  END   OF  LINE.

  SELECTION
- SCREEN  SKIP  1 .
  SELECTION
- SCREEN  ULINE  1 ( 80 ).
  SELECTION
- SCREEN  SKIP  1 .

* I / F
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN POSITION  3 .
    PARAMETERS  P_RDO3  RADIOBUTTON
                  
GROUP  GRP2
                  
DEFAULT   ' X '
                  
USER - COMMAND RADI.
    SELECTION
- SCREEN COMMENT  5 ( 8 TEXT - 008 .
  SELECTION
- SCREEN  END   OF  LINE.

  SELECTION
- SCREEN  SKIP  1 .

* 印刷
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN POSITION  3 .
    PARAMETERS P_RDO4  RADIOBUTTON
                 
GROUP  GRP2.
    SELECTION
- SCREEN COMMENT  5 ( 8 TEXT - 009 .
  SELECTION
- SCREEN  END   OF  LINE.

  SELECTION
- SCREEN  SKIP  1 .

* 打印设备
  SELECTION
- SCREEN  BEGIN   OF  LINE.
    SELECTION
- SCREEN COMMENT  10 ( 8 TEXT - 010 .
    SELECTION
- SCREEN POSITION  23 .
    PARAMETERS     PA_PDEST 
LIKE  PRI_PARAMS - PDEST .
  SELECTION
- SCREEN  END   OF  LINE.
SELECTION
- SCREEN  END   OF  BLOCK BL1.
* -- -------------------------------------------------------------------*
* -- ----类型定义
* 提货 / 送货 / 移送 抬头表
TYPES: 
BEGIN   OF  TYP_LIKP,
       ZZOP2FLG           
LIKE  LIPS - ZZOP2FLG,          "再印刷标志位
       NAME1                
LIKE  ADRC - NAME1,             "经销店名称
       WADAT              
LIKE  LIKP - WADAT,             "提货预定日
       KUNNR                
LIKE  LIKP - KUNNR,             "经销点编号
       VBELN                 
LIKE  LIKP - VBELN,             "出库凭证
       TEL_NUMBER    
LIKE  ADRC - TEL_NUMBER,        "经销店电话
       VSBED                 
LIKE     LIKP - VSBED,                  "装运条件
       PROCE(
20 )          TYPE C ,                     "出库路径
       VGBEL                 
LIKE  LIPS - VGBEL,             "订单号
       STREET        
LIKE  ADRC - STREET,            "送货地址
       WERKS2        
LIKE  LIPS - WERKS,             "提货仓库
       NAME2         
LIKE  T001W - NAME1,            "提货仓库名称
       WERKS         
LIKE  LIKP - WERKS,             "交货的接收工厂
                                                  "或移送场合仓库
       Z001          
LIKE  TLINE - TDLINE,           "运货车号
       Z002          
LIKE  TLINE - TDLINE,           "交易者号
       Z003          
LIKE  TLINE - TDLINE,           "交易者名称
       DEL_FLG    TYPE C ,                        "删除标志
       
END     OF  TYP_LIKP.
* 提货 / 送货 / 移送 明细数据
TYPES: 
BEGIN   OF  TYP_LIPS,
       VBELN         
LIKE  LIKP - VBELN,             "出库凭证
       ZZOP2FLG      
LIKE  LIPS - ZZOP2FLG,          "再印刷标志位
       WERKS         
LIKE  LIPS - WERKS,             "出库工厂
       MATNR         
LIKE  LIPS - MATNR,             "品名代码
       CHARG         
LIKE  LIPS - CHARG,             "管区
       LFIMG         
LIKE  LIPS - LFIMG,             "数量
       VGBEL         
LIKE  LIPS - VGBEL,             "单据编号
       FLG           TYPE C,                      "机型管理
       NAME2         
LIKE  T001W - NAME1,            "出库仓库
       MATERIAL_TYPE 
LIKE  CAWNT - ATWTB,            "机种类别
       
END     OF  TYP_LIPS.
* 移管 明细
TYPES: 
BEGIN   OF  TYP_RESB,
       NAME1         
LIKE  ADRC - NAME1,              "仓库名称
       RSNUM         
LIKE  RESB - RSNUM,              "入出库预定
       BDTER         
LIKE  RESB - BDTER,              "预定日
       WERKS         
LIKE  RESB - WERKS,              "工厂
       UMWRK         
LIKE  RESB - UMWRK,              "入库工厂
       MATNR         
LIKE  RESB - MATNR,              "品名代码
       CHARG         
LIKE  RESB - CHARG,              "管区
       BDMNG         
LIKE  RESB - BDMNG,              "数量
       TEL_NUMBER    
LIKE  ADRC - TEL_NUMBER,         "电话号码
       STREET        
LIKE  ADRC - STREET,             "地址
       FLG           TYPE C,                       "机型管理
       NAME2         
LIKE  T001W - NAME1,             "出库仓库
       MATERIAL_TYPE 
LIKE  CAWNT - ATWTB,             "机种类别
       VGBEL         
LIKE  LIPS - VGBEL,              "移送移管的指令传票
       ZZOP2FLG      
LIKE  RESB - ZZOP2FLG,
       
END     OF  TYP_RESB.
* 移管 抬头
TYPES: 
BEGIN   OF  TYP_RKPF,
       ZZOP2FLG      
LIKE  LIPS - ZZOP2FLG,           "再印刷标志位
       NAME1         
LIKE  ADRC - NAME1,              "仓库名称
       BDTER         
LIKE  RESB - BDTER,              "提货预定日
       UMWRK         
LIKE  RESB - UMWRK,              "仓库
       RSNUM         
LIKE  RESB - RSNUM,              "出库凭证
       TEL_NUMBER    
LIKE  ADRC - TEL_NUMBER,         "经销店电话
       VSBED         
LIKE  LIKP - VSBED,              "装运条件
       PROCE(
20 )     TYPE C ,                      "出库路径
       VGBEL         
LIKE  LIPS - VGBEL,              "移送移管的指令传票
       STREET        
LIKE  ADRC - STREET,             "送货地址
       WERKS         
LIKE  RESB - WERKS,              "提货仓库
       NAME2         
LIKE  T001W - NAME1,             "提货仓库名称
       
END     OF  TYP_RKPF.

* -- -------------------------------------------------------------------*
* -- ----工作区定义
DATA: REC_LIKP TYPE  TYP_LIKP.
DATA: REC_LIPS TYPE  TYP_LIPS.
DATA: REC_RESB TYPE  TYP_RESB.
DATA: REC_RKPF TYPE  TYP_RKPF.
DATA: REC_INDX 
LIKE   INDX.
* -- -------------------------------------------------------------------*
* -- ----内部表定义
DATA: TBL_LIKP TYPE  TABLE   OF  TYP_LIKP.
DATA: TBL_LIPS TYPE 
TABLE   OF  TYP_LIPS.
DATA: TBL_RESB TYPE 
TABLE   OF  TYP_RESB.
DATA: TBL_RKPF TYPE 
TABLE   OF  TYP_RKPF.
* -- -------------------------------------------------------------------*
* -- ----全局变量定义
DATA:G_DATE             LIKE  SY - DATUM.               "本地日期
DATA:G_TIME            
LIKE  SY - UZEIT.               "本地时间
DATA:G_TFLG            TYPE C.                      "日期标志
DATA:G_LINE(
4 )         TYPE C VALUE  ' 1 ' .            "行的记数器
DATA:G_ZZOP2FLGCHAR(
6 ) TYPE C.                      " [ 再印刷 ] 字样
DATA:G_LIKP(
30 )        TYPE C,                      "TBL_LIKP的ID
     G_LIPS(
30 )        TYPE C,                      "TBL_LIPS的ID
     G_RKPF(
30 )        TYPE C,                      "TBL_RKPF的ID
     G_RESB(
30 )        TYPE C.                      "TBL_RESB的ID
* -- -------------------------------------------------------------------*
* -- ----常量定义
CONSTANTS:
  C_RADI(
4 )          TYPE C VALUE  ' RADI ' ,           "常量RADI
  C_NULL             TYPE C VALUE 
'' ,               "常量 ''
  C_X(
1 )             TYPE C VALUE  ' X '   ,            "常量X
  C_S000(
4 )          TYPE C VALUE  ' S000 ' ,           "常量S000
  C_01               
LIKE  LIKP - VSBED VALUE  ' 01 ' ,    "常量01
  C_02               
LIKE  LIKP - VSBED VALUE  ' 02 ' ,    "常量02
  C_03               
LIKE  LIKP - VSBED VALUE  ' 03 ' ,    "常量03
  C_04               
LIKE  LIKP - VSBED VALUE  ' 04 ' ,    "常量04
  C_05               
LIKE  LIKP - VSBED VALUE  ' 05 ' ,    "常量05
  C_11               
LIKE  LIKP - VSBED VALUE  ' 11 ' ,    "常量11
  C_31               
LIKE  LIKP - VSBED VALUE  ' 31 ' ,    "常量31
  C_ZZ               
LIKE  LIKP - VSBED VALUE  ' ZZ ' ,    "常量ZZ
  C_000000(
6 )        TYPE C VALUE  ' 000000 ' ,         "常量000000
  C_WE(
2 )            TYPE C VALUE  ' WE ' ,             "常量WE
  C_261(
3 )           TYPE C VALUE  ' 261 ' ,            "常量261
  C_Z001(
4 )          TYPE C VALUE  ' Z001 ' ,           "常量Z001
  C_Z002(
4 )          TYPE C VALUE  ' Z002 ' ,           "常量Z002
  C_Z003(
4 )          TYPE C VALUE  ' Z003 ' ,           "常量Z003
  C_MATNR(
5 )         TYPE C VALUE  ' MATNR ' ,          "常量MATNR
  C_UTC8(
5 )          TYPE C VALUE  ' UTC+8 ' ,          "常量UTC + 8
  C_1(
1 )             TYPE C VALUE  ' 1 ' ,              "常量1
  C_2(
1 )             TYPE C VALUE  ' 2 ' ,              "常量2
  C_A(
1 )             TYPE C VALUE  ' + ' ,              "常量 +
  C_D(
1 )             TYPE C VALUE  ' - ' ,              "常量 -
  C_SAPSCRIPT_ID(
12 ) TYPE C VALUE  ' ZMM001_A140 ' ,    "SAPSCRIPT的ID
  C_SMARTFORM_ID(
12 ) TYPE C VALUE  ' ZMMR001_A140 ' ,   "SMARTFORM的ID
  C_LIKP(
4 )          TYPE C VALUE  ' LIKP ' ,           "表名LIKP
  C_LIPS(
4 )          TYPE C VALUE  ' LIPS ' ,           "表名LIPS
  C_RKPF(
4 )          TYPE C VALUE  ' RKPF ' ,           "表名RKPF
  C_RESB(
4 )          TYPE C VALUE  ' RESB ' ,           "表名RESB
  C_ZH               
LIKE  SYST - LANGU VALUE  ' 1 ' ,     "中文语言
  C_JA               
LIKE  SYST - LANGU VALUE  ' J ' ,     "日文语言
  C_VBBK             
LIKE   THEAD - TDOBJECT
                          VALUE   
' VBBK ' ,           "常量VBBK
  C_MARA             
LIKE  BAPI1003_KEY - OBJECTTABLE
                          VALUE   
' MARA ' ,           "常量MARA
  C_ZCLASS_MAT       
LIKE   BAPI1003_KEY - CLASSNUM
                          VALUE   
' ZCLASS_MAT ' ,     "常量ZCLASS_MAT
  C_001              
LIKE   BAPI1003_KEY - CLASSTYPE
                          VALUE   
' 001 ' ,            "常量001
  C_TYPEC            
LIKE   BAPI1003_ALLOC_VALUES_CHAR - CHARACT
                          VALUE 
' ZMACHINE_TYPE ' .    "常量ZMACHINE_TYPE
*& -- ------------------------------------------------------------------*
*& -- ----初处理事件
INITIALIZATION.
  PERFORM SCREEN_INIT.
*& -- ------------------------------------------------------------------*
*& -- ----选择屏幕PBO事件
AT SELECTION - SCREEN OUTPUT.
  PERFORM SCREEN_PBO.
*& -- ------------------------------------------------------------------*
*& -- ----选择屏幕PAI事件
AT SELECTION - SCREEN.
  PERFORM SCREEN_PAI.
*& -- ------------------------------------------------------------------*
*& -- ----主处理事件
START - OF - SELECTION.
  PERFORM PROCESS_MAIN.
*& -- ------------------------------------------------------------------*
*& -- ----末处理事件
END - OF - SELECTION.
  PERFORM PROCESS_END.


*& -- -------------------------------------------------------------------*
*&   FORM  SCREEN_INIT
*&   功能: 保管场所的缺省值 S000
*& -- -------------------------------------------------------------------*
FORM SCREEN_INIT.
  PA_LGORT 
=  C_S000.
ENDFORM.                                           " SCREEN_INIT

*& -- -------------------------------------------------------------------*
*&   FORM  SCREEN_PBO
*&   功能: 选择屏幕PBO
*& -- -------------------------------------------------------------------*
FORM SCREEN_PBO.
  LOOP AT SCREEN.                                  "循环屏幕参量
    
IF  P_RDO1  =  C_X.                               "复数选择
      
IF    SCREEN - NAME    =   ' SE_VBELN-LOW '           "出库凭证前项目
        
OR  SCREEN - NAME    =   ' SE_VBELN-HIGH '          "出库凭证后项目
        
OR  SCREEN - NAME    =   ' SE_RSNUM-LOW '           "入出库凭证前项目
        
OR  SCREEN - NAME    =   ' SE_RSNUM-HIGH ' .        "入出库凭证后项目
        SCREEN
- INPUT   =   0 .                         "禁止输入
        SCREEN
- OUTPUT  =   1 .                         "允许输出
      ENDIF.
      PERFORM SCREEN_INIT.
    ENDIF.
    
IF  P_RDO2  =  C_X.                               "个别选择
      
IF  SCREEN - NAME      =   ' PA_WERKS '               "仓库
        
OR  SCREEN - NAME    =   ' PA_LGORT '               "保管场所
        
OR  SCREEN - NAME    =   ' SE_VSBED-LOW '           "出库路径前项目
        
OR  SCREEN - NAME    =   ' SE_VSBED-HIGH '          "出库路径后项目
        
OR  SCREEN - NAME    =   ' SE_DATUM-LOW '           "出库预定日前项目
        
OR  SCREEN - NAME    =   ' SE_DATUM-HIGH ' .        "出库预定日后项目
        SCREEN
- INPUT   =   0 .                         "禁止输入
        SCREEN
- OUTPUT  =   1 .                         "允许输出
      ENDIF.
    ENDIF.
    
IF  P_RDO3  =  C_X.                               "I / F
      
IF  SCREEN - NAME      =   ' PA_PDEST ' .             "打印设备
        SCREEN
- INPUT   =   0 .
        SCREEN
- OUTPUT  =   1 .
      ENDIF.
    ENDIF.
    MODIFY SCREEN.                                 "修改屏幕参量
  ENDLOOP.
ENDFORM.                                           " SCREEN_PBO

*& -- -------------------------------------------------------------------*
*&   FORM  SCREEN_PAI
*&   功能: 选择屏幕PAI
*& -- -------------------------------------------------------------------*
FORM SCREEN_PAI.
 
IF  SY - UCOMM  =  C_RADI.                             "判断PAI触发功能代码
   PERFORM SCREEN_FLUSH.                           "刷新屏幕
 
ELSE .
   PERFORM SCREEN_CHECK_INPUT.                     "输入检查
 ENDIF.
ENDFORM.                                           " SCREEN_PAI

*& -- -------------------------------------------------------------------*
*&   FORM  SCREEN_FLUSH
*&   功能: 刷新屏幕
*& -- -------------------------------------------------------------------*
FORM SCREEN_FLUSH.
    
IF  P_RDO1  =  C_X.                              "复数选择
      REFRESH: SE_VBELN,                          "出库凭证
               SE_RSNUM.                          "入出库预定
    ENDIF.
    
IF  P_RDO2  =  C_X.                              "个别选择
      CLEAR:   PA_WERKS,                          "仓库
               PA_LGORT.                          "保管场所
      REFRESH: SE_VSBED,                          "出库路径
               SE_DATUM.                          "出库预定日
    ENDIF.
    
IF  P_RDO3  =  C_X.                              "I / F
      CLEAR    PA_PDEST.                          "打印设备
    ENDIF.
ENDFORM.                                          "SCREEN_FLUSH

*& -- -------------------------------------------------------------------*
*&   FORM  SCREEN_CHECK_INPUT
*&   功能: 输入检查
*& -- -------------------------------------------------------------------*
FORM SCREEN_CHECK_INPUT.
  
IF  P_RDO1  =  C_X.                                 "复数选择
    
IF  PA_WERKS  IS  INITIAL.                        "工厂未输入
       
SET   CURSOR  FIELD  ' PA_WERKS ' .
*  报消息: [ 在所有需要输入的字段中输入一个条目 ]
        MESSAGE ID 
' 00 '  TYPE  ' E '   NUMBER   ' 055 ' .
    ENDIF.
    
IF  PA_LGORT  IS  INITIAL.                        "保管场所未输入
      
SET   CURSOR  FIELD  ' PA_LGORT ' .
*  报消息: [ 在所有需要输入的字段中输入一个条目 ]
      MESSAGE ID 
' 00 '  TYPE  ' E '   NUMBER   ' 055 ' .
    ENDIF.
  ENDIF.
  
IF  P_RDO2  =  C_X.                                 "个别选择
    
IF     SE_VBELN []   IS  INITIAL                    "出厂凭证未输入
      
AND  SE_RSNUM []   IS  INITIAL.                   "和入出库凭未输入
      
SET   CURSOR  FIELD  ' SE_VBELN-LOW ' .
*  报消息: [ 在所有需要输入的字段中输入一个条目 ]
    MESSAGE ID 
' 00 '  TYPE  ' E '   NUMBER   ' 055 ' .
    ENDIF.
  ENDIF.
  
IF  P_RDO4  =  C_X.                                 "打印输出
    
IF  PA_PDEST  IS  INITIAL.                        "打印设备未输入
      
SET   CURSOR  FIELD  ' PA_PDEST ' .
*  报消息: [ 在所有需要输入的字段中输入一个条目 ]
      MESSAGE ID 
' 00 '  TYPE  ' E '   NUMBER   ' 055 ' .
    ENDIF.
  ENDIF.
ENDFORM.                                           "SCREEN_CHECK_INPUT

*& -- -------------------------------------------------------------------*
*&   FORM  PROCESS_MAIN
*&   功能: 主处理:取得对象数据 -> 编辑数据 -> 输出帐票
*& -- -------------------------------------------------------------------*
FORM PROCESS_MAIN.
  PERFORM DATA_GET.                                "取得对象数据
  PERFORM DATA_EDIT.                               "编辑数据
  
IF  P_RDO3  =  C_X.                                 "选择了I / F
    STOP.
  ENDIF.
  
IF  P_RDO4  =  C_X.                                 "选择了印刷
    
IF  SY - LANGU  =  C_ZH.                            "用户登陆语言为中文
      PERFORM WRITE_SAPSCRIPT.                     "中文输出帐票
    ENDIF.
    
IF  SY - LANGU  =  C_JA.                            "用户登陆语言为日文
      PERFORM WRITE_SMARTFORM.                     "日文输出帐票
    ENDIF.
*  报消息: [ 正常执行输出 ]
    MESSAGE ID 
' ZXX001 '  TYPE   ' S '   NUMBER   ' 036 ' .
  ENDIF.
ENDFORM.                                           " PROCESS_MAIN

*& -- -------------------------------------------------------------------*
*&   FORM  DATA_GET
*&   功能: 对象数据取得
*& -- -------------------------------------------------------------------*
FORM DATA_GET.
  CLEAR: TBL_LIKP,
         TBL_LIPS,
         TBL_RKPF,
         TBL_RESB.
  
IF  P_RDO1  =  C_X.                                 "如果选了  [ 复数选择 ]
    PERFORM DO_CHOOSE1.
  ENDIF.
  
IF  P_RDO2  =  C_X.                                 "如果选了  [ 个别选择 ]
    PERFORM DO_CHOOSE2.
  ENDIF.
  
IF  TBL_LIKP  IS  INITIAL
    
AND  TBL_RESB  IS  INITIAL.                       "对象数据不存在
*  报消息: [ 对象数据不存在 ]  终止程序
    MESSAGE S035.
    STOP.
  ENDIF.
ENDFORM.                                           " DATA_GET

*& -- -------------------------------------------------------------------*
*&   FORM  DO_CHOOSE1
*&   功能: 复数选择情况
*& -- -------------------------------------------------------------------*
FORM DO_CHOOSE1 .
* 2 - 1 - 1 - 1  提货 / 送货 / 移送 场合
  
IF     C_01   IN    SE_VSBED                        "出库路径01  02   03   04
     
OR  C_02   IN    SE_VSBED                        " 05   11   31  或没输入
     
OR  C_03   IN    SE_VSBED
     
OR  C_04   IN    SE_VSBED
     
OR  C_05   IN    SE_VSBED
     
OR  C_11   IN    SE_VSBED
     
OR  C_31   IN    SE_VSBED
     
OR  ( SE_VSBED []   IS  INITIAL ).
    PERFORM  DO_SE_VSBED1.                         "出库路径情况1处理
  ENDIF.
* 2 - 1 - 1 - 2  移管 场合
  
IF     C_ZZ   IN    SE_VSBED
    
OR  ( SE_VSBED []   IS  INITIAL ).                  "出库路径ZZ 或没输入
    PERFORM DO_SE_VSBED2.                          "出库路径情况2处理
  ENDIF.
ENDFORM.                                           " DO_CHOOSE1
*& -- -------------------------------------------------------------------*
*&   FORM  DO_SE_VSBED1
*&   功能: 出库路径是01  02   03   04   05   11   31  时处理
*& -- -------------------------------------------------------------------*
FORM DO_SE_VSBED1.
* 局部变量
DATA: LO_ADRNR  
LIKE  VBPA - ADRNR.                  "销售凭证:合作伙伴地址
DATA: LO_SERAIL 
LIKE  LIPS - SERAIL.                 "地址
* 2 - 1 - 1 - 1 - 1  查询  [ SD凭证:交货抬头数据 ] (LIKP)
  
SELECT     VBELN                                 "交货
            WADAT                                 "计划货物移动日期
            KUNNR                                 "送达方
            VSBED                                 "装运条件
            WERKS                                 "交货的接收工厂
  APPENDING CORRESPONDING FIELDS 
OF   TABLE  TBL_LIKP
  
FROM       LIKP                                  "交货抬头数据
  
WHERE      VSBED  IN  SE_VSBED                     "指定条件 装运条件
  
AND        WADAT  IN  SE_DATUM.                    "指定条件 移动日期
  
IF  SY - SUBRC  <>   0 .                               "对象不存在 退出FORM
    
RETURN .
  ENDIF.
* 2 - 1 - 1 - 1 - 2  查询  [ 销售凭证 : 合作伙伴 ] (VBPA)
  CLEAR REC_LIKP.
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
SELECT   SINGLE  ADRNR
    
INTO    LO_ADRNR
    
FROM    VBPA                                   "销售凭证:合作伙伴
    
WHERE   VBELN  =  REC_LIKP - VBELN                 "交货
    
AND     POSNR  =  C_000000                       "销售和分销凭证项目号
    
AND     PARVW  =  C_WE.                          "合作伙伴功能
* 2 - 1 - 1 - 1 - 3  查询  [ 地址 (业务地址服务) ] (ADRC)
    
IF  SY - SUBRC  =   0 .
      
SELECT    SINGLE  NAME1                        "客户名称
              TEL_NUMBER                          "电话号码
              STREET                              "地址
        
INTO   (REC_LIKP - NAME1,
               REC_LIKP
- TEL_NUMBER,
               REC_LIKP
- STREET
              )
        
FROM   ADRC
       
WHERE   ADDRNUMBER  =  LO_ADRNR               "地址号码等于LO_ADRNR
         
AND   NATION  =   SPACE .                     "国际地址版本等于SPACE
      MODIFY  TBL_LIKP 
FROM   REC_LIKP
                TRANSPORTING NAME1                "客户名称
                             TEL_NUMBER           "电话号码
                             STREET.              "地址
    ENDIF.
    CLEAR REC_LIKP.
  ENDLOOP.
* 2 - 1 - 1 - 1 - 4  查询  [ SD凭证:交货:项目数据 ] (LIPS)
CLEAR REC_LIKP.
LOOP AT TBL_LIKP 
INTO  REC_LIKP.
  
SELECT  ZZOP2FLG                                "再印刷标志
         VBELN                                   "交货凭证号
         WERKS                                   "工厂
         MATNR                                   "物料号
         CHARG                                   "批号
         LFIMG                                   "实际已交货量
         SERAIL                                  "序列号参数文件
         VGBEL                                   "参考单据的单据编号
   
INTO  (REC_LIPS - ZZOP2FLG,
         REC_LIPS
- VBELN,
         REC_LIPS
- WERKS,
         REC_LIPS
- MATNR,
         REC_LIPS
- CHARG,
         REC_LIPS
- LFIMG,
         LO_SERAIL,
         REC_LIPS
- VGBEL)
    
FROM  LIPS
   
WHERE  VBELN   =  REC_LIKP - VBELN                 "交货抬头表—交货凭证号
     
AND  WERKS   =  PA_WERKS                       "参数工厂
     
AND  LGORT   =  PA_LGORT                       "参数保管场所
     
AND  ( ZZOP2FLG  IS   NULL
          
OR  ZZOP2FLG  =   SPACE  )                  "再印刷标志位
     
AND  KOMKZ    <>   SPACE .                       "拣配控制指示符

    
IF  LO_SERAIL   <>   '' .                         "机种类型不为空
      REC_LIPS
- FLG  =  C_X.                        "机型管理 赋X
    
ELSE .                                        "机种类型为空
      REC_LIPS
- FLG  =   SPACE .                      "机型管理 赋SPACE
    ENDIF.

    REC_LIKP
- VGBEL  =  REC_LIPS - VGBEL.             "添加抬头订单号
    REC_LIKP
- ZZOP2FLG  =  REC_LIPS - ZZOP2FLG.
    REC_LIKP
- WERKS2  =  REC_LIPS - WERKS.
    MODIFY TBL_LIKP 
FROM   REC_LIKP
             TRANSPORTING VGBEL                  "定单号
                          ZZOP2FLG               "再印刷标志
                          WERKS2.                "提货仓库
    APPEND REC_LIPS 
TO  TBL_LIPS.                 "添加明细条目
  ENDSELECT.

  
IF  SY - SUBRC  <>   0 .                              "该抬头没有明细数据
    REC_LIKP
- DEL_FLG  =  C_X.
    MODIFY TBL_LIKP 
FROM   REC_LIKP
             TRANSPORTING DEL_FLG.               "删除标志
  ENDIF.
  ENDLOOP.
  
DELETE  TBL_LIKP  WHERE  DEL_FLG  =  C_X.           "删除没有明细的表头
* 2 - 1 - 1 - 1 - 5  查询  [ 工厂/分支机构 ] (T001W)
  CLEAR REC_LIPS.
  LOOP AT TBL_LIPS 
INTO  REC_LIPS.
    
SELECT   SINGLE  NAME1                          "工厂名称
    
FROM    T001W
    
INTO    REC_LIPS - NAME2                        "出库仓库名称
    
WHERE   WERKS  =  REC_LIPS - WERKS.               "工厂为出库工厂
    MODIFY TBL_LIPS 
FROM   REC_LIPS
             TRANSPORTING NAME2.
  ENDLOOP.

  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
SELECT   SINGLE  NAME1                          "工厂名称
    
FROM    T001W
    
INTO    REC_LIKP - NAME2                        "出库仓库名称
    
WHERE   WERKS  =  REC_LIKP - WERKS2.              "工厂为出库工厂
    MODIFY TBL_LIKP 
FROM   REC_LIKP
             TRANSPORTING NAME2.                 "提货仓库名称
  ENDLOOP.

ENDFORM.                                         " DO_SE_VSBED1

*& -- -------------------------------------------------------------------*
*&   FORM  DO_SE_VSBED2
*&   功能: 出库路径是ZZ 或者没有输入 时处理
*& -- -------------------------------------------------------------------*
FORM DO_SE_VSBED2.
DATA: LO_ADRNR 
LIKE  VBPA - ADRNR,                  "地址
      LO_SERNP 
LIKE  MARC - SERNP.                  "序列号参数文件
* 2 - 1 - 1 - 2 - 1  查询  [ 预定/相关需求 ] (RESB)
  CLEAR REC_RESB.
  
SELECT   RSNUM                                  "入出库预定
          BDTER                                  "预定日
          WERKS                                  "工厂
          UMWRK                                  "入库工厂
          MATNR                                  "物料号码
          CHARG                                  "批次编号
          BDMNG                                  "需求量
          ZZOP2FLG                               "再印刷标志位
    
INTO  (REC_RESB - RSNUM,
          REC_RESB
- BDTER,
          REC_RESB
- WERKS,
          REC_RESB
- UMWRK,
          REC_RESB
- MATNR,
          REC_RESB
- CHARG,
          REC_RESB
- BDMNG,
          REC_RESB
- ZZOP2FLG)
    
FROM   RESB                                  "预定相关需求明细
   
WHERE   BWART  =  C_261                         "移动类型(库存管理)
     
AND   BDTER  IN  SE_DATUM                     "组件的需求日期
                                                "画面参数出入库预定日
     
AND   WERKS  =  PA_WERKS                      "工厂为画面参数仓库
     
AND   LGORT  =  PA_LGORT                      "库存地点 = 画面保管场所
     
AND  ( ZZOP2FLG  IS   NULL
          
OR  ZZOP2FLG  =   SPACE  ).                "再印刷标志位
    APPEND REC_RESB 
TO  TBL_RESB.
  ENDSELECT.
  
IF  SY - SUBRC  <>   0 .                             "对象不存在 退出FORM
    
RETURN .
  ENDIF.
* 2 - 1 - 1 - 2 - 2  查询  [ 工厂/分支机构 ] (T001W)
  CLEAR REC_RESB.
  LOOP AT TBL_RESB 
INTO  REC_RESB.
    
SELECT    SINGLE  ADRNR                        "地址
      
INTO   LO_ADRNR
      
FROM   T001W
     
WHERE   WERKS  =  REC_RESB - UMWRK.             "相应的工厂代号
* 2 - 1 - 1 - 2 - 3  查询  [ 地址 (业务地址服务) ] (ADRC)
    
IF  SY - SUBRC  =   0 .
      
SELECT   NAME1                             "客户名称
              TEL_NUMBER                        "电话号码
              STREET                            "地址
        
INTO  (REC_RESB - NAME1,
              REC_RESB
- TEL_NUMBER,
              REC_RESB
- STREET )
        
FROM   ADRC
          UP  
TO   1  ROWS
       
WHERE   ADDRNUMBER  =  LO_ADRNR             "地址号码等于LO_ADRNR
         
AND   NATION      =   SPACE .               "国际地址版本等于SPACE
      MODIFY  TBL_RESB 
FROM   REC_RESB
                TRANSPORTING NAME1
                             TEL_NUMBER
                             STREET.
      ENDSELECT.
    ENDIF.
  ENDLOOP.
* 2 - 1 - 1 - 2 - 4  查询  [ 物料的工厂数据 ] (MARC)
  CLEAR REC_RESB.
  LOOP AT TBL_RESB 
INTO  REC_RESB.
    
SELECT    SINGLE  SERNP                         "序列号参数文件
      
INTO   LO_SERNP
      
FROM   MARC
     
WHERE   MATNR  =  REC_RESB - MATNR               "物料号为预定表中物料号
       
AND   WERKS  =  REC_RESB - WERKS.              "工厂为预定表中工厂
    
IF  LO_SERNP  <>  C_NULL.                       "机种类别不为空
      REC_RESB
- FLG  =  C_X.
    
ELSE .
      REC_RESB
- FLG  =   SPACE .
    ENDIF.
    MODIFY TBL_RESB 
FROM   REC_RESB
             TRANSPORTING FLG .
  ENDLOOP.
* 2 - 1 - 1 - 2 - 5  查询  [ 工厂/分支机构 ] (T001W)
  LOOP AT TBL_RESB 
INTO  REC_RESB.
    
SELECT    SINGLE  NAME1
      
INTO   REC_RESB - NAME2                        "提货仓库名称
      
FROM   T001W
     
WHERE   WERKS  =  REC_RESB - WERKS.
    
IF  SY - SUBRC  =   0 .
      MODIFY TBL_RESB 
FROM   REC_RESB
               TRANSPORTING NAME2.
    ENDIF.
  ENDLOOP.
ENDFORM.                                          "DO_SE_VSBED2

*& -- -------------------------------------------------------------------*
*&   FORM  DO_CHOOSE2
*&   功能: 个别选择情况
*& -- -------------------------------------------------------------------*
FORM DO_CHOOSE2.
  
IF   NOT  SE_VBELN []   IS  INITIAL.                   "出库凭证有输入
    PERFORM DO_SE_VBELN.
  ENDIF.
  
IF   NOT  SE_RSNUM []   IS  INITIAL.                   "入出库预定有输入
    PERFORM DO_SE_RSNUM.
  ENDIF.
ENDFORM.                                          "DO_CHOOSE2

*& -- -------------------------------------------------------------------*
*&   FORM  DO_SE_VBELN
*&   功能: 个别选择情况 出库凭证番号有输入
*& -- -------------------------------------------------------------------*
FORM DO_SE_VBELN.
* 局部变量
DATA: LO_ADRNR  
LIKE  VBPA - ADRNR,                  "地址
      LO_SERAIL 
LIKE  LIPS - SERAIL.                 "机种
* 2 - 1 - 2 - 1 - 1  查询  [ SD凭证:交货抬头数据 ] (LIKP)
  
SELECT     VBELN                                 "出库凭证
            WADAT                                 "出库预定日
            KUNNR                                 "批发销售店号
            VSBED                                 "装运条件
            WERKS                                 "接受工厂
  APPENDING CORRESPONDING FIELDS 
OF   TABLE  TBL_LIKP
     
FROM    LIKP                                  "交货抬头表
    
WHERE    VBELN  IN  SE_VBELN.                    "指定的出库凭证号
  
IF  SY - SUBRC  <>   0 .                               "数据不存在 退出FORM
    
RETURN .
  ENDIF.
* 2 - 1 - 2 - 1 - 2  查询  [ 销售凭证 : 合作伙伴 ] (VBPA)
  CLEAR REC_LIKP.
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
SELECT    SINGLE  ADRNR                          "地址
      
INTO   LO_ADRNR
      
FROM   VBPA                                  "合作伙伴
     
WHERE   VBELN  =  REC_LIKP - VBELN                "分销单据号 = 交货凭证号
       
AND   POSNR  =  C_000000                      "销售项目号 = ' 000000 '
       
AND   PARVW  =  C_WE.                         "合作伙伴功能等于SH
* 2 - 1 - 2 - 1 - 3  查询  [ 地址 (业务地址服务) ] (ADRC)
    
IF  SY - SUBRC  =   0 .
      
SELECT    SINGLE  NAME1                         "客户名称
              TEL_NUMBER                           "电话号码
              STREET                               "地址
        
INTO   (REC_LIKP - NAME1,
               REC_LIKP
- TEL_NUMBER,
               REC_LIKP
- STREET)
        
FROM   ADRC
       
WHERE   ADDRNUMBER  =  LO_ADRNR                "地址号码等于LO_ADRNR
         
AND   NATION  =   SPACE .                      "国际地址版本 = SPACE
      MODIFY  TBL_LIKP 
FROM   REC_LIKP
                TRANSPORTING NAME1
                             TEL_NUMBER
                             STREET.
    ENDIF.
  ENDLOOP.
* 2 - 1 - 2 - 1 - 4  查询  [ SD凭证 : 交货: 项目数据 ] (LIPS)
  CLEAR REC_LIKP.
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
SELECT   ZZOP2FLG                               "再印刷标志位
            VBELN                                  "交货凭证号
            WERKS                                  "工厂
            MATNR                                  "物料号码
            CHARG                                  "批次编号
            LFIMG                                  "实际已交货量
            SERAIL                                 "机种
            VGBEL                                  "参考单据的单据编号
      
FROM   LIPS
      
INTO  (REC_LIPS - ZZOP2FLG,
            REC_LIPS
- VBELN,
            REC_LIPS
- WERKS,
            REC_LIPS
- MATNR,
            REC_LIPS
- CHARG,
            REC_LIPS
- LFIMG,
            LO_SERAIL,
            REC_LIPS
- VGBEL)
     
WHERE   VBELN  =  REC_LIKP - VBELN.                "交货凭证号相等

      
IF  LO_SERAIL   <>  C_NULL.                     "机种类型不为空
        REC_LIPS
- FLG  =  C_X.                        "机型管理 赋X
      
ELSE .                                        "机种类型为空
        REC_LIPS
- FLG  =   SPACE .                      "机型管理 赋SPACE
      ENDIF.

      REC_LIKP
- VGBEL  =  REC_LIPS - VGBEL.             "添加抬头订单号
      REC_LIKP
- ZZOP2FLG  =  REC_LIPS - ZZOP2FLG.       "再印刷标志位
      REC_LIKP
- WERKS2  =  REC_LIPS - WERKS.
      MODIFY TBL_LIKP 
FROM   REC_LIKP
               TRANSPORTING VGBEL                  "定单号
                            ZZOP2FLG               "再印刷标志
                            WERKS2.                "提货仓库
      APPEND REC_LIPS 
TO  TBL_LIPS.                 "添加明细条
    ENDSELECT.
    
IF  SY - SUBRC  <>   0 .                              "如果没有相应明细数据
      REC_LIKP
- DEL_FLG  =  C_X.                      "记下要删除标志
      MODIFY TBL_LIKP 
FROM   REC_LIKP
               TRANSPORTING DEL_FLG.
    ENDIF.
  ENDLOOP.
  
DELETE  TBL_LIKP  WHERE  DEL_FLG  =  C_X.             "删除没有明细的表头
* 2 - 1 - 2 - 1 - 6  查询  [ 工厂/分支机构 ] (T001W)
  LOOP AT TBL_LIPS 
INTO  REC_LIPS.
    
SELECT    SINGLE  NAME1                           "工厂名称
      
INTO   REC_LIPS - NAME2                         "出库仓库名称
      
FROM   T001W                                  "工厂
     
WHERE   WERKS  =  REC_LIPS - WERKS.                "工厂代码 = 出库工厂
    MODIFY TBL_LIPS 
FROM   REC_LIPS
             TRANSPORTING NAME2.
  ENDLOOP.

  CLEAR LIKP.
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
SELECT   SINGLE  NAME1                            "工厂名称
    
FROM    T001W
    
INTO    REC_LIKP - NAME2                          "出库仓库名称
    
WHERE   WERKS  =  REC_LIKP - WERKS2.                "工厂为出库工厂
    MODIFY TBL_LIKP 
FROM   REC_LIKP
             TRANSPORTING NAME2.
  ENDLOOP.
ENDFORM.                                           "DO_SE_VBELN

*& -- -------------------------------------------------------------------*
*&   FORM  DO_SE_RSNUM
*&   功能: 个别选择情况 入出库预定有输入
*& -- -------------------------------------------------------------------*
FORM DO_SE_RSNUM.
* 局部变量
DATA: LO_ADRNR 
LIKE  VBPA - ADRNR,                    "地址
      LO_SERNP 
LIKE  MARC - SERNP.                    "序列号参数文件
* 2 - 1 - 2 - 2 - 1  查询  [ 预定/相关需求 ] (RESB)
  CLEAR REC_RESB.
  
SELECT     RSNUM                                  "入出库预定
            BDTER                                  "预定日
            WERKS                                  "工厂
            UMWRK                                  "入库工厂
            MATNR                                  "物料号码
            CHARG                                  "批次编号
            BDMNG                                  "需求量
            ZZOP2FLG                               "再印刷标志位
  APPENDING CORRESPONDING FIELDS 
OF   TABLE  TBL_RESB
    
FROM     RESB
   
WHERE     RSNUM  IN  SE_RSNUM.
  
IF  SY - SUBRC  <>   0 .                                "数据不存在 退出FORM
    
RETURN .
  ENDIF.
* 2 - 1 - 2 - 2 - 3  查询  [ 工厂/分支机构 ] (T001W)
  LOOP AT TBL_RESB 
INTO  REC_RESB.
    
SELECT    SINGLE  ADRNR                          "地址
      
INTO   LO_ADRNR
      
FROM   T001W                                 "工厂表
     
WHERE   WERKS  =  REC_RESB - UMWRK.               "相应的工厂代号
* 2 - 1 - 2 - 2 - 4  查询  [ 地址 (业务地址服务) ] (ADRC)
    
IF  SY - SUBRC  =   0 .
      
SELECT    SINGLE  NAME1                        "客户名称
              TEL_NUMBER                          "电话号码
              STREET                              "地址
        
INTO  (REC_RESB - NAME1,
              REC_RESB
- TEL_NUMBER,
              REC_RESB
- STREET)
        
FROM   ADRC                                "中心地址管理
       
WHERE   ADDRNUMBER  =  LO_ADRNR               "地址号码等于LO_ADRNR
         
AND   NATION  =   SPACE .                     "国际地址版本等于SPACE
      MODIFY  TBL_RESB 
FROM   REC_RESB
                TRANSPORTING NAME1
                             TEL_NUMBER
                             STREET.
    ENDIF.
  ENDLOOP.
* 2 - 1 - 2 - 2 - 5  查询  [ 物料的工厂数据 ] (MARC)
  CLEAR REC_RESB.
  LOOP AT TBL_RESB 
INTO  REC_RESB.
    
SELECT    SINGLE  SERNP                         "序列号参数文件
      
INTO   LO_SERNP
      
FROM   MARC
     
WHERE   MATNR  =  REC_RESB - MATNR               "物料号为预定表中物料号
       
AND   WERKS  =  REC_RESB - WERKS.              "工厂为预定表中工厂
    
IF  LO_SERNP  <>  C_NULL.                       "机种类别不为空情况
      REC_RESB
- FLG  =  C_X.
    
ELSE .
      REC_RESB
- FLG  =   SPACE .                      "机种类别为空情况
    ENDIF.
    MODIFY TBL_RESB 
FROM   REC_RESB
             TRANSPORTING FLG .                  "机型管理
  ENDLOOP.
* 2 - 1 - 2 - 2 - 6  查询  [ 工厂/分支机构 ] (T001W)
  CLEAR REC_RESB.
  LOOP AT TBL_RESB 
INTO  REC_RESB.
    
SELECT    SINGLE  NAME1                         "名称
      
INTO   REC_RESB - NAME2
      
FROM   T001W
     
WHERE   WERKS  =  REC_RESB - WERKS.              "工厂为预定表中出库工厂
    
IF  SY - SUBRC  =   0 .
      MODIFY TBL_RESB 
FROM   REC_RESB
               TRANSPORTING NAME2.
    ENDIF.
  ENDLOOP.
ENDFORM.                                         "DO_SE_RSNUM

*& -- -------------------------------------------------------------------*
*&   FORM  DATA_EDIT
*&   功能: 数据编辑
*& -- -------------------------------------------------------------------*
FORM DATA_EDIT.
* 2 - 2 - 1  移管的情况下处理
  LOOP AT TBL_RESB 
INTO  REC_RESB.

    SHIFT REC_RESB
- RSNUM  LEFT  DELETING LEADING  ' 0 ' .
    MODIFY TBL_RESB 
FROM   REC_RESB
             TRANSPORTING RSNUM.

    REC_RKPF
- NAME1       =  REC_RESB - NAME1.         "仓库名称
    REC_RKPF
- BDTER       =  REC_RESB - BDTER.         "提货预定日
    REC_RKPF
- UMWRK       =  REC_RESB - UMWRK.         "仓库
    REC_RKPF
- RSNUM       =  REC_RESB - RSNUM.         "出库凭证
    REC_RKPF
- TEL_NUMBER  =  REC_RESB - TEL_NUMBER.    "经销店电话
    REC_RKPF
- VSBED       =  C_ZZ.                   "装运条件
    REC_RKPF
- PROCE       =   TEXT - 018 .               "出库路径
    REC_RKPF
- VGBEL       =  REC_RESB - VGBEL.         "移送移管的指令传票
    REC_RKPF
- STREET      =  REC_RESB - STREET.        "送货地址
    REC_RKPF
- WERKS       =  REC_RESB - WERKS.         "提货仓库
    REC_RKPF
- NAME2       =  REC_RESB - NAME2.         "提货仓库名称
    REC_RKPF
- ZZOP2FLG    =  REC_RESB - ZZOP2FLG.      "再印刷标志位

    COLLECT REC_RKPF 
INTO  TBL_RKPF .              "汇集移管抬头
  ENDLOOP.
* 2 - 2 - 2  项目 [ 出库路径 ] 的出力内容
  CLEAR REC_LIKP.
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
   
CASE  REC_LIKP - VSBED.                           " [ 装运条件 ]
   
WHEN  C_01.                                     " 01  出库路径为预处理
     REC_LIKP
- PROCE  =   TEXT - 011 .
   
WHEN  C_02.                                     " 02  送货
     REC_LIKP
- PROCE  =   TEXT - 012 .
   
WHEN  C_03.                                     " 03  送货(无偿)
     REC_LIKP
- PROCE  =   TEXT - 013 .
   
WHEN  C_04.                                     " 04  紧急送货
     REC_LIKP
- PROCE  =   TEXT - 014 .
   
WHEN  C_05.                                     " 05  紧急送货(无偿)
     REC_LIKP
- PROCE  =   TEXT - 015 .
   
WHEN  C_11.                                     " 11  输出
     REC_LIKP
- PROCE  =   TEXT - 016 .
   
WHEN  C_31.                                     " 31  移送
     REC_LIKP
- PROCE  =   TEXT - 017 .
   
WHEN  OTHERS.                                   "其它 移管
     REC_LIKP
- PROCE  =   TEXT - 018 .
   ENDCASE.
   MODIFY TBL_LIKP 
FROM  REC_LIKP.
  ENDLOOP.
* 2 - 2 - 3   [ 装运条件 ] 是01时 输出运货车号 交易者号 交易者名称
  PERFORM GET_TEXT.
* 2 - 2 - 4  取得机种类别
  LOOP AT TBL_LIPS 
INTO  REC_LIPS.                 "提货 / 送货 / 移送
    PERFORM GET_LIPS_MATERIAL_TYPE.
  ENDLOOP.
  LOOP AT TBL_RESB 
INTO  REC_RESB.                 "移管
    PERFORM GET_RESB_MATERIAL_TYPE.
  ENDLOOP.
* 2 - 2 - 5  计算印刷时间
  PERFORM GET_TIME.
  
IF  G_TFLG  =  C_1.
    G_DATE 
=  SY - DATUM  -   1 .
  ELSEIF G_TFLG 
=  C_2.
    G_DATE 
=  SY - DATUM  +   1 .
  
ELSE .
    G_DATE 
=  SY - DATUM.
  ENDIF.
* 2 - 2 - 6  现在的页
* 2 - 2 - 7  总页数
ENDFORM.                                          " DATA_EDIT

*& -- -------------------------------------------------------------------*
*&   FORM  GET_TEXT
*&   功能: 装运条件" 01 "时 输出运货车号 交易者号 交易者名称
*& -- -------------------------------------------------------------------*
FORM GET_TEXT.
DATA:   LO_TBL_TLINE 
LIKE   TABLE   OF  TLINE.         "读取的文本行
DATA:   LO_NAME  
LIKE  THEAD - TDNAME.               "将要读取的文本名
DATA:   LO_REC_TLINE 
LIKE  TLINE.                  "读取的文本行
CLEAR REC_LIKP.
* 2 - 2 - 3  装运条件" 01 "时
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
IF  REC_LIKP - VSBED  =  C_01.
* 输出运货车号
       REFRESH LO_TBL_TLINE.
       LO_NAME 
=  REC_LIKP - VBELN.                  "交货凭证号
       CALL 
FUNCTION   ' READ_TEXT '
         EXPORTING
           CLIENT                  
=  SY - MANDT     "登录的客户机编号
           ID                      
=  C_Z001       "要读的文本的文本标识
           LANGUAGE                
=  C_ZH         "将要读取的文本语言
           NAME                    
=  LO_NAME      "将要读取的文本名
           OBJECT                  
=  C_VBBK       "将要读取的文本对象
         TABLES
           LINES                   
=  LO_TBL_TLINE "读文本的文本标题
         EXCEPTIONS
          ID                      
=   1              "无效的文本标识
          LANGUAGE                
=   2              "无效的语言
          NAME                    
=   3              "无效的文本名
          NOT_FOUND               
=   4              "找不到说明文本
          OBJECT                  
=   5              "无效的对象名
          REFERENCE_CHECK         
=   6              "参照链中断
          WRONG_ACCESS_TO_ARCHIVE 
=   7              "访问时存档句柄无效
          OTHERS                  
=   8 .            "其他
       
IF  SY - SUBRC  =   0 .
         LOOP AT LO_TBL_TLINE 
INTO  LO_REC_TLINE  WHERE  TDLINE  <>   SPACE .
           REC_LIKP
- Z001  =  LO_REC_TLINE - TDLINE.   "运货车号
         ENDLOOP.
       ENDIF.
* 输出交易者号
       REFRESH LO_TBL_TLINE.
       LO_NAME 
=  REC_LIKP - VBELN.
       CALL 
FUNCTION   ' READ_TEXT '
         EXPORTING
           CLIENT                        
=  SY - MANDT
           ID                            
=  C_Z002
           LANGUAGE                      
=  C_ZH
           NAME                          
=  LO_NAME
           OBJECT                        
=  C_VBBK
         TABLES
           LINES                         
=  LO_TBL_TLINE
         EXCEPTIONS
          ID                      
=   1
          LANGUAGE                
=   2
          NAME                    
=   3
          NOT_FOUND               
=   4
          OBJECT                  
=   5
          REFERENCE_CHECK         
=   6
          WRONG_ACCESS_TO_ARCHIVE 
=   7
          OTHERS                  
=   8 .
       
IF  SY - SUBRC  =   0 .
         LOOP AT LO_TBL_TLINE 
INTO  LO_REC_TLINE  WHERE  TDLINE  <>   SPACE .
           REC_LIKP
- Z002  =  LO_REC_TLINE - TDLINE.    "交易者号
         ENDLOOP.
       ENDIF.
* 输出交易者名称
       REFRESH LO_TBL_TLINE.
       LO_NAME 
=  REC_LIKP - VBELN.
       CALL 
FUNCTION   ' READ_TEXT '
         EXPORTING
           CLIENT                        
=  SY - MANDT
           ID                            
=  C_Z003
           LANGUAGE                      
=  C_ZH
           NAME                          
=  LO_NAME
           OBJECT                        
=  C_VBBK
         TABLES
           LINES                         
=  LO_TBL_TLINE
         EXCEPTIONS
          ID                      
=   1
          LANGUAGE                
=   2
          NAME                    
=   3
          NOT_FOUND               
=   4
          OBJECT                  
=   5
          REFERENCE_CHECK         
=   6
          WRONG_ACCESS_TO_ARCHIVE 
=   7
          OTHERS                  
=   8 .
       
IF  SY - SUBRC  =   0 .
         LOOP AT LO_TBL_TLINE 
INTO  LO_REC_TLINE  WHERE  TDLINE  <>   SPACE .
           REC_LIKP
- Z003  =  LO_REC_TLINE - TDLINE.   "交易者名称
         ENDLOOP.
       ENDIF.
       MODIFY TBL_LIKP 
FROM   REC_LIKP
                TRANSPORTING Z001                 "运货车号
                             Z002                 "交易者号
                             Z003.                "交易者名称
    ENDIF.
  ENDLOOP.
ENDFORM.                                          "GET_TEXT

*& -- -------------------------------------------------------------------*
*&   FORM  GET_LIPS_MATERIAL_TYPE
*&   功能: 提货 / 送货 / 移送 取得机种类别
*& -- -------------------------------------------------------------------*
FORM GET_LIPS_MATERIAL_TYPE.
* 要分类的对象码
DATA: LO_OBJKEY              
LIKE  BAPI1003_KEY - OBJECT,
* 分类 BAPI  -  关键字字段
      LO_TBL_OBJKEY          
LIKE  BAPI1003_OBJECT_KEYS
                                  OCCURS 
0   WITH  HEADER LINE,
* 返回参数
      LO_TBL_RETURN          
LIKE  BAPIRET2
                                  OCCURS 
0   WITH  HEADER LINE,
* 分配 BAPI  -  NUM、DATE、TIME 类型的值
      LO_TBL_ALLOCVALUESNUM  
LIKE  BAPI1003_ALLOC_VALUES_NUM
                                  OCCURS 
0   WITH  HEADER LINE,
* 分配 BAPI  -   CHAR 、BOOL 类型的值
      LO_TBL_ALLOCVALUESCHAR 
LIKE  BAPI1003_ALLOC_VALUES_CHAR
                                  OCCURS 
0   WITH  HEADER LINE,
* 分配 BAPI  -  CURR 类型值
      LO_TBL_ALLOCVALUESCURR 
LIKE  BAPI1003_ALLOC_VALUES_CURR
                                  OCCURS 
0   WITH  HEADER LINE.

  LO_TBL_OBJKEY
- KEY_FIELD  =  C_MATNR.            "MATNR
  LO_TBL_OBJKEY
- VALUE_EXT  =  REC_LIPS - MATNR.     "品目代码
  APPEND LO_TBL_OBJKEY.
  CLEAR: LO_OBJKEY.
  CALL 
FUNCTION   ' BAPI_OBJCL_CONCATENATEKEY '
    EXPORTING
      OBJECTTABLE    
=  C_MARA
    IMPORTING
      OBJECTKEY_CONC 
=  LO_OBJKEY
    TABLES
      OBJECTKEYTABLE 
=  LO_TBL_OBJKEY
      
RETURN           =  LO_TBL_RETURN.

  
IF   NOT  LO_TBL_RETURN  IS  INITIAL.                "检查是否出错
    
EXIT .
  ENDIF.

  CALL 
FUNCTION   ' BAPI_OBJCL_GETDETAIL '
    EXPORTING
      OBJECTKEY       
=  LO_OBJKEY
      OBJECTTABLE     
=  C_MARA
      CLASSNUM        
=  C_ZCLASS_MAT
      CLASSTYPE       
=  C_001
    TABLES
      ALLOCVALUESNUM  
=  LO_TBL_ALLOCVALUESNUM
      ALLOCVALUESCHAR 
=  LO_TBL_ALLOCVALUESCHAR
      ALLOCVALUESCURR 
=  LO_TBL_ALLOCVALUESCURR
      
RETURN            =  LO_TBL_RETURN.
  
READ   TABLE  LO_TBL_ALLOCVALUESCHAR  WITH   KEY  CHARACT  =  C_TYPEC.
  
IF  SY - SUBRC  =   0 .
    REC_LIPS
- MATERIAL_TYPE  =  LO_TBL_ALLOCVALUESCHAR - VALUE_CHAR.
    MODIFY TBL_LIPS 
FROM  REC_LIPS.
  ENDIF.
  REFRESH LO_TBL_OBJKEY.
ENDFORM.                                         "GET_LIPS_MATERIAL_TYPE

*& -- -------------------------------------------------------------------*
*&   FORM  GET_RESB_MATERIAL_TYPE
*&   功能: 移管 取得机种类别
*& -- -------------------------------------------------------------------*
FORM GET_RESB_MATERIAL_TYPE.
* 要分类的对象码
DATA: LO_OBJKEY
        
LIKE  BAPI1003_KEY - OBJECT,
* 分类 BAPI  -  关键字字段
      LO_TBL_OBJKEY
       
LIKE  BAPI1003_OBJECT_KEYS        OCCURS  0   WITH  HEADER LINE,
* 返回参数
      LO_TBL_RETURN
        
LIKE  BAPIRET2                   OCCURS  0   WITH  HEADER LINE,
* 分配 BAPI  -  NUM、DATE、TIME 类型的值
      LO_TBL_ALLOCVALUESNUM
        
LIKE  BAPI1003_ALLOC_VALUES_NUM  OCCURS  0   WITH  HEADER LINE,
* 分配 BAPI  -   CHAR 、BOOL 类型的值
      LO_TBL_ALLOCVALUESCHAR
        
LIKE  BAPI1003_ALLOC_VALUES_CHAR OCCURS  0   WITH  HEADER LINE,
* 分配 BAPI  -  CURR 类型值
      LO_TBL_ALLOCVALUESCURR
        
LIKE  BAPI1003_ALLOC_VALUES_CURR OCCURS  0   WITH  HEADER LINE.

  LO_TBL_OBJKEY
- KEY_FIELD  =  C_MATNR.             "MATNR
  LO_TBL_OBJKEY
- VALUE_EXT  =  REC_RESB - MATNR.      "品目代码
  APPEND LO_TBL_OBJKEY.
  CLEAR: LO_OBJKEY.
  CALL 
FUNCTION   ' BAPI_OBJCL_CONCATENATEKEY '
    EXPORTING
      OBJECTTABLE    
=  C_MARA
    IMPORTING
      OBJECTKEY_CONC 
=  LO_OBJKEY
    TABLES
      OBJECTKEYTABLE 
=  LO_TBL_OBJKEY
      
RETURN           =  LO_TBL_RETURN.

  
IF   NOT  LO_TBL_RETURN  IS  INITIAL.               "检查是否出错
    
EXIT .
  ENDIF.

  CALL 
FUNCTION   ' BAPI_OBJCL_GETDETAIL '
    EXPORTING
      OBJECTKEY       
=  LO_OBJKEY
      OBJECTTABLE     
=  C_MARA
      CLASSNUM        
=  C_ZCLASS_MAT
      CLASSTYPE       
=  C_001
    TABLES
      ALLOCVALUESNUM  
=  LO_TBL_ALLOCVALUESNUM
      ALLOCVALUESCHAR 
=  LO_TBL_ALLOCVALUESCHAR
      ALLOCVALUESCURR 
=  LO_TBL_ALLOCVALUESCURR
      
RETURN            =  LO_TBL_RETURN.
  
READ   TABLE  LO_TBL_ALLOCVALUESCHAR  WITH   KEY  CHARACT  =  C_TYPEC.
  
IF  SY - SUBRC  =   0 .
    REC_RESB
- MATERIAL_TYPE  =  LO_TBL_ALLOCVALUESCHAR - VALUE_CHAR.
                                                   "特性值
    MODIFY TBL_RESB 
FROM  REC_RESB.
  ENDIF.
  REFRESH LO_TBL_OBJKEY.
ENDFORM.                                         "GET_RESB_MATERIAL_TYPE

*& -- -------------------------------------------------------------------*
*&   FORM  GET_TIME
*&   功能: 取得对应本地时间
*& -- -------------------------------------------------------------------*
FORM GET_TIME.
  DATA: LO_TIME1 
LIKE  SY - UZEIT,                    "系统时间
        LO_TIME2 
LIKE  SY - UZEIT,                    "用户时间
        LO_TIME3 
LIKE  SY - UZEIT,                    "对应本地时间
        LO_UT1   
LIKE  TTZR - UTCSIGN,                "差别1
        LO_UT2   
LIKE  TTZR - UTCSIGN,                "差别2
        LO_ZONE1 
LIKE  TTZZ - TZONE,                  "时区1
        LO_ZONE2 
LIKE  USR02 - TZONE.                 "时区2
  CLEAR: G_TIME.
  CLEAR: G_TFLG.
  CALL 
FUNCTION   ' TZON_GET_OS_TIMEZONE '
   IMPORTING
     EF_TIMEZONE         
=  LO_ZONE1.               "时区1
* 取得标准时间
  PERFORM GET_TIME1
            USING
              LO_ZONE1                             "时区1
            CHANGING
              LO_TIME1                             "系统时间
              LO_UT1.                              "差别1
  
SELECT   SINGLE  TZONE
    
INTO  LO_ZONE2
    
FROM  USR02
   
WHERE  BNAME  =  SY - UNAME.                         "用户名称
  
IF  LO_ZONE2  =   SPACE .
    LO_ZONE2 
=  C_UTC8.                             "时区2
  ENDIF.
* 取得标准时间
  PERFORM GET_TIME1
            USING
              LO_ZONE2                             "时区2
            CHANGING
              LO_TIME2                             "用户时间
              LO_UT2.                              "差别2

DEFINE TIME.
  LO_TIME3 
=  SY - UZEIT  & 1  LO_TIME1  & 2  LO_TIME2.     "对应本地时间
END - OF - DEFINITION.
  
IF  LO_UT1  =  C_A  AND  LO_UT2  =  C_A.
    TIME 
-   + .
    
IF  LO_TIME3  >  SY - UZEIT.
      G_TFLG 
=  C_1.
    ENDIF.
  ELSEIF LO_UT1 
=  C_A  AND  LO_UT2  =  C_D.
    TIME 
-   - .
    
IF  LO_TIME3  >  SY - UZEIT.
      G_TFLG 
=  C_1.
    ENDIF.
  ELSEIF LO_UT1 
=  C_D  AND  LO_UT2  =  C_A.
    TIME 
+   + .
    
IF  LO_TIME3  <  SY - UZEIT.
      G_TFLG 
=  C_2.
    ENDIF.
  ELSEIF LO_UT1 
=  C_D  AND  LO_UT2  =  C_D.
    TIME 
+   - .
    
IF  LO_TIME3  <  SY - UZEIT.
      G_TFLG 
=  C_2.
    ENDIF.
  ENDIF.
  G_TIME 
=  LO_TIME3.
ENDFORM.                                          "GET_TIME

*& -- -------------------------------------------------------------------*
*&   FORM  GET_TIME1
*&   功能: 取得标准时间
*& -- -------------------------------------------------------------------*
*        -- >P_ZONE  时区
*        < -- P_TIME  时间
*        < -- P_UT    差别
* -- --------------------------------------------------------------------*
FORM GET_TIME1
       USING
         P_ZONE
       CHANGING
         P_TIME
         P_UT.
  DATA: LO_ZONERULE 
LIKE  TTZZ - ZONERULE.           "时区规则
  
SELECT   SINGLE  ZONERULE
    
INTO  LO_ZONERULE
    
FROM  TTZZ
   
WHERE  TZONE  =  P_ZONE.
  
SELECT   SINGLE  UTCDIFF
         UTCSIGN
    
INTO  (P_TIME,P_UT)
    
FROM  TTZR
   
WHERE  ZONERULE  =  LO_ZONERULE.

ENDFORM.                                          " GET_TIME1

*& -- -------------------------------------------------------------------*
*&   FORM  WRITE_SAPSCRIPT
*&   功能: 帐票输出
*& -- -------------------------------------------------------------------*
FORM WRITE_SAPSCRIPT.
DATA: LO_LINE       TYPE I,                       "条目计数
      LO_TITLE(
15 )  TYPE C,                       "当前标题
      LO_HEAD(
15 )   TYPE C,                       "当前头部
      LO_INDEX      TYPE I VALUE 
0 ,               "指示变量
      LO_REC_OPTIONS 
LIKE   ITCPO.                 "打印选项
      LO_REC_OPTIONS
- TDDEST     =  PA_PDEST.        "输出设备
      LO_REC_OPTIONS
- TDIMMED    =  C_X.             "立即打印
      LO_REC_OPTIONS
- TDDELETE   =   SPACE .           "打印后立即删除
      LO_REC_OPTIONS
- TDNEWID    =  C_X.             "新打印请求
      LO_REC_OPTIONS
- TDPREVIEW  =  C_X.             "打印预览
* 2 - 3 - 1排序
  SORT TBL_LIKP 
BY  VBELN ASCENDING
                   VSBED ASCENDING.
  SORT TBL_LIPS 
BY  MATNR ASCENDING.
  SORT TBL_RESB 
BY  RSNUM ASCENDING
                   MATNR ASCENDING.
  SORT TBL_RKPF 
BY  RSNUM ASCENDING.
* 2 - 3 - 2帐票出力
*  打开文档格式
   PERFORM FORM_OPEN
             USING
               C_SAPSCRIPT_ID                    "表格名称
               C_ZH                              "语言
               LO_REC_OPTIONS.                   "打印机选项
* 送货 / 提货 / 移送 输出
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
IF  LO_INDEX  <>   0 .                            "是否为第1页
      PERFORM FORM_CONTROL
                USING
                  
' NEW-PAGE ' .
    ENDIF.
    LO_INDEX 
=  LO_INDEX  +   1 .
    LO_LINE 
=   0 .
    
IF  REC_LIKP - ZZOP2FLG  IS  INITIAL.
      G_ZZOP2FLGCHAR 
=   SPACE .
    
ELSE .
      G_ZZOP2FLGCHAR 
=   TEXT - 020 .                  "再印刷
    ENDIF.
    
CASE  REC_LIKP - VSBED.                          "装运条件
* 2 - 3 - 2 - 1   [ 装运条件 ]  为常量01场合   提货格式输出
      
WHEN  C_01.
        PERFORM FORM_WRITE
                  USING
                    
' E_TITLE_T '                   "提货单标题
                    
' HEAD ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD '
                    
' MAIN ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD_T '                     "提货单抬头
                    
' MAIN ' .
        LO_TITLE 
=   ' E_TITLE_T ' .
        LO_HEAD  
=   ' E_HEAD_T ' .
* 2 - 3 - 2 - 2   [ 装运条件 ]  为常量02 / 03 / 04 / 05 / 11场合   送货格式输出
      
WHEN  C_02  OR
           C_03 
OR
           C_04 
OR
           C_05 
OR
           C_11.
        PERFORM FORM_WRITE
                  USING
                    
' E_TITLE_S '                    "送货单标题
                    
' HEAD ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD '
                    
' MAIN ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD_S '                     "送货单抬头
                    
' MAIN ' .
        LO_TITLE 
=   ' E_TITLE_S ' .
        LO_HEAD  
=   ' E_HEAD_S ' .
      
WHEN  C_31.
* 2 - 3 - 2 - 2   [ 装运条件 ]  为常量31场合   送货格式输出
        PERFORM FORM_WRITE
                  USING
                    
' E_TITLE_S '                   "送货单标题
                    
' HEAD ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD '
                    
' MAIN ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD_YS '                    "移送单抬头
                    
' MAIN ' .
        LO_TITLE 
=   ' E_TITLE_S ' .
        LO_HEAD 
=   ' E_HEAD_YS ' .
      
WHEN  OTHERS.                                "其它场合
        PERFORM FORM_WRITE
                  USING
                    
' E_TITLE_S '
                    
' HEAD ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD '
                    
' MAIN ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD_YS '
                    
' MAIN ' .
        LO_TITLE 
=   ' E_TITLE_YS ' .
        LO_HEAD  
=   ' E_HEAD_YS ' .
    ENDCASE.
    PERFORM FORM_WRITE
              USING
                
' E_ITEM_HEAD '
                
' MAIN ' .                           "明细头名称
    G_LINE 
=   ' 5.2 ' .
    DO 
29  TIMES.                                  "画29行明细表格行
      PERFORM FORM_WRITE
                USING
                  
' E_ITEM_BODY '
                  
' MAIN ' .
      G_LINE 
=  G_LINE  +   1 .
    ENDDO.
* 详细信息输出
    CLEAR REC_LIPS.
    LOOP AT TBL_LIPS 
INTO  REC_LIPS
      
WHERE  VBELN  =  REC_LIKP - VBELN.               "与抬头对应的明细
       
IF  LO_LINE  >=   29 .                          "数据明细行大于29,分页
         LO_LINE 
=   0 .
         PERFORM FORM_WRITE
                   USING
                     
' E_ITEM_FOOT '
                     
' MAIN ' .                      "当前页提货仓库
         PERFORM FORM_WRITE
                   USING
                     
' E_FOOT '
                     
' FOOT ' .                      "打印当前页页脚
         PERFORM FORM_CONTROL
                   USING
                     
' NEW-PAGE ' .                  "新建页
         PERFORM FORM_WRITE
                   USING
                     LO_TITLE
                     
' HEAD ' .                      "上一页标题信息
         PERFORM FORM_WRITE
                   USING
                     
' E_HEAD '
                     
' MAIN ' .
         PERFORM FORM_WRITE
                   USING
                     LO_HEAD
                     
' MAIN ' .                      "上一页头部信息
         PERFORM FORM_WRITE
                   USING
                     
' E_ITEM_HEAD '
                     
' MAIN ' .                      "明细头名称
         G_LINE 
=   ' 5.2 ' .
         DO 
29  TIMES.
           PERFORM FORM_WRITE
                     USING
                       
' E_ITEM_BODY '
                       
' MAIN ' .                    "画表格行
           G_LINE 
=  G_LINE  +   1 .                   "表格行加1
         ENDDO.
       ENDIF.
       PERFORM FORM_WRITE
                 USING
                   
' E_ITEM_DATA '                   "打印一条明细
                   
' MAIN ' .
       LO_LINE 
=  LO_LINE  +   1 .                     "明细行加1
    ENDLOOP.
    PERFORM FORM_WRITE
              USING
                
' E_ITEM_FOOT '
                
' MAIN ' .                           "打印提货仓库
    PERFORM FORM_WRITE
              USING
                
' E_FOOT '
                
' FOOT ' .                           "打印页脚
  ENDLOOP.

* 移管 输出
  LOOP AT TBL_RKPF 
INTO  REC_RKPF.
    
IF  LO_INDEX  <>   0 .
      PERFORM FORM_CONTROL
                USING
                  
' NEW-PAGE ' .
    ENDIF.
    LO_INDEX 
=  LO_INDEX  +   1 .
    LO_LINE 
=   0 .
    
IF  REC_RKPF - ZZOP2FLG  IS  INITIAL.              "再印刷标志
      G_ZZOP2FLGCHAR 
=   SPACE .
    
ELSE .
      G_ZZOP2FLGCHAR 
=   TEXT - 020 .                  " [ 再印刷 ]
    ENDIF.
    PERFORM FORM_WRITE
              USING
                
' E_TITLE_S '                        "送货单标题
                
' HEAD ' .
    PERFORM FORM_WRITE
              USING
                
' E_HEAD '                           "抬头方框
                
' MAIN ' .
    PERFORM FORM_WRITE
              USING
                
' E_HEAD_YG '                        "移管抬头数据
                
' MAIN ' .
    PERFORM FORM_WRITE
              USING
                
' E_ITEM_HEAD '                       "明细头名称
                
' MAIN ' .
* 打印29行明细条目框
    G_LINE 
=   ' 5.2 ' .
    DO 
29  TIMES.
      PERFORM FORM_WRITE
                USING
                  
' E_ITEM_BODY '
                  
' MAIN ' .
      G_LINE 
=  G_LINE  +   1 .
    ENDDO.
    G_LINE 
=   ' 5.2 ' .
* 详细信息输出
    CLEAR REC_RESB.
    LOOP AT TBL_RESB 
INTO  REC_RESB
      
WHERE  RSNUM  =  REC_RKPF - RSNUM.
       
IF  LO_LINE  >=   29 .
         LO_LINE 
=   0 .
        PERFORM FORM_WRITE
                  USING
                    
' E_ITEM_FOOT_YG '
                    
' MAIN ' .                        "当前页提货仓库
        PERFORM FORM_WRITE
                  USING
                    
' E_FOOT '
                    
' FOOT ' .                        "打印当前页页脚
        PERFORM FORM_CONTROL
                  USING
                    
' NEW-PAGE ' .                    "新建页
        PERFORM FORM_WRITE
                  USING
                    
' E_TITLE_S '                     "标题
                    
' HEAD ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD '                        "抬头方框
                    
' MAIN ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_HEAD_YG '                     "抬头数据
                    
' MAIN ' .
        PERFORM FORM_WRITE
                  USING
                    
' E_ITEM_HEAD '
                    
' MAIN ' .                        "明细头名称
         G_LINE 
=   ' 5.2 ' .
         DO 
29  TIMES.
           PERFORM FORM_WRITE
                     USING
                       
' E_ITEM_BODY '
                       
' MAIN ' .
           G_LINE 
=  G_LINE  +   1 .
         ENDDO.
         G_LINE 
=   ' 5.2 ' .
       ENDIF.
       PERFORM FORM_WRITE
                 USING
                   
' E_ITEM_DATA_YG '
                   
' MAIN ' .                        "打印一条移管数据
       LO_LINE 
=  LO_LINE  +   1 .                     "数据行加1
    ENDLOOP.
    PERFORM FORM_WRITE
              USING
                
' E_ITEM_FOOT_YG '
                
' MAIN ' .                           "打印提货仓库
    PERFORM FORM_WRITE
              USING
                
' E_FOOT '
                
' FOOT ' .                           "打印页脚
  ENDLOOP.

  PERFORM FORM_CLOSE.                             "关闭文档格式
ENDFORM.                                          " WRITE_SAPSCRIPT

*& -- -------------------------------------------------------------------*
*&   FORM  FORM_OPEN
*&   功能: 打开文档格式
*& -- -------------------------------------------------------------------*
*     -- >  I_FORM_NAME       FORM的ID
*     -- >  I_LANGUAGE        语言
*     -- >  I_OPTIONS         打印机选项
* -- --------------------------------------------------------------------*
FORM FORM_OPEN
       USING
         I_FORM_NAME TYPE 
ANY
         I_LANGUAGE  TYPE 
ANY
         I_OPTIONS   TYPE 
ANY .
CALL 
FUNCTION   ' OPEN_FORM '
   EXPORTING
     FORM                              
=  I_FORM_NAME
     LANGUAGE                          
=  I_LANGUAGE
     OPTIONS                           
=  I_OPTIONS
   EXCEPTIONS
     CANCELED                          
=   1
     DEVICE                            
=   2
     FORM                              
=   3
     OPTIONS                           
=   4
     UNCLOSED                          
=   5
     MAIL_OPTIONS                      
=   6
     ARCHIVE_ERROR                     
=   7
     INVALID_FAX_NUMBER                
=   8
     MORE_PARAMS_NEEDED_IN_BATCH       
=   9
     SPOOL_ERROR                       
=   10
     CODEPAGE                          
=   11
     OTHERS                            
=   12 .
  
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.                                          " FORM_OPEN
*& -- -------------------------------------------------------------------*
*&   FORM  FORM_WRITE
*&   功能: 指定WINDOW ELEMENT输出到当前打开的FORM
*& -- -------------------------------------------------------------------*
*     -- >  I_ELEMENT_NAME     文本元素名称
*     -- >  I_WINDOW_NAME      页窗口名称
* -- --------------------------------------------------------------------*
FORM FORM_WRITE USING I_ELEMENT_NAME TYPE  ANY
                      I_WINDOW_NAME  TYPE 
ANY .
  CALL 
FUNCTION   ' WRITE_FORM '
    EXPORTING
      ELEMENT                        
=  I_ELEMENT_NAME
      WINDOW                         
=  I_WINDOW_NAME
      EXCEPTIONS
      ELEMENT                        
=   1
      
FUNCTION                         =   2
      TYPE                           
=   3
      UNOPENED                       
=   4
      UNSTARTED                      
=   5
      WINDOW                         
=   6
      BAD_PAGEFORMAT_FOR_PRINT       
=   7
      SPOOL_ERROR                    
=   8
      CODEPAGE                       
=   9
      OTHERS                         
=   10 .
  
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.                                          "FORM_WRITE
*& -- -------------------------------------------------------------------*
*&   FORM  FORM_CLOSE
*&   功能: 关闭文档格式
*& -- -------------------------------------------------------------------*
FORM FORM_CLOSE.
  CALL 
FUNCTION   ' CLOSE_FORM '
    EXCEPTIONS
      UNOPENED                       
=   1
      BAD_PAGEFORMAT_FOR_PRINT       
=   2
      SEND_ERROR                     
=   3
      SPOOL_ERROR                    
=   4
      CODEPAGE                       
=   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.
ENDFORM.                                          "FORM_CLOSE

*& -- -------------------------------------------------------------------*
*&   FORM  FORM_CONTROL
*&   功能: FROM控制
*& -- -------------------------------------------------------------------*
*     -- >  I_COMMAND     FORM命令
* -- --------------------------------------------------------------------*
FORM FORM_CONTROL
       USING
         I_COMMAND TYPE 
ANY .
CALL 
FUNCTION   ' CONTROL_FORM '
               EXPORTING
                    COMMAND 
=  I_COMMAND
               EXCEPTIONS
                 UNOPENED        
=   1
                 UNSTARTED       
=   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.                                         "FORM_CONTROL
*& -- -------------------------------------------------------------------*
*&   FORM  WRITE_SMARTFORM
*&   功能: SMARTFROM输出
*& -- -------------------------------------------------------------------*
FORM WRITE_SMARTFORM.
  DATA LO_RS38L_FNAM TYPE RS38L_FNAM.            "SMARTFORMS文件名
  SORT TBL_LIKP 
BY  VBELN.                        "对内部表TBL_LIKP排序
  SORT TBL_RKPF 
BY  RSNUM.                        "对内部表TBL_RKPF排序

  CONCATENATE C_SMARTFORM_ID                     "SMARTFORM名称
              C_LIKP                             "表名LIKP
              SY
- UZEIT                           "当前时间
         
INTO  G_LIKP.                            "生成标记ID
  REC_INDX
- AEDAT  =  SY - DATUM.                     "SYST日期
  REC_INDX
- USERA  =  SY - UNAME.                     "用户名
  REC_INDX
- PGMID  =  SY - REPID.                     "ABAP 程序名
  EXPORT TBL_LIKP
[]                               "把内表存入数据库缓存
      
TO   DATABASE  INDX(HK)                       "EXPORT 数据表中的区域
      ID G_LIKP                                  "INDX中用户
- 定义关键字
    
FROM  REC_INDX.

  CONCATENATE C_SMARTFORM_ID                     "SMARTFORM名称
              C_LIPS                             "表名LIPS
              SY
- UZEIT                           "当前时间
         
INTO  G_LIPS.                            "生成标记ID
  REC_INDX
- AEDAT  =  SY - DATUM.                     "SYST日期
  REC_INDX
- USERA  =  SY - UNAME.                     "用户名
  REC_INDX
- PGMID  =  SY - REPID.                     "ABAP 程序名
  EXPORT TBL_LIPS
[]                               "把内表存入数据库缓存
      
TO   DATABASE  INDX(HK)                       "EXPORT 数据表中的区域
      ID G_LIPS                                  "INDX中用户
- 定义关键字
    
FROM  REC_INDX.

  CONCATENATE C_SMARTFORM_ID                     "SMARTFORM名称
              C_RKPF                             "表名RKPF
              SY
- UZEIT                           "当前时间
         
INTO  G_RKPF.                            "生成标记ID
  REC_INDX
- AEDAT  =  SY - DATUM.                     "SYST日期
  REC_INDX
- USERA  =  SY - UNAME.                     "用户名
  REC_INDX
- PGMID  =  SY - REPID.                     "ABAP 程序名
  EXPORT TBL_RKPF
[]                               "把内表存入数据库缓存
      
TO   DATABASE  INDX(HK)                       "EXPORT 数据表中的区域
      ID G_RKPF                                  "INDX中用户
- 定义关键字
    
FROM  REC_INDX.

  CONCATENATE C_SMARTFORM_ID                     "SMARTFORM名称
              C_RESB                             "表名RESB
              SY
- UZEIT                           "当前时间
         
INTO  G_RESB.                            "生成标记ID
  REC_INDX
- AEDAT  =  SY - DATUM.                     "SYST日期
  REC_INDX
- USERA  =  SY - UNAME.                     "用户名
  REC_INDX
- PGMID  =  SY - REPID.                     "ABAP 程序名
  EXPORT TBL_RESB
[]                               "把内表存入数据库缓存
      
TO   DATABASE  INDX(HK)                       "EXPORT 数据表中的区域
      ID G_RESB                                  "INDX中用户
- 定义关键字
    
FROM  REC_INDX.

  CALL 
FUNCTION   ' SSF_FUNCTION_MODULE_NAME '
    EXPORTING
      FORMNAME                 
=   ' ZMMR001_A140 '   "SMARTFORMS程序名
   IMPORTING
      FM_NAME                  
=  LO_RS38L_FNAM   "对应的函数名
   EXCEPTIONS
     NO_FORM                   
=   1
     NO_FUNCTION_MODULE        
=   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.

  CALL 
FUNCTION  LO_RS38L_FNAM
  EXPORTING
      P_LIKP                   
=  G_LIKP          "TBL_LIKP对应的ID
      P_LIPS                   
=  G_LIPS          "TBL_LIPS对应的ID
      P_RKPF                   
=  G_RKPF          "TBL_RKPF对应的ID
      P_RESB                   
=  G_RESB          "TBL_RESB对应的ID
   EXCEPTIONS
     FORMATTING_ERROR          
=   1
     INTERNAL_ERROR            
=   2
     SEND_ERROR                
=   3
     USER_CANCELED             
=   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.

  
DELETE   FROM   DATABASE  INDX(HK) ID G_LIKP.        "删除缓存数据TBL_LIKP
  
DELETE   FROM   DATABASE  INDX(HK) ID G_LIPS.        "删除缓存数据TBL_LIPS
  
DELETE   FROM   DATABASE  INDX(HK) ID G_LIKP.        "删除缓存数据TBL_RKPF
  
DELETE   FROM   DATABASE  INDX(HK) ID G_LIPS.        "删除缓存数据TBL_RESB
ENDFORM.                                          "WRITE_SMARTFORM

*& -- -------------------------------------------------------------------*
*&   FORM  PROCESS_END
*&   功能: 打印完毕后,确定已打印标志,更新数据库
*& -- -------------------------------------------------------------------*
FORM PROCESS_END.
  LOOP AT TBL_LIKP 
INTO  REC_LIKP.
    
UPDATE  LIPS                                   "确定LIPS中已打印标志
    
SET  ZZOP2FLG  =  C_X
    
WHERE  VBELN  =  REC_LIKP - VBELN.
  ENDLOOP.
  LOOP AT TBL_RESB 
INTO  REC_RESB.
    
UPDATE  RESB                                   "确定RESB中已打印标志
    
SET  ZZOP2FLG  =  C_X
    
WHERE  RSNUM  =  REC_RESB - RSNUM.
  ENDLOOP.
ENDFORM.                                         "PROCESS_END

 

你可能感兴趣的:(代码)