MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pick Records matching the criteria using SORT
Goto page Previous  1, 2
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 43
Topics: 9

PostPosted: Fri Jul 21, 2017 9:45 am    Post subject: Reply with quote

How to get this Numeric values left justified with Sign for example -103.70
Code:

Madras    19541112   25      42041117   50   42041119   75
Bangalore 19541112   15      42041117   40   42041119   35
Cochin    19541112   35      42041117   30   42041119   55
Delhi     19541112  -130.70  42041117   30   42041119   55   
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Jul 21, 2017 12:04 pm    Post subject: Reply with quote

Suchay,

You need to be clear on what you want. Make sure you describe ALL of your requirements at once instead of adding one requirement at a time. You need to learn to use the code tags properly. you need to use "/" aka backward slash for the ending code. You have been using forward slash "/" which does not work. Here is a link to the topic that shows how to use the code tags.

https://www.mvsforums.com/helpboards/viewtopic.php?p=19031#19031

Now coming to your control cards. Why did you have 134, 18 when the city name is ONLY 14 bytes? Did you add another field in the WHEN=GROUP ? Or is that a typo? or you just wanted 4 spaces after the city name as your Amount field starts at 152? Why are using UFF format when you wanted signs? You need to use SFF format which handles the SIGN also.

Either way considering these are all typos, here are optimized control cards which will give you the desired results

Code:

//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,8,CH,EQ,C'MLS1111S'),           
                PUSH=(134:13,14)),                                   
                                                                     
        IFTHEN=(WHEN=(1,8,CH,EQ,C'19541112'),                       
               BUILD=(134,14,                    $ CITY NAME         
                      93,15,SFF,PD,LENGTH=8,     $ CONVERT TO PD     
                      7Z,X'0C',                  $ INITVAL 0         
                      7Z,X'0C')),                $ INITVAL 0         
                                                                     
        IFTHEN=(WHEN=(1,8,CH,EQ,C'42041117'),                       
               BUILD=(134,14,                    $ CITY NAME         
                      7Z,X'0C',                  $ INITVAL 0         
                      93,15,SFF,PD,LENGTH=8,     $ CONVERT TO PD     
                      7Z,X'0C')),                $ INITVAL 0         
                                                                     
        IFTHEN=(WHEN=(1,8,CH,EQ,C'42041119'),                       
               BUILD=(134,14,                    $ CITY NAME         
                      7Z,X'0C',                  $ INITVAL 0         
                      7Z,X'0C',                  $ INITVAL 0         
                      93,15,SFF,PD,LENGTH=8)),   $ CONVERT TO PD     
                                                                     
        IFTHEN=(WHEN=NONE,                                           
               BUILD=(14X,                       $ CITY NAME         
                      7Z,X'0C',                  $ INITVAL 0         
                      7Z,X'0C',                  $ INITVAL 0         
                      7Z,X'0C'))                 $ INITVAL 0         
                                                                     
  SORT FIELDS=(01,14,CH,A)                                           
                                                               
   SUM FIELDS=(15,8,PD,                                         
               23,8,PD,                                         
               31,8,PD)                                         
                                                               
                                                               
  OUTREC BUILD=(01:01,14,                                       
                15:15,8,PD,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-),   
                30:23,8,PD,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-),   
                45:31,8,PD,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-))   
                                                               
  OUTFIL INCLUDE=(1,14,CH,GT,C' '),                             
  BUILD=(X,1,14,                                               
         2X,                                                   
         15,15,JFY=(SHIFT=LEFT),                               
         2X,                                                   
         30,15,JFY=(SHIFT=LEFT),                               
         2X,                                                   
         45,15,JFY=(SHIFT=LEFT),
         2X)
/*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Jul 21, 2017 2:07 pm    Post subject: Reply with quote

Kolusu,

how about two steps solution and avoid sorting ?

untested
Code:

//SYSIN    DD *                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,8,CH,EQ,C'MLS1111S'),   
                PUSH=(134:13,14)),                         
        IFTHEN=(WHEN=(1,8,CH,EQ,C'19541112'),               
             OVERLAY=(150:93,15)),                         
        IFTHEN=(WHEN=(1,8,CH,EQ,C'42041117'),               
             OVERLAY=(165:93,15)),                         
        IFTHEN=(WHEN=(1,8,CH,EQ,C'42041119'),               
             OVERLAY=(180:93,15))                           
                                                           
 OPTION COPY
                                                           
  OUTFIL REMOVECC,NODETAIL,                                 
  INCLUDE=(134,14,CH,GT,C' '),                             
  SECTIONS=(134,14,                                         
  TRAILER3=(134,14,                                         
            2X,                                             
            TOT=(150,15,SFF,EDIT=(SIIIIIIIIIIT.TT)),         
            2X,                                             
            TOT=(165,15,SFF,EDIT=(SIIIIIIIIIIT.TT)),         
            2X,                                             
            TOT=(180,15,SFF,EDIT=(SIIIIIIIIIIT.TT)),         
            2X))                                           
//*


Code:

//SYSIN DD *
  OPTION COPY
  INREC OVERLAY=(17:17,15,JFY=(SHIFT=LEFT),
                 34:34,15,JFY=(SHIFT=LEFT),
                 51:34,15,JFY=(SHIFT=LEFT))



Limitation :

city appears only once in the report i.e no duplicate city.

Thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Jul 21, 2017 2:29 pm    Post subject: Reply with quote

Magesh_J wrote:
Kolusu,

how about two steps solution and avoid sorting ?
Limitation :

city appears only once in the report i.e no duplicate city.

Thanks
Magesh


Magesh,

OP hasn't confirmed about the cities being unique. So If OP has unique city names then he can use a copy. However if you look at my new control cards, I actually reduced the file length to just 39 bytes instead of the fill length of 133. So resources required to sort is reduced and it takes care even if OP had duplicate data.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 43
Topics: 9

PostPosted: Fri Jul 21, 2017 2:41 pm    Post subject: Reply with quote

Magesh/Kolusu,

Cities are unique, since it is a summary for each City the report produces

Kolusu,

On the requirements part , it is an adhoc request and client keeps changing since onetime run. will follow the code tag standards going forward
Back to top
View user's profile Send private message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Jul 21, 2017 2:55 pm    Post subject: Reply with quote

kolusu wrote:

OP hasn't confirmed about the cities being unique. So If OP has unique city names then he can use a copy. However if you look at my new control cards, I actually reduced the file length to just 39 bytes instead of the fill length of 133. So resources required to sort is reduced and it takes care even if OP had duplicate data.


Kolusu,

Now OP confimred its unique.

You are converting the value twice + SORT + 5 BUILD statments

Please advise which would be optimal ?

Thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Jul 21, 2017 3:11 pm    Post subject: Reply with quote

Suchay wrote:
Magesh/Kolusu,

Cities are unique, since it is a summary for each City the report produces

Kolusu,

On the requirements part , it is an adhoc request and client keeps changing since onetime run. will follow the code tag standards going forward


Well you could have answered the question about cities being earlier itself before the left justified request and yet you did not bother to answer that simple detail. bonk . You could have saved a lot of time.

Either way if your cities are unique, then use the following control cards which will give you the desired results in a single pass

Code:

//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,8,CH,EQ,C'MLS1111S'),           
                PUSH=(134:13,14)),                                 
                                                                   
        IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C'19541112'),           
                PUSH=(152:93,15)),                                 
                                                                   
        IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C'42041117'),           
                PUSH=(167:93,15)),                                 
                                                                   
        IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C'42041119'),           
                PUSH=(182:93,15)),                                 
                                                                   
        IFTHEN=(WHEN=INIT,                                         
        OVERLAY=(152:152,15,SFF,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-), 
                 167:167,15,SFF,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-), 
                 182:182,15,SFF,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-), 
                                                                   
                 152:152,15,JFY=(SHIFT=LEFT),                       
                 167:167,15,JFY=(SHIFT=LEFT),                       
                 182:182,15,JFY=(SHIFT=LEFT)))                     
                                                                   
  OUTFIL INCLUDE=(134,14,CH,GT,C' '),                               
  REMOVECC,NODETAIL,                                               
  SECTIONS=(134,14,                                                 
  TRAILER3=(X,134,14,                                               
            2X,                                                     
            152,15,                                                 
            2X,                                                     
            167,15,                                                 
            2X,                                                     
            182,15,                                                 
            2X))                                                   
                                                                   
//*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Jul 21, 2017 3:20 pm    Post subject: Reply with quote

Kolusu,

Did you use any robo to develope code ?

How could you derive an alternate solution @ this speed ?

Regards,
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Jul 21, 2017 3:25 pm    Post subject: Reply with quote

Magesh_J wrote:
kolusu wrote:

OP hasn't confirmed about the cities being unique. So If OP has unique city names then he can use a copy. However if you look at my new control cards, I actually reduced the file length to just 39 bytes instead of the fill length of 133. So resources required to sort is reduced and it takes care even if OP had duplicate data.


Kolusu,

Now OP confimred its unique.

You are converting the value twice + SORT + 5 BUILD statments

Please advise which would be optimal ?

Thanks
Magesh


Magesh,

If the cities are unique, then why even bother with 2 steps? It can be done in a single pass of data as shown above. Obviously a COPY operation is efficient than a SORT operation. Please remember that there are many ways to arrive at a solution.

Had I known that the cities are unique, I would have arrived at that solution to begin with. So it all depends on how detailed the question is.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Jul 21, 2017 3:45 pm    Post subject: Reply with quote

Magesh_J wrote:
Kolusu,

Did you use any robo to develope code ?

How could you derive an alternate solution @ this speed ?

Regards,
Magesh


huh? Robot that can think and write the solutions? wow. No I do not have access to any of those AI based robots. I wish I had one though.

It is just me who codes the solutions. If you give the detailed requirement, I can code most of the job even in my sleep. Smile
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group