View previous topic :: View next topic |
Author |
Message |
DGM Beginner
Joined: 21 Sep 2003 Posts: 12 Topics: 4
|
Posted: Sat Nov 12, 2005 1:08 am Post subject: Easytrieve Abend at END OF File |
|
|
The input file is 1 byte length and and total of 14080 records.
I want to accumulate 483 bytes from input to write to output file. My Program is abending at end of file.
Trying to find why is it so ?
Code: |
FILE FILE01
FILE01-RECIN 1 1 A
FILE FILE02
FILE02-RECOUT 1 483 A
WS-OUTPUT-RECORD W 483 A
WS-OUTPUT-REC WS-OUTPUT-RECORD W 1 OCCURS 483 INDEX RECO
JOB INPUT NULL START READ-INFILE
PERFORM PROCESS-OUT
PROCESS-OUT. PROC
RECO = 1
DO WHILE (RECO LE 483) AND (NOT EOF FILE01)
WS-OUTPUT-REC(RECO) = FILE01-RECIN
PERFORM READ-INFILE
RECO = RECO + 1
END-DO
MOVE WS-OUTPUT-RECORD TO FILE02-RECOUT
PUT FILE02
END-PROC
READ-INFILE. PROC
GET FILE01
END-PROC
|
Can any one help me writing perfect code to avoid abend. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sat Nov 12, 2005 4:17 am Post subject: |
|
|
DGM,
You are getting an error because you don't have logic to perform once the file has reached end. you are just checking for EOF condition but you did not code any logic to perform after eof.
Anyway here is an untested code which should give you the desired results.
Code: |
FILE FILE01
F1-REC 01 001 A
FILE FILE02
F2-OUT 01 483 A
F2-REC 01 001 A OCCURS 483 INDEX ODX
JOB INPUT FILE01 FINISH LAST-REC
ODX = ODX + 1
IF ODX > 483
PUT FILE02
ODX = 1
F2-OUT = ' '
F2-REC (ODX) = F1-REC
ELSE
F2-REC (ODX) = F1-REC
END-IF
LAST-REC. PROC
PUT FILE02
END-PROC
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
DGM Beginner
Joined: 21 Sep 2003 Posts: 12 Topics: 4
|
Posted: Sat Nov 12, 2005 4:09 pm Post subject: |
|
|
Hi Kolusu
This worked and thak you very much for your solution.
Again It didn't solve my purpose what I am trying to do.
This logic will always write the record even if it has not reached 483 Bytes. But I want to write only when full complete of 483 Bytes.
If the input record has 483 Bytes I want to write one record.
If input file has 965 records which is 1 less than 483*2 , I still want to write one record. If the input file has 966 Bytes which is Exactly 2 output record, I want to write two records.
For this one , I removed the FINISH LAST-REC.
But when I removed it, Even if the input file has 483 Records, It didn't write any record.
How do I accompalish this logic in easytrieve. I tried DO WHILE and in end I could not get my result.
Thanks
DGM |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sat Nov 12, 2005 4:22 pm Post subject: |
|
|
DGM,
You should have mentioned all the requirements earlier. You don't need a DO while statement to incorporate the new requirement, all you need is to chang the IF statement to the following and remove the last-rec proc.
Code: |
IF ODX = 483
F2-REC (ODX) = F1-REC
PUT FILE02
ODX = 0
F2-OUT = ' '
ELSE
F2-REC (ODX) = F1-REC
END-IF
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
DGM Beginner
Joined: 21 Sep 2003 Posts: 12 Topics: 4
|
Posted: Mon Nov 14, 2005 12:12 am Post subject: |
|
|
Hi kolusu
I did the coding the way you have suggested. I saw my input has 966 records and i am expecting two output records but it only wrote one record. I thing i have to do something with end of file but could not figure out.
please check if the logic you have given is correct or not.
I have not checked if the input file has 483 records. I thing in this case also It will write only one record.
Thanks
Digambar |
|
Back to top |
|
|
DGM Beginner
Joined: 21 Sep 2003 Posts: 12 Topics: 4
|
Posted: Mon Nov 14, 2005 12:15 am Post subject: |
|
|
Sorry for mistaken in last sentense. If input has 483 records, It won't be writing any record by putting the = sign in If loop. |
|
Back to top |
|
|
DGM Beginner
Joined: 21 Sep 2003 Posts: 12 Topics: 4
|
Posted: Mon Nov 14, 2005 12:23 am Post subject: |
|
|
I thing, I have mistaken in my code. I have kept ODX = 1 instead of ODX=0.
I will check it again before Post again.
Thank you kolusu. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Nov 14, 2005 7:35 am Post subject: |
|
|
DGM,
The code shown by me gives the exact results.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
DGM Beginner
Joined: 21 Sep 2003 Posts: 12 Topics: 4
|
Posted: Mon Nov 14, 2005 10:49 pm Post subject: |
|
|
Yes Kolusu, It worked as I have expected. It is a great site to get the resolution.
Thank you Kolusu |
|
Back to top |
|
|
|
|