Page 1 of 1

Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 5:17 pm
by lions90
Hi,

Im from Holland, so i hope my english is good enough. I'm writing a cobol pgm for xml. I'm using 3 files, INPBEST (input), OUTXML (xml) and TEMPFILE (temp file for records i need later).

I'm testing a the moment and when i run 3 customers seperately it goes well concering the TEMPFILE. When i need to fill the TEMPFILE for 2 customers it goes wrong. For the second customer i get EOF right away, but the program does the same sections for the second customer. My code is:

I'm using WS-array and with write i fill the temp records. The SW-OPEN is used to determine if TEMPFILE is open.

IF SW-OPEN = ZERO
THEN
OPEN OUTPUT TEMPFILE
MOVE 1 TO SW-OPEN
WRITE TEMP-RECORD FROM TEMP-REC : temp-rec is ws-array
END-IF

CLOSE TEMPFILE

OPEN INPUT TEMPFILE

PERFORM S02-READ-TEMP

PERFORM UNTIL EOF
WRITE XML-RECORD FROM TEMP-RECORD
PERFORM S02-READ-TEMP
END-PERFORM

MOVE ZERO TO SW-OPEN

CLOSE TEMPFILE

As said for the first en second customer all sections are processed but for second,third etc etc customer EOF is reached (so TEMPFILE is empty). Why is TEMPFILE not filled more than once? Hope you can help me. Thanks.

Regard,
Jeroen

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 5:51 pm
by BillyBoyo
Can you show where "EOF" is defined and how it is used?

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 6:03 pm
by lions90
EOF is used here:

S02-READ-TEMP SECTION.

READ TEMPFILE INTO WS-IPAP-RECORD
AT END SET EOF TO TRUE

TEMPFILE is empty second time....dont understand why.

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 6:04 pm
by lions90
SWITCHES.
03 EOF-SWITCH PIC X.
88 EOF VALUE 'J'.

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 6:07 pm
by Robert Sample
After the first customer is processed, how do you reset the switch? If you do not reset the switch yourself, it will still be EOF when you start processing the second customer's data.

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 6:10 pm
by GuyC
by the looks of it; you only write to temp file the first time :
IF SW-OPEN = ZERO
   ...
   WRITE TEMP-RECORD FROM TEMP-REC : temp-rec is ws-array
END-IF

shouldn't the WRITE be outside of that IF?
IF SW-OPEN = ZERO
   ...
END-IF
WRITE TEMP-RECORD FROM TEMP-REC : temp-rec is ws-array

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 6:15 pm
by lions90
YES that solves the problem...after first customer i set eof-swith to 'N'. Stupid mistake but thanks for your help ;-)

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 6:20 pm
by BillyBoyo
The things is not to lead yourself astray with a misdiagnosis of the problem.

Your 2nd processing got EOF. You should have checked how EOF was set, as the first thing to do. Instead you assumed it was correct, and that led you to "how is it not writing" for the 2nd.

Re: Problem with filling temp sequential file more than once

PostPosted: Wed Aug 08, 2012 6:25 pm
by lions90
Yes you are right...thanks for the help!