View previous topic :: View next topic
|
Author |
Message |
Abhushan_s
New User
Joined: 28 Jul 2008 Posts: 34 Location: Ahmedabad
|
|
|
|
Hi Could anyone tell me where can we possibly use LOW VALUES and HIGH VALUES..
Actually i have to check for NOT NUMERIC data as well as LOW VALUES, so are these low values some kind of values that come neither in NUMERIC nor in ALPHANUMERIC data? coz when i consulted about it, i got the response as LOW VALUES are those values that are some kinds of Special charecters...
Could anyone help me out regarding LOW VALUES and HIGH VALUES? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
Abhushan_s wrote: |
Could anyone help me out regarding LOW VALUES and HIGH VALUES? |
There are occasions when you may wish to set a variable to an infinitely high or infinitely low number. For example, suppose you were merging two files on surnames as the primary key:
*in data division FILE SECTION
Code: |
FD FILE-1.
01 RECORD-1.
03 IN-NAME-1 PIC X(20).
03 FILLER PIC X(50).
FD MERGE-FILE.
01 RECORD-OUT PIC X(70).
:
:
PERFORM WITH TEST AFTER EOF-FLAG-1 AND EOF-FLAG-2 |
*loop until each file has been read to completion
*read each file
Code: |
READ FILE-1
AT END SET EOF-FLAG-1 TO TRUE
MOVE HIGH-VALUES TO IN-NAME-1
END-READ
READ FILE-2
AT END SET EOF-FLAG-2 TO TRUE
MOVE HIGH-VALUES TO IN-NAME-2
END-READ |
*sort the records (assuming no 2 names are the same)
*on ascending surname
Code: |
IF IN-NAME-1 IS < IN-NAME-2 THEN
WRITE RECORD-OUT FROM RECORD-1
ELSE
WRITE RECORD-OUT FROM RECORD-2
END-IF
END-PERFORM |
In this example, when IN-NAME-1 is less than IN-NAME-2 (based on their ASCII values e.g. A < B etc..) then the FILE-1 record (RECORD-1) is written to the merge file (RECORD-OUT). One of FILE-1 and FILE-2 will come to an end before the other so the completed file has its IN-NAME- value set to constant that will ALWAYS be greater than the IN-NAME- value still being read, ensuring all remain files are written to the merge file. This is done with the lines: MOVE HIGH-VALUES TO IN-NAME-1 and MOVE HIGH-VALUES TO IN-NAME-2.
Quote: |
Actually i have to check for NOT NUMERIC data as well as LOW VALUES, so are these low values some kind of values that come neither in NUMERIC nor in ALPHANUMERIC data? coz when i consulted about it, i got the response as LOW VALUES are those values that are some kinds of Special charecters... |
It is important to note that HIGH-VALUES and LOW-VALUES are ALPHANUMERIC in type, so you can't set numerically defined variables to this type (you would have to implicitly redefine the variable first). This is an annoying quirk of COBOL.
Hope this helps.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
Back to top |
|
|
Abhushan_s
New User
Joined: 28 Jul 2008 Posts: 34 Location: Ahmedabad
|
|
|
|
Hey Anuj thanks for the reply, It helped.
I would like to just re-phrase what you mentioned.
Is it that, as the values in either FILE-1 or FILE-2 will come to an end, we need to keep one of the values or both of them to a high value that will cause all the eligible records in both the files to be written to the output file?
Actually i have another issue, iam checking for the value in a field 'WS-A' and i dont want it to either be NOT NUMERIC or LOW VALUES. but when i give the condition as
IF WS-A IS NOT NUMERIC OR LOW-VALUES
It shows an error which is
"An invalid abbreviated relation condition was found. The statement was
discarded." on the above conditional statement.
Is the error due to wrong syntax?
please let me know the correct syntax of it. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
IF WS-A IS NOT NUMERIC OR LOW-VALUES |
This is syntactically invalid; if you carry the condition through you get IF WS-A NOT NUMERIC OR NOT LOW-VALUES, and NOT LOW-VALUES is invalid. You need to have
Code: |
IF WS-A NOT NUMERIC AND WS-A NOT = LOW-VALUES |
. You don't want an OR condition, anyway -- why have an IF test in that case? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
as Robert indicated, your syntax is bad. but that was based on your verbiage, which was also incorrect:
Quote: |
i dont want it to either be NOT NUMERIC or LOW VALUES
|
should have been:
i dont want it to be NOT NUMERIC and I don't want it to be equal to LOW VALUES |
|
Back to top |
|
|
Abhushan_s
New User
Joined: 28 Jul 2008 Posts: 34 Location: Ahmedabad
|
|
|
|
Hey Robert thanks for the help. [/quote] |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
Good, the syntax worked for you, however, you didn't answer this
Quote: |
why have an IF test in that case? |
yet, asked by Robert.. |
|
Back to top |
|
|
Abhushan_s
New User
Joined: 28 Jul 2008 Posts: 34 Location: Ahmedabad
|
|
|
|
Actually Anuj, i have a case to test whether the field is having a non numeric data and also check whether it has LOW-VALUES.
i was told to do that, nut i also asked y do we need the IF condition , but then there is some standard i had to follow so even i was confused in the beginning but then no harm in checking again! . |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
Abhushan_s wrote: |
i have a case to test whether the field is having a non numeric data and also check whether it has LOW-VALUES. |
Probably, one would expect to have two different behaviour of program on these two checks, well, anyway..
Quote: |
i was told to do that |
well, if one has a better suggestion, one must know the tactics to let other know aboout that...even to seniors ..
Probably I skipped to answer it in previous hit to this thread..
Quote: |
Is it that, as the values in either FILE-1 or FILE-2 will come to an end, we need to keep one of the values or both of them to a high value that will cause all the eligible records in both the files to be written to the output file? |
answer is..Yes. |
|
Back to top |
|
|
Abhushan_s
New User
Joined: 28 Jul 2008 Posts: 34 Location: Ahmedabad
|
|
|
|
Hey Anuj, Thanks for the Reply. I would keep that in mind. |
|
Back to top |
|
|
|