on ‎2017 Jul 30 8:39 AM
Hi,
I cannot get table keys via the RTTS technique. I use following code:
DATA: the_table TYPE REF TO data.
CREATE DATA the_table TYPE TABLE OF ('MARA').
DATA typedescription TYPE REF TO cl_abap_tabledescr.
typedescription ?= cl_abap_tabledescr=>describe_by_data_ref( the_table ).
DATA keys TYPE abap_table_keydescr_tab.
keys = typedescription->get_keys( ).
It always returns full list of fields, not only primary key, which I don't want.
I also tried the detection of keys from static internal table, but got the same result.
DATA: itab LIKE mara OCCURS 0 WITH HEADER LINE,
lt_tabdescr TYPE abap_keydescr_tab,
ref_table_descr TYPE REF TO cl_abap_tabledescr.
ref_table_descr ?= cl_abap_typedescr=>describe_by_data( itab[] ).
lt_tabdescr[] = ref_table_descr->key[].<br>
Detecting the key fields via describe_by_name( ) doesn't work either.
Any suggestions? System release is SAP ECC 7.40 SP09
Request clarification before answering.
Well, as suggested by horst.keller in comments, you can use method get_ddic_field_list of class CL_ABAP_STRUCTDESCR.
And filter its returning table by KEYFLAG field value 🙂 For example:
DELETE lt_field_list WHERE keyflag <> 'X'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.