retrieving and changing external attributes
TRANSCRIPT
Presentation © Copyright 2008, Bryan Meyers, www.bmeyers.net
Part 14
Retrieving and Changing Retrieving and Changing External AttributesExternal Attributes
Return VariablesReturn Variables
• A return variable is a CL variable that has a significant value only upon the return from another command, program or procedure
• Some CL commands exist solely for the purpose of providing a value to a return variable
Common Return Variable CommandsCommon Return Variable Commands
• RTVCFGSTS (Retrieve Configuration Status)• RTVDTAARA (Retrieve Data Area)• RTVJOBA (Retrieve Job Attributes)• RTVLIBD (Retrieve Library Description)• RTVMBRD (Retrieve Member Description)• RTVMSG (Retrieve Message)• RTVNETA (Retrieve Network Attributes)• RTVOBJD (Retrieve Object Description)• RTVSYSVAL (Retrieve System Value)• RTVUSRPRF (Retrieve User Profile)
RTVJOBA CommandRTVJOBA Command
• RTVJOBA retrieves current job attributes– Uses command parameter(s) to retrieve
attribute(s), assign its value(s) to CL variable(s) DCL &curuser *CHAR 10DCL &date *CHAR 6
RTVJOBA CURUSER(&curuser) + DATE(&date)
Common Job AttributesSimple job name JOB *CHAR 10Job user USER *CHAR 10Job number NBR *CHAR 6Current user profile CURUSER *CHAR 10Job type (0=batch, 1=interactive)
TYPE *CHAR 1
System library list SYSLIBL *CHAR 165Current library CURLIB *CHAR 10User library list USRLIBL *CHAR 2750Printer device PRTDEV *CHAR 10Output queue/ library
OUTQ OUTQLIB
*CHAR 10 *CHAR 10
Job date DATE *CHAR 6
CHGJOB CommandCHGJOB Command
• CHGJOB changes job attributes– Often used with RTVJOBA
PGM DCL &runpty *DEC (2 0)
RTVJOBA RUNPTY(&runpty) IF (&runpty *LT 50) DO CHGJOB RUNPTY(50) ENDDO /* (Long-running processing goes here) */
CHGJOB RUNPTY(&runpty) RETURNENDPGM
System ValuesSystem Values
• System-wide attributes that affect the operating environment– Not objects
• Several categories– Date/time– Editing– System Control– Library List– Allocation– Message/logging– Storage– Security
RTVSYSVAL CommandRTVSYSVAL Command
• RTVSYSVAL retrieves a single system value, assigns it to a CL variable
PGM DCL &model *CHAR 4 DCL &srlnbr *CHAR 8 RTVSYSVAL SYSVAL(QMODEL) RTNVAR(&model) RTVSYSVAL SYSVAL(QSRLNBR) RTNVAR(&srlnbr) SNDPGMMSG MSG(‘Your server is a model’ *BCAT &model + *BCAT ‘serial number’ *BCAT &srlnbr) + MSGTYPE(*COMP) RETURNENDPGM Common System Values
System date QDATE *CHAR 6System time QTIME *CHAR 6Day of week QDAYOFWEEK *CHAR 4Security level QSECURITY *CHAR 2Model QMODEL *CHAR 4Serial number QSRLNBR *CHAR 8
CHGSYSVAL CommandCHGSYSVAL Command
• CHGSYSVAL command changes system values• Rarely used in CL program– Changes affect entire system– Cannot change all system values– Might be used in conjunction with RTVSYSVAL
PGM DCL &hour *CHAR 2 RTVSYSVAL SYSVAL(QHOUR) RTNVAR(&hour) IF (&hour = '02') DO CHGSYSVAL SYSVAL(QHOUR) VALUE('03') ENDDO RETURNENDPGM
Date/Time System ValuesDate/Time System Values
• QDATE – Current system date (*CHAR 6)– Also QMONTH, QDAY, QYEAR (*CHAR 2)
• QCENTURY – Current century (*CHAR 1)– ‘0’ = 2000-2062
• QTIME – Current system time (*CHAR 6 or 9)– Also QHOUR, QMINUTE, QSECOND (*CHAR 2)
• QDATETIME – Current timestamp (*CHAR 20)– Timestamp carried out to microseconds
• QDAYOFWEEK – Day of week (*CHAR 4)– *SUN, *MON, *TUE, *WED, *THU, *FRI, *SAT
• QDATFMT – Default date format (*CHAR 3)– MDY, YMD, DMY, JUL
• QTIMZON – Time zone (*CHAR 10)– Names *TIMZON object that reflects system’s time zone– WRKTIMZON command accesses *TIMZON objects
Date/Time System ValuesDate/Time System Values
DCL &Date *CHAR 6DCL &Century *CHAR 1DCL &Time *CHAR 9DCL &Datetime *CHAR 20DCL &Dayofweek *CHAR 4DCL &Datfmt *CHAR 3DCL &Timzon *CHAR 10
RTVSYSVAL QDATE &Date /* '042214' */RTVSYSVAL QCENTURY &Century /* '1' */RTVSYSVAL QTIME &Time /* '135412465' */RTVSYSVAL QDATETIME &Datetime /* '20140422135412465384' */RTVSYSVAL QDAYOFWEEK &Dayofweek /* '*TUE' */RTVSYSVAL QDATFMT &Datfmt /* 'MDY' */RTVSYSVAL QTIMZON &Timzon /* 'QN0700MST3' */
System Control System ValuesSystem Control System Values
• QABNORMSW – previous system end status– *CHAR 1– ‘0’ = Normal end, ‘1’ = Abnormal end
• QIPLSTS – type of last IPL– *CHAR 1
• QIPLDATTIM – date/time for automatic IPL– *CHAR 20
• QMODEL – server model– *CHAR 4
• QSRLNBR – server serial number– *CHAR 8
• QPRTDEV – default printer device– *CHAR 10
Library List System ValuesLibrary List System Values
• QSYSLIBL – default system library list– *CHAR 150
• QUSRLIBL – default user library list– *CHAR 250
RTVUSRPRF CommandRTVUSRPRF Command
• RTVUSRPRF retrieves user profile information, assigns to CL variable(s)– Often used with CHGUSRPRF to change user
informationDCL &user *CHAR 10 DCL &limit *CHAR 10
RTVUSRPRF *CURRENT RTNUSRPRF(&user) LMTCPB(&limit)
Common User Profile AttributesRetrieved user profile RTNUSRPRF *CHAR 8Special authority SPCAUT *CHAR 100Accounting code ACGCDE *CHAR 15User profile text TEXT *CHAR 50Last password change date PWDCHGDAT *CHAR 6Limited capabilities LMTCPB *CHAR 10
RTVOBJD CommandRTVOBJD Command
• RTVOBJD (Retrieve Object Description) retrieves descriptive information about a single object– Library in which the object resides– Object owner– Date of last save– Date of last use
DCL &owner *CHAR 10DCL &library *CHAR 10DCL &usedate *CHAR 7
RTVOBJD MYFILE *FILE OWNER(&owner) RTNLIB(&library) USEDATE(&usedate)
RTVMBRD CommandRTVMBRD Command
• RTVMBRD (Retrieve Member Description) retrieves information about database file member– Current number of active records– Number of deleted records– Date of last save– Date of last use
DCL &nbrrcd *DEC (10 0)DCL &dltrcd *DEC (10 0)
RTVMBRD MYLIB/MYFILE MBR(*FIRST) + NBRCURRCD(&nbrrcd) NBRDLTRCD(&dltrcd)
RTVNETA CommandRTVNETA Command
• RTVNETA (Retrieve Network Attributes) retrieves network attributes– System name– Network name
DCL &system *CHAR 8DCL &network *CHAR 8
RTVNETA SYSNAME(&system) LCLNETID(&network)
Date Conversion with CVTDATDate Conversion with CVTDAT
• CVTDAT converts date from one format to another– Dates are represented as character strings
PGM DCL &today *CHAR 6 DCL &mbrdate *CHAR 5
RTVSYSVAL QDATE RTNVAR(&today) CVTDAT &today TOVAR(&mbrdate) + FROMFMT(*SYSVAL) TOFMT(*JUL) TOSEP(*NONE) ADDPFM FILE(RECEIPTS) MBR('CASH' *CAT &mbrdate) RETURNENDPGM