2009 Mar 19 2:06 PM
I have a code that add the amount from period 1 up to period 16 to get the total
"determines what periods have been requested and sums them accordingly
LOOP AT s_perio INTO wa_perio.
IF wa_perio+6(3) = space.
w_low = wa_perio+3(3).
w_high = wa_perio+3(3).
ELSE.
w_low = wa_perio+3(3).
IF wa_perio+6(3) = 12.
w_high = 16.
ELSE.
w_high = wa_perio+6(3).
ENDIF.
ENDIF.
ENDLOOP.
wa_times-sign = c_sign.
wa_times-option = c_option_bt.
wa_times-low = w_low.
wa_times-high = w_high.
APPEND wa_times TO times.
ADD st_linerec-wog001 THEN st_linerec-wog002 UNTIL st_linerec-wog016
GIVING w_total ACCORDING TO times.Now i want to change the code from add then until... to ASSIGN and INCREMENT (since the first one is not used in classes, an obsolete statement). Am i supposed to use field symbol? and i'm not sure how to use INCREMENT for it.
Thanks.
2009 Mar 19 2:28 PM
Try this way
v_int = times-low.
do.
concatenate 'ST_LINEREC-WOG' v_int into v_field.
condense v_field no-gaps.
assign (v_field) to <fs>
w_total = w_total + <fs>.
if times-high eq v_int.
exit.
endif.
v_int = v_int + 1.
enddo.
a®
I have a code that add the amount from period 1 up to period 16 to get the total
"determines what periods have been requested and sums them accordingly
LOOP AT s_perio INTO wa_perio.
IF wa_perio+6(3) = space.
w_low = wa_perio+3(3).
w_high = wa_perio+3(3).
ELSE.
w_low = wa_perio+3(3).
IF wa_perio+6(3) = 12.
w_high = 16.
ELSE.
w_high = wa_perio+6(3).
ENDIF.
ENDIF.
ENDLOOP.
wa_times-sign = c_sign.
wa_times-option = c_option_bt.
wa_times-low = w_low.
wa_times-high = w_high.
APPEND wa_times TO times.
ADD st_linerec-wog001 THEN st_linerec-wog002 UNTIL st_linerec-wog016
GIVING w_total ACCORDING TO times.Now i want to change the code from add then until... to ASSIGN and INCREMENT (since the first one is not used in classes, an obsolete statement). Am i supposed to use field symbol? and i'm not sure how to use INCREMENT for it.
Thanks.
2009 Mar 19 2:28 PM
Try this way
v_int = times-low.
do.
concatenate 'ST_LINEREC-WOG' v_int into v_field.
condense v_field no-gaps.
assign (v_field) to <fs>
w_total = w_total + <fs>.
if times-high eq v_int.
exit.
endif.
v_int = v_int + 1.
enddo.
a®
2009 Mar 19 2:53 PM
Hi a®s, when i tried your code. It says times is not a table with header line. This is how i declare times
DATA: times TYPE RANGE OF index,
wa_times LIKE LINE OF times.
2009 Mar 19 2:58 PM
Try this way
read table times into wa_times index 1.
v_int = wa_times-low.
do.
concatenate 'ST_LINEREC-WOG' v_int into v_field.
condense v_field no-gaps.
assign (v_field) to <fs>
w_total = w_total + <fs>.
if wa_times-high eq v_int.
exit.
endif.
v_int = v_int + 1.
enddo.
a®
2009 Mar 19 3:08 PM
It gaves msg "Field symbol is not assigned" ,a®s
this is how i applied your code in mine.
FIELD-SYMBOLS <fs> TYPE ANY.
DATA v_int(3) type c.
DATA v_field(17) type C.
read table times into wa_times index 1.
v_int = wa_times-low.
do.
concatenate 'ST_LINEREC-WOG' v_int into v_field.
condense v_field no-gaps.
assign (v_field) to <fs>.
w_total = w_total + <fs>.
if wa_times-high eq v_int.
exit.
endif.
v_int = v_int + 1.
enddo.maybe the problem comes from the declaration part?
2009 Mar 19 4:31 PM
I think v_field not getting proper values
ST_LINEREC-WOG003 i think it getting as ST_LINEREC-WOG3
Try to change this way
field-symbols <fs> type any.
data v_int type i. "<<
data : v_cint(3) type c. "<<
data v_field(17) type c.
data: times type range of index,
wa_times like line of times.
read table times into wa_times index 1.
v_int = wa_times-low.
do.
unpack v_int to v_cint.. "<<
concatenate 'ST_LINEREC-WOG' v_cint into v_field.
condense v_field no-gaps.
assign (v_field) to <fs>.
w_total = w_total + <fs>.
if wa_times-high eq v_int.
exit.
endif.
v_int = v_int + 1.
enddo.
a®
2009 Mar 19 5:02 PM
2009 Mar 19 2:31 PM
Hi,
try this.
w_total = w_total + : st_linerec-wog001,
st_linerec-wog002,
st_linerec-wog003,
st_linerec-wog004,
st_linerec-wog005,
st_linerec-wog006,
st_linerec-wog007,
st_linerec-wog008,
st_linerec-wog009,
st_linerec-wog010,
st_linerec-wog011,
st_linerec-wog012,
st_linerec-wog013,
st_linerec-wog014 ,
st_linerec-wog015,
st_linerec-wog016 .
2009 Mar 19 2:48 PM
Hi Sreesudha , thank you for your suggestion but your code will always sum all period no matter what the period the user enter on selection screen.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |