I am new to REXX. Actually I have couple of questions.
I created a REXX tool names as 'B' to take a Browse a file. Whenever I type in 'B' in the command line and then place the cursor over the Dataset name and will Press enter to Browse the file.
I have added this rexx tool's PDS file to SYSPROC.
1) But When I try to run this Browse tool by typing as 'B' in the command line, it runs only when the dataset is in the edit/view mode. IF I have opened the dataset in Browse mode(non-editable mode), the REXX tool 'B' gets triggered only if I type as 'TSO B' in the command line.
I wish to use just 'B' in all the cases, without using the keyword TSO. Please suggest me how to get rid of this TSO command/Keyword in non-editable screens.
2) 2nd Question is: There are 2 error messages doing validation of dataset one is ZEDSMSG and another is ZEDLMSG. I wish to display both the message at the same time. But the system is expecting to Press F1/Help to display ZEDLMSG.
How to display both ZEDSMSG and ZEDLMSG at the same time without any manual intervention.
Code(Got it from some forum. Its working fine)
Code:
/* REXX B*/
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
ADDRESS ISREDIT "MACRO ("DSN") PROCESS"
'ISREDIT (ROW1, COL1) = CURSOR'
IF DSN <> "" THEN DO
IF DSN == 'DSN' THEN
DO
CALL BROWSE1
EXIT
END
ELSE
DO
SYSFILE1=DSN
END
END
ELSE DO
IF DATATYPE(COL1,'N')==1 THEN DO
IF COL1 = '00000' THEN EXIT
ADDRESS ISREDIT "(CURLINE) = LINE .ZCSR"
DELIM = "~'!%?&-_=+?\{};:`<,>/?*()@#$¬|" '"'
LOFLINE = LENGTH(CURLINE)
HQUAL = USERID()
START = LOFLINE - VERIFY(REVERSE(CURLINE),DELIM,"M",LOFLINE-COL1+1)+2
LOFLINE = VERIFY(CURLINE,DELIM,"M",COL1)-1
IF START <= LOFLINE THEN
SYSFILE1 = STRIP(SUBSTR(CURLINE,START,LOFLINE-START+1))
ELSE DO
ZEDSMSG = "INVALID CURSOR POSITION"
ZEDLMSG = "INVALID CURSOR POSITION. PLACE THE CURSOR OVER THE DATASET"
'ISPEXEC SETMSG MSG(ISRZ001)'
EXIT
END
TEMP =LISTDSI("'"SYSFILE1"'")
IF(SYSREASON /= '0000')
THEN DO
ZEDSMSG = "INVALID DATASET NAME"
ZEDLMSG = "INVALID DATASET NAME : '"SYSFILE1"'"
'ISPEXEC SETMSG MSG(ISRZ001)'
EXIT
END
END
END
ADDRESS ISPEXEC "BROWSE DATASET('"SYSFILE1"')"
EXIT
BROWSE1:
ADDRESS ISPEXEC
'VGET (ZSCREENI,ZSCREENC,ZENVIR)' /* EXTRACT SCREEN IMAGE,
CURSOR POS AND ISPF LEVEL */
IF SUBSTR(ZENVIR,5,4) < '4.5' THEN
CALL GET_ZSCREEN_VALUES
TRTABLE='ABCDEFGHIJKLMNOPQRSTUVWXYZ' /* SETUP VALID DSNAME CHARS */
TRTABLE=TRTABLE !! TRANSLATE(TRTABLE) !! '$#@0123456789.''-{()'
TRTABLE=TRANSLATE(XRANGE('00'X,'FF'X),,TRTABLE,' ')
ZSCREENI=TRANSLATE(ZSCREENI,,TRTABLE,' ') /* REMOVE NON-DSN CHARS */
IF SUBSTR(ZSCREENI,ZSCREENC+1,1) <> ' ' THEN /* MAYBE CSR ON DSN */
DO /* EXTRACT DSN FROM SCREEN IMAGE
AND BROSWE DATASET */
NAME=WORD(SUBSTR(ZSCREENI,1+LASTPOS(' ',ZSCREENI,ZSCREENC)),1)
NAME=TRANSLATE(STRIP(SUBSTR(NAME,1,56))) /* MAX OF 56 CHAR NAME */
IF SUBSTR(NAME,1,1)='(' THEN
PARSE VAR NAME '('NAME')'.
PARSE VAR NAME DSN '('MEM')' /* IS THERE A MEMBER NAME? */
OMEM=MEM
IF MEM<>'' THEN /* IF SO, REFORMAT FOR BROWSE
CMD */
DO
GDG=0
NAME=DSN /* GET DSN */
IF SUBSTR(NAME,1,1)='''' THEN /* IF ORIGINAL NAME STARTED WITH
QUOTES */
NAME=NAME'''' /* FIX QUOTES */
IF DATATYPE(MEM,'N') = 1 THEN /* GDG? */
DO
DROP OTRAP.
CALL OUTTRAP 'OTRAP.'
ADDRESS TSO 'LISTCAT ENT('NAME')' /* GET REAL GDG NAMES */
CALL OUTTRAP 'OFF'
IF OTRAP.0>(2-2*MEM) THEN /* IF ENOUGH LINES RETURNED */
DO
A=OTRAP.0-1+2*MEM /* PARSE LISTCAT OUTPUT */
N="'"SUBWORD(OTRAP.A,3,1)"'" /* GET REAL DSNAME */
IF SYSDSN(N)='OK' THEN /* VERIFY THAT DS EXISTS */
DO /* IF REAL GDG NAME EXISTS */
NAME=N /* USE REA NAME AS DSNAME */
MEM='' /* FORGET THE MEMBER NAME */
OMEM='' /* FORGET THE MEMBER NAME */
GDG=1 /* INDICATE WE FORGOT MEMBER
NAME */
END
END
END
IF GDG=0 THEN /* IF GDG CHECK FAILED */
MEM='MEMBER('MEM')' /* ADD MEMBER KEYWORD FOR BR */
END
'CONTROL ERRORS RETURN' /* RETURN ERRORS TO PROGRAM */
'LMINIT DATAID(VCURSOR) DATASET('NAME')' /* ALLOC W/ TSO NAMING */
IF RC>0 & SUBSTR(NAME,1,1) <> "'" THEN /* ALLOC W/O TSO NAME */
'LMINIT DATAID(VCURSOR) DATASET('''NAME''')'
IF RC=0 THEN
DO
SERVICE=TRANSLATE(SERVICE)
IF SERVICE<>"" THEN
SERVICE 'DATAID('VCURSOR')' MEM /* BROWSE THE DATASET */
END
ELSE /* ALLOCS FAILED: SET ORIGINAL
MESSAGE */
'LMINIT DATAID(VCURSOR) DATASET('NAME')'
IF RC>7 THEN
'SETMSG MSG(ISRZ002)' /* IF ERROR, SHOW MESSAGES */
'LMFREE DATAID(&VCURSOR)' /* FREE DS IF ALLOCATED */
END
ELSE /* CURSOR WAS NOT ON A DSNAME */
DO /* GIVE USER AN ERROR MESSAGE */
ZERRSM = 'INVALID CURSOR POSITION'
PARSE VALUE '* YES THE CURSOR WAS NOT ON A DATA SET NAME.',
WITH ZERRHM ZERRALRM ZERRLM
'SETMSG MSG(ISRZ002)'
END
XIT 0
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
Please use the code tags when posting data/code. Thet maintain spacing. Your posted code appears to have no indentation - if that is true then I suggest the first thing you do is indent it properly.
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
Quote:
How to display both ZEDSMSG and ZEDLMSG at the same time
Those are the short message and the long message text. If you only want the long message, do not provide the short message.
You said you want both... but in this situation the long message text already includes the short message text, so I do not think it is necessary to actually combine the text. In other situations, just make the long message text to have the text you want to show.
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
The logic of your tool relies on editor macro statements. Those statements will not work outside of edit (or view). Nor will they work if you issue a "TSO B" command. What you are trying to do will not work.
But in general, if you do want to shorten the keystrokes, use a PF key or add an entry to your USERCMDS table.
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
Quote:
ADDRESS ISREDIT "MACRO ("DSN") PROCESS"
You have written and EDIT macro.
This means you need to use edit (or view) to invoke this macro.
Even if you invoke with TSO first, it will not work as the ISREDIT commands will fail.
While it can be done while in Browse, it is a lot of trial and error of new techniques. Not worth it in my book.
Quote:
I wish to use just 'B' in all the cases, without using the keyword TSO. Please suggest me how to get rid of this TSO command/Keyword in non-editable screens.
As the Rolling Stones once said: You can't always get what you want.
You said you want both... but in this situation the long message text already includes the short message text, so I do not think it is necessary to actually combine the text. In other situations, just make the long message text to have the text you want to show.
I removed the short message as you suggested. Using only ZEDLMSG. Thanks!!!
Quote:
The logic of your tool relies on editor macro statements. Those statements will not work outside of edit (or view). Nor will they work if you issue a "TSO B" command. What you are trying to do will not work.
Regarding TSO B: Yes its working in non-editable screen while using 'TSO B'. If the screen is non-editable, The DSN always contains value 'DSN', hence 'Browse1' Module is called, which converts non-editable into editable using VGET command(I think so).
Hi Daveporcelan/All,
Quote:
Even if you invoke with TSO first, it will not work as the ISREDIT commands will fail.
I am new to REXX. You are suggesting that ISREDIT is preventing my expectation(for removing command TSO while typing 'TSO B'). Could you please suggest how to overcome this
Because in my previous company, They used some tool, so they can use B for Browse, V for view and so on. But there is no such utility/tool available in my current company to browse/view/edit the file using the command from primary command line.
If I move my current design to production, Since the number of keystokes are larger (Have to type 'TSO B' instead of 'B'), I believe no one will use it(they will opt with ISPF 3.4 option itself).
Please suggest me how to avoid using TSO. Is it possible in REXX or any other language or tool is needed to achieve this?
The only solution that I know of which will work everywhere, is using the ISPF Command Table as previously suggested.
I have done something similar to what you describe, though my program scans the screen data copy in variable ZSCREENI for the datasetname under the cursor. Note - I recently changed the Screendsn section, so it might not work in all situations.
The program is called @BEVDS and is stored in SYSEXEC:
Code:
/* rexx
Browse, Edit or View named dataset
*/
arg what ds .
if what='' then exit xmsg("Missing 'what'")
if ds ='' then ds=ScreenDsn()
if ds ='' then exit xmsg("Missing dataset")
ds="'"strip(ds,"b","'")"'"
if Sysdsn(ds)<>'OK' then exit xmsg(ds Sysdsn(ds))
if what='M' then Call MEMLIST
if length(what)=1 then,
what=word('BROWSE EDIT VIEW',pos(what,'BEV'))
address ispexec what "dataset("ds")"
exit 0
XMsg: if arg(1)<>'' then say arg(1);return word(arg(2) 0,1)
Then I have 3 command table entries:
BDS executes @BEVDS with option B
EDS executes @BEVDS with option E
VDS executes @BEVDS with option V
The command table program I use is found at CBTTAPE.ORG file 349. I like that 'cause I wrote it, but I know that there are others.
The actual statements when using CBT349 are:
Code:
\BDS\0\SELECT CMD(%@bevds B &zparm)\
\EDS\0\SELECT CMD(%@bevds E &zparm)\
\VDS\0\SELECT CMD(%@bevds V &zparm)\
Thanks a lot Willy for providing complete code!!! .
But eventhough, I am not getting how to execute those Command table entries.
Steps done:
1) Placed the REXX program 'BEVDS' as a member at the dataset XXXX.ANAND.REXX.
2) Again I typed the 3 command table statements in the separate member in the same PDS 'XXXX.ANAND.REXX' with the member name as 'TEMP'
3) Added the PDS 'XXXX.ANAND.REXX' to SYSPROC/SYSEXEC.
Please suggest me how to proceed further/execute this. IF I execute 'BEVDS' by typing as 'bevds' in command line, it says 'MISSING WHAT Argument'. If I execute Temp, it says invalid symbol @ or / or invalid select command.
I am trying to execute your code in different ways for past 2 weeks. But I am missing something.
You must add the commands to the ISPF Command Table to make them work without having to enter TSO in front of the command.
You can add commands using the ISPF option 3.16, though I would recommend against it. The CBTTAPE.ORG website has a couple of command table update programs. I recommend the one found in file 349 as it updates the internal table, so if you make a mistake the worst case scenario is that you have to logout and back in.
To use the CBT349 program:
1. Download the CBT349.zip file to your pc and unzip it.
2. Transfer the XMI file to z/OS and RECEIVE it.
3. Copy the received members ISPCMDL and ISPCMDU to your REXX lib.
4. Create member ISPCOMND in you ISPF profile lib with this content:
\BDS\0\SELECT CMD(%@bevds B &zparm)\
\EDS\0\SELECT CMD(%@bevds E &zparm)\
\VDS\0\SELECT CMD(%@bevds V &zparm)\
5. Issue command TSO ISPCMDU to update the internal command table.
6. Replace the Screendsn section in the @BEVDS program with this (the original has a bug in it):