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

Group according to certain fields using SORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Dec 14, 2010 3:11 pm
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: 2481
Location: @my desk

PostPosted: Tue Dec 14, 2010 3:12 pm
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 14, 2010 3:15 pm
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: 2481
Location: @my desk

PostPosted: Tue Dec 14, 2010 3:18 pm
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 14, 2010 3:20 pm
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Dec 14, 2010 3:39 pm
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
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: 2481
Location: @my desk

PostPosted: Tue Dec 14, 2010 3:56 pm
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
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: 2481
Location: @my desk

PostPosted: Tue Dec 14, 2010 4:27 pm
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: 1702
Location: Australia

PostPosted: Tue Dec 14, 2010 4:30 pm
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: 2481
Location: @my desk

PostPosted: Tue Dec 14, 2010 4:34 pm
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: 1702
Location: Australia

PostPosted: Tue Dec 14, 2010 4:40 pm
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
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
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: 2481
Location: @my desk

PostPosted: Tue Dec 14, 2010 6:52 pm
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
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: 27
Location: SHENZHEN CHINA

PostPosted: Thu Dec 16, 2010 7:01 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top