View previous topic :: View next topic |
Author |
Message |
kris07 Beginner
Joined: 15 Jan 2007 Posts: 8 Topics: 4 Location: india
|
Posted: Tue Jul 24, 2007 9:23 am Post subject: To move the data between Header and Trailer Records |
|
|
Hi,
I have job which i need to move the data to discard file or proper file based on the records present in the file
Input File
aaa1111111
xxxxxxxxxx
xxxxxxxxxx
aaa2222222
xxxxxxxx
xxxxxxxx
bbb2222222
for example in the above scenario i need to move to proper file if
the data is in between aaa if i encounter bbb i have to move to discard file
i dont have limitation of records between aaa it can vary.
the record lenght is fixed of 80
can you please suggest.
regards,
kris07 |
|
Back to top |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Jul 24, 2007 9:50 am Post subject: |
|
|
my suggestions:- provide a little more detail about the file - such as how to identify the header and trailer
- this is application programming, are you looking for a SORT solution or a programming solution?
- if you are looking for a SORT solution, post the question in the SORT/Utilities Forum
- your requirements are confusing to me. you have an input file and apparently two output files, one you call Proper and the other Discard.
- what identifies records destined to the Proper file
- which records should go to the Discard file?
_________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
|
kris07 Beginner
Joined: 15 Jan 2007 Posts: 8 Topics: 4 Location: india
|
Posted: Thu Jul 26, 2007 8:24 am Post subject: |
|
|
Hi,
The header and trailer are identified by aaaa, the records identified between the aaa(Header and trailer) are proper files and the records which are not having trailer (aaaa) instead as (bbbb) they are identified as discard file.
we have towrite in application programming |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Thu Jul 26, 2007 8:58 am Post subject: |
|
|
kris07,
This is one of the simplest program you can ever get. You should be able to write this without any problem. I Hate to spoon feed you but here it is. Hopefully you learn something out of it.
Code: |
FD INPUT-FILE
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS INPUT-REC.
01 INPUT-REC.
05 RECORD-IDENTIFIER PIC X(03).
05 FILLER PIC X(77).
FD PROPER-FILE
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS PROPER-REC.
01 PROPER-REC PIC X(80).
FD DISCARD-FILE
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS DISCARD-REC.
01 DISCARD-REC PIC X(80).
WORKING-STORAGE SECTION.
01 S-EOF-INPUT PIC X(01) VALUE 'N'.
01 W-HDR-TRLR-COUNT PIC S9(01) VALUE 0.
PROCEDURE DIVISION.
PERFORM 1000-INITIALIZATION
PERFORM 2000-MAIN-PROCESS UNTIL S-EOF-INPUT = 'Y'
CLOSE INPUT-FILE
PROPER-FILE
DISCARD-FILE
GOBACK
.
1000-INITIALIZATION.
*************************************************************
*THIS PARAGRAPH OPENS THE FILES AND DOES THE PRIME READ. *
*************************************************************
OPEN INPUT INPUT-FILE
OUTPUT PROPER-FILE
DISCARD-FILE
PERFORM 4000-READ-INPUT
.
2000-MAIN-PROCESS.
*************************************************************
*THIS PARAGRAPH PERFORMS THE MAIN LOGIC *
*************************************************************
IF W-HDR-TRLR-COUNT > 0
IF RECORD-IDENTIFIER = 'AAA'
IF W-HDR-TRLR-COUNT = 2
MOVE +0 TO W-HDR-TRLR-COUNT
END-IF
END-IF
WRITE PROPER-REC FROM INPUT-REC
ELSE
WRITE DISCARD-REC FROM INPUT-REC
END-IF
PERFORM 4000-READ-INPUT
.
4000-READ-INPUT.
*************************************************************
*THIS PARAGRAPH READS THE INPUT FILE. *
*************************************************************
READ INPUT-FILE
AT END
MOVE 'Y' TO S-EOF-INPUT
NOT AT END
IF RECORD-IDENTIFIER = 'AAA'
ADD +1 TO W-HDR-TRLR-COUNT
END-IF
END-READ
.
|
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|