‎2007 Nov 28 9:56 AM
Hi experts,
Im new to ABAP. I have probelm with my internal table. Consider the following example.
My First Internal Table following structure and Data's.
Mat_name Qty Unit_Price
Pen 5 6.00
Pencil 2 3.00
In second Internal table structure is,
Mat_name Qty Unit_Price Net_price
My requirement is I need to calculete the net_price using Qty and Unit_price.
For material Pen ( 5 * 6.00 ) = 30.00(net_price).
So my Final internal table datas sholud be stored like,
Mat_name Qty Unit_Price Net_price
Pen 5 6.00 30.00
Pencil 2 3.00 6.00
How can I do that. Any body give me your valuable suggestions.
Thanks,
Points assured.
‎2007 Nov 28 10:02 AM
hi
first of all ,
<b>move itab1 to itab2</b> after that
<b>loop at itab2
itab2-netprice = ( itab2-qty * itab2-price)
modify itab index sy-tabix
endloop.</b>
‎2007 Nov 28 9:59 AM
HI,
LOOP AT first_itab INTO struct1.
struct2-matname = struct1-matname.
struct2-qty = struct1-qty.
struct2-netprice = struct1-unit * struct1-qty.
append struct2 TO second_itab.
clear struct2.
ENDLOOP.rgs
‎2007 Nov 28 10:00 AM
Hi.. use this
Loop at itab1.
wa_itab2-mat = itab1-mat.
wa_itab2-qunt = itab1-qunt.
wa_itab2-unitp = itab1-unitp.
wa_itab2-netp = itab1-qunt * itab1-unitp.
append wa_itab2 to itab2.
clear wa_itab2.
endloop.
‎2007 Nov 28 10:00 AM
loop at itab.
itab_new-name = itab-name.
itab_new-qty = itab-gty.
itab_new-unit = itab-unit.
itab_new -net = itab-unit * itab-gty.
append itab_new .
clear itab_new.
endloop.
‎2007 Nov 28 10:00 AM
if ur itab is already populated with all other fields except net_price....the use...
loop at itab.
itab-Net_price = itab-qty * itab-unit_price.
modify itab index sy-tabix.
endloop.
‎2007 Nov 28 10:02 AM
hi
first of all ,
<b>move itab1 to itab2</b> after that
<b>loop at itab2
itab2-netprice = ( itab2-qty * itab2-price)
modify itab index sy-tabix
endloop.</b>
‎2007 Nov 28 10:05 AM
Hi,
Thanks for the replies.
My Internal tables don't have the header line.
That is the probelm.
Thanks.
‎2007 Nov 28 10:09 AM
loop at itab1 into wa.
wa-net_price = ( wa_qty * wa-unit_price ).
modify itab index sy-tabix from wa.
endloop.
‎2007 Nov 28 10:12 AM
Hi
declare work areas for both internal tables n use this code
Loop at itab1 into wa_itab1.
wa_itab2-mat = wa_itab1-mat.
wa_itab2-qunt = wa_itab1-qunt.
wa_itab2-unitp = wa_itab1-unitp.
wa_itab2-netp = wa_itab1-qunt * wa_itab1-unitp.
append wa_itab2 to itab2.
clear wa_itab2,wa_itab1.
endloop.
<b>please reward if helpful</b>
‎2007 Nov 28 10:03 AM
Hi,
loop at itab into wa.
wa-net_price = wa-qty * wa-unit_price.
append wa-net_price to itab.
endloop.
rewards if useful
kavitha
‎2007 Nov 28 10:03 AM
Hi,
follow the sample code.
loop at itab1.
itab2-Mat_name = itab1-Mat_name.
itab2-Qty = itab1-Qty.
itab2-Unit_Price = itab1-Unit_price.
itab2-Net_price = itab1-Unit_price * itab1-Qty.
append itab2.
clear: itab1,
itab2.
endloop.
loop at itab2.
write:/ itab2-Mat_name,
itab2-Qty,
itab2-Unit_Price,
itab2-Net_price,
clear itab2.
endloop.
pls reward if needful.
Thanks,
Sreeram.
‎2007 Nov 28 10:05 AM
Hi Jasmine,
Let the first Internal table be itab1 and second one be itab2
Code:
DATA: wa_itab LIKE LINE OF itab2.
LOOP AT itab1 INTO wa_itab.
wa_itab-Net_price = wa_itab-Qty * wa_itab-Unit_Price.
INSERT wa_itab INTO TABLE itab2.
END LOOP.
Thanks
Ravi
‎2007 Nov 28 10:07 AM
Hi,
Check this simple program..
DATA : BEGIN OF itab OCCURS 100,
matnr type eban-matnr,
menge type eban-menge,
price(10) type p decimals 2,
END OF itab.
DATA : BEGIN OF itab2 OCCURS 100,
matnr type eban-matnr,
menge type eban-menge,
price(10) type p decimals 2,
total(10) type p decimals 2,
END OF itab2.
itab-matnr = 'PEN'.
itab-menge = '5'.
itab-price = '6.00'.
APPEND itab.
itab-matnr = 'PENCIL'.
itab-menge = '2'.
itab-price = '3.00'.
APPEND itab.
LOOP AT itab.
itab2-total = itab-menge * itab-price .
MOVE-CORRESPONDING itab to itab2.
APPEND itab2.
ENDLOOP.
‎2007 Nov 28 10:13 AM
Hi jasmine,
Loop at first_int_table.
second_int_table-mat_name = first_int_table-mat_name.
second_int_table-qty = first_int_table-qty.
second_int_table-unit_price = first_int_table-unit_price.
second_int_table-net_price = first_int_table-qty * first_int_table-unit_price.
ENDLOOP.
loop at second_int_table.
write:/ second_int_table-mat_name ,
second_int_table-qty,
second_int_table-unit_price.
second_int_table-net_price.
endloop.