View previous topic :: View next topic
|
Author |
Message |
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
i have resolved this. I was able to use setenv |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
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 |
|
|
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Just looked up SETENV on Google - it is a *nix thing - not mainframe. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
mambopras
New User
Joined: 11 Nov 2008 Posts: 52 Location: Hyderabad
|
|
|
|
What does the [b] signify in the STRING function used in the program ? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
it' s a mix up of tags
something
ibmmainframe.com does not honor nested tags inside the <code> tages |
|
Back to top |
|
|
Susan Talbot
New User
Joined: 17 Dec 2010 Posts: 36 Location: KY
|
|
|
|
yes please ignore the b tag |
|
Back to top |
|
|
|