MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Invoking ISPF Services from a Batch COBOL Program

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Troodon
Beginner


Joined: 10 Sep 2004
Posts: 9
Topics: 4
Location: Johannesburg, Gauteng, South Africa

PostPosted: Fri Jan 07, 2005 8:01 am    Post subject: Invoking ISPF Services from a Batch COBOL Program Reply with quote

I am trying to invoke the LMINIT service inside a batch COBOL Program, but am getting a return code of 20. Can anyone help.

EG. of Code:

Working storage.

77 isp-isplink Pic x(8) value 'ISPLINK'.
77 isp-lminit Pic x(8) value 'LMINIT '.
77 isp-dataid Pic x(8) value low-values.
77 isp-ddname Pic x(8) value 'PDSINP'.
77 isp-shr pic x(8) value 'SHR'.

Procedure Division.

call isp-isplink using isp-dataid isp-ddname isp-shr
end-call

if return-code = 0
display 'PDSLIST: LMINIT passed'
else
display 'PDSLIST: LMINIT failed'
display 'PDSLIST: return code =<' return-code '>'
stop run
end-if

exit
.

eg of JCL:

//FLP01#01 EXEC PGM=PDSLIST
//STEPLIB DD DISP=SHR,DSN=????????.TEST.LINKLIB
//PDSINP DD DISP=SHR,DSN=MY.PDS
//SYSABOUT DD SYSOUT=*
//IAMINFO DD SYSOUT=*
//SYSDBOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//ABENDAID DD SYSOUT=*
//SYSPUNCH DD SYSOUT=*
//SYSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
//SYSTSPRT DD SYSOUT=*
//*

Output from running pgm:

PDSLIST: LMINIT failed
PDSLIST: return code =<00020>

Thank's
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Fri Jan 07, 2005 9:08 am    Post subject: Reply with quote

Troodon,

You are missing the ISP-LMINIT in your call.

Change your call from

Quote:

call isp-isplink using isp-dataid isp-ddname isp-shr


to

Code:

call isp-isplink using [b]isp-lminit[/b] isp-dataid isp-ddname isp-shr


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Fri Jan 07, 2005 9:32 am    Post subject: Reply with quote

Maybe it's me, but I don't see where in the JCL a TSO environment is being defined by calling the IKJEFT01 program along with the requisite ISPF libraries, and where ISPF is being enabled with an ISPSTART command prior to the program being called??
Back to top
View user's profile Send private message
Troodon
Beginner


Joined: 10 Sep 2004
Posts: 9
Topics: 4
Location: Johannesburg, Gauteng, South Africa

PostPosted: Mon Jan 10, 2005 2:41 am    Post subject: Reply with quote

Kolusu

Thanks for pointing out such an obvious stupid error Embarassed . However fixing it did not make a diference. Perhaps I am missing something, but is superk right. To invoke ispservices in a batch cobol program, I must invoke the program through the TSO environment, and then first run an ISPSTART command, before invoking the cobol batch program. Although my ISP liraries are not in the JCL provided, they are in the system libraries, they must be availble or I would be getting an 806 instead of a return code 20. Question Since I have never done this before can someone provide an example please
_________________
Man is the universe becoming Conscious of itself.
Back to top
View user's profile Send private message
Troodon
Beginner


Joined: 10 Sep 2004
Posts: 9
Topics: 4
Location: Johannesburg, Gauteng, South Africa

PostPosted: Mon Jan 10, 2005 3:53 am    Post subject: Reply with quote

I have tried executing the COBOL program from option 6 in ISPF in the following way

CALL 'my.linklib(PDSLIST)'

And got the following reponse:

********************************************************************* ISPS107
*
* Required parm missing
* Not all required parameters were found for the LMINIT service.
*

The COBOL Code looks like this:

77 isp-lminit Pic x(8) value 'LMINIT'.
77 isp-dataid Pic x(8) value space.
77 isp-ddname Pic x(8) value 'PDSINP'.
77 isp-shr pic x(3) value 'SHR'.

call 'ISPLINK' using
isp-lminit isp-dataid isp-ddname isp-shr
end-call

I have allocated the file PDSINP before executing the command succesfully. What am I missing. The manual says:

Call Invocation Format

CALL ISPLINK (LMINIT, data-id-var
{,project,group1 [,group2] [,group3] [,group4] ,type}
{,dsname }
{,ddname }
,[serial] ,[password]
,[SHR|EXCLU |SHRW|MOD]
,[org-var]);

From this the only required prameters are LMINIT, data-id-var, one of (project etc, dsname,ddname)

What am I missing Question
_________________
Man is the universe becoming Conscious of itself.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Jan 10, 2005 7:36 am    Post subject: Reply with quote

Troodon,

The problem is due to the difference b/w Batch & Online. When u invoke ur cobol program thru' option 6 - Online, it uses all the ISPF libraries that are already allocated during ur login. But when u invoke ur cobol program via JCL - Batch you need to allocate these ISPF libraries manually. Hope I'm clear.

You need to allocate so many datasets (ISPPLIB, ISPMLIB, ISPTLIB, SYSEXEC, .....). Try the 'Batchpdf' macro provided in the following link. It will create u a JCL with all ISPF allocations. It reads ur online allocations and replicates the same for batch.

http://www.sillysot.com/ftp/batchpdf.txt

For more details on how to use BATCHPDF, please refer the 3rd post From BOTTOM in the following link.
http://www.mvsforums.com/helpboards/viewtopic.php?t=2608&highlight=batchpdf

Hope this helps,

Thanks,
Phantom
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Mon Jan 10, 2005 10:09 am    Post subject: Reply with quote

I copied the code from the ISPF COBOL Model for the LMINIT command, and got this as a (working) result:

Code:

PROCEDURE DIVISION.                                           
    MOVE "LMINIT  " TO ISPF-SERVICE.                           
    MOVE "PDSINP  " TO ISPF-DATA-ID.                           
    MOVE "        " TO ISPF-PROJECT.                           
    MOVE "        " TO ISPF-GROUP1.                           
    MOVE "        " TO ISPF-GROUP2.                           
    MOVE "        " TO ISPF-GROUP3.                           
    MOVE "        " TO ISPF-GROUP4.                           
    MOVE "        " TO ISPF-TYPE.                             
    MOVE "                                                  " 
         TO ISPF-DSNAME.                                       
    MOVE "PDSINP  " TO ISPF-DDNAME.                           
    MOVE "      "   TO ISPF-SERIAL.                           
    MOVE "        " TO ISPF-PSWD-VALUE.                       
    MOVE "SHR     " TO ISPF-ENQ-VAR.                           
    MOVE "        " TO ISPF-ORG-VAR.                           
    CALL "ISPLINK" USING  ISPF-SERVICE     ISPF-DATA-ID       
                      ISPF-PROJECT     ISPF-GROUP1         
                      ISPF-GROUP2      ISPF-GROUP3         
                      ISPF-GROUP4      ISPF-TYPE           
                      ISPF-DSNAME      ISPF-DDNAME         
                      ISPF-SERIAL      ISPF-PSWD-VALUE     
                      ISPF-ENQ-VAR     ISPF-ORG-VAR.       

It appears that you must code the DATAID field (or you will get a "parameter missing" message), and that you must account for all of the fields.
Back to top
View user's profile Send private message
Troodon
Beginner


Joined: 10 Sep 2004
Posts: 9
Topics: 4
Location: Johannesburg, Gauteng, South Africa

PostPosted: Wed Jan 12, 2005 2:27 am    Post subject: Reply with quote

Thanks folks for your Help I have made use of both the BATCHPDF rexx and the MODEL command to fix my program, However I am now getting a return code 10 from the LMOPEN function. Here are some displays from the program:

Code:
PDSLIST: Before LMINIT
  LMINIT:  ispf-service      =<LMINIT  >           
  LMINIT:  ispf-data-id      =<PDSLINP >           
  LMINIT:  ispf-project      =<        >           
  LMINIT:  ispf-group1       =<        >           
  LMINIT:  ispf-group2       =<        >           
  LMINIT:  ispf-group3       =<        >           
  LMINIT:  ispf-group4       =<        >           
  LMINIT:  ispf-type         =<        >           
  LMINIT:  ispf-dsname       =<                   
  LMINIT:  ispf-ddname       =<PDSLINP >           
  LMINIT:  ispf-serial       =<      >             
  LMINIT:  ispf-pswd-value   =<        >           
  LMINIT:  ispf-enq-var      =<SHR     >           
  LMINIT:  ispf-org-var      =<        >           
PDSLIST: LMINIT passed                             
PDSLIST: return code =<00000>
  LMINIT:  ispf-service      =<LMINIT  >           
  LMINIT:  ispf-data-id      =<PDSLINP >           
  LMINIT:  ispf-project      =<        >           
  LMINIT:  ispf-group1       =<        >           
  LMINIT:  ispf-group2       =<        >           
  LMINIT:  ispf-group3       =<        >           
  LMINIT:  ispf-group4       =<        >           
  LMINIT:  ispf-type         =<        >           
  LMINIT:  ispf-dsname       =<                   
  LMINIT:  ispf-ddname       =<PDSLINP >           
  LMINIT:  ispf-serial       =<      >             
  LMINIT:  ispf-pswd-value   =<        >           
  LMINIT:  ispf-enq-var      =<SHR     >           
  LMINIT:  ispf-org-var      =<        >       
PDSLIST: before LMOPEN                       
  LMOPEN:  ispf-service      =<LMOPEN  >           
  LMOPEN:  ispf-data-id      =<PDSLINP >           
  LMOPEN:  ispf-option1      =<INPUT   >           
  LMOPEN:  ispf-data-lenvar  =<        >           
  LMOPEN:  ispf-recform      =<        >           
  LMOPEN:  ispf-org-var      =<        >         
PDSLIST: LMOPEN failed                     
PDSLIST: return code =<00010>               

It seams to me that although the LMINIT is processing with a 0 return code, it is not establishing the DATA-ID correctly. I have tried using spaces in the DATA-ID with the LMINIT and the LMINIT then fails.

From the Manual I understood that the LMINIT should establish the DATAID, and then the LMOPEN would uses it to open the DDNAME. Please tell me what I am missing Question
_________________
Man is the universe becoming Conscious of itself.
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Wed Jan 12, 2005 6:36 am    Post subject: Reply with quote

The DATAID column needs to contain the name of the variable that you want to receive the DATAID value. You use the VDEFINE service to define this (and any other ISPF variables) to ISPF.

I don't have time to expand on this at the moment, but you've now got something to go on, at least.
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Jan 12, 2005 6:42 am    Post subject: Reply with quote

After the LMINIT command is processed to set the value of the DATA-ID variable, from that point on the value is specified as a variable, in this case &PDSLINP will work.
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Wed Jan 12, 2005 6:56 am    Post subject: Reply with quote

I just found this code in an old program. It'll give you an idea of what I mean:

Code:

   
 01  ISPF-NAMES.                                       
     05  NAME-DATABASE     PIC X(8)  VALUE 'DATABASE'.
     05  NAME-COMPCODE     PIC X(8)  VALUE 'COMPCODE'.
     05  NAME-PRODCODE     PIC X(8)  VALUE 'PRODCODE'.
     05  NAME-SCORCODE     PIC X(8)  VALUE 'SCORCODE'.
     05  NAME-SCCTFR       PIC X(8)  VALUE 'SCCTFR  '.
     05  NAME-SCCTTO       PIC X(8)  VALUE 'SCCTTO  '.
     05  NAME-VERSION      PIC X(8)  VALUE 'VERSION '.
     05  NAME-USER         PIC X(8)  VALUE 'ZUSER   '.
                                                       
 01  ISPF-BUF              PIC X(120) VALUE SPACES.   
                                                       
 01  ISPF-TYPES.                                       
     05  CHAR              PIC X(8)  VALUE 'CHAR'.     
     05  FIXED             PIC X(8)  VALUE 'FIXED'.   
                                                       
 01  ISPF-SERVICES.                                   
     05  VDEF              PIC X(8)  VALUE 'VDEFINE'. 
     05  VRESET            PIC X(8)  VALUE 'VRESET '. 
                                                         
 01  ISPF-LENGTHS.                                       
     05  L04               PIC S9(9) COMP VALUE  4.       
     05  L06               PIC S9(9) COMP VALUE  6.       
     05  L08               PIC S9(9) COMP VALUE  8.       
     05  L30               PIC S9(9) COMP VALUE 30.       
     05  L50               PIC S9(9) COMP VALUE 50.       
     05  L80               PIC S9(9) COMP VALUE 80.       
     05  L94               PIC S9(9) COMP VALUE 94.       
                                                         
                                                                   
     CALL 'ISPLINK' USING VDEF NAME-DATABASE DATABASE CHAR   L80. 
     CALL 'ISPLINK' USING VDEF NAME-COMPCODE COMPCODE FIXED  L04. 
     CALL 'ISPLINK' USING VDEF NAME-PRODCODE PRODCODE FIXED  L04. 
     CALL 'ISPLINK' USING VDEF NAME-SCORCODE SCORCODE FIXED  L04. 
     CALL 'ISPLINK' USING VDEF NAME-SCCTFR   SCCTFR   FIXED  L04. 
     CALL 'ISPLINK' USING VDEF NAME-SCCTTO   SCCTTO   FIXED  L04. 
     CALL 'ISPLINK' USING VDEF NAME-VERSION  VERSION  FIXED  L04. 
     CALL 'ISPLINK' USING VDEF NAME-USER     USER-ID  CHAR   L08. 
                                                                   




You may like to consider using the ISPEXEC interface for some commands:

Code:

                                                                   
     MOVE 'VGET (ZUSER DATABASE) SHARED' TO ISPF-BUF.             
     CALL 'ISPEXEC' USING L80, ISPF-BUF.               




It can make life a little simpler.
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group