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

How to evaluate the value in Comp-3


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

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Tue Oct 23, 2007 3:47 pm
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: 1436
Location: Bangalore,India

PostPosted: Tue Oct 23, 2007 4:08 pm
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: 123
Location: Hyderabad

PostPosted: Tue Oct 23, 2007 4:29 pm
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: 123
Location: Hyderabad

PostPosted: Tue Oct 23, 2007 4:34 pm
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: 1287
Location: Chennai, India

PostPosted: Tue Oct 23, 2007 5:28 pm
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: 1287
Location: Chennai, India

PostPosted: Tue Oct 23, 2007 5:57 pm
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 Developer


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

PostPosted: Tue Oct 23, 2007 10:40 pm
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: 123
Location: Hyderabad

PostPosted: Wed Oct 24, 2007 9:01 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top