2023 Jan 05 6:21 PM
Hello Professionals
I am trying to leverage the code posted in this place (below) to output the technical fieldnames and related attributes from some SAP tables like T000, T001...
However, while the code's syntax is correct, I get no output. I am coming from a web development background and ABAP is new to me 🙂
Thanks
*&---------------------------------------------------------------------*
*& Report ZMY_ALV_10
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMY_ALV_10.
FIELD-SYMBOLS:
<fieldname> TYPE ANY, "Name of field
<line> TYPE ANY, "Line structure for table
<fieldvalue> TYPE ANY. "Value of field
DATA: l_shorttext LIKE dd03m-ddtext.
DATA: wa_dd03l LIKE dd03l.
DATA WA_PA1_DELTA.
SELECT * FROM dd03l INTO wa_dd03l
WHERE tabname = 'ZHR_INTER_PA1_DL'.
* Assign name of field
ASSIGN COMPONENT 2 OF STRUCTURE wa_dd03l TO <fieldname>.
* Assign structure for internal table
ASSIGN wa_pa1_delta TO <line>.
* Assign field value from structure
ASSIGN COMPONENT <fieldname> OF STRUCTURE <line> TO <fieldvalue>.
* Find DD text for field
SELECT SINGLE ddtext
FROM dd03m
INTO l_shorttext
WHERE tabname = 'ZHR_INTER_PA1_DL' AND
fieldname = <fieldname> AND
ddlanguage = 'EN'.
WRITE: / <fieldname>, l_shorttext, ' : ', <fieldvalue>.
ENDSELECT.
2023 Jan 06 5:45 AM
2023 Jan 06 8:27 AM
Aditya,
Thank you for the followup. Basically I am collecting configuration and master data tables within specific clients and trying to download their structure to Excel as well access these tables programmatically to perform some summing and grouping by specific fields to summarise transactions by targeted field names such as Material type, document type, or even by any structural elements such as storage location, sales office…to collect some KPIs somewhat mimic the behaviour of ST13 (Table analysis).
Many thanks
Omar
2023 Jan 06 11:31 AM
Hello,
Can you try this code:
FIELD-SYMBOLS:
<fieldname> TYPE ANY, "Name of field
<line> TYPE ANY, "Line structure for table
<fieldvalue> TYPE ANY. "Value of field
DATA: l_shorttext LIKE dd03m-ddtext.
DATA: wa_dd03l LIKE dd03l.
SELECT * FROM dd03l INTO wa_dd03l
WHERE tabname = 'ZHR_INTER_PA1_DL'.
* Assign name of field
ASSIGN COMPONENT 2 OF STRUCTURE wa_dd03l TO <fieldname>.
* Assign structure for internal table
ASSIGN wa_dd03l TO <line>.
* Assign field value from structure
ASSIGN COMPONENT 2 OF STRUCTURE <line> TO <fieldvalue>.
* Find DD text for field
SELECT SINGLE ddtext
FROM dd03m
INTO l_shorttext
WHERE tabname = 'ZHR_INTER_PA1_DL' AND
fieldname = <fieldname> AND
ddlanguage = 'EN'.
WRITE: / <fieldname>, l_shorttext, ' : ', <fieldvalue>.
ENDSELECT.
2023 Jan 06 2:50 PM
Hello Abit
Thank you for your followup.
While your code's syntax is correct, I get no output on my end.
Best reagrds
Omar
2023 Jan 06 11:37 AM
To read and display table content of an arbitrary table:
PARAMETERS tabname TYPE tabname.
DATA dataref TYPE REF TO data.
CREATE DATA dataref TYPE TABLE OF (tabname).
FIELD-SYMBOLS <lt_data> TYPE ANY TABLE.
ASSIGN dataref->* TO <lt_data>.
SELECT * FROM (tabname) INTO TABLE @<lt_data>.
cl_demo_output=>display( <lt_data> ).
To read and display table structure:
DATA lt_comp TYPE TABLE OF dd03p.
CALL FUNCTION 'DD_TABL_GET'
EXPORTING
tabl_name = tabname
withtext = abap_true
langu = 'E'
TABLES
dd03p_tab_a = lt_comp
EXCEPTIONS
OTHERS = 1.
DATA lt_desc TYPE TABLE OF string.
lt_desc = VALUE #( FOR <wa> IN lt_comp ( |Name { <wa>-fieldname }, data type { <wa>-rollname }, description { <wa>-ddtext }| ) ).
cl_demo_output=>display( lt_desc ).
2023 Jan 06 2:47 PM
Hello Andrei
Thank you for the follow-up.
The first piece of code does not work for me as I am running Pack 7 so my editor does not recognize the inline declarations made in your code.
For the second piece, I get an error message that field <tabname> is unknown.
Best reagrds
Omar
2023 Jan 09 10:48 AM
Hello Omar,
what kind of error do you get in the first part? All variables and field symbols are declared explicitly here. In the second part there is no field symbol <tabname>. The variable tabname is decalared in the first part with a PARAMETERS statement.