From: Tim Johnston To: All
Attention all OPNQRYF gurus:
I have an order entry file which has an item number (LPROD), quantity ordered (LQORD) and selling price (LNET). I want to summarize the information into a file that has month-to-date information. I decided to try to use OPNQRYF and the mapped fields. The summary file looks like:
LPROD (15) MTD (11 2)
What I want to do is multiply the quantity ordered times the selling price, and summarize on that result. The CL compiles when I select the query for the month-to-date and tell it to summarize:
MAPFLD(('MTD %SUM+ ("LQORD * LNET")'))
But when I run the program, I get an error message "Operand for %SUM Function not valid."
Can I summarize a mapped field which has a calculation in it or am I going to have to find a way around it?
From: Ted Holt To: Tim Johnston
I think you have quote problems. Try this. I'll assume your data is in file FILEX and the summary file you're using to format the data is called SUMFILE.
OVRDBF FILE(SUMFILE) + TOFILE(FILEX) SHARE(*YES) OPNQRYF FILE((FILEX)) + FORMAT(SUMFILE) + QRYSLT(whatever) + KEYFLD((LPROD)) + MAPFLD((MTD '%SUM+ (LQORD * LNET)')) + GRPFLD(LPROD) CALL program CLOF FILEX DLTOVR SUMFILE
This is off the top of my head, so there may be a parenthesis or something out of whack.
From: Tim Johnston To: Ted Holt
You were close. All I needed was double parentheses around the expression:
MAPFLD((MTD '%SUM+ ((LQORD * LNET))'))
Makes perfect sense now, doesn't it? OPNQRYF is great, but some of the syntax rules just don't jive!
From: Ted Holt To: Tim Johnston
It wouldn't be so bad if you could catch more of these errors with the syntax checker, but most OPNQRYF errors are run-time errors. But OPNQRYF wouldn't have nearly the power it has if everything were bound at compile-time, rather than at run-time.
LATEST COMMENTS
MC Press Online