IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Unpredictable results while dealing with DATA-RECORD


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
swapnilushinde

New User


Joined: 17 Mar 2009
Posts: 30
Location: Bangalore.India

PostPosted: Wed Jul 07, 2010 6:49 pm
Reply with quote

Hello everyone
I am confused with below scenario -
Input 1 :
Code:
 
FD INPUT1                       
     RECORDING MODE IS F         
     DATA RECORD IS P-REC.   
01 P-REC  PIC  X(200).     


Input 2 :
Code:
 
FD INPUT2                       
     RECORDING MODE IS F         
     DATA RECORD IS T-REC.   
01 T-REC  PIC  X(200).     


Inside program :
Code:
 
IF T-REC = P-REC


Will it cause any problem when I compare directly DATA-RECORD ?
Ideally, we always READ input file into working storage record and then play with working storage record only. We should not play with file description (FD) record.. (Correct me if wrong !!)
In my case, above IF condition sometimes work fine and sometimes wont.. I should not compare DATA-RECORDS.
Please let me know whether my understanding is correct or I am missing something.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Jul 07, 2010 7:56 pm
Reply with quote

swapnilushinde wrote:
Ideally, we always READ input file into working storage record and then play with working storage record only. We should not play with file description (FD) record.. (Correct me if wrong !!)
The word "Ideally" can get questionable, there is no thumb-rule of this sort - though it can be a site standard. You can use them directly.

Quote:
In my case, above IF condition sometimes work fine and sometimes wont.. I should not compare DATA-RECORDS.
in what cases did it work and in it did not? Did it work "ideally" when you use working-storage variables?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 07, 2010 8:07 pm
Reply with quote

The basic reasons for using workarea option is
you can initialize/manipulate/question the workarea without regard to file status.

this enables for smother logic - not having to qualify everything with a
IF FILE IS OPEN AND STATUS IS OK.

also means when jr programmers follow with maintenance,
there is less worry about inadvertently 'adding' a bug.

with the speed of machines and memory availability
most professionals use the workarea-option when working with files to prevent S0C4's.

and if all works correctly with workarea option,
then there is little need to revert to using the datarecord.
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Wed Jul 07, 2010 8:08 pm
Reply with quote

In my experience, using the "data records" (the 01 level that is contained within the FD file section) ALWAYS works.

PROVIDED that I have successfully opened the files and read a record from the files. AND have not reached an end of file condition.

When I can avoid the READ ________ INTO method, I avoid it.
This is because when I do the READ of the file with the INTO clause--
1. The record is available in the 01 level area and
2. AFTER the record is in the 01 level area it is COPIED
INTO the area that I specified (extra time to process data)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 07, 2010 8:24 pm
Reply with quote

ridgewalker58 wrote:
In my experience, using the "data records" (the 01 level that is contained within the FD file section) ALWAYS works.

good for you!
ridgewalker58 wrote:

PROVIDED that I have successfully opened the files and read a record from the files. AND have not reached an end of file condition.

and therein lies the rub, especially for jr's following.
ridgewalker58 wrote:

When I can avoid the READ ________ INTO method, I avoid it.
This is because when I do the READ of the file with the INTO clause--
1. The record is available in the 01 level area and
2. AFTER the record is in the 01 level area it is COPIED
INTO the area that I specified (extra time to process data)


very true for simple programs, and process time is important on a small machine.

but, if one is performing a 2 or more file match merge,
the logic is much easier if the workarea option is used.

and if there is a large difference in file sizes,
the time saved by not using the workarea-option
can be eaten up and lost by the extra IF OPEN STATUS-OK
tests.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jul 07, 2010 8:43 pm
Reply with quote

Hello,

Quote:
We should not play with file description (FD) record.. (Correct me if wrong !!)

In my case, above IF condition sometimes work fine and sometimes wont.. I should not compare DATA-RECORDS.
Please let me know whether my understanding is correct or I am missing something.
It looks like you are missing something. Done correctly, the compare will work correctly every time - either way. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top