2006 Oct 26 5:05 AM
Hi All ...
In My work area tehre are 40 fields out of which 12 fields contains the sales of a material in past 12 months....I need to calculate number of months from this work area with sales figures...
Lets us say there is sales only in 4 months....
so i need to sum the total sales and then divide it by the number of months with the sales figures in it ...
How can i do it? without checkin gthe inbdividual fields and increment variable....
Thanks in advance .....
2006 Oct 26 5:16 AM
You can use field-symbols. If field name is similar like z1, z2, z3...etc then construct fiel-name and assign it to field-symbol and then you can check it inside loop for 12 months.
Hi All ...
In My work area tehre are 40 fields out of which 12 fields contains the sales of a material in past 12 months....I need to calculate number of months from this work area with sales figures...
Lets us say there is sales only in 4 months....
so i need to sum the total sales and then divide it by the number of months with the sales figures in it ...
How can i do it? without checkin gthe inbdividual fields and increment variable....
Thanks in advance .....
2006 Oct 26 5:16 AM
You can use field-symbols. If field name is similar like z1, z2, z3...etc then construct fiel-name and assign it to field-symbol and then you can check it inside loop for 12 months.
2006 Oct 26 5:21 AM
the best way to frame a question is to show the abap. Otherwise we arwe gussing what you structure looks like and may misunderstand you. Why didn't you put the data declarion in the question?
aNYWAY, I am guessing that it's something like:
data: begin of work,
........
month_tot1 like bseg-wrbtr,
month_tot2 like bseg-wrbtr,
month_tot3 like bseg-wrbtr,
month_tot4 like bseg-wrbtr,
.....
end of workarea.
field-symbols <tot> type bseg-wrbtr.
data: total like bseg-wrbtr,counter like sy-index
data: AVG like bseg-wrbtr,counter like sy-index.
data fname(30).
CLEAR: TOTAL,COUNTER,AVG.
do 12 TIMES.
concatenate 'WORK-MONTH_TOT' SY-INDEX INTO FNAM.
assigN (FNAM) TO <TOT>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
IF <TOT> <> 0.
ADD 1 TO COUNTER.
ADD <TOT> TO TOTAL.
ENDIF.
enddo.
IF COUNTER <> 0.
AVG = TOTAL / COUNTER.
ENDIF.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |