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
 

 

cobol pgm using 4 input file with specific column werite in

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: cobol pgm using 4 input file with specific column werite in
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

Senior Member


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

PostPosted: Wed Feb 20, 2008 12:32 pm    Post subject: Re: cobol pgm using 4 input file with specific column werite
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    Post subject:
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    Post subject:
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    Post subject: Reply to: cobol pgm using 4 input file with specific column
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    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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