6.1儿童节,上海初步解封,四川发生6.1级别地震且有人员伤亡。
莫言说:起风了,不要被大风吹倒,活下去~
事务代码CL01如何创建物料分类视图的BAPI我们之前第16章有讲到过,今天我们学习TCODE CL02的BAPI用法。
用来修改对象特征数据。
有了创建的经验,修改起来也就得心应手啦。传入参数字段:
参数名称 | 关联类型 | 可选的 | 说明 |
OBJECTKEY | BAPI1003_KEY-OBJECT | 可选 | 要分类的对象码 |
OBJECTTABLE | BAPI1003_KEY-OBJECTTABLE | 必选 | 对于分类的对象的数据库表名称 |
CLASSNUM | BAPI1003_KEY-CLASSNUM | 必选 | 分类编号 |
CLASSTYPE | BAPI1003_KEY-CLASSTYPE | 必选 | 分类的类型 |
STATUS | BAPI1003_KEY-STATUS | 可选 | 分类状态 |
KEYDATE | BAPI1003_KEY-KEYDATE | 可选 | 关键日期 |
参数名称 | 关联类型 | 可选的 | 说明 |
ALLOCVALUESNUMNEW | BAPI1003_ALLOC_VALUES_NUM | 必选 | 分配 BAPI – NUM、DATE、TIME 类型的值 |
ALLOCVALUESCHARNEW | BAPI1003_ALLOC_VALUES_CHAR | 必选 | 分配 BAPI – CHAR、BOOL 类型的值 |
ALLOCVALUESCURRNEW | BAPI1003_ALLOC_VALUES_CURR | 必选 | 分配 BAPI – CURR 类型值 |
RETURN | BAPIRET2 | 必选 | 返回参数 |
ALLOCVALUESNUMNEW常用输入参数字段:
组件 | 类型 | 简短描述 |
CHARACT | ATNAM | 特征名称 |
ALLOCVALUESCHARNEW常用输入参数字段:
组件 | 类型 | 简短描述 |
CHARACT | ATNAM | 特征名称 |
VALUE_CHAR | ATWRT30 | 特征值 |
如下是demo代码,作为HOT583.com的码农,多年前也是SAP ABAP beginners ,最开始学习会有些难度,
到处去找Tutorial for Constant。如下是详细代码:
REPORT ZTEST_HOT583_COM.
*bapi相关参数的内表,工作区定义
DATA: BEGIN OF ls_excel,
matnr TYPE char40, “
klart TYPE klassenart, “
table TYPE tabelle, “
classnum TYPE klasse_d, “
zhg_ysg_zpl TYPE char30, “子品类
zhg_ysg_cz TYPE char30, “材质
zhg_ysg_ztcc TYPE char30, “主体尺寸
zhg_ysg_azfs TYPE char30, “安装方式
zhg_ysg_cpfx TYPE char30, “产品方向
zhg_ysg_dcpz TYPE char30, “档次配置
zhg_ysg_bjpz TYPE char30, “部件配置
zhg_ysg_xspz TYPE char30, “下水管配置
zhg_ysg_lbsx TYPE char30, “类别属性
zhg_ysg_gpxh TYPE char30, “柜盆型号
zhg_ysg_tjdx TYPE char30, “体积
zhg_ysg_ys TYPE char30, “颜色
zhg_ysg_logo TYPE char30, “LOGO
zhg_hyf_xcx TYPE char30, “型材型号
zhg_hyf_xccy TYPE char30, “型材长度
zhg_hyf_bkys1 TYPE char30, “边框颜色
zhg_hyf_gc TYPE char30, “工厂
zhg_hyf_xl TYPE char30, “产品系列
zhg_hyf_xh TYPE char30, “产品型号
* zhg_hyf_zdhd TYPE char30, “最大玻璃厚度
zhg_hyf_jtx TYPE char30, “胶条型号-200
zhg_hyf_cphd1 TYPE char30, “玻璃厚度 -200
zhg_hyf_jtc TYPE char30, “胶条长度-200
icon TYPE char04,
mess TYPE char200,
END OF ls_excel.
DATA: lt_excel LIKE STANDARD TABLE OF ls_excel.
DATA: lt_numnew LIKE bapi1003_alloc_values_num OCCURS 0 WITH HEADER LINE,
lt_charnew LIKE bapi1003_alloc_values_char OCCURS 0 WITH HEADER LINE,
lt_currnew LIKE bapi1003_alloc_values_curr OCCURS 0 WITH HEADER LINE,
lt_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: c_objectkey LIKE bapi1003_key-object,
c_objecttable LIKE bapi1003_key-objecttable,
c_classnum LIKE bapi1003_key-classnum,
c_classtype LIKE bapi1003_key-classtype.
************************************************
*中间省略从excel读取数据到lt_excel内表的过程
************************************************
LOOP AT lt_excel INTO ls_excel WHERE icon = ‘@5D@’.
FREE: lt_numnew ,lt_charnew ,lt_currnew ,lt_return .
CLEAR: c_objectkey,c_objecttable,c_classnum,c_classtype ,
lt_numnew ,lt_charnew ,lt_currnew ,lt_return .
c_objectkey = ls_excel-matnr.
c_objecttable = ls_excel-table.
c_classnum = ls_excel-classnum.
c_classtype = ls_excel-klart.
IF p_klart = ‘001’.
lt_charnew-charact = ‘ZHG_YSG_ZPL’. “子品类
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_zpl.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_CZ’. “材质
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_cz.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_ZTCC’. “主体尺寸
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_ztcc.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_AZFS’. “安装方式
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_azfs.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_CPFX’. “产品方向
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_cpfx.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_DCPZ’. “档次配置
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_dcpz.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_BJPZ’. “部件配置
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_bjpz.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_XSPZ’. “下水管配置
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_xspz.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_LBSX’. “类别属性
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_lbsx.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_GPXH’. “柜盆型号
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_gpxh.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_TJDX’. “体积
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_tjdx.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_YS’. “颜色
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_ys.
APPEND lt_charnew. CLEAR: lt_charnew.
lt_charnew-charact = ‘ZHG_YSG_LOGO’. “LOGO
lt_charnew-VALUE_NEUTRAL = ls_excel-zhg_ysg_logo.
APPEND lt_charnew. CLEAR: lt_charnew.
ENDIF.
CALL FUNCTION ‘BAPI_OBJCL_CHANGE’
EXPORTING
objectkey = c_objectkey
objecttable = c_objecttable
classnum = c_classnum
classtype = c_classtype
* STATUS = ‘1’
* STANDARDCLASS =
* CHANGENUMBER =
* KEYDATE = SY-DATUM
* NO_DEFAULT_VALUES = ‘ ‘
* KEEP_SAME_DEFAULTS = ‘ ‘
* OBJECTKEY_LONG =
* IMPORTING
* CLASSIF_STATUS =
TABLES
allocvaluesnumnew = lt_numnew
allocvaluescharnew = lt_charnew
allocvaluescurrnew = lt_currnew
return = lt_return.
READ TABLE lt_return WITH KEY type = ‘E’.
IF sy-subrc = 0.
ROLLBACK WORK.
ELSE.
COMMIT WORK AND WAIT.
ls_excel-icon = ‘@5B@’ .
ls_excel-mess = ‘数据更新成功’.
ENDIF.
ENDLOOP.
本文链接 :http://www.hot583.com/2022/06/01/bapi_objcl_change/
本文为作者原创,如果这篇文章对您有用,欢迎转载,
转载请务必注明来源《今日热点在看》http://www.hot583.com/
我的微信公众号【 hot583 】 或者在这个链接联系我
微信原文《全文完》