View previous topic :: View next topic
|
Author |
Message |
Narismha
New User
Joined: 22 Nov 2006 Posts: 23 Location: Mumbai
|
|
|
|
Can any one explain/send me the tip to create PDS and members in it(Dynamically) through the cobol program.
Regards
-Narisimha |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
This is my very rudimentary sample:
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. PDSPROG.
INSTALLATION.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PDS-FILE ASSIGN TO PDS
ORGANIZATION IS SEQUENTIAL
ACCESS IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD PDS-FILE
LABEL RECORD STANDARD
BLOCK 0 RECORDS
RECORDING MODE F
RECORD CONTAINS 80 CHARACTERS.
01 PDS-RECORD PIC X(80).
WORKING-STORAGE SECTION.
01 FILLER.
05 WS-DUMMY PIC S9(8) COMP.
05 WS-RETURN-CODE PIC S9(8) COMP.
05 WS-REASON-CODE PIC S9(8) COMP.
05 WS-INFO-CODE PIC S9(8) COMP.
05 WS-CPPL-ADDRESS PIC S9(8) COMP.
05 WS-FLAGS PIC X(4) VALUE X'00010001'.
05 WS-BUFFER PIC X(256).
05 WS-LENGTH PIC S9(8) COMP VALUE 256.
01 DSN PIC X(44) VALUE SPACE.
PROCEDURE DIVISION.
CALL 'IKJTSOEV' USING WS-DUMMY WS-RETURN-CODE WS-REASON-CODE
WS-INFO-CODE WS-CPPL-ADDRESS.
IF WS-RETURN-CODE > ZERO
DISPLAY 'IKJTSOEV FAILED, RETURN-CODE=' WS-RETURN-CODE
' REASON-CODE=' WS-REASON-CODE 'INFO-CODE=' WS-INFO-CODE
MOVE WS-RETURN-CODE TO RETURN-CODE
STOP RUN.
MOVE 'PDS.DATASET.NAME' TO DSN.
MOVE SPACE TO WS-BUFFER.
STRING
'ALLOC DD(PDS) DA('
QUOTE
DELIMITED BY SIZE
DSN
DELIMITED BY SPACE
QUOTE
') NEW REU RECFM(F B) LRECL(80) '
'DIR(255) SPACE(10,10) CYLINDERS'
DELIMITED BY SIZE
INTO WS-BUFFER.
CALL 'IKJEFTSR' USING WS-FLAGS WS-BUFFER WS-LENGTH
WS-RETURN-CODE WS-REASON-CODE WS-DUMMY.
DISPLAY WS-BUFFER.
IF WS-RETURN-CODE > ZERO
DISPLAY 'IKJEFTSR FAILED, RETURN-CODE=' WS-RETURN-CODE
' REASON-CODE=' WS-REASON-CODE
MOVE WS-RETURN-CODE TO RETURN-CODE
STOP RUN.
MOVE SPACE TO WS-BUFFER.
STRING
'ALLOC DD(PDS) DA('
QUOTE
DELIMITED BY SIZE
DSN
DELIMITED BY SPACE
'(#1)'
QUOTE
') SHR REU'
DELIMITED BY SIZE
INTO WS-BUFFER.
CALL 'IKJEFTSR' USING WS-FLAGS WS-BUFFER WS-LENGTH
WS-RETURN-CODE WS-REASON-CODE WS-DUMMY.
DISPLAY WS-BUFFER.
IF WS-RETURN-CODE > ZERO
DISPLAY 'IKJEFTSR FAILED, RETURN-CODE=' WS-RETURN-CODE
' REASON-CODE=' WS-REASON-CODE
MOVE WS-RETURN-CODE TO RETURN-CODE
STOP RUN.
OPEN OUTPUT PDS-FILE.
MOVE SPACE TO PDS-RECORD.
WRITE PDS-RECORD.
CLOSE PDS-FILE.
MOVE SPACE TO WS-BUFFER.
STRING
'FREE DD(PDS)'
DELIMITED BY SIZE
INTO WS-BUFFER.
CALL 'IKJEFTSR' USING WS-FLAGS WS-BUFFER WS-LENGTH
WS-RETURN-CODE WS-REASON-CODE WS-DUMMY.
DISPLAY WS-BUFFER.
IF WS-RETURN-CODE > ZERO
DISPLAY 'IKJEFTSR FAILED, RETURN-CODE=' WS-RETURN-CODE
' REASON-CODE=' WS-REASON-CODE
MOVE WS-RETURN-CODE TO RETURN-CODE
STOP RUN.
MOVE ZERO TO RETURN-CODE.
STOP RUN.
|
Note: this program won't run properly in a TSO environment. If you want to run it in TSO, just eliminate the first step where the TSO environment (IKJTSOEV ) is being setup. |
|
Back to top |
|
|
Narismha
New User
Joined: 22 Nov 2006 Posts: 23 Location: Mumbai
|
|
|
|
Hi Superk,
Thank you for your quick reply. As per the above code i should get the PDS 'PDS.DATASET.NAME(#1)' . But i did not get any data set.
Can you please let me know what JCL i have to use.
I used the DD card for this PDS as //PDS dd dummy
PLease help me on this.
Thanks
-Narisimha |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
The only necessary DD for this program is SYSOUT, so you can see any possible error messages. Nothing else is needed. |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
I have not tried superk's solution. It looks to me like this is a great way to do it if you can get it to work.
Where I work we have a utility that lets COBOL call REXX. One possible approach would be to call a REXX program to allocate the PDS.
We have being using the PUTENV approach to do most of our dynamic file allocations but I don't know whether PUTENV can handle a PDS (I suspect it cannot). The PUTENV approach is very easy.
Of course you can use Assembler to do what you want. We have an assembler routine that allocates a PDS member. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
jasorn wrote: |
This doesn't have syntax hilighting but I think it's a good, free, multiplatform, cobol editor for those of us who like spf editors.
www.geocities.jp/sakachin2/index.htm |
I don't know what I was answering but apparently I put this in the wrong thread. But it is a GREAT editor. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
I hate it when i do that. . . |
|
Back to top |
|
|
mainframe_96
New User
Joined: 18 Dec 2006 Posts: 13 Location: usa
|
|
|
|
If you absolutely need to create the pds in the cobol Program itself then this is not the solution. However you can create an 80 byte sequential file that you can copy into a pds after the completion
Create the file like this
FD xxxxx
BLOCK CONTAINS 0 RECORDS,
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD,
DATA RECORD IS xxxxx-Copy-RECORD.
01 xxxx-COpy-RECORD PIC X(80).
then use Iebgener. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Which of the above is not the solution?
You really can create a pds from within a COBOL program. . . Not somethng you would do just every day, but it is do-able. |
|
Back to top |
|
|
Narismha
New User
Joined: 22 Nov 2006 Posts: 23 Location: Mumbai
|
|
|
|
Hi All,
Thanks for all your inputs.
Through REXX is a good solution, but i have created PS files dynamically.
Thanks and Regards
-Narisimha |
|
Back to top |
|
|
|