From: Eric Hill To: All
I have a need to use the concatenate (*CAT) operand in Open Query File. I have a variable called &OCODE that is character, 360 bytes in size, and contains a group of states that I want selected with a blank between each state (AL CA AR TX). I want to select all the records in my Cus-tomer Master file that are in that group of states. I have tried this using the QUSRTOOL command BLDQRYSLT, but it says that my select statement has more than 15 characters in it. I have tried it using the "E and *CAT example in the February issue of MC, and nothing seems to work.
From: Ted Holt To: Eric Hill
You'll have to go through the routine of extracting each state and adding it to the list of values used by the %VALUES function. 5 shows an example of this technique.
You'll have to go through the routine of extracting each state and adding it to the list of values used by the %VALUES function. Figure 5 shows an example of this technique.
This routine is slightly different from your requirements in that you wouldn't have to leave blanks between states, or you could leave one or more blanks between them.
Editor's Note: To work properly, the program in 5 must be executed via a command or called from another proram. It will not work properly if called directly from the command line unless you make sure to include 360 characters in the first parameter. The reason for this is that when character parameters longer than 32 bytes are passed via the CALL command, there is no guarantee that all characters beyond the last non-blank will contain blanks. The only way to ensure they're blanks is by including all 360 characters of the parameter when calling the program.
Editor's Note: To work properly, the program in Figure 5 must be executed via a command or called from another proram. It will not work properly if called directly from the command line unless you make sure to include 360 characters in the first parameter. The reason for this is that when character parameters longer than 32 bytes are passed via the CALL command, there is no guarantee that all characters beyond the last non-blank will contain blanks. The only way to ensure they're blanks is by including all 360 characters of the parameter when calling the program.
TechTalk: OPNQRYF with Sets of Values
Figure 5 OPNQRYF With Sets of Values
PGM PARM(&OCODE) DCL VAR(&OCODE) TYPE(*CHAR) LEN(360) DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(512) VALUE('*ALL') DCL VAR(&N) TYPE(*DEC) LEN(3 0) IF COND(&OCODE *NE ' ') THEN(DO) CHGVAR VAR(&QRYSLT) VALUE('STATE = %VALUES(') CHGVAR VAR(&N) VALUE(1) LOOP: + IF COND(%SST(&OCODE &N 1) *NE ' ') THEN(DO) CHGVAR VAR(&QRYSLT) VALUE(&QRYSLT *BCAT '"' *CAT %SST(&OCODE + &N 2) *CAT '"') CHGVAR VAR(&N) VALUE(&N + 1) ENDDO CHGVAR VAR(&N) VALUE(&N + 1) IF COND(&N *LE 358) THEN(GOTO CMDLBL(LOOP)) CHGVAR VAR(&QRYSLT) VALUE(&QRYSLT *TCAT ')') ENDDO OVRDBF FILE(XXXXX) SHARE(*YES) OPNQRYF FILE((XXXXX)) QRYSLT(&QRYSLT) etc. /* If &OCODE is 'AR AZ CA AL', you'll get + QRYSLT('STATE = %VALUES( "AR" "AZ" "CA" "AL")') */
LATEST COMMENTS
MC Press Online