Hi, there was a need, we created a dynamic table, the fields to be printed on the ALV are not clear, we give the table name to the table DD03L and pull the field names to be printed on the ALV from there, they said that we also want the definitions, we hit the wall because the field is not known.
This class has come to our rescue: cl_text_identifier
With this class, you give the data element used in the field from DD03L, it either brings the definition directly to you according to your needs or brings the definition from which table it draws in a structure.
Example: (I directly gave the table manually to see the A524 table)
DATA: lo_text_identifier TYPE REF TO cl_text_identifier.
DATA: l_text TYPE text255,
l_vtr TYPE flag_x,
l_txid TYPE txid_t_text_identifier_result.
DATA: lt_fields TYPE ttfieldname.
CREATE OBJECT lo_text_identifier.
SELECT *
FROM a524
INTO TABLE @DATA(lt_a524).
READ TABLE lt_a524 INTO DATA(ls_a524) INDEX 1. " THIS IS THE IMPORTANT METHOD TAKES STRUCTURE ONLY, NOT TABLE.
lt_fields = VALUE #( ( 'LAND1' ) ( 'REGIO' ) ( 'KUNAG' ) ( 'MATNR' ) ).
lo_text_identifier->read_text(
EXPORTING
tabname = 'A524' " Table
fieldnames = lt_fields " Set of Fields (Field Set Access)
record = ls_a524 " Data Record With Structure of TABNAME
record_specified = 'X' " Flag Set if RECORD Supplied With Data
language = sy-langu " Language
IMPORTING
text = l_text " Determined Text (Single Field Call)
text_for_value_read = l_vtr " Text Determined for Specified Value
text_identifier_results = l_txid " Results Description for Each Field
EXCEPTIONS
internal_error = 1 " Internal Error
illegal_call = 2 " Invalid Call
illegal_table = 3 " Specified Table Does Not Exist
illegal_field = 4 " Specified Field Does Not Exist
no_text = 5 " No text exists
record_required = 6 " Parameter Record Required
illegal_record = 7 " Parameter Record has Invalid Format
table_record_required = 8 " Record for Additional Table Required
illegal_table_record = 9 " Data Record for Additional Table has Invalid Format
special_parameter_mismatch = 10 " Special Parameter Value has Unexpected Type/Value
OTHERS = 11
).
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
In Debug, the fields we want to get the definition of in the structure are full,


L_TXID field will be filled, we should give direct result of throwing one area would fill the space TR L_TEXT full name for the country would be Turkey.
As you can see below it shows definitions and definitions where it went and pulled it from.

IF THE EXPORT PARAMETER IS NOT FILLED IN “FIELDNAMES”, IT WILL SEARCH FOR ALL FIELDS IN THE TABLE.
TEXT_AVAILABLE_IN_QUERY = IF HAS ‘X’ VALUE THAT MEANS THIS FIELD HAS A TEXT TABLE,
TEXT_FOR_VALUE_READ = IF HAS ‘X’ VALUE THAT MEANS WE HAVE SUCCESFULLY READ A VALUE

ISSUE IN THE EXAMPLE ABOVE “KBSTAT” “TEXT_AVAILABLE_IN_QUERY” HAS VALUE “X” BUT “TEXT_FOR_VALUE_READ” IS EMPTY, TABLE OF THE TEXT SHOWN IS “T686F”
RESULT CHECK
