retrieving and changing external attributes

17
Presentation © Copyright 2008, Bryan Meyers, www.bmeyers.net Part 14 Retrieving and Changing Retrieving and Changing External Attributes External Attributes

Upload: others

Post on 27-Apr-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Retrieving and Changing External Attributes

Presentation © Copyright 2008, Bryan Meyers, www.bmeyers.net

Part 14

Retrieving and Changing Retrieving and Changing External AttributesExternal Attributes

Page 2: Retrieving and Changing External 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

Page 3: Retrieving and Changing External Attributes

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)

Page 4: Retrieving and Changing External Attributes

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

Page 5: Retrieving and Changing External Attributes

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

Page 6: Retrieving and Changing External Attributes

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

Page 7: Retrieving and Changing External Attributes

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

Page 8: Retrieving and Changing External Attributes

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

Page 9: Retrieving and Changing External Attributes

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

Page 10: Retrieving and Changing External Attributes

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' */

Page 11: Retrieving and Changing External Attributes

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

Page 12: Retrieving and Changing External Attributes

Library List System ValuesLibrary List System Values

• QSYSLIBL – default system library list– *CHAR 150

• QUSRLIBL – default user library list– *CHAR 250

Page 13: Retrieving and Changing External Attributes

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

Page 14: Retrieving and Changing External Attributes

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)

Page 15: Retrieving and Changing External Attributes

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)

Page 16: Retrieving and Changing External Attributes

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)

Page 17: Retrieving and Changing External Attributes

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