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

Merging 2 lines in one on conditional basis


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Jun 25, 2013 11:00 pm
Reply with quote

This is my requirement -

Input data - FB 80

It has multiple lines, but only few pairs as shown below -

Code:

AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-777
    04/13     03/14     Z3  00000
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-888
    03/13     02/14     L3  00000
AAAAAA 123456-1234567-123


Output expected - FB 160

I need to get only pairs in the output. Like this -

Code:

AAAAAA 123456-1234567-777    04/13     03/14     Z3  00000
AAAAAA 123456-1234567-888    03/13     02/14     L3  00000
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 25, 2013 11:52 pm
Reply with quote

What is your sort product?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 25, 2013 11:53 pm
Reply with quote

So, from the data you have shown you can just ignore everything that is "-123"?

Or any other way to know which ones you want?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 26, 2013 12:11 am
Reply with quote

Hello,

I suspect incomplete test data . . .
Back to top
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Wed Jun 26, 2013 1:32 am
Reply with quote

Pandora-Box wrote:
What is your sort product?


It is DFSORT.

Bill Woodger wrote:
So, from the data you have shown you can just ignore everything that is "-123"?

Or any other way to know which ones you want?


-123 is just a sample data, it could be any value.
What I need is a pair of records as shown in example:
for record having -777 paired record has values -
04/13 03/14 Z3 00000
similarly record having -888 paired record is-
03/13 02/14 L3 00000

I just need these paired records in output to be merged in to one line.

I hope its clear now!
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jun 26, 2013 1:58 am
Reply with quote

How do you define "paired" records?

Do you mean the last record of the group has spaces in the first 3 bytes and you need to pick the record prior to that as a pair?

If that is indeed true

1. Use ICETOOL SELECT operator with LASTDUP on the sequence number
2. Use when=init to append a sequence number at position 161.
3. Use when=group with END=(1,3,CH,EQ,C' ') and RECORDS=2 and push the contents on to pos 81.
4. Use When=(1,3,CH,EQ,C' ') subtract 1 from the sequence number to make it a duplicate record.
5. Using OUTFIL build the first 160 bytes removing the sequence number
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 26, 2013 12:30 pm
Reply with quote

Kolusu,

Instead of this why cant we just do something like this

1.GROUP 1,3 when not equal to space and adding SEQ and pushing data
2.OUTFIL INCLUDE only for number 2 and BUILD to reformat
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 26, 2013 12:47 pm
Reply with quote

Well, experiment.

Remember to turn off the SORT for SELECT. OPTION COPY in the USING(xxxx) xxxxCNTL file.

Give yourself 50m input records.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 26, 2013 8:17 pm
Reply with quote

Bill & Kolusu,

Code:
//S1      EXEC PGM=SORT
//SYSPRINT  DD SYSOUT=*
//SYSOUT    DD SYSOUT=*
//SORTIN    DD *
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-777
    04/13     03/14     Z3  00000
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-123
AAAAAA 123456-1234567-888
    03/13     02/14     L3  00000
AAAAAA 123456-1234567-123
//SORTOUT   DD SYSOUT=*
//SYSIN     DD *
  SORT   FIELDS=COPY
  INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,NE,C'   '),
                 PUSH=(35:SEQ=1,1,25))
  OUTFIL INCLUDE=(35,1,ZD,EQ,02),BUILD=(1:36,25,26:1,33)


This will give the output

Code:
AAAAAA 123456-1234567-777    04/13     03/14     Z3  00000
AAAAAA 123456-1234567-888    03/13     02/14     L3  00000


I am not sure what is the disadvantage of this method
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jun 26, 2013 9:09 pm
Reply with quote

pandora,

There are "n" different ways to get the desired results. My choice was to use SELECT to pick the Last Duplicate via ICETOOL and you chose the traditional method. There wouldn't be a difference in performance either method.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 26, 2013 9:51 pm
Reply with quote

Ok fine :-)

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

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Thu Jun 27, 2013 9:14 am
Reply with quote

Kolusu, Pandora...

Thanks a lot to both of you for providing the solution. I really do appreciate. icon_smile.gif
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 Merging 2 datasets into one DFSORT/ICETOOL 1
No new posts Conditional EATTR in MFS ? IMS DB/DC 0
No new posts I need a 4 lines block where substrin... DFSORT/ICETOOL 12
No new posts Copy few lines from SYSOUT of 10 mill... All Other Mainframe Topics 5
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:

Back to Top