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
 

 

sorting with separate sign

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

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Thu Sep 03, 2009 6:17 pm    Post subject: sorting with separate sign
Reply with quote

Hai

this is my dataset

AB+25
SA-30
AB-20
SA+55
AB-10

The first two positions are a code. The next three positions are a Cobol numeric field, where the sign is leading as a separate character

The outcome has to be

AB-05
SA+25

AB-05 because +25 + -20 + -10 = -05
SA+25 because -30 + +55 = +25

How do I do this?
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: Thu Sep 03, 2009 10:03 pm    Post subject:
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
AB+25
SA-30
AB-20
SA+55
AB-10
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(1,2,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,2,
      TRAILER3=(1,2,TOT=(3,3,FS,EDIT=(STT),SIGNS=(+,-))))
/*
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Thu Sep 03, 2009 10:55 pm    Post subject: Reply to: sorting with separate sign
Reply with quote

Thank you Frank
I've been looking iin the manual, but don't understand it all

What do the SECTIONS and TRAILER keyword do?
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: Thu Sep 03, 2009 11:16 pm    Post subject:
Reply with quote

SECTIONS says to treat each change in value for positions 1-3 as a group of records and TRAILER3 creates a trailer record for each such group.
Since NODETAIL is specified, only the trailer3 records will be written, not the data records.

So the AB records would be a group and their trailer record would be written, and the SA records would be another group and their trailer record would be written. 1,2 in TRAILER3 puts positions 1-2 from the last record of the group in the trailer record. TOT puts the total for the group in the trailer record.
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Thu Sep 03, 2009 11:36 pm    Post subject:
Reply with quote

ok Frank
if 1,2 in TRAILER3 puts positions 1-2 from the last record of the group in the trailer record, what does "SECTIONS=(1,2," do then? Especially what does the 1,2, in SECTIONS do?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Sep 04, 2009 12:06 am    Post subject: Reply to: sorting with separate sign
Reply with quote

revdpoel,

Check this for a detailed explanation of "Creating Reports with OUTFIL"

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG30/2.6.8?

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
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: Fri Sep 04, 2009 12:41 am    Post subject:
Reply with quote

SECTIONS=(1,2 identifies the value that defines a section. The first "section" is the AB records and the second "section" is the SA records. When the value in positions 1-2 changes from AB to SA, we start a new section.
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Fri Sep 04, 2009 1:35 am    Post subject:
Reply with quote

Frank, i wanted to give the example in an easier way for myself to understand it more clearly

But the real dataset is FB 50, with a header (first position 1), data (first position 2) and trailer (first position 3)

120090903
2AB+25
2SA-30
2AB-20
2SA+55
2AB-10
30007

The outcome has to be

120090903
2AB-05
2SA+25
30004

This means that the number of records in the trailer has to change after the sort from 7 to 4
Does this make things more difficult or DFSort?
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: Fri Sep 04, 2009 1:58 am    Post subject:
Reply with quote

I'd take a different approach for that and use these DFSORT control statements:

Code:

  OMIT COND=(1,1,CH,EQ,C'3')                         
  INREC OVERLAY=(51:4,3,FS,TO=ZD,LENGTH=2)           
  SORT FIELDS=(1,3,CH,A)                             
  SUM FIELDS=(51,2,ZD)                               
  OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),             
    OVERLAY=(4:51,2,ZD,EDIT=(STT),SIGNS=(+,-)))     
  OUTFIL REMOVECC,BUILD=(1,50),                     
    TRAILER1=('3',COUNT+1=(M11,LENGTH=4))           
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Fri Sep 04, 2009 4:47 pm    Post subject: Reply to: sorting with separate sign
Reply with quote

Frank, please read the attachment
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: Sat Sep 05, 2009 6:18 am    Post subject:
Reply with quote

Huh? Your control statements seem to be set up to sum these two fields:

0000034+000000000004908460
0000034-000000000003908455

But you say you want your output to be:

0000068+000000000004908460

That would only be a sum of the first field, not the second one. So I don't really understand what you want or what you're doing.

The + and - field was originally 3 bytes. Now it's 19 bytes, so you convert it to an 18-byte ZD value, but then you use an EDIT mask of EDIT=(STT) which is only three bytes, not 19 bytes so you're truncating the result.

Since I don't understand your new requirement, I can't really help you fix your control statements.
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Sat Sep 05, 2009 3:10 pm    Post subject:
Reply with quote

sorry Frank
I turned things around

'Output expected' and 'output we get' should be turned around

Output we get
020090731200907FJQ00001
11167000300030EUR69KS010011D0000000000010000000000000000001999990000068+000000000004908460
90000000003

Output expected
020090731200907FJQ00001
11167000300030EUR69KS010011D0000000000010000000000000000001999990000068+000000000001000005
90000000003

probably the EDIT mask has to be EDIT=(STTTTTTTTTTTTTTTTTT) ?
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: Sun Sep 06, 2009 10:49 pm    Post subject:
Reply with quote

Quote:
probably the EDIT mask has to be EDIT=(STTTTTTTTTTTTTTTTTT) ?


Yes.
Back to top
View user's profile Send private message
revdpoel

New User


Joined: 01 Nov 2006
Posts: 56

PostPosted: Mon Sep 07, 2009 1:56 pm    Post subject:
Reply with quote

Frank it works
thnx
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 Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts Stripping and Sorting of VB file G SRINIVASA RAO SYNCSORT 5 Wed Sep 14, 2016 1:34 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts VB file sorting V S Amarendra Reddy DFSORT/ICETOOL 2 Fri Feb 26, 2016 8:29 pm
No new posts How to display data in separate lines... salilnigam1970 DFSORT/ICETOOL 2 Tue Jan 26, 2016 9:49 pm


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