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 

Rearranging data

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Piscesian
Beginner


Joined: 17 Dec 2004
Posts: 14
Topics: 8
Location: Monrovia,California

PostPosted: Tue Apr 25, 2006 3:37 pm    Post subject: Rearranging data Reply with quote

Hi,

I have an input mainframe dataset that contains data like this:
257}20050414}20050501}180}50
257}20050414}20050501}180}25
257}20050414}20050501}180}0

I want to re-arrange(re-format) the data to appear ike this:

257}20050414}20050501}180}50}25}0

Can anybody suggest me a method to achieve this either using DFSORT or Excel or any macro.

Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Apr 25, 2006 3:41 pm    Post subject: Reply with quote

Are there only three records in the data set, or are there more records? If more records, what do they look like?

What is the "rule" you want to use here? For example:
- Append the last field from the second and third records to the end of the first record?
- Or match the keys and append?
- Or what?

You really need to explain what rules you want to use so we don't have to guess.

Also, what is the RECFM and LRECL of the input file?

BTW, this belongs in the Utilities Forum.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Piscesian
Beginner


Joined: 17 Dec 2004
Posts: 14
Topics: 8
Location: Monrovia,California

PostPosted: Tue Apr 25, 2006 4:01 pm    Post subject: Reply with quote

Sorry,Frank,for posting in the wrong forum.

There are approximately 20,000 records in the input dataset.
For e.g
Code:

257}20050414}20050501}180}50
257}20050414}20050501}180}25
257}20050414}20050501}180}0
257}20050501}20050601}181}31770.92
257}20050501}20050601}181}0
257}20050501}20050601}181}3015
1429}20050414}20050101}90}1472
1429}20050414}20050101}90}8836.03
1429}20050414}20050101}90}55
---
---and so on
Required output format:
257}20050414}20050501}180}50}25}0
257}20050501}20050601}181}31770.92}0}3015
1429}20050414}20050101}90}1472}8836.03}55


In short, for records having matching columns(first two columns), then data appearing in the last column should be written adjacent to the first record and subsequent rows
of that record should not be written in the output.

LRECL of input file is 69 and RECFM is VB

I hope I'm clear this time.

Thx,
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Apr 25, 2006 7:03 pm    Post subject: Reply with quote

So let me see if I understand:
1) There are always three records for each match (first two columns)
2) The 5 fields are variable position/length and are delimited by }
3) You want the appended fields to be delimited by } (no blanks)
Is that right?

If so and assuming the maximum length of each field is 10 bytes, including the { delimiter, you could use a DFSORT/ICETOOL job like the following to do it. You'll need z/OS DFSORT V1R5 UK90007 or DFSORT R14 PTF UK90006 (April, 2006) to use PARSE and SQZ. If you don't have this PTF, ask your System Programmer to install it. For complete details on these functions, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Code:

//S1    EXEC PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN     DD DSN=... input file (VB)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...    output file (VB)
//TOOLIN DD *
* After reformatting the records with INREC,
* splice tmp2 and tmp3 into the base record
* using field1 and field2 as the key.
 SPLICE FROM(IN) TO(T1) ON(5,20,CH) -
   WITHEACH WITH(55,10) WITH(65,9) USING(CTL1)
* Sort on seqnum2 to get the records back in order.
* Then squeeze the fields and trim the blanks at the end.
 SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,
* Extract field1-field5 into fixed parsed fields %00-%04.
* Build a reformatted record as follows:
* |RDW|%00|%01|%02|%03|%04{|tmp2|tmp3|seqnum1|seqnum2|
* seqnum1 is 1, 2 or 3 for each set of three records with same key.
* seqnum2 is a sequence number for getting the records back
* in their original order.
         PARSE=(%00=(ENDAT=C'}',FIXLEN=10),
               %01=(ENDAT=C'}',FIXLEN=10),
               %02=(ENDAT=C'}',FIXLEN=10),
               %03=(ENDAT=C'}',FIXLEN=10),
               %04=(FIXLEN=9)),
         BUILD=(1,4,5:%00,15:%01,25:%02,35:%03,45:%04,C'{')),
        IFTHEN=(WHEN=INIT,
         OVERLAY=(75:SEQNUM,3,ZD,RESTART=(5,20),78:SEQNUM,5,ZD)),
* For second record with each key, put field5 into tmp2.
        IFTHEN=(WHEN=(75,3,ZD,EQ,+2),
         OVERLAY=(55:45,10)),
* For third record with each key, put field5 into tmp3.
        IFTHEN=(WHEN=(75,3,ZD,EQ,+3),
         OVERLAY=(65:45,9))
/*
//CTL2CNTL DD *
  SORT FIELDS=(78,5,ZD,A)
  OUTFIL FNAMES=OUT,BUILD=(1,4,5,70,SQZ=(SHIFT=LEFT)),VLTRIM=C' '
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
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
Page 1 of 1

 
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