Get Current Transaction Variant Name

By | Last Updated on May 16, 2013 | 3,574

Transaction Variants are very good for hiding the Screen Elements. Simple code snippet to get the Transaction code variant name.

When using Transaction Variants, the changes are kind of static – means you can’t hide the screen elements based on the field content. This code would get you the Transaction Variant which is being used for that particular transaction. Once known, you can make appropriate changes to screen fields based on the Transaction Variant name using LOOP AT SCREEN.

Get Current Transaction Variant Name

DATA : v_variant      TYPE shdfv-tcvariant,
       v_client_dep   TYPE char1.
* Get the variant of current transaction
  ID 'VARIANT'            FIELD v_variant
" V_VARIANT     would contain the current Transaction Variant
" V_CLIENT_DEP  would contain if the Variant is client dependent

Get Transaction Variant using FM

As skrishna pointed out, you can also use the FM RS_HDSYS_GET_TC_VARIANT to do the same

call function 'RS_HDSYS_GET_TC_VARIANT'
    tcvariant = l_tcvariant
    flag_client_independent = l_xclientind
    rc = l_rc.


For Example : In Sales Order processing, you can set up a Transaction Variant in the customization for a Sales Order Type. If you want to override the value when you are in blah blah transaction variant, you can use this code snippet to get to know the transaction variant name.

Do you have a Code Snippet which you want to share, Submit Code Snippet here

Share It!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{273 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 273 articles.

Load comments


  • steve oldner

    Very useful, thanks!

  • skrishna

    FYI. I have used a function as below for the same

    call function ‘RS_HDSYS_GET_TC_VARIANT’
    tcvariant = l_tcvariant
    flag_client_independent = l_xclientind
    rc = l_rc.

  • Hello skrishna,

    Thanks for pointing it out – I have updated the post to include the the code as well.

    Naimesh Patel

Comments on this Post are now closed. If you have something important to share, you can always contact me.