IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Call COBOL from ISPF Panel REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Tarique Anwer

New User


Joined: 27 Jan 2016
Posts: 10
Location: India

PostPosted: Wed Feb 10, 2016 12:52 pm
Reply with quote

Hello,

I've searched through the forums but did not come across a similar problem anywhere, so any help is much appreciated. I've written a new ISPF Panel (code below) where I'm trying to validate a User Input - Program Name (PGMNAME) against the list of available Programs in the Baseline. To do this, I tried calling a REXX from the ISPF Panel, IDLVALPG.
which enquires the Data Dictionary by calling a COBOL module in turn.

Panel:
Code:
)ATTR DEFAULT(%+¿)
* TYPE(PT)              /* Panel Title                */
% TYPE(ET)              /* Emphasised Text            */
+ TYPE(NT)              /* Normal Text                */
¿ TYPE(SI)              /* Normal Text(White)         */
µ TYPE(NEF) CAPS(ON)    /* Normal Entry Field         */
› TYPE(AB)              /* Action Bar                 */
@ TYPE(ABSL)            /* Action Bar Separator Line  */
)ABC DESC('Help')  MNEM(1)
PDC DESC('Print')  MNEM(1)
ACTION RUN(ISRROUTE) PARM('SELECT CMD(IDLHELP 1)')
PDC DESC('Setup')  MNEM(1)
ACTION RUN(ISRROUTE) PARM('SELECT CMD(IDLHELP 2)')
PDC DESC('Modify') MNEM(1)
ACTION RUN(ISRROUTE) PARM('SELECT CMD(IDLHELP 3)')
PDC DESC('Report Bug') MNEM(8) UNAVAIL(ZEDF)
)ABCINIT
.ZVARS=HELPMENU
&zedf = 1          /* Option unavailable for now */
)BODY EXPAND(\\)
› Help +
@\~\
+\ \*Panel Title+\ \
+Option ===>µZCMD
+
+
+
+\ \   ¿T E S T    P A N E L +   \ \
+
¿0 +Print        +Option 1
¿1 +Setup        +Option 2
¿2 +Modify       +Option 3
+
+
+
*Enter the parameters below:
+   Program Name  . . .µZ       +\ \
+   Environment .µZ    +\ \
+
+
+
+
+
)INIT
.ZVARS  = 'PGMNAME ENVNAME'
.HELP   = IDLHLPP
VGET (PGMNAME ENVNAME) PROFILE
)REINIT
REFRESH(*)
)PROC
VER (&PGMNAME,NB)
VER (&ENVNAME,NB)
&ZQ = &Z
  IF (&ZCMD ^= ' ')
    &ZQ = TRUNC(&ZCMD,'.')
    IF (&ZQ = ' ')
      .MSG = IDMSG001
  &ZSEL = TRANS( &ZQ
                0,'CMD(OPTONE)'
                1,'CMD(OPTTWO)'
                2,'CMD(OPTTHREE)'
                ' ',' '
                *,'?')
  &ZTRAIL = .TRAIL
VPUT (PGMNAME ENVNAME) PROFILE
&CPOS = ZCMD

*REXX(*,PGMNAME,(IDLVALPG))
IF (.MSG ^= &Z)
  EXIT
*REXX(*,CPOS,PGMNAME,ENVNAME)
  /*
  prefix = substr(PGMNAME,1,2)
  if prefix ^= 'EP' then
    do
     cpos   = 'PGMNAME'
     zrxmsg = 'IDMSG002'
     zrxrc  = 8
     return
    end
  */
*ENDREXX
IF (.MSG ^= &Z)
  .CURSOR = &CPOS
  REFRESH(*)
ELSE
  .CURSOR = ZCMD
)END



IDLVALPG :

Code:

/********************************************************/
/* Call ISPPRXVP to get the ISPF dialog variables into */
/* REXX. */
/********************************************************/
Call ISPPRXVP 'I'
/********************************************************/
trace ?i
say PGMNAME
RETCODE1 = '0000'
INPUTA = 'PGM'||PGMNAME
address tso "CALL BASELINE.COBOL(DDENQ)' '/TEST'"
if RETCODE1 ^= '0000' then
  do
   say RETCODE1
  end
Call ISPPRXVP 'T'
/********************************************************/
/* Call ISPPRXVP to get update the ISPF dialog */
/* variables with the changes made in this REXX. */
/********************************************************/
Call ISPPRXVP  'T'
Return


The following COBOL snippet fetches the value of the REXX variable 'INPUTA' using IRXEXCOM

Code:

01  SHVBLOCK.                                               
    02 SHVNEXT                              PIC S9(9) BINARY.
    02 SHVUSER                              PIC S9(9) BINARY.
    02 SHVCODE                              PIC X(1).       
    02 SHVRET                               PIC X(1).       
    02 X                                    PIC X(2).       
    02 SHVBUFL                              PIC S9(9) BINARY
                                            VALUE +32767.   
    02 SHVNAMA                              POINTER.         
    02 SHVNAML                              PIC S9(9) BINARY.
    02 SHVVALA                              POINTER.         
    02 SHVVALL                              PIC S9(9) BINARY.
01  REXXVARNAME                             PIC X(20).       
01  REXXVARVALUE                            PIC X(134).     
01  REXXVARNAMEL                            PIC S9(9) BINARY.
01  REXXVARVALUEL                           PIC S9(9) BINARY.
01  NILVALUE                                PIC S9(9) BINARY.

...
MOVE 0               TO NILVALUE                 
MOVE 'INPUTA'     TO REXXVARNAME               
MOVE 6               TO REXXVARNAMEL             
SET SHVNAMA     TO ADDRESS OF REXXVARNAME   
MOVE REXXVARNAMEL TO SHVNAML                   
SET SHVVALA       TO ADDRESS OF REXXVARVALUE   
MOVE 0            TO SHVNEXT                   
MOVE 0            TO SHVUSER                   
MOVE 'F'          TO SHVCODE                   
MOVE X'00'        TO SHVRET                   
MOVE X'0000'      TO X                         
CALL IRXEXCOM USING IRXEXCOM NIL NIL SHVBLOCK 
MOVE REXXVARVALUE TO INPUTA                   


When I call IDLVALPG from the Panel, IRXEXCOM always returns a value of X'01' for SHVRET, which the manual suggests is the code for SHVNEWV EQU X’01’ - Variable did not exist.

However, if I instead use IDLVALPG as a REXX by itself, the call is successful with SHVRET X'00'.

How do I get around this? Is what I'm trying to achieve actually possible?

Regards,
Tarique
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Wed Feb 10, 2016 7:45 pm
Reply with quote

Sorry, I am not a COBOLer, so I might be wrong.

I would start with the COBOL program and have it do some VDEFINEs and then display the panel. After the display, field value should be in the vdefined variable.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Feb 10, 2016 8:36 pm
Reply with quote

I assume that the 'say pgmname' in IDLVALPG shows the correct value?
Can't say why it does not work, but I have a suggestion. Since IDLVALPG is so small, move it's code to the inline REXX in the panel.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Wed Feb 10, 2016 9:09 pm
Reply with quote

It probably has something to do with how the Rexx environment is established by the *Rexx panel statement. (This is only an educated guess on my part. I have learned from other experiences with panel exits and inline Rexx that sometimes there are unexpected restrictions. For example, I once had a Rexx panel exit that performed a DB2 call via DSNREXX. It worked well for years, until we went to z/OS 2.1)

If you only have one variable to pass to the Cobol program, you could always pass it as a PARM rather than attempt to retrieve it via IRXEXCOM. Which does not explain why it is not working, however.
Back to top
View user's profile Send private message
Tarique Anwer

New User


Joined: 27 Jan 2016
Posts: 10
Location: India

PostPosted: Wed Feb 10, 2016 9:21 pm
Reply with quote

Hi Pedro/ Willy,

Thanks for your replies.

@Pedro - The COBOL program is an existing module which is used for Cross-Reference elsewhere as well so I won't be able to modify it. Making a copy of it doesn't make sense for just one Panel so I'll have to abandon the idea, if I can't get this to work, unfortunately.

@Wily - The 'say' statement does show the correct value, which means that IDLVALPG does have access to PGMNAME from the ISPF Panel. Strangely enough the REXX variable, INPUTA goes missing when IRXEXCOM tries to access it (And I don't know how it tries to do so - Couldn't find anything relevant so far). Incidentally, I had started with inline REXX but thought I could try moving it out of the ISPF panel, just in case the variable defined in the Panel was not accessible to IRXEXCOM. Evidently that didn't work either!

I've just started with System Programming and incidentally this is the first ISPF Application that I have written, so I'm obviously lacking in experience. I've been able to work my way around using the (excellent) IBM manuals, but apart from that I'm pretty much on my own icon_smile.gif

I looked up troubleshooting tips from SHARE conferences, tried using 'say' statements, Panel Trace ISPDPTRC, ISPVCALL MONITOR VAR(INPUTA) and the /TEST option with the call statement, but nothing has helped me so far.

The call to the COBOL module works as expected if I do it from a standalone REXX, but not from the Panel REXX. No idea why!

Regards,
Tarique
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Feb 10, 2016 11:18 pm
Reply with quote

I have done a test with an assembler program which does get/put using IRXEXCOM, and it works fine - except that the panel variable 'pgmstat' is not set afterwards.
Panel snippet:
%Enter programname#pgmname +
+
%Is ok ? ¤pgmstat +
+
)Init
&pgmname = &Z
&pgmstat = &Z
)Proc
*REXX(*,(TESTPX02))

REXX TESTPX02 snippet:
Call ISPPRXVP 'I'
inputa='PGM'pgmname
say 'pgmname:' pgmname',pgmstat:' pgmstat', inputa:' inputa
cc=RexxGblv('save var(inputa) pool(testpx01)')
cc=RexxGblv('add var(pgmstat) value(OK) pool(testpx01)')
say 'list pool(testpx01)'
cc=RexxGblv('list pool(testpx01)')
cc=RexxGblv('load var(pgmstat) pool(testpx01)')
say 'pgmstat:' pgmstat
Call ISPPRXVP 'T'
return

Output with pgmname=ABC:
pgmname: ABC,pgmstat: , inputa: PGMABC
list pool(testpx01)
INPUTA PGMABC
PGMSTAT OK
# of records listed: 0002
pgmstat: OK

The REXXGBLV program can be found on CBTTAPE.ORG file 669 by the way.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Feb 10, 2016 11:37 pm
Reply with quote

I think it has to do with the way the COBOL program gets the REXX environment parameters.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Feb 11, 2016 1:00 am
Reply with quote

correction, I do see the modified 'pgmstat' value after the REXX call.
Back to top
View user's profile Send private message
Tarique Anwer

New User


Joined: 27 Jan 2016
Posts: 10
Location: India

PostPosted: Thu Feb 11, 2016 11:14 am
Reply with quote

Hi Willy,

Appreciate your help. I've XMIT'ed your XMI file from CBTTAPE but unfortunately I won't be able to use it in our environment because it is written in Assembly and I cannot use it without being able to explain how it does, what it does icon_smile.gif I've never used ASM on the ZOS so far.

Is there anything else I could try that could possibly lead a way out? Thanks again for looking into this.

Regards,
Tarique
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Feb 11, 2016 4:07 pm
Reply with quote

I can only assume it has to do with the way the COBOL program initializes the REXX environment. I'm not a COBOL person so can't help you there. However, if it sets the RETCODE1 variable, then it must have a valid REXX environment.
By the way, you do not need the "Call ISPPRXVP 'I'" , "Call ISPPRXVP 'T'" and "RETURN" statements, they are inserted for you.
The $$DOC member in the CBT669 file tells you what the program does, but that of course might not be enough.
There is a difference to how you use your COBOL program - REXXGBLV must run as a function.
Sorry, I am out of ideas.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top