VAKEY (Variable key) in S4 HANA

Field VAKEY is not available in KONH Table in S4 HANA. If still you want to get the value of VAKEY as it might have been used in different programs then use Method: DETERMINE_VAKEY_FROM_DB of Class: CL_COND_VAKEY_SRV.

Sample Code:

TABLES : konh.

SELECT-OPTIONS : s_knumh FOR konh-knumh OBLIGATORY.

START-OF-SELECTION.
  SELECT * FROM konh INTO TABLE @DATA(_t_konh)
    WHERE knumh IN @s_knumh.
  IF sy-subrc IS INITIAL.
    LOOP AT _t_konh ASSIGNING FIELD-SYMBOL(<fs_konh>).
      TRY.
          DATA(_vakey) = NEW cl_cond_vakey_srv( )->determine_vakey_from_db( iv_usage   = <fs_konh>-kvewe
                                                                            iv_knumh   = <fs_konh>-knumh
                                                                            iv_kotabnr = <fs_konh>-kotabnr ).
*      Perform your operations with VAKEY here
        CATCH cx_cond_vakey INTO DATA(_o_cx_ref).
          CLEAR : _vakey.
      ENDTRY.
    ENDLOOP.
  ENDIF.

One comment

Leave a Reply