‎2008 Apr 29 5:40 AM
Hi Experts,
here i ve a problem like, in my table there are 3 PSPHI(projects) values,
if i loop n calculate the sum it is getting total amt for 3 PSPHI values,
but i want every end of PSPHI i need sum.
the below code is working fine if there is no AT coomand, if i put AT END OF PSPHI it is giving 00.00 values.
LOOP AT it_final into it_output.
AT END OF PSPHI.
if it_final-wrttp = '04'
AND it_final-vorga = 'COIN'
AND it_final-beltp = '02'
AND it_final-versn = '000'.
t_pla_rev = t_pla_rev + it_output-wlp01.
MOVE it_output-wlp01 TO pla_rev.
sum = sum + pla_rev.
if sy-subrc EQ 0.
else.
write:/10 ' u r not ok'.
endif.
e ndif.
append it_output.
*ENDAT.
ENDLOOP.
write:/10 'total amt is', sum.
could anybady check where i gone wrong pls...
Thanks in advance,
sudharsan.
‎2008 Apr 29 6:00 AM
Hi ,
Please use the READ :-
loop...
at end of psph.
read table itab into wa index sy-tabix.
do ur operation like sum.
endat.
endloop.
Because 'at' events the work area numeric values becomes 000...
‎2008 Apr 29 6:04 AM
Hi Sudharshan,
use AT END OF after completion of validations (if statement and all ).
AT END OF PSPHI.
SUM.
WRITE: / XXXX.
ENDAT.
Regards,
Narasimha
‎2008 Apr 29 6:07 AM
Hi,
at end of field statement works well if the field u specify is thee first field of the int-table....
if say the specified field is the 3rd field..... at end of field3 is equal to at end of field1,field2,field3 combo...........
try putting ur PSPHI fld as first field of itab....
Cheers,
jose.
‎2008 Apr 29 6:07 AM
‎2008 Apr 29 6:12 AM
Hi,
What is your table structure.
The command AT ........ENDAT work in sequential order.
Let me explain with example.
if your table itab has two column column1 and column2
loop at itab into wa.
at new column2.
// This will execute when the Value of column 1 change or column2
// change.
endat.
endlloop.
The solution of your problem is.
Change your internal table column order ,
Put the column first for which you want to calculate the sum.
Thanks & Regards
Kulvendra Kumar
‎2008 Apr 29 6:45 AM
Hi Friends,
thank u very much for ur replays,
here my table structure is: suppose there
are col1,col2,col,col4,......
( here my dought is which one can i use either AT NEW or AT END OF )
loop at itab into wa.
at new col2.
( here i want to use CASE cond for checking for period.)
CASE month.
if month = '01'.
here i want to sum(col4 values).
endif.
endcase.
endat.
endloop.
i want to do like above, could anybady explain how to procede..
Thanks in advance,
sudharssn.
‎2008 Apr 29 7:19 AM
‎2008 Apr 29 7:38 AM
Hi,
your internal table structure to be in such a way that the first field should be PSPHI and before looping this table sort the internal table on the field PSPHI and then use the loop and at end of PSPHI for summing the values then it will work.
Regards,
Ramesh
*Award points if answer is helpful