as400 crtcmd command not created in library - command

I am making my own command, and so far the cl code that processes the .cmd code works just fine on its own. I can call it and send in the parameters and it does exactly what it needs to do, so I'm assuming that the error must be with the .cmd:
CMD 'DISPLAY SYSTEM LEVEL (DSPSYSLVL) NADIA S.C.'
PARM KWD(OUTPUT)
MIN(1)
TYPE(*CHAR) LEN(8)
RSTD(*YES)
VALUES(*MSGLINE *DISPLAY)
PROMPT('OUTPUT FOR SYSTEM LEVEL')
PARM KWD(SOLUTION)
TYPE(*CHAR) LEN(4)
RSTD(*YES)
VALUES(*YES *NO)
DFT(*NO)
PROMPT('TELL ME HOW YOU DID IT')
PARM KWD(SHOWCMD)
TYPE(*CHAR) LEN(4)
RSTD(*YES)
VALUES(*YES *NO)
DFT(*NO)
PROMPT('SHOW COMMAND')
when I run crtcmd and give the appropriate filenames, I get the message "Command DSPSYSLVL not created in library [library name]." with a CPF0201 message.
I'm still fairly new to the whole system, and I'm really not sure what the problem could be. The job log doesn't provide any new information either...

It may just be a transcription issue but the first thing that stands out is the multi-line format without the continuation character (+):
CMD 'DISPLAY SYSTEM LEVEL (DSPSYSL'
PARM KWD(OUTPUT) +
MIN(1) +
TYPE(*CHAR) LEN(8) +
RSTD(*YES) +
VALUES(*MSGLINE *DISPLAY) +
PROMPT('OUTPUT FOR SYSTEM LEVEL')
PARM KWD(SOLUTION) +
TYPE(*CHAR) LEN(4) +
RSTD(*YES) +
VALUES(*YES *NO) +
DFT(*NO) +
PROMPT('TELL ME HOW YOU DID IT')
PARM KWD(SHOWCMD) +
TYPE(*CHAR) LEN(4) +
RSTD(*YES) +
VALUES(*YES *NO) +
DFT(*NO) +
PROMPT('SHOW COMMAND')
Each PARM is a single entity and must be 'continued' if split onto multiple lines.
The CRTCMD command should generate a spooled file containing more details about the errors.
EDIT: Also the maximum length of the CMD prompt is 30 characters.

Related

Save job output from SDSF into a PDS and using ISPF functions in REXX

We periodically runs jobs and we need to save the output into a PDS and then parse the output to extract parts of it to save into another member. It needs to be done by issuing a REXX command using the percent sign and the REXX member name as an SDSF command line. I've attempted to code a REXX to do this, but it is getting an error when trying to invoke an ISPF service, saying the ISPF environment has not been established. But, this is SDSF running under ISPF.
My code has this in it (copied from several sources and modified):
parse arg PSDSFPARMS "(" PUSERPARMS
parse var PSDSFPARMS PCURRPNL PPRIMPNL PROWTOKEN PPRIMCMD .
PRIMCMD=x2c(PPRIMCMD)
RC = isfquery()
if RC <> 0 then
do
Say "** SDSF environment does not exist, exec ending."
exit 20
end
RC = isfcalls("ON")
Address SDSF "ISFGET" PPRIMPNL "TOKEN('"PROWTOKEN"')" ,
" (" VERBOSE ")"
LRC = RC
if LRC > 0 then
call msgrtn "ISFGET"
if LRC <> 0 then
Exit 20
JOBNAME = value(JNAME.1)
JOBNBR = value(JOBID.1)
SMPDSN = "SMPE.*.OUTPUT.LISTINGS"
LISTC. = ''
SMPODSNS. = ''
SMPODSNS.0 = 0
$ = outtrap('LISTC.')
MSGVAL = msg('ON')
address TSO "LISTC LVL('"SMPDSN"') ALL"
MSGVAL = msg(MSGVAL)
$ = outtrap('OFF')
do LISTCi = 1 to LISTC.0
if word(LISTC.LISTCi,1) = 'NONVSAM' then
do
parse var LISTC.LISTCi . . DSN
SMPODSNS.0 = SMPODSNS.0 + 1
i = SMPODSNS.0
SMPODSNS.i = DSN
end
IX = pos('ENTRY',LISTC.LISTCi)
if IX <> 0 then
do
IX = pos('NOT FOUND',LISTC.LISTCi,IX + 8)
if IX <> 0 then
do
address ISPEXEC "SETMSG MSG(IPLL403E)"
EXITRC = 16
leave
end
end
end
LISTC. = ''
if EXITRC = 16 then
exit 0
address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
"NAMES(TSEL TSMPDSN)"
I execute this code by typing %SMPSAVE next to the spool output line on the "H" SDSF panel and it runs fine until it gets to this point in the REXX:
114 *-* address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
"NAMES(TSEL TSMPDSN)"
>>> "TBCREATE SMPDSNS NOWRITE NAMES(TSEL TSMPDSN)"
ISPS118S SERVICE NOT INVOKED. A VALID ISPF ENVIRONMENT DOES NOT EXIST.
+++ RC(20) +++
Does anyone know why it says I don't have a valid ISPF environment and how I can get around this?
I've done quite a bit in the past with REXX, including writing REXX code to handle line commands, but this is the first time I've tried to use ISPEXEC commands within this code.
Thank you,
Alan

Subprocess no output in windows

I need to run an exe file with different parameters and write the output to a file. I tried the following script. After the program is running, the output file is empty. Tell me how to solve this problem
import subprocess
output_f = open('output.txt', 'a')
for i in "abcdefghijklmnopqrstuvwxyz{}_":
for j in "abcdefghijklmnopqrstuvwxyz{}_":
program = 'C:/Users/PC/Desktop/task2 (1).exe ' + i +" " +j;
process = subprocess.Popen(program,stdout=output_f)
code = process.wait()
output_f.close()
print(code)

Updating my current script which modifies multiple lines into a single one

My current script copies text like this with a shortcut:
:WiltedFlower: aetheryxflower ─ 4
:Alcohol: alcohol ─ 3,709
:Ant: ant ─ 11,924
:Apple: apple ─ 15
:ArmpitHair: armpithair ─ 2
and pastes it modified into a single line
Pls trade 4 aetheryxflower 3 alcohol 11 ant 15 apple 2 armpithair <#id>
As you can see there are already two little problems, the first one is that it copies only the number/s before a comma if one existed instead of ignoring it. The second is that I always need to also copy before hitting the hotkey and start re/start the script, I've thought of modifying the script so that it uses the already selected text instead of the copied one so that I can bind it with a single hotkey.
That is my current script, it would be cool if anyone can also tell me what they used and why exactly, so that I also get better with ahk
!q::
list =
While pos := RegExMatch(Clipboard, "(\w*) ─ (\d*)", m, pos ? pos + StrLen(m) : 1)
list .= m2 " " m1 " "
Clipboard := "", Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
If the pattern of your copied text dont change, you can use something like this:
#Persistent
OnClipboardChange:
list =
a := StrSplit(StrReplace(Clipboard, "`r"), "`n")
Loop,% a.Count() {
b := StrSplit( a[A_Index], ": " )
c := StrSplit( b[2], " - " )
list .= Trim( c[2] ) " " Trim( c[1] ) " "
}
Clipboard := "Pls trade " list " <#951737931159187457>"]
ToolTip % Clipboard ; just for debug
return
With your example text, the output will be:
Pls trade aetheryxflower ─ 4 alcohol ─ 3,709 ant ─ 11,924 apple ─ 15 armpithair ─ 2 <#951737931159187457>
And this will run EVERY TIME your clipboard changes, to avoid this, you can add at the top of the script #IfWinActive, WinTitle or #IfWinExist, WinTitle depending of your need.
The answer given would solve the problem, assuming that it never changes pattern as Diesson mentions.
I did the explanation of the code you provided with comments in the code below:
!q::
list = ; initalize a blank variable
; regexMatch(Haystack, regexNeedle, OutputVar, startPos)
; just for frame of reference in explanation of regexMatch
While ; loop while 'pos' <> 0
pos := RegExMatch(Clipboard ; Haystack is the string to be searched,
in this case the Clipboard
, "(\w*) ─ (\d*)" ; regex needle in this case "capture word characters
(a-z OR A-Z OR 0-9 OR _) any number of times, space dash space
then capture any number of digits (0-9)"
, m ; output var array base name, ie first capture will be in m1
second m2 and so on.
, pos ? pos + StrLen(m) : 1) ; starting position for search
"? :"used in this way is called a ternary operator, what is saying
is "if pos<>0 then length of string+pos is start position, otherwise
start at 1". Based on the docs, this shouldn't actually work well
since 'm' in this case should be left blank
list .= m2 " " m1 " " ; append the results to the 'list' variable
followed with a space
Clipboard := "" ; clear the clipboard.
Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0 ; wait zero seconds for the clipboard to change
If ErrorLevel ; if waiting zero seconds for the clipboard to change
doesn't work, give error msg to user.
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
Frankly this code is what I would call quick and dirty, and seems unlikely to work well all the time.

Infinite loop stops

I have googled this a lot and I can only find answers that relate to conditions within the loop being met. I want this loop to run infinitely (Hence while 1==1) and I'm testing it at the moment by just leaving it running in Thonny. It runs for variable lengths of time and then just stops. It doesn't exit the program or stop running, it just behaves as if it's waiting for something but there's nothing that I can see that it's waiting for. The shell doesn't report any errors or report that it has stopped running, it simply stops printing the string in the fourth line print statement.
I am very new to python and Linux and I have no idea how to debug this problem or where to look for the stopping point. Even running it in debug mode doesn't render any helpful information. Has anyone got any suggestions please?
The only other thing that I have tried outside of what I have said is I have tried running it on a fresh install of Raspberry Pi OS on three different Raspberry Pi 4 Model B computers. It behaves exactly the same on all of them.
while 1==1:
time.sleep(1)
cnt = 1
print('One = One loop ' + str(datetime.today()) + ' CNT: ' + str(cnt))
while Decimal(target_temperature()) - Decimal(0.3) >= Decimal(actual_temperature()) and switch_state() == 'currently not running':
print('Before heating loop ' + str(datetime.today()))
try:
if cnt == 1:
if Decimal(target_temperature()) - Decimal(0.3) >= Decimal(actual_temperature()) and switch_state() == 'currently not running':
print('First heating loop ' + str(datetime.today()))
requests.get('http://192.168.1.167/4/on')
log_db('On', str(target_temperature()), str(actual_temperature()))
time.sleep(225)
requests.get('http://192.168.1.167/4/off')
log_db('Off', str(target_temperature()), str(actual_temperature()))
time.sleep(300)
cnt = cnt + 1
if(cnt != 1):
if Decimal(target_temperature()) - Decimal(0.3) >= Decimal(actual_temperature()) and switch_state() == 'currently not running':
print('Second heating loop ' + str(datetime.today()))
requests.get('http://192.168.1.167/4/on')
log_db('On', str(target_temperature()), str(actual_temperature()))
time.sleep(180)
requests.get('http://192.168.1.167/4/off')
log_db('Off', str(target_temperature()), str(actual_temperature()))
time.sleep(300)
except Exception as e:
print(e)
Bearing in mind i don't know anything about python i will try to help.
1 - The first thing i would do is put the whole program in a try catch block. That wasy if anything bad happens you should be told about it
try:
<all your code>
except Exception as e2:
print('The whole thing errored' + e2)
2 - The delays are in seconds? For testing i would change every sleep to (30) so you can see what is going on without getting too bored waiting, when you have it working then change the times back.
3 - I would add some more print('got here!') like where you have if(cnt == 1) add else print('first loop wasnt 1 it was ' + cnt)
4 - try and make the code easier for you to read, when it gets actually run it will be so optimized that it wont bear any relation to what you write. So write it in a way that is easiest for you
5 - You turn it on and then off, but if the off failed it would never be turned off, you should assume that it will go badly and that will be the day you get a big bill. Try and stop it if an error occurs by adding another check if actualTemp > targetTemp then turn it off?
6 - the http request might take ages, specify a time in seconds you are prepared to wait like , timeout=60
try:
while 1==1:
try:
time.sleep(30)
targetTemp = Decimal(target_temperature())
actualTemp = Decimal(actual_temperature())
switchState = switch_state()
print('Doing it at ' + str(datetime.now()) + ' target ' + str(targetTemp) + ' actual ' + str(actualTemp) + ' switch ' + switchState)
if targetTemp - Decimal(0.3) >= actualTemp and switchState == 'currently not running'
print('too cold turning it for a bit!')
requests.get('http://192.168.1.167/4/on', timeout=60)
log_db('On', targetTemp , actualTemp)
else if actualTemp > targetTemp and switchState != 'currently not running'
print('too hot turning it off!')
requests.get('http://192.168.1.167/4/off', timeout=60)
log_db('Off', targetTemp , actualTemp)
else
print('Not doing anything!')
except Exception as e1:
print('Loop errored -> ' + e1)
except Exception as e2:
print('Whole thing errored -> ' + e2)
Thanks Billy the Kid. You were right. Sometimes the devices that the loop uses via HTTPRequests just don't reapond (the two functions use HTTPRequests) and sometimes they create errors that aren't caught in the loop. Putting the whole thing in a try/catch oddly did identify that. Problem solved.

Why is this block of code producing runtime error 91

This block of code is causing runtime error 91 or with block not set error
this code is for opening reports in crystal report in vb6
For DocCodeCount = 0 To cboDoctorsCode.ListCount - 1
strReportTitle = "DOCTOR'S TRANSMITTAL COPY"
strSqlStatement = "PFMS '" & cboControlCode.Text & "', '" & cboDoctorsCode.List(DocCodeCount) & "', '" & sCurrentUserName & "'"
strFilename = App.Path & "\Reports\ClaimsBillProc\PF MS.rpt"
newRpt.OpenReport vADOConnection, strSqlStatement, strFilename, strReportTitle, 3, False
Set newRpt = Nothing
Next
When used in 1 time opening of report it runs fine but when it is used in this manner in the loop it causes error.
The answer is quite clear: You destroy your object within the loop.
This line is the obvious reason for your one time wonder:
Set newRpt = Nothing