ABAP 获取批次特性
Posted 想发财的小夏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP 获取批次特性相关的知识,希望对你有一定的参考价值。
通过物料+工厂+批次 获取到批次特性值
涉及 TCODE:MSC1/2/3N,CT04
通过调用BAPI:BAPI_OBJCL_GETDETAIL,代码如下:
FUNCTION ZFM_TEST01.
*"--------------------------------------------------------------------
*"*"局部接口:
*" IMPORTING
*" VALUE(IV_MATNR) TYPE MATNR
*" VALUE(IV_CHARG) TYPE CHARG_D
*" VALUE(IV_WERKS) TYPE WERKS_D
*" CHANGING
*" REFERENCE(CS_DATA) TYPE ANY
*"--------------------------------------------------------------------
DATA :lv_objek TYPE cuobn,
lv_obtab TYPE tabelle,
lv_klart TYPE klassenart,
lv_class TYPE klasse_d.
DATA: lt_allocvaluesnum TYPE TABLE OF bapi1003_alloc_values_num,
lt_allocvalueschar TYPE TABLE OF bapi1003_alloc_values_char,
lt_allocvaluescurr TYPE TABLE OF bapi1003_alloc_values_curr,
lt_return TYPE TABLE OF bapiret2.
CALL FUNCTION 'VB_BATCH_2_CLASS_OBJECT'
EXPORTING
i_matnr = iv_matnr
i_charg = iv_charg
i_werks = iv_werks
IMPORTING
e_objek = lv_objek
e_obtab = lv_obtab
e_klart = lv_klart
e_class = lv_class.
"获取特性值
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objecttable = lv_obtab
classnum = lv_class
classtype = lv_klart
objectkey_long = lv_objek
TABLES
allocvaluesnum = lt_allocvaluesnum
allocvalueschar = lt_allocvalueschar
allocvaluescurr = lt_allocvaluescurr
return = lt_return.
LOOP AT lt_allocvalueschar INTO DATA(ls_char).
ASSIGN COMPONENT ls_char-charact OF STRUCTURE cs_data TO FIELD-SYMBOL(<lfs_char>).
IF sy-subrc = 0 AND <lfs_char> IS ASSIGNED.
<lfs_char> = ls_char-value_char .
ENDIF.
CLEAR ls_char.
UNASSIGN <lfs_char>.
ENDLOOP.
ENDFUNCTION.
以上是关于ABAP 获取批次特性的主要内容,如果未能解决你的问题,请参考以下文章