‎2006 Nov 27 7:00 PM
Hi guys,
I have two dynamic tables <it_pro> and <it_acor>, and I need to make a loop statement for one of then depending on the column of an ALV that was edited.
How can I do in order to do a loop dynamically?
Regards,
Eric
‎2006 Nov 27 7:02 PM
HI,
Why don't you use the DO loop, then write an EXIT command where ever required
Regards
Sudheer
‎2006 Nov 27 7:02 PM
HI,
Why don't you use the DO loop, then write an EXIT command where ever required
Regards
Sudheer
‎2006 Nov 27 8:06 PM
Hi Sudheer,
Why I want to do is to use the same loop for the two validations in order to save lines of code.
For example,
IF ls_mod_cell-fieldname = 'PROPUESTA'.
I want to make this: LOOP AT <it_pro> INTO <wa_pro>.
else
LOOP AT <it_acor> INTO <wa_pro>.
endif.
I want to make it like this because all the code inside the loop is the same.
Regards,
Eric
‎2006 Nov 27 8:23 PM
Hello Eric
Perhaps you are looking for something like this:
field-symbols:
<lt_itab> TYPE TABLE,
<ls_line> TYPE ANY,
<ld_fld> TYPE ANY.
IF ( ls_mod_cell-fieldname = 'PROPUESTA' ).
ASSIGN <lt_itab> TO <it_pro>.
ELSE.
ASSIGN <lt_itab> TO <it_acor>.
ENDIF.
LOOP AT <lt_Itab> ASSIGNING <ls_line>.
ASSIGN ls_mod_cell-fieldname OF STRUCTURE <ls_line> TO <ld_fld>.
* Now validate the changed data...
IF ( <ld_fld> .... ).
ELSE.
ENDIF.
ENDLOOP.Regards
Uwe
‎2006 Nov 27 8:48 PM
Hi Uwe,
I think this will work, I'm gonna try and let you know.
Regards,
Eric
‎2006 Nov 27 8:56 PM
Thanks again Uwe,
This was what I needed.
field-symbols:
<lt_itab> TYPE TABLE,
<ls_line> TYPE ANY,
<ld_fld> TYPE ANY.
IF ( ls_mod_cell-fieldname = 'PROPUESTA' ).
ASSIGN <it_pro>< TO lt_itab>.
ELSE.
ASSIGN <it_acor>< TO lt_itab>.
ENDIF.
LOOP AT <lt_Itab> ASSIGNING <ls_line>.
....
Regards,
Eric
‎2006 Dec 01 8:25 AM
You can try these code below:
IF ( ls_mod_cell-fieldname = 'PROPUESTA' ).
itab_name = 'it_pro'.
ELSE.
itab_name = 'it_acor'.
ENDIF.
LOOP AT (itab_name) ASSIGNING <ls_line>.
....If it can run correctly, it wil be high performance.
-
Sorry, unable to interpret the expression "(itab_name)".
It is error.
Message was edited by:
Meng Yuxin