2005 Dec 22 3:49 AM
I am new to ABAP programming. Can somebody please help me out with the following program or give me some hints as to how to proceed?
1. ABAP inputs: The pgm will have following parameters:
P_ITEM - input string of 20 characters (select options)
P_QTY - input number (select options)
P_RATE - input number with 2 decimal points (select options)
2. Main processing logic:
1. Accept 5 items each with qty and rate.
2. store in internal table.
3. calculate their price.
4. sort on price in ascending order.
5. display o/p as per section 3.
3. Output format:
ITEM QTY RATE PRICE
TOTAL
Hints: For this ABAP make use of APPEND, SUM, MODIFY
Thank you.
2005 Dec 22 4:02 AM
This can be coded, but it does make much sense. There is no "tie" between the selection-screen fields. If you are assuming that the first value in P_ITEM corresponds to the first value in P_QTY and P_RATE, then you can do it, but this is not really a good way of coding. Here is a sample anyway.
Add values to all three select-options and hit execute.
report zrich_0004
no standard page heading.
data: begin of itab occurs 0,
item(20) type c,
qty type i,
rate type p decimals 2,
price type p decimals 2,
end of itab.
select-options: s_item for itab-item,
s_qty for itab-qty,
s_rate for itab-rate.
start-of-selection.
clear itab. refresh itab.
loop at s_item.
clear itab.
itab-item = s_item-low.
read table s_qty index sy-tabix.
if sy-subrc = 0.
itab-qty = s_qty-low.
endif.
read table s_rate index sy-tabix.
if sy-subrc = 0.
itab-rate = s_rate-low.
endif.
itab-price = itab-qty * itab-rate.
append itab.
endloop.
sort itab ascending by price.
loop at itab.
write:/ itab-item, itab-qty, itab-rate, itab-price.
endloop.
Welcome to SDN! Please remember to award points for helpful answers and mark your posts as solved when solved completely.
Regards,
Rich Heilman
riding piggy back on Rich's code...
report zrich_0004 no standard page heading.
data: begin of itab occurs 0,
item(20) type c,
qty type i,
rate type p decimals 2,
amount type p decimals 2,
end of itab
.
select-options: s_item for itab-item,
s_qty for itab-qty,
s_rate for itab-rate.
start-of-selection.
clear itab. refresh itab.
loop at s_item.
clear itab.
itab-item = s_item-low.
read table s_qty index sy-tabix.
if sy-subrc = 0.
itab-qty = s_qty-low.
endif.
read table s_rate index sy-tabix.
if sy-subrc = 0.
itab-rate = s_rate-low.
endif.
itab-amount = itab-qty * itab-rate.
append itab.
endloop.
loop at itab.
write:/ itab-item, itab-qty, itab-rate,itab-amount.
at last.
sum.
write:/ 'Total:', itab-amount.
endat.
endloop.
Regards,
Suresh Datti
P.S. I din't see any need to use MODIFY
2005 Dec 22 4:02 AM
This can be coded, but it does make much sense. There is no "tie" between the selection-screen fields. If you are assuming that the first value in P_ITEM corresponds to the first value in P_QTY and P_RATE, then you can do it, but this is not really a good way of coding. Here is a sample anyway.
Add values to all three select-options and hit execute.
report zrich_0004
no standard page heading.
data: begin of itab occurs 0,
item(20) type c,
qty type i,
rate type p decimals 2,
price type p decimals 2,
end of itab.
select-options: s_item for itab-item,
s_qty for itab-qty,
s_rate for itab-rate.
start-of-selection.
clear itab. refresh itab.
loop at s_item.
clear itab.
itab-item = s_item-low.
read table s_qty index sy-tabix.
if sy-subrc = 0.
itab-qty = s_qty-low.
endif.
read table s_rate index sy-tabix.
if sy-subrc = 0.
itab-rate = s_rate-low.
endif.
itab-price = itab-qty * itab-rate.
append itab.
endloop.
sort itab ascending by price.
loop at itab.
write:/ itab-item, itab-qty, itab-rate, itab-price.
endloop.
Welcome to SDN! Please remember to award points for helpful answers and mark your posts as solved when solved completely.
Regards,
Rich Heilman
2005 Dec 22 4:13 AM
riding piggy back on Rich's code...
report zrich_0004 no standard page heading.
data: begin of itab occurs 0,
item(20) type c,
qty type i,
rate type p decimals 2,
amount type p decimals 2,
end of itab
.
select-options: s_item for itab-item,
s_qty for itab-qty,
s_rate for itab-rate.
start-of-selection.
clear itab. refresh itab.
loop at s_item.
clear itab.
itab-item = s_item-low.
read table s_qty index sy-tabix.
if sy-subrc = 0.
itab-qty = s_qty-low.
endif.
read table s_rate index sy-tabix.
if sy-subrc = 0.
itab-rate = s_rate-low.
endif.
itab-amount = itab-qty * itab-rate.
append itab.
endloop.
loop at itab.
write:/ itab-item, itab-qty, itab-rate,itab-amount.
at last.
sum.
write:/ 'Total:', itab-amount.
endat.
endloop.
Regards,
Suresh Datti
P.S. I din't see any need to use MODIFY
2005 Dec 22 4:17 AM
2005 Dec 22 4:38 AM
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |