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().
    IF sy-subrc = 0  AND  IS ASSIGNED.

       = ls_char-value_char .

    ENDIF.

    CLEAR ls_char.
    UNASSIGN .

  ENDLOOP.

ENDFUNCTION.

你可能感兴趣的:(BAPI,abap)