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

Add Comma to each record until find the next client number


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

New User


Joined: 04 Oct 2005
Posts: 34

PostPosted: Sat Jul 28, 2018 12:25 am
Reply with quote

Hi,

Add comma to each record until find the next client number in file

File contain date,org name,client number, email id etc...

Input
---------

20180720 XYZCOMPANY 145678 ABC@EMAIL.COM
20180721 XYZCOMPANY 145678 ABC@EMAIL.COM
20180722 XYZCOMPANY 145678 ABC@EMAIL.COM
20180723 XYZCOMPANY 145678 ABC@EMAIL.COM

20180720 XYZCOMPANY 145685 ABC@EMAIL.COM
20180721 XYZCOMPANY 145685 ABC@EMAIL.COM

20180722 XYZCOMPANY 145687 ABC@EMAIL.COM
20180723 XYZCOMPANY 145688 ABC@EMAIL.COM

Output like this
==========
20180720 XYZCOMPANY 145678 ABC@EMAIL.COM,
20180721 XYZCOMPANY 145678 ABC@EMAIL.COM,
20180722 XYZCOMPANY 145678 ABC@EMAIL.COM,
20180723 XYZCOMPANY 145678 ABC@EMAIL.COM

20180720 XYZCOMPANY 145685 ABC@EMAIL.COM,
20180721 XYZCOMPANY 145685 ABC@EMAIL.COM

20180722 XYZCOMPANY 145687 ABC@EMAIL.COM
20180723 XYZCOMPANY 145688 ABC@EMAIL.COM
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Sat Jul 28, 2018 1:55 am
Reply with quote

Please send the requirements document and someone here will do the coding/testing for you.

Also, we'll let your boss know Not to bother you with such tasks and directly post on this forum.

.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


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

PostPosted: Sat Jul 28, 2018 2:05 am
Reply with quote

First Please take a few minutes to review your post before submit....

It is as if you are asking someone to do it here .. I find it rude at least...

To answer your question:

1. Your need to use ICETOOL for multiple passes along with joinkeys
2. First pass you need to prepare for //JNF1CNTL where JNF1CNTL should have your key and nth SEQUENCE number for each group (Ex: 145678 and 4 ) You need to do that using INREC + Adding SEQUNCE NUMBER + SORT descending based on Sequence number and SELECT first and assign to a temp file which would serve as you JNF1CNTL
3.Assign your original file for JNF2CNTL
4.Inrec add a sequnce to your original file
5.join both files based on client number
6. Reformat
7.When Sequence number matches from both the files dont add ',' else add
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Sat Jul 28, 2018 2:58 am
Reply with quote

Or you could do something like this by joining the same input to itself, which does not involve SORTing. I have assumed the input attributes to be FB/LRECL-80.
You could modify it as per your actual requirement.
Code:
//STEP01   EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTJNF1 DD *                               
20180720 XYZCOMPANY 145678 ABC@EMAIL.COM       
20180721 XYZCOMPANY 145678 ABC@EMAIL.COM       
20180722 XYZCOMPANY 145678 ABC@EMAIL.COM       
20180723 XYZCOMPANY 145678 ABC@EMAIL.COM       
20180720 XYZCOMPANY 145685 ABC@EMAIL.COM       
20180721 XYZCOMPANY 145685 ABC@EMAIL.COM       
20180722 XYZCOMPANY 145687 ABC@EMAIL.COM       
20180723 XYZCOMPANY 145688 ABC@EMAIL.COM       
//SORTJNF2 DD *                                   
20180720 XYZCOMPANY 145678 ABC@EMAIL.COM           
20180721 XYZCOMPANY 145678 ABC@EMAIL.COM           
20180722 XYZCOMPANY 145678 ABC@EMAIL.COM           
20180723 XYZCOMPANY 145678 ABC@EMAIL.COM           
20180720 XYZCOMPANY 145685 ABC@EMAIL.COM           
20180721 XYZCOMPANY 145685 ABC@EMAIL.COM           
20180722 XYZCOMPANY 145687 ABC@EMAIL.COM           
20180723 XYZCOMPANY 145688 ABC@EMAIL.COM           
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                               
 JOINKEYS FILE=F1,FIELDS=(81,8,A),SORTED,NOSEQCK             
 JOINKEYS FILE=F2,FIELDS=(81,8,A),SORTED,NOSEQCK             
 JOIN UNPAIRED,F1                                             
 REFORMAT FIELDS=(F1:1,80,F2:21,6,?)                         
 SORT FIELDS=COPY                                             
 INREC IFOUTLEN=80,                                           
       IFTHEN=(WHEN=(21,6,CH,EQ,81,6,CH),OVERLAY=(41:C','))   
//JNF1CNTL DD *                                               
 INREC OVERLAY=(81:SEQNUM,8,ZD)                               
//JNF2CNTL DD *                                               
 INREC OVERLAY=(81:SEQNUM,8,ZD,START=0) 
SORTOUT had:
Code:
20180720 XYZCOMPANY 145678 ABC@EMAIL.COM,
20180721 XYZCOMPANY 145678 ABC@EMAIL.COM,
20180722 XYZCOMPANY 145678 ABC@EMAIL.COM,
20180723 XYZCOMPANY 145678 ABC@EMAIL.COM
20180720 XYZCOMPANY 145685 ABC@EMAIL.COM,
20180721 XYZCOMPANY 145685 ABC@EMAIL.COM
20180722 XYZCOMPANY 145687 ABC@EMAIL.COM
20180723 XYZCOMPANY 145688 ABC@EMAIL.COM
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Jul 28, 2018 3:00 pm
Reply with quote

After 13 years as a member of the forum you should know to use the code-tags when postings code, data, screenshots etc.
Also after so long in the industry you should know the difference between a data set and a file.
Back to top
View user's profile Send private message
naveensrimf

New User


Joined: 04 Oct 2005
Posts: 34

PostPosted: Mon Jul 30, 2018 7:32 pm
Reply with quote

Thanks for the solution. Now my requirement is full filled.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Aug 02, 2018 12:06 am
Reply with quote

If you don't care about the sort order then try below solution as well else add one more step to SORT it back to original order. If the records are more like in millions then probably this is not the right way to do it.
Code:
//STEP010  EXEC PGM=SORT
//SYSUDUMP DD  SYSOUT=*
//SYSOUT   DD  SYSOUT=*
//SORTIN   DD  *
20180720 XYZCOMPANY 145678 ABC@EMAIL.COM
20180721 XYZCOMPANY 145678 ABC@EMAIL.COM
20180722 XYZCOMPANY 145678 ABC@EMAIL.COM
20180723 XYZCOMPANY 145678 ABC@EMAIL.COM
20180720 XYZCOMPANY 145685 ABC@EMAIL.COM
20180721 XYZCOMPANY 145685 ABC@EMAIL.COM
20180722 XYZCOMPANY 145687 ABC@EMAIL.COM
20180723 XYZCOMPANY 145688 ABC@EMAIL.COM
//SORTOUT  DD  SYSOUT=*
//SYSIN    DD  *
   SORT FIELDS=(21,6,CH,A,50,2,ZD,D)
   INREC OVERLAY=(50:SEQNUM,2,ZD,RESTART=(21,6),41:C',')
   OUTREC OVERLAY=(60:SEQNUM,2,ZD,RESTART=(21,6))
   OUTFIL IFOUTLEN=41,
          IFTHEN=(WHEN=(60,2,ZD,EQ,1),OVERLAY=(41:C' '))
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 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top