Posted Tue, 20 Jul 2021 04:18:44 GMT by

I would like to include variable in filename.

DCL VAR(&QTRYEAR) TYPE(*DEC) LEN(4 0) USAGE(*GLOBAL)
DCL VAR(&QTRNBR) TYPE(*DEC) LEN(2 0) USAGE(*GLOBAL)
DCL VAR(&QTRDTE) TYPE(*DEC) LEN(6 0) USAGE(*GLOBAL)
DCL VAR(&QTRDTESTR) TYPE(*CHAR) LEN(6) USAGE(*GLOBAL)

CHGVAR VAR(&QTRYEAR) VALUE(YEAR(CVTDATE(&VD_DTE_E, YMD1)))
CHGVAR VAR(&QTRNBR) VALUE(QUARTER(CVTDATE(&VD_DTE_E, YMD1)))
CHGVAR VAR(&QTRDTE) VALUE((&QTRYEAR * 100) + (&QTRNBR))
CHGVAR VAR(&QTRDTESTR) VALUE(&QTRDTE)

EXECUTE VIEW(CXPLIB/HD210715A4) PCFMT(*SDF) TOSTMF('/CXP1MIS/HD210715A4_61859_&QTRDTE_RecordType1.dat') REPLACE(*YES) SETVAR((&BUSID 61859)) DTSTYLE(*USA '/' *USA ':') TEXT('Oregon DOI Request Record Type1')
EXECUTE VIEW(CXPLIB/HD210715A4) PCFMT(*SDF) TOSTMF('/CXP1MIS/HD210715A4_68349_&QTRDTESTR_RecordType1.dat') REPLACE(*YES) SETVAR((&BUSID 68349)) DTSTYLE(*USA '/' *USA ':') TEXT('Oregon DOI Request Record Type1')

If I replace the "_" with a "-" it seems to work but, I really don't want to do that.

Thanks for the help.

Posted Tue, 20 Jul 2021 04:31:14 GMT by

Hi.

The underscore character is used by the ViewPoint and Sequel SQL syntax checking program and is a special character used to block variable value substitution.  The first advise is to not use an underscore in the Variable name.

Next, if you want to include an underscore in the variable substitution, then you would need to concatenate the underscore character in your chgvar commands.

See my example below.  We can pretty much get any part of a date you need, in my example, I am getting Year and Month from current date. 

Copy/paste this example into a new script design and you should get a good idea of how to handle the file name with special characters.

 

DCL VAR(&YR) TYPE(*CHAR) LEN(15)
DCL VAR(&XX) TYPE(*CHAR) LEN(15)


CHGVAR VAR(&XX) VALUE(char(yyyymm(current date)))
CHGVAR VAR(&YR) VALUE('_' cat '&&XX')

SEQUEL/EXECUTE VIEW(SEQUELEX/CUSTLIST) PCFMT(*XLS) TOSTMF('/tmp/test_ABC&&YR.xls') REPLACE(*YES)

Posted Tue, 20 Jul 2021 08:51:33 GMT by

Rich,

Thanks for the quick reply.

Your solution is excellent.

 

You must be signed in to post in this forum.