2016 Jul 25 11:22 AM
Hi all,
I have an internal table like this :
TYPES : BEGIN OF lty_wrk,
bukrs type bkpf-bukrs,
gjahr type bkpf-gjahr,
belnr type bkpf-belnr,
END OF lty_wrk.
DATA : tb_wrk TYPE TABLE OF lty_wrk.
I want to have the description of each data element.
That is to say, I want to have : 'Society', 'Exercice year', 'Document post'.
Thanks in advance for your help !
BR,
Wals
2016 Jul 25 11:55 AM
Use RTTI as explained in the ABAP documentation (RTTS - Run Time Type Services; use the methods DESCRIBE_BY_NAME for type 'LTY_WRK', then method GET_DDIC_OBJECT of CL_ABAP_TYPEDESCR to get the data elements, and function module DDIF_NAMETAB_GET to get the texts).
2016 Jul 25 11:40 AM
Hi ,
Please use the table - DD04T (R/3 DD: Data element texts) to get description of data elements.
Thanks.
2016 Jul 25 11:45 AM
Thanks Pavan but I only have the internal table.
And I want to have all element data from this internal table before reading DD04T.
BR,
Wals
2016 Jul 25 11:51 AM
Hi,
I think your requirement is to get field catalog from your custom structure.
In this case , please use the following FM
LVC_FIELDCATALOG_MERGE - just pass your structure you will get field catalog.
If not ,please elaborate your requirement.
2016 Jul 25 11:45 AM
Hi,
where would you like this header text.
means you want to print those text or want to use in some other place.
please clear your requirement.
2016 Jul 25 11:47 AM
I want the list of the description of each data element of my internal table.
i want it in an other internal table.
2016 Jul 25 11:52 AM
2016 Jul 25 11:55 AM
Hi,
For header in report use class CL_SALV_TABLE and method FACTORY. After calling of method pass Output table into it. it will give you description of field in Data element.
like
BUKRS = Company code
GJAHR = Year
BELNR = Document Number.
If you want to change the Description Use CL_SALV_COLUMNS_TABLE,
CL_SALV_COLUMN_TABLE.
Regards,
E.Ananthachari.
2016 Jul 25 11:55 AM
Use RTTI as explained in the ABAP documentation (RTTS - Run Time Type Services; use the methods DESCRIBE_BY_NAME for type 'LTY_WRK', then method GET_DDIC_OBJECT of CL_ABAP_TYPEDESCR to get the data elements, and function module DDIF_NAMETAB_GET to get the texts).
2016 Jul 25 3:59 PM
The MF DDIF_NAMETAB_GET need a structure defined in the DDIC.
Or I declare the internal table in the program not in the DDIC.
2016 Jul 25 8:06 PM
Sorry for the error. Better use the method GET_DDIC_FIELD of CL_ABAP_ELEMDESCR (RTTI).
So, the general algorithm is (please correct the errors):
DATA rtti_struct TYPE REF TO CL_ABAP_STRUCTDESCR.
DATA rtti_elem TYPE REF TO CL_ABAP_ELEMDESCR.
rtti_struct ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( 'LTY_WRK' ).
DATA(comps) = rtti_struct->GET_COMPONENTS( ).
LOOP AT comps. "consider we should not use header line
IF comps-type->type_kind = comps-type->typekind_elem.
rtti_elem ?= comps-type.
"before using get_ddic_field, we should check the field with method is_ddic_type
DATA(dfies) = rtti_elem->get_ddic_field( ).
WRITE : / comps-fieldname, dfies-fieldtext.
ENDIF.
ENDLOOP.
2016 Jul 25 10:39 PM
What exactly is the use case for this? What are you trying to accomplish?
Also I'm curious how do you expect to get 'Society', 'Exercice year', 'Document post' from those fields when the dictionary description is different...
2016 Jul 26 12:06 PM
Thanks very much to everybody for your help.
Thank you Sandra Rossi !
@Jelena : Sorry, it's true I didn't explain very well.