Last active
March 19, 2024 03:39
-
-
Save zhjuncai/6067997 to your computer and use it in GitHub Desktop.
abap demo use of cl_abap_structdescr to get list of structure component definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*&---------------------------------------------------------------------* | |
*& report z_demo_structdescr | |
*& | |
*&---------------------------------------------------------------------* | |
*& | |
*& | |
*&---------------------------------------------------------------------* | |
report z_demo_structdescr. | |
data: | |
ls_trq_item type /scmtms/s_trq_item_k, | |
lr_trq_item type ref to /scmtms/s_trq_item_k, | |
lo_field_catalog type ref to cl_abap_structdescr, | |
lt_field_list type ddfields, | |
ls_field type line of ddfields, | |
lv_field_desc type string. | |
lo_field_catalog ?= cl_abap_structdescr=>describe_by_data( p_data = ls_trq_item ). | |
lt_field_list = lo_field_catalog->get_ddic_field_list( ). | |
read table lt_field_list into ls_field with key fieldname = 'key'. | |
if sy-subrc eq 0. | |
lv_field_desc = ls_field-fieldtext. | |
endif. | |
lo_field_catalog ?= cl_abap_structdescr=>describe_by_name( p_name = '/scmtms/s_trq_item_k' ). | |
check lo_field_catalog is bound. | |
free lt_field_list. | |
lt_field_list = lo_field_catalog->get_ddic_field_list( ). | |
create data lr_trq_item. | |
lo_field_catalog ?= cl_abap_structdescr=>describe_by_data_ref( p_data_ref = lr_trq_item ). | |
check lo_field_catalog is bound. | |
free lt_field_list. | |
lt_field_list = lo_field_catalog->get_ddic_field_list( ). | |
write / 'Done Test!'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 21 will get you a dump