Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic File allocation in Cobol

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

New User


Joined: 04 Jan 2006
Posts: 77
Location: Bangalore

PostPosted: Wed Jan 11, 2006 1:54 am    Post subject: Dynamic File allocation in Cobol
Reply with quote

I need to process 2 million to 3 million records in my program, add/delete/modify wrt to given rules. These records need to be output in to another system. The Backend system, to which my program exports the file, can take in a file of max capacity 200,000. Now as I pointed out, the input can vary between 2 million and 3 million, so I can have 10 - 15 files after every run.
Now, I cannot send them a Blank file, they say its gonna kill them? icon_eek.gif I need to DYNAMICALLY allocate the files, say if there are 2.5 million records, there should be 13 files and no more.

Is there any way to code this in cobol, dyanamic FD statements? Or some utility in the IBM mainframe that can sync up with my Cobol Pgm to create these files dynamically?

HELP!!! icon_sad.gif icon_sad.gif icon_sad.gif
Back to top
View user's profile Send private message

vikasc4

New User


Joined: 11 Dec 2005
Posts: 32

PostPosted: Wed Jan 11, 2006 11:05 am    Post subject:
Reply with quote

I think you can use GDG with the limit as 13. You can use a counter and as it reaches 200,000, the program must terminate and you can again submit the job and start from the 200,001th record.

To start from this new record position you can accept the starting record position at run time and for that you don't have to change the program every time. For e.g for the first time the value supplied must be 1 for the first record,for the second time it must be 200,001 and so on.....

If this solve your problem then tell me or it may be that i don't understand your problem fully if that is the case then pl elaborate your problem fully. like

1. what is the record size , is it fixed or variable.
etc.

regards

Vikas icon_smile.gif icon_smile.gif icon_smile.gif
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Jan 14, 2006 8:46 am    Post subject: Re: Dynamic File allocation in Cobol
Reply with quote

Hi new2cobol,

Quote:

I need to process 2 million to 3 million records in my program, add/delete/modify wrt to given rules. These records need to be output in to another system. The Backend system, to which my program exports the file, can take in a file of max capacity 200,000. Now as I pointed out, the input can vary between 2 million and 3 million, so I can have 10 - 15 files after every run.
Now, I cannot send them a Blank file, they say its gonna kill them? I need to DYNAMICALLY allocate the files, say if there are 2.5 million records, there should be 13 files and no more.

Is there any way to code this in cobol, dyanamic FD statements? Or some utility in the IBM mainframe that can sync up with my Cobol Pgm to create these files dynamically?


I?m going to key on something you said above, that the backend process could accept a max capacity of 200,000 records from a single file. I believe I would approach this a little differently, instead of filling each file to the max capacity, I would send them, with room for expansion, maybe 20 files. Every time, with an approximate equal number of records in each file.

You could do this in a single program, or you could make the process into two programs.

Pseudo Code for a single program:

Code:


    OPEN INPUT  IN-FILE
         OUTPUT INTERMEDIATE-FILE.

    PERFORM P7000-READ-IN-FILE

    PERFORM P2000-PROCESS-IN-FILE
        UNTIL IN-FILE-EOF

    CLOSE IN-FILE
          INTERMEDIATE-FILE.

    OPEN INPUT  INTERMEDIATE-FILE    
       OUTPUT OUT-FILE-01
                OUT-FILE-02
                OUT-FILE-03
                OUT-FILE-04
                OUT-FILE-05
                OUT-FILE-06
                OUT-FILE-07
                OUT-FILE-08
                OUT-FILE-09
                OUT-FILE-10
                OUT-FILE-11
                OUT-FILE-12
                OUT-FILE-13
                OUT-FILE-14
                OUT-FILE-15
                OUT-FILE-16
                OUT-FILE-17
                OUT-FILE-18
                OUT-FILE-19
                OUT-FILE-20.

    COMPUTE WS-FILE-RECORD-COUNT = TOTAL-RECORD-COUNT / 20.

    PERFORM P7000-READ-INTERMEDIATE-FILE

    PERFORM P2100-PROCESS-INTERMEDIATE-FILE
        UNTIL INTERMEDIATE-FILE-EOF.
             
    CLOSE       INTERMEDIATE-FILE    
              OUT-FILE-01
                OUT-FILE-02
                OUT-FILE-03
                OUT-FILE-04
                OUT-FILE-05
                OUT-FILE-06
                OUT-FILE-07
                OUT-FILE-08
                OUT-FILE-09
                OUT-FILE-10
                OUT-FILE-11
                OUT-FILE-12
                OUT-FILE-13
                OUT-FILE-14
                OUT-FILE-15
                OUT-FILE-16
                OUT-FILE-17
                OUT-FILE-18
                OUT-FILE-19
                OUT-FILE-20.

    GOBACK.

P2000-PROCESS-IN-FILE.
    PERFORM P3000-UPDATE-FILE
    PERFORM P8000-WRITE-INTERMEDIATE-FILE
    ADD +1             TO TOTAL-RECORD-COUNT
    PERFORM P7000-READ-IN-FILE

P2100-PROCESS-INTERMEDIATE-FILE.
    MOVE +0             TO TOTAL-WRITE-COUNT
    EVALUATE TOTAL-WRITE-COUNT
        WHEN 0 THRU WS-FILE-RECORD-COUNT
            PERFORM P8001-WRITE-OUT-FILE-01
            ADD +1      TO TOTAL-WRITE-COUNT
        WHEN (WS-FILE-RECORD-COUNT + 1) THRU (WS-FILE-RECORD-COUNT * 2) 
            PERFORM P8002-WRITE-OUT-FILE-02
            ADD +1      TO TOTAL-WRITE-COUNT
        WHEN ((WS-FILE-RECORD-COUNT * 2) + 1) THRU (WS-FILE-RECORD-COUNT * 3) 
            PERFORM P8003-WRITE-OUT-FILE-03
            ADD +1      TO TOTAL-WRITE-COUNT
        WHEN ((WS-FILE-RECORD-COUNT * 3) + 1) THRU (WS-FILE-RECORD-COUNT * 4) 
            PERFORM P8004-WRITE-OUT-FILE-04
            ADD +1      TO TOTAL-WRITE-COUNT
        :
        :
        WHEN > WS-FILE-RECORD-COUNT * 19
            PERFORM P8020-WRITE-OUT-FILE-20
            ADD +1      TO TOTAL-WRITE-COUNT
    END-EVALUATE
    PERFORM P7000-READ-INTERMEDIATE-FILE.

Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Jan 20, 2006 2:28 pm    Post subject:
Reply with quote

Hi David,

That was a good stuff from you. But I do believe that Intermediate file should be opened in I-O mode (which will enable to open or close in the same pgm). Isn't it?

Thanks & Regards
Prabs
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Jan 21, 2006 12:02 am    Post subject: Re: Dynamic File allocation in Cobol
Reply with quote

prabs2006,

Opening in I-O mode says that you can read and/or write/rewrite to the file while it's open. In this case I want open for output to sequentially write until all of the data has been written, counting the number of records. Then, closing the file and re-opening as input resets the current record pointer back to the first record, and it can then be sequentially read until eof.

Dave,
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jan 21, 2006 6:31 am    Post subject:
Reply with quote

Hi Prabs,

I haven't used this link myself, but it may be what you're looking for.

ftp://ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html#Section_2.3
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Mon Jan 23, 2006 4:35 pm    Post subject:
Reply with quote

Hi David,

I didnt get ur point here. You mean to say any file opened in output mode can be closed and can be opened in input mode in the same pgm. I am afraid this will not be possible.

Hi Jack,

As far as I have gone thru the link, it doesn't have anything that we discuss here.

Thanks & Regards
Prabs
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Jan 23, 2006 8:33 pm    Post subject: Re: Dynamic File allocation in Cobol
Reply with quote

Hi prabs2006,

Here is a program I wrote to demonstrate my point. (with run JCL)

Code:


  ENVIRONMENT DIVISION.                                               
  INPUT-OUTPUT SECTION.                                               
  FILE-CONTROL.                                                       
                                                                     
       SELECT INTERIM-FILE        ASSIGN TO UT-S-INTERIM.             
                                                                     
  DATA DIVISION.                                                     
  FILE SECTION.                                                       
                                                                     
  FD  INTERIM-FILE                                                   
      LABEL RECORDS ARE STANDARD                                     
      BLOCK CONTAINS 0 RECORDS.                                       
  01  INTERIM-REC.                                                   
      05  RECORD-NUMBER           PIC 9(5).                           
      05  RECORD-FILLER           PIC X(75).                         
                                                                     
  WORKING-STORAGE SECTION.                                           
                                                                     
  01  PGM-VARIABLES.
      05  SUB                     PIC S9(9)    COMP-3       
                                               VALUE +0.     
      05  WS-INTERIM-EOF-SW       PIC X        VALUE 'N'.   
  PROCEDURE DIVISION.                                       
                                                             
      OPEN OUTPUT INTERIM-FILE.                             
                                                             
      PERFORM                                               
        VARYING SUB FROM 1 BY 1                             
        UNTIL SUB > 5                                       
          MOVE SUB TO RECORD-NUMBER                         
          PERFORM P8000-WRITE-INTERIM-RECORD                 
              THRU P8000-EXIT                               
      END-PERFORM.                                           
                                                             
      CLOSE INTERIM-FILE.                                   
                                                             
      OPEN INPUT INTERIM-FILE.                               

      PERFORM P7000-READ-INTERIM-FILE                                 
          THRU P7000-EXIT.                                           
                                                                     
      PERFORM                                                         
        UNTIL WS-INTERIM-EOF-SW = 'Y'                                 
          DISPLAY 'RECORD-NUMBER:' RECORD-NUMBER                     
          PERFORM P7000-READ-INTERIM-FILE                             
              THRU P7000-EXIT                                         
      END-PERFORM.                                                   
                                                                     
      CLOSE INTERIM-FILE.                                             
                                                                     
      GOBACK.                                                         
 ******************************************************************   
 *    READ INTERIM FILE                                               
 ****************************************************************** 

  P7000-READ-INTERIM-FILE.                                           
                                                                     
      READ INTERIM-FILE                                               
          AT END                                                     
             MOVE 'Y'             TO WS-INTERIM-EOF-SW.               
                                                                     
  P7000-EXIT.                                                         
      EXIT.                                                           
      EJECT                                                           
 ******************************************************************   
 *    WRITE INTERIM RECORD                                           
 ******************************************************************   
                                                                     
  P8000-WRITE-INTERIM-RECORD.                                         
                                                                     
      WRITE INTERIM-REC.                                             
                                                                     
  P8000-EXIT.                                                         
      EXIT.           
      EJECT             
                                                                                                                                                                         
                                                         

//xxxxx#   JOB (ACCT,ROOM),xxxxxxx,                     
//    MSGCLASS=Y,NOTIFY=xxxxx                           
//JS00100  EXEC PGM=#TEST                               
//STEPLIB  DD DSN=xxx.xxxxxxx.TEST.LOADLIB,DISP=SHR     
//INTERIM  DD DSN=xxxxx.INTERIM,                       
//            DISP=(NEW,CATLG,DELETE),                 
//            SPACE=(80,(100,100),RLSE),AVGREC=U,       
//            RECFM=FB,LRECL=80                         
//SYSOUT  DD SYSOUT=*                                   



And this is the results of running the above program.

Code:

.SARPAGE 4                                                   
.                                                             
.RECORD-NUMBER:00001                                         
.RECORD-NUMBER:00002                                         
.RECORD-NUMBER:00003                                         
.RECORD-NUMBER:00004                                         
.RECORD-NUMBER:00005                                         
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Tue Jan 24, 2006 9:52 am    Post subject:
Reply with quote

Hi David,

Good..A new one for me as I haven't done like this before..Thanks for the same..

Thanks & Regards
Prabs
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 Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us