Using CADI Query to send email to PX user
These are
notes to/from Greg and Floy re using CADI Query to email files to users. They
are in last-first order, on or about February 1, 2005.
Thanks for the additional tutorial. Actually, I had already tried that, or something pretty close, based on your earlier document, the one which started this chain of Q&A. But I had run into the problem of the key, which is a variable created by the user response when the batch is run.
BUT, I finally figured it out!!! I had to change to .batchowner and .document_no because I had to find a file where the primary key matched what the user was prompted to enter. The batch works now and I’ve put it on the FIS menu so that our AP clerk can email the po to the author by running the batch. This is what the last run of the batch looks like:
$ RUN
DMS:FORM
PO
DPSLIB:DPS_PO
NO
YES
.PONUMBER
VENDOR
fiscode
dps_codes
DPS_LIST
NO
NO
YES
27
1
POEMAIL_$REQNUM$.LIS
YES
-1
$ !
$ CADI QUERY/OUTPUT="TMP$/LOGICAL" REQ 01$REQNUM$ .BATCHOWNER
$ PXUSERNAME = F$TRNLNM("TMP$_1")
$ MAIL POEMAIL_$REQNUM$.LIS/SUBJ="Your approved P.O. for Req # $REQNUM$" 'PXUSER
NAME
$ !
I think
this would be a good improvement to write into DPS so that it occurs
automatically when this selection is made.
flp
The batch should contain the following lines:
$ CADI QUERY/OUTPUT="TMP$/LOGICAL" filename key .PXUSERNAME
$ PXUSERNAME = F$TRNLNM("TMP$_1")
$ MAIL POEMAIL.LIS/SUBJ="Your approved P.O." 'PXUSERNAMELine 1: You’ll need to change the CAdi command’s “filename” and “key” to whatever file this field .PXUSERNAME is stored in and whatever key you want it to find. This will populate the logical TMP$ with the value “1” (one field was queried). And it will populate the logical TMP$_1 with the value of the field .PXUSERNAME for the queried record.
Line 2: This line sets the symbol PXUSERNAME to the value of the logical TMP$_1
Line 3:This line mails the file. The last value in this line is the user to receive the mail message which, in this case, is the symbol PXUSERNAME (anytime you reference a symbol outside of quotes in a DCL procedure, the symbol is preceded with a single quote mark)… FYI, if the symbol is inside of quotation marks, it is preceded with two single quote marks and followed by a single quote mark. For example, SUBJECT=”Here’s an email to ‘’PXUSERNAME’ “
Whoever executes this procedure will need to have the symbol CADI defined (or the system won’t understand the command CADI at the dollar prompt).
It
seems to work for REG user. Getting back to my original idea, can a FIS or DPS
user use the Cadi Query function, for instance to email an approved po to the
requisition author? This is where I started with my Cadi Query questions. I
wanted Fis_acct1 to be able to email a po. Not sure if it works only in REG or
if I can make it work in other modules.
flp
Sure…
$ PKG_P8 = F$TRNLNM(“REG$DEF_TERMCODE”)
I think that
ought to do it. However, this means that the REG$DEF_TERMCODE must be defined
BEFORE it gets to this line of code, so the CAdi Logs section will have to be
executed AFTER the Registration Logs are set.
Greg
I made
the changes and removed the define/system commands.
Also removed the default termcode set for P8 within the SBR section,
$SBR_LOGS:
$ !
$ PKG_COM = "SBRSYS_EXE:[SBR.EXE]BILLOGS"
$ PKG_P1 = ""
$ PKG_P2 = ""
$ PKG_P3 = ""
$ PKG_P4 = ""
$ PKG_P5 = ""
$ PKG_P6 = ""
$ PKG_P7 = ""
$ PKG_P8 = "043s" (I removed the 043S)
$ GOSUB DO_COM
$ RETURN
$ !
because
I’d prefer not to have to maintain the two default termcodes (I tried moving the
cadi cmd around in the reg login file, but it didn’t seem to matter). Now, the
reg user is asked for the SBR default termcode. Is there a way within
reg_cadi_logs.com to have the SBR P8 parameter default to the default reg term?
flp
Adding the “REG” as parameter 1 (P1) is still necessary so that the program knows what section of code to do:
$PROMPT_PKG:
$ IF
P1 .EQS. ""
$
THEN IF F$MODE() .EQS. "INTERACTIVE"
$ THEN ASK P1 "Package Code <''DEFALT_PKG'> : "
$ ENDIF
$ !
$ IF P1 .EQS. ""
$ THEN P1 = DEFALT_PKG
$ ENDIF
$ ENDIF
$ !
$ P1 = F$EDIT(P1,"UPCASE,COLLAPSE")
$ ELENUM = 0
$ !
$VALIDATE_PKG:
$ PKG = F$ELEMENT(ELENUM,",",VALID_PKGS)
$
IF PKG .NES. ","
$ THEN IF PKG .EQS. P1
$ THEN GOTO
'P1'_PACKAGE
$ ELSE ELENUM = ELENUM + 1
$ GOTO VALIDATE_PKG
$ ENDIF
$ ENDIF
If P1 is
empty, it will prompt the user for what package the Server is running for. It
then goes to the label xxx_PACKAGE depending on what package is entered at the
prompt. Of course, if you wanted to, you could strip out all the other packages
from this specialized REG_CADI_LOGS since it will always be running for REG.
The easiest thing is just to pass the “REG” as P1.
Greg
I
understand except for one thing: What is meant by the “REG” at the end of the
cmd line:
$ @CDISYS_EXE:[CADI_SERVER.EXE]CADI_LOGS REG
If I
copy
$copy cdisys_exe:[cadi_server.exe]cadi_logs.com
users1:[reg.exe]reg_cadi_logs.com
And put the execution of reg_cadi_logs.com in the reg login file, do I need to
follow it with “REG”?
flp
Here are a few examples of CAdi commands and their results that I ran on your system:
1. A simple
query to the STUDENT file returning the results to the screen:
$ CADI QUERY STUDENT 123456789 FIRSTNAME
John
2. A similar
query, returning the results to a text file:
$ CADI QUERY/OUT="GREG.XXX" STUDENT 123456789 FIRSTNAME
$ TYPE GREG.XXX
John
3. A similar
query, returning the results to a set of logicals
$ CADI QUERY/OUTPUT="MYQUERY/LOGICAL" STUDENT 123456789 FIRSTNAME
$ SHO LOG/JOB MYQUERY*
(LNM$JOB_810C9000)
"MYQUERY" = "1"
"MYQUERY_1" = "John"
4. A similar
query, returning the results to a set of logicals that include the field names
$ CADI QUERY/OUTPUT="MYQUERY/LOGICAL=FIELDID" STUDENT 123456789 FIRSTNAME
$ SHO LOG/JOB MYQUERY*
(LNM$JOB_810C9000)
"MYQUERY" = "1"
"MYQUERY_1" = "FIRSTNAME=John"
5. The job
logical CADI$STATUS will always show you whether a CAdi command was successful
or failed. If this logical is set to “0”, then the command was successful
$ SHO LOG/JOB CADI$STATUS*
(LNM$JOB_810C9000)
"CADI$STATUS" = "0"
6. Example
of CAdi Command that was unsuccessful and the CADI$STATUS logicals after that
query
$ CADI QUERY/OUTPUT="MYQUERY/LOGICAL=FIELDID" STUDENT 123456789
FIRSTNAME,LASTNAME,GPA
$ SHO LOG/JOB CADI$STATUS*
(LNM$JOB_810C9000)
"CADI$STATUS" = "1"
"CADI$STATUS_TEXT" = "1"
"CADI$STATUS_TEXT1" = "The list of fields to query was invalid."
You don’t
have a field named GPA in your student file.
Greg
Is the
Cadi Query command supposed to return something to the screen? It doesn’t.
$ CADI QUERY STUDENT 444449156 FIRSTNAME,LASTNAME,GPA
Looked
in manual and found the /output qualifier. Used that but it didn’t create a .lis
file.
$ CADI QUERY STUDENT 444449156 FIRSTNAME,LASTNAME,GPA/output=flp.lis
How do
I see the result?
flp
I’ve
increased REG_FLOY’s Page Fault Quota, this should allow you to execute the
program now.
Greg
I put the command line in my login, then ran the query again and got this:
$ CADI
QUERY STUDENT 444449156 FIRSTNAME,LASTNAME,GPA
%DCL-W-ACTIMAGE, error activating image CDISYS_EXE:[CADI_SERVER.EXE]CADI
-CLI-E-IMGNAME, image file DKA0:[CADI_SERVER.EXE]CADI.EXE;19
-SYSTEM-F-EXQUOTA, process quota exceeded
Does
this mean I need to change something in my authorize setup?
flp
I’ve modified the CADI_LOGS file so that now any user can execute the file.
That being
said, she’s still going to get an “insufficient privilege” error because of the
following line that is in the CAdi Logs command procedure:
$ DEFINE/SYSTEM CADI$REG_KEY "STUDENT=K0"
This user isn’t a system user and therefore can’t define system logicals.
The only way
that I can think to get around this would be for you to copy the CADI_LOGS
command procedure to another name/location (I would suggest
REGSYS_EXE:[REG.EXE]REG_CADI_LOGS.COM) and remove this line from the new file.
Then, have your REG users execute the one in the REG directory when they log
in. You could also make any other changes that you wanted to in this copied
version (like removing the definition of the default termcode).
Greg
I added this to the users1:[reg]login.com file which several people use. One user, reg_charlott gets this msg upon login, now. She has Group, Grpprv & Oper privileges. What else does she need?
%DCL-E-OPENING,error
opening DKAO:[CADI_SERVER>EXE]CADI_LOGS: as input-RMS-E-PRV, insufficient
privilege or privilege or file protection violation.
Floy
CAdi can be
used to query any DMS datafile. It’s not a program that only works using
CampusConnect. It can be run from the $ prompt, just like the DMS programs (ASQ,
SORT, etc). The format of a simple command is:
$ CADI QUERY filename key field1,field2
For example:
$ CADI QUERY STUDENT 123456789 FIRSTNAME,LASTNAME,GPA
Greg
Pinkston
You
mailed this to me some time back. I need to know if CADI QUERY works on my
system. Can it be used on any file or just the Course file?
I want to
use it on a DPS file. I’ve got a test batch called dpstest.bcf in
users:[reg_flprpt] directory, trying to figure out how to mail a p.o. to the
author of a requisition. The test req # is 8965; the username is
SYSMGR (me).
flp
USING CAdi QUERY TO MAIL MESSAGE TO USERNAME CONTAINED IN FIELD
COURSE file has .USERNAME field (name of person who added the Course). How do
we use the data in the .USERNAME field as the recipient of an email message,
such as:
$ MAIL/SUBJECT="CRSEID$ was deleted from Course file" CRSDEL_NOTIFY.LIS USER$
We do not want the current USERNAME$ (person running the program) but rather
the USERNAME field data in the COURSE file for the selected record, i.e., not
this:
* EQUATE <$USER$> <...USER>
This can be done using CAdi commands...
$ CADI QUERY/OUTPUT="CRS/LOGICAL" COURSE "MATH1301 01033S" USERNAME
CAdi queries the file COURSE for the courseid specified and returns the value of the field .USERNAME to the logical CRS_1 (Since there was only one field requested.)
$ MAILTO = F$TRNLNM("CRS_1")
Sets the variable MAILTO to the value of the logical CRS_1
$ MAIL/SUBJECT="Course MATH1301 01033S has been deleted" BODY.EMAIL 'MAILTO
Sends a mail message to the MAILTO variable with the specified subject and uses a pre-defined file BODY.EMAIL as the content of the message.
This is only a valid option for PX Clients with CAdi installed (which comes with CampusConnect).