Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to create a data set through Cobol code

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

New User


Joined: 26 May 2003
Posts: 4
Location: Delhi

PostPosted: Wed Oct 01, 2003 9:15 pm    Post subject: How to create a data set through Cobol code
Reply with quote

My requirement is to create the dataset (if possible GDG) through the cobol code.can anyone please tell me how to do it.?
Back to top
View user's profile Send private message

mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 238
Location: USA

PostPosted: Thu Oct 02, 2003 11:36 am    Post subject:
Reply with quote

Hello prasannadhabe,

Below is the program you can write to create a GDG in a cobol program.
Hope this helps.

-------------------------------------------------------------------------------------
IDENTIFICATION DIVISION.
PROGRAM-ID. MYPROG.

INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUTFILE ASSIGN TO OTFILE.

FILE SECTION.
FD OUTFILE
RECORD CONTAINS 80 CHARACTERS
LABEL RECORDS ARE OMITTED
DATA RECORD IS OT-REC.

01 OT-REC PIC X(80)

01 WS-JCL-AREA.
05 WS-JOBCARD.
10 FILLER PIC X(20) VALUE
'//JOBNAME JOB 0,'''.
10 FILLER PIC X(10) VALUE 'NOTIFY'.
10 JCL-JOBNAME PIC X(10) VALUE SPACES.
10 FILLER PIC X(60) VALUE
''',MSGCLASS=Y,CLASS=D '.
10 FILLER PIC X(02) VALUE SPACES.


05 WS-JOBLIB.
10 FILLER PIC X(60) VALUE
'//JOBLIB DD DSN=<JOBLIB NAME>,DISP=SHR'

05 WS-UTILITY.
10 FILLER PIC X(60) VALUE
'// UTILITY EXEC PGM=IDCAMS'

05 WS-STATEMENTS.
10 .....WRITE THE GDG CREATE STATEMENTS HERE


01 INTRDR-CONTROL PIC X(80) VALUE SPACES.

01 WS-SUB PIC 9(3) value + 0.


PROCEDURE DIVISION.

PERFORM VARYING WS-SUB FROM 1 BY 1 UNTIL WS-SUB > N **** Here N is the numbe rof 05 level statements.
MOVE WS-JCL-AREA(WS-SUB) TO INTRDR-CONTROL
WRITE OT-REC FROM INTRDR-CONTROL
END-PERFORM.

CLOSE OUTFILE.




In the jcl code it as

Code:

//STEP1 EXEC PGM=MYPROG
//*
//OTFILE DD SYSOUT=(A,INTRDR)

-------------------------------------------------------------------------------------

Hope this helps

Regards

Mayuresh Tendullkar
Back to top
View user's profile Send private message
prasannadhabe

New User


Joined: 26 May 2003
Posts: 4
Location: Delhi

PostPosted: Fri Oct 03, 2003 6:36 pm    Post subject:
Reply with quote

Thanks For your help. Mr. Tendulkar.....
Back to top
View user's profile Send private message
Prandip

New User


Joined: 04 Mar 2005
Posts: 85
Location: In my tiny cubicle ...

PostPosted: Fri Jan 20, 2006 6:59 pm    Post subject: Re: How to create a data set through Cobol code
Reply with quote

This is another way it might be done. Forgive the crudeness, I'm not a programmer.
Code:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. MYPROG.
       INSTALLATION.
       AUTHOR. PRANDIP.
       DATE-WRITTEN. 1/20/2006.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.

         FILE-CONTROL.
           SELECT INPUT-FILE ASSIGN TO UT-S-SYSUT1
             ORGANIZATION IS SEQUENTIAL
             ACCESS IS SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.

       FD  INPUT-FILE
           LABEL RECORD STANDARD
           BLOCK 0 RECORDS
           RECORDING MODE F
           RECORD CONTAINS 80 CHARACTERS.
       01 INPUT-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  ALLOCATE-NEW-DSN.
           05  FILLER PIC X(16) VALUE 'ALLOC DD(SYSUT2)'.
           05  FILLER PIC X(4) VALUE ' DA('.
           05  FILLER PIC X    VALUE "'".
           05  WS-DATASET-NAME PIC X(23)
               VALUE 'PRANDIP.MY.GDG.G0001V00'.
           05  FILLER PIC X    VALUE "'".
           05  FILLER PIC X(17) VALUE ') NEW REU CATALOG'.
           05  FILLER PIC X(30) VALUE ' SPACE(100,100) TRACKS RELEASE'.
           05  FILLER PIC X(21) VALUE ' RECFM(F B) LRECL(80)'.

       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 ALLOCATE-NEW-DSN TO 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 ZEROS TO RETURN-CODE.
           STOP RUN.
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us