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
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/18704.html