Application Development 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 field value from table inside nested structure.

uirji_netweaver
Participant
0 Kudos

Hi Team

i need to read value of field (Check) from the below deep structure ,

HRDATA.STAR_CHEQUE-CHEQUE_FPAYHX-CHECK..

here HRDATA is structure of /1PYXXFO/ZHR_PAYSTUB.

STAR_CHEQUE is table type defined on /1PYXXFO/ZHR_PAYSTUB_____M0030.

CHEQUE_FPAYHX is defined on structure FPAYHX

CHECK is field of char13 field of FPAYHX.

i tried the below code ,

DATA table_descr TYPE REF TO cl_abap_tabledescr.
DATA struct_descr TYPE REF TO cl_abap_structdescr.
DATA columns TYPE abap_compdescr_tab.
FIELD-SYMBOLs
<column> LIKE LINE OF columns.
table_descr ?= cl_abap_typedescr=>describe_by_data( HRDATA-STAR_CHEQUE ).
struct_descr ?= table_descr->get_table_line_type( ).
columns = struct_descr->components.

now i went a level where i see the fields of STAR_CHEQUE are moved to field symbol columns. now how do i read CHEQUE_FPAYHX structure then the filed CHECK?

Please help with this?

Thanks

NK

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos

Why do you use RTTI?

uirji_netweaver
Participant
0 Kudos

Hi Sandra ,

Thanks for the reply , the above code is reference from another post. now i tried the alternative way , but i see componet of <FS-STRCT2> is not assigning to <FS-STRCT2> . Please suggest

FIELD-SYMBOLS : <FS-STRUCT1> TYPE any,
<FS-STRUCT2> TYPE ANY ,
<fs_wa> type FPAYHX.
data: lv_comp_name(20) type c value 'CHEQUE_FPAYHX'.
ASSIGN HRDATA-STAR_CHEQUE[] to <FS-STRUCT1>.
ASSIGN COMPONENT lv_comp_name OF STRUCTURE <FS-STRUCT1> TO <FS-STRUCT2>.

Sandra_Rossi
Active Contributor

Same question for ASSIGN with dynamic naming, isn't your variable HRDATA typed statically? Do you mean that you don't have this line of code (or parameter)?

DATA hrdata TYPE /1PYXXFO/ZHR_PAYSTUB.
If so, you don't need ASSIGN, its components may be accessed directly.

PS: minus character in names is obsolete and forbidden in ABAP Objects.

Sandra_Rossi
Active Contributor

If your ABAP release is >= 7.40, use:

LOOP AT hrdata-star_cheque ASSIGNING FIELD-SYMBOL(<line_of_star_cheque>).
  IF <line_of_star_cheque>-cheque_fpayhx IS INITIAL.
    ...
  ENDIF.
ENDLOOP.

PS: I advise using "good" names, bad practice in your code is to name <STRUCT1> a field symbol which refers to the internal table STAR_CHEQUE.

uirji_netweaver
Participant

Thanks sandra.rossi , your inputs solved my issue