创建PO

FORM FRM_CREATE_PO  USING    P_POSNR
                    CHANGING P_EBELN.

  DATA: LV_VENDOR      TYPE LIFNR,
        LV_ITEM        TYPE EBELP,
        LV_CONDTYPE(4).

  DATA:          LV_AMOUNT TYPE P DECIMALS 2,
                 LV_TAX    TYPE P DECIMALS 2 VALUE ‘1.17‘,
                 LV_RATIO  TYPE P DECIMALS 2."公司间加价系数

  CHECK P_EBELN IS INITIAL.

  CLEAR: GS_POHEADER,
         GS_POHEADERX.

  PERFORM FRM_GET_COMPANY_RATIO(ZSDS0002) USING IT_ZSDT0018-BUKRS CHANGING LV_RATIO.

  PERFORM FRM_CONVERT_VENDOR USING ‘1001‘ CHANGING LV_VENDOR.

  GS_POHEADER-VENDOR      = LV_VENDOR.
  GS_POHEADER-SUPPL_PLNT  = ‘1001‘.
  GS_POHEADER-DOC_TYPE    = ‘ZRTO‘.
  GS_POHEADER-DOC_DATE    = IT_ZSDT0018-DATUM.
  GS_POHEADER-CREAT_DATE  = SY-DATUM.
  GS_POHEADER-CREATED_BY  = SY-UNAME.
  GS_POHEADER-PURCH_ORG   = ‘8000‘.
  GS_POHEADER-PUR_GROUP   = ‘A15‘.
  GS_POHEADER-COMP_CODE   = IT_ZSDT0018-BUKRS.
  GS_POHEADER-SALES_PERS  = P_POSNR.

  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-OUR_REF    = ‘X‘.
  GS_POHEADERX-SUPPL_PLNT = ‘X‘.

  CLEAR LV_ITEM.

  REFRESH: GT_POITEM,GT_POITEMX,
           GT_POCOND,GT_POCONDX.

  REFRESH: GT_POSCHEDULE,
           GT_POSCHEDULEX.

  LOOP AT ITAB WHERE POSNR = P_POSNR.
    ADD 10 TO LV_ITEM.

    CLEAR GS_POITEM.
    GS_POITEM-PO_ITEM     = LV_ITEM.
    GS_POITEM-MATERIAL    = ITAB-MATNR."Article (商品款号)
    GS_POITEM-PLANT       = ITAB-WERKS.
    GS_POITEM-BATCH       = ITAB-CHARG.
    GS_POITEM-QUANTITY    = ITAB-MENGE.
    GS_POITEM-STGE_LOC    = ‘0001‘.
    GS_POITEM-RET_ITEM    = ‘X‘.
    GS_POITEM-VAL_TYPE    = ITAB-CHARG.
    GS_POITEM-TAX_CODE    = ‘J1‘.
    APPEND GS_POITEM TO GT_POITEM.

    CLEAR GS_POITEMX.
    GS_POITEMX-PO_ITEM    = LV_ITEM.
    GS_POITEMX-MATERIAL   = ‘X‘.
    GS_POITEMX-BATCH      = ‘X‘.
    GS_POITEMX-STGE_LOC   = ‘X‘.
    GS_POITEMX-PLANT      = ‘X‘.
    GS_POITEMX-QUANTITY   = ‘X‘.
    GS_POITEMX-STGE_LOC   = ‘X‘.
    GS_POITEMX-RET_ITEM   = ‘X‘.
    GS_POITEMX-VAL_TYPE   = ‘X‘.
    GS_POITEMX-TAX_CODE   = ‘X‘.
    APPEND GS_POITEMX TO GT_POITEMX.

    CLEAR GS_POSCHEDULE.
    GS_POSCHEDULE-PO_ITEM = LV_ITEM.
    GS_POSCHEDULE-SCHED_LINE = 1.
    GS_POSCHEDULE-DELIVERY_DATE = IT_ZSDT0018-DATUM.
    APPEND GS_POSCHEDULE TO GT_POSCHEDULE.

    CLEAR GS_POSCHEDULEX.
    GS_POSCHEDULEX-PO_ITEM = LV_ITEM.
    GS_POSCHEDULEX-SCHED_LINE = 1.
    GS_POSCHEDULEX-DELIVERY_DATE = ‘X‘.
    APPEND GS_POSCHEDULEX TO GT_POSCHEDULEX.

*   获取物料的成本价 * 加价系数 * 1.17
    PERFORM FRM_GET_MAT_VALUE(ZSDS0002) USING ITAB-MATNR ITAB-CHARG ‘1001‘ LV_RATIO CHANGING LV_AMOUNT.
**   根据是否有采购信息记录 判断净价的条件类型
*    PERFORM FRM_CHECK_CONDITION_TYPE(ZSDS0002) USING LV_VENDOR ‘8000‘  ITAB-WERKS ITAB-MATNR CHANGING LV_CONDTYPE.
    IF ITAB-CHARG+0(1) = ‘W‘ AND LV_AMOUNT IS INITIAL.
      SELECT SINGLE ZJE FROM ZMMT0121
        INTO LV_AMOUNT
        WHERE MATNR = ITAB-MATNR
          AND CHARG = ITAB-CHARG
          AND WERKS = ITAB-WERKS.

      IF SY-SUBRC EQ 0.
*    ---> 定价过程取消税率 1.17 20150426 start
*        LV_AMOUNT = LV_AMOUNT * LV_TAX.
*    <--- 定价过程取消税率 1.17 20150426 end
      ENDIF.
    ENDIF.

    CLEAR GS_POCOND.
    GS_POCOND-ITM_NUMBER = LV_ITEM.
    GS_POCOND-COND_TYPE = ‘PB00‘.
    GS_POCOND-COND_VALUE = LV_AMOUNT.
    GS_POCOND-CURRENCY = ‘CNY‘.
    GS_POCOND-CHANGE_ID = ‘U‘.
    GS_POCOND-COND_UPDAT = ‘X‘.
    APPEND GS_POCOND TO GT_POCOND.

    CLEAR GS_POCONDX.
    GS_POCONDX-ITM_NUMBER = LV_ITEM.
    GS_POCONDX-COND_TYPE = ‘X‘.
    GS_POCONDX-COND_VALUE = ‘X‘.
    GS_POCONDX-CURRENCY = ‘X‘.
    GS_POCONDX-CHANGE_ID = ‘X‘.
    GS_POCONDX-COND_UPDAT = ‘X‘.
    APPEND GS_POCONDX TO GT_POCONDX.

    CLEAR GS_POCOND.
    GS_POCOND-ITM_NUMBER = LV_ITEM.
    GS_POCOND-COND_TYPE = ‘PBXX‘.
    GS_POCOND-COND_VALUE = LV_AMOUNT.
    GS_POCOND-CURRENCY = ‘CNY‘.
    GS_POCOND-CHANGE_ID = ‘U‘.
    GS_POCOND-COND_UPDAT = ‘X‘.
    APPEND GS_POCOND TO GT_POCOND.

    CLEAR GS_POCONDX.
    GS_POCONDX-ITM_NUMBER = LV_ITEM.
    GS_POCONDX-COND_TYPE = ‘X‘.
    GS_POCONDX-COND_VALUE = ‘X‘.
    GS_POCONDX-CURRENCY = ‘X‘.
    GS_POCONDX-CHANGE_ID = ‘X‘.
    GS_POCONDX-COND_UPDAT = ‘X‘.
    APPEND GS_POCONDX TO GT_POCONDX.
  ENDLOOP.

  CALL FUNCTION ‘BAPI_PO_CREATE1‘
    EXPORTING
      POHEADER         = GS_POHEADER
      POHEADERX        = GS_POHEADERX
    IMPORTING
      EXPPURCHASEORDER = GV_EXPPURCHASEORDER
    TABLES
      RETURN           = IT_RETURN
      POITEM           = GT_POITEM
      POITEMX          = GT_POITEMX
      POCOND           = GT_POCOND
      POCONDX          = GT_POCONDX
      POSCHEDULE       = GT_POSCHEDULE
      POSCHEDULEX      = GT_POSCHEDULEX.

  LOOP AT IT_RETURN  WHERE TYPE = ‘E‘ OR TYPE = ‘A‘ OR TYPE = ‘X‘.

  ENDLOOP.

  IF SY-SUBRC EQ 0.
    CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘.

    CLEAR P_EBELN.

    APPEND_MSG_LIST ‘E‘ ‘ZSD002‘ ‘048‘ P_POSNR IT_RETURN-MESSAGE  ‘‘ ‘‘.
  ELSE.

    CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘
      EXPORTING
        WAIT = ‘X‘.

    P_EBELN = GV_EXPPURCHASEORDER.

    APPEND_MSG_LIST ‘S‘ ‘ZSD002‘ ‘047‘ P_POSNR P_EBELN  ‘‘ ‘‘.
  ENDIF.
ENDFORM.                    " FRM_CREATE_PO
FORM frm_get_mat_value  USING    p_matnr
                                 p_charg
                                 p_werks
                                 p_ratio
                        CHANGING p_value.

  DATA : lv_ratio  TYPE p DECIMALS 2,"公司间加价系数
         lv_value  TYPE p DECIMALS 2,"物料成品价
         lv_amount TYPE p DECIMALS 5,
         lv_matnr  TYPE matnr,
         lv_mtart  TYPE mtart,
         lv_tax    TYPE p DECIMALS 2 VALUE ‘1.17‘.

  SELECT SINGLE *
    FROM mbew
    WHERE matnr = p_matnr
      AND bwkey = p_werks
      AND bwtar = p_charg.

  IF mbew-vprsv EQ ‘S‘.
    lv_value = mbew-stprs / mbew-peinh.
  ELSE.
    lv_value = mbew-verpr / mbew-peinh.
  ENDIF.

  SELECT SINGLE mtart INTO lv_mtart FROM mara WHERE matnr = p_matnr.

*  IF LV_MTART EQ ‘Z006‘."辅料.
*    P_VALUE = LV_VALUE * LV_TAX.
*  ELSE.
*    P_VALUE = LV_VALUE * P_RATIO * LV_TAX.
*  ENDIF.

*    ---> 定价过程取消税率 1.17 20150426 start
  IF lv_mtart EQ ‘Z006‘."辅料.
    p_value = lv_value.
  ELSE.
    p_value = lv_value * p_ratio.
  ENDIF.
*    <--- 定价过程取消税率 1.17 20150426 end
ENDFORM.                    " FRM_GET_MAT_VALUE
时间: 2024-10-11 05:38:45

创建PO的相关文章

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

前提条件:表sjzdfl  表sjzdxx (使用数据库MySQL) 表sjzdfl (两个字段sjzdflId 和 sjzdflmc) 表sjzdfl 建表语句: [sql] view plaincopy DROP TABLE IF EXISTS `sjzdfl`; CREATE TABLE `sjzdfl` ( `sjzdflId` int(11) NOT NULL auto_increment, `sjzdflmc` varchar(255) default NULL, PRIMARY K

使用JBoss Tool反向创建PO类

使用Hibernate Tool可以根据已有的数据库结构,反向创建PO.DAO等类,方便于开发,最近正好有个工作内容,需要用这个,所以重新捡起来学习下. 现在Hibernate Tool已经被JBoss收购,起了个新名字,叫做JBoss Tool,高大上的名字. 要求jdk6或7的版本,并且要求Eclipse Luna 4.4.2版本. 在Edit Configuration中选择已有的一个工程(可以是普通的java工程,也可以是maven工程),然后可以选择Database connectio

BAPI_PO_CREATE1 创建PO ch_memory_complete = ‘x&#39;,导致hold on 解决方案,

1.尝试注释标准逻辑,看会不会有什么问题, ZME_BAPI_PO_CUST IF_EX_ME_BAPI_PO_CREATE_02~INBOUND 里面有个控制很费解 我给注释了 2.改用 BAPI_PO_CREATE, 3.用 BAPI_PO_CREATE1 后,  and status on hold.再使用 BAPI_PO_CHANGE 将状态改回来, 3. Hello Jürgen, Thanks for your reply~According to NOTE 354771:MEMOR

「SAP技术」已启用质检物料创建PO时候&#39;STOCK TYPE&#39;没有默认为X?

「SAP技术」 SAP MM 已启用质检物料创建PO时候'STOCK TYPE'没有默认为X? Part I:SAP 标准行为 1, 物料11002335, QM视图里 01 inspection type activated, PO里该物料的stock type 字段值默认为 'X Quality Inspection', 这是正常的. Part II:项目上SAP系统的不正常行为 物料号11002749, QM视图里 01 inspection type activated, 创建PO时候,

创建PO/SO

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 . PERFO

创建第一个Hiberntae工程

一.前言 很久之前已经对Hibernate有所了解,在项目中进行过简单的应用,基本了解hibernate的简单应用,没有深入的了解,来Shine公司快三个月了,公司的ORM框架就是用Hiberante,只是对Hibernate框架应用都进行了简单的封装,提升开发的效率.今天深入了看了一些Hiberbate基于原生态SQL查询,收获了不少,所以决定搭建一个Hibernate的小应用例子,进行深入的学习. 二.例子说明 这个小例子是基于商品类别.商品两张表进行搭建的,就是一个普通的java工程,项目

Oracle EBS:追踪PO全过程

1.创建PO PO_HEADERS_ALL select po_header_id from po_headers_all where segment1 =; select * from po_headers_all where po_header_id =; po_lines_all select * from po_lines_all where po_header_id =; po_line_locations_all select * from po_line_locations_all

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

常用查询scripts /*bom*/ select p_item.segment1,c_item.segment1,bic.COMPONENT_QUANTITY,bic.COMPONENT_YIELD_FACTOR from bom_bill_of_materials bbom, bom_inventory_components bic, mtl_system_items_b p_item, mtl_system_items_b c_item where bbom.BILL_SEQUENCE_

采购订单批量创建 BAPI_PO_CREATE1

*&---------------------------------------------------------------------* *& REPORT  ZMM_PO_CREATE *& *& REPORTNAME   :批量创建PO *&---------------------------------------------------------------------* *& CREATED BY   : LIUXINYUAN *&am