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

Dynamic File allocation in Cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
Reply with quote

Hi Prabs,

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

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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top