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
373

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
357

Hi vijay krishna,

See this example code for select-options you can use like this code in your programm.

Ex:

>DATA num TYPE i.

>

>DATA num1(30).

>

>SELECT-OPTIONS p1 FOR num.

>

>

>LOOP AT p1.

> DO.

> IF sy-index IN p1.

> write / sy-index.

> ELSE.

> EXIT.

> ENDIF.

>ENDDO.

>ENDLOOP.

Plzz reward if it is useful,

Mahi.

2 REPLIES 2
Read only

Former Member
0 Likes
358

Hi vijay krishna,

See this example code for select-options you can use like this code in your programm.

Ex:

>DATA num TYPE i.

>

>DATA num1(30).

>

>SELECT-OPTIONS p1 FOR num.

>

>

>LOOP AT p1.

> DO.

> IF sy-index IN p1.

> write / sy-index.

> ELSE.

> EXIT.

> ENDIF.

>ENDDO.

>ENDLOOP.

Plzz reward if it is useful,

Mahi.

Read only

Former Member
0 Likes
357

Hi Vijay

Do you have a master table from where you can get the values of p1.

As an example ....lets say i have a select option for plant: so_werks for marc-werks.

Now i enter on my selection screen plant as 1000 to 3000 . So for this low and high values , i will query the master table T001W to get all the plants between 1000 and 3000 into an internal table say gt_werks.

select werks

into table gt_werks

from t001w

where werks GE so_werks-low

and werks LE so_werks-high.

I will be processing this table further for all these plants obtained.

Do you have a similar situation?

cheers

shivika