have in 100 records in a flat file i want to move records
like 1,3,5,7,9,11,.. to Output file1 and
2,4,6,8,10,12,14 .. records moved to Output file2..Pls
Provide real time answer..

Answer Posted / dimpy19

FILE-CONTROL.
SELECT INP ASSIGN TO INF
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD INP
RECORDING MODE IS F.
01 INP-REC.
10 STUDENT-ID PIC 9(3).
10 STUDENT-NAME PIC X(20).
FILE-CONTROL.
SELECT INP ASSIGN TO INF
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD INP
RECORDING MODE IS F.
01 INP-REC.
10 STUDENT-ID PIC 9(3).
10 STUDENT-NAME PIC X(20).
WORKING-STORAGE SECTION.
01 C PIC 99 VALUE ZEROS.
01 D PIC 99V99 VALUE ZEROS.
01 E PIC 99.99.
01 I PIC 99 VALUE ZEROS.
01 WS-INP-REC.
10 WS-STUDENT-ID PIC 9(3).
10 WS-STUDENT-NAME PIC X(20).
05 EOF PIC X VALUE 'N'.
01 PRINT-CHAR PIC X(20).
PROCEDURE DIVISION.
OPEN INPUT INP.
READ INP INTO WS-INP-REC.
PERFORM UNTIL EOF = 'Y'
ADD 1 TO I
DISPLAY I
DIVIDE 2 INTO I GIVING C REMAINDER D
MOVE D TO E
DISPLAY E
IF (D IS ZERO)THEN
DISPLAY WS-STUDENT-NAME
END-IF
READ INP INTO WS-INP-REC AT END MOVE 'Y' TO EOF
END-READ
END-PERFORM.
CLOSE INP.
GOBACK.

output :
01
01.00
02
00.00
BRPITA
03
01.00
04
00.00
DRPITA
05
01.00
06
00.00
FRPITA

input :
000001 070 ARPITA
000002 080 BRPITA
000003 090 CRPITA
000004 100 DRPITA
000005 110 ERPITA
000006 120 FRPITA

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the pertinent COBOL commands?

2623


What is the utilization of copybook in cobol?

657


Explain the configuration section of a cobol program with examples of syntax.

659


Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.

1701


What is the problem of ordered sequential files access?

702






how do you reference the variable block file formats from cobol programs

686


What are various search techniques in cobol? Explain.

650


Can we change the password using ALTER? anyone tried and changed?

1547


how do you reference the rrds file formats from cobol programs

798


IF I mention stop run in CICS what happens?

1896


What are all the divisions of a COBOL program?

663


State the various causes of s0c1, s0c5 and s0c7.

663


A table has two indexes defined. Which one will be used by the SEARCH?

758


Have you used comp and comp-3 in your project? And how?

2008


How do we get current date from system with century in COBOL?

805