‎2007 Jun 12 6:01 AM
Hi All,
I have an internal table which has following values:
Project Indicator Cost
P001 I 10000
P001 I 20000
P001 D 500
P001 D 1000
P002 I 2000
P002 I 1000
I need to do a processing in such a way that i get following data in another internal table.
Project Indicator Cost
P001 I 30000
P001 D 1500
P002 I 3000
How do I achieve this ?
Regards,
Satya
‎2007 Jun 12 6:04 AM
Hi,
You can create a new internal table with just the three fields and then use COLLECT to sum up the records..
LOOP AT ITAB INTO WA.
* move the values.
WA_COLLECT-PROJECT = WA-PROJECT.
WA_COLLECT-INDICATOR = WA-INDICATOR.
WA_COLLECT-COST = WA-COST.
* Use collect.
COLLECT WA_COLLECT TO ITAB_COLLECT.
ENDLOOP.
* Now the values will be consolidated based on project and indicator..
Thanks,
Naren
‎2007 Jun 12 6:03 AM
append the all the records to internal table then use delete adjacent duplicates command.
‎2007 Jun 12 6:04 AM
Hi,
You can create a new internal table with just the three fields and then use COLLECT to sum up the records..
LOOP AT ITAB INTO WA.
* move the values.
WA_COLLECT-PROJECT = WA-PROJECT.
WA_COLLECT-INDICATOR = WA-INDICATOR.
WA_COLLECT-COST = WA-COST.
* Use collect.
COLLECT WA_COLLECT TO ITAB_COLLECT.
ENDLOOP.
* Now the values will be consolidated based on project and indicator..
Thanks,
Naren
‎2007 Jun 12 6:05 AM
hi Satya,
do this way ..
sort itab by project indicator.
loop at itab.
at new project.
sum.
it_final-project = itab-project.
it_final-indicator = itab-indicator.
append it_final.
clear : it_final, itab..
endloop.
‎2007 Jun 12 6:06 AM
HI Satya ,
Use the collect statement.
The code will look some thing like this
Loop at it_1 into wa_1.
collect wa_1 into it_2.
endloop.Hope this helps.
Regards
Arun
‎2007 Jun 12 6:06 AM
hi satya,
welcome to sdn,
use <b>collect</b> statement in loop to calcualte project related costs,
reward points if helpful,
regards,
seshu.
‎2007 Jun 12 6:07 AM
Hi
Write
sort itab by project indicator.
Loop at ITAB.
at end of indicator.
read table itab index sy-tabix.
sum.
move-corresponding itab to itab1.
append itab1.
endat.
clear itab1.
endloop
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Jun 12 6:07 AM
sort itab1 by firstfieldname secondfieldname
loop at itab1 into wa1
amount = amount + wa1-thirdfield name .
at end of second field name .
wa2-thirdfield name = amount.
append wa2 to itab2 .
clear amount.
end at.
endloop.
itab2 will contains the required entires
‎2007 Jun 12 6:10 AM
Hi,
for this You can use collect statement,write collect on abap editor and press F1 help, u will get it.
regards,
sudha
‎2007 Jun 12 6:14 AM
use the below logic for you display
sort you itab so that the sequence will be there
sort itab by PROJECT INDICATOR.
LOOP AT ITAB .
*****for new Project based on sorting .
Atnew PROJECT .
Endat .
Atend INDICATOR.
***** Total will be done on indicator Using sum
SUM .
final-PROJECT = WA-PROJECT.
final -INDICATOR = WA-INDICATOR.
final -COST = WA-COST.
Endat
****appending in new table
Append final .
ENDLOOP.
****DIsplay Output
LOOP AT FINAL.
WRITE : / final-PROJECT ,final -INDICATOR ,final -COST .
ENDLOOP.
Girish
‎2007 Jun 12 6:21 AM
Hi,
<b>fallow the fallowing steps</b>
1. first sort the internal table (sort).
2.then based on previous value check with current value.
ex: take some temp workarea and store 1st record , when internal table workarea is holding the value of 2nd record then compare those records....... if both char datatype values are same then add the integer types.( equal operator ).
3. store those new value into an new internal table.(append).
4. loop that new internal table . then U will get the acctual result (loop).
don't forget to give points of itis usefill for U.