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

Calculate

Former Member
0 Likes
354

Hi all

In the below code u can see the calculations from jan to feb.My doubt is in the select options if give 1 to 6

I need to pick values from jan to june value.If am using directly

the IF condition or the CASE condition only one value is coming.But i want calculaion of the ranges from 1 to 6 i.e:from jan to feb.Please go thru the code u will hav a much more better understanding

VIjay

DATA:v_p1 TYPE i.

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_p1-power_cost_p1_jan

= t_power_cost_p1-power_cost_p1_jan + it_faglflext-hsl10.

t_power_cost_p1-power_cost_p1_feb

= t_power_cost_p1-power_cost_p1_feb + it_faglflext-hsl11.

t_power_cost_p1-power_cost_p1_mar

= t_power_cost_p1-power_cost_p1_mar + it_faglflext-hsl12

+ it_faglflext-hsl13 + it_faglflext-hsl14

+ it_faglflext-hsl15 + it_faglflext-hsl16.

IF it_faglflext-ryear EQ v_gjahr.

t_power_cost_p1-power_cost_p1_apr

= t_power_cost_p1-power_cost_p1_apr + it_faglflext-hsl01.

t_power_cost_p1-power_cost_p1_may

= t_power_cost_p1-power_cost_p1_may + it_faglflext-hsl02.

t_power_cost_p1-power_cost_p1_jun

= t_power_cost_p1-power_cost_p1_jun + it_faglflext-hsl03.

t_power_cost_p1-power_cost_p1_jul

= t_power_cost_p1-power_cost_p1_jul + it_faglflext-hsl04.

t_power_cost_p1-power_cost_p1_aug

= t_power_cost_p1-power_cost_p1_aug + it_faglflext-hsl05.

t_power_cost_p1-power_cost_p1_sep

= t_power_cost_p1-power_cost_p1_sep + it_faglflext-hsl06.

t_power_cost_p1-power_cost_p1_oct

= t_power_cost_p1-power_cost_p1_oct + it_faglflext-hsl07.

t_power_cost_p1-power_cost_p1_nov

= t_power_cost_p1-power_cost_p1_nov + it_faglflext-hsl08.

t_power_cost_p1-power_cost_p1_dec

= t_power_cost_p1-power_cost_p1_dec + it_faglflext-hsl09.

ENDIF.

ENDIF.

ENDFORM.

Hi all

In the below code u can see the calculations from jan to feb.My doubt is in the select options if give 1 to 6

I need to pick values from jan to june value.If am using directly

the IF condition or the CASE condition only one value is coming.But i want calculaion of the ranges from 1 to 6 i.e:from jan to feb.Please go thru the code u will hav a much more better understanding

VIjay

DATA:v_p1 TYPE i.

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_p1-power_cost_p1_jan

= t_power_cost_p1-power_cost_p1_jan + it_faglflext-hsl10.

t_power_cost_p1-power_cost_p1_feb

= t_power_cost_p1-power_cost_p1_feb + it_faglflext-hsl11.

t_power_cost_p1-power_cost_p1_mar

= t_power_cost_p1-power_cost_p1_mar + it_faglflext-hsl12

+ it_faglflext-hsl13 + it_faglflext-hsl14

+ it_faglflext-hsl15 + it_faglflext-hsl16.

IF it_faglflext-ryear EQ v_gjahr.

t_power_cost_p1-power_cost_p1_apr

= t_power_cost_p1-power_cost_p1_apr + it_faglflext-hsl01.

t_power_cost_p1-power_cost_p1_may

= t_power_cost_p1-power_cost_p1_may + it_faglflext-hsl02.

t_power_cost_p1-power_cost_p1_jun

= t_power_cost_p1-power_cost_p1_jun + it_faglflext-hsl03.

t_power_cost_p1-power_cost_p1_jul

= t_power_cost_p1-power_cost_p1_jul + it_faglflext-hsl04.

t_power_cost_p1-power_cost_p1_aug

= t_power_cost_p1-power_cost_p1_aug + it_faglflext-hsl05.

t_power_cost_p1-power_cost_p1_sep

= t_power_cost_p1-power_cost_p1_sep + it_faglflext-hsl06.

t_power_cost_p1-power_cost_p1_oct

= t_power_cost_p1-power_cost_p1_oct + it_faglflext-hsl07.

t_power_cost_p1-power_cost_p1_nov

= t_power_cost_p1-power_cost_p1_nov + it_faglflext-hsl08.

t_power_cost_p1-power_cost_p1_dec

= t_power_cost_p1-power_cost_p1_dec + it_faglflext-hsl09.

ENDIF.

ENDIF.

ENDFORM.

1 REPLY 1
Read only

Former Member
0 Likes
325

Hi Vivay,

First of all, I don´t understand why you use 4 IF-statements when you can do it with 2. You should concatenate the first 2 and I don´t see any difference between the latter 2.

Regarding your question: it_faglflext is an internal table and each record only contains one value, so you should loop at the internal table and do the logic you implemented for every record of that internal table.

I hope this helps!