销售订单行项目批量导入(BDC)

*----------------------------------------------------------------------*
* Program name : ZSD_BDC_ORDERITEM_NEW        Date written: 07-11-10   *
* Author's name: HouZhiYu                     Last update :            *
* Program title: 销售订单行项目批量导入                                *
*----------------------------------------------------------------------*
REPORT ZSD_BDC_ORDERITEM.

TABLES: VBAK,"销售凭证:抬头数据
        VBAP,"销售凭证:项目数据
        VBEP,"销售凭证:细目数据
        TVAP,"销售凭证:项目类别
        KONV."条件(事务数据)


*****************************************************************
*        INTERNAL TABLES
*****************************************************************
DATA: BEGIN OF L_VBAK OCCURS 0,
      VBELN    LIKE VBAP-VBELN,      "订单号
      POSNR    LIKE VBAP-POSNR,      "项目号
      MATNR    LIKE RV45A-MABNR,      "物料编号
      KWMENG(15)   TYPE C,  "数量
      KDMAT LIKE   VBAP-KDMAT,   "客户物料编号
      PSTYV LIKE   VBAP-PSTYV,   "项目类型
      UEPOS LIKE   VBAP-UEPOS,   "上层项
      PR01_KBETR(11)    TYPE C,                             "PR01价格
      PR01_KOEIN(5)    TYPE C,                              "PR01币种
      ETDAT LIKE   RV45A-ETDAT,  "首次日期
      PS_PSP_PNR(24) TYPE C,"WBS元素
      PN00_KBETR(11)    TYPE C,                             "PN00价格
      PN00_KOEIN(5)    TYPE C,                              "PN00币种
*      PN002_KBETR(5)    TYPE C,                             "PN00价格
*      PN002_KOEIN LIKE  RV45A-KOEIN,                        "PN00币种
      ZP01_KBETR(11)    TYPE C,                             "ZP01价格
      ZP01_KOEIN(5)    TYPE C,                              "ZP01币种
      ZP21_KBETR(11)    TYPE C,                             "ZP21价格
      ZP21_KOEIN(5)    TYPE C,                              "ZP21币种
      ZP03_KBETR(11)    TYPE C,                             "ZP03价格
      ZP03_KOEIN(5)    TYPE C,                              "ZP03币种
      ZP23_KBETR(11)    TYPE C,                             "ZP23价格
      ZP23_KOEIN(5)    TYPE C,                              "ZP23币种
      ZP05_KBETR(11)    TYPE C,                             "ZP05价格
      ZP05_KOEIN(5)    TYPE C,                              "ZP05币种
      ZP25_KBETR(11)    TYPE C,                             "ZP25价格
      ZP25_KOEIN(5)    TYPE C,                              "ZP25币种
      ZP08_KBETR(11)    TYPE C,                             "ZP08价格
      ZP08_KOEIN(5)    TYPE C,                              "ZP08币种
      ZP28_KBETR(11)    TYPE C,                             "ZP28价格
      ZP28_KOEIN(5)    TYPE C,                              "ZP28币种
      ZP09_KBETR(11)    TYPE C,                             "ZP09价格
      ZP09_KOEIN(5)    TYPE C,                              "ZP09币种
      ZP29_KBETR(11)    TYPE C,                             "ZP29价格
      ZP29_KOEIN(5)    TYPE C,                              "ZP29币种
      ZP11_KBETR(11)    TYPE C,                             "ZP11价格
      ZP11_KOEIN(5)    TYPE C,                              "ZP11币种
      ZP31_KBETR(11)    TYPE C,                             "ZP31价格
      ZP31_KOEIN(5)    TYPE C,                              "ZP31币种
      ZTERM  LIKE  VBKD-ZTERM,"付款方式
      S_PARTNER  LIKE  SDPARTNERLIST-PARTNER,"送达方
      JUMING(50)   TYPE C,      "局名
      IHREZ      LIKE VBKD-IHREZ,"售达方中您的参考
      POSEX      LIKE VBAP-POSEX,"售达方中采购订单项目
      IHREZ_E    LIKE VBKD-IHREZ_E,"送达方中您的参考
      END OF L_VBAK.
*---bdc专用-------------------------
DATA:T_BDC LIKE STANDARD TABLE OF BDCDATA INITIAL SIZE 0
                WITH HEADER LINE.      "STANDARD BDC TABLE

DATA: BEGIN OF MESSTAB OCCURS 0."输出消息号
        INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSTAB.

REFRESH T_BDC.
DATA: MODE TYPE C.
*-------输出错误信息内表--------------------------
DATA: BEGIN OF ITAB_MESSTAB OCCURS 0.

        INCLUDE STRUCTURE L_VBAK.

DATA:    FLAG(10)."错误标记
DATA:    MESSAGE(100)."信息

DATA: END OF ITAB_MESSTAB.
*--------------------------------------------
DATA: IT_UPLOAD LIKE L_VBAK OCCURS 0 WITH HEADER LINE.
DATA: IT_UPLOAD_SO LIKE L_VBAK OCCURS 0 WITH HEADER LINE.
DATA: P_VBELN LIKE VBAK-VBELN.
DATA L_NAME LIKE THEAD-TDNAME.
RANGES: R_PSTYV FOR VBAP-PSTYV.
DATA: SUM TYPE I.
*----------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.

START-OF-SELECTION.
  IF R2 = 'X'.
    MODE = 'E'.
  ENDIF.

START-OF-SELECTION.
  IF R3 = 'X'.
    MODE = 'N'.
  ENDIF.
  PERFORM MAIN.

*&---------------------------------------------------------------------*
*&      Form  main
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MAIN.

  PERFORM UPOLOAD_FILE.

  SORT IT_UPLOAD_SO BY VBELN.
  SORT IT_UPLOAD BY VBELN.

  LOOP AT IT_UPLOAD_SO.


*--检查订单是否存在--------------------------
    P_VBELN = IT_UPLOAD_SO-VBELN.
*-------------在P_VBELN前面补零-----
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
              INPUT  = P_VBELN
         IMPORTING
              OUTPUT = P_VBELN.

    CLEAR VBAK.
    SELECT SINGLE VBELN FROM VBAK
                   INTO VBAK-VBELN
                   WHERE VBELN = P_VBELN.

    IF SY-SUBRC <> 0.
      MOVE-CORRESPONDING IT_UPLOAD_SO TO ITAB_MESSTAB.
      ITAB_MESSTAB-FLAG = '失败'."错误标记
      ITAB_MESSTAB-MESSAGE = '该订单没有被创建,无法更新ITEM!!'."信息
      APPEND ITAB_MESSTAB.
      DELETE IT_UPLOAD WHERE VBELN = IT_UPLOAD_SO-VBELN.
      DELETE IT_UPLOAD_SO WHERE VBELN = IT_UPLOAD_SO-VBELN.
      CONTINUE.
    ENDIF.

*-----将外部数据赋值给要执行BDC的内表-------
    LOOP AT IT_UPLOAD WHERE VBELN = IT_UPLOAD_SO-VBELN.
      MOVE-CORRESPONDING IT_UPLOAD TO L_VBAK.
      APPEND L_VBAK.
    ENDLOOP.
*----判断当前表头合作伙伴个数-----------------
    SELECT COUNT( DISTINCT PARVW ) FROM VBPA
                      INTO SUM
                      WHERE VBELN = P_VBELN
                      AND   POSNR = '000000'.
*--数据检查如果没有问题则执行BDC------------------
    PERFORM CHECK_INPUT.
    CLEAR: L_VBAK[],IT_UPLOAD,L_VBAK,P_VBELN,
    SUM.

  ENDLOOP.
*---输出日志信息-----------
  PERFORM OUTPUT_LOG.
ENDFORM.                    " main
*&---------------------------------------------------------------------*
*&      Form  check_input
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CHECK_INPUT.
  SORT L_VBAK BY VBELN  POSNR.
  LOOP AT L_VBAK.
*---数据检查-------
*以下数据为必填项,如果为空则报系统错误---------
*订单行项目/物料/数量/项目类型/首次日期/送达方/送达方中您的参考

    IF L_VBAK-POSNR = ''."订单行项目
      MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
      ITAB_MESSTAB-FLAG = '失败'."错误标记
      ITAB_MESSTAB-MESSAGE = '订单行项目不能为空'."信息
      APPEND ITAB_MESSTAB.
      DELETE L_VBAK WHERE VBELN = L_VBAK-VBELN
                    AND   POSNR = L_VBAK-POSNR.
      CONTINUE.
    ENDIF.


    IF L_VBAK-MATNR = ''."物料
      MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
      ITAB_MESSTAB-FLAG = '失败'."错误标记
      ITAB_MESSTAB-MESSAGE = '物料不能为空'."信息
      APPEND ITAB_MESSTAB.
      DELETE L_VBAK WHERE VBELN = L_VBAK-VBELN
                    AND   POSNR = L_VBAK-POSNR.
      CONTINUE.
    ENDIF.

    IF L_VBAK-KWMENG = ''."数量
      MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
      ITAB_MESSTAB-FLAG = '失败'."错误标记
      ITAB_MESSTAB-MESSAGE = '数量不能为空'."信息
      APPEND ITAB_MESSTAB.
      DELETE L_VBAK WHERE VBELN = L_VBAK-VBELN
                    AND   POSNR = L_VBAK-POSNR.
      CONTINUE.
    ENDIF.

    IF L_VBAK-PSTYV = ''."项目类型
      MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
      ITAB_MESSTAB-FLAG = '失败'."错误标记
      ITAB_MESSTAB-MESSAGE = '项目类型不能为空'."信息
      APPEND ITAB_MESSTAB.
      DELETE L_VBAK WHERE VBELN = L_VBAK-VBELN
                    AND   POSNR = L_VBAK-POSNR.
      CONTINUE.
    ENDIF.

    IF L_VBAK-ETDAT = ''."首次日期
      MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
      ITAB_MESSTAB-FLAG = '失败'."错误标记
      ITAB_MESSTAB-MESSAGE = '首次日期不能为空'."信息
      APPEND ITAB_MESSTAB.
      DELETE L_VBAK WHERE VBELN = L_VBAK-VBELN
                    AND   POSNR = L_VBAK-POSNR.
      CONTINUE.
    ENDIF.


*    IF L_VBAK-IHREZ_E = ''."送达方中您的参考
*      MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
*      ITAB_MESSTAB-FLAG = '失败'."错误标记
*      ITAB_MESSTAB-MESSAGE = '送达方中您的参考不能为空'."信息
*      APPEND ITAB_MESSTAB.
*      DELETE L_VBAK WHERE VBELN = L_VBAK-VBELN
*                    AND   POSNR = L_VBAK-POSNR.
*      CONTINUE.
*    ENDIF.

*&数量 ,价格处理。
    CONDENSE L_VBAK-KWMENG NO-GAPS.
    CONDENSE L_VBAK-PR01_KBETR NO-GAPS.
    CONDENSE L_VBAK-PN00_KBETR   NO-GAPS.
*    CONDENSE L_VBAK-PN002_KBETR  NO-GAPS.
    CONDENSE L_VBAK-ZP01_KBETR   NO-GAPS.                   "ZP01价格
    CONDENSE L_VBAK-ZP21_KBETR   NO-GAPS.                   "ZP21价格
    CONDENSE L_VBAK-ZP03_KBETR   NO-GAPS.                   "ZP03价格
    CONDENSE L_VBAK-ZP23_KBETR   NO-GAPS.                   "ZP23价格
    CONDENSE L_VBAK-ZP05_KBETR   NO-GAPS.                   "ZP05价格
    CONDENSE L_VBAK-ZP25_KBETR   NO-GAPS.                   "ZP25价格
    CONDENSE L_VBAK-ZP08_KBETR   NO-GAPS.                   "ZP08价格
    CONDENSE L_VBAK-ZP28_KBETR   NO-GAPS.                   "ZP28价格
    CONDENSE L_VBAK-ZP09_KBETR   NO-GAPS.                   "ZP09价格
    CONDENSE L_VBAK-ZP29_KBETR   NO-GAPS.                   "ZP29价格
    CONDENSE L_VBAK-ZP11_KBETR   NO-GAPS.                   "ZP11价格
    CONDENSE L_VBAK-ZP31_KBETR   NO-GAPS.                   "ZP31价格

*----取得带 billing plan 的Item category(项目类型)-----------------
    MOVE: 'I' TO R_PSTYV-SIGN,
          'EQ' TO R_PSTYV-OPTION,
          'ZTAO' TO  R_PSTYV-LOW.
    APPEND R_PSTYV.
    MOVE 'ZAO2'TO R_PSTYV-LOW.
    APPEND R_PSTYV.
    MOVE 'TAO'TO R_PSTYV-LOW.
    APPEND R_PSTYV.
    MOVE 'ZAO'TO R_PSTYV-LOW.
    APPEND R_PSTYV.
    MOVE 'YYAO'TO R_PSTYV-LOW.
    APPEND R_PSTYV.
*---执行BDC---------
    PERFORM RUN_BDC.
  ENDLOOP.
ENDFORM.                    " check_input

*&---------------------------------------------------------------------*
*&      Form  upoload_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM UPOLOAD_FILE.
  CALL FUNCTION 'UPLOAD'
     EXPORTING
          CODEPAGE = '8400'
*          FILENAME = SOURCEFILE
          FILENAME = P_FILE
          FILETYPE = 'DAT'
     TABLES
          DATA_TAB = IT_UPLOAD
     EXCEPTIONS
          OTHERS   = 7.

  SORT IT_UPLOAD BY VBELN.

  REFRESH IT_UPLOAD_SO.
  CLEAR  IT_UPLOAD_SO.
  MOVE IT_UPLOAD[] TO IT_UPLOAD_SO[].
  SORT IT_UPLOAD_SO BY VBELN.
*--删除重复行-------
  DELETE ADJACENT DUPLICATES FROM IT_UPLOAD_SO COMPARING VBELN.

ENDFORM.                    " upoload_file
*&---------------------------------------------------------------------*
*&      Form  get_filename
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_P_FILE1  text
*----------------------------------------------------------------------*
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.
  REFRESH T_BDC.
  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
   '1'    'SAPMV45A' '0102',
  ' ' 'BDC_CURSOR' 'VBAK-VBELN',
  ' ' 'BDC_OKCODE' '/00',
  ' ' 'VBAK-VBELN' L_VBAK-VBELN."订单号

  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
   '1'    'SAPMV45A' '4001',
  ' ' 'BDC_OKCODE' '=POAN',
  ' ' '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(02)',
  ' ' 'BDC_SUBSCR' 'SAPMV45A'.
*----------行项目概览数据输出----------------
  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
  '1'    'SAPMV45A' '4001',
  ' ' 'BDC_OKCODE' '/00',
  ' ' 'BDC_SUBSCR' 'SAPMV45A',
  ' ' 'BDC_SUBSCR' 'SAPMV45A',
  ' ' 'BDC_SUBSCR' 'SAPMV45A',
  ' ' 'BDC_SUBSCR' 'SAPMV45A',
  ' ' 'BDC_SUBSCR' 'SAPMV45A',
  ' ' 'BDC_SUBSCR' 'SAPLV45W',
  ' ' 'BDC_SUBSCR' 'SAPMV45A ',
  ' ' 'BDC_CURSOR' 'KOMV-KBETR(02)',
  ' ' 'RV45A-MABNR(02)' L_VBAK-MATNR,"物料编号
  ' ' 'VBAP-POSNR(02)'  L_VBAK-POSNR,"行项目
*  ' ' 'RV45A-KWMENG(02)' '1',
  ' ' 'RV45A-KWMENG(02)' L_VBAK-KWMENG,  "数量
  ' ' 'VBAP-PSTYV(02)'  L_VBAK-PSTYV,   "项目类型
  ' ' 'RV45A-ETDAT(02)'  L_VBAK-ETDAT,   "首次日期
  ' ' 'BDC_SUBSCR' 'SAPMV45A'.

*如果客户物料编号/WBS元素/上层物料编号/PR01价格/PR01币种为空则以默认显示
  IF L_VBAK-KDMAT NE SPACE."客户物料编号
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '4001',
*    ' ' 'BDC_OKCODE' '/00',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV45W',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(02)',
    ' ' 'VBAP-KDMAT(02)'  L_VBAK-KDMAT."客户物料编号
*    ' ' 'BDC_SUBSCR' 'SAPMV45A'.
  ENDIF.

  IF L_VBAK-UEPOS NE SPACE."上层项
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '4001',
*    ' ' 'BDC_OKCODE' '/00',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV45W',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(02)',
    ' ' 'VBAP-UEPOS(02)'  L_VBAK-UEPOS.   "上层项
*    ' ' 'BDC_SUBSCR' 'SAPMV45A'.
  ENDIF.

  IF L_VBAK-PS_PSP_PNR NE SPACE."WBS元素
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '4001',
*    ' ' 'BDC_OKCODE' '/00',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV45W',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(02)',
    ' ' 'VBAP-PS_PSP_PNR(02)'  L_VBAK-PS_PSP_PNR.   "WBS元素
*    ' ' 'BDC_SUBSCR' 'SAPMV45A'.
  ENDIF.


  IF L_VBAK-PR01_KBETR NE SPACE.                            "PR01价格
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '4001',
*    ' ' 'BDC_OKCODE' '/00',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV45W',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(02)',
    ' ' 'KOMV-KBETR(02)'  L_VBAK-PR01_KBETR.                "PR01价格
*    ' ' 'KOMV-KBETR(02)' '1000'.
*    ' ' 'BDC_SUBSCR' 'SAPMV45A'.
  ENDIF.

  IF L_VBAK-PR01_KOEIN NE SPACE.                            "PR01币种
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '4001',
*    ' ' 'BDC_OKCODE' '/00',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV45W',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(02)',
    ' ' 'RV45A-KOEIN(02)'  L_VBAK-PR01_KOEIN.               "PR01币种
*    ' ' 'BDC_SUBSCR' 'SAPMV45A'.
  ENDIF.
*---付款方式输入-------------------------------
  IF L_VBAK-ZTERM <> ''.
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    ' ' 'VBKD-ZTERM(02)' L_VBAK-ZTERM."付款条款
  ENDIF.
*------------------原始代码-----------------------
*    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '4001',
*    ' ' 'BDC_OKCODE' '/00',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV45W',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(02)',
*    ' ' 'RV45A-MABNR(02)' L_VBAK-MATNR,"物料编号
*    ' ' 'VBAP-KDMAT(02)'  L_VBAK-KDMAT,"客户物料编号
*    ' ' 'VBAP-POSNR(02)'  L_VBAK-POSNR,"行项目
*    ' ' 'RV45A-KWMENG(02)' L_VBAK-KWMENG,  "数量
*    ' ' 'VBAP-PSTYV(02)'  L_VBAK-PSTYV,   "项目类型
*    ' ' 'VBAP-UEPOS(02)'  L_VBAK-UEPOS,   "上层项
*    ' ' 'KOMV-KBETR(02)'  L_VBAK-PR01_KBETR,                "PR01价格
*    ' ' 'RV45A-KOEIN(02)'  L_VBAK-PR01_KOEIN,               "PR01币种
*    ' ' 'RV45A-ETDAT(02)'  L_VBAK-ETDAT,   "首次日期
*    ' ' 'VBAP-PS_PSP_PNR(02)'  L_VBAK-PS_PSP_PNR,   "WBS元素
*    ' ' 'BDC_SUBSCR' 'SAPMV45A'.
*-------------------END OF--------------------------------------------
  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
  '1'    'SAPMV45A' '4001',
  ' ' 'BDC_OKCODE' '=ITEM',
  ' ' '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(02)',
  ' ' 'BDC_SUBSCR' 'SAPMV45A'.

*----判断是否是带 billing plan 的Item category---------
  IF NOT L_VBAK-PSTYV IN R_PSTYV.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '4003',
     ' ' 'BDC_OKCODE' '=T/06',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_CURSOR' 'RV45A-KWMENG'.
  ELSE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '4003',
     ' ' 'BDC_OKCODE' '=T/07',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPMV45A'.
  ENDIF.
*------------END OF-------------------------

  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
  '1'    'SAPMV45A' '5003',
  ' ' 'BDC_OKCODE' '=V69A_KOAN',
  ' ' 'BDC_SUBSCR' 'SAPMV45A',
  ' ' 'BDC_SUBSCR' 'SAPLV69A',
  ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.
*---------价格输入区------------------------
*    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A',
*    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.
*--价格条件可以为空
  IF L_VBAK-PN00_KBETR NE SPACE
     AND L_VBAK-PN00_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
    ' ' 'KOMV-KSCHL(10)' 'PN00',
    ' ' 'KOMV-KBETR(10)' L_VBAK-PN00_KBETR,
    ' ' 'RV61A-KOEIN(10)' L_VBAK-PN00_KOEIN.
  ENDIF.

*  IF L_VBAK-PN002_KBETR NE SPACE
*     AND L_VBAK-PN002_KOEIN NE SPACE.
*
*    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A',
*    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.
*
*    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*  ' ' 'KOMV-KSCHL(10)' 'PN00',
*  ' ' 'KOMV-KBETR(10)' L_VBAK-PN002_KBETR,
*  ' ' 'RV61A-KOEIN(10)' L_VBAK-PN002_KOEIN.
*  ENDIF.

  IF L_VBAK-ZP01_KOEIN NE SPACE
     AND L_VBAK-ZP01_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
  ' ' 'KOMV-KSCHL(10)' 'ZP01',
  ' ' 'KOMV-KBETR(10)' L_VBAK-ZP01_KBETR,
  ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP01_KOEIN.
  ENDIF.

  IF L_VBAK-ZP21_KBETR NE SPACE
     AND L_VBAK-ZP21_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
  ' ' 'KOMV-KSCHL(10)' 'ZP21',
  ' ' 'KOMV-KBETR(10)' L_VBAK-ZP21_KBETR,
  ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP21_KOEIN.
  ENDIF.

  IF L_VBAK-ZP03_KBETR NE SPACE
     AND L_VBAK-ZP03_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.


    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
    ' ' 'KOMV-KSCHL(10)' 'ZP03',
    ' ' 'KOMV-KBETR(10)' L_VBAK-ZP03_KBETR,
    ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP03_KOEIN.
  ENDIF.

  IF L_VBAK-ZP23_KBETR NE SPACE
     AND L_VBAK-ZP23_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.


    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
  ' ' 'KOMV-KSCHL(10)' 'ZP23',
  ' ' 'KOMV-KBETR(10)' L_VBAK-ZP23_KBETR,
  ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP23_KOEIN.
  ENDIF.

  IF L_VBAK-ZP05_KOEIN NE SPACE
     AND L_VBAK-ZP05_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
  ' ' 'KOMV-KSCHL(10)' 'ZP05',
  ' ' 'KOMV-KBETR(10)' L_VBAK-ZP05_KBETR,
  ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP05_KOEIN.
  ENDIF.

  IF L_VBAK-ZP25_KBETR NE SPACE
     AND L_VBAK-ZP25_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
  ' ' 'KOMV-KSCHL(10)' 'ZP25',
  ' ' 'KOMV-KBETR(10)' L_VBAK-ZP25_KBETR,
  ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP25_KOEIN.
  ENDIF.

  IF L_VBAK-ZP08_KBETR NE SPACE
    AND L_VBAK-ZP08_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=V69A_KOAN',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '5003',
*    ' ' 'BDC_OKCODE' '=V69A_KOAN',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*    ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*    ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
  ' ' 'KOMV-KSCHL(10)' 'ZP08',
  ' ' 'KOMV-KBETR(10)' L_VBAK-ZP08_KBETR,
  ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP08_KOEIN.
  ENDIF.
*  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*  '1'    'SAPMV45A' '5003',
*  ' ' 'BDC_OKCODE' '=V69A_KOAN',
*  ' ' 'BDC_SUBSCR' 'SAPMV45A ',
*  ' ' 'BDC_SUBSCR' 'SAPLV69A ',
*  ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)',
*  ' ' 'KOMV-KSCHL(02)' 'PN00',
*  ' ' 'KOMV-KSCHL(03)' 'PN00',
*  ' ' 'KOMV-KSCHL(04)' 'ZP01',
*  ' ' 'KOMV-KSCHL(05)' 'ZP21',
*  ' ' 'KOMV-KSCHL(06)' 'ZP03',
*  ' ' 'KOMV-KSCHL(07)' 'ZP23',
*  ' ' 'KOMV-KSCHL(08)' 'ZP05',
*  ' ' 'KOMV-KSCHL(09)' 'ZP25',
*  ' ' 'KOMV-KSCHL(10)' 'ZP08',
*  ' ' 'KOMV-KBETR(02)' L_VBAK-PN00_KBETR,
*  ' ' 'KOMV-KBETR(03)' L_VBAK-PN002_KBETR,
*  ' ' 'KOMV-KBETR(04)' L_VBAK-ZP01_KBETR,
*  ' ' 'KOMV-KBETR(05)' L_VBAK-ZP21_KBETR,
*  ' ' 'KOMV-KBETR(06)' L_VBAK-ZP03_KBETR,
*  ' ' 'KOMV-KBETR(07)' L_VBAK-ZP23_KBETR,
*  ' ' 'KOMV-KBETR(08)' L_VBAK-ZP05_KBETR,
*  ' ' 'KOMV-KBETR(09)' L_VBAK-ZP25_KBETR,
*  ' ' 'KOMV-KBETR(10)' L_VBAK-ZP08_KBETR,
*  ' ' 'RV61A-KOEIN(02)' L_VBAK-PN00_KOEIN,
*  ' ' 'RV61A-KOEIN(03)' L_VBAK-PN002_KOEIN,
*  ' ' 'RV61A-KOEIN(04)' L_VBAK-ZP01_KOEIN,
*  ' ' 'RV61A-KOEIN(05)' L_VBAK-ZP21_KOEIN,
*  ' ' 'RV61A-KOEIN(06)' L_VBAK-ZP03_KOEIN,
*  ' ' 'RV61A-KOEIN(07)' L_VBAK-ZP23_KOEIN,
*  ' ' 'RV61A-KOEIN(08)' L_VBAK-ZP05_KOEIN,
*  ' ' 'RV61A-KOEIN(09)' L_VBAK-ZP25_KOEIN,
*  ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP08_KOEIN.

*  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
* '1'    'SAPMV45A' '5003',
* ' ' 'BDC_OKCODE' '/00',
* ' ' 'BDC_SUBSCR' 'SAPMV45A',
* ' ' 'BDC_SUBSCR' 'SAPLV69A',
* ' ' 'BDC_CURSOR' 'KOMV-KBETR(06)'.


  IF L_VBAK-ZP28_KBETR NE SPACE
    AND L_VBAK-ZP28_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '5003',
     ' ' 'BDC_OKCODE' '/00',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPLV69A',
     ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*   '1'    'SAPMV45A' '5003',
*   ' ' 'BDC_OKCODE' '/00',
*   ' ' 'BDC_SUBSCR' 'SAPMV45A',
*   ' ' 'BDC_SUBSCR' 'SAPLV69A',
*   ' ' 'BDC_CURSOR' 'KOMV-KBETR(06)',
    ' ' 'KOMV-KSCHL(10)' 'ZP28',
    ' ' 'KOMV-KBETR(10)' L_VBAK-ZP28_KBETR,
    ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP28_KOEIN.
  ENDIF.

  IF L_VBAK-ZP09_KBETR NE SPACE
    AND L_VBAK-ZP09_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '5003',
     ' ' 'BDC_OKCODE' '/00',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPLV69A',
     ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*   '1'    'SAPMV45A' '5003',
*   ' ' 'BDC_OKCODE' '/00',
*   ' ' 'BDC_SUBSCR' 'SAPMV45A',
*   ' ' 'BDC_SUBSCR' 'SAPLV69A',
*   ' ' 'BDC_CURSOR' 'KOMV-KBETR(06)',
    ' ' 'KOMV-KSCHL(10)' 'ZP09',
    ' ' 'KOMV-KBETR(10)' L_VBAK-ZP09_KBETR,
    ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP09_KOEIN.
  ENDIF.

  IF L_VBAK-ZP29_KBETR NE SPACE
    AND L_VBAK-ZP29_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '5003',
     ' ' 'BDC_OKCODE' '/00',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPLV69A',
     ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*   '1'    'SAPMV45A' '5003',
*   ' ' 'BDC_OKCODE' '/00',
*   ' ' 'BDC_SUBSCR' 'SAPMV45A',
*   ' ' 'BDC_SUBSCR' 'SAPLV69A',
*   ' ' 'BDC_CURSOR' 'KOMV-KBETR(06)',
   ' ' 'KOMV-KSCHL(10)' 'ZP29',
   ' ' 'KOMV-KBETR(10)' L_VBAK-ZP29_KBETR,
   ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP29_KOEIN.
  ENDIF.

  IF L_VBAK-ZP11_KBETR NE SPACE
   AND L_VBAK-ZP11_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '5003',
     ' ' 'BDC_OKCODE' '/00',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPLV69A',
     ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)'.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*   '1'    'SAPMV45A' '5003',
*   ' ' 'BDC_OKCODE' '/00',
*   ' ' 'BDC_SUBSCR' 'SAPMV45A',
*   ' ' 'BDC_SUBSCR' 'SAPLV69A',
*   ' ' 'BDC_CURSOR' 'KOMV-KBETR(06)',
   ' ' 'KOMV-KSCHL(10)' 'ZP11',
   ' ' 'KOMV-KBETR(10)' L_VBAK-ZP11_KBETR,
   ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP11_KOEIN.
  ENDIF.

  IF L_VBAK-ZP31_KBETR NE SPACE
   AND L_VBAK-ZP31_KOEIN NE SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '5003',
     ' ' 'BDC_OKCODE' '/00',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPLV69A',
     ' ' 'BDC_CURSOR' 'KOMV-KBETR(10)'.


    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*   '1'    'SAPMV45A' '5003',
*   ' ' 'BDC_OKCODE' '/00',
*   ' ' 'BDC_SUBSCR' 'SAPMV45A',
*   ' ' 'BDC_SUBSCR' 'SAPLV69A',
*   ' ' 'BDC_CURSOR' 'KOMV-KBETR(06)',
   ' ' 'KOMV-KSCHL(10)' 'ZP31',
   ' ' 'KOMV-KBETR(10)' L_VBAK-ZP31_KBETR,
   ' ' 'RV61A-KOEIN(10)' L_VBAK-ZP31_KOEIN.
  ENDIF.


*  PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*  '1'    'SAPMV45A' '5003',
*  ' ' 'BDC_OKCODE' '/00',
*  ' ' 'BDC_SUBSCR' 'SAPMV45A',
*  ' ' 'BDC_SUBSCR' 'SAPLV69A',
*  ' ' 'BDC_CURSOR' 'KOMV-KBETR(06)',
*  ' ' 'KOMV-KSCHL(02)' 'ZP28',
*  ' ' 'KOMV-KSCHL(03)' 'ZP09',
*  ' ' 'KOMV-KSCHL(04)' 'ZP29',
*  ' ' 'KOMV-KSCHL(05)' 'ZP11',
*  ' ' 'KOMV-KSCHL(06)' 'ZP31',
*  ' ' 'KOMV-KBETR(02)' L_VBAK-ZP28_KBETR,
*  ' ' 'KOMV-KBETR(03)' L_VBAK-ZP09_KBETR,
*  ' ' 'KOMV-KBETR(04)' L_VBAK-ZP29_KBETR,
*  ' ' 'KOMV-KBETR(05)' L_VBAK-ZP11_KBETR,
*  ' ' 'KOMV-KBETR(06)'  L_VBAK-ZP31_KBETR,
*  ' ' 'RV61A-KOEIN(02)' L_VBAK-ZP28_KOEIN,
*  ' ' 'RV61A-KOEIN(03)' L_VBAK-ZP09_KOEIN,
*  ' ' 'RV61A-KOEIN(04)' L_VBAK-ZP29_KOEIN,
*  ' ' 'RV61A-KOEIN(05)' L_VBAK-ZP11_KOEIN,
*  ' ' 'RV61A-KOEIN(06)' L_VBAK-ZP31_KOEIN.
*---------------------END OF------------------------

*----判断是否是带 billing plan 的Item category---------
  IF NOT L_VBAK-PSTYV IN R_PSTYV.
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=T/09',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(07)'.
  ELSE.
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '5003',
    ' ' 'BDC_OKCODE' '=T/10',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV69A',
    ' ' 'BDC_CURSOR' 'KOMV-KSCHL(07)'.
  ENDIF.
*------------END OF-------------------------

*-------付款方和送达方的判断--------------------
*  IF L_VBAK-F_PARTNER = '' "付款方
*     AND L_VBAK-S_PARTNER = ''."送达方
  IF L_VBAK-S_PARTNER = ''."送达方
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '4003',
    ' ' 'BDC_OKCODE' '/00',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV09C'.
*    ' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(06)',
*    ' ' 'GV_FILTER' 'PARALL'.
*    ' ' 'GVS_TC_DATA-REC-PARTNER(05)' L_VBAK-F_PARTNER,"付款方
*    ' ' 'GVS_TC_DATA-REC-PARTNER(06)' L_VBAK-S_PARTNER."送达方

  ELSE.
*  根据表头合作伙伴的行数来判断送达方的位置
    IF SUM = 4.
      PERFORM FRM_ADD_BDC_TAB_RECORD USING:
      '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '/00',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPLV09C',
      ' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(04)',
      ' ' 'GV_FILTER' 'PARALL',
      ' ' 'GVS_TC_DATA-REC-PARTNER(04)' L_VBAK-S_PARTNER."送达方
    ELSEIF SUM = 5.
      PERFORM FRM_ADD_BDC_TAB_RECORD USING:
      '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '/00',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPLV09C',
      ' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(05)',
      ' ' 'GV_FILTER' 'PARALL',
      ' ' 'GVS_TC_DATA-REC-PARTNER(05)' L_VBAK-S_PARTNER."送达方
    ELSEIF SUM = 6.
      PERFORM FRM_ADD_BDC_TAB_RECORD USING:
      '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '/00',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPLV09C',
      ' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(06)',
      ' ' 'GV_FILTER' 'PARALL',
      ' ' 'GVS_TC_DATA-REC-PARTNER(06)' L_VBAK-S_PARTNER."送达方

    ENDIF.

*    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
*    '1'    'SAPMV45A' '4003',
*    ' ' 'BDC_OKCODE' '/00',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPMV45A',
*    ' ' 'BDC_SUBSCR' 'SAPLV09C',
*    ' ' 'BDC_CURSOR' 'GVS_TC_DATA-REC-PARTNER(06)',
*    ' ' 'GV_FILTER' 'PARALL',
*   ' ' 'GVS_TC_DATA-REC-PARTNER(05)' L_VBAK-F_PARTNER,"付款方
*    ' ' 'GVS_TC_DATA-REC-PARTNER(06)' L_VBAK-S_PARTNER."送达方

  ENDIF.
*------------------end of------------------------------------

*----判断是否是带 billing plan 的Item category---------
  IF NOT L_VBAK-PSTYV IN R_PSTYV.
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '4003',
    ' ' 'BDC_OKCODE' '=T/11',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPMV45A',
    ' ' 'BDC_SUBSCR' 'SAPLV70T'.
  ELSE.
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
     '1'    'SAPMV45A' '4003',
     ' ' 'BDC_OKCODE' '=T/12',
     ' ' 'BDC_SUBSCR' 'SAPMV45A',
     ' ' 'BDC_SUBSCR' 'SAPMV45A'.
  ENDIF.
*-----------END OF-------------------------------

*--------采购订单数据的判断--------------------------------
*如果售达方中采购订单项目和售达方中您的参考都为空、送达方中您的参考
  IF L_VBAK-POSEX = SPACE AND L_VBAK-IHREZ = SPACE
     AND L_VBAK-IHREZ_E = SPACE.

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '=SICH',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A  ',
      ' ' 'BDC_CURSOR' 'VBKD-IHREZ_E'.
*     ' ' 'VBAP-POSEX' L_VBAK-POSEX,"售达方中采购订单项目
*     ' ' 'VBKD-IHREZ' L_VBAK-IHREZ,"售达方中您的参考
*      ' ' 'VBKD-IHREZ_E'    L_VBAK-IHREZ_E."送达方中您的参考

  ELSEIF L_VBAK-POSEX = SPACE."售达方中采购订单项目
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
      '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '=SICH',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A  ',
      ' ' 'BDC_CURSOR' 'VBKD-IHREZ_E',
*     ' ' 'VBAP-POSEX' L_VBAK-POSEX."售达方中采购订单项目
      ' ' 'VBKD-IHREZ' L_VBAK-IHREZ,"售达方中您的参考
      ' ' 'VBKD-IHREZ_E'    L_VBAK-IHREZ_E."送达方中您的参考


  ELSEIF L_VBAK-IHREZ = SPACE."售达方中您的参考

    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
      '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '=SICH',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A  ',
      ' ' 'BDC_CURSOR' 'VBKD-IHREZ_E',
      ' ' 'VBAP-POSEX' L_VBAK-POSEX,"售达方中采购订单项目
      ' ' 'VBKD-IHREZ_E'    L_VBAK-IHREZ_E."送达方中您的参考

  ELSEIF L_VBAK-IHREZ_E = SPACE."送达方中您的参考
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
      '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '=SICH',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A  ',
      ' ' 'BDC_CURSOR' 'VBKD-IHREZ_E',
      ' ' 'VBAP-POSEX' L_VBAK-POSEX,"售达方中采购订单项目
      ' ' 'VBKD-IHREZ' L_VBAK-IHREZ."售达方中您的参考
*      ' ' 'VBKD-IHREZ_E'    L_VBAK-IHREZ_E."送达方中您的参考


  ELSE.
    PERFORM FRM_ADD_BDC_TAB_RECORD USING:
    '1'    'SAPMV45A' '4003',
      ' ' 'BDC_OKCODE' '=SICH',
      ' ' 'BDC_SUBSCR' 'SAPMV45A',
      ' ' 'BDC_SUBSCR' 'SAPMV45A  ',
      ' ' 'BDC_CURSOR' 'VBKD-IHREZ_E',
     ' ' 'VBAP-POSEX' L_VBAK-POSEX,"售达方中采购订单项目
     ' ' 'VBKD-IHREZ' L_VBAK-IHREZ,"售达方中您的参考
      ' ' 'VBKD-IHREZ_E'    L_VBAK-IHREZ_E."送达方中您的参考
  ENDIF.
  CLEAR: R_PSTYV[],R_PSTYV.
*-------------------------------------------------------
*  CALL TRANSACTION 'VA02' USING T_BDC MODE 'E'.
  PERFORM SUB_TRANSFER_DATA USING 'VA02'.

*--处理日志信息-----------------------
*----->message inf.
  IF SY-SUBRC = 0.
    MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
*-----表示肯定成功了
    ITAB_MESSTAB-MESSAGE  =  '该行项目已成功导入!'.
    ITAB_MESSTAB-FLAG   =  '成功'.
    APPEND ITAB_MESSTAB.

*--创建文本--------------------------------------
    PERFORM CREATE_TEXT USING L_VBAK-VBELN L_VBAK-POSNR L_VBAK-JUMING.
  ELSE.
    MOVE-CORRESPONDING L_VBAK TO ITAB_MESSTAB.
    LOOP AT MESSTAB WHERE MSGTYP = 'E'.
      ITAB_MESSTAB-FLAG    = '失败'.
      SELECT SINGLE TEXT
               FROM T100
               INTO ITAB_MESSTAB-MESSAGE
              WHERE SPRSL = MESSTAB-MSGSPRA
                AND ARBGB = MESSTAB-MSGID
                AND MSGNR = MESSTAB-MSGNR.
      CALL FUNCTION 'FORMAT_MESSAGE'
           EXPORTING
                ID  = MESSTAB-MSGID
                NO  = MESSTAB-MSGNR
           IMPORTING
                MSG = ITAB_MESSTAB-MESSAGE.
    ENDLOOP.
    IF SY-SUBRC NE 0."没有E类型信息
      LOOP AT MESSTAB WHERE MSGTYP = 'S'.
        ITAB_MESSTAB-FLAG    = '失败'.
        SELECT SINGLE TEXT
               FROM T100
               INTO ITAB_MESSTAB-MESSAGE
              WHERE SPRSL = MESSTAB-MSGSPRA
                AND ARBGB = MESSTAB-MSGID
                AND MSGNR = MESSTAB-MSGNR.
        CALL FUNCTION 'FORMAT_MESSAGE'
             EXPORTING
                  ID  = MESSTAB-MSGID
                  NO  = MESSTAB-MSGNR
             IMPORTING
                  MSG = ITAB_MESSTAB-MESSAGE.
      ENDLOOP.
    ELSE.
      LOOP AT MESSTAB WHERE MSGTYP = 'S'.
        ITAB_MESSTAB-FLAG   =  '成功'.
        ITAB_MESSTAB-MESSAGE = '行项目更新成功!'.
      ENDLOOP.
*--创建文本--------------------------------------
      PERFORM CREATE_TEXT USING L_VBAK-VBELN L_VBAK-POSNR L_VBAK-JUMING.
    ENDIF.
    APPEND ITAB_MESSTAB.
  ENDIF.
  COMMIT WORK AND WAIT.
  REFRESH MESSTAB.
  CLEAR MESSTAB.

ENDFORM.                    " RUN_BDC

*---------------------------------------------------------------------*
*       FORM SUB_TRANSFER_DATA                                        *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  T_CODE                                                        *
*---------------------------------------------------------------------*
FORM SUB_TRANSFER_DATA USING    T_CODE.

  CALL TRANSACTION T_CODE
    USING      T_BDC
    MODE       MODE  " 'N'-Do not display
*    MODE       'A' " 'A'-Display the screens
    UPDATE     'S'
    MESSAGES INTO MESSTAB.
ENDFORM.                    " sub_transfer_data

*&---------------------------------------------------------------------*
*      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  output_LOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM OUTPUT_LOG.
  SORT ITAB_MESSTAB BY VBELN.
  PERFORM ALV_DISPLAY."ALV输出
ENDFORM.                    " output_LOG
*&---------------------------------------------------------------------*
*&      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           = ITAB_MESSTAB
    EXCEPTIONS
      PROGRAM_ERROR      = 1
      OTHERS             = 2.

ENDFORM.                    " ALV_DISPLAY
*&---------------------------------------------------------------------*
*&      Form  INIT_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM INIT_FIELDCAT .
  GT_FIELDCAT-FIELDNAME = 'VBELN'.
  GT_FIELDCAT-SELTEXT_L = '订单号'.
  GT_FIELDCAT-SELTEXT_S = '订单号'.
  GT_FIELDCAT-SELTEXT_M = '订单号'.
  APPEND GT_FIELDCAT.
  CLEAR GT_FIELDCAT.
  GT_FIELDCAT-FIELDNAME = 'POSNR'.
  GT_FIELDCAT-SELTEXT_L = '项目号'.
  GT_FIELDCAT-SELTEXT_S = '项目号'.
  GT_FIELDCAT-SELTEXT_M = '项目号'.
  APPEND GT_FIELDCAT.
  CLEAR GT_FIELDCAT.
  GT_FIELDCAT-FIELDNAME = 'KWMENG'.
  GT_FIELDCAT-SELTEXT_L = '数量'.
  GT_FIELDCAT-SELTEXT_S = '数量'.
  GT_FIELDCAT-SELTEXT_M = '数量'.
  APPEND GT_FIELDCAT.
  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'KDMAT'.
*  GT_FIELDCAT-SELTEXT_L = '客户物料编号'.
*  GT_FIELDCAT-SELTEXT_S = '客户物料编号'.
*  GT_FIELDCAT-SELTEXT_M = '客户物料编号'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'PSTYV'.
*  GT_FIELDCAT-SELTEXT_L = '项目类型'.
*  GT_FIELDCAT-SELTEXT_S = '项目类型'.
*  GT_FIELDCAT-SELTEXT_M = '项目类型'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'UEPOS'.
*  GT_FIELDCAT-SELTEXT_L = '上层项'.
*  GT_FIELDCAT-SELTEXT_S = '上层项'.
*  GT_FIELDCAT-SELTEXT_M = '上层项'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'PR01价格'.
*  GT_FIELDCAT-SELTEXT_L = 'PR01_KBETR'.
*  GT_FIELDCAT-SELTEXT_S = 'PR01_KBETR'.
*  GT_FIELDCAT-SELTEXT_M = 'PR01_KBETR'.
**  gt_fieldcat-hotspot = 'X'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'PR01币种'.
*  GT_FIELDCAT-SELTEXT_L = 'PR01_KOEIN'.
*  GT_FIELDCAT-SELTEXT_S = 'PR01_KOEIN'.
*  GT_FIELDCAT-SELTEXT_M = 'PR01_KOEIN'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'ETDAT'.
*  GT_FIELDCAT-SELTEXT_L = '首次日期'.
*  GT_FIELDCAT-SELTEXT_S = '首次日期'.
*  GT_FIELDCAT-SELTEXT_M = '首次日期'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'PS_PSP_PNR'.
*  GT_FIELDCAT-SELTEXT_L = 'WBS元素'.
*  GT_FIELDCAT-SELTEXT_S = 'WBS元素'.
*  GT_FIELDCAT-SELTEXT_M = 'WBS元素'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'PN00_KBETR'.
*  GT_FIELDCAT-SELTEXT_L = 'PN00价格'.
*  GT_FIELDCAT-SELTEXT_S = 'PN00价格'.
*  GT_FIELDCAT-SELTEXT_M = 'PN00价格'.
*  APPEND GT_FIELDCAT.
*  CLEAR GT_FIELDCAT.
*  GT_FIELDCAT-FIELDNAME = 'PN00_KOEIN'.
*  GT_FIELDCAT-SELTEXT_L = 'PN00币种'.
*  GT_FIELDCAT-SELTEXT_S = 'PN00币种'.
*  GT_FIELDCAT-SELTEXT_M = 'PN00币种'.
*  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.
ENDFORM.                    " INIT_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  CREATE_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_VBAK_VBELN  text
*      -->P_I_VBAK_POSNR  text
*----------------------------------------------------------------------*
FORM CREATE_TEXT USING    P_I_VBAK_VBELN
                          P_I_VBAK_POSNR
                          P_L_VBAK-JUMING.
  DATA:L_TLINE   LIKE TLINE OCCURS 0 WITH HEADER LINE.
****局名
  L_TLINE-TDFORMAT = '01'.
  L_TLINE-TDLINE  = P_L_VBAK-JUMING.
  APPEND L_TLINE.
*-------------在P_I_VBAK_VBELN前面补零-----
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
            INPUT  = P_I_VBAK_VBELN
       IMPORTING
            OUTPUT = P_I_VBAK_VBELN.

*-------------在P_I_VBAK_POSNR前面补零-----
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
            INPUT  = P_I_VBAK_POSNR
       IMPORTING
            OUTPUT = P_I_VBAK_POSNR.

*  L_NAME = P_I_VBAK_VBELN.
  CONCATENATE P_I_VBAK_VBELN P_I_VBAK_POSNR INTO L_NAME.

  CALL FUNCTION 'CREATE_TEXT'
       EXPORTING
            FID         = 'Z003'
            FLANGUAGE   = '1'
            FNAME       = L_NAME
            FOBJECT     = 'VBBP'
            SAVE_DIRECT = 'X'
            FFORMAT     = '*'
       TABLES
            FLINES      = L_TLINE
       EXCEPTIONS
            NO_INIT     = 1
            NO_SAVE     = 2
            OTHERS      = 3.
  CLEAR: L_TLINE[],L_TLINE,L_NAME.
ENDFORM.                    " CREATE_TEXT 

你可能感兴趣的:(function,upload,delete,Parameters,RadioButton,output)