pjohns
1st March 2010, 18:54
Hello,

I have an Exchange schema which currently exports records from the item master.

Part of this export includes the price for each item in the item master. For a range of items I need to set the price in the export file to zero. I'm struggling as to what syntax I should use in a condition script to acheive this.

I currently have the following condition script which is taking the price from the tdsls032 table for every item in the export file. How can I change the script to say if the item is in range A to C then enter a zero price?

====================================
table ttiitm001
table ttdsls032
domain tcitem item
domain tcpric pric
domain tcdate tdat
domain tccplt cpls
domain tcpric price

select tdsls032.item, tdsls032.pric
from tdsls032
where (tdsls032.tdat > date.num() or tdsls032.tdat = 0)
and tdsls032.cpls = "001"
and tdsls032.item = :tiitm001.item
selectdo

price = tdsls032.pric

selectempty

price = 0

endselect

return(price)

================================================

Thanks in advance.

PJ - A novice Baan scripter!

Amit_Jain
2nd March 2010, 05:57
PJohn

As far as I understood your problem, I would rather first export all item whose price is to be set to zero. By Defining the Range for that particular Exchange scheme(make sure you have checked the range checkbox in Export Table Relation to make ranges applicable). Then as a second step, importing the same data after setting the price to constant zero.

As far as your current script is concerned, I think if you change you code from
"and tdsls032.item = :tiitm001.item"
To

"and tdsls032.item = :item"
your problem should get resolved, but make sure you pass item as parameter.

Regards

litrax
2nd March 2010, 13:03
Hello,

As far as I understand it, simply write a if condition:

selectdo
if tdsls032.item > A
and tdsls032.item < C then
price = 0
else
price = tdsls032.pric
endif
selectempty


Or am I false?

Litrax

pjohns
2nd March 2010, 13:40
Hello Litrax,

I came to the same conclusion as you.


selectdo

if tiitm001.item(1;5) = "CS011" then
price = 0
else
price = tdsls032.pric
endif
selectempty


This set all items starting with CS011 to zero price.

One thing I came across during testing, which confused me, is if I specified a particular item in the condition script the price would not be set to zero.


if tiitm001.item = "CS011-000000-1" then
price = 0
else
price = tdsls032.pric
endif
selectempty


This item existed in my exchange export but it would not have it's price set to zero. if I wanted this logic is the syntax different?

Thanks for your help.

PJ

manish_patel
2nd March 2010, 14:15
Please use strip$() and shiftl$() functions. It may solve your problem.

if strip$(shiftl$(tiitm001.item)) = "CS011-000000-1" then

mark_h
2nd March 2010, 15:56
Hello Litrax,

I came to the same conclusion as you.


selectdo

if tiitm001.item(1;5) = "CS011" then
price = 0
else
price = tdsls032.pric
endif
selectempty


This set all items starting with CS011 to zero price.

One thing I came across during testing, which confused me, is if I specified a particular item in the condition script the price would not be set to zero.


if tiitm001.item = "CS011-000000-1" then
price = 0
else
price = tdsls032.pric
endif
selectempty


This item existed in my exchange export but it would not have it's price set to zero. if I wanted this logic is the syntax different?

Thanks for your help.

PJ

Seems to me one time I did something like this I had to use strip$(tiitm001.item) = "some part". Not even sure I have that old exchange scheme.

pjohns
2nd March 2010, 16:16
Hi Mark,

Somebody else, whose post has disappeared, suggested the following which is along the same lines as yours.


if strip$(shiftl$(tiitm001.item)) = "CS011-000000-1" then


In the end my condition script was -

if (tiitm001.item(1;6) = "DS1105") or (tiitm001.item(1;6) = "DS2105")
then
price = 0

else

price = tdsls032.pric

endif


selectempty

price = 0



Thanks to the "Baanboarders" for their help.

I'm not a natural programmer and only know the basics. But it's great that I can always come to baanboard.com and find lots of people willing to help.

Cheers

PJ

mark_h
2nd March 2010, 23:44
It was in the deleted post - not sure why it was deleted. Took care of that and undeleted the post so they know their answer was a good one.