View previous topic :: View next topic
|
Author |
Message |
swapnilushinde
New User
Joined: 17 Mar 2009 Posts: 30 Location: Bangalore.India
|
|
|
|
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 :
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
ridgewalker58
New User
Joined: 26 Sep 2008 Posts: 51 Location: New York
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|