2020 Mar 08 8:00 AM
Hi
TYPES : BEGIN OF TWA_OUT,
STATU TYPE PLKO-STATU,
KTEXT TYPE PLKO-KTEXT,
ZAEHL TYPE PLKO-ZAEHL,
MATNR TYPE MARA-MATNR,
END OF TWA_OUT.
DATA: WA_OUT TYPE TWA_OUT,
LS_STRU TYPE REF TO CL_ABAP_STRUCTDESCR,
LT_DDFIELD_HD TYPE DDFIELDS .
LS_STRU ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_DATA( WA_OUT ).
CALL METHOD LS_STRU->GET_DDIC_FIELD_LIST
* EXPORTING
* P_LANGU = SY-LANGU
* P_INCLUDING_SUBSTRUCTRES = ABAP_FALSE
RECEIVING
P_FIELD_LIST = LT_DDFIELD_HD
EXCEPTIONS
NOT_FOUND = 1
NO_DDIC_TYPE = 2
OTHERS = 3
.
WRITE : 'xxxxxxxxxxxx'.
In this code i use GET_DDIC_FIELD_LIST but i got SY-SUBRC = 2 ( NO_DDIC_TYPE )
Where did I go wrong ?
2020 Mar 08 8:05 AM
Hi,
The problem is that you're using a locally defined structure which is off course not available in the data dictionary. That's why you're getting the NO_DDIC_TYPE error.
A solution could be to create a DDIC structure for your type TWA_OUT.
Best regards,
Geert-Jan Klaps
Hi,
The problem is that you're using a locally defined structure which is off course not available in the data dictionary. That's why you're getting the NO_DDIC_TYPE error.
A solution could be to create a DDIC structure for your type TWA_OUT.
Best regards,
Geert-Jan Klaps
2020 Mar 08 8:05 AM
Hi,
The problem is that you're using a locally defined structure which is off course not available in the data dictionary. That's why you're getting the NO_DDIC_TYPE error.
A solution could be to create a DDIC structure for your type TWA_OUT.
Best regards,
Geert-Jan Klaps
2020 Mar 08 8:28 AM
2020 Mar 08 8:47 AM
Hi,
You could try to use CL_ABAP_ELEMDESCR for each field in the structure and use method GET_DDIC_FIELD. Might be necessary to refer to the actual types in stead of using for example PLKO-STATU.
Best regards,
Geert-Jan Klaps
2020 Mar 08 9:39 AM
2020 Mar 08 1:00 PM
Sina Rahemi concerning GET_DDIC_FIELD, there are lots of examples in the forum or in blog posts.
2020 Mar 08 1:14 PM
Hi srahemi,
Based on your example you could do something like this (in stead of using ls_stru->get_ddic_field_list).
DATA: lo_element TYPE REF TO cl_abap_elemdescr.
* Read structure components
DATA(lt_components) = ls_stru->get_components( ).
* Loop over components
LOOP AT lt_components INTO DATA(ls_component).
* Cast data descriptor into element descriptor
lo_element ?= ls_component-type.
* Read data dictionary description
lo_element->get_ddic_field(
* EXPORTING
* p_langu = SY-LANGU " Current Language
RECEIVING
p_flddescr = DATA(ls_field_description)
EXCEPTIONS
not_found = 1 " Type could not be found
no_ddic_type = 2 " Typ is not a dictionary type
others = 3
).
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.Best regards,
Geert-Jan Klaps
2020 Mar 08 1:42 PM
Thank you Geert-Jan Klaps.
Also I was able to find this and it worked
LS_STRU ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_DATA( P_DATA = WA_OUT ).
LT_DDFIELD_HD = CL_SALV_DATA_DESCR=>READ_STRUCTDESCR( LS_STRU ).
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |