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: 

Finding the field of an dynamic internal table

Former Member
0 Kudos

Hi,

I have a situation while doing the program where I need to give one where condition with my dynamic internal table while looping through it.

EX:

LOOP AT <dyntab> ASSIGNING <dyn_wa>.

IF <dyn_wa>- field = 'XXXX' "HOW TO ACHIEVE THE FIELD OF THE DYN_WA

then proceed with one logic.

Endif.

ENDLOOP.

Can anyone tell how to achieve this?

Edited by: Jjammy on Jul 31, 2009 7:46 AM

1 ACCEPTED SOLUTION

former_member386202
Active Contributor
0 Kudos

Hi,

Refer following code

  • Local Field Symbol

FIELD-SYMBOLS: <lf_any> TYPE ANY. "Changed data

LOOP AT <gf_dyna_table> ASSIGNING <gf_dyna>.

DO.

ASSIGN COMPONENT sy-index OF STRUCTURE <gf_dyna> TO <lf_any>.

IF sy-subrc NE 0.

EXIT.

ENDIF.

IF ls_attach-line IS INITIAL.

ls_attach-line = <lf_any>.

ELSE.

CONCATENATE ls_attach-line <lf_any> INTO ls_attach-line

SEPARATED BY lc_tab.

ENDIF.

ENDDO.

CONCATENATE lc_cret ls_attach-line INTO ls_attach-line.

  • Append Changed Data to attachement table

APPEND ls_attach TO gt_attach.

  • Clear

CLEAR : ls_attach.

ENDLOOP.

Regards,

Prashant

3 REPLIES 3

Former Member
0 Kudos

hi,

try this...

LOOP AT <dyntab> ASSIGNING <dyn_wa>.

ASSIGN COMPONENT 'FIELDNAME' OF STRUCTURE <dyn_wa> TO <fs_field>.

IF <fs_field> IS ASSIGNED AND <fs_field> EQ 'VALUE'.

then proceed with one logic.

Endif.

ENDLOOP.

Thanks,

Renjith.

Edited by: Renjith Munnilath on Jul 31, 2009 7:58 AM

former_member386202
Active Contributor
0 Kudos

Hi,

Refer following code

  • Local Field Symbol

FIELD-SYMBOLS: <lf_any> TYPE ANY. "Changed data

LOOP AT <gf_dyna_table> ASSIGNING <gf_dyna>.

DO.

ASSIGN COMPONENT sy-index OF STRUCTURE <gf_dyna> TO <lf_any>.

IF sy-subrc NE 0.

EXIT.

ENDIF.

IF ls_attach-line IS INITIAL.

ls_attach-line = <lf_any>.

ELSE.

CONCATENATE ls_attach-line <lf_any> INTO ls_attach-line

SEPARATED BY lc_tab.

ENDIF.

ENDDO.

CONCATENATE lc_cret ls_attach-line INTO ls_attach-line.

  • Append Changed Data to attachement table

APPEND ls_attach TO gt_attach.

  • Clear

CLEAR : ls_attach.

ENDLOOP.

Regards,

Prashant

Former Member
0 Kudos

one way of doing it.

type-pools: abap.

data: lt_mara like mara occurs 0 with header line,

lt_comp type standard table of abap_componentdescr,

ls_comp type abap_componentdescr.

data: lo_struct type ref to cl_abap_structdescr.

field-symbols: <fs_value> type any,

<ls_mara>.

lt_mara-matnr = 1.

append lt_mara.

clear lt_mara.

loop at lt_mara assigning <ls_mara>.

lo_struct ?= cl_abap_typedescr=>describe_by_data( <ls_mara> ).

lt_comp = lo_struct->get_components( ).

loop at lt_comp into ls_comp.

check ls_comp-name ne 'MATNR'.

exit.

endloop.

endloop.