本人诚心接ABAP远程开发任务,价格公道,有需要的联系我,欢迎个人,甲方爸爸,乙方私信联系。
DATA: GS_HEADER TYPE BAPIMATHEAD,
GS_CLIENT TYPE BAPI_MARA,
GS_CLIENTX TYPE BAPI_MARAX,
GS_PLANT TYPE BAPI_MARC,
GS_PLANTX TYPE BAPI_MARCX,
GS_STORAGE TYPE BAPI_MARD,
GS_STORAGEX TYPE BAPI_MARDX,
GS_VALUATION TYPE BAPI_MBEW,
GS_VALUATIONX TYPE BAPI_MBEWX,
GS_SALE TYPE BAPI_MVKE,
GS_SALEX TYPE BAPI_MVKEX,
GT_MATERIAL_DESC TYPE TABLE OF BAPI_MAKT,
GS_MATERIAL_DESC TYPE BAPI_MAKT,
GT_UNIT TYPE TABLE OF BAPI_MARM,
GS_UNIT TYPE BAPI_MARM,
GT_UNITX TYPE TABLE OF BAPI_MARMX,
GS_UNITX TYPE BAPI_MARMX,
GS_BAPI_TE_MARA TYPE BAPI_TE_MARA,
GS_BAPI_TE_MARAX TYPE BAPI_TE_MARAX,
GT_REX TYPE TABLE OF BAPIPAREX,
GS_REX TYPE BAPIPAREX,
GT_REXX TYPE TABLE OF BAPIPAREXX,
GS_REXX TYPE BAPIPAREXX,
GV_VALUE_CHAR TYPE C LENGTH 240,
GS_BAPIRETURN TYPE BAPIRET2.
DATA: GS_TAXCLASS TYPE BAPI_MLAN.
DATA: GT_TAXCLASS TYPE STANDARD TABLE OF BAPI_MLAN.
DATA: GT_RETURN_MATERIAL TYPE TABLE OF BAPI_MATRETURN2,
GS_RETURN_MATERIAL TYPE BAPI_MATRETURN2.
DATA: GT_CLASS_RETURN TYPE STANDARD TABLE OF BAPIRET2,
GS_CLASS_RETURN TYPE BAPIRET2.
DATA: GV_MESSAGE TYPE STRING .
DATA: GT_WERKS_LGORT TYPE STANDARD TABLE OF ZMMT_WERKS.
DATA: GT_SALES TYPE STANDARD TABLE OF ZMMT_WERKS.
DATA: GS_WERKS_LGORT TYPE ZMMT_WERKS.
DATA: GS_SALES TYPE ZMMT_WERKS.
CLEAR: GS_HEADER,
GS_CLIENT,
GS_CLIENTX,
GS_PLANT,
GS_PLANTX,
GS_STORAGE,
GS_STORAGEX,
GS_VALUATION,
GS_VALUATIONX,
GS_SALE,
GS_SALEX,
GT_MATERIAL_DESC,
GS_MATERIAL_DESC,
GT_UNIT,
GS_UNIT,
GT_UNITX,
GS_UNITX,
GS_BAPIRETURN,
GS_BAPI_TE_MARA,
GS_BAPI_TE_MARAX,
GT_REX,
GS_REX,
GT_REXX,
GS_REXX,
GV_VALUE_CHAR,
GS_RETURN,
GT_RETURN_MATERIAL,
GS_RETURN_MATERIAL,
GV_MESSAGE,
GS_TAXCLASS,
GT_TAXCLASS.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_MAIN-MATNR
IMPORTING
OUTPUT = GV_MATNR.
"SET_HEADER
GS_HEADER-MATERIAL = GV_MATNR.
GS_HEADER-MATL_TYPE = GS_MAIN-MTART. "物料类型
GS_HEADER-BASIC_VIEW = 'X'.
GS_HEADER-IND_SECTOR = 'C'. "行业领域
"SET_CLIENT_DATA
GS_CLIENT-DIVISION = '10'. "部门
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' "基本计量单位
EXPORTING
INPUT = GS_MAIN-MEINS
* LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_CLIENT-BASE_UOM
* EXCEPTIONS
* UNIT_NOT_FOUND = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
GS_CLIENT-MATL_GROUP = GS_MAIN-MATKL. "物料组
GS_CLIENT-DSN_OFFICE = GS_MAIN-LABOR. "实验室/设计室
GS_CLIENT-EXTMATLGRP = GS_MAIN-EXTWG. "外部物料组
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' "重量单位
EXPORTING
INPUT = GS_MAIN-GEWEI
* LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_CLIENT-UNIT_OF_WT
* EXCEPTIONS
* UNIT_NOT_FOUND = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
GS_CLIENT-NET_WEIGHT = GS_MAIN-NTGEW. "净重
GS_CLIENT-SIZE_DIM = GS_MAIN-GROES. "大小/量纲
"GS_CLIENT-MFR_NO = GS_MAIN-LIFNR. "制造商编号
GS_CLIENT-TRANS_GRP = '0001'. "运输组
GS_CLIENT-BATCH_MGMT = 'X'. "启用批次管理
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = GS_CLIENT-MFR_NO
IMPORTING
OUTPUT = GS_CLIENT-MFR_NO.
GS_CLIENT-TRANS_GRP = '0001'. "运输组
GS_CLIENT-PERIOD_IND_EXPIRATION_DATE = ''. "货架寿命到期日的期间标识
GS_CLIENT-BATCH_MGMT = 'X'. "批次管理需求的标识
GS_CLIENTX-DIVISION = 'X'.
GS_CLIENTX-BASE_UOM = 'X'.
GS_CLIENTX-MATL_GROUP = 'X'.
GS_CLIENTX-DSN_OFFICE = 'X'.
GS_CLIENTX-EXTMATLGRP = 'X'.
GS_CLIENTX-UNIT_OF_WT = 'X'.
GS_CLIENTX-NET_WEIGHT = 'X'.
GS_CLIENTX-SIZE_DIM = 'X'.
GS_CLIENTX-MFR_NO = 'X'.
GS_CLIENTX-TRANS_GRP = 'X'.
GS_CLIENTX-PERIOD_IND_EXPIRATION_DATE = 'X'.
GS_CLIENTX-BATCH_MGMT = 'X'.
"SET_MATERIAL_DESC
GS_MATERIAL_DESC-LANGU = '1'.
GS_MATERIAL_DESC-LANGU_ISO = 'ZH'.
GS_MATERIAL_DESC-MATL_DESC = GS_MAIN-MAKTX.
APPEND GS_MATERIAL_DESC TO GT_MATERIAL_DESC.
GS_MATERIAL_DESC-LANGU = 'E'.
GS_MATERIAL_DESC-LANGU_ISO = 'EN'.
GS_MATERIAL_DESC-MATL_DESC = GS_MAIN-MAKTXE.
APPEND GS_MATERIAL_DESC TO GT_MATERIAL_DESC.
"SET_UNIT
*第一行是1:1转换 即自己和自己转换
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' ""帐面库存单位的可选计量单位
EXPORTING
INPUT = GS_MAIN-MEINS
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_UNIT-ALT_UNIT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
GS_UNIT-GROSS_WT = GS_MAIN-BRGEW. "毛重
GS_UNIT-VOLUME = GS_MAIN-VOLUM. "业务量
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' ""体积单位
EXPORTING
INPUT = GS_MAIN-VOLEH
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_UNIT-VOLUMEUNIT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' "重量单位
EXPORTING
INPUT = GS_MAIN-GEWEI
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_UNIT-UNIT_OF_WT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
GS_UNIT-DENOMINATR = '1'. "转换为基本计量单位的分母
GS_UNIT-NUMERATOR = '1'. "基本计量单位转换分子
APPEND GS_UNIT TO GT_UNIT.
GS_UNITX-ALT_UNIT = GS_UNIT-ALT_UNIT.
GS_UNITX-GROSS_WT = 'X'.
GS_UNITX-VOLUME = 'X'.
GS_UNITX-DENOMINATR = 'X'.
GS_UNITX-NUMERATOR = 'X'.
GS_UNITX-UNIT_OF_WT = 'X'.
GS_UNITX-VOLUMEUNIT = 'X'.
APPEND GS_UNITX TO GT_UNITX.
CLEAR: GS_UNIT, GS_UNITX.
*第二行是EA 和 基本计量单位转换
IF GS_MAIN-LRMEI IS NOT INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' ""帐面库存单位的可选计量单位
EXPORTING
INPUT = GS_MAIN-LRMEI
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_UNIT-ALT_UNIT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
GS_UNIT-DENOMINATR = GS_MAIN-UMREN. "转换为基本计量单位的分母
GS_UNIT-NUMERATOR = GS_MAIN-UMREZ. "基本计量单位转换分子
APPEND GS_UNIT TO GT_UNIT.
GS_UNITX-ALT_UNIT = GS_UNIT-ALT_UNIT.
GS_UNITX-DENOMINATR = 'X'.
GS_UNITX-NUMERATOR = 'X'.
APPEND GS_UNITX TO GT_UNITX.
CLEAR: GS_UNIT, GS_UNITX.
ENDIF.
IF GS_MAIN-MSEHT1 IS NOT INITIAL .
*第三行是 包装和基本计量单位转换
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' ""帐面库存单位的可选计量单位
EXPORTING
INPUT = GS_MAIN-MSEHT1
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_UNIT-ALT_UNIT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
GS_UNIT-ALT_UNIT = GS_MAIN-MSEHT1.
GS_UNIT-DENOMINATR = GS_MAIN-UMREN1.
GS_UNIT-NUMERATOR = GS_MAIN-UMREZ1.
APPEND GS_UNIT TO GT_UNIT.
GS_UNITX-ALT_UNIT = GS_UNIT-ALT_UNIT.
GS_UNITX-DENOMINATR = 'X'.
GS_UNITX-NUMERATOR = 'X'.
APPEND GS_UNITX TO GT_UNITX.
ENDIF.
"SET_CUSTOMIZED_DATA
GS_BAPI_TE_MARA-MATERIAL = GV_MATNR.
GS_BAPI_TE_MARA-KPPM1 = GS_MAIN-KPPM1. "开票品名
GS_BAPI_TE_MARA-KPGG1 = GS_MAIN-KPGG1. "开票规格
GS_BAPI_TE_MARA-TCGNO = GS_MAIN-TCGNO. "税收分类编码
GS_BAPI_TE_MARA-GDSNO = GS_MAIN-GDSNO. "商品编码
GS_BAPI_TE_MARA-GSSZH = GS_MAIN-GSSZH. "关税税则号
GS_BAPI_TE_MARA-GSSL = GS_MAIN-GSSL. "关税税率
GS_BAPI_TE_MARA-XFSSL = GS_MAIN-XFSSL. "消费税率
GS_BAPI_TE_MARA-JJFS = GS_MAIN-JJFS. "消费税计价方式
GS_BAPI_TE_MARA-BGZWM = GS_MAIN-BGZWM. "报关中文名
GS_BAPI_TE_MARA-LIFNR = GS_MAIN-LIFNR. "供应商
GS_BAPI_TE_MARA-BZLEV = GS_MAIN-BZLEV. "包装级别
GS_REX-STRUCTURE = 'BAPI_TE_MARA'.
GS_REX-VALUEPART1 = GS_BAPI_TE_MARA.
APPEND GS_REX TO GT_REX.
GS_BAPI_TE_MARAX-MATERIAL = GV_MATNR.
GS_BAPI_TE_MARAX-KPPM1 = 'X'.
GS_BAPI_TE_MARAX-KPGG1 = 'X'.
GS_BAPI_TE_MARAX-TCGNO = 'X'.
GS_BAPI_TE_MARAX-GDSNO = 'X'.
GS_BAPI_TE_MARAX-GSSZH = 'X'.
GS_BAPI_TE_MARAX-GSSL = 'X'.
GS_BAPI_TE_MARAX-XFSSL = 'X'.
GS_BAPI_TE_MARAX-JJFS = 'X'.
GS_BAPI_TE_MARAX-BGZWM = 'X'.
GS_BAPI_TE_MARAX-LIFNR = 'X'.
GS_BAPI_TE_MARAX-BZLEV = 'X'.
GS_REXX-STRUCTURE = 'BAPI_TE_MARAX'.
GS_REXX-VALUEPART1 = GS_BAPI_TE_MARAX.
APPEND GS_REXX TO GT_REXX.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = GS_HEADER
CLIENTDATA = GS_CLIENT
CLIENTDATAX = GS_CLIENTX
* PLANTDATA = GS_PLANT
* PLANTDATAX = GS_PLANTX
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA = GS_STORAGE
* STORAGELOCATIONDATAX = GS_STORAGEX
* VALUATIONDATA = GS_VALUATION
* VALUATIONDATAX = GS_VALUATIONX
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
* SALESDATA = GS_SALE
* SALESDATAX = GS_SALEX
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
* FLAG_ONLINE = ' '
* FLAG_CAD_CALL = ' '
* NO_DEQUEUE = ' '
* NO_ROLLBACK_WORK = ' '
IMPORTING
RETURN = GS_BAPIRETURN
TABLES
MATERIALDESCRIPTION = GT_MATERIAL_DESC
UNITSOFMEASURE = GT_UNIT
UNITSOFMEASUREX = GT_UNITX
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS = GT_TAXCLASS
* RETURNMESSAGES =
* PRTDATA =
* PRTDATAX =
RETURNMESSAGES = GT_RETURN_MATERIAL
EXTENSIONIN = GT_REX
EXTENSIONINX = GT_REXX.
LOOP AT GT_RETURN_MATERIAL INTO GS_RETURN_MATERIAL WHERE TYPE CA 'EAX'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = GS_RETURN_MATERIAL-ID
MSGNR = GS_RETURN_MATERIAL-NUMBER
MSGV1 = GS_RETURN_MATERIAL-MESSAGE_V1
MSGV2 = GS_RETURN_MATERIAL-MESSAGE_V2
MSGV3 = GS_RETURN_MATERIAL-MESSAGE_V3
MSGV4 = GS_RETURN_MATERIAL-MESSAGE_V4
IMPORTING
MESSAGE_TEXT_OUTPUT = GV_MESSAGE.
CONCATENATE LV_ALL_MESSAGE GV_MESSAGE INTO LV_ALL_MESSAGE .
ENDLOOP.
CLEAR: GS_HEADER,
GS_CLIENT,
GS_CLIENTX,
GS_PLANT,
GS_PLANTX,
GS_STORAGE,
GS_STORAGEX,
GS_VALUATION,
GS_VALUATIONX,
GS_SALE,
GS_SALEX,
GT_MATERIAL_DESC,
GS_MATERIAL_DESC,
GT_UNIT,
GS_UNIT,
GT_UNITX,
GS_UNITX,
GS_BAPIRETURN,
GS_BAPI_TE_MARA,
GS_BAPI_TE_MARAX,
GT_REX,
GS_REX,
GT_REXX,
GS_REXX,
GV_VALUE_CHAR,
GS_RETURN,
GT_RETURN_MATERIAL,
GS_RETURN_MATERIAL,
GV_MESSAGE,
GS_TAXCLASS,
GT_TAXCLASS.
GS_HEADER-MATERIAL = GV_MATNR.
GS_HEADER-MATL_TYPE = IS_MAIN-MTART. "物料类型
GS_HEADER-SALES_VIEW = 'X'.
GS_HEADER-STORAGE_VIEW = 'X'.
GS_HEADER-MRP_VIEW = 'X'.
"当MARA-MTART=Z002或者Z003时,增加工作计划视图
IF GS_MAIN-MTART = 'Z002' OR GS_MAIN-MTART = 'Z003'.
GS_HEADER-WORK_SCHED_VIEW = 'X'.
ENDIF.
GS_HEADER-PURCHASE_VIEW = 'X'.
GS_HEADER-ACCOUNT_VIEW = 'X'.
GS_HEADER-COST_VIEW = 'X'.
"SET_TAXCLASS_DATA
GS_TAXCLASS-DEPCOUNTRY = 'CN'.
GS_TAXCLASS-DEPCOUNTRY_ISO = 'CN'.
GS_TAXCLASS-TAX_TYPE_1 = 'MWST'.
GS_TAXCLASS-TAXCLASS_1 = GS_MAIN-MWSKZ.
APPEND GS_TAXCLASS TO GT_TAXCLASS.
"SET_CLIENT_DATA
GS_CLIENT-DIVISION = '10'. "部门
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' "基本计量单位
EXPORTING
INPUT = GS_MAIN-MEINS
* LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_CLIENT-BASE_UOM
* EXCEPTIONS
* UNIT_NOT_FOUND = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
GS_CLIENT-MATL_GROUP = GS_MAIN-MATKL. "物料组
GS_CLIENT-DSN_OFFICE = GS_MAIN-LABOR. "实验室/设计室
GS_CLIENT-EXTMATLGRP = GS_MAIN-EXTWG. "外部物料组
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' "重量单位
EXPORTING
INPUT = GS_MAIN-GEWEI
* LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = GS_CLIENT-UNIT_OF_WT
* EXCEPTIONS
* UNIT_NOT_FOUND = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
GS_CLIENT-NET_WEIGHT = GS_MAIN-NTGEW. "净重
GS_CLIENT-SIZE_DIM = GS_MAIN-GROES. "大小/量纲
"GS_CLIENT-MFR_NO = GS_MAIN-LIFNR. "制造商编号
GS_CLIENT-TRANS_GRP = '0001'. "运输组
GS_CLIENT-BATCH_MGMT = 'X'. "启用批次管理
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = GS_CLIENT-MFR_NO
IMPORTING
OUTPUT = GS_CLIENT-MFR_NO.
GS_CLIENT-TRANS_GRP = '0001'. "运输组
GS_CLIENT-PERIOD_IND_EXPIRATION_DATE = ''. "货架寿命到期日的期间标识
GS_CLIENT-BATCH_MGMT = 'X'. "批次管理需求的标识
GS_CLIENTX-DIVISION = 'X'.
GS_CLIENTX-BASE_UOM = 'X'.
GS_CLIENTX-MATL_GROUP = 'X'.
GS_CLIENTX-DSN_OFFICE = 'X'.
GS_CLIENTX-EXTMATLGRP = 'X'.
GS_CLIENTX-UNIT_OF_WT = 'X'.
GS_CLIENTX-NET_WEIGHT = 'X'.
GS_CLIENTX-SIZE_DIM = 'X'.
GS_CLIENTX-MFR_NO = 'X'.
GS_CLIENTX-TRANS_GRP = 'X'.
GS_CLIENTX-PERIOD_IND_EXPIRATION_DATE = 'X'.
GS_CLIENTX-BATCH_MGMT = 'X'.
"SET_PLANT_DATA
GS_PLANT-PLANT = IV_WERKS.
IF GS_MAIN-PRCTR IS NOT INITIAL . "利润中心
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GS_MAIN-PRCTR
IMPORTING
OUTPUT = GS_PLANT-PROFIT_CTR.
ENDIF.
GS_PLANT-SAFETY_STK = GS_MAIN-EISBE. "安全库存
GS_PLANT-INHSEPRODT = GS_MAIN-DZEIT. "厂内生产时间
GS_PLANT-PLND_DELRY = GS_MAIN-PLIFZ. "计划的天数内交货
GS_PLANT-GR_PR_TIME = GS_MAIN-WEBAZ. "以天计的收货处理时间
GS_PLANT-AVAILCHECK = '02'. "可用性检查的检查组
"GS_PLANT-MATFRGTGRP = '0001'. "运输组
GS_PLANT-LOADINGGRP = '0001'. "装载组
"采购类型 原料选F 半成品/成品选X
IF GS_MAIN-MTART = 'Z001'.
GS_PLANT-PROC_TYPE = 'F'. "采购类型
ELSE.
GS_PLANT-PROC_TYPE = 'X'. "采购类型
ENDIF.
GS_PLANT-MRP_TYPE = 'PD'. "物料需求计划类型
GS_PLANT-LOTSIZEKEY = 'EX'. "批量 (物料计划)
GS_PLANT-PERIOD_IND = 'M'. "期间标识
GS_PLANT-CONSUMMODE = '2'. "消耗模式
GS_PLANT-FWD_CONS = '999'. "消耗时期-向前
GS_PLANT-BWD_CONS = '999'. "消耗期间:逆向
GS_PLANT-LOT_SIZE = '1'. "批量产品成本核算
GS_PLANT-PLAN_STRGP = '40'. "计划策略组
GS_PLANT-MRP_CTRLER = IV_DISPO. "MRP 控制者(物料计划人)
GS_PLANT-SM_KEY = '000'. "浮动的计划边际码
GS_PLANTX-PLANT = IV_WERKS.
GS_PLANTX-PROFIT_CTR = 'X'.
GS_PLANTX-SAFETY_STK = 'X'.
GS_PLANTX-INHSEPRODT = 'X'.
GS_PLANTX-PLND_DELRY = 'X'.
GS_PLANTX-GR_PR_TIME = 'X'.
GS_PLANTX-AVAILCHECK = 'X'.
"GS_PLANTX-MATFRGTGRP = 'X'.
GS_PLANTX-LOADINGGRP = 'X'.
GS_PLANTX-PROC_TYPE = 'X'.
GS_PLANTX-MRP_TYPE = 'X'.
GS_PLANTX-LOTSIZEKEY = 'X'.
GS_PLANTX-PERIOD_IND = 'X'.
GS_PLANTX-CONSUMMODE = 'X'.
GS_PLANTX-FWD_CONS = 'X'.
GS_PLANTX-BWD_CONS = 'X'.
GS_PLANTX-LOT_SIZE = 'X'.
GS_PLANTX-PLAN_STRGP = 'X'.
GS_PLANTX-MRP_CTRLER = 'X'.
GS_PLANTX-SM_KEY = 'X'.
"SET_STORAGE_DATA
DATA: LV_WAERS TYPE WAERS.
DATA: LV_BUKRS TYPE BUKRS.
SELECT SINGLE T001~WAERS INTO LV_WAERS FROM T001W
INNER JOIN T001K ON T001W~BWKEY = T001K~BWKEY
INNER JOIN T001 ON T001K~BUKRS = T001~BUKRS
WHERE T001W~WERKS = IV_WERKS.
IF LV_WAERS NE 'CNY' .
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_AMOUNT = GS_MAIN-VERPR
FOREIGN_CURRENCY = 'CNY'
LOCAL_CURRENCY = LV_WAERS
TYPE_OF_RATE = 'M'
READ_TCURR = 'X'
IMPORTING
LOCAL_AMOUNT = GS_MAIN-VERPR
EXCEPTIONS
NO_RATE_FOUND = 1
OVERFLOW = 2
NO_FACTORS_FOUND = 3
NO_SPREAD_FOUND = 4
DERIVED_2_TIMES = 5
OTHERS = 6.
ENDIF.
GS_VALUATION-VAL_AREA = IV_WERKS.
GS_VALUATION-PRICE_UNIT = '1'. "价格单位
IF GS_MAIN-MTART = 'Z001'.
GS_VALUATION-MOVING_PR = GS_MAIN-VERPR. "移动平均价格/周期单价
GS_VALUATION-VAL_CLASS = '3000'. "评估类
GS_VALUATION-PRICE_CTRL = 'V'. "价格控制指示符
IF IV_WERKS = '5001'.
GS_VALUATION-ML_SETTLE = '2'. "价格确定
GS_VALUATION-ML_ACTIVE = 'X'. "物料帐簿在物料层被激活 即ML作业
GS_VALUATIONX-ML_SETTLE = 'X'.
GS_VALUATIONX-ML_ACTIVE = 'X'.
ENDIF.
IF GS_MAIN-VERPR IS NOT INITIAL .
GS_VALUATIONX-MOVING_PR = 'X'.
ENDIF.
ENDIF.
*如果MTART=Z002,评估类BKLAS取7900,价格控制VPRSV取值S,标准价格STPRS从OA传入,价格确定MLAST取3,ML作业MLMAA打勾;
*如果MTART=Z003,评估类BKLAS取7920,价格控制VPRSV取值S,标准价格STPRS从OA传入,价格确定MLAST取3,ML作业MLMAA打勾;
IF GS_MAIN-MTART = 'Z002' OR GS_MAIN-MTART = 'Z003'.
IF GS_MAIN-MTART = 'Z002'.
GS_VALUATION-VAL_CLASS = '7900'. "评估类
ELSE.
GS_VALUATION-VAL_CLASS = '7920'. "评估类
ENDIF.
GS_VALUATION-STD_PRICE = GS_MAIN-VERPR. "标准价格
GS_VALUATION-PRICE_CTRL = 'S'. "价格控制指示符
GS_VALUATION-ML_SETTLE = '3'. "价格确定
GS_VALUATION-ML_ACTIVE = 'X'. "物料帐簿在物料层被激活 即ML作业
GS_VALUATIONX-ML_SETTLE = 'X'.
GS_VALUATIONX-ML_ACTIVE = 'X'.
IF GS_MAIN-VERPR IS NOT INITIAL .
GS_VALUATIONX-STD_PRICE = 'X'.
ENDIF.
ENDIF.
" Z001为原材料 Z002为半成品,Z003为成品 都需要进行成本核算
GS_VALUATION-QTY_STRUCT = 'X'. "物料根据数量结构进行成本核算
GS_VALUATIONX-QTY_STRUCT = 'X'.
"物料来源 不区分物料类型了,不管是原料还是半成品/成品,全勾选吧
GS_VALUATION-ORIG_MAT = 'X'. "物料来源
GS_VALUATIONX-ORIG_MAT = 'X'. "物料来源
GS_VALUATIONX-VAL_AREA = IV_WERKS.
GS_VALUATIONX-VAL_CLASS = 'X'.
GS_VALUATIONX-PRICE_CTRL = 'X'.
GS_VALUATIONX-PRICE_UNIT = 'X'.
"SET_SALE_DATA
GS_SALE-SALES_ORG = IV_VKORG. "销售机构
GS_SALE-DISTR_CHAN = IV_VTWEG. "分销渠道
GS_SALE-DELYG_PLNT = IV_WEKRS. "交货工厂
GS_SALE-ACCT_ASSGT = '01'. "科目设置组
GS_SALE-ITEM_CAT = 'NORM'. "项目类别组
GS_SALE-CASH_DISC = 'X'. "现金折扣标志
GS_SALEX-SALES_ORG = IV_VKORG.
GS_SALEX-DISTR_CHAN = IV_VTWEG.
GS_SALEX-DELYG_PLNT = 'X'.
GS_SALEX-ACCT_ASSGT = 'X'.
GS_SALEX-ITEM_CAT = 'X'.
GS_SALEX-CASH_DISC = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = GS_HEADER
CLIENTDATA = GS_CLIENT
CLIENTDATAX = GS_CLIENTX
PLANTDATA = GS_PLANT
PLANTDATAX = GS_PLANTX
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
STORAGELOCATIONDATA = GS_STORAGE
STORAGELOCATIONDATAX = GS_STORAGEX
VALUATIONDATA = GS_VALUATION
VALUATIONDATAX = GS_VALUATIONX
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
SALESDATA = GS_SALE
SALESDATAX = GS_SALEX
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
* FLAG_ONLINE = ' '
* FLAG_CAD_CALL = ' '
* NO_DEQUEUE = ' '
* NO_ROLLBACK_WORK = ' '
IMPORTING
RETURN = GS_BAPIRETURN
TABLES
* MATERIALDESCRIPTION = GT_MATERIAL_DESC
* UNITSOFMEASURE = GT_UNIT
* UNITSOFMEASUREX = GT_UNITX
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
TAXCLASSIFICATIONS = GT_TAXCLASS
* RETURNMESSAGES =
* PRTDATA =
* PRTDATAX =
RETURNMESSAGES = GT_RETURN_MATERIAL
EXTENSIONIN = GT_REX
EXTENSIONINX = GT_REXX.
LOOP AT GT_RETURN_MATERIAL INTO GS_RETURN_MATERIAL WHERE TYPE CA 'EAX'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = GS_RETURN_MATERIAL-ID
MSGNR = GS_RETURN_MATERIAL-NUMBER
MSGV1 = GS_RETURN_MATERIAL-MESSAGE_V1
MSGV2 = GS_RETURN_MATERIAL-MESSAGE_V2
MSGV3 = GS_RETURN_MATERIAL-MESSAGE_V3
MSGV4 = GS_RETURN_MATERIAL-MESSAGE_V4
IMPORTING
MESSAGE_TEXT_OUTPUT = GV_MESSAGE.
CONCATENATE EV_MESSAGE GV_MESSAGE INTO EV_MESSAGE .
ENDLOOP.
IF EV_MESSAGE IS INITIAL .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
首先判断物料是否扩充了分类视图,如果有就不扩充,无则扩充
CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'
EXPORTING
OBJECTKEY_IMP = LV_OBJECTKEYNEW
OBJECTTABLE_IMP = 'MARA'
CLASSTYPE_IMP = '023'
* READ_VALUATIONS =
* KEYDATE = SY-DATUM
* LANGUAGE = SY-LANGU
TABLES
ALLOCLIST = LT_ALLOC_LIST
* ALLOCVALUESCHAR =
* ALLOCVALUESCURR =
* ALLOCVALUESNUM =
RETURN = LT_CLASS.
READ TABLE LT_CLASS INTO LS_CLASS WITH KEY TYPE = 'S'.
IF SY-SUBRC = 0.
ELSE.
CALL FUNCTION 'BAPI_OBJCL_CREATE'
EXPORTING
OBJECTKEYNEW = LV_OBJECTKEYNEW
OBJECTTABLENEW = 'MARA'
CLASSNUMNEW = 'ZBATCH'
CLASSTYPENEW = '023'
* STATUS = '1'
* STANDARDCLASS =
* CHANGENUMBER =
* KEYDATE = SY-DATUM
* NO_DEFAULT_VALUES = ' '
* OBJECTKEYNEW_LONG =
* IMPORTING
* CLASSIF_STATUS =
TABLES
* ALLOCVALUESNUM =
* ALLOCVALUESCHAR =
* ALLOCVALUESCURR =
RETURN = GT_CLASS_RETURN.
LOOP AT GT_CLASS_RETURN INTO GS_CLASS_RETURN WHERE TYPE CA 'EAX'.
CONCATENATE EV_MESSAGE GS_CLASS_RETURN-MESSAGE INTO EV_MESSAGE.
ENDLOOP.
IF EV_MESSAGE IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
ENDIF.
ENDIF.