Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic load a csect

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Thu Aug 13, 2015 11:57 pm    Post subject: Dynamic load a csect
Reply with quote

CICS has a command to load a csect into memory and set a pointer
Code:
EXEC CICS
LOAD PROGRAM('mypgm')
SET(ADDRESS OF WS-MYPGM-PTR)
END-EXEC.

How can I do something similar in a COBOL program running in batch? I checked the Language Environment manual but could not find a utility for this.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Aug 14, 2015 12:02 am    Post subject:
Reply with quote

Code:
CALL <variable-name>
where variable-name is the program name you want to call. It doesn't work exactly the same (you cannot set a pointer for it, for example). The load module indicated in <variable-name> must be available via STEPLIB (etc.) when the program executes, but does not need to be included in the linkage edit / bind of the calling program.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Fri Aug 14, 2015 12:09 am    Post subject:
Reply with quote

Sorry forgot to mention - it is not an executable csect. It is an assembler csect which has just data. After the load a LINKAGE variable is set to point to the csect. The program can then do a SEARCH ALL on the variable to find a data item.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7231

PostPosted: Fri Aug 14, 2015 12:40 am    Post subject: Reply to: Dynamic load a csect
Reply with quote

Code:
       01  W-LOAD-POINTER                      USAGE PROCEDURE-POINTER.
       01  FILLER REDEFINES W-LOAD-POINTER.
           05 W-ADDRESS-OF-LOAD                USAGE POINTER.


           SET W-LOAD-POINTER           TO ENTRY
                                            "yourcsectname"
[or]
                                            identifier-containing-csect-name
           SET ADDRESS OF L-SEARCH-TABLE
                                        TO W-ADDRESS-OF-LOAD


This will load the CSECT (assuming in your search chain, of course) and put the address of the entry-point into W-LOAD-POINTER. Which you then REDEFINES as an ordinary POINTER, and use it as you would an ordinary POINTER.

What you are short of is the length of the table to be searched (from that) so include it in the CSECT (or know what was loaded in there). Your table in the LINKAGE SECTION should use an ODO.

Alternatively, a hard-coded table and recompile when the length changes.
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Fri Aug 14, 2015 12:42 am    Post subject:
Reply with quote

This is how I have done a batch program loading the same assemble table as I would in CICS.

Code:
ASSEMBLE TABLE

WSSSRYNU AMODE 31
WSSSRYNU RMODE ANY
WSSSRYNU CSECT
SRYCOUNT DC    A(SRYLNGTH/08)
SRYENTRY DC    CL08'xxxxxxx1'         
         DC    CL08'xxxxxxx2 '       
         DC    CL08'xxxxxxx3 '   
         DC    CL08'@@@@@@@@'         END OF TABLE
SRYLNGTH EQU   *-SRYENTRY
         END   

COBOL BATCH CODE TO ACCESS ABOVE TABLE

01  WS-TBL1-STRG.
    05  WS-TBL1-NAME           PIC X(08)  VALUE 'WSSSRYNU'.
    05  WS-TBL1-ADDR           USAGE  PROCEDURE-POINTER.
    05  FILLER  REDEFINES  WS-TBL1-ADDR.
        10  WS-TBL1-DATA       USAGE  POINTER.
        10  FILLER                    PIC X(04).

    05  WS-TBL1-IDX              PIC 9(08)  VALUE ZEROES.

    05  WS-TBL1-VERIFIED      PIC X(01)  VALUE ' '.
        88  WS-TBL1-LOADED                    VALUE 'L'.
        88  WS-TBL1-FAILED                     VALUE 'F'.

    05 WS-ACCESS-VERIFY      PIC X(01) VALUE ' '.
       88 WS-ACCESS-MATCH                  VALUE 'M'.
       88 WS-ACCESS-ERROR                  VALUE 'E'.




LINKAGE SECTION.

01 PCT-SRYN-TABLE.
  05 PCT-SRYN-COUNT             PIC 9(04) VALUE ZEROES.
  05 PCT-SRYN-ENTRY             OCCURS 0 TO 60 TIMES
                                DEPENDING ON PCT-SRYN-COUNT.
    10 PCT-SRYN-ACCESS          PIC X(08) VALUE SPACES.


PROCEDURE DIVISION

SET WS-TBL1-ADDR  TO  NULLS
SET WS-TBL1-ADDR  TO  ENTRY  WS-TBL1-NAME

IF WS-TBL1-ADDR  =  NULLS
    DISPLAY '********************************************'
    DISPLAY '* PROGRAM xxxxxxxx: '
    DISPLAY '* 909 - TABLE NOT LOADED:'  WS-TBL1-NAME
    DISPLAY '********************************************'
    MOVE '909'            TO LIT-ABEND-CODE
    PERFORM 9999-ABEND
ELSE
    SET WS-TBL1-LOADED                    TO  TRUE
    SET ADDRESS OF PCT-SRYN-TABLE  TO  WS-TBL1-DATA
END-IF


IF WS-TBL1-LOADED
  PERFORM VARYING WS-TBL1-IDX  FROM 1 BY 1
    UNTIL WS-ACCESS-MATCH OR WS-ACCESS-ERROR

    IF PCT-SRYN-ACCESS (WS-TBL1-IDX) = '@@@@@@@@'
      SET WS-ACCESS-ERROR TO TRUE
    END-IF

    IF WS-xxxx-USER = PCT-SRYN-ACCESS (WS-TBL1-IDX)
      SET WS-ACCESS-MATCH TO TRUE
    END-IF
  END-PERFORM
END-IF
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7231

PostPosted: Fri Aug 14, 2015 12:52 am    Post subject: Reply to: Dynamic load a csect
Reply with quote

That's a more detailed example of it. I missed pasting the PIC X(4) in the REDEFINES.

PROCEDURE-POINTERs are funny things, which have an address, then another four bytes.

A FUNCTION-POINTER is similar, but only four bytes long. One way to make use of a function in C/C++, for instance.

We covered this last time the PROCEDURE-POINTER came up. I don't think your error code is ever going to execute. Unless you have a Language Environment abend handler, and you have no code for that. So you'll get an S806, or an S706, or an Sx06 depending on how busted the CSECT is.

If you have the handler, you don't need the NULLS processing.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Fri Aug 14, 2015 1:13 am    Post subject:
Reply with quote

Excellent icon_biggrin.gif That worked. Thank you
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Copybook structure in Load module Vai123 COBOL Programming 7 Fri Sep 16, 2016 8:29 pm
This topic is locked: you cannot edit posts or make replies. ERROR WHILE SUBMITTING LOAD JOB ANURADHA NEELAKANTAN JCL & VSAM 12 Thu Aug 25, 2016 11:50 am
No new posts Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm
No new posts Execute multiple DB2 Load commands in... faizm DB2 4 Wed Aug 03, 2016 12:53 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us