‎2008 Jul 25 10:11 AM
Hi Gurus,
I have a internal table which has these content in store
ITEM VENDOR PAYMENT DATE TAX RATE AMOUNT
001 810000 01.07.2008 1% 2500
002 810000 01.07.2008 1% 3600
003 810000 01.07.2008 2% 3000
004 810000 02.07.2008 2% 320
005 810000 02.07.2008 2% 900
006 810000 02.07.2008 3% 2000
007 810001 02.07.2008 2% 4000
008 810001 02.07.2008 2% 1000
If the table content has the same vendor , payment date and tax rate. the content of these records should be combined. and others dont need. the content for new internal table should be
ITEM VENDOR PAYMENT DATE TAX RATE AMOUNT
001 810000 01.07.2008 1% 6100
002 810000 01.07.2008 2% 3000
003 810000 02.07.2008 2% 320
004 810000 02.07.2008 2% 900
005 810000 02.07.2008 3% 2000
006 810001 02.07.2008 2% 5000
the first 2 rows are combined and the amount is calculated to the total amount of item 1 and 2. same as the last 2 rows.
can anyone tell me how to achieve it?
regards,
Samson
‎2008 Jul 25 11:23 AM
Hi Samson,
Please understand and change the fields according to your requirement. This will get the issue resolved. This is for one field which I have done. For three fields declare three temporary variables.
LOOP AT t_customer INTO fs_customer.
IF w_temp ne fs_customer-cusnum.
WRITE :/ fs_customer-cusnum UNDER text-001,
fs_customer-cusname UNDER text-002.
w_amt = fs_customer-amount.
ELSE.
w_amt = w_amt + fs_customer-amount.
WRITE: 45 w_amt.
ENDIF. " IF W_TEMP <> FS_CUSTOMER-...
w_temp = fs_customer-cusnum.
ENDLOOP. " LOOP AT T_CUSTOMER....Regards,
Swapna.
‎2008 Jul 25 10:13 AM
‎2008 Jul 25 10:17 AM
‎2008 Jul 25 10:13 AM
Hi
We can use the COLLECT statment
Ex:
here the Cusotmer number is same -
CLEAR fs_customer. " Clears Header line
fs_customer-num = 'C002'.
fs_customer-name = 'MIKE'.
fs_customer-amount = 2000.
APPEND fs_customer TO t_customer. " Adds a record to Internal table
**Record 3**
CLEAR fs_customer.
fs_customer-num = 'C003'.
fs_customer-name = 'ARNOLD'.
fs_customer-amount = 2000.
APPEND fs_customer TO t_customer.
**Record 4**
CLEAR fs_customer. " Clears Header line
fs_customer-num = 'C002'.
fs_customer-name = 'MIKE'.
fs_customer-amount = 2000.
COLLECT fs_customer INTO t_customer. " Adds Data to Existing Field
Thanks & Regards,
Chandralekha.
‎2008 Jul 25 10:15 AM
hi,
COLLECT statement can be used only when all non key fileds are numeric. It adds all the non key numeric fields.
Regards
Sumit Agarwal
‎2008 Jul 25 10:17 AM
Hi,
just do m2 steps
step 1: make sure that your 1st and 2nd col are of datatype c
or p or n.
step2 use COLLECT STATEMENT.
For details check the link
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/content.htm
Regards,
Anirban
‎2008 Jul 25 10:17 AM
If U don't have the field ITEM(first field) then U can use
COLLECT statement ..
‎2008 Jul 25 10:18 AM
hi
frist sort the table like this
let tha table is ITAB
the n
sort ITAB by field vendor , payment date and tax rate.
now apply loop on this internal table and
inside this loop
use AT NEW or ON change Statement on fields vendor , payment date and tax rate.
Hope this will lead u to solution
Cheers
Snehi
‎2008 Jul 25 11:23 AM
Hi Samson,
Please understand and change the fields according to your requirement. This will get the issue resolved. This is for one field which I have done. For three fields declare three temporary variables.
LOOP AT t_customer INTO fs_customer.
IF w_temp ne fs_customer-cusnum.
WRITE :/ fs_customer-cusnum UNDER text-001,
fs_customer-cusname UNDER text-002.
w_amt = fs_customer-amount.
ELSE.
w_amt = w_amt + fs_customer-amount.
WRITE: 45 w_amt.
ENDIF. " IF W_TEMP <> FS_CUSTOMER-...
w_temp = fs_customer-cusnum.
ENDLOOP. " LOOP AT T_CUSTOMER....Regards,
Swapna.