Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I'm having a problem calling a subroutine.
I've created the subroutine:
SUB CheckPrice(pCustomer, pProduct, pSalesDate)
LOAD SalesPrice
FROM DateFile.txt
(txt, codepage is 1252, embedded labels, delimiter is '\t', msq)
WHERE
CustomerCode = '$(pCustomer)' AND
ItemCode = '$(pProduct)' AND
FromDate <= '$(pSalesDate)' AND
'$(pSalesDate)' <= ToDate
;
END SUB
When I call the subroutine once for a fixed customer/product/date it returns the price I expect.
However, I want to call the subroutine from within a LOAD. When I try the code below I get 'Error in expresssion:')' expected.
LOAD SalesDate,
CustomerCode,
ItemCode,
IF (ISNULL(Call CheckPrice(CustomerCode, ItemCode, SalesDate)), 'N', 'P') as chkprice
FROM SalesOrder.qvd
(qvd);
Any ideas why this is?
Cherian
Have you tried putting the Sub Call in a dollar expansion?
$( Call CheckPoint( ...
Hello Toni
Tried that but it made no difference
Looking at your example I do not really see how it should work.
The subroutine will only execute a table load, but how does it return a value to trigger the IF conditional check for null? I imagine it would always be interpreted as a NULL.
Have you tried executing the CALL as string in the $-expansion?
$(="IF (ISNULL(Call CheckPrice(CustomerCode, ItemCode, SalesDate)), 'N', 'P')")
Hi,
what you're trying to achieve is a script function. This is not possible in QV, only sub routine without return values.
- Ralf
It's impossible call a subroutine in LOAD statement?
Right. You can call a sub routine only via "call"..
Damn :s Thanks :s
About mapping tables and apply match, how do that if I pass more then one field?
For example, I have this
if(match(t_cuni,'LTA','FGS','QQ'), 1, applymap('fnConvToQQ',uniBase)) * t_qhnd as cantReturn;
but here, I just pass one field, unibase to mappiing fnConvToQQ'.
how pass two fields? like this?
applymap('fnConvToQQ',uniBase,cantBase)
You can use applymap() multiple times in a LOAD statement. One for each field..