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

create a GDG generation with setenv?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Thu Apr 21, 2011 7:27 pm
Reply with quote

If I have created a GDG base, can I create the next GDG generation in a COBOL program using setenv?

I tried it but was getting errors and could not get it to work. Part of the problem is I am not sure what the syntax should be for the ENV-VALUE passed into setenv. It didn't seem to like the +1 in the DSN or the DCB parameters.

Will I need to use IKJEFTSR and execute a TSO ALLOCATE commmand instead?

Also, a side note -
Is BPXWDYN only available to use if Unix Services are turned on? And which is the cleanest, most efficient way to allocate files? setenv, TSO command, or BPXWDYN?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Apr 21, 2011 8:21 pm
Reply with quote

Creating a relative generation (i.e. using a +1 instead of an actual explicit dataset name) is only possible in batch, by using BPXWDYN, or by calling actual JES enqueue and dequeue macros that I personally don't know much about. I don't know what sentenv is or what it does.

As far as I'm concerned, it's a tossup between using the standard TSO ALLOC command that we've all used forever, or BPXWDYN, which can be used in other langauges as well (I've used it in REXX execs a lot).
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Fri Apr 22, 2011 12:20 am
Reply with quote

i have resolved this. I was able to use setenv
Back to top
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Fri Apr 29, 2011 8:01 pm
Reply with quote

Susan Talbot wrote:
i have resolved this. I was able to use setenv

Can you post some example code for others' benefit?
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Fri Apr 29, 2011 8:39 pm
Reply with quote

Sure! In my JCL I am passing in the name of the file and the SPACE (PRIMARY, SECONDARY)

This is passed in via PARM=
Code:

//STEP002 EXEC PGM=MYPGM,                                           
//PARM='TEST.GDG.FOR.TEST.PROGRAM(+1)00050005'


In the program

Code:

FILE-CONTROL.                         
    SELECT CARD-OUT ASSIGN TO PRINT   
           ORGANIZATION IS SEQUENTIAL 
           ACCESS MODE IS SEQUENTIAL   
           FILE STATUS PRINT-STAT.     

DATA DIVISION.                               
FILE SECTION.                               
FD  CARD-OUT                                 
    RECORDING MODE   F                       
    LABEL RECORDS  ARE STANDARD             
    BLOCK CONTAINS   0 RECORDS               
    RECORD CONTAINS 80 CHARACTERS.           
01  FILE-RECORD                  PIC X(80). 

WORKING-STORAGE SECTION.                   
01 PRINT-STAT                    PIC 99.   
01 WS-SIZE                       PIC 9(9).

01 ENV-VARS.                                             
   05 ENV-NAME                   PIC X(9).               
   05 ENV-VALUE                  PIC X(100).             
   05 ENV-OVERWRITE          PIC S9(8) COMP.         
   05 ENV-RC                       PIC 9(9) BINARY.       


LINKAGE SECTION.                                   
01 PARM-AREA.                                       
   05  SYSIN-FILE-ID                 PIC X(31).
   05 WS-PRIMARY                    PIC 9(4).
   05 WS-SECOND                     PIC 9(4).


PROCEDURE DIVISION.
PERFORM 2000-CREATE-FILE
PERFORM 2500-OPEN-FILE 

  2000-CREATE-FILE.                                                                                                     
      MOVE z'PRINT' TO ENV-NAME.                                   
      STRING ' DSN('                                               
              SYSIN-FILE-ID                                         
             '),NEW,CYL,SPACE(' WS-PRIMARY ',' WS-SECOND '),UNIT(SY
 -           'SDA),CATALOG' Delimited By Size                       
      Into ENV-VALUE.                                               
      DISPLAY 'ENV-VALUE = ' ENV-VALUE                             
      MOVE 1 TO ENV-OVERWRITE.                                     
      CALL "setenv" USING ENV-NAME, ENV-VALUE, ENV-OVERWRITE       
      RETURNING ENV-RC.                                             
      DISPLAY 'ENV-RC = ' ENV-RC                                   
                                                                   
      IF ENV-RC = 0                                                 
         PERFORM 2500-OPEN-FILE                                     
      ELSE                                                         
         PERFORM 8000-FILE-ERROR                                   
      END-IF.               

     
  2500-OPEN-FILE.                     
                                     
       OPEN OUTPUT CARD-OUT           
                                     
       IF PRINT-STAT NOT = 00         
          PERFORM 8500-OPEN-ERROR.   


                                 


I created the GDG Base an Model outside of this program.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Apr 29, 2011 10:39 pm
Reply with quote

Just looked up SETENV on Google - it is a *nix thing - not mainframe.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 29, 2011 11:45 pm
Reply with quote

SETENV may be a *nix thing, but environment variables come right out of the COBOL Language Reference manual:
Quote:
4.2.3.2 Environment variable contents for a QSAM file



For a QSAM file, the environment variable must contain either a DSN or a PATH option in the format shown below.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Apr 30, 2011 12:03 am
Reply with quote

Nic Clouston wrote:
Just looked up SETENV on Google - it is a *nix thing - not mainframe.

Remember, though, that Unix -- and perhaps some other *nices -- runs under z/OS on the mainframe. I think that setenv is IBM's recommended method of doing dynamic file allocations in Enterprise COBOL.
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Sun May 15, 2011 2:02 pm
Reply with quote

What does the [b] signify in the STRING function used in the program ?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun May 15, 2011 2:26 pm
Reply with quote

it' s a mix up of tags
Code:
[b]something  [/b]

something

ibmmainframe.com does not honor nested tags inside the <code> tages
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Mon May 16, 2011 7:41 am
Reply with quote

yes please ignore the b tag
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to create a list of SAR jobs with... CA Products 3
No new posts DFHPI1008 JSON generation failed COBOL Programming 0
No new posts Started task using a generation dataset JCL & VSAM 7
No new posts create rexx edit Macro that edits the... CLIST & REXX 3
No new posts COBOL - create and write to output fi... COBOL Programming 0
Search our Forums:

Back to Top