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

Looping

Former Member
0 Likes
1,040

Hi guys

In the below code if i give input for p1 as ' 1' and ' 3 ' .then i need to pick values of only april,may and june.P1 being select-option field.I am unable to run it in a loop.What i mean is if i give 1 and 3 as input in p1.I am getting only values for p1 =1.if i use p-low and p1-high then i am missing the middle value of p1 = 2.Please help me.Points will be rewarded.

With Regards

Vijay

SELECT-OPTIONS: p1 FOR v_p1 OBLIGATORY.

FORM determine_power_cost USING

it_faglflext TYPE faglflext

v_gjahr TYPE gjahr

CHANGING lv_success_flag TYPE c.

DATA : lv_plant_maint_flag.

CLEAR lv_plant_maint_flag.

IF ( it_faglflext-rcntr EQ '0000360101'

OR it_faglflext-rcntr LE '0000360111')

OR ( it_faglflext-rcntr EQ '0000360301'

OR it_faglflext-rcntr LE '0000360304').

IF ( it_faglflext-racct EQ '0000332000' )

OR ( it_faglflext-racct EQ '0000332200' )

OR ( it_faglflext-racct EQ '0000332100' )

OR ( it_faglflext-racct EQ '0000332300' ).

IF it_faglflext-ryear = v_gjahr."v_next_year.

t_power_cost_p2-power_cost_p2_apr

= t_power_cost_p2-power_cost_p2_apr + it_faglflext-hsl01.

t_power_cost_p2-power_cost_p2_may

= t_power_cost_p2-power_cost_p2_may + it_faglflext-hsl02.

t_power_cost_p2-power_cost_p2_jun

= t_power_cost_p2-power_cost_p2_jun + it_faglflext-hsl03.

t_power_cost_p2-power_cost_p2_jul

= t_power_cost_p2-power_cost_p2_jul + it_faglflext-hsl04.

ENDIF.

ENDIF.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,017

Hi,

Yes you can use CASE. I guess this is the best practice...

Rgds,

Bujji

9 REPLIES 9
Read only

Former Member
0 Likes
1,017

Hi,

SELECT-OPTIONS: p1 FOR v_p1 OBLIGATORY.

RANGES:r1 for v_p1.

At selection-screen output.

read table p1 index 1.

r1-sign = 'I'.

r1-option = 'EQ'.

while p1-low LE p1-high.

r1-low = p1-low.

append r1.

p1-low = p1-low + 1.

endwhile.

Now you can use RANGES 'R1'.

Rgds,

Bujji

Read only

0 Likes
1,017

hi bujji

i understood most of it.Please tell me how to use the R1 now.Is dat like below am mentioning.Please coorect meif am wrong.Or should i use CASE condiotion.Please help.

Vijay

if R1 = 1.

t_power_cost_p2-power_cost_p2_apr

= t_power_cost_p2-power_cost_p2_apr + it_faglflext-hsl01.

endif.

if R1 = 2.

t_power_cost_p2-power_cost_p2_may

= t_power_cost_p2-power_cost_p2_may + it_faglflext-hsl02.

endif.

if R1 = 3.

t_power_cost_p2-power_cost_p2_jun

= t_power_cost_p2-power_cost_p2_jun + it_faglflext-hsl03.

endif.

if R1 = 4.

t_power_cost_p2-power_cost_p2_jul

= t_power_cost_p2-power_cost_p2_jul + it_faglflext-hsl04.

endif.

Read only

Former Member
0 Likes
1,018

Hi,

Yes you can use CASE. I guess this is the best practice...

Rgds,

Bujji

Read only

0 Likes
1,017

Hi bujji

If am using IF or CASEit is coming as R1.If u dont mind can u tell me exactly where should i add the piece of the code that u gave me .If u can write it in the code that i posted.it will be great use to me

Vijay

Read only

0 Likes
1,017

Hi bujji

If am using IF or CASE it is coming as R1 is unknown.If u dont mind can u tell me exactly where should i add the piece of the code that u gave me .If u can write it in the code that i posted.it will be great use to me

Vijay

Read only

Former Member
0 Likes
1,017

Hi,

Check the below code....

Loop at R1.

CASE R1-low.

WHEN 1.

t_power_cost_p2-power_cost_p2_apr

= t_power_cost_p2-power_cost_p2_apr + it_faglflext-hsl01.

WHEN 2.

t_power_cost_p2-power_cost_p2_may

= t_power_cost_p2-power_cost_p2_may + it_faglflext-hsl02.

WHEN 3.

t_power_cost_p2-power_cost_p2_jun

= t_power_cost_p2-power_cost_p2_jun + it_faglflext-hsl03.

WHEN 4.

t_power_cost_p2-power_cost_p2_jul

= t_power_cost_p2-power_cost_p2_jul + it_faglflext-hsl04.

when others.

Endloop.

Rgds,

Bujji

Read only

0 Likes
1,017

Hi Bujji

It is coming as R1 is unknown.And also int CASE condotion we are mentioning only R1-low what about values of R1-HIGH and also values between R1-LOW and R1-HIGH.If it covers then fine.Orelse pleae address my doubt.Thanks a lot for taking your time and supporting me.

Vijay

Read only

Former Member
0 Likes
1,017

Hi,

R1 is the ranges what we need to define like below..

RANGES:R1 FOR v_p1.

Next we are initialising the R1 with P1. So as per our code R1 has all the low values, not high. Go with that code, still if you have any doubts then post your doubts.

Rgds,

Bujji

Read only

0 Likes
1,017

Hi bujji

AM getting evrything fine.But one small proiblem.IF i am giving input from 1 and 4 say.And the first time am not getting any values but the second time it showing me value.Please help.

Vijay