Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem With GET_DDIC_FIELD_LIST

srahemi
Participant
0 Likes
3,526

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 ?

1 ACCEPTED SOLUTION
Read only

geert-janklaps
SAP Mentor
SAP Mentor
2,847

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

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 ?

7 REPLIES 7
Read only

geert-janklaps
SAP Mentor
SAP Mentor
2,848

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

Read only

0 Likes
2,847

Thanks for the guidance.

Is there no other way?

Read only

2,847

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

Read only

0 Likes
2,847

Can you give me an example?

Read only

2,847

Sina Rahemi concerning GET_DDIC_FIELD, there are lots of examples in the forum or in blog posts.

Read only

2,847

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

Read only

2,847

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