SAPHub

Read SAP Domain Value Range or Domain Fixed Values

Some domains has fixed values maintained in the domain level. This list of fixed values maintained in domain are provided as F4 help in the screen interface for the data element.

PSTYP_EDI is a domain where fixed values are maintained as shown below. Let us try to read the fixed values through program.

Use SAP function module GET_DOMAIN_VALUES to read Domain Value Range or Domain fixed values.

DATA: g_domain TYPE dd07l-domname.
DATA: gt_tab   TYPE TABLE OF dd07v,
      gwa_tab  TYPE dd07v.

g_domain = 'PSTYP_EDI'.

CALL FUNCTION 'GET_DOMAIN_VALUES'
  EXPORTING
    domname         = g_domain
  TABLES
    values_tab      = gt_tab
  EXCEPTIONS
    no_values_found = 1
    OTHERS          = 2.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

WRITE:/ 'Domain',12 'Fix.Value',22 'Short Text'.
WRITE:/ sy-uline(43).
LOOP AT gt_tab INTO gwa_tab.
  WRITE:/ gwa_tab-domname,12 gwa_tab-domvalue_l,22 gwa_tab-ddtext.
  CLEAR: gwa_tab.
ENDLOOP.

Output

To read the text of particular fixed value of the domain use the function module ‘DD_DOMVALUE_TEXT_GET’.

DATA: g_domain TYPE dd07l-domname.
DATA: g_value  TYPE dd07l-domvalue_l.
DATA: g_subrc  TYPE sy-subrc,
      gwa_tab  TYPE dd07v.

g_domain = 'PSTYP_EDI'.
g_value  = '5'.

CALL FUNCTION 'DD_DOMVALUE_TEXT_GET'
  EXPORTING
    domname             = g_domain
    value               = g_value
 IMPORTING
   dd07v_wa            = gwa_tab
   rc                  = g_subrc.
IF g_subrc = 0.
  WRITE:/ 'Domain',12 'Fix.Value',22 'Short Text'.
  WRITE:/ sy-uline(43).
  WRITE:/ gwa_tab-domname,12 gwa_tab-domvalue_l,22 gwa_tab-ddtext.
ENDIF. 

Output