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

[Solved]SUM based on two conditions using SYNCSORT


IBM Mainframe Forums -> SYNCSORT
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Fri Jul 30, 2021 10:42 am
Reply with quote

Hi..

My Input data is

AAAAA 11111 T 3
AAAAA 11111 T 1
AAAAA 11111 T 3
AAAAA 11111 L 3
AAAAA 11111 T 2
BBBBB BBBBB L 4
BBBBB BBBBB L 3
BBBBB BBBBB T 1
BBBBB BBBBB T 3
CCCCC CCCCC T 4
CCCCC CCCCC T 2

Now If first 5 bytes is AAAAA and from the 6th position onwards next 5 bytes is 11111 then i need to sum the data based on T or L which is there in the 13th Position.

I tried the below cards using SYNCSORT..

Code:

INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
  IFTHEN=(WHEN=(1,5,CH,EQ,C'AAAAA',AND,7,5,CH,EQ,C'11111'),
                 OVERLAY=(81:8C'0'))
 SORT FIELDS=(14,1,CH,A,81,8,ZD,A)
OPTION ZDPRINT
SUM FIELDS=(18,1,ZD)
OUTREC BUILD=(1,80)


But it is not taking the second condition - AND,7,5,CH,EQ,C'11111' ( Throwing an error)
How to code multiple conditions in my case....
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 606
Location: Bamberg, Germany

PostPosted: Fri Jul 30, 2021 10:58 am
Reply with quote

sri_mf wrote:
Hi..

My Input data is

AAAAA 11111 T 3
AAAAA 11111 T 1
AAAAA 11111 T 3
AAAAA 11111 L 3
AAAAA 11111 T 2
BBBBB BBBBB L 4
BBBBB BBBBB L 3
BBBBB BBBBB T 1
BBBBB BBBBB T 3
CCCCC CCCCC T 4
CCCCC CCCCC T 2

Now If first 5 bytes is AAAAA and from the 6th position onwards next 5 bytes is 11111 then i need to sum the data based on T or L which is there in the 13th Position.

I tried the below cards using SYNCSORT..

Code:

INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
  IFTHEN=(WHEN=(1,5,CH,EQ,C'AAAAA',AND,7,5,CH,EQ,C'11111'),
                 OVERLAY=(81:8C'0'))
 SORT FIELDS=(14,1,CH,A,81,8,ZD,A)
OPTION ZDPRINT
SUM FIELDS=(18,1,ZD)
OUTREC BUILD=(1,80)


But it is not taking the second condition - AND,7,5,CH,EQ,C'11111' ( Throwing an error)
How to code multiple conditions in my case....

Nothing is "thrown" in z/OS.. icon_evil.gif

Use:
Code:
SUM FIELDS=(15,1,ZD)

And also check Position of the first SORT FIELDS=(..)
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Fri Jul 30, 2021 11:35 am
Reply with quote

Code:
AAAAA 11111  T   3
AAAAA 11111  T   1
AAAAA 11111  T   3
AAAAA 11111  L   3
AAAAA 11111  T   2
BBBBB BBBBB  L   4
BBBBB BBBBB  L   3
BBBBB BBBBB  T   1
BBBBB BBBBB  T   3
CCCCC CCCCC  T   4
CCCCC CCCCC  T   2


after 11111 there are 2 spaces and after T or L there are 3 spaces.... T or L are starting at 14th Position and the numbers 3,1,3 etc are starting at 18th position
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1189

PostPosted: Fri Jul 30, 2021 8:14 pm
Reply with quote

Needs to be automatically re-routed to the Beginners Forum.

It’s all getting extremely annoying.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 329
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Fri Jul 30, 2021 8:47 pm
Reply with quote

And the SYNCSORT error message is?

Or, it just doesn't produce expected results?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2771
Location: NYC,USA

PostPosted: Sat Jul 31, 2021 3:10 am
Reply with quote

Code:
//SORTIN   DD  *                                                       
AAAAA 11111 T 3                                                         
AAAAA 11111 T 1                                                         
AAAAA 11111 T 3                                                         
AAAAA 11111 L 3                                                         
AAAAA 11111 T 2                                                         
BBBBB BBBBB L 4                                                         
BBBBB BBBBB L 3                                                         
BBBBB BBBBB T 1                                                         
BBBBB BBBBB T 3                                                         
CCCCC CCCCC T 4                                                         
CCCCC CCCCC T 2                                                         
//SORTOUT   DD SYSOUT=*                                                 
//SYSOUT   DD  SYSOUT=*                                                 
//SYSIN     DD *                                                       
//SYSIN     DD *                                                   
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                 
       IFTHEN=(WHEN=(1,11,CH,EQ,C'AAAAA 11111'),OVERLAY=(81:8C'0'))
 SORT FIELDS=(81,8,ZD,A)                                           
 OUTFIL REMOVECC,NODETAIL,SECTIONS=(81,8,                           
        TRAILER3=(1,14,X,TOT=(15,1,ZD,EDIT=(IT)))),BUILD=(1,80)         

Output:
Code:
********************************* TOP OF DATA **********************************
AAAAA 11111 T  12                                                               
BBBBB BBBBB L   4                                                               
BBBBB BBBBB L   3                                                               
BBBBB BBBBB T   1                                                               
BBBBB BBBBB T   3                                                               
CCCCC CCCCC T   4                                                               
CCCCC CCCCC T   2                                                               
******************************** BOTTOM OF DATA ********************************
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Sat Jul 31, 2021 9:44 am
Reply with quote

Thank you very much Rohit.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2771
Location: NYC,USA

PostPosted: Sat Jul 31, 2021 4:37 pm
Reply with quote

Welcome Sri.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Arithmetic division using Syncsort SYNCSORT 6
No new posts SORT HELP - SORT A COLUMN and GROUP B... DFSORT/ICETOOL 9
No new posts using based or defined variables PL/I & Assembler 2
No new posts SORT - Multiple Conditions DFSORT/ICETOOL 4
No new posts SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13
Search our Forums:

Back to Top