MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PRocessing difference

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Nabanita Das
Beginner


Joined: 09 Nov 2005
Posts: 33
Topics: 10

PostPosted: Thu Nov 10, 2005 11:12 pm    Post subject: PRocessing difference Reply with quote

Can anyone please explain how these 2 logics process differetnly?
Requirement was like following:

First record is a header record . So we need to skip that record and start processing from the next record till the end of the file FILE1

Logic 1:
perform Read-file1
perform untill (sw-eof-file1) or fatal-error

perform read-file1
perform process-para
end-perform

Logic 2:
Perform read-file1 2 times
perform until (sw-eof-file1) or fiatal-error

perform process-para
perform read-file1
end-perform


Please explain as I got different output for the above two logics.

Thanks and Regards,
Nabanita
Back to top
View user's profile Send private message
Ravi
Beginner


Joined: 27 Jun 2005
Posts: 88
Topics: 2

PostPosted: Thu Nov 10, 2005 11:33 pm    Post subject: Reply with quote

Nabanita Das,

You need add a IF NOT EOF logic before processing process-para in your logic 1.

logic 2 is fine but probably better to have a eof check before reading 2nd time.

Hope this helps.
Code:

Logic 1:
---------
perform Read-file1
perform untill (sw-eof-file1) or fatal-error

   perform read-file1
   if not eof file1 then
      perform process-para

end-perform
Back to top
View user's profile Send private message
Nabanita Das
Beginner


Joined: 09 Nov 2005
Posts: 33
Topics: 10

PostPosted: Fri Nov 11, 2005 12:04 am    Post subject: Reply with quote

Would you please explain how the logic you suggested is going to make difference? I tried it and it worked fine but I want to understand it more clearly. I may be very dumb ,sorry.

Thanks
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Nov 11, 2005 12:58 am    Post subject: Reply with quote

Nabanita Das,

As Ravi mentioned, you need to introduce a EOF check before invoking your Process-Para. This is essential because, assume you have only 1 record (the rule applies for 'n' records also. where n > 1).

As per your first logic
1. you have already read the header - outside the loop.
2. End of File is not set now.
3. So, the control gets into the loop and reads the input file again. This time there are no more records and hence EOF if set.
4. But without verifying the EOF condition, you invoke the process-para. But the FD record contains junk value and you do some operation using this junk data. (It might probably be the last record you read successfully - which is the header. So instead of skipping the header you actually process it).

This is true for any number of records. If you have 1 header followed by 4 data records, your EOF is set on the 5th iteration (6th read) but even after the EOF condition Process-para is invoked - once.

Bottomline is, you need to check for EOF condition everytime before you go to the record processing area.

Hope I am clear. Pls let me know if you need more information.

Thanks,
Phantom
Back to top
View user's profile Send private message
Nabanita Das
Beginner


Joined: 09 Nov 2005
Posts: 33
Topics: 10

PostPosted: Fri Nov 11, 2005 3:24 am    Post subject: Reply with quote

Thanks, Phantom. This is the kind of explanation I was looking for.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group