Problem with filling temp sequential file more than once



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Problem with filling temp sequential file more than once

Postby lions90 » Wed Aug 08, 2012 5:17 pm

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
lions90
 
Posts: 5
Joined: Mon Jul 30, 2012 11:20 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Problem with filling temp sequential file more than once

Postby BillyBoyo » Wed Aug 08, 2012 5:51 pm

Can you show where "EOF" is defined and how it is used?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Problem with filling temp sequential file more than once

Postby lions90 » Wed Aug 08, 2012 6:03 pm

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.
lions90
 
Posts: 5
Joined: Mon Jul 30, 2012 11:20 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Problem with filling temp sequential file more than once

Postby lions90 » Wed Aug 08, 2012 6:04 pm

SWITCHES.
03 EOF-SWITCH PIC X.
88 EOF VALUE 'J'.
lions90
 
Posts: 5
Joined: Mon Jul 30, 2012 11:20 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Problem with filling temp sequential file more than once

Postby Robert Sample » Wed Aug 08, 2012 6:07 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Problem with filling temp sequential file more than once

Postby GuyC » Wed Aug 08, 2012 6:10 pm

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
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: Problem with filling temp sequential file more than once

Postby lions90 » Wed Aug 08, 2012 6:15 pm

YES that solves the problem...after first customer i set eof-swith to 'N'. Stupid mistake but thanks for your help ;-)
lions90
 
Posts: 5
Joined: Mon Jul 30, 2012 11:20 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Problem with filling temp sequential file more than once

Postby BillyBoyo » Wed Aug 08, 2012 6:20 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Problem with filling temp sequential file more than once

Postby lions90 » Wed Aug 08, 2012 6:25 pm

Yes you are right...thanks for the help!
lions90
 
Posts: 5
Joined: Mon Jul 30, 2012 11:20 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post