225 pts.
 OPNQRYF HOW?
HI Everyone,

 i need a idea, i have on CL program (pgm parm) a field wndate(8,0) and i need make a opnqryf (file1) compare wndate with mvdatl(8,0), but i only wanted the first 6 position (yyyymm) of both . Anyone give a idea how can i made this?

OS/400 in V5R4M1

thanks in advanced.

 



Software/Hardware used:
OS/400 in V5R4M1
ASKED: July 6, 2010  10:47 AM
UPDATED: March 3, 2011  12:02 PM

Answer Wiki:
an example of a substring statment ... quick reponse... Think this is what you're looking for.... CHGVAR VAR(&USRDTA) VALUE(&DAY || '-' + || %SST(&JOBDATE 1 4)) You can use MAPFLD on OPNQRYF cmd to create new fields of 6,0 based on the date fields of the file and then use these fields on QRYSLT.
Last Wiki Answer Submitted:  March 3, 2011  12:02 pm  by  Znason   460 pts.
All Answer Wiki Contributors:  Znason   460 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

OPNQRYR compare example…………… Bob

OPNQRYF FILE(DBALIB/GWHFMSTR) +
OPTION(*INP) +
FORMAT(DBALIB/GWHFMSTR) +
QRYSLT(‘MBLIB *EQ +
“‘ *CAT &LIBNAME *CAT ‘” *AND +
MBFILE *EQ “‘ *CAT &FILENAME *CAT ‘”‘)
/* */
CPYFRMQRYF FROMOPNID(GWHFMSTR) TOFILE(DBALIB/GWHBYFILE) +
MBROPT(*REPLACE) CRTFILE(*YES) +
FMTOPT(*NOCHK)

 460 pts.

 

OK .. If wndate was 20100706 Then is qryslt could be …
mvdatl *GE 20100701 *and mvdatl *LE 20100731

dcl wndatec *char 8
dcl wndat01 *char 8
dcl windat31 *char 8
chgvar wndatec windate
chgvar wndat01 (%sst(windatec 1 6) *tcat ’01)
chgvar wndat31 (%sst(windatec 1 6) *tcat ’31)

qryslt (‘mvdatl *GE ‘ *cat wndat01 *cat ‘*and mvdatl *LE’ *cat wndat31)

This time we don’t need no stinkin ”’ because the field mvdatl isn’t character.
Phil

 44,630 pts.

 

Greatest movie line –
“Badges?… We don’t need no… stinkin’ badges!”
The Treasure of the Sierra Madre 1948

How did (Humphrey Bogart get into movies with such wonderful lines.
“You know how to whistle”
“the stuff that dreams are made of”
“Louis, I think this is the beginning of a beautiful friendship”
Phil

 44,630 pts.

 

*CAT and %SST will get you what you need.

remember though, that you need to convert the numeric date to an alpha field because of the way *CAT, *BCAT and *TCAT, and %SST work.

-Sarge

 950 pts.