Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function module to read domain value table texts (not fixed value)

Former Member
0 Kudos

Hi,

i'm looking for an function module or method to read from a known domain the text of a value which is defined in a value table (not as a fixed value).

(All I found is to read the fixed values - but this i don't need.)

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos

AFAIK there are only FMs for single value text. But you could use same tools than SQ01 generated queries, look for method if_text_identifier_obj-read_text in forum.

Regards,
Raymond

raghug
Active Contributor
0 Kudos

The closest I got was CL_TEXT_IDENTIFIER which did not suit my purposes. So I ended up writing my own... here are some key code snippets.

Some notes:

  • The opt_crit is for additional key fields, which some domain text tables have. For example T336T has LGNUM and KZDIF as keys.
  • Reading this now, I would think the DD03L selections should have an ORDER BY POSITION to ensure that it is getting the same field consistently... but apparently this worked for me 🙂
        SELECT SINGLE * INTO l_dd1
          FROM dd01l
          WHERE domname = domname
          AND as4local = 'A'
          AND as4vers = ''  ##WARN_OK.
         
        ...IF sy-subrc....
         
        CALL FUNCTION 'DDUT_TEXTTABLE_GET' ##FM_SUBRC_OK
          EXPORTING
            tabname   = l_dd1-entitytab
          IMPORTING
            texttable = l_chktab
          EXCEPTIONS
            OTHERS    = 1.          
       
        ...IF sy-subrc...  
        
        SELECT SINGLE fieldname position INTO (l_txtfield, l_position)
          FROM dd03l
          WHERE tabname = l_chktab
          AND as4local = 'A'
          AND as4vers  = ''
          AND keyflag = ''  ##WARN_OK.
        IF sy-subrc = 0.
          l_position = l_position - 1.
          SELECT SINGLE fieldname INTO l_chkfield
            FROM dd03l
            WHERE tabname = l_chktab
            AND as4local = 'A'
            AND as4vers = ''
            AND position = l_position  ##WARN_OK.
          IF opt_crit IS NOT INITIAL.
            l_position = l_position - 1.

            SELECT SINGLE fieldname INTO l_optfield
              FROM dd03l
              WHERE tabname = l_chktab
              AND as4local = 'A'
              AND as4vers = ''
              AND position = l_position  ##WARN_OK.
            IF sy-subrc = 0.
              CONCATENATE l_optfield ` = '` opt_crit `' AND ` INTO l_entered.
              APPEND l_entered TO li_entered.
            ENDIF.
          ENDIF.

          " Assemble WHERE clause
          CONCATENATE l_chkfield ` = '` chk_value `'` INTO l_entered.
          APPEND l_entered TO li_entered.

          SELECT SINGLE (l_txtfield) INTO e_text
            FROM (l_chktab)
            WHERE (li_entered)
            AND spras = sy-langu.
          IF sy-subrc <> 0.
            l_error = abap_true.
          ENDIF.

... And I had my method setup to be able to call it like this

      field_text = my_class->chk_dd_value(
                                           domname      = 'KZDIF'
                                           chk_value    = l_kzdif
                                           opt_crit     = l_lgnum
                                         ).  

gregory_gotera2
Explorer
0 Kudos

Hi

review the FM DOMAIN_VALUE_GET

Regards

Gregory

0 Kudos

This only works for fixed values, not from a value table. For example check the domain WERKS.