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

Stuck in handling overflow !


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

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Thu Jul 29, 2010 4:09 pm
Reply with quote

I am trying to sum up in the case of overflow also. I referred manual but not getting exact usgae of INREC statement with X'00 etc. to handle overflow..! Please assist me in this to handle overflow....!

//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD *
ONE 12
TWO 23
ONE 28
ONE 30
TWO 78
ONE 10
//SORTOUT DD DSN=xxx.DFSORT.OUTPUT,DISP=SHR
//SYSIN DD *
INREC FIELDS=(1,3,4:X'00')
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,2,ZD)
/*
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Thu Jul 29, 2010 4:25 pm
Reply with quote

Code:

//SYSIN DD *
  INREC FIELDS=(1,4,c'00',5,2)
  SORT FIELDS=(1,3,CH,A)
  SUM FIELDS=(5,4,ZD)
/*
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Thu Jul 29, 2010 5:15 pm
Reply with quote

Thanks joss..
would you please explain how does it work ?
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Thu Jul 29, 2010 5:40 pm
Reply with quote

Thanks joss... once again i have understood it properly !

But i didnt get the meaning of C and X !

When should i go for X and when for C ?
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Thu Jul 29, 2010 5:46 pm
Reply with quote

only Z stand for binary zero i.e. hex 00

only X would stand for a space : hex 40

C'<text>' stand for string
X'nn' stand for hex nn (in your case x'00' stands for low values)

if you need to understand it better ,
remove the SUM line and run the code ... u ll understand the editing

go through DFSORT: Getting Started
everything is given in detail hardly takes 2 day to finish off
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Thu Jul 29, 2010 6:32 pm
Reply with quote

since you were using ZD i padded 0 to the left of you number to change the length of you field.

if it was binary (pic comp) you could have used X'00' or Z. it would have looked like

Code:

//SYSIN DD *
  INREC FIELDS=(1,4,2Z,5,2)
  SORT FIELDS=(1,3,CH,A)
  SUM FIELDS=(5,4,BI)
/*


OR

Code:

//SYSIN DD *
  INREC FIELDS=(1,4,x'0000',5,2)
  SORT FIELDS=(1,3,CH,A)
  SUM FIELDS=(5,4,BI)


/*
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: Thu Jul 29, 2010 10:29 pm
Reply with quote

Here's a better way to do this with DFSORT - better because you don't have to know which kind of zeros to pad with - DFSORT figures it out for you:

For ZD value in 5-6:

Code:

   INREC BUILD=(1,4,5,2,ZD,TO=ZD,LENGTH=4)   
   SORT FIELDS=(1,3,CH,A)                     
   SUM FIELDS=(5,4,ZD)                       


For BI value in 5-6:

Code:

   INREC BUILD=(1,4,5,2,ZD,TO=BI,LENGTH=4)   
   SORT FIELDS=(1,3,CH,A)                     
   SUM FIELDS=(5,4,BI)                       
Back to top
View user's profile Send private message
Gabriel Araujo Alves

New User


Joined: 20 Jul 2010
Posts: 38
Location: Brazil

PostPosted: Thu Jul 29, 2010 11:34 pm
Reply with quote

Why when i put this, the second zero doesn't display?

Code:
INREC FIELDS=(1,3,05,02,ZD,M11,LENGTH=04)



look at sysout

Code:
ONE 072
TWO 098
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: Thu Jul 29, 2010 11:52 pm
Reply with quote

M11 adjusts the pattern according to the implicit length of the input field (2 in this case). Specifying LENGTH extends the pattern with blanks on the left. EDIT=(TTTT) would give leading zeros if that's what you want.

I assume you have a SORT and SUM statement but I don't know what they look like. Please show ALL of the control statements you're using. Once I know the statements you're using, I'll be able to explain why you got what you got.
Back to top
View user's profile Send private message
Gabriel Araujo Alves

New User


Joined: 20 Jul 2010
Posts: 38
Location: Brazil

PostPosted: Fri Jul 30, 2010 1:26 am
Reply with quote

Look like i do...

Code:
//STEP1 EXEC PGM=SORT                         
//SYSOUT DD SYSOUT=*                           
//SYSPRINT DD SYSOUT=*                         
//SORTIN DD *                                 
ONE 12                                         
TWO 23                                         
ONE 28                                         
ONE 30                                         
TWO 78                                         
ONE 10                                         
/*                                             
//SORTOUT DD SYSOUT=*                         
//SYSIN DD *                                   
 INREC FIELDS=(1,3,05,02,ZD,M11,LENGTH=04)     
 SORT FIELDS=(1,3,CH,A)                       
 SUM FIELDS=(5,2,ZD)                           
/*                                             
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: Fri Jul 30, 2010 1:54 am
Reply with quote

Your INREC and SORT statements give this result:

Code:

ONE  12     
ONE  10     
ONE  28     
ONE  30     
TWO  78     
TWO  23     


p,2,ZD,M11 gives TT because the input length is 2. LENGTH=4 extends that with 2 blanks on the left to give bbTT.

Your SUM statement is summing on 5,2,ZD instead of 6,2,ZD so you're actually summing ' 1' instead of '12', etc. This gives 07 for ONE and 09 for TWO in positions 5-6, and the 7th position is taken from the first record with each key. So you end up with:

Code:

ONE 072
TWO 098


Not sure what you were trying to do but whatever it is, you didn't do it right.
Back to top
View user's profile Send private message
Gabriel Araujo Alves

New User


Joined: 20 Jul 2010
Posts: 38
Location: Brazil

PostPosted: Fri Jul 30, 2010 4:29 am
Reply with quote

Really, i forget that inrec reformatted the fields.
thanks...
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 Newbie Stuck on "Duplicate Datas... TSO/ISPF 5
No new posts NDM getting stuck - mainframe/JCL All Other Mainframe Topics 13
No new posts Assembler class assignment: stuck on ... PL/I & Assembler 12
No new posts Assembler: Set Program Mask for decim... PL/I & Assembler 4
No new posts File Handling COBOL Programming 9
Search our Forums:

Back to Top