The query variable is invalid in the query and in the CL.
In the QM Query, give the variable a meaningful name, preceded by an ampersand ie. &TRAN.
in the CL, the SETVAR part of the STRQMQRY statement should read ((TRAN ‘FCT’)), where the QM Query variable is first WITHOUT THE AMPERSAND and the value that you want it changed to is second. This second value could be a variable from the CL program WITH AN AMPERSAND.
The above is generally true. Your query should probably be more like:
UPDATE SECTEMP/SCP002 SET SCTLVL = ‘8’ WHERE SCTRAN = &FCT
The SETVAR() parameter that you have says to replace the QM substitution variable FCT with the value from the CL variable &T01.SCTRAN. However, you haven’t put [&FCT] anywhere in the QM UPDATE statement to indicate where the substitution ought to be made.
Although you declare &T01.SCTRAN, I don’t see where you assign any value to it. Most likely, the value comes from the file you declared — UNUSEDFCT. But if it does, then there’s no reason to declare it. The reference to the file will generate an automatic declaration for all fields in the file. BTW, it’s a little odd to have a period (.) in the middle of a CL variable name. Is that really the correct name? Or were you intending ‘T01′ to be a correlated name?
Also, you declare &T01.SCTRAN as a *CHAR (10) variable. That potentially means that you expect a character expression in your WHERE clause. Unfortunately, that usually means that a character literal is going to be used. And character literals need to be enclosed in quotes, as you did with ‘8’. If you don’t want QM to interpret the value as a column name, you will have to supply quotes along with the value.
Assume &T01.SCTRAN has the value ‘ABC DEF’. After the substitution, the query above would become:
UPDATE SECTEMP/SCP002 SET SCTLVL = ‘8’ WHERE SCTRAN = ABC DEF
Notice the lack of quotes around ‘ABC DEF’.
I supply quotes like this:
UPDATE SECTEMP/SCP002 SET SCTLVL = ‘8’ WHERE SCTRAN = &Q&FCT&Q
…with my SETVAR() like this:
SETVAR( (Q ””) (FCT &T01.SCTRAN))
That is, I simply use a new QM substitution variabe, &Q, and I put it wherever quotes will end up in the query. Then I send in a the quote mark through the SETVAR(). Usually, I declare a CL variable as &Q defined as *CHAR (1) with VALUE( ”” ). My SETVAR() becomes:
SETVAR( (Q &Q) (FCT &T01.SCTRAN))
With that, the resulting UPDATE becomes:
UPDATE SECTEMP/SCP002 SET SCTLVL = ‘8’ WHERE SCTRAN = ‘ABC DEF’
You have to supply the quotes yourself; you can’t code them into the UPDATE statement around a substitution variable. If you do, then QM will assume that you want the literal ‘&FCT’ rather than the substitution variable inside quotes. It’s a detail that will trip you up a couple times, but pretty easy to get around.
One minor note — You have FCT surrounded by quotes in your SETVAR(). The only reason to do that would be if your substitution variable name had lower-case letters like:
UPDATE SECTEMP/SCP002 SET SCTLVL = ‘8’ WHERE SCTRAN = &Q&fct&Q
You’d then need to use this:
SETVAR( (Q &Q) (‘fct’ &T01.SCTRAN))
…in order to preserve the lower-case name.