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

Comparing Comp-3 fields with greater than equal to condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Prateeksichem1

New User


Joined: 11 Jul 2018
Posts: 2
Location: US

PostPosted: Fri Jul 13, 2018 8:45 am
Reply with quote

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
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jul 13, 2018 11:50 am
Reply with quote

Can you post a snippet of input data with hex on. Please use the code tags.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jul 13, 2018 6:13 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2120
Location: USA

PostPosted: Fri Jul 13, 2018 7:19 pm
Reply with quote

Prateeksichem1 wrote:
Comp-3 field in file2 (length S9(13V99))

What "length" stands for??? icon_rolleyes.gif
What does this syntax mean - S9(13V99) - ??????? icon_exclaim.gif

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
View user's profile Send private message
Prateeksichem1

New User


Joined: 11 Jul 2018
Posts: 2
Location: US

PostPosted: Fri Jul 13, 2018 7:57 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jul 13, 2018 8:27 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2120
Location: USA

PostPosted: Fri Jul 13, 2018 9:28 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 13, 2018 9:50 pm
Reply with quote

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
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Fri Jul 13, 2018 10:10 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10879
Location: italy

PostPosted: Sat Jul 14, 2018 1:29 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Sat Jul 14, 2018 3:12 am
Reply with quote

Code:
2555,08,PD

Is this field ever positive with values in the other field > -5000 i.e. nearer 0?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2120
Location: USA

PostPosted: Sat Jul 14, 2018 7:55 pm
Reply with quote

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
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Add condition to a FINDREP SORT card DFSORT/ICETOOL 4
No new posts Pull data using date difference betwe... DB2 6
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
Search our Forums:

Back to Top