Application Development and Automation 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 only

set constant value to variable

Former Member
0 Likes
1,567

Hi everybody,

from table i want 2 records, one record with 2 conditions, and other record with 1 condition out of 2.

If i use loop and with checking 1 condition, moved data to variable and continue the loop to get other record with other 1 condition which is same out of 2 the data moved by 1st condition may get change. I want to set that constant while loop start for 2nd condition.

Can anybody tell how to set constant in loop?

loop at itb.

check ( condition 1 or condition 2)

get record 1. (want this values to set constant)

if condition 1

get record 2

else continue loop till condition 1.

endloop.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

guilherme_frisoni
Contributor
0 Likes
1,301

Hi,

I couldn't understand very well, but I guess you should look for AT NEW or AT END.

Frisoni

10 REPLIES 10
Read only

guilherme_frisoni
Contributor
0 Likes
1,302

Hi,

I couldn't understand very well, but I guess you should look for AT NEW or AT END.

Frisoni

Read only

0 Likes
1,301

suppose

itab-a = 2 itab-b = 0 and it has 6 fileds only 2 for conditions.

so, i need 2 recods such that

loop at itab.

check itab-a = 2 or itab-b = 0.

move itab-c to var1,

itab-d to var2.

if itab-a =2. -


here if itab-b =0, it will go for next record that time it may change var1 & var2 values

move itab-c to var3. i do not want to get it changed. whatever value of var1 and var2 is got already it

else continue. should be there for all next loop without changing it.

endif.

endif.

I think now it may be clear....

Read only

0 Likes
1,301

So do you mean to say first your will check for OR condition and then move your field into var1 & 2 and then check AND condition and if this satisties move to VAR3 & 4?

Thanks

Kiran

Read only

0 Likes
1,301

hi kiran,

var1 & var2 can get by any of 2 get satisfied.

for var3 & var4 loop will continue to get other record but during next loop var1 var2 may change as it satisfies or condition.

so i do not want to change them for next loop

Read only

0 Likes
1,301

what do u mean by "loop will continue to get other record but during next loop"

Your explanation is not clear at all. Can you explain with data in itab and what will be your scenario and what o/p are you looking for.

Thanks

Kiran

Read only

0 Likes
1,301

plz tell me if i move some data to variable & throught the program i want to keep that data constant without changing its value.

how to do that?

Read only

0 Likes
1,301

1. You should have that declared as a global variable.

2. Once you move some value, dont move any other value into it.

Thanks

Kiran

Read only

0 Likes
1,301

I hope I understood u correct

loop at itab.
read table itab into wa_itab index '1'.
if sy-subrc eq 0.
check itab-a = wa_itab-2 or itab-b = wa_itab-0.
move itab-c to var1,
itab-d to var2.
endif. 
if itab-a =2.

Read only

0 Likes
1,301

outside of loop:

clear: &var1, &var2.

the check condition Inside the loop:

IF condition is met.

IF &var1 IS NOT INITIAL.

assign value to &var1.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
1,301

More clearity please.