Add API_SQL

This commit is contained in:
SJLennon 2021-08-24 15:52:55 -04:00
parent 82180c4408
commit 6256be9353
2 changed files with 11 additions and 8 deletions

View File

@ -14,7 +14,7 @@ The company is long gone, but I recently found the code on my PC and resurrected
Now (2021) you can get similar information with SQL - see [Work Management Services](https://www.ibm.com/docs/en/i/7.4?topic=services-work-management) on the IBM site. However, I have not found an SQL interface to QWCLOBJL. I also suspect that this code if faster than SQL, but probably in most use cases speed may not be a factor.
**Update 08/2021**: See APIs_SQL for code that does the same thing but using SQL provided by IBM in [Work Management Services](https://www.ibm.com/docs/en/i/7.4?topic=services-work-management)
**Update 08/2021**: See [APIs_SQL](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs_SQL) for code that does the same thing but using SQL provided by IBM in [Work Management Services](https://www.ibm.com/docs/en/i/7.4?topic=services-work-management)
### GETOBJUSR.CMD
@ -73,23 +73,23 @@ S|The job is a system job.
W|The job is a spooled writer job.
X|The job is the SCPF system job.
Notes:
### Notes
1. The code was originally fixed format but I converted it to **FREE (using [Craig Rutledge's JCRCMDS](https://www.jcrcmds.com/)). If needed for general use it should probably be a service program. I'm not sure service programs were a thing in 1997, but if they were I was not familar with them then.
2. On more current OS releases you can get similar information in SQL with the [GET_JOB_INFO table function](https://www.ibm.com/docs/en/i/7.4?topic=services-get-job-info-table-function).
2. On more current OS releases you can get similar information in SQL with the [GET_JOB_INFO table function](https://www.ibm.com/docs/en/i/7.4?topic=services-get-job-info-table-function). For code using SQL, that is shorter and probably simpler, see [APIs_SQL](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs_SQL)
## Messages: QMHMOVPM (Move Program Messages) & QMHRSNEM (Resend Escape Message)
These commands makes handling CL program exceptions easy and concise. Source is an [article in IT Jungle](https://www.itjungle.com/2012/05/02/fhg050212-story01/) back in 2012. My thanks to Ted Holt and Brian Rusch.
### MOVPGMMSG - Move Program Messages Command
### MOVPGMMSG.CMD - Move Program Messages Command
This is a command that calls the IBM QMHMOVPM (Move Program Messages) API. You'd use it to pass diagnostic messages up to the calling program.
### RSNESCMSG - Resend Escape Message Command
### RSNESCMSG.CMD - Resend Escape Message Command
This is a command that calls the IBM QMHRSNEM (Resend Escape Message) API to send the current escape message to the calling program. This also ends the current program.
### CLERRHANDL - Ted Holt's CL Error Handler Template
### CLERRHANDL.CLLE - Ted Holt's CL Error Handler Template
This is execuatble code from Ted Holt that demonstrates handling exceptions in CL, using these two commands. When called it will fail and you will see the diagnostic message "From-file QCUSTCDT in *LIBL not found."

View File

@ -1,11 +1,12 @@
# Using IBM [Work Management Services](https://www.ibm.com/docs/en/i/7.4?topic=services-work-management)
IBM has begun providing access to APIs using SQL. The code here uses the QSYS2.OBJECT_LOCK_INFO SQL view. It is shorter and simplified code that can be used to replace that in [APIs which returns users who have a lock on an object](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs).
IBM has begun providing access to APIs using SQL. The code here uses the QSYS2.OBJECT_LOCK_INFO SQL view. This is shorter and simplified code that can be used to replace that in [APIs which returns users who have a lock on an object](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs).
## GETOBJUSR.CMD
This command is the top level interface. It is unchanged from the version in [APIs](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs), but it provided here for completeness.
Prompted, it looks like this:
![GetObjUsr Prompt](Images/GetObjUsr_1.jpg)
You specify the object and type and the command returns information on the locks on the object. You can return a file of objects and/or a message.
@ -14,6 +15,7 @@ The returned file is GETOBJUP in QTEMP.
The returned message would be suitable for sending to the operator and look something like one of these:
![GetObjUsr Message](Images/GetObjUsr_2.jpg)
![GetObjUsr Message](Images/GetObjUsr_3.jpg)
It shows the details of up to 4 jobs and lists how many additional jobs, if any, have locks.
@ -23,6 +25,7 @@ The job name can be copied and pasted into a WRKJOB command, e.g. `wrkjob 233920
## GETOBJUP File
If requested, this file is created in QTEMP. The contents would look like this:
![GetObjUsr Message](Images/GetObjUsr_4.jpg)
## GETOBJUC.CLLE
@ -33,7 +36,7 @@ This is the command processing program for the GETOBJUSR command. It does some h
This creates QTEMP/GETOBJUP if requested, using SQL. Then it retreives the job name using the QSYS2.OBJECT_LOCK_INFO view, and orders it by job name. It populates file GETOBJUP using SQL.
This about 100 lines shorter and it does not need the SRTUSRSPC program.
This about 100 lines shorter then the version in [APIs](https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/tree/master/APIs) and it does not need the SRTUSRSPC program.
## T0/T1/T2/T3.CLLE