*----------------------------------------------------------------------*
* Program name : ZSD_BDC_ORDERHEAD Date written: 07-11-10 *
* Author's name: HouZhiYu Last update : *
* Program title: 销售订单表头批量创建 *
*----------------------------------------------------------------------*
REPORT ZSD_BDC_ORDERHEAD_01_HZY MESSAGE-ID ZB.
TABLES: VBAK. "销售凭证:抬头数据
**--------传入HEAD数据----------------
DATA: BEGIN OF L_VBAK OCCURS 0,
AUART LIKE VBAK-AUART,"订单类型
VKORG LIKE VBAK-VKORG,"销售组织
VTWEG LIKE VBAK-VTWEG,"分销渠道
SPART LIKE VBAK-SPART,"部门
VKBUR LIKE VBAK-VKBUR,"销售办事处
VKGRP LIKE VBAK-VKGRP,"销售组
AGV_KUNNR LIKE KUAGV-KUNNR,"售达方
WEV_KUNNR LIKE KUWEV-KUNNR,"送达方
BSTKD LIKE VBKD-BSTKD,"采购订单编号
BSTDK LIKE VBKD-BSTDK,"采购订单日期
KETDAT LIKE RV45A-KETDAT,"请求交货日期
* DWERK LIKE RV45A-DWERK,"交货工厂
WAERK LIKE VBAK-WAERK,"凭证货币
VSBED LIKE VBAK-VSBED,"装运条件
ZTERM LIKE VBKD-ZTERM,"付款条款
INCO1 LIKE VBKD-INCO1,"国际贸易条款(部分1)
INCO2 LIKE VBKD-INCO2,"国际贸易条款(部分2)
MSCHL LIKE VBKD-MSCHL,"催款代码
AUGRU LIKE VBAK-AUGRU,"订单原因
ABRVW LIKE VBAK-ABRVW,"用途
C_PARTNER LIKE SDPARTNERLIST-PARTNER,"出具发票方
F_PARTNER LIKE SDPARTNERLIST-PARTNER,"付款方
BSARK LIKE VBKD-BSARK,"采购订单类型
AP_PARTNER LIKE SDPARTNERLIST-PARTNER,"AP 联系人
EK_PARTNER LIKE SDPARTNERLIST-PARTNER,"EK 最终用户
ROHS(20) TYPE C,"RoHS(头文本)
END OF L_VBAK.
*--BDC专用变量定义-----------
DATA:T_BDC LIKE STANDARD TABLE OF BDCDATA INITIAL SIZE 0
WITH HEADER LINE. "STANDARD BDC TABLE
REFRESH T_BDC.
*--BDC执行方式
DATA: MODE TYPE C.
* INTERNALE TABLE FOR MESSAGE.
DATA: ITAB_MESSAGE LIKE STANDARD TABLE OF BDCMSGCOLL WITH HEADER LINE.
*输出错误信息内表---
DATA: BEGIN OF MESSTAB OCCURS 0.
INCLUDE STRUCTURE L_VBAK.
DATA: FLAG(10)."错误标记
DATA: MESSAGE(100)."信息
DATA: VBELN TYPE VBAK-VBELN."订单号码
DATA: END OF MESSTAB.
*--输出日志专用----
DATA TMP_CANCEL.
*----------alv所需变量定义----------------------------------------------
TYPE-POOLS: SLIS.
DATA:
V_REPID LIKE SY-REPID,
I_PERIOD TYPE STRING.
DATA:
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
"ALV 字段
V_ALV_LAYOUT TYPE SLIS_LAYOUT_ALV. "ALV 样式
DATA GIT_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA GIT_EVENTS TYPE SLIS_T_EVENT.
*--输出屏幕-------
*****************************************************************
* SELECTION-SCREEN
*****************************************************************
SELECTION-SCREEN BEGIN OF BLOCK BLOCK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R1 TYPE C
RADIOBUTTON GROUP MOD.
SELECTION-SCREEN COMMENT 3(20) TEXT-005 FOR FIELD R1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R2 TYPE C
RADIOBUTTON GROUP MOD.
SELECTION-SCREEN COMMENT 3(20) TEXT-006 FOR FIELD R2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R3 TYPE C
RADIOBUTTON GROUP MOD DEFAULT 'X'.
SELECTION-SCREEN COMMENT 3(20) TEXT-007 FOR FIELD R3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK BLOCK1.
*&-------------------------------------------------------------------*
* AT SELECTION-SCREEN
*&-------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM GET_FILENAME USING P_FILE.
*&-------------------------------------------------------------------*
* START-OF-SELECTION
*&-------------------------------------------------------------------*
START-OF-SELECTION.
IF R1 = 'X'.
MODE = 'A'.
ENDIF.
IF R2 = 'X'.
MODE = 'E'.
ENDIF.
IF R3 = 'X'.
MODE = 'N'.
ENDIF.
*----------------
*---加载文件------
PERFORM UPOLOAD_FILE.
*--执行BDC操作----
PERFORM RUN_BDC.
*--输出日志信息----
PERFORM OUTPUT_LOG.
*---------------------------------------------------------------------*
* FORM UPOLOAD_FILE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM UPOLOAD_FILE.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = '8400'
* FILENAME = SOURCEFILE
FILENAME = P_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = L_VBAK
EXCEPTIONS
OTHERS = 7.
ENDFORM. " upoload_file
*---------------------------------------------------------------------*
* FORM GET_FILENAME *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_P_FILE *
*---------------------------------------------------------------------*
FORM GET_FILENAME USING P_P_FILE.
"出现打开文件的对话框
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = ',*.*,*.*.'
MODE = 'O'
IMPORTING
FILENAME = P_P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " get_filename
*&---------------------------------------------------------------------*
*& Form RUN_BDC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM RUN_BDC.
LOOP AT L_VBAK.
REFRESH T_BDC.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '0101',
' ' 'BDC_CURSOR' 'VBAK-AUART',
' ' 'BDC_OKCODE' '/00',
' ' 'VBAK-AUART' L_VBAK-AUART,"订单类型
' ' 'VBAK-VKORG' L_VBAK-VKORG,"销售组织
' ' 'VBAK-VTWEG' L_VBAK-VTWEG,"分销渠道
' ' 'VBAK-SPART' L_VBAK-SPART,"部门
' ' 'VBAK-VKBUR' L_VBAK-VKBUR,"销售办事处
' ' 'VBAK-VKGRP' L_VBAK-VKGRP."销售组
*---如果送达方或请求交货日期.等于空则带出默认送到方--------
IF L_VBAK-WEV_KUNNR = '' AND L_VBAK-KETDAT = ''.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4001',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'VBKD-BSTKD' L_VBAK-BSTKD,"采购订单编号
' ' 'VBKD-BSTDK' L_VBAK-BSTDK,"采购订单日期
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'KUAGV-KUNNR' L_VBAK-AGV_KUNNR,"售达方
* ' ' 'KUWEV-KUNNR' L_VBAK-WEV_KUNNR,"送达方
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBAK-WAERK',
* ' ' 'RV45A-KETDAT' L_VBAK-KETDAT,"请求交货日期
' ' 'RV45A-KPRGBZ' 'D',"请求交货日期类型
' ' 'RV45A-DWERK' '',"交货工厂
' ' 'VBAK-WAERK' L_VBAK-WAERK,"凭证货币
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV45W',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A'.
ELSEIF L_VBAK-WEV_KUNNR = ''."送达方
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4001',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'VBKD-BSTKD' L_VBAK-BSTKD,"采购订单编号
' ' 'VBKD-BSTDK' L_VBAK-BSTDK,"采购订单日期
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'KUAGV-KUNNR' L_VBAK-AGV_KUNNR,"售达方
* ' ' 'KUWEV-KUNNR' L_VBAK-WEV_KUNNR,"送达方
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBAK-WAERK',
' ' 'RV45A-KETDAT' L_VBAK-KETDAT,"请求交货日期
' ' 'RV45A-KPRGBZ' 'D',"请求交货日期类型
' ' 'RV45A-DWERK' '',"交货工厂
' ' 'VBAK-WAERK' L_VBAK-WAERK,"凭证货币
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV45W',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A'.
ELSEIF L_VBAK-KETDAT = ''."请求交货日期
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4001',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'VBKD-BSTKD' L_VBAK-BSTKD,"采购订单编号
' ' 'VBKD-BSTDK' L_VBAK-BSTDK,"采购订单日期
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'KUAGV-KUNNR' L_VBAK-AGV_KUNNR,"售达方
' ' 'KUWEV-KUNNR' L_VBAK-WEV_KUNNR,"送达方
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBAK-WAERK',
* ' ' 'RV45A-KETDAT' L_VBAK-KETDAT,"请求交货日期
' ' 'RV45A-KPRGBZ' 'D',"请求交货日期类型
' ' 'RV45A-DWERK' '',"交货工厂
' ' 'VBAK-WAERK' L_VBAK-WAERK,"凭证货币
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV45W',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A'.
ELSE.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4001',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'VBKD-BSTKD' L_VBAK-BSTKD,"采购订单编号
' ' 'VBKD-BSTDK' L_VBAK-BSTDK,"采购订单日期
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'KUAGV-KUNNR' L_VBAK-AGV_KUNNR,"售达方
' ' 'KUWEV-KUNNR' L_VBAK-WEV_KUNNR,"送达方
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBAK-WAERK',
' ' 'RV45A-KETDAT' L_VBAK-KETDAT,"请求交货日期
' ' 'RV45A-KPRGBZ' 'D',"请求交货日期类型
' ' 'RV45A-DWERK' '',"交货工厂
' ' 'VBAK-WAERK' L_VBAK-WAERK,"凭证货币
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV45W',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A'.
ENDIF.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4001',
' ' 'BDC_OKCODE' '=KKAU',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV45W',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'RV45A-MABNR(01)',
' ' 'BDC_SUBSCR' 'SAPMV45A'.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=T/02',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBAK-ABRVW',
' ' 'VBAK-AUGRU' L_VBAK-AUGRU,"订单原因
' ' 'VBAK-ABRVW' L_VBAK-ABRVW."用途
IF L_VBAK-VSBED = ''."装运条件
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=T/03',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBAK-VSBED',
* ' ' 'VBAK-VSBED' L_VBAK-VSBED,"装运条件
' ' 'VBKD-KZAZU' 'X'.
ELSE.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=T/03',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBAK-VSBED',
' ' 'VBAK-VSBED' L_VBAK-VSBED,"装运条件
' ' 'VBKD-KZAZU' 'X'.
ENDIF.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=T/06',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBKD-INCO2',
' ' 'VBKD-INCO1' L_VBAK-INCO1,"国际贸易条款(部分1)
' ' 'VBKD-INCO2' L_VBAK-INCO2,"国际贸易条款(部分2)
' ' 'VBKD-ZTERM' L_VBAK-ZTERM."付款条款
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=T/11',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBKD-MSCHL',
' ' 'VBKD-MSCHL' L_VBAK-MSCHL."催款代码
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=T/09',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_CURSOR' 'VBKD-BSARK',
' ' 'VBKD-BSARK' L_VBAK-BSARK."采购订单类型
*-------合作伙伴输入区域----------------------------------------
IF L_VBAK-EK_PARTNER = '' AND L_VBAK-C_PARTNER = ''
AND L_VBAK-F_PARTNER = '' AND L_VBAK-AP_PARTNER = ''.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV09C'.
* ' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(11)',
* ' ' 'GV_FILTER' 'PARALL',
* ' ' 'GVS_TC_DATA-REC-PARVW(11)' 'AP'.
ENDIF.
IF L_VBAK-EK_PARTNER <> ''."ek最终用户
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV09C',
' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(02)',
' ' 'GVS_TC_DATA-REC-PARTNER(02)' L_VBAK-EK_PARTNER."EK 最终用户
ENDIF.
IF L_VBAK-C_PARTNER <> ''."出具发票方
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV09C',
' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(03)',
' ' 'GVS_TC_DATA-REC-PARTNER(03)' L_VBAK-C_PARTNER."出具发票方
ENDIF.
IF L_VBAK-F_PARTNER <> ''."付款方
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV09C',
' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(04)',
' ' 'GVS_TC_DATA-REC-PARTNER(04)' L_VBAK-F_PARTNER."付款方
ENDIF.
IF L_VBAK-AP_PARTNER <> ''."AP 联系人
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '/00',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV09C',
' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(11)',
' ' 'GV_FILTER' 'PARALL',
' ' 'GVS_TC_DATA-REC-PARVW(11)' 'AP',
' ' 'GVS_TC_DATA-REC-PARTNER(11)' L_VBAK-AP_PARTNER."AP 联系人
ENDIF.
PERFORM FRM_ADD_BDC_TAB_RECORD USING:
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=T/10',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV09C',
' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(11)',
' ' 'GV_FILTER' 'PARALL',
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=TP_LAST',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV70T',
' ' 'LV70T-SPRAS' 'EN',
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=TP_DETAIL',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV70T',
' ' 'LV70T-SPRAS' 'EN',
'1' 'SAPLSTXX' '1100',
' ' 'BDC_CURSOR' 'RSTXT-TXLINE(02)',
' ' 'BDC_OKCODE' '=TXVB',
' ' 'RSTXT-TXLINE(02)' L_VBAK-ROHS(20),"RoHS(头文本)
'1' 'SAPLSTXX' '1100',
' ' 'BDC_CURSOR' 'RSTXT-TXLINE(02)',
' ' 'BDC_OKCODE' '=TXBA',
'1' 'SAPMV45A' '4002',
' ' 'BDC_OKCODE' '=SICH',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPMV45A',
' ' 'BDC_SUBSCR' 'SAPLV70T'.
CALL TRANSACTION 'VA01' USING T_BDC MODE MODE
MESSAGES INTO ITAB_MESSAGE.
*--处理日志信息
PERFORM GET_LOG.
ENDLOOP.
ENDFORM. " RUN_BDC
*&---------------------------------------------------------------------*
* FORM FRM_ADD_BDC_TAB_RECORD *
*&---------------------------------------------------------------------*
* FILL BDC *
*&---------------------------------------------------------------------*
FORM FRM_ADD_BDC_TAB_RECORD USING:TMP_FLAG
TMP_VAR1
TMP_VAR2.
CLEAR T_BDC.
IF TMP_FLAG = '1'.
T_BDC-PROGRAM = TMP_VAR1.
T_BDC-DYNPRO = TMP_VAR2.
T_BDC-DYNBEGIN = 'X'.
ELSE.
T_BDC-FNAM = TMP_VAR1.
T_BDC-FVAL = TMP_VAR2.
ENDIF.
APPEND T_BDC.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_log
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_LOG.
MOVE-CORRESPONDING L_VBAK TO MESSTAB.
LOOP AT ITAB_MESSAGE.
IF ITAB_MESSAGE-MSGTYP = 'S' AND
ITAB_MESSAGE-MSGNR = '311'.
MESSTAB-FLAG = '成功'.
MESSAGE ID ITAB_MESSAGE-MSGID
TYPE ITAB_MESSAGE-MSGTYP
NUMBER ITAB_MESSAGE-MSGNR
WITH ITAB_MESSAGE-MSGV1
ITAB_MESSAGE-MSGV2
ITAB_MESSAGE-MSGV3
ITAB_MESSAGE-MSGV4
INTO MESSTAB-MESSAGE. "成功信息/
MESSTAB-VBELN = ITAB_MESSAGE-MSGV2."订单号码
ELSEIF ITAB_MESSAGE-MSGTYP = 'E'.
MESSTAB-FLAG = '失败'.
MESSAGE ID ITAB_MESSAGE-MSGID
TYPE ITAB_MESSAGE-MSGTYP
NUMBER ITAB_MESSAGE-MSGNR
WITH ITAB_MESSAGE-MSGV1
ITAB_MESSAGE-MSGV2
ITAB_MESSAGE-MSGV3
ITAB_MESSAGE-MSGV4
INTO MESSTAB-MESSAGE. "失败信息/
ELSEIF ITAB_MESSAGE-MSGTYP = 'A'.
MESSTAB-FLAG = '失败'.
MESSAGE ID ITAB_MESSAGE-MSGID
TYPE ITAB_MESSAGE-MSGTYP
NUMBER ITAB_MESSAGE-MSGNR
WITH ITAB_MESSAGE-MSGV1
ITAB_MESSAGE-MSGV2
ITAB_MESSAGE-MSGV3
ITAB_MESSAGE-MSGV4
INTO MESSTAB-MESSAGE. "失败信息/
ENDIF.
ENDLOOP.
APPEND MESSTAB.
CLEAR ITAB_MESSAGE[].
CLEAR ITAB_MESSAGE.
CLEAR MESSTAB.
ENDFORM. " get_log
*&---------------------------------------------------------------------*
*& Form output_log
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OUTPUT_LOG.
*---输出日志到文本------
CALL FUNCTION 'DOWNLOAD'
EXPORTING
CODEPAGE = '8400'
FILENAME = 'c:/outlist.txt'
FILETYPE = 'dat'
IMPORTING
CANCEL = TMP_CANCEL
TABLES
DATA_TAB = MESSTAB.
*--如果取消则ALV输出-------
IF TMP_CANCEL = 'x'.
PERFORM ALV_DISPLAY."ALV输出
ENDIF.
ENDFORM. " output_log
**********************ALV输出*****************************************
*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_DISPLAY .
DATA L_TMP TYPE LVC_TITLE.
* PERFORM FRM_GET_EVENTS."alv表头所用
* PERFORM FRM_COMMENT_BUILD."alv表头所用
* v_alv_layout-colwidth_optimize = 'X'.
* v_alv_layout-info_fieldname = 'COLOR'.
PERFORM INIT_FIELDCAT.
* 调用ALV函数显示
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_GRID_TITLE = L_TMP
IS_LAYOUT = V_ALV_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
I_SAVE = 'X'
* IS_VARIANT =
* IT_EVENTS = GIT_EVENTS[]"alv表头赋值
* i_callback_user_command = 'FRM_UCOMM'"ALV事件
TABLES
T_OUTTAB = MESSTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " ALV_DISPLAY
*&---------------------------------------------------------------------*
*& Form INIT_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM INIT_FIELDCAT .
GT_FIELDCAT-FIELDNAME = 'AUART'.
GT_FIELDCAT-SELTEXT_L = '订单类型'.
GT_FIELDCAT-SELTEXT_S = '订单类型'.
GT_FIELDCAT-SELTEXT_M = '订单类型'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'VKORG'.
GT_FIELDCAT-SELTEXT_L = '销售组织'.
GT_FIELDCAT-SELTEXT_S = '销售组织'.
GT_FIELDCAT-SELTEXT_M = '销售组织'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'VTWEG'.
GT_FIELDCAT-SELTEXT_L = '分销渠道'.
GT_FIELDCAT-SELTEXT_S = '分销渠道'.
GT_FIELDCAT-SELTEXT_M = '分销渠道'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'SPART'.
GT_FIELDCAT-SELTEXT_L = '部门'.
GT_FIELDCAT-SELTEXT_S = '部门'.
GT_FIELDCAT-SELTEXT_M = '部门'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'VKBUR'.
GT_FIELDCAT-SELTEXT_L = '销售办事处'.
GT_FIELDCAT-SELTEXT_S = '销售办事处'.
GT_FIELDCAT-SELTEXT_M = '销售办事处'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'VKGRP'.
GT_FIELDCAT-SELTEXT_L = '销售组'.
GT_FIELDCAT-SELTEXT_S = '销售组'.
GT_FIELDCAT-SELTEXT_M = '销售组'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'AGV_KUNNR'.
GT_FIELDCAT-SELTEXT_L = '售达方'.
GT_FIELDCAT-SELTEXT_S = '售达方'.
GT_FIELDCAT-SELTEXT_M = '售达方'.
* gt_fieldcat-hotspot = 'X'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'WEV_KUNNR'.
GT_FIELDCAT-SELTEXT_L = '送达方'.
GT_FIELDCAT-SELTEXT_S = '送达方'.
GT_FIELDCAT-SELTEXT_M = '送达方'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'BSTKD'.
GT_FIELDCAT-SELTEXT_L = '采购订单编号'.
GT_FIELDCAT-SELTEXT_S = '采购订单编号'.
GT_FIELDCAT-SELTEXT_M = '采购订单编号'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'KETDAT'.
GT_FIELDCAT-SELTEXT_L = '请求交货日期'.
GT_FIELDCAT-SELTEXT_S = '请求交货日期'.
GT_FIELDCAT-SELTEXT_M = '请求交货日期'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'WAERK'.
GT_FIELDCAT-SELTEXT_L = '凭证货币'.
GT_FIELDCAT-SELTEXT_S = '凭证货币'.
GT_FIELDCAT-SELTEXT_M = '凭证货币'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'VSBED'.
GT_FIELDCAT-SELTEXT_L = '装运条件'.
GT_FIELDCAT-SELTEXT_S = '装运条件'.
GT_FIELDCAT-SELTEXT_M = '装运条件'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'ZTERM'.
GT_FIELDCAT-SELTEXT_L = '付款条款'.
GT_FIELDCAT-SELTEXT_S = '付款条款'.
GT_FIELDCAT-SELTEXT_M = '付款条款'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'INCO1'.
GT_FIELDCAT-SELTEXT_L = '国际贸易条款(部分1)'.
GT_FIELDCAT-SELTEXT_S = '国际贸易条款(部分1)'.
GT_FIELDCAT-SELTEXT_M = '国际贸易条款(部分1)'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'INCO2'.
GT_FIELDCAT-SELTEXT_L = '国际贸易条款(部分2)'.
GT_FIELDCAT-SELTEXT_S = '国际贸易条款(部分2)'.
GT_FIELDCAT-SELTEXT_M = '国际贸易条款(部分2)'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'MSCHL'.
GT_FIELDCAT-SELTEXT_L = '催款代码'.
GT_FIELDCAT-SELTEXT_S = '催款代码'.
GT_FIELDCAT-SELTEXT_M = '催款代码'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'AUGRU'.
GT_FIELDCAT-SELTEXT_L = '订单原因'.
GT_FIELDCAT-SELTEXT_S = '订单原因'.
GT_FIELDCAT-SELTEXT_M = '订单原因'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'VBKD'.
GT_FIELDCAT-SELTEXT_L = '采购订单日期'.
GT_FIELDCAT-SELTEXT_S = '采购订单日期'.
GT_FIELDCAT-SELTEXT_M = '采购订单日期'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'ABRVW'.
GT_FIELDCAT-SELTEXT_L = '用途'.
GT_FIELDCAT-SELTEXT_S = '用途'.
GT_FIELDCAT-SELTEXT_M = '用途'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'C_PARTNER'.
GT_FIELDCAT-SELTEXT_L = '出具发票方'.
GT_FIELDCAT-SELTEXT_S = '出具发票方'.
GT_FIELDCAT-SELTEXT_M = '出具发票方'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'F_PARTNER'.
GT_FIELDCAT-SELTEXT_L = '付款方'.
GT_FIELDCAT-SELTEXT_S = '付款方'.
GT_FIELDCAT-SELTEXT_M = '付款方'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'BSARK'.
GT_FIELDCAT-SELTEXT_L = '采购订单类型'.
GT_FIELDCAT-SELTEXT_S = '采购订单类型'.
GT_FIELDCAT-SELTEXT_M = '采购订单类型'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'AP_PARTNER'.
GT_FIELDCAT-SELTEXT_L = 'AP 联系人'.
GT_FIELDCAT-SELTEXT_S = 'AP 联系人'.
GT_FIELDCAT-SELTEXT_M = 'AP 联系人'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'EK_PARTNER'.
GT_FIELDCAT-SELTEXT_L = 'EK 最终用户'.
GT_FIELDCAT-SELTEXT_S = 'EK 最终用户'.
GT_FIELDCAT-SELTEXT_M = 'EK 最终用户'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'ROHS'.
GT_FIELDCAT-SELTEXT_L = 'RoHS(头文本)'.
GT_FIELDCAT-SELTEXT_S = 'RoHS(头文本)'.
GT_FIELDCAT-SELTEXT_M = 'RoHS(头文本)'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'FLAG'.
GT_FIELDCAT-SELTEXT_L = '是否成功'.
GT_FIELDCAT-SELTEXT_S = '是否成功'.
GT_FIELDCAT-SELTEXT_M = '是否成功'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'MESSAGE'.
GT_FIELDCAT-SELTEXT_L = '备注'.
GT_FIELDCAT-SELTEXT_S = '备注'.
GT_FIELDCAT-SELTEXT_M = '备注'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
GT_FIELDCAT-FIELDNAME = 'VBELN'.
GT_FIELDCAT-SELTEXT_L = '订单号码'.
GT_FIELDCAT-SELTEXT_S = '订单号码'.
GT_FIELDCAT-SELTEXT_M = '订单号码'.
APPEND GT_FIELDCAT.
CLEAR GT_FIELDCAT.
ENDFORM. " INIT_FIELDCAT