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

How to create PDS from a cobol program??


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

New User


Joined: 22 Nov 2006
Posts: 23
Location: Mumbai

PostPosted: Fri Mar 23, 2007 4:38 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Fri Mar 23, 2007 6:44 pm
Reply with quote

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
View user's profile Send private message
Narismha

New User


Joined: 22 Nov 2006
Posts: 23
Location: Mumbai

PostPosted: Mon Mar 26, 2007 11:18 am
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Mon Mar 26, 2007 9:47 pm
Reply with quote

The only necessary DD for this program is SYSOUT, so you can see any possible error messages. Nothing else is needed.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Wed Mar 28, 2007 8:28 pm
Reply with quote

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
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Mon Apr 02, 2007 4:40 pm
Reply with quote

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
Back to top
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Tue Apr 03, 2007 12:23 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 03, 2007 9:48 pm
Reply with quote

I hate it when i do that. . . icon_smile.gif
Back to top
View user's profile Send private message
mainframe_96

New User


Joined: 18 Dec 2006
Posts: 13
Location: usa

PostPosted: Thu Apr 05, 2007 1:22 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2007 1:36 am
Reply with quote

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
View user's profile Send private message
Narismha

New User


Joined: 22 Nov 2006
Posts: 23
Location: Mumbai

PostPosted: Mon Apr 09, 2007 8:50 pm
Reply with quote

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
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top