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

How to add comma at the end of each record using jcl


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

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Oct 10, 2012 2:59 pm
Reply with quote

hi,
i have two input files.

file1:(LRECL=5)

Code:
A
B
C
AB
ABCD


FILE2:(LRECL=5)

Code:
B
C
AB
ABCD

I Need to compare two files and add comm at the end of each record except for last record. is there anyway we can add comma at the end of each record using jcl??


so my output should be

Code:
B,
C,
AB,
ABCD


Using joinkeys we can copy matching records into output file.but am not sure about adding comma at the end of each record.

regds,
useit
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Oct 10, 2012 3:05 pm
Reply with quote

i know we can add comma using below command.

//SYSIN DD *
OPTION COPY
INREC OVERLAY=(6:C',')

but my problem is how can we identify last record and not to include comma for the last record??
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 10, 2012 3:17 pm
Reply with quote

the issue has been discussed quite a few times
hy not search the forum Yourself ?
Back to top
View user's profile Send private message
Dsingh29

Active User


Joined: 16 Dec 2008
Posts: 132
Location: IBM

PostPosted: Wed Oct 10, 2012 3:41 pm
Reply with quote

here is the link icon_razz.gif

ibmmainframes.com/about56437.html
Back to top
View user's profile Send private message
ezio vin

New User


Joined: 16 Aug 2012
Posts: 44
Location: india

PostPosted: Wed Oct 10, 2012 4:00 pm
Reply with quote

if you are going to use the above specified inrec statement you will not get the exected result.

you will get the result like follows

Code:
A   ,
B   ,
C   ,
D   ,
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 Oct 10, 2012 4:26 pm
Reply with quote

Useit,

Please don't try to gain attention for your topics by putting the subject in "all caps".

You mention that you are already using JOINKEYS. Can you show what you have, describe the task fully, and tell us the LRECL/RECFM of inputs and output. Sample input, sample output.

DATASORT is not going to help you unless your data is already in order on one particular byte, as otherwise the data will be rearranged as a SORT is required for DATASORT.
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Oct 10, 2012 4:57 pm
Reply with quote

input file layput.

01.inrec
05 repgrp pic X(7)

Output file

01.outrec
05 repgrp pic X(7)

input file1:

Code:
'Z4   '
'Z7   '
'Z8   '
'Z9   '
'Z777 '
'Z8888'


input file2
Code:
'Z4   '
'Z7   '
'Z4444'
i need to capture only non matching records from the first file.

Code:
//SORTJNF1 DD DSN=infile1,DISP=OLD 
//SORTJNF2 DD DSN=infile2,DISP=OLD 
//NOMATCH  DD DSN=outfile,DISP=OLD         
//SYSOUT   DD SYSOUT=*                           
//SYSIN    DD *                                   
JOINKEYS FILE=F1,FIELDS=(2,5,A)                   
JOINKEYS FILE=F2,FIELDS=(2,5,A)                   
REFORMAT FIELDS=(F1:1,7,F2:1,7)                         
JOIN UNPAIRED,F1,ONLY                             
SORT FIELDS=(2,5,CH,A)                           
//SRTMSGE  DD SYSOUT=*                           
//*                                               

so i have got output as

Code:
'Z8   '
'Z9   '
'Z777 '
'Z8888'


but i need to add comma at the end of eeach record of the output file.except the last record. so my output should be

Code:
'Z8   ',
'Z9   ',
'Z777 ',
'Z8888'
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 Oct 10, 2012 5:04 pm
Reply with quote

Useit,

This is what you could do
Do a join of records in Step 1 and get the matched records
Use Symnames have a symbol and assign the value of total matched record count in Step1
In Step 2 use Inrec overlay with sequence number & replace the first space with comma and check for the symbol to check last record and dont do any action for it
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 Oct 10, 2012 5:12 pm
Reply with quote

Useit,

The format of your sample is different from what you showed originally. Please be accurate first time up, otherwise we waste time looking at the wrong thing. OVERLAY will get the trailing comma on.

You are SORTing after the JOINKEYS. Because of the JOINKEYS your data is already in that order (JOINKEYS does SORTs by default). So you can make that
Code:

  SORT FIELDS=COPY


Are you expecting a large volume for your output? If not, it might be just as easy to do the DATASORT in a separate step, you are about to SORT on (1,1,CH,A).
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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top