IF P_ZY EQ 'X'."直营订单 调拨单

      PERFORM FRM_INIT_PO_HEADER.

      PERFORM FRM_INIT_PO_ITEM.

      PERFORM FRM_INIT_PO_SCHLINE.

      PERFORM FRM_INIT_PO_TEXTS.

      PERFORM FRM_CREATE_PO USING P_COMMIT.

    ELSEIF P_JM EQ 'X'."加盟订单 销售订单

      PERFORM FRM_INIT_SALESORDER_HEADER .

      PERFORM FRM_INIT_SALESORDER_ITEMS .

      PERFORM FRM_INIT_SALESORDER_PARTNER .

      PERFORM FRM_INIT_SALESORDER_TEXTS .

      PERFORM FRM_CREATE_SALESORDER USING P_COMMIT.
ENDIF.
FORM FRM_INIT_PO_HEADER.

  DATA: LV_VENDOR TYPE LIFNR,
LV_DATE TYPE DATUM. CLEAR: GS_POHEADER,
GS_POHEADERX. LV_DATE = IT_HEADER-ZDATE. IF LV_DATE IS INITIAL.
LV_DATE = P_DATE.
ENDIF. PERFORM FRM_CONVERT_VENDOR USING '' CHANGING LV_VENDOR. GS_POHEADER-VENDOR = LV_VENDOR.
GS_POHEADER-SUPPL_PLNT = ''.
GS_POHEADER-DOC_TYPE = GS_ORG-AUART.
GS_POHEADER-DOC_DATE = LV_DATE. "Document Date
GS_POHEADER-CREAT_DATE = SY-DATUM.
GS_POHEADER-CREATED_BY = SY-UNAME.
GS_POHEADER-PURCH_ORG = GS_ORG-EKORG.
GS_POHEADER-PUR_GROUP = GS_ORG-EKGRP.
GS_POHEADER-COMP_CODE = GS_ORG-BUKRS.
GS_POHEADER-SALES_PERS = IT_HEADER-ZPOSN."Salesperson
GS_POHEADER-TELEPHONE = IT_HEADER-ZLXDH."Vendor's Telephone GS_POHEADERX-DOC_TYPE = 'X'.
GS_POHEADERX-DOC_DATE = 'X'.
GS_POHEADERX-CREAT_DATE = 'X'.
GS_POHEADERX-CREATED_BY = 'X'.
GS_POHEADERX-VENDOR = 'X'.
GS_POHEADERX-PURCH_ORG = 'X'.
GS_POHEADERX-PUR_GROUP = 'X'.
GS_POHEADERX-COMP_CODE = 'X'.
GS_POHEADERX-SALES_PERS = 'X'.
GS_POHEADERX-TELEPHONE = 'X'.
GS_POHEADERX-SUPPL_PLNT = 'X'.
ENDFORM. " FRM_INIT_PO_HEADER
FORM FRM_INIT_PO_ITEM.

  DATA : LV_LGORT TYPE VBAP-LGORT,
LV_WERKS TYPE VBAP-WERKS,
LV_MATNR TYPE VBAP-MATNR,
LV_BWTTY TYPE MBEW-BWTTY,
LV_MEINS TYPE MARA-MEINS,
LV_QTY TYPE EKPO-MENGE,
LV_CHARG TYPE MCHA-CHARG. CLEAR: GS_POITEM,
GT_POITEM,
GS_POITEMX,
GT_POITEMX. SHIFT IT_HEADER-ZKUBM LEFT DELETING LEADING ''. LV_WERKS = IT_HEADER-ZKUBM. LOOP AT IT_ITEM WHERE ZPOSN EQ IT_HEADER-ZPOSN.
* 转换物料号码
PERFORM FRM_CONVERT_ARTICLE USING IT_ITEM-ZSPKH CHANGING LV_MATNR.
* 是否启用分割评估
SELECT SINGLE BWTTY INTO LV_BWTTY FROM MBEW WHERE MATNR = LV_MATNR AND BWKEY = LV_WERKS.
* 基本单位
SELECT SINGLE MEINS INTO LV_MEINS FROM MARA WHERE MATNR = LV_MATNR. IF LV_MEINS = 'G'."基本单位为G, 下单数量取总金重
LV_QTY = IT_ITEM-ZZJZ.
ELSE."否则取总件数
LV_QTY = IT_ITEM-ZSPJH.
ENDIF. IF LV_QTY IS INITIAL.
LV_QTY = .
ENDIF. LV_CHARG = IT_ITEM-CHARG. * 物料启用了分割凭证但是没有评估类型(批次),则使用物料编码作为评估类型
IF LV_BWTTY = 'X' AND LV_CHARG IS INITIAL.
PERFORM FRM_CONVERT_VALUE_TYPE USING LV_MATNR CHANGING LV_CHARG.
ENDIF.
* 检查物料 门店 批次是否存在
PERFORM FRM_CHECK_BATCH USING LV_WERKS LV_MATNR LV_CHARG. CLEAR GS_POITEM.
GS_POITEM-PO_ITEM = IT_ITEM-ZITEM.
GS_POITEM-MATERIAL = LV_MATNR.
GS_POITEM-PLANT = LV_WERKS.
GS_POITEM-BATCH = IT_ITEM-CHARG."批次
GS_POITEM-SUPPL_STLOC = ''.
GS_POITEM-QUANTITY = LV_QTY. IF LV_BWTTY = 'X'."
GS_POITEM-VAL_TYPE = LV_CHARG."评估类型
ENDIF. IF GS_ORG-AUART = 'ZSTJ'."Consigment
GS_POITEM-ITEM_CAT = 'K'.
ELSE.
GS_POITEM-ITEM_CAT = 'U'.
ENDIF. APPEND GS_POITEM TO GT_POITEM. CLEAR GS_POITEMX.
GS_POITEMX-PO_ITEM = IT_ITEM-ZITEM.
GS_POITEMX-MATERIAL = 'X'.
GS_POITEMX-BATCH = 'X'.
GS_POITEMX-VAL_TYPE = 'X'.
GS_POITEMX-STGE_LOC = 'X'.
GS_POITEMX-PLANT = 'X'.
GS_POITEMX-QUANTITY = 'X'.
GS_POITEMX-ITEM_CAT = 'X'.
APPEND GS_POITEMX TO GT_POITEMX.
ENDLOOP. ENDFORM. " FRM_INIT_PO_ITEM
FORM FRM_INIT_PO_SCHLINE .
REFRESH: GT_POSCHEDULE,
GT_POSCHEDULEX. * CLEAR gs_poschedule.
* gs_poschedule-po_item = p_item_no.
* gs_poschedule-sched_line = 1.
* gs_poschedule-delivery_date = lv_del_date.
* APPEND gs_poschedule TO gt_poschedule.
*
* CLEAR gs_poschedulex.
* gs_poschedulex-po_item = p_item_no.
* gs_poschedulex-sched_line = 1.
* gs_poschedulex-delivery_date = 'X'.
* APPEND gs_poschedulex TO gt_poschedulex.
ENDFORM. " FRM_INIT_PO_SCHLINE
FORM FRM_INIT_PO_TEXTS.
REFRESH: GT_POTEXTHEADER,
GT_POTEXTITEM.
CLEAR: GS_POTEXTITEM,
GS_POTEXTITEM. * Header Text
* 抬头文本
CLEAR GS_POTEXTHEADER.
GS_POTEXTHEADER-TEXT_ID = 'F01'.
GS_POTEXTHEADER-TEXT_LINE = IT_HEADER-ZHTEXT."订单抬头文本
APPEND GS_POTEXTHEADER TO GT_POTEXTHEADER. * Item Text
* 行项目文本
LOOP AT IT_ITEM WHERE ZPOSN EQ IT_HEADER-ZPOSN.
CLEAR GS_POTEXTITEM.
GS_POTEXTITEM-PO_ITEM = IT_ITEM-ZITEM.
GS_POTEXTITEM-TEXT_ID = 'F01'.
GS_POTEXTITEM-TEXT_LINE = IT_ITEM-ZITEXT."订单行项目文本
APPEND GS_POTEXTITEM TO GT_POTEXTITEM.
ENDLOOP.
ENDFORM. " FRM_INIT_PO_TEXTS
FORM FRM_CREATE_PO USING P_COMMIT.
DATA : LV_TESTRUN TYPE BAPIFLAG-BAPIFLAG,
LV_ERROR. IF P_COMMIT IS INITIAL.
LV_TESTRUN = 'X'.
ENDIF. CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = GS_POHEADER
POHEADERX = GS_POHEADERX
TESTRUN = LV_TESTRUN
IMPORTING
EXPPURCHASEORDER = GV_EXPPURCHASEORDER
TABLES
RETURN = GT_RETURN
POITEM = GT_POITEM
POITEMX = GT_POITEMX
POSCHEDULE = GT_POSCHEDULE
POSCHEDULEX = GT_POSCHEDULEX
POTEXTHEADER = GT_POTEXTHEADER
POTEXTITEM = GT_POTEXTITEM. LOOP AT GT_RETURN INTO GS_RETURN.
CLEAR IT_MSG.
MOVE-CORRESPONDING GS_RETURN TO IT_MSG.
IT_MSG-ZPOSN = IT_HEADER-ZPOSN.
IT_MSG-ORDER = GV_EXPPURCHASEORDER. CASE GS_RETURN-TYPE.
WHEN 'E' OR 'X' OR 'A'.
IF GS_RETURN-ID = 'MEPO' AND GS_RETURN-NUMBER = ''.
CONTINUE.
ELSE.
IT_MSG-LIGHT = ''."Red Light
ENDIF. LV_ERROR = 'X'.
WHEN 'S'.
IT_MSG-LIGHT = ''."Green Light
WHEN OTHERS.
CONTINUE.
ENDCASE. COLLECT IT_MSG.
ENDLOOP. IF LV_ERROR EQ 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE. CHECK P_COMMIT EQ 'X'. PERFORM FRM_RECORD_LINES USING IT_HEADER-ZPOSN GV_EXPPURCHASEORDER.
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT = 'X'.
ENDIF.
ENDFORM. " FRM_CREATE_PO
FORM FRM_INIT_SALESORDER_HEADER.

  DATA : LV_DATE TYPE DATUM.

  CLEAR GS_SALESORDER_HEADER.

  LV_DATE = IT_HEADER-ZDATE.

  IF LV_DATE IS INITIAL.
LV_DATE = P_DATE.
ENDIF. * Mandatory entries:
GS_SALESORDER_HEADER-DOC_TYPE = GS_ORG-AUART. "Sales document type
GS_SALESORDER_HEADER-SALES_ORG = GS_ORG-VKORG. "Sales organization
GS_SALESORDER_HEADER-DISTR_CHAN = GS_ORG-VTWEG. "Distribution channel
GS_SALESORDER_HEADER-DIVISION = GS_ORG-SPART. " Division * Optional entries:
GS_SALESORDER_HEADER-DOC_DATE = LV_DATE. "Document date
GS_SALESORDER_HEADER-PURCH_NO_C = IT_HEADER-ZPOSN. "Customer PO No. (POS订单号码)
GS_SALESORDER_HEADER-ORD_REASON = IT_HEADER-ZPLX. "Order reason.
GS_SALESORDER_HEADER-TELEPHONE = IT_HEADER-ZLXDH. "Telephone Number. (联系电话)
GS_SALESORDER_HEADER-NAME = IT_HEADER-ZLSR. "Name of order. (联系人) * Change index
GS_SALESORDER_HEADERX-UPDATEFLAG = 'I'. "Sales document type
GS_SALESORDER_HEADERX-DOC_TYPE = 'X'. "Sales document type
GS_SALESORDER_HEADERX-SALES_ORG = 'X'. "Sales organization
GS_SALESORDER_HEADERX-DISTR_CHAN = 'X'. "Distribution channel
GS_SALESORDER_HEADERX-DIVISION = 'X'. " Division GS_SALESORDER_HEADERX-DOC_DATE = 'X'. "Document date (订单日期)
GS_SALESORDER_HEADERX-PURCH_NO_C = 'X'. "Customer PO No. (POS订单号码)
GS_SALESORDER_HEADERX-ORD_REASON = 'X'. "Order reason. (订单类型)
GS_SALESORDER_HEADERX-TELEPHONE = 'X'. "Telephone Number. (联系电话)
GS_SALESORDER_HEADERX-NAME = 'X'. "Name of order. (联系人)
* GS_SALESORDER_HEADERX-DOC_DATE = 'X'. "Name of order. (联系人) CLEAR GS_LOGIC_SWITCH.
* GS_LOGIC_SWITCH-COND_HANDL = 'X'.
GS_LOGIC_SWITCH-PRICING = 'G'.
ENDFORM. " FRM_INIT_SALESORDER_HEADER
FORM FRM_INIT_SALESORDER_ITEMS.

  DATA : LV_MATNR TYPE MARA-MATNR,
LV_BWTTY TYPE MBEW-BWTTY,
LV_MEINS TYPE MARA-MEINS,
LV_CHARG TYPE MCH1-CHARG,
LV_WERKS TYPE MARC-WERKS,
LV_MENGE TYPE EKPO-MENGE. DATA : LV_ZPR5 TYPE P DECIMALS . REFRESH: GT_SALESORDER_ITEMX,
GT_SALESORDER_ITEM,
GT_SALESORDER_CONDITIONS,
GT_SALESORDER_CONDITIONX,
GT_SALESORDER_SCHLINE,
GT_SALESORDER_SCHLINEX,
GT_SALESORDER_TEXT. LV_WERKS = IT_HEADER-WERKS. LOOP AT IT_ITEM WHERE ZPOSN EQ IT_HEADER-ZPOSN. *** 行项目
* Convert Article no. (商品款号)
PERFORM FRM_CONVERT_ARTICLE USING IT_ITEM-ZSPKH CHANGING LV_MATNR.
* 评估类别
SELECT SINGLE BWTTY INTO LV_BWTTY FROM MBEW WHERE MATNR = LV_MATNR AND BWKEY = LV_WERKS.
* 基本单位
SELECT SINGLE MEINS INTO LV_MEINS FROM MARA WHERE MATNR = LV_MATNR. IF LV_MEINS = 'G'.
LV_MENGE = IT_ITEM-ZZJZ.
ELSE.
LV_MENGE = IT_ITEM-ZSPJH."Target quantity in sales units
ENDIF. * Batch
LV_CHARG = IT_ITEM-CHARG.
* 检查批次、物料是否存在
PERFORM FRM_CHECK_BATCH USING LV_WERKS LV_MATNR LV_CHARG. CLEAR GS_SALESORDER_ITEM.
GS_SALESORDER_ITEM-ITM_NUMBER = IT_ITEM-ZITEM."
GS_SALESORDER_ITEM-MATERIAL = LV_MATNR."
GS_SALESORDER_ITEM-BATCH = IT_ITEM-CHARG."
GS_SALESORDER_ITEM-PLANT = LV_WERKS. "
GS_SALESORDER_ITEM-TARGET_QTY = LV_MENGE."Target quantity in sales units IF LV_BWTTY EQ 'X'.
GS_SALESORDER_ITEM-VAL_TYPE = LV_CHARG." ”Valution Type
ENDIF. APPEND GS_SALESORDER_ITEM TO GT_SALESORDER_ITEM. CLEAR GS_SALESORDER_ITEMX.
GS_SALESORDER_ITEMX-UPDATEFLAG = 'I'.
GS_SALESORDER_ITEMX-ITM_NUMBER = IT_ITEM-ZITEM.
GS_SALESORDER_ITEMX-MATERIAL = 'X'.
GS_SALESORDER_ITEMX-BATCH = 'X'.
GS_SALESORDER_ITEMX-VAL_TYPE = 'X'.
GS_SALESORDER_ITEMX-PLANT = 'X'.
GS_SALESORDER_ITEMX-TARGET_QTY = 'X'.
APPEND GS_SALESORDER_ITEMX TO GT_SALESORDER_ITEMX. *** 计划行
CLEAR GS_SALESORDER_SCHLINE.
GS_SALESORDER_SCHLINE-ITM_NUMBER = IT_ITEM-ZITEM.
GS_SALESORDER_SCHLINE-SCHED_LINE = ''.
GS_SALESORDER_SCHLINE-REQ_QTY = LV_MENGE.
APPEND GS_SALESORDER_SCHLINE TO GT_SALESORDER_SCHLINE. CLEAR GS_SALESORDER_SCHLINEX.
GS_SALESORDER_SCHLINEX-ITM_NUMBER = IT_ITEM-ZITEM.
GS_SALESORDER_SCHLINEX-SCHED_LINE = ''.
GS_SALESORDER_SCHLINEX-UPDATEFLAG = 'I'.
GS_SALESORDER_SCHLINEX-REQ_QTY = 'X'.
APPEND GS_SALESORDER_SCHLINEX TO GT_SALESORDER_SCHLINEX. *** 条件
* 估算价(金单价)
CLEAR GS_SALESORDER_CONDITIONS.
GS_SALESORDER_CONDITIONS-ITM_NUMBER = IT_ITEM-ZITEM.
GS_SALESORDER_CONDITIONS-COND_TYPE = 'ZPR4'.
GS_SALESORDER_CONDITIONS-COND_VALUE = IT_ITEM-ZJDJ.
GS_SALESORDER_CONDITIONS-CURRENCY = 'CNY'.
APPEND GS_SALESORDER_CONDITIONS TO GT_SALESORDER_CONDITIONS. CLEAR GS_SALESORDER_CONDITIONX.
GS_SALESORDER_CONDITIONX-ITM_NUMBER = IT_ITEM-ZITEM.
GS_SALESORDER_CONDITIONX-COND_TYPE = 'ZPR4'.
GS_SALESORDER_CONDITIONX-UPDATEFLAG = 'I'.
GS_SALESORDER_CONDITIONX-COND_VALUE = 'X'.
GS_SALESORDER_CONDITIONX-CURRENCY = 'X'.
APPEND GS_SALESORDER_CONDITIONX TO GT_SALESORDER_CONDITIONX. *** 行项目文本
CLEAR GS_SALESORDER_TEXT.
GS_SALESORDER_TEXT-ITM_NUMBER = IT_ITEM-ZITEM."
GS_SALESORDER_TEXT-TEXT_ID = ''."Object VBBP
GS_SALESORDER_TEXT-TEXT_LINE = IT_ITEM-ZITEXT."(订单抬头文本)
GS_SALESORDER_TEXT-LANGU = SY-LANGU.
APPEND GS_SALESORDER_TEXT TO GT_SALESORDER_TEXT.
ENDLOOP. * 合计金额
CLEAR GS_SALESORDER_CONDITIONS.
GS_SALESORDER_CONDITIONS-COND_TYPE = 'ZPR0'.
GS_SALESORDER_CONDITIONS-COND_ST_NO = .
GS_SALESORDER_CONDITIONS-COND_COUNT = .
GS_SALESORDER_CONDITIONS-COND_VALUE = IT_HEADER-ZHJJE.
GS_SALESORDER_CONDITIONS-CURRENCY = 'CNY'.
APPEND GS_SALESORDER_CONDITIONS TO GT_SALESORDER_CONDITIONS. CLEAR GS_SALESORDER_CONDITIONX.
GS_SALESORDER_CONDITIONX-COND_TYPE = 'ZPR0'.
GS_SALESORDER_CONDITIONX-COND_ST_NO = .
GS_SALESORDER_CONDITIONX-COND_COUNT = .
GS_SALESORDER_CONDITIONX-UPDATEFLAG = 'I'.
GS_SALESORDER_CONDITIONX-COND_VALUE = 'X'.
GS_SALESORDER_CONDITIONX-CURRENCY = 'X'.
APPEND GS_SALESORDER_CONDITIONX TO GT_SALESORDER_CONDITIONX. * 订单订金
IF IT_HEADER-ZDDLX IS NOT INITIAL.
LV_ZPR5 = IT_HEADER-ZDDLX.
CLEAR GS_SALESORDER_CONDITIONS.
GS_SALESORDER_CONDITIONS-COND_TYPE = 'ZPR5'.
GS_SALESORDER_CONDITIONS-COND_ST_NO = .
GS_SALESORDER_CONDITIONS-COND_COUNT = .
GS_SALESORDER_CONDITIONS-COND_VALUE = LV_ZPR5.
GS_SALESORDER_CONDITIONS-CURRENCY = 'CNY'.
APPEND GS_SALESORDER_CONDITIONS TO GT_SALESORDER_CONDITIONS. CLEAR GS_SALESORDER_CONDITIONX.
GS_SALESORDER_CONDITIONX-COND_TYPE = 'ZPR5'.
GS_SALESORDER_CONDITIONX-COND_ST_NO = .
GS_SALESORDER_CONDITIONX-COND_COUNT = .
GS_SALESORDER_CONDITIONX-UPDATEFLAG = 'I'.
GS_SALESORDER_CONDITIONX-COND_VALUE = 'X'.
GS_SALESORDER_CONDITIONX-CURRENCY = 'X'.
APPEND GS_SALESORDER_CONDITIONX TO GT_SALESORDER_CONDITIONX.
ENDIF.
ENDFORM. " FRM_INIT_SALESORDER_ITEMS
FORM FRM_INIT_SALESORDER_PARTNER.

  DATA : LV_KUNNR TYPE VBPA-KUNNR."Customer

  CLEAR: GT_SALESORDER_PARTNER.

* Convert customer no. to internal no.(客户编码)
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = IT_HEADER-ZKUBM
IMPORTING
OUTPUT = LV_KUNNR. * WE Ship to , AG Sold to
CLEAR GS_SALESORDER_PARTNER.
* gs_salesorder_partner-itm_number = '10'."
GS_SALESORDER_PARTNER-PARTN_ROLE = 'WE'."SP
GS_SALESORDER_PARTNER-PARTN_NUMB = LV_KUNNR. "(客户编码)
* gs_salesorder_partner-name = u_header-zkhmc. "Name (客户名称)
APPEND GS_SALESORDER_PARTNER TO GT_SALESORDER_PARTNER. * CLEAR gs_salesorder_partner.
** gs_salesorder_partner-itm_number = '10'."
* gs_salesorder_partner-partn_role = 'AG'."SH
* gs_salesorder_partner-partn_numb = '0000040001'."SHip to
* APPEND gs_salesorder_partner TO gt_salesorder_partner.
ENDFORM. " FRM_INIT_SALESORDER_PARTNER
FORM FRM_INIT_SALESORDER_TEXTS.

*  CLEAR : GS_SALESORDER_TEXT,
* GT_SALESORDER_TEXT.
* Header Texts
CLEAR GS_SALESORDER_TEXT.
GS_SALESORDER_TEXT-TEXT_ID = ''."Object VBBK
GS_SALESORDER_TEXT-TEXT_LINE = IT_HEADER-ZHTEXT."(订单抬头文本)
GS_SALESORDER_TEXT-LANGU = SY-LANGU."
APPEND GS_SALESORDER_TEXT TO GT_SALESORDER_TEXT. ** Item Texts
* LOOP AT T_ITEMS INTO IT_ITEM.
* CLEAR GS_SALESORDER_TEXT.
* GS_SALESORDER_TEXT-ITM_NUMBER = IT_ITEM-ZITEM."
* GS_SALESORDER_TEXT-TEXT_ID = '0001'."Object VBBP
* GS_SALESORDER_TEXT-TEXT_LINE = IT_ITEM-ZITEXT."(订单抬头文本)
* GS_SALESORDER_TEXT-LANGU = SY-LANGU.
* APPEND GS_SALESORDER_TEXT TO GT_SALESORDER_TEXT.
* ENDLOOP. ENDFORM. " FRM_INIT_SALESORDER_TEXTS
FORM FRM_CREATE_SALESORDER USING P_COMMIT.

  DATA : LV_SALESORDER TYPE BAPIVBELN-VBELN,
LV_TESTRUN TYPE BAPIFLAG-BAPIFLAG,
LV_ERROR. IF P_COMMIT IS INITIAL.
LV_TESTRUN = 'X'.
ENDIF. CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = GS_SALESORDER_HEADER
ORDER_HEADER_INX = GS_SALESORDER_HEADERX
LOGIC_SWITCH = GS_LOGIC_SWITCH
TESTRUN = LV_TESTRUN
IMPORTING
SALESDOCUMENT = LV_SALESORDER
TABLES
RETURN = GT_RETURN
ORDER_ITEMS_IN = GT_SALESORDER_ITEM
ORDER_ITEMS_INX = GT_SALESORDER_ITEMX
ORDER_PARTNERS = GT_SALESORDER_PARTNER
ORDER_SCHEDULES_IN = GT_SALESORDER_SCHLINE
ORDER_SCHEDULES_INX = GT_SALESORDER_SCHLINEX
ORDER_CONDITIONS_IN = GT_SALESORDER_CONDITIONS
ORDER_CONDITIONS_INX = GT_SALESORDER_CONDITIONX
ORDER_TEXT = GT_SALESORDER_TEXT. LOOP AT GT_RETURN INTO GS_RETURN.
CLEAR IT_MSG.
MOVE-CORRESPONDING GS_RETURN TO IT_MSG.
IT_MSG-ZPOSN = IT_HEADER-ZPOSN.
IT_MSG-ORDER = LV_SALESORDER. CASE GS_RETURN-TYPE.
WHEN 'E' OR 'X' OR 'A'.
IT_MSG-LIGHT = ''."Red Light
LV_ERROR = 'X'.
WHEN 'S'.
IF GS_RETURN-ID = 'V1' AND GS_RETURN-NUMBER = ''.
IT_MSG-LIGHT = ''."Green Light
ELSE.
CONTINUE.
ENDIF.
WHEN OTHERS.
CONTINUE.
ENDCASE. COLLECT IT_MSG.
* EXIT.
ENDLOOP. IF LV_ERROR EQ 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CHECK P_COMMIT EQ 'X'. PERFORM FRM_RECORD_LINES USING IT_HEADER-ZPOSN LV_SALESORDER. * CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT = 'X'.
ENDIF. ENDFORM. " FRM_CREATE_SALESORDER

创建PO/SO的更多相关文章

  1. 利用MyEclipse自动创建PO类、hbm文件(映射文件)、DAO

    原文地址:http://blog.csdn.net/fangzhibin4712/article/details/7179414 前提条件:表sjzdfl  表sjzdxx (使用数据库MySQL) ...

  2. SAP MM ME21N 创建PO时报错 - Net price in CNY becomes too large –

    SAP MM ME21N 创建PO时报错 - Net price in CNY becomes too large – 笔者所在的项目上,由于客户尚未正式大规模量产,在现阶段,所有的物料基本都是走费用 ...

  3. 「SAP技术」已启用质检物料创建PO时候'STOCK TYPE'没有默认为X?

    「SAP技术」 SAP MM 已启用质检物料创建PO时候'STOCK TYPE'没有默认为X? Part I:SAP 标准行为 1, 物料11002335, QM视图里 01 inspection t ...

  4. 使用bapi创建PO遇到问题(BAPI_PO_CREATE1

    今天用 BAPI_PO_CREATE1创建po. 注意事项: vendor 供应商号:长度必须和系统一致,10位.如 2000025要写成 0002000025传递给参数. POITEM 中的 PO_ ...

  5. BAPI创建PO,禁止净价信息更新

    大家都知道创建PO时,我们如果勾选了"信息更新",则该PO保存后相应的信息记录会把这个PO更新为其最后的凭证,那么这张PO的净价会作为下次创建新PO时净价的默认值. 这样我们设置的 ...

  6. BAPI_PO_CREATE1 创建PO ch_memory_complete = ‘x',导致hold on 解决方案,

    1.尝试注释标准逻辑,看会不会有什么问题, ZME_BAPI_PO_CUST IF_EX_ME_BAPI_PO_CREATE_02~INBOUND 里面有个控制很费解 我给注释了 2.改用 BAPI_ ...

  7. 创建PO

    FORM FRM_CREATE_PO USING P_POSNR CHANGING P_EBELN. DATA: LV_VENDOR TYPE LIFNR, LV_ITEM TYPE EBELP, L ...

  8. 创建第一个Hiberntae工程

    一.前言 很久之前已经对Hibernate有所了解,在项目中进行过简单的应用,基本了解hibernate的简单应用,没有深入的了解,来Shine公司快三个月了,公司的ORM框架就是用Hiberante ...

  9. BOM/ROUTING/PO/WIP等模块常用查询

    常用查询scripts /*bom*/ select p_item.segment1,c_item.segment1,bic.COMPONENT_QUANTITY,bic.COMPONENT_YIEL ...

随机推荐

  1. 8.Methods(一)

    1.Instance Constructors and Classes (Reference Types) Constructors methods : 1.allow an instance of ...

  2. [SAP ABAP开发技术总结]CLEAR、REFRESH、FREE内表清理区别

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  3. FZU 2212 Super Mobile Charger(超级充电宝)

    [Description] [题目描述] While HIT ACM Group finished their contest in Shanghai and is heading back Harb ...

  4. python中的is、==和cmp()比较字符串

    python 中的is.==和cmp(),比较字符串 经常写 shell 脚本知道,字符串判断可以用 =,!= 数字的判断是 -eq,-ne 等,但是 Python 确不是这样子地.所以作为慢慢要转换 ...

  5. list map vector set 常用函数列表

    #include <stdio.h> #include <iostream>//cin,cout #include <sstream>//ss transfer. ...

  6. 设计js通用库

    设计js通用库的四个步骤: 1.需求分析:分析库需要完成的所有功能. 2.编程接口:根据需求设计需要用到的接口及参数.返回值. 3.调用方法:支持链式调用,我们期望以动词方式描述接口. (ps:设计链 ...

  7. ubuntu 14.0.04 通过自启动脚本实现主机和虚拟机的文件夹共享

    首先要先设置主机ip为固定ip: 1.vi /etc/rc.local,进入vi界面,在尾部增加一行代码: mount -t cifs -o username=share,password=12345 ...

  8. maven之详解继承与聚合

    说到聚合与继承我们都很熟悉,maven同样也具备这样的设计原则,下面我们来看一下Maven的pom如何进行聚合与继承的配置实现. 一.为什么要聚合? 随着技术的飞速发展和各类用户对软件的要求越来越高, ...

  9. Java用webSocket实现tomcat的日志实时输出到web页面

    原文:http://blog.csdn.net/smile326/article/details/52218264 1.场景需求 后台攻城狮和前端攻城狮一起开发时,经常受到前端攻城狮的骚扰,动不动就来 ...

  10. 在应用中更新App版本

    在应用中, 为了提高用户体验, 会提供更新版本的功能. 那么如何实现呢? 我写了一个简单的Demo, 说明一下, 需要注意几个细节. 使用了Retrofit和Rx处理网络请求. Github下载地址 ...