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

calculating

Former Member
0 Likes
1,135

Hi All,

How can I implement this logic with abap ?


PNR PL  P.Suba  ROOT-ID   ORGEH     HJ  Quota
200	0001	0001	00012128	00012128	02	81
210	0001	0001	00012128	00012128	02	34
515	0001	0001	00012128	00012128	02	64
551	0001	0001	00012128	00012128	02	80
829	0001	0001	00011256	00011256	02	72
843	0001	0001	00011256	00011256	02	92

in order to calculate OSHA it is necessary

to operate as follows:

1. Finding out number of personal per ORGEH
2. Add up the quoatas per ORGEH
   e.g.  ORGEH 00011256 = (72 + 92) / 100 
         Result =         1.62

Pls can somebody help me to perform above

shown logic with abap

Regards

ertas

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,116

Loop at data

w_total = w_total + data-quato_value

at end of ORGEH.

w_res = w_total / 100.

endat.

endloop.

10 REPLIES 10
Read only

Former Member
0 Likes
1,117

Loop at data

w_total = w_total + data-quato_value

at end of ORGEH.

w_res = w_total / 100.

endat.

endloop.

Read only

0 Likes
1,116

Its a field to accumulate the values that you are adding, (72 + 92 for example).

Read only

Former Member
0 Likes
1,116

what do you mean with w_total ?

regards

ertas

Read only

Former Member
0 Likes
1,116

HI,

First move the data into one more table in that ORGEH should be the first field

declaretiong of temp_table.
same as current_table but ORGEH will be the first field
loop at current_table.
 move-corresponding current_table into temp_table.
append temp_table.
endloop.

sort temp_table by orgeh.

loop at temp_table.
 add the quotas.
at end of orgeh.
 quota = quota / 100.
endat.
endloop..

Read only

Former Member
0 Likes
1,116

hi Ertas,

First create a internal table with first field ORGEH then other fields.

use events At new

At NEW ORGEH.

loop at IT_tab.

v_total = wa_tab-Quota+v_total.

wa_finaloutput-Quota = v_tatal.

append wa_finaloutput to IT_finaloutput.

endloop.

end at .

Read only

0 Likes
1,116

Kumar At NEW ist allowed only within LOOP

Read only

0 Likes
1,116

without a loop u cannot acheive this..

There is multiple records

Read only

Former Member
0 Likes
1,116

Hi ,

do the following

consider all these records are in internal table itab.

U can first declare another internal table itab1 simialr to itab with one more field precent.

Loop at itab.

Itab1-pl = itab-pl.

Itab1-p.suba = itab-p.suba

Itab1-root-id = itab-root-id.

Itab1-orgeh = itab-orgeh.

Itab1-hj = itab-hj

Itab1-quota = itab-quota.

Collect itab1.----


instead of append u can use collect. So it will add 72 and 92.

Clear itab1.

Endloop.

Loop at itab1.

Wa_precent = itab1-quota / 100.

Itab1-persent = wa_precent.

Modify itab-precent index sy-tabix.

Clear itab1.

Endloop.

reward if useful.

diana.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,116

say F1 , F2 as last two fields of ur list

put ORGEH as first field of itab.

sort itab by orgeh.

data:val1 type i.

data:val2 type i.

loop at itab

val1 = val1 + F2.

at end of orgeh.

val2 = val1 / 100.

move corresponding itab to itab1.

itab1-result = val2.

clear val2.

clear val1.

endat.

endloop.

Read only

Former Member
0 Likes
1,116

hi ,

thanks for rewarding . is yr problem solved?

regards,.

diana.