Skip to Content
avatar image
Former Member

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

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.)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Dec 20, 2016 at 12:33 PM
    -1

    Hi

    review the FM DOMAIN_VALUE_GET

    Regards

    Gregory

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2016 at 09:45 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2016 at 11:25 AM

    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
                                             ).  
    
    Add comment
    10|10000 characters needed characters exceeded