ME31K 创建框架协议
1业务说明
在实际业务需求中,需要和供应商签订协议。
此文档使用BAPI:BAPI_CONTRACT_CREATE创建协议
2前台实现
事务代码:ME31K
输入抬头信息
行项目
行项目详细内容
保存即可
3代码实现
3.1调用BAPI
抬头
行项目
导入BAPI
3.2问题解决
3.2.1 SUBOBJECT_NOT_FOUND
在创建时报错,
错误位置在此处,子对象没找到
GOOGLE到相关解决方案
事务代码:SLG0
新增对象COND,对象文本Condition technique (ERP)
选中对象,双击子对象
子对象名称MAINTENANCE,文本Maintenance of Condition records
再次运行,发现已经不报错了,问题解决
3.2.2 保存增强点BADI_IM_PRF_SAVE_OA
3.2.3 长文本增强
当长文本做修改后,需要传给另外一个程序中使用,找了四代增强点,传输长文本。
3.3源代码
"-----------------------------@斌将军----------------------------- DATA:GS_HEADER TYPE BAPIMEOUTHEADER, GS_HEADERX TYPE BAPIMEOUTHEADERX, GV_NUMBER TYPE BAPIMEOUTHEADER-NUMBER, GS_EXP_HEADER TYPE BAPIMEOUTHEADER, GT_ITEM TYPE TABLE OF BAPIMEOUTITEM, GS_ITEM TYPE BAPIMEOUTITEM, GT_ITEMX TYPE TABLE OF BAPIMEOUTITEMX, GS_ITEMX TYPE BAPIMEOUTITEMX, GT_RETURN TYPE TABLE OF BAPIRET2, GS_RETURN TYPE BAPIRET2. DATA:LV_MESSAGE TYPE CHAR200, LV_CHECK TYPE CHAR1. "抬头 CLEAR:GS_HEADER. *GS_HEADER-NUMBER = GWA_OUT-EBELN. "合同号 GS_HEADER-VENDOR = '0070002292'."供应商 GS_HEADER-DOC_TYPE = 'YZXY'. "协议类型 GS_HEADER-COMP_CODE = '2000'. "公司代码 GS_HEADER-DOC_DATE = '20191129'. "协议日期 GS_HEADER-VPER_START = '20191129'. "协议起始日期 GS_HEADER-VPER_END = '20191229'. "协议截至日期 GS_HEADER-PURCH_ORG = '2000'. "采购组织 GS_HEADER-PUR_GROUP = 'CG9'. "采购组 GS_HEADER-ACUM_VALUE = '1'. "目标值 GS_HEADER-CURRENCY = 'CNY'. "货币 GS_HEADER-COLLECT_NO = 'CT'. "汇总号 GS_HEADER-LANGU = SY-LANGU. CLEAR:GS_HEADERX. *GS_HEADERX-NUMBER = ABAP_TRUE. "合同号 GS_HEADERX-VENDOR = ABAP_TRUE. "供应商 GS_HEADERX-DOC_TYPE = ABAP_TRUE. "协议类型 GS_HEADERX-COMP_CODE = ABAP_TRUE. "公司代码 GS_HEADERX-DOC_DATE = ABAP_TRUE. "协议日期 GS_HEADERX-VPER_START = ABAP_TRUE. "协议起始日期 GS_HEADERX-VPER_END = ABAP_TRUE. "协议截至日期 GS_HEADERX-PURCH_ORG = ABAP_TRUE. "采购组织 GS_HEADERX-PUR_GROUP = ABAP_TRUE. "采购组 GS_HEADERX-ACUM_VALUE = ABAP_TRUE. "目标值 GS_HEADERX-CURRENCY = ABAP_TRUE. "货币 GS_HEADERX-COLLECT_NO = ABAP_TRUE. "汇总号 GS_HEADERX-LANGU = ABAP_TRUE. "行项目 CLEAR:GS_ITEM. GS_ITEM-ITEM_NO = '10'. "行号 GS_ITEM-EMATERIAL = '000000000000231829'."物料号 GS_ITEM-SHORT_TEXT = '铝板'. "短文本 GS_ITEM-MATL_GROUP = 'CRC09'. "物料组 GS_ITEM-PLANT = '2000'. "工厂 GS_ITEM-STGE_LOC = '1006'. "库存地点 GS_ITEM-TARGET_QTY = '1'. "目标数量 GS_ITEM-PO_UNIT = 'KG'."订单单位 GS_ITEM-PO_UNIT_ISO = 'KG'."ISO代码中的定单单位 GS_ITEM-NET_PRICE = '1'. "净价 GS_ITEM-PRICE_UNIT = '1'. "价格单位 每 GS_ITEM-ORDERPR_UN = 'KG'. "订单价格单位(采购) GS_ITEM-ORDERPR_UN_ISO = 'KG'. "订单价格单位(采购) GS_ITEM-TAX_CODE = 'JF'. "销售/购买税代码 GS_ITEM-VAL_TYPE = 'CR'. "评估类型 *GS_ITEM-ACCTASSCAT = 'U'."科目分配类别 *GS_ITEM-ITEM_CAT = 0."项目类别 APPEND GS_ITEM TO GT_ITEM. CLEAR:GS_ITEMX. GS_ITEMX-ITEM_NO = '10'. "行号 GS_ITEMX-ITEM_NOX = ABAP_TRUE. "行号 GS_ITEMX-EMATERIAL = ABAP_TRUE. "物料号 *GS_ITEMX-MATERIAL = ABAP_TRUE. "物料号 GS_ITEMX-SHORT_TEXT = ABAP_TRUE. "短文本 GS_ITEMX-MATL_GROUP = ABAP_TRUE. "物料组 GS_ITEMX-PLANT = ABAP_TRUE. "工厂 GS_ITEMX-STGE_LOC = ABAP_TRUE. "库存地点 GS_ITEMX-TARGET_QTY = ABAP_TRUE. "目标数量 GS_ITEMX-PO_UNIT = ABAP_TRUE. GS_ITEMX-PO_UNIT_ISO = ABAP_TRUE. GS_ITEMX-NET_PRICE = ABAP_TRUE. "净价 GS_ITEMX-PRICE_UNIT = ABAP_TRUE. "价格单位 GS_ITEMX-ORDERPR_UN = ABAP_TRUE. GS_ITEMX-ORDERPR_UN_ISO = ABAP_TRUE. GS_ITEMX-TAX_CODE = ABAP_TRUE. GS_ITEMX-VAL_TYPE = ABAP_TRUE. "评估类型 *GS_ITEMX-ACCTASSCAT = ABAP_TRUE. "科目分配类别 *GS_ITEMX-ITEM_CAT = ABAP_TRUE. "项目类别 APPEND GS_ITEMX TO GT_ITEMX. CALL FUNCTION 'BAPI_CONTRACT_CREATE' EXPORTING HEADER = GS_HEADER HEADERX = GS_HEADERX * VENDOR_ADDRESS = * TESTRUN = * TECHNICAL_DATA = IMPORTING PURCHASINGDOCUMENT = GV_NUMBER EXP_HEADER = GS_EXP_HEADER TABLES RETURN = GT_RETURN ITEM = GT_ITEM ITEMX = GT_ITEMX * ACCOUNT = * ACCOUNTPROFITSEGMENT = * ACCOUNTX = * DELIVERY_ADDRESS = * ITEM_COND_VALIDITY = * ITEM_COND_VALIDITYX = * ITEM_CONDITION = * ITEM_CONDITIONX = * ITEM_COND_SCALE_VALUE = * ITEM_COND_SCALE_QUAN = * ITEM_TEXT = * HEADER_TEXT = * HEAD_COND_VALIDITY = * HEAD_COND_VALIDITYX = * HEAD_CONDITION = * HEAD_CONDITIONX = * HEAD_COND_SCALE_VAL = * HEAD_COND_SCALE_QUAN = * PARTNER = * PARTNERX = * EXTENSIONIN = * EXTENSIONOUT = . LV_CHECK = 'S'. LOOP AT GT_RETURN INTO GS_RETURN WHERE TYPE = 'A' OR TYPE = 'E'. LV_MESSAGE = LV_MESSAGE && GS_RETURN-MESSAGE. LV_CHECK = 'E'. ENDLOOP. IF LV_CHECK = 'S'. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING WAIT = 'X'. WRITE:GV_NUMBER. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ENDIF. "-----------------------------@斌将军-----------------------------
定期更文,欢迎关注