iseriesuniversity

Thursday, September 27, 2007

Lowercase to Uppercase

There had been few occasions to change the inputs from a command to be converted all upper case for CPP. This is especially true when CL and Query management is used. The query source are set of SQL statements, in which the field values are case sensitive. So when, name 'Subbu' is compared with 'SUBBU', they do not match.

Like always there is a great helper API for thus purpose. It is QCLSCAN. Please refer to the following url for more information on this API.

publib.boulder.ibm.com/iseries/v5r1/ic2924/info/apis/qclscan.htm

The following source when used, converts the inputs parameter passed to all upper case and return the upper case value in the same parameter.

Please use when required.

PGM PARM(&USRIN)
DCL VAR(&USRIN) TYPE(*CHAR) LEN(10)
DCL VAR(&CHARLEN) TYPE(*DEC) LEN(3 0) VALUE(10)
DCL VAR(&STRPOS) TYPE(*DEC) LEN(3 0) VALUE(1)
DCL VAR(&PATTERN) TYPE(*CHAR) LEN(10)
DCL VAR(&PATTERNLEN) TYPE(*DEC) LEN(3 0)
DCL VAR(&TRAS) TYPE(*CHAR) LEN(1) VALUE('1')
DCL VAR(&TRIMTRBL) TYPE(*CHAR) LEN(1) VALUE('1')
DCL VAR(&WILD) TYPE(*CHAR) LEN(1) VALUE('1')
DCL VAR(&OUTPUT) TYPE(*DEC) LEN(3 0)
CALL PGM(QCLSCAN) PARM(&USRIN &CHARLEN &STRPOS +
&PATTERN &PATTERNLEN &TRAS &TRIMTRBL +
&WILD &OUTPUT)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The +
output is' *BCAT &USRIN)
ENDPGM: ENDPGM

Thank you,
For more help reach me on iseriesconsultant@rediffmail.com

Friday, September 21, 2007

Purpose
Data migration is one of the major and crucial activities for many of core AS400 systems. This is performed by application support team with the active involvement of infrastructure support team. The infrastructure support team must perform the backup before the data migration and the restoration in case the things does not act as it must after the data migration (roll back).
The purpose of this document is to suggest an automatic way of performing the roll back activity after an unsuccessful data migration.


Assumption
• The Responsibility of roll back rests with infrastructure team. (Though it may not be the case always)
• The backup of user libraries or at least the required impacted libraries has been performed prior to data migration.
• Tape is in possession of infrastructure support team and is loaded in the tape drive. (TAP03 is assumed for this coding)• Required authorities to restore the objects, the access to library and access to this program are available
• RESTORE, is the name of library to which the objects are restored.

Note

• TAP03, the tape drive is mentioned in the source code only as an example. Please change it according to your needs.
• AS/400, iSeries and System i, all refer to the same system, as far as the practicality, for this document is concerned.
• The coding is performed on V5R2 system, and any release after this, may have better code handling in place.

Important Terms

• Physical Files – These are database files on AS400 that contain data. Physical file may have more than one member. Every member is a table with rows and columns. A physical file may have logical files.
• Logical files – these files are views for Physical file. They do not contain data, but point to physical file containing data. Logical file must have at least one physical file attached to it.
Constraints

• Logical file cannot be copied to a library without the corresponding Physical file being copied first.• Physical files cannot be deleted until all the associated logical files are deleted.

Program logic
• Information on all the files in the library to be rolled back is dumped to an out file.
• The file is used as a reference to delete the logical (first) and physical (second) files from the library.
• Restore all the files pertaining to library to library ‘RESTORE’.
• Copy the physical files first and then the corresponding logical files to destination library.
• Clear the ‘RESTORE’ library.
• Repeat the same for any further libraries required.

Caution
• Ensure that, there is enough space on the system to have the files restored to ‘RESTORE’ library.
• QINTER subsystem must be down, and you are logged at console as security officer or a powerful profile. Else with users logged in it will create havoc and roll back will be hindered.

Code
The code provided here, as mentioned earlier, is developed on V5R2 system, the release higher to this will have more features to handle. Please have this code as reference and tailor it to your needs.
Program name: DLTRSTFIL This is to core program to be called with the library name as the parameter. The program 1. Deletes the logical file and then the physical files. 2. Restores the files to 'RESTORE' library.3. Moves the files to destination library. (Passed as parameter)4. Clears the 'RESTORE' library. 5. Prints the job log.
PGM PARM(&LIBNAM) DCL VAR(&LIBNAM) TYPE(*CHAR) LEN(10) DCLF FILE(RBKLIB/APPFILES) CLRPFM FILE(RBKLIB/APPFILES) MBR(APPFILES) DSPOBJD OBJ(&LIBNAM/*ALL) OBJTYPE(*FILE) + OUTPUT(*OUTFILE) OUTFILE(RBKLIB/APPFILES) RCVF: RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(DLTF)) IF COND(&ODOBAT *EQ PF) THEN(DO) CALL PGM(RBKLIB/DLTLF) PARM(&ODOBNM &LIBNAM) DLTF FILE(&LIBNAM/&ODOBNM) ENDDO GOTO CMDLBL(RCVF) DLTF: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The + entire deletion opertion is complete') RSTOBJ OBJ(*ALL) SAVLIB(&LIBNAM) DEV(TAPO3) + OBJTYPE(*FILE) RSTLIB(RESTORE) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The + restoration is complete') CALL PGM(RBKLIB/MOVFILES) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The + move operation is complete') CLRLIB LIB(RESTORE) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The + library restore is cleared.') DSPJOBLOG OUTPUT(*PRINT) ENDPGM

Program name: DLTLF

The program
1. Deletes the logical files and then pass the control to DLTRSTFIL program to delete the corresponding physical file.
2. Handles the exception when no logical files are associated with the physical file.

PGM PARM(&PFNAM &LIBNAM) DCL VAR(&PFNAM) TYPE(*CHAR) LEN(10) DCL VAR(&LIBNAM) TYPE(*CHAR) LEN(10) DCLF FILE(RBKLIB/TESTF) CLRPFM FILE(RBKLIB/TESTF) MBR(TESTF) DSPDBR FILE(&LIBNAM/&PFNAM) OUTPUT(*OUTFILE) + OUTFILE(RBKLIB/TESTF) RCVF: RCVF MONMSG MSGID(CPF0864 CPD0079 CPD0078) EXEC(GOTO + CMDLBL(DLTLF)) IF COND(&WHREFI *EQ ' ') THEN(GOTO + CMDLBL(DLTLF2)) DLTF FILE(&WHRELI/&WHREFI) GOTO CMDLBL(RCVF) DLTLF2: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('There + are no logicals to this physical file') GOTO CMDLBL(ENDPGM) DLTLF: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The + logical files are deleted.') ENDPGM: ENDPGM

Program name: MOVFILES
This program,
1. Move the physical file to the destination library (passed as parameter)
2. Makes the call to program MOVLF to move the Logical files to destination library.

PGM PARM(&LIBNAM) DCL VAR(&LIBNAM) TYPE(*CHAR) LEN(10) DCLF FILE(RBKLIB/APPFILES) CLRPFM FILE(RBKLIB/APPFILES) MBR(APPFILES) DSPOBJD OBJ(RESTORE/*ALL) OBJTYPE(*FILE) + OUTPUT(*OUTFILE) OUTFILE(RBKLIB/APPFILES) RCVF: RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM)) IF COND(&ODOBAT *EQ PF) THEN(DO) MOVOBJ OBJ(RESTORE/&ODOBNM) OBJTYPE(*FILE) + TOLIB(&LIBNAM) CALL PGM(RBKLIB/MOVLF) PARM(&ODOBNM &LIBNAM) ENDDO GOTO CMDLBL(RCVF) ENDPGM: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The + move operation complete. The entire + operation is completed for library' *BCAT &LIBNAM) ENDPGM

Program name: MOVLF

This program moves the Logical files of the corresponding Physical file to destination library.

PGM PARM(&PFNAM &LIBNAM) DCL VAR(&PFNAM) TYPE(*CHAR) LEN(10) DCL VAR(&LIBNAM) TYPE(*CHAR) LEN(10) DCLF FILE(RBKLIB/TESTF) CLRPFM FILE(RBKLIB/TESTF) MBR(TESTF) DSPDBR FILE(&LIBNAM/&PFNAM) OUTPUT(*OUTFILE) + OUTFILE(RBKLIB/TESTF) RCVF: RCVF MONMSG MSGID(CPF0864 CPD0079 CPD0078) EXEC(GOTO + CMDLBL(MOVLF)) IF COND(&WHREFI *EQ ' ') THEN(GOTO + CMDLBL(MOVLF2)) MOVOBJ OBJ(RESTORE/&WHREFI) OBJTYPE(*FILE) + TOLIB(&LIBNAM) GOTO CMDLBL(RCVF) MOVLF2: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('There + are no logicals to this physical file') GOTO CMDLBL(ENDPGM) MOVLF: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The + logical files are moved') ENDPGM: ENDPGM


Conclusion

The document provides one of the automated and relatively simple method to deal with the roll back situation after a unsuccessful data migration. Please feel free to change the code according to your requirements.

Monday, June 25, 2007

Deleting objects based on its creation date

The situation often demands the maintenance of the system by deleting the required. The following example, is used to identify the object of a particular type (in this example it is *JRNRCV) to be deleted based on its creation date. The cut off date considered for this example is 365 days old.

So solution has been modularized for program reusability.

The following program accepts the journal receiver library as a input parameter. It then pass on the object name and the creation date as input to the program JRNDATE.

OBJDLT
PGM PARM(&JRNRCVLIB)
DCL VAR(&JRNRCVLIB) TYPE(*CHAR) LEN(10)
DCLF FILE(QADSPOBJ)
DSPOBJD OBJ(&JRNRCVLIB/*ALL) OBJTYPE(*JRNRCV) +
OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ)
NEXT: RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM))
CALL PGM(SUBBU/JRNDATE) PARM(&ODCDAT *ODOBNM)
GOTO CMDLBL(NEXT)
ENDPGM: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The Old +
journals have been backed up and deleted!')
ENDPGM


The program JRNDATE, get the journal receiver name and its creation date as input and deletes the old journal receivers. The current system date is also retrieved for comparison. The obsoleteness of the object is determined by calling the program CALDATE, which calculates the cut off date.

JRNDATE

PGM PARM(&DATE &JRNRCVNAM)
DCL VAR(&JRNRCVNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&DATE) TYPE(*CHAR) LEN(6)
DCL VAR(&SYSDATE) TYPE(*CHAR) LEN(6)
RTVSYSVAL SYSVAL(QDATE) RTNVAR(&SYSDATE)
CALL PGM(QGPL/CALDATE) PARM(&SYSDATE &DATE)
IF COND(&DATE *LT &SYSDATE) THEN(CALL +
PGM(QGPL/JRNRCVDLT) PARM(&JRNRCVNAM))
ENDPGM

The program CALDATE is the heart of this utility. This program calculates the date, 365 days ago. The underlined statement can be modified for numeric, 365 and can be used to identify the obsolete objects.


CALDATE
PGM PARM(&IN_DATE &OUTDATE)
DCL VAR(&IN_DATE) TYPE(*CHAR) LEN(6)
DCL VAR(&OUTDATE) TYPE(*CHAR) LEN(6)
DCL VAR(&JULDATE) TYPE(*CHAR) LEN(5)
DCL VAR(&YEAR) TYPE(*CHAR) LEN(2)
DCL VAR(&DAYS) TYPE(*CHAR) LEN(3)
DCL VAR(&DECDAYS) TYPE(*DEC) LEN(5)
DCL VAR(&DECDAY2) TYPE(*DEC)
DCL VAR(&DECTEMP) TYPE(*DEC)
DCL VAR(&DECYEAR) TYPE(*DEC)
DCL VAR(&OUTDAYS) TYPE(*CHAR)
DCL VAR(&OUTYEAR) TYPE(*CHAR)
CVTDAT DATE(&IN_DATE) TOVAR(&JULDATE) FROMFMT(*DMY) +
TOFMT(*JUL) TOSEP(*NONE)
CHGVAR VAR(&YEAR) VALUE(%SST(&JULDATE 1 2))
CHGVAR VAR(&DAYS) VALUE(%SST(&JULDATE 3 3))
CHGVAR VAR(&DECDAYS) VALUE(&DAYS)
CHGVAR VAR(&DECYEAR) VALUE(&YEAR)
CHGVAR VAR(&DECTEMP) VALUE(&DECDAYS)
CHGVAR VAR(&DECDAYS) VALUE(365 - &DECDAYS)
IF COND(&DECDAYS <= 0) THEN(DO)
CHGVAR VAR(&DECDAYS) VALUE(&DECTEMP)
CHGVAR VAR(&DECYEAR) VALUE(&DECYEAR - 1)
IF COND(&DECYEAR < 0) THEN(DO)
CHGVAR VAR(&DECYEAR) VALUE(99)
ENDDO
ENDDO
ELSE CMD(DO)
CHGVAR VAR(&DECYEAR) VALUE(&DECYEAR - 1)
ENDDO
CHGVAR VAR(&OUTYEAR) VALUE(&DECYEAR)
CHGVAR VAR(&OUTDAYS) VALUE(&DECDAYS)
CHGVAR VAR(&YEAR) VALUE(%SST(&OUTYEAR 25 2))
CHGVAR VAR(&DAYS) VALUE(%SST(&OUTDAYS 30 3))
CHGVAR VAR(%SST(&JULDATE 1 2)) VALUE(&YEAR)
CHGVAR VAR(%SST(&JULDATE 3 3)) VALUE(&DAYS)
CVTDAT DATE(&JULDATE) TOVAR(&OUTDATE) FROMFMT(*JUL) +
TOFMT(*DMY) TOSEP(*NONE)
ENDPGM: ENDPGM


This utility can be used in conjunction with the "Delete detached audit journal receivers" to delete the journal receivers based on date.

You can use this source code as reference and make your own automations.

Thanks for this spending time to read this article. Please mail me at dean@iseriesuniversity.com for any further clarifications or queries.

Thank you,
Subramaniam.S

Monday, June 18, 2007

Purpose:
There are many printers in live environment used for printing different documents. Whenever, there is a problem with the physical printer or a shop closure, rerouting the printer to different out queue becomes quite a task to be planned and is time consuming.

The purpose of this document is to provide the background for this entire utility development and the benefits of using this utility.

Existing Scenario:
Non availability of a physical printer is indeed a show stopper. If this happens, the impact is really considerable, as most of the printers are setup location wise. Non availability of printer results in
Delay in job processing as the printers needs to redirect to other location.
Rerouting printer is a time consuming activity.
Reverting the step 2 is reinventing the same wheel, is again time consuming.
Manual efforts are significant.

The advantages mentioned above can be resolved by the Out Queue Change utility.

Utility Description:

Dataarea
The utility will create a library SPLDVTLIB and create a data area to hold the out queue (From out queue) parameters to be changed. The name of the data area thus created will have the first five character of out queue that needs to be routed and last five characters are from the first characters of the out queue that will receive the spool file redirection.

Example: If the out queue name to be redirected is ‘FROMOUTQ’ and the out queue to receive the redirection is ‘TOOUTQ’ the data area name that will be created by the utility in library SPLDVTLIB becomes ‘FROMOTOOUT’.

The purpose of the data area is not only to hold the parameters of the out queue. The program logic of the utility also ensures that the same routing is not repeated for the out queue.

These data areas are of type *CHAR, and are of 40 characters in length.

The critical to the utility is this data area they help in
Retaining the details of the out queue to be redirected.
Preventing the redirection more than once for the same out queue.

These data areas are deleted once the redirection is reverted.

Writer
The changes to the out queue cannot be done if the writer is started. The writer needs to be ended for the out queue to be changed. Once the out queue is changed the writer is started again. And because the out queue is changed the writer will point to other out queue.

Parameters to be changed
The parameters changed for this utility is ‘Remote Print Queue’ and ‘IP Address’. The Remote print queue parameter is retained in the data area and changed to the out queue to be redirected to. The IP address is also retained in the data area and then changed to loop back, ‘127.0.01’. This ensures the spool file to be redirected is routed to the remote printer specified in the ‘Remote Print Queue’ parameter.

CL program:
The CL program that implements the utility is provided below.

PGM PARM(&FROMOUTQ &amp;amp;FOUTQLIB &TOOUTQ &TOUTQLIB)
DCL VAR(&FROMOUTQ) TYPE(*CHAR) LEN(10)
DCL VAR(&FOUTQLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&TOOUTQ) TYPE(*CHAR) LEN(10)
DCL VAR(&TOUTQLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&IPADR) TYPE(*CHAR) LEN(15)
DCL VAR(&DTAARANAM) TYPE(*CHAR) LEN(10) /* The +
data area to be created for holding out +
queue values */
DCL VAR(&DTAARAREV) TYPE(*CHAR) LEN(10) /* This +
data area is not reverse check */
DCL VAR(&amp;RCVAR) TYPE(*CHAR) LEN(800)
DCL VAR(&RCVLEN) TYPE(*CHAR) LEN(4)
DCL VAR(&FRMPARA) TYPE(*CHAR) LEN(20) /* 'This +
is the calue passed tos API' */
DCL VAR(&FMTNAM) TYPE(*CHAR) LEN(8) +
VALUE('OUTQ0100')
DCL VAR(&RMTPRTQNAM) TYPE(*CHAR) LEN(15)
CHGJOB LOG(4 0 *SECLVL)
CHKOBJ OBJ(&FOUTQLIB/&FROMOUTQ) OBJTYPE(*OUTQ)
MONMSG MSGID(CPF9801) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Specify +
the correct out queue that needs to be +
diverted')
GOTO ENDPGM
ENDDO
CHKOBJ OBJ(&TOUTQLIB/&TOOUTQ) OBJTYPE(*OUTQ)
MONMSG MSGID(CPF9801) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Specify +
the correct out queue to which spools +
needs to get diverted.')
GOTO ENDPGM
ENDDO
/********* THE WRITER NEEDS TO BE ENDED TO GET DIVERTED TO OTHER QUEUE ********/
ENDWTR WTR(&FROMOUTQ) OPTION(*IMMED)
MONMSG MSGID(CPF3313)
/******************************************************************************/
CHGVAR VAR(%SST(&FRMPARA 1 10)) VALUE(&FROMOUTQ)
CHGVAR VAR(%SST(&amp;FRMPARA 11 10)) VALUE(&FOUTQLIB)
CHGVAR VAR(%BIN(&RCVLEN)) VALUE(800)
/********** DATA AREA CREATION ********************/
CHGVAR VAR(%SST(&DTAARANAM 1 5)) VALUE(%SST(&FROMOUTQ 1 5))
CHGVAR VAR(%SST(&DTAARANAM 6 5)) VALUE(%SST(&TOOUTQ 1 5))
CHGVAR VAR(%SST(&DTAARAREV 1 5)) VALUE(%SST(&TOOUTQ 1 5))
CHGVAR VAR(%SST(&DTAARAREV 6 5)) VALUE(%SST(&FROMOUTQ 1 5))
/******************************************************************************/
CRTDTAARA: CRTDTAARA DTAARA(SPLDVTLIB/&DTAARANAM) TYPE(*CHAR) +
LEN(40) TEXT('Created for spool file +
printing redirection')
MONMSG MSGID(CPF1023) EXEC(GOTO CMDLBL(MSG1))
MONMSG MSGID(CPF1021) EXEC(DO)
CRTLIB LIB(SPLDVTLIB) TEXT('Library for spool file +
redirection utility')
GOTO CMDLBL(CRTDTAARA)
ENDDO
CRTDTAARA DTAARA(SPLDVTLIB/&DTAARAREV) TYPE(*CHAR) +
LEN(40) TEXT('Spool file redirection')
MONMSG MSGID(CPF1023) EXEC(GOTO CMDLBL(REVERT))
DLTDTAARA DTAARA(SPLDVTLIB/&DTAARAREV)
CALL PGM(QSPROUTQ) PARM(&amp;RCVAR &RCVLEN &FMTNAM +
&FRMPARA X'00000000')
CHGVAR VAR(&RMTPRTQNAM) VALUE(%SST(&RCVAR 472 128))
CHGVAR VAR(&IPADR) VALUE(%SST(&RCVAR 218 15))
CHGDTAARA DTAARA(SPLDVTLIB/&DTAARANAM (1 15)) +
VALUE(&RMTPRTQNAM)
CHGDTAARA DTAARA(SPLDVTLIB/&amp;DTAARANAM (16 15)) VALUE(&IPADR)
CHGOUTQ OUTQ(&FOUTQLIB/&FROMOUTQ) RMTSYS(*INTNETADR) +
RMTPRTQ(&TOOUTQ) INTNETADR('127.0.0.1')
STRRMTWTR OUTQ(&FOUTQLIB/&FROMOUTQ)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The +
spool divertion has been succesfully setup')
GOTO ENDPGM
REVERT: RTVDTAARA DTAARA(SPLDVTLIB/&DTAARAREV (16 15)) +
RTNVAR(&IPADR)
RTVDTAARA DTAARA(SPLDVTLIB/&DTAARAREV (1 15)) +
RTNVAR(&RMTPRTQNAM)
ENDWTR WTR(&FROMOUTQ) OPTION(*IMMED)
CHGOUTQ OUTQ(&TOUTQLIB/&TOOUTQ) RMTSYS(*INTNETADR) +
RMTPRTQ(&TOOUTQ) INTNETADR(&IPADR)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The +
spool file divertion reverted, Thank you!')
DLTDTAARA DTAARA(SPLDVTLIB/&DTAARANAM)
DLTDTAARA DTAARA(SPLDVTLIB/&DTAARAREV)
STRRMTWTR OUTQ(&FOUTQLIB/&FROMOUTQ)
GOTO CMDLBL(ENDPGM)
MSG1: SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The +
diversion is already active')
ENDPGM: ENDPGM



Benefits & drawbacks:
This utility will help in following benefits.
The redirecting and reverting can be done by calling the program and passing the parameters. Calling the same program will revert the redirection. Repeating the same step one more time, will enable the redirection the other way around.
This utility can help if the physical printer is not working.
Avoid any changes to the application for spool file redirection.
Saves lot of time and rework.

Drawbacks:
The utility is not user specific. Reach me for more utilities and any clarifications at dean@iseriesuniversity.com

Thursday, March 08, 2007

Delete detached audit journal receivers

Under many disk space crunch instances. We may require clearing the detached journal receivers. For example, as a system administrator we may need to clear the detached journal receivers of the system audit journal QAUDJRN.

This will bring down the system space utilization if the detached journal receivers are plenty.

Assumptions:
The journal receivers, to be deleted are backed up along with other important system objects as a part of Daily, Weekly or monthly backup.
The process does allow the execution of the sample program provided.


Now, this simple task can be automated with much simpler CL program.

PGM
DCLF FILE(SUBBU/AUDJRNFIL)
DSPOBJD OBJ(QGPL/AUDRCV*) OBJTYPE(*JRNRCV) +
OUTPUT(*OUTFILE) OUTFILE(SUBBU/AUDJRNFIL)
NEXT: RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM))
DLTJRNRCV JRNRCV(QGPL/&ODOBNM)
MONMSG MSGID(CPF7022) EXEC(SNDPGMMSG MSGID(CPF9898) +
MSGF(QCPFMSG) MSGDTA('The detached +
journal receivers are deleted'))
GOTO CMDLBL(NEXT)
ENDPGM: ENDPGM


The library name needs to be changed.
Outfile needs to be created before hand.

Reach me at dean@iseriesuniversity.com for any queries or clarifications.

Next, How to save the deceivers before deleting them

Labels: , , ,

Monday, February 26, 2007

*USER to reset *USRPRF

Purpose

With the Business Process Outsourcing and Remote administration flourishing, there are always requirement to complete all the tasks, except the tangible operations offshore.
The document is basically to elaborate how a reset for a user profile can be done from offshore, still maintaining accountability and authorization.

Assumption

The document assumes multi tier architecture in place. And, authority to reset the user profile rest with offshore team. The document further assumes, the Level 1 support posses the profile with user class *USER or any other User class and not *SECADM or *SECOFR.

The document further assumes the little knowledge of CL programming.

Back ground

Out of eight special authorities that are available for any user profile on iSeries system, *SECADM, is the authority that is required for creating, modifying and deleting the user profile. This also includes the password, status and password expiration status change.

It is the profile that posses this special authority, could change the password for any user profile, and change the status between *ENABLED or *DISABLED or change the password expiration status *YES or *NO.

When the responsibility of changing the password, profile status and the password expiration status rest with offshore level 1 support, can everyone be given the *SECADM authority? No.

This may lead to security non-compliance.

Adopted authority

iSeries among many other most useful features also provide us a feature called ‘Adopted Authority’. This is basically adopting the special authority of another profile than itself. So, irrespective of what the using user profile authority is, the profile can use this command or a program based on the objects adopted authority.

This is a very good feature if used properly. Else it may lead to opening the secured walls. And hence because of the criticality, this is a disallowed feature for some of the institutions.

Let us discuss the good part of it, with a proper illustration.

Resetting the User Profile

The illustration given here is a command and it’s CPP (Command Processing Program) for resetting a user profile.

The command and the CPP have the same name RESETPRF.
The CPP Program (RESETPRF CL Program):

PGM PARM(&USRPRF)
DCL VAR(&USRPRF) TYPE(*CHAR) LEN(10)
CHGUSRPRF USRPRF(&USRPRF) PASSWORD(&USRPRF) +
PWDEXP(*YES) STATUS(*ENABLED)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('The +
profile' *BCAT &USRPRF *BCAT 'has been reset')
ENDPGM


The program receives the user profile &USRPRF and resets the password to same as the user profile, change the status of user profile to *ENABLED, and changing the password expiry status to *YES.

Changing the password expiry to *YES, ensures the user has the accountability of activity done by the profile. This is because, it will prompt the user to change the password the next time it logs on to the system.

Now look at the simple CMD.

CMD
PARM KWD(USRPRF) TYPE(*CHAR) LEN(10) +
PROMPT('Enter the User Profile')

This is to receive the user profile to be reset the more meaningful way. And hence the display is like what is given below.

(RESETPRF)

Type choices, press Enter.

Enter the User Profile . . . . . > __________ Character value






Bottom
F3=Exit F4=Prompt F5=Refresh F12=Cancel F13=How to use this display
F24=More keys

Now type your profile name and the profile will be reset.
Now, where the adopted authority is being used? Let us get on to that.

The above program and the command can be created by any profile with *SECADM authority. On the CPP, which is none, but the CL program RESETPRF, in this case, needs a parameter to be changed to make it usable by other authorized profiles. This includes the profiles without *SECADM authority.


Change Program (CHGPGM)

Type choices, press Enter.

Program . . . . . . . . . . . . > RESETPRF Name, generic*, *ALL
Library . . . . . . . . . . . *USRLIBL Name, *USRLIBL
Optimize program . . . . . . . . *NO *SAME, *YES, *FULL, *BASIC...
User profile . . . . . . . . . . *OWNER *SAME, *USER, *OWNER
Use adopted authority . . . . . *YES *SAME, *YES, *NO
Remove observable info . . . . . *NONE *SAME, *ALL, *NONE...
+ for more values
Enable performance collection:
Collection level . . . . . . . *SAME *SAME, *NONE, *PEP, *FULL...
Procedures . . . . . . . . . . *ALLPRC, *NONLEAF
Profiling data . . . . . . . . . *SAME *SAME, *NOCOL, *COL, *CLR...
Teraspace . . . . . . . . . . . *NO *NO, *YES, *SAME
Force program re-creation . . . *NO *NO, *YES, *NOCRT
Text 'description' . . . . . . . 'Reset the user profile
'

Bottom
F3=Exit F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys

The field value for ‘User Profile’ needs to be changed to *OWNER from *USER. This makes any profile authorized to this object to use this command.

Now the command RESETPRF, should be created using CRTCMD.
Conclusion

This is a more useful feature that can be used for similar requirements. But, care should be taken on the adopted authority and the user profile authorized. This may else lead to a security exposure on the system.

This can be made as a menu option, for Level 1 support. This will enable them to reset the profiles without need for accessing the command line and *SECADM special authority.

Please mail me at dean@iseriesuniversity.com for any clarifications or concerns.

Subbu

Tuesday, February 20, 2007

This is to create a simple reporting tool for system administrator.

The requirement is, the profile should posses a *AUDIT authority as expected for any AS/400 system administrator. There should exist a data area, called DATTIM in your library or any library and please replace the library name 'Subbu' with yours.

And RTVDSKINF, should have been completed. It is very much recommended that this, command is submitted in batch mode, hence it does not eat up the system resources.

The CL program produces few spool files.

And here it is. The program is not very great, but can act as basic starting point for futher improvements.

*************** Beginning of data ***************************************************************************************
0001.00 PGM 070220
0002.00 DCL VAR(&TIME) TYPE(*CHAR) LEN(7) 070220
0003.00 DCL VAR(&amp;amp;DATE) TYPE(*CHAR) LEN(6) 070220
0004.00 DCL VAR(&TIME2) TYPE(*CHAR) LEN(4) 070220
0005.00 DCL VAR(&DATE2) TYPE(*CHAR) LEN(10) 070220
0006.00 RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATE) 070220
0007.00 RTVSYSVAL SYSVAL(QTIME) RTNVAR(&TIME) 070220
0008.00 RTVDTAARA DTAARA(SUBBU/DATTIM (1 10)) RTNVAR(&DATE2) 070220
0009.00 RTVDTAARA DTAARA(SUBBU/DATTIM (11 4)) RTNVAR(&TIME2) 070220
0010.00 DSPAUDJRNE ENTTYP(AF CO CD CP SV CA DO JS SF PW SV ZC) + 070220
0011.00 FROMTIME(&DATE2 &TIME2) 070220
0012.00 CHGDTAARA DTAARA(SUBBU/DATTIM (1 10)) VALUE(&DATE) 070220
0013.00 CHGDTAARA DTAARA(SUBBU/DATTIM (11 7)) VALUE(&TIME) 070220
0014.00 /******************************************************************************/ 070220
0015.00 SBMJOB CMD(PRTDSKINF RPTTYPE(*LIB)) 070220
0016.00 DSPSYSSTS OUTPUT(*PRINT) 070220
0017.00 /******************************************************************************/ 070220
0018.00 ENDPGM 070220
****************** End of data ******************************************************************************************

Hope this helps.

Thank you and you can reach me at dean@iseriesuniversity.com

Subramaniam.S