Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to add comma at the end of each record using jcl

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
useit

Active User


Joined: 05 Oct 2006
Posts: 147

PostPosted: Wed Oct 10, 2012 2:59 pm    Post subject: How to add comma at the end of each record using jcl
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: 147

PostPosted: Wed Oct 10, 2012 3:05 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Wed Oct 10, 2012 3:17 pm    Post subject: Reply to: HOW TO ADD COMMA AT THE END OF EACH RECORD USING J
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    Post subject: Reply to: HOW TO ADD COMMA AT THE END OF EACH RECORD USING J
Reply with quote

here is the link icon_razz.gif

http://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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Oct 10, 2012 4:26 pm    Post subject: Reply to: How to add comma at the end of each record using j
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: 147

PostPosted: Wed Oct 10, 2012 4:57 pm    Post subject:
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

Moderator


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

PostPosted: Wed Oct 10, 2012 5:04 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Oct 10, 2012 5:12 pm    Post subject: Reply to: How to add comma at the end of each record using j
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us