sequential files

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
neeraja
Member
Posts: 8
Joined: Sun Nov 18, 2007 12:40 pm
Location: India

sequential files

Post by neeraja » Sat Jan 19, 2008 5:46 pm

Hi,

Pls let me know

There are 2 sequential files. First file as records emp_no, emp_name, emp_salary, emp_dob .... so I need to copy emp_no and emp_name to other sequential file (which is empty).



Neeraja

mkk157
Member
Posts: 37
Joined: Wed Feb 07, 2007 2:00 pm
Location: Hyderabad

Post by mkk157 » Mon Jan 21, 2008 1:01 pm

Hi Neeraja,

This can be achieved by 2 two ways depends on the requirement.
The choice depends on whether u have any further processing in copying the data from Input file to Output file or not

1) Through JCL : U can make this possible by using a SORT card in a JCL
(When ther is no further processing of the records)

2) Through COBOL Program : U can write a program to make this possible.
(When there is a further processing of the records)

Please let us know the actual requirements so that we will provide the solution.
Kumar
If u can dream it, U can do it.

neeraja
Member
Posts: 8
Joined: Sun Nov 18, 2007 12:40 pm
Location: India

Post by neeraja » Mon Jan 21, 2008 9:47 pm

Hi,

I need cobol code for my quey. Actually this was the interveiw question
asked me and i dont have any further processing with this records.

mkk157
Member
Posts: 37
Joined: Wed Feb 07, 2007 2:00 pm
Location: Hyderabad

Post by mkk157 » Tue Jan 22, 2008 4:33 pm

Hi Neeraja,

If want to copy the 2 of the fields (EMP_NO & EMP_NAME) from Input file to Output file, the following code will be helpful.

FD INFILE
BLOCK CONTAINS 0 RECORDS.
01 INFILE-RECORD.
05 EMP_NO PIC X(5).
05 EMP_NAME PIC X(15).
05 EMP_SALARY PIC S9(9)COMP-3.
05 EMP_DOB PIC X(10).


FD OUTFILE
BLOCK CONTAINS 0 RECORDS.
01 OUTFILE-RECORD.
05 EMP_NO PIC X(5).
05 EMP_NAME PIC X(15).


PROCEDURE DIVISION.

MAIN-PROCESS SECTION.

PERFORM COPY-PROCESS UNTIL INFILE-EOF.

MAIN-PROCESS-EXIT.
EXIT.


COPY-INOUT SECTION.

READ INFILE INTO INFILE-RECORD

MOVE EMP_NO IN INFILE-RECORD
TO EMP_NO IN OUTFILE-RECORD

MOVE EMP_NAME IN IN INFILE-RECORD
TO EMP_NAME IN OUTFILE-RECORD

PERFORM WRITE-OUTFILE.

COPY-INOUT-EXIT.
EXIT.


WRITE-OUTFILE SECTION.

WRITE OUTFILE-RECORD.

WRITE-FILE-EXIT.
EXIT.


Still If u have any concerns, please get back.
Kumar
If u can dream it, U can do it.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others