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

Checking Work area

Former Member
0 Likes
853

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 .....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
576

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.

2 REPLIES 2
Read only

Former Member
0 Likes
577

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.

Read only

former_member186741
Active Contributor
0 Likes
576

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.