04-19-2007 3:41 PM
I need to read a talbe to find material price for the current price. if it isn't found i need to basically loop until i do find a price. do you have some sample code to acheive this?
thanks
04-19-2007 3:47 PM
loop at itab.
if itab-price eq CURRENT_PRICE.
*do some thing
EXIT.
endif.
endif.
04-19-2007 3:47 PM
loop at itab.
if itab-price eq CURRENT_PRICE.
*do some thing
EXIT.
endif.
endif.
04-19-2007 3:54 PM
I need to get the price for the current month and if it is blank then I need to go to the previous month.
04-19-2007 3:52 PM
First read the database table in an internal table using where Select and WHERE clause to identify the records.
Then loop at itab where price eq CURRENT_PRICE.
process further - for ex copy to another internal table
append itab to current_price_table.
endloop.
Please reward points if useful.
04-19-2007 3:57 PM
so would you 1st select all records for that material and put into a table. I then need to see if there is a price fo the current and if not i need to loop until I find a price. Is there anyway to limit what come back in my select becuase if I have the current price fo rth emonth I don't need to get all the records but maybe this is faster than reading 1 record at a time
04-19-2007 4:11 PM
how about selecting all the current month prices then checking if the ones you want are there, any that aren't save to a separate table then for all those do a second select to the database to get all previous month prices.
Are you using full keys for your DB selects? If you can use select single then loop/select single is not much different from selectfor all entries
04-19-2007 4:20 PM
I am doing a select for all entries and putting into an internal table.
04-19-2007 3:55 PM
04-19-2007 4:01 PM
Hi MICK,
See if this can be useful.
data: variable like currentprice.
move current price into variable.
select keyfield materialprice values from dbtable into table internaltable
where filteringcondition1(column name of the dbtable) = value of
filteringcondition1.
loop at internaltable where key field = keyfield value and
material price = current price.
perform actions need
to be done when material price
is equal to current price.
endloop.
Award points if useful.
Regds,
Ravi Sankara Kumar.
04-19-2007 4:08 PM
Same as Ravi's except you dont need the exit in the loop. If the where condition is not satisfied it wont even go inside the loop.
loop at itab where <YOur condition>.
Record is found, process your code here.
endloop.
hith
Sunil Achyut
04-19-2007 4:12 PM
I think I exlained incorectly. I don't know my material price and need to loop until I find a value so i fiest need to look at the current month and if not found keep going back. would i just subtract 1 from the month and do a nested loop?