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

Splice Multiple records to Single record.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Shajakhan Y

New User


Joined: 08 Nov 2010
Posts: 6
Location: Chennai, India

PostPosted: Tue Nov 09, 2010 3:13 pm
Reply with quote

Hi all,

Below is my requirement,

Input:
-------
AAA~ABC~XXX~XXX~JKL~
AAA~XXX~DEF~XXX~XXX~MNO~
AAA~XXX~XXX~GHI~XXX~XXX~PQR~
BBB~STU~XXX~XXX~234~
BBB~XXX~VWX~XXX~XXX~567~
BBB~XXX~XXX~YZ1~XXX~XXX~890~

Desired Output:
------------------
AAA~ABC~DEF~GHI~JKL~MNO~PQR~
BBB~STU~VWX~YZ1~234~567~890~

I know this can be obtained by splicing record 1 with record 2 and then splicing the result with record 3. But my original input has 13 records for each key(1,3) and I need to write 12 splice steps.

Is there any alternate easy way to do this?

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 09, 2010 3:25 pm
Reply with quote

Shajakhan Y.,
welcome to the forum.

Frank and Kolusu are not even awake yet, so to save you some dialog time:

1. insure that you are using DFSORT and not a competitor.

2. Look thru some of the posts answered by Frank and Kolusu and insure that you are providing all the necessary info that they will need to answer your question.
look at some of their questions to other posters,
as well as the job you should run to determine your DFSORT level.
Back to top
View user's profile Send private message
Shajakhan Y

New User


Joined: 08 Nov 2010
Posts: 6
Location: Chennai, India

PostPosted: Tue Nov 09, 2010 5:16 pm
Reply with quote

Hi,
Complexity of my Input Record:
-------------------------------------
Excluding the key column(1,3), The sample input I have provided has only 3 records & 6 columns per key. (2 sets of 3 columns).

But my original input has 13 records & 156 columns (12 sets of 13 columns).

The below SPLICE step can obtain me the desired output for my Sample Input. But applying the same logic to my original input will make things very complex.
//TOOLIN DD *
SPLICE FROM(INPUT) TO(TEMP1) ON(1,4,CH) -
WITHALL -
WITH(09,4) WITH(13,4) -
WITH(21,4) WITH(25,4)
SPLICE FROM(TEMP1) TO(OUTPUT) ON(1,4,CH) -
WITH(13,4) -
WITH(25,4)
/*

I am looking for a simple alternate way to achieve my desired output.

Thanks,
Shajakhan Y.
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: Tue Nov 09, 2010 9:57 pm
Reply with quote

Hello,

You need to post the "rules" that caused some of the values to be shown in red. . .

Sort products do not yet "color sort". . . icon_smile.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Nov 09, 2010 11:19 pm
Reply with quote

Shajakhan Y,

You need to provide more details.

1. What is the LRECL and recfm of the input and output dataset?
2. Do you want to pick up any value other than XXX on each record and string them together as a single record?
3. What happens if you have 2 records with the same string?

ex:
AAA~ABC~EFG~XXX~JKL~
AAA~XXX~DEF~XXX~XXX~MNO~

You have 2 values EFG and DEF for the same key AAA which value need to be picked?

4. Is the input file already sorted on the key (1,3)?
Back to top
View user's profile Send private message
Shajakhan Y

New User


Joined: 08 Nov 2010
Posts: 6
Location: Chennai, India

PostPosted: Wed Nov 10, 2010 8:52 am
Reply with quote

Hi Skolusu,

What is the LRECL and recfm of the input and output dataset?
The RECFM is FB for both input & output. The LRECL of my original Input is 1200.

Do you want to pick up any value other than XXX on each record and string them together as a single record?
The Input is already sorted on key (1,3). For every key, there will be 13 records. Eg. 'AAA' will have 13 records & 'BBB' will have 13 records...

1st record -> Key in pos (1,3). value in pos (4,3), (43,4) , (95,3), ..
2nd record -> Key in pos (1,3). value in pos (7,3), (47,4), (98,3), ..
3nd record -> Key in pos (1,3). value in pos (10,3), (51,4), (101,3), ..
...
13th record -> key in pos (1,3). value in (40,3), (91,4), ..

My input will be diagonally arranged with SPACES in the remaining places.
(** Actually XXX in the input i have shown is SPACES. I want to show that the data is diagonally arranged, that is why i used XXX here**)
I am new to this forum and i don't know how to post the screenshot of my input.

You have 2 values EFG and DEF for the same key AAA which value need to be picked?
I will not have two values in the same position.
eg:
AAA~ABC~
AAA~XXX~DEF~
AAA~XXX~XXX~GHI~
(** XXX here is SPACES).

Thanks,
Shajakhan Y.
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 Nov 10, 2010 9:26 am
Reply with quote

Hello,

Quote:
I am new to this forum and i don't know how to post the screenshot of my input.
To do this, you use the Code tag.

I've taken your last post and "Code'd" the data as i understand it should be - it won't hurt my feelings if i'm offbase icon_smile.gif
Code:
AAA~ABC~
AAA~   ~DEF~
AAA~   ~   ~GHI~


When posting data from a termnal, copy/paste the data from the screen, highlight this pasted data, then click Code. There is a Preview function so you can see your post as it will appear to the forum (rather than how it looks n the RFeply Editor). When it appears as you want, Submit.
Back to top
View user's profile Send private message
Shajakhan Y

New User


Joined: 08 Nov 2010
Posts: 6
Location: Chennai, India

PostPosted: Wed Nov 10, 2010 9:58 am
Reply with quote

Dick Scherrer,
Thanks. Exactly what i want. Now, I will be able to post my data properly.

Input:
--------
Code:
AAA~ABC~            JKL~            CCCC~
AAA~    DEF~            MNO~             DDDD~
AAA~        GHI~            PQR~              EEEE~
AAA~            FFF~            MMM~               FFFF~
BBB~STU~            234~            1111~
BBB~    VWX~            567~             2222~
BBB~        YZ1~            890~              3333~
BBB~            ZX3~            121~               4444~


Desired Output:
------------------
Code:
AAA~ABC~DEF~GHI~FFF~JKL~MNO~PQR~MMM~CCCC~DDDD~EEEE~FFFF~
BBB~STU~VWX~YZ1~ZX3~234~567~890~121~1111~2222~3333~4444~


I know this can be done as below:
Solution:
-----------
Code:
//TOOLIN   DD *
 SPLICE FROM(INPUT) TO(TEMP1) ON(1,4,CH) WITHALL -
 WITH(09,4) WITH(13,4) WITH(17,4) -
 WITH(25,4) WITH(29,4) WITH(33,4) -
 WITH(42,5) WITH(47,5) WITH(52,5)
*
 SPLICE FROM(TEMP1) TO(TEMP2) ON(1,4,CH) WITHALL -
 WITH(13,4) WITH(17,4) -
 WITH(29,4) WITH(33,4) -
 WITH(47,5) WITH(52,5)
*
 SPLICE FROM(TEMP2) TO(OUTPUT) ON(1,4,CH) -
 WITH(17,4) -
 WITH(33,4) -
 WITH(52,5)
/*


But this solution gets complex when no. of records per key & no. of columns increases. My original input has 13 records per key & 156 columns.

So, I am looking for some alternate easy way to do this.

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

New User


Joined: 08 Nov 2010
Posts: 6
Location: Chennai, India

PostPosted: Wed Nov 10, 2010 3:32 pm
Reply with quote

Hi all,

I just found that this can be done using the 'WITHANY' operand.

The WITHANY operand of SPLICE can be used to create one spliced record for each set of duplicates. The first duplicate is spliced with the nonblank values of each subsequent duplicate for specified fields.

Solution:
-----------
Code:
//TOOLIN   DD *
 SPLICE FROM(INPUT) TO(TEMP1) ON(1,4,CH) WITHANY -
 WITH(09,4) WITH(13,4) WITH(17,4) -
 WITH(25,4) WITH(29,4) WITH(33,4) -
 WITH(42,5) WITH(47,5) WITH(52,5)
/*


Thanks,
Shajakhan Y.
Back to top
View user's profile Send private message
giraffe

New User


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

PostPosted: Wed Nov 10, 2010 7:15 pm
Reply with quote

I think the 'witheach' option for splice tool may fulfill the goal...
Back to top
View user's profile Send private message
Shajakhan Y

New User


Joined: 08 Nov 2010
Posts: 6
Location: Chennai, India

PostPosted: Thu Nov 11, 2010 8:39 am
Reply with quote

Hi Giraffe,

Operand 'WITHEACH' won't work here becouse I have records with
nonconsecutive or missing WITH fields.

The below will be my output if I use WITHEACH.
Code:
AAA~ABC~DEF~GHI~FFF~JKL~            CCCC~
BBB~STU~VWX~YZ1~ZX3~234~            1111~


Thanks,
Shajakhan Y.
Back to top
View user's profile Send private message
giraffe

New User


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

PostPosted: Thu Nov 11, 2010 8:58 am
Reply with quote

YEP, IT LOOKS LIKE THE WITHANY OPTION FOR SPLICE IS A NEW FEATURE, THE PUBLICATION OF 'DFSORT APPLICATION PROGRAMMING GUIDE' WHICH I'M READING IS SECOND EDITION, MARCH 2005, THANKS A LOT.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Nov 11, 2010 11:41 pm
Reply with quote

The WITHANY option of DFSORT's ICETOOL has been available since July, 2008. That's hardly "new".
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top