Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to evaluate the value in Comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 113
Location: India

PostPosted: Tue Oct 23, 2007 3:47 pm    Post subject: How to evaluate the value in Comp-3
Reply with quote

Hi,

Here is my reqirement. I had 3 fields in my input file. Say name, city and amount.
The amount field is S9(6)V99 COMP-3.
When the amount field is -ive and the value is > 1500 i should populate name, city and -ive symbol to my output.
When the amount field is +ive or blank and the value is >1500 i should populate name, city and +ive symbol to my output.

If the amount field has value -1200. I should not consider this record.
If the amount field has value -1800. I should populate '-' to my output.
If the amount filed has value 1200. I should ignore this record.
If the amount field has value 2000. I should populate '+' to my output.

How can i do this as this is S9(6)V99 COMP-3.
Back to top
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Tue Oct 23, 2007 4:08 pm    Post subject:
Reply with quote

Bhaskar,

Quote:
When the amount field is -ive and the value is > 1500 i should populate name, city and -ive symbol to my output.
When the amount field is +ive or blank and the value is >1500 i should populate name, city and +ive symbol to my output.

Explain your above conditions properly. Its confusing.

Also we expcet some sample data (ip and op) with file attribs and file layout.
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 113
Location: India

PostPosted: Tue Oct 23, 2007 4:29 pm    Post subject: Reply to: How to evaluate the value in Comp-3
Reply with quote

Hi,

This is my input file format.
WS-NAME PIC X(10).
WS-CITY PIC X(10).
WS-AMT PIC S9(6)V99 COMP-3.

The output file format is
WS-NAME PIC X(10).
WS-CITY PIC X(10).
WS-SIGN PIC X(1).

The input data is as follows.
BHASKAR BOMBAY -1200
SUNIL DELHI -1800
KUMAR CALCUTTA 1200
SUNNY CHENNAI 2000

My output should be as follows.
SUNIL DELHI -
SUNNY CHENNAI +

As sunil and sunny value is greater than 1500 excluding the sign they were written to output with corresponding symbol.
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 113
Location: India

PostPosted: Tue Oct 23, 2007 4:34 pm    Post subject: Reply to: How to evaluate the value in Comp-3
Reply with quote

Hi,

If the amount is less than -1500 i should populate '-' and
if the amount is greater than 1500 i should populate '+'.

this is the reqirement.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Tue Oct 23, 2007 5:28 pm    Post subject: Reply to: How to evaluate the value in Comp-3
Reply with quote

Check this for your requirement

Code:
//S2    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SORTIN DD *                                                     
BHASKAR BOMBAY   -1200                                           
SUNIL   DELHI    -1800                                           
KUMAR   CALCUTTA  1200                                           
SUNNY   CHENNAI   2000                                           
/*                                                               
//SORTOUT DD SYSOUT=*                                             
//OUT1    DD DSN=file name,DISP=(,CATLG,)                   
//SYSIN    DD    *                                               
  INREC OVERLAY=(18:18,5,SFF,TO=ZD,LENGTH=5)                     
  SORT FIELDS=COPY                                               
  INCLUDE COND=(19,4,ZD,GT,1500)                                 
  OUTREC OVERLAY=(18:18,5,ZD,EDIT=(STTTT),SIGNS=(+,-))           
  OUTFIL FNAMES=OUT1,OUTREC=(1:1,18)                             
/*   



output:

Code:
SUNIL   DELHI    -           
SUNNY   CHENNAI  + 


I have assumed that fields start at the same position in all the records.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Tue Oct 23, 2007 5:57 pm    Post subject: Reply to: How to evaluate the value in Comp-3
Reply with quote

Bhaskar,

Had a look at your previous post and noted that the first 2 fields are of 10 bytes.

Code:
WS-NAME PIC X(10).
WS-CITY PIC X(10).


Have made changes accordingly in the sort card. Please find below the updated one.

Code:
//S2    EXEC  PGM=ICEMAN                                               
//SYSOUT    DD  SYSOUT=*                                               
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
//SORTIN DD *                                                         
BHASKAR   BOMBAY    -1200                                             
SUNIL     DELHI     -1800                                             
KUMAR     CALCUTTA   1200                                             
SUNNY     CHENNAI    2000                                             
/*                                                                     
//SORTOUT DD SYSOUT=*                                                 
//OUT1    DD DSN=file name  ,DISP=(,CATLG,)                         
//SYSIN    DD    *                                                     
  INREC OVERLAY=(21:21,5,SFF,TO=ZD,LENGTH=5)                           
  SORT FIELDS=COPY                                                     
  INCLUDE COND=(22,4,ZD,GT,1500)                                       
  OUTREC OVERLAY=(21:21,5,ZD,EDIT=(STTTT),SIGNS=(+,-))                 
  OUTFIL FNAMES=OUT1,OUTREC=(1:1,21)                                   
/*                                                                     


output:

Code:
 SUNIL     DELHI     -         
 SUNNY     CHENNAI   +         
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Oct 23, 2007 10:40 pm    Post subject:
Reply with quote

Quote:
The amount field is S9(6)V99 COMP-3.


This means the amount is a 5-byte PD field representing a value like sdddddd.dd (e.g. +1600.00 or -2000.00).
Quote:
If the amount is less than -1500 i should populate '-' and
if the amount is greater than 1500 i should populate '+'.


I take that to mean if the amount is < -1500.00, you want '-' and if the amount is > +1500.00, you want '+'.

Note that the decimal point is not stored internally for the PD value, so +1600.00 would be X'000160000C' and -2000.00 would be X'000200000D'. Thus we need to use -150000 and +150000 as the constants.


Given all that, here's a DFSORT job to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INCLUDE COND=(21,5,PD,GT,150000,OR,21,5,PD,LT,-150000)
  INREC IFTHEN=(WHEN=(21,5,PD,GT,+0),
    BUILD=(1,20,C'+')),
   IFTHEN=(WHEN=NONE,BUILD=(1,20,C'-'))
/*
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 113
Location: India

PostPosted: Wed Oct 24, 2007 9:01 am    Post subject: Reply to: How to evaluate the value in Comp-3
Reply with quote

Hi Frank Yaeger,

Thank you so much.
Thanks for providing me the solution and also clear explanation.
Many more thanks for providing clear explanation.
Thank You So Much.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us