|
View previous topic :: View next topic
|
| Author |
Message |
Prateeksichem1
New User
Joined: 11 Jul 2018 Posts: 2 Location: US
|
|
|
|
Hi,
I have 2 files
file1 of length 500
file2 of length 80
based on the matched keys, I need to compare Comp-3 field in file2 (length S9(13V99)) with the Comp-3 field in file1(length S9(13V99)).
file 2 field = -5000
file 1 field needs to be less than -5000 (like -6000)
when I'm running sort with below code, it gives me all the negative values not only lesser ones, need your help to achieve this. Thanks
JOINKEYS FILE=F1,FIELDS=(2417,3,A)
JOINKEYS FILE=F2,FIELDS=(0043,3,A)
REFORMAT FIELDS=(F1:1,2550,F2:1,200)
INCLUDE COND=(209,08,PD,LT,2555,08,PD)
SORT FIELDS=COPY
OUTREC FIELDS=(1:1,2550)
Thanks
Prateek |
|
| Back to top |
|
 |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
| Can you post a snippet of input data with hex on. Please use the code tags. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Hello Prateek - welcome to the forums!
| Quote: |
file1 of length 500
file2 of length 80
|
| Quote: |
JOINKEYS FILE=F1,FIELDS=(2417,3,A)
JOINKEYS FILE=F2,FIELDS=(0043,3,A)
REFORMAT FIELDS=(F1:1,2550,F2:1,200) |
Not related to your issue, but the length mentioned does not seem to be consistent with the position/lengths in your JOINKEYS/REFORMAT. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| Prateeksichem1 wrote: |
| Comp-3 field in file2 (length S9(13V99)) |
What "length" stands for???
What does this syntax mean - S9(13V99) - ???????
All these stuff have nothing to do with your following SORT statements.
Please provide a clear, correct, and full explanation of your problem. We are here not to guess your hidden thoughts. |
|
| Back to top |
|
 |
Prateeksichem1
New User
Joined: 11 Jul 2018 Posts: 2 Location: US
|
|
|
|
Sorry couldn't get you the full details... hope this makes little sense.
Length of both the fields are 8 bytes (S9(13V99) Comp-3).
| Code: |
hex values:
File 2 (-5000.00)
----+----1-------------
*****************
Y Y........................
4E4E00000000
08080000500D
File 1 (-6201.50)
-1----+--------
....................
00000210
0000605D
|
in Output file I want all the values from file 1 - which is less than -5000.00 (file 2).
Just comparing 2 negative Comp-3 values using Sort and write in the output with lesser value but getting all the values (not only the lesser one). |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Whats your input, output RECFM,LRECL etc? Can you show some values that came into the output that you were not expecting (in hex). Use code tags (button) while posting data/code to preserve alignment. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| Prateeksichem1 wrote: |
Sorry couldn't get you the full details... hope this makes little sense.
Length of both the fields are 8 bytes (S9(13V99) Comp-3) |
Please, read about the syntax of COBOL first of all.
So far, period. |
|
| Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
| Quote: |
| (S9(13V99) Comp-3). |
This is not COBOL syntax. S9(13)V99 COMP-3 would be valid COBOL syntax for an 8-byte packed decimal variable with 2 decimal digits. If you are going to refer (repeatedly) to a language, you should at least make sure you've got the syntax correct.
| Quote: |
JOINKEYS FILE=F1,FIELDS=(2417,3,A)
JOINKEYS FILE=F2,FIELDS=(0043,3,A)
REFORMAT FIELDS=(F1:1,2550,F2:1,200)
INCLUDE COND=(209,08,PD,LT,2555,08,PD)
SORT FIELDS=COPY
OUTREC FIELDS=(1:1,2550) |
Where, exactly, in here do you tell Sort to exclude records from F1 with a value more than -5000 (or include those records with a value less than -5000)? If you do not specify the restriction to Sort, are you expecting the product to read your mind? |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Robert, 5000 is sample data only. He wants the 'less than' condition on any amount.
Prateek, please provide meaningful lengths/position of keys and data and a meaningful sample data for Sort card.
. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10902 Location: italy
|
|
|
|
| Quote: |
| I need to compare Comp-3 field in file2 (length S9(13V99)) with the Comp-3 field in file1(length S9(13V99)). |
IMU ( In My Understanding ) the 5000 is just an example ... |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Is this field ever positive with values in the other field > -5000 i.e. nearer 0? |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| Prateeksichem1 wrote: |
Hi,
I have 2 files
file1 of length 500
file2 of length 80
based on the matched keys, I need to compare Comp-3 field in file2 (length S9(13V99)) with the Comp-3 field in file1(length S9(13V99)).
file 2 field = -5000
file 1 field needs to be less than -5000 (like -6000) b
when I'm running sort with below code, it gives me all the negative values not only lesser ones, need your help to achieve this. Thanks
JOINKEYS FILE=F1,FIELDS=(2417,3,A)
JOINKEYS FILE=F2,FIELDS=(0043,3,A)
REFORMAT FIELDS=(F1:1,2550,F2:1,200)
INCLUDE COND=(209,08,PD,LT,2555,08,PD)
SORT FIELDS=COPY
OUTREC FIELDS=(1:1,2550)
Thanks
Prateek |
Classical recommendations for a newbie:
1) use code tags in your posts
2) use correct syntax notation for any language
3) present examples of your input/output data
4) verify for yourself, and prove to the readers that you are using CORRECTLY calculated field offsets, sizes, etc (so far there is nothing)
5) use short test datasets specifically truncated for this test only! 1-10 records is enough to debug the code
6) print and demonstrate to the public ALL INVOLVED FIELDS! Not only ditty about "wrong final results"
There are hundreds of other obvious advices, but those above should be enough to start with. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|