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

cobol pgm using 4 input file with specific column werite in


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

New User


Joined: 22 Jun 2006
Posts: 13
Location: mumbai

PostPosted: Wed Feb 20, 2008 11:04 am
Reply with quote

Hi ,

Please help me regarding this issue

i have 4 input file in cobol program

File1:

column1 column2 column3 column4
0-20 21-40 41-60 61-80

File 2:
column1 column2 column3 column4
0-20 21-40 41-60 61-80

File 3:
column1 column2 column3 column4
0-20 21-40 41-60 61-80

file 4:
column1 column2 column3 column4
0-20 21-40 41-60 61-80
now using cobol pgm

i want to generate 5 file which contains information of all files
with specific column

File5

column1 column2 column3 column4
file1 file2 file3 file4
colum2(21-40) colum3(41-60) column4(61-80) column1(0-20)
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Feb 20, 2008 12:32 pm
Reply with quote

satish1978 wrote:
i want to generate 5 file which contains information of all files with specific column
Ok...but did You want to say 'file 5' or 5 files (five seprates files) ?
Back to top
View user's profile Send private message
star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Wed Feb 20, 2008 1:27 pm
Reply with quote

Hi,

Hope following will help you for this:

Code:

01 WS-INREC
     05 WS-FILE-STRC                    OCCURS  4 TIMES.
          10 WS-INFILE-COL1            PIC X(20).
          10 WS-INFILE-COL2            PIC X(20).
          10 WS-INFILE-COL3            PIC X(20).
          10 WS-INFILE-COL4            PIC X(20).

01 WS-OUTREC
     05 WS-OUTFILE-COL1                PIC X(20).
     05 WS-OUTFILE-COL2                PIC X(20).
     05 WS-OUTFILE-COL3                PIC X(20).
     05 WS-OUTFILE-COL4                PIC X(20).

01 END-OF-FILE-FLAG                    PIC X(01) VALUE 'N'.
    88 END-OF-FILE-YES                           VALUE 'Y'.
    88 END-OF-FILE-NO                            VALUE 'N'.

01 WS-SUB                              PIC 9(01).

PROCEDUE DIVISION.
0000-MAINLINE-PARA.

    PERFORM  0100-OPEN-FILE-PARA
       THRU  0100-OPEN-FILE-EXIT.

    PERFORM  0200-PROCESS-FILE-PARA
       THRU  0200-POCESS-FILE-EXIT.

    PERFORM  0300-CLOSE-FILE-PARA
       THRU  0300-CLOSE-FILE-EXIT.

    STOP RUN.
0000-MAINLINE-EXIT.
    EXIT.
    EJECT
0000-MAINLINE-EXIT.
    EXIT.
    EJECT
   
0100-OPEN-FILE-PARA.

   OPEN INPUT    FILE1
                 FILE2
                 FILE3
                 FILE4
          OUTPUT FILE5.

0100-OPEN-FILE-EXIT.
   EXIT.
   EJECT

0200-PROCESS-FILE-PARA.

   PERFORM   0400-READ-FILE-PARA
       THRU  0400-READ-FILE-EXIT.

   IF END-OF-FILE-NO
     PERFORM UNTIL END-OF-FILE-YES
       MOVE WS-INFILE-COL2 (1)           TO WS-OUTFILE-COL1                 
       MOVE WS-INFILE-COL3 (2)           TO WS-OUTFILE-COL2                 
       MOVE WS-INFILE-COL4 (3)           TO WS-OUTFILE-COL3                 
       MOVE WS-INFILE-COL1 (4)           TO WS-OUTFILE-COL4                 
       PERFORM   0500-WRITE-FILE-PARA
          THRU   0500-WRITE-FILE-EXIT
       PERFORM   0400-READ-FILE-PARA
          THRU   0400-READ-FILE-EXIT
     END-PERFORM
   ELSE
     DISPLAY 'INPUT FILE HAS NO RECORD'
   END-IF.   

0200-PROCESS-FILE-EXIT.
   EXIT.
   EJECT


0300-CLOSE-FILE-PARA.

   CLOSE    FILE1
            FILE2
            FILE3
            FILE4
            FILE5.

0300-CLOSE-FILE-EXIT.
   EXIT.
   EJECT

0400-READ-FILE-PARA.

   READ INFILE1 INTO WS-FILE-STRC (1)
   AT END SET END-OF-FILE-YES           TO TRUE.
   
   IF END-OF-FILE-NO
      READ INFILE2 INTO WS-FILE-STRC (2)
      AT END SET END-OF-FILE-YES        TO TRUE
   END-IF.

   IF END-OF-FILE-NO
      READ INFILE3 INTO WS-FILE-STRC (3)
      AT END SET END-OF-FILE-YES        TO TRUE
   END-IF.

   IF END-OF-FILE-NO
      READ INFILE4 INTO WS-FILE-STRC (4)
      AT END SET END-OF-FILE-YES        TO TRUE
   END-IF.
   
0400-READ-FILE-EXIT.
   EXIT.
   EJECT

0500-WRITE-FILE-PARA.

   WRITE OUT-REC            FROM WS-OUTREC.

0500-WRITE-FILE-EXIT.
   EXIT.
   EJECT



Cheers! icon_smile.gif
Back to top
View user's profile Send private message
star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Wed Feb 20, 2008 1:55 pm
Reply with quote

Hi,
Quote:
01 WS-SUB PIC 9(01).


We don't need WS-SUB so remove this from declaration.


Cheers! icon_smile.gif
Back to top
View user's profile Send private message
satish1978

New User


Joined: 22 Jun 2006
Posts: 13
Location: mumbai

PostPosted: Wed Feb 20, 2008 2:01 pm
Reply with quote

no i want
i want

one output file

file out

COLUMN1 Column2 Colmun3 column4
file1 file2 file3 file4
colum2 column3 column4 column1
(21-40) (41-60) (61-80) (0-20)
Back to top
View user's profile Send private message
star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Thu Feb 21, 2008 10:47 am
Reply with quote

Hey,


Changed the requirement trying to be an onsite coordinator or what... icon_biggrin.gif

Anyways I gave the full logic just change the MOVE statement according to your need. Think you can do this much

Cheers! icon_smile.gif
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top