I am trying to make a reusable CL program that will automatically generate a report monthly by executing a query. The query will use a date range from day 01 to day 99 of the previous month(yyyy(mm-1)'01' and yyyy(mm-1)'99').
The problem starts when I try to execute my query:
OPNQRYF FILE((&QUERY)) OPTION(*INP) +
QRYSLT('DATE *GE ' *CAT &FROM *CAT ' *AND DATE *LE +
' *CAT &TO *CAT ' *AND ITEM *EQ %VALUES( +
''z007349459'' ''z007358'') *AND TYPE *NE ''N''')
DATE is a field name in the table.
&FROM = yyyymm-1 + '01'. CHAR
&TO = yyyymm-1 + '99'. CHAR
I've already tried to string all the conditions into one variable but I still get an error message.
Here's how I tried to combine the conditions into one query:
&SEL1 = ('DATE *BCAT '*EQ %RANGE(&FROM &TO)'') <-
&SEL2 = *AND ITEM *EQ %VALUES( +
''z007349459'' ''z007358'')
&SEL3 = *AND TYPE *NE ''N'''
CHGVAR &QRYSLT VALUE(&SEL1 *BCAT &SEL2)
CHGVAR &QRYSLT VALUE(&QRYSLT *BCAT &SEL3)
OPNQRYF (&QUERY) OPTION(*INP) QRYSLT(&QRYSLT)
What am I doing wrong? Any help would be appreciated. Thanks in advance!
The problem starts when I try to execute my query:
OPNQRYF FILE((&QUERY)) OPTION(*INP) +
QRYSLT('DATE *GE ' *CAT &FROM *CAT ' *AND DATE *LE +
' *CAT &TO *CAT ' *AND ITEM *EQ %VALUES( +
''z007349459'' ''z007358'') *AND TYPE *NE ''N''')
DATE is a field name in the table.
&FROM = yyyymm-1 + '01'. CHAR
&TO = yyyymm-1 + '99'. CHAR
I've already tried to string all the conditions into one variable but I still get an error message.
Here's how I tried to combine the conditions into one query:
&SEL1 = ('DATE *BCAT '*EQ %RANGE(&FROM &TO)'') <-
&SEL2 = *AND ITEM *EQ %VALUES( +
''z007349459'' ''z007358'')
&SEL3 = *AND TYPE *NE ''N'''
CHGVAR &QRYSLT VALUE(&SEL1 *BCAT &SEL2)
CHGVAR &QRYSLT VALUE(&QRYSLT *BCAT &SEL3)
OPNQRYF (&QUERY) OPTION(*INP) QRYSLT(&QRYSLT)
What am I doing wrong? Any help would be appreciated. Thanks in advance!