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
 

 

Group according to certain fields using SORT

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

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Tue Dec 14, 2010 2:42 pm    Post subject: Group according to certain fields using SORT
Reply with quote

hi all,

Kindly go thru the attachement for the requirement.
I am not able to place here with proper alignment. So attached the requirement in the document.

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

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Dec 14, 2010 3:11 pm    Post subject:
Reply with quote

Do NOT post attachments as not evreyone can or chooses to open them
Use cut and paste with the code tags, and having been on the forum for 6 years I would rather hope that you had learnt to use them by now

Code:
[code]Put
Your code
Here [/code]
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Tue Dec 14, 2010 3:12 pm    Post subject:
Reply with quote

karthi_ind,

You have been a member of this forum for quite a long time. Are n't you comfortable using the "Code" tags yet?? icon_eek.gif

Also your requirement does not reveal the position, length and format of all the relevant fields.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 14, 2010 3:15 pm    Post subject:
Reply with quote

Now i had to download from usenet MS Word to read the attachment. Bill Gates is knocking on my door because that was an illegal act. Thanks.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Tue Dec 14, 2010 3:18 pm    Post subject:
Reply with quote

Peter,

"Nothing is illegal until you get caught" icon_lol.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 14, 2010 3:20 pm    Post subject:
Reply with quote

Arun Raj wrote:
Peter,

"Nothing is illegal until you get caught" icon_lol.gif


And proven guilty icon_rolleyes.gif
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Tue Dec 14, 2010 3:37 pm    Post subject:
Reply with quote

Code:

Input file

Status      id1    id2     id3   price qty   descr
------------------------------------------------------
aa            1      1      1    10     2     xxx
aa            1      1      1    10     2     yyy
aa            1      1      1    10     2     aaa
bb            2      2      2    05     3     yyy
bb            2      2      2    05     3     aaa

Output file

Status      id1    id2     id3   price qty   descr
-------------------------------------------------------
aa           1      1      1     10     2     xxx
                                              yyy
                                              aaa
bb           2      2      2     05     3     yyy
                                              aaa      


Format is FB

Status - length (3), Starts in 3, type is char
id1 - length (6), starts in 17, type is numeric
id2 - length (20), starts in 33, type is char
id3 - length (10), starts in 54, type is char
price - length (7), starts in 66, type is numeric
qty - length (6), starts in 74, type is numeric
Descr - length (11), starts in 83, type is char

remaining can be spaces till the end of 120.

Please let me know if you need any other details.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Dec 14, 2010 3:39 pm    Post subject:
Reply with quote

You have shown the input and the output but have not explained the rules from getting from one to the other.
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Tue Dec 14, 2010 3:52 pm    Post subject: Reply to: Group according to certain fields using SORT
Reply with quote

Hi expat,

The rule is

if the status, id1, id2, id3, price, qty are equal for more than one records and descr is different then it has to remove the repeated values of
status, id1, id2, id3, price, qty and has to retain descr field alone in the output file (as given in the above output file), same has to be done for all other records also.

Hope this makes clear.

Thanks.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Tue Dec 14, 2010 3:56 pm    Post subject:
Reply with quote

Quote:
if the status, id1, id2, id3, price, qty are equal for more than one records and descr is different
What if descr is also same for multiple records?
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Tue Dec 14, 2010 4:01 pm    Post subject: Reply to: Group according to certain fields using SORT
Reply with quote

Hi Arun,

Descr will not be same for multiple records.

Thanks.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Tue Dec 14, 2010 4:27 pm    Post subject:
Reply with quote

It might be worth giving this a try.
Code:
//STEP01 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN= Input  file FB/252
//SORTOUT  DD DSN= Output file FB/120
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(253:SEQNUM,8,ZD,RESTART=(1,82))),
        IFTHEN=(WHEN=(253,8,ZD,NE,1),BUILD=(83:83,11,120:X)),IFOUTLEN=120
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Tue Dec 14, 2010 4:30 pm    Post subject:
Reply with quote

Hi,

try this
Code:
  SORT FIELDS=COPY                                   
  INREC OVERLAY=(94:SEQNUM,8,ZD,RESTART=(1,79))       
  OUTREC IFTHEN=(WHEN=(94,8,ZD,GT,1),                 
    BUILD=(82C' ',83,11)),                           
         IFTHEN=(WHEN=(94,8,ZD,EQ,1),                 
    BUILD=(1,93,120:X))                               


Gerry
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Tue Dec 14, 2010 4:34 pm    Post subject:
Reply with quote

Hi Gerry,

Does n't the above card have an additional OUTREC pass?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Tue Dec 14, 2010 4:40 pm    Post subject:
Reply with quote

Hi Arun,

yes, you are right icon_redface.gif


Gerry
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Tue Dec 14, 2010 5:32 pm    Post subject: Reply to: Group according to certain fields using SORT
Reply with quote

Thanks Arun and Gerry.

The code is working pretty fine.

Thanks for your help.
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Tue Dec 14, 2010 6:07 pm    Post subject: Reply to: Group according to certain fields using SORT
Reply with quote

Hi Arun,

There is a change in the requirement, I want to display Status field also.
It has to repeat the same values for Status field alone. Not for other fields.

Code:

Status     ............................... descr
---------------------------------------------
aa                                         xxx
aa                                         yyy
aa                                         aaa
bb                                         yyy
bb                                         aaa



Other fields are some, no need to repeat it again.

Thanks


[/code]
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2161
Location: @my desk

PostPosted: Tue Dec 14, 2010 6:52 pm    Post subject:
Reply with quote

I dont understand why people are not willing to state all of their requirements in their initial post itself. icon_evil.gif
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Tue Dec 14, 2010 7:09 pm    Post subject: Reply to: Group according to certain fields using SORT
Reply with quote

Sorry arun,

I got to know only after seeing the result. Actually i need that field for further validation.

I tried with the below code and it is working fine

Code:

   OPTION COPY                                                         
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(253:SEQNUM,8,ZD,RESTART=(01,82))), 
    IFTHEN=(WHEN=(253,8,ZD,NE,1),BUILD=(01:1,16,83:83,11,120:X)),       
                                 IFOUTLEN=120                           


Thanks
Back to top
View user's profile Send private message
giraffe

New User


Joined: 09 Nov 2010
Posts: 28
Location: SHENZHEN CHINA

PostPosted: Thu Dec 16, 2010 7:01 pm    Post subject:
Reply with quote

I don't think these solutions above may work, since the value for restart fields should be in order, unfortunately there's a header...
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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