‎2019 Jan 24 5:08 PM
I want to access the Data Field names and Data in a deep structure. The Deep structure contains data fields and 2 flat structures. The 2 structures are of the same Type, see snippet below.
The problem is that I do not want to hard code the PTS_ADDRESS for the structure name to access the data fields and data in the shipfr_address and shipto_address components.
Can someone please provide me the proper method to get to that data, dynamically? If I pass the shipfr_address as the name in the describe_by_name method, then it fails, because that name does not exist.
TYPES: BEGIN OF ptw_pallet_label,
printer TYPE rspolname, " Printer Long name
btw_file TYPE char30, " Bartender File Name
copies TYPE char2, " Number of Copies
shipfr_address TYPE pts_address, " Ship-From <--Structure
shipto_address TYPE pts_address, " Ship-To <--Structure
shipto_pstlz TYPE char20, " Ship-To Postal Code w/ Prefix
bolnr TYPE bolnr, " Bill of Lading
END OF ptw_pallet_label.
TYPES: pti_pallet_label TYPE STANDARD TABLE OF ptw_pallet_label.
*& Currently using the following to access the data fields,
*& So how to complete this without having it hardcoded?
gw_comp_strucname = 'PTS_ADDRESS'.
go_comp_structdescr ?= cl_abap_typedescr=>describe_by_name( gw_comp_strucname ).
gi_comp_structure = go_structdescr->get_components( ).
‎2019 Jan 24 5:50 PM
Hi Donna,
I have used the method 'describe_by_data' in the past for reading information dynamically in nested structures. You can retrieve a structure reference for what you are interested in by giving the relevant structure as input to the method and then read the components from that.
Regards,
Ryan Crosby
‎2019 Jan 24 5:50 PM
Hi Donna,
I have used the method 'describe_by_data' in the past for reading information dynamically in nested structures. You can retrieve a structure reference for what you are interested in by giving the relevant structure as input to the method and then read the components from that.
Regards,
Ryan Crosby
‎2019 Jan 24 7:51 PM
Thanks Ryan, you pointed me the direction I needed. I am now getting the structure reference and then using that to do a get_relative_name, which returns the proper PTS_ADDRESS, then I can do the describe_by_name and get components.