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

Question on DATASORT and EDIT


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

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Oct 19, 2012 6:49 pm
Reply with quote

Hi,

Input is like below. FB, 29 bytes, the fields are Amount (25 bytes), a filler (1 byte) and Key (3 bytes).
Code:
----+----1----+----2----+----
*****************************
                   AMOUNT KEY
                     0.00 111
               -11,159.25 122
               -10,999.76 123
                43,903.06 145
                     0.00 201
****************************


The format is
Code:
WS-C            PIC --,---,---,---,---,--9.9(2). 
WS-FILL         PIC X.
WS-NOS          PIX XXX.


I want to multiple AMOUNT field by -1 for all the records except the header.

Output should be like below.
Code:
----+----1----+----2----+----
*****************************
                   AMOUNT KEY
                     0.00 111
                11,159.25 122
                10,999.76 123
               -43,903.06 145
                     0.00 201
****************************


Here is ICETOOL step used.

Code:
//TOOLIN  DD *                                                       
 DATASORT FROM(IN) TO(OUT) HEADER USING(CTL1)                       
/*                                                                   
//CTL1CNTL DD *                                                     
 SORT FIELDS=(27,3,CH,A)                                             
 INREC OVERLAY=(1:1,25,SFF,MUL,-1,TO=ZD,LENGTH=25)                   
 OUTFIL FNAMES=OUT,                                                 
 OVERLAY=(1:1,25,ZD,EDIT=(SI,III,III,III,III,IIT.TT),SIGNS=(,-))     
/*   


But I got the below output.

Code:
----+----1----+----2----+----
*****************************
                 1,464.53 KEY
                    -0.00 111
                11,159.25 122
                10,999.76 123
               -43,903.06 145
                    -0.00 201
****************************


Please advise, 1), Why header is overlaid with some value (1,464.53)
2) For 0.00 value in amount field, the sign is attached as -0.00. But it should be 0.00

I'm with
Code:
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 19, 2012 6:58 pm
Reply with quote

"Header and trailer records will only be affected by the SKIPREC option and
OUTFIL statements
. SKIPREC=n will remove the first n indd records, so the first
header record will be the n+1 indd record. OUTFIL statements will process the
header and trailer records in the normal way."

You can SUB from +0, quicker than MUL :-)

You can do all on the same statement, probably.

Have you checked EDIT for any special possible treatment of zero values?

If you need a "quick and dirty" to get it going (it is Friday) you could FINDREP to change -0.00 to blank0.00
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Oct 19, 2012 7:18 pm
Reply with quote

Hi Bill,

Thank you for the reply. icon_smile.gif

Bill Woodger wrote:
You can SUB from +0, quicker than MUL :-)

Yes, the below worked out and no more -0.00 in the output. But still, wondering why MUL by -1 won't do that with EDIT.

Code:
 INREC OVERLAY=(+0,SUB,1,25,SFF,TO=ZD,LENGTH=25)                   
 OUTFIL FNAMES=OUT,                                                 
 OVERLAY=(1:1,25,ZD,EDIT=(SI,III,III,III,III,IIT.TT),SIGNS=(,-)) 

Bill Woodger wrote:
"Header and trailer records will only be affected by the SKIPREC option and
OUTFIL statements
. SKIPREC=n will remove the first n indd records, so the first
header record will be the n+1 indd record. OUTFIL statements will process the
header and trailer records in the normal way."

I think DATASORT of ICETOOL can be used to sort the records between header(s) and trailer(s). Not sure, what I'm missing here.

Bill Woodger wrote:
Have you checked EDIT for any special possible treatment of zero values?

Checked, but I don't see anything for this case.

Please advise.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 19, 2012 7:22 pm
Reply with quote

INREC will not get the header/trailer records, but OUTFIL will.

So you need to do everything before OUTFIL.

I'll leave the rest to Kolusu :-)
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 19, 2012 8:03 pm
Reply with quote

Thinking about it, by algebra, a minus times a plus is a minus. Says so in the 370-etc POP as well.

I think I read you can't get a "negative zero" in Cobol any more. Since I never MULTIPLY BY -1 in Cobol, maybe why I'd never seen so many "negative zeros" (only ever saw one, from another person's program) :-) There are some references in the DFSORT manual.

Do you need to SORT the file? With an IFTHEN to exclude the header, you can just do the adjustment in an ordinary Sort step, without ICETOOL.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri Oct 19, 2012 8:34 pm
Reply with quote

Gnanas N,
Are you saying you got the desired output just by using +0,SUB,1,25,SFF,TO=ZD,LENGTH=25 in stead of 1,25,SFF,MUL,-1,TO=ZD,LENGTH=25 OR did you make any other changes?

Quote:
Please advise, 1), Why header is overlaid with some value (1,464.53)

This is not "some value". Type AMOUNT and do HEX ON.

Regardless, why not qualify your header or detail records and do multiplication/subtraction only for detail records?

Thanks,
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Oct 19, 2012 9:05 pm
Reply with quote

Hi Bill,

Bill Woodger wrote:
Do you need to SORT the file?

No, there is no need to SORT the file. Since I use DATASORT for excluding the header, SORT operator should be used in the processing.

Bill Woodger wrote:
With an IFTHEN to exclude the header, you can just do the adjustment in an ordinary Sort step, without ICETOOL.

Yes. Again, I need to add the header values using OUTFIL HEADER statement.

Thank you.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Oct 19, 2012 9:09 pm
Reply with quote

Hi sqlcode1,

sqlcode1 wrote:
Gnanas N,
Are you saying you got the desired output just by using +0,SUB,1,25,SFF,TO=ZD,LENGTH=25 in stead of 1,25,SFF,MUL,-1,TO=ZD,LENGTH=25 OR did you make any other changes?

Yes. +0,SUB,1,25,SFF,TO=ZD,LENGTH=25 worked out; no other changes.

Thank you.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Oct 19, 2012 10:08 pm
Reply with quote

Gnanas N wrote:

Please advise, 1), Why header is overlaid with some value (1,464.53)


Gnanas N,

Datasort works on the INPUT phase and you have 2 edit mask on both INREC and OUTFIL. Datasort does NOT control editing on the OUTFIL. And the numbers you see on your first record is because ZD format edit format will ignore the zone and hence that number. As SQLCODE mentioned set your hex on and see the contents. ex:

Code:

AMOUNT
CDDEDE
146453


Now the question is why do you need to convert the number to ZD ? You are NOT summing or doing any thing with that conversion.

You just need the following control cards
Code:


//CTL1CNTL DD *                                             
  SORT FIELDS=(27,3,CH,A)                                   
  INREC OVERLAY=(+0,SUB,1,25,SFF,                           
                 EDIT=(SI,III,III,III,III,IIT.TT),SIGNS=(,-))
//*


Gnanas N wrote:

2) For 0.00 value in amount field, the sign is attached as -0.00. But it should be 0.00


As bill mentioned Subtracting from zero is easier to handle negative zero values. if you insist on multiplication with -1 then you can use the following control cards.
Code:

//CTL1CNTL DD *                                             
  SORT FIELDS=(27,3,CH,A)                                   
  INREC OVERLAY=(1,25,SFF,MUL,-1,                           
                 EDIT=(SI,III,III,III,III,IIT.TT),SIGNS=(,-))

  OUTFIL FINDREP=(ENDPOS=25,INOUT=(C'-0.00',C' 0.00'))       
//*
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Oct 19, 2012 10:46 pm
Reply with quote

Hi Kolusu,

Quote:
Now the question is why do you need to convert the number to ZD ? You are NOT summing or doing any thing with that conversion.


I thought that MUL can not be done on SFF field so converting it into ZD. icon_sad.gif I need to check the manual.

Quote:
You just need the following control cards

Code:
//CTL1CNTL DD *                                             
  SORT FIELDS=(27,3,CH,A)                                   
  INREC OVERLAY=(+0,SUB,1,25,SFF,                           
                 EDIT=(SI,III,III,III,III,IIT.TT),SIGNS=(,-))
//*

This works perfectly.

Thank you.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 19, 2012 11:11 pm
Reply with quote

Quote:
I need to check the manual.

that should have been done before starting this thread.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Oct 19, 2012 11:45 pm
Reply with quote

Yes, Dick. icon_redface.gif
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 Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Question for file manager IBM Tools 7
No new posts Need help to resolve a hard edit COBOL Programming 8
This topic is locked: you cannot edit posts or make replies. Need help to resolve a hard edit COBOL Programming 4
Search our Forums:

Back to Top