Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to append comma at the end of each variable len rec

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

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Sun Apr 15, 2012 3:03 am    Post subject: How to append comma at the end of each variable len rec
Reply with quote

Hi,

I have a requirement like this:

1)Each record has one field of variable length in a flat file of length 10.
aaa
bbbbb
ccccccc

I want each record to be suffixed with ,(comma) at the end of non blank chars in the record.

i.e.

o/p should be:::

aaa,
bbbbb,
ccccccc,

I had tried with PARSE but no use as it uses FIXLENGTH. Whenever PARSE finds blank, i moved it to FIXLENGTH of 7 and used BUILD to append comma.i could see few spacess before comma.

o/p was :
aaa ,
bbbbb ,
ccccccc,

Will it be possible to do with icetool/sort.

Thanks a lot.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Sun Apr 15, 2012 3:18 am    Post subject: Reply to: How to append comma at the end of each variable le
Reply with quote

Can you have embedded spaces in your data?

If not, FINDREP (which finds and replaces) can do it for you. Change a space to a comma, and DO it only once.

Edit: This looks related to your previous question. If so, it is probably best to list the whole requirement, otherwise we might spend time on things we later find aren't necessary.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Sun Apr 15, 2012 5:33 am    Post subject:
Reply with quote

Hi,

what if there is no space in last byte ?

If there are no embedded spaces then this might help

Code:
//STEP0001 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
1234567890                                             
123456789                                             
12345678                                               
1234567                                               
123456                                                 
12345                                                 
1234                                                   
123                                                   
12                                                     
1                                                     
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=(10,1,CH,EQ,C' '),               
        OVERLAY=(10:C','))                             
  OUTREC BUILD=(1,10,SQZ=(SHIFT=LEFT))                 
/*                                                     



Gerry
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Sun Apr 15, 2012 2:29 pm    Post subject:
Reply with quote

Good call, worked a treat!

Thanks a lot gcicchet and Bill.

There will be a space in last byte and no embedded spaces.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Sun Apr 15, 2012 4:15 pm    Post subject: Reply to: How to append comma at the end of each variable le
Reply with quote

OK, no problem.

Remember, if connected to your previous question and one of the every-third input records contains eight characters, the trailing comma will be chopped off when it becomes one of three parts of a 28-byte record.

I'd done on for the "embedded spaces", so it may as well appear...

Code:

//TRLCOMMA EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN DD *
 SORT FIELDS=COPY
 INREC IFTHEN=(WHEN=(01,10,CH,EQ,C' '),OVERLAY=(01:C' ')),
       IFTHEN=(WHEN=(02,09,CH,EQ,C' '),OVERLAY=(02:C',')),
       IFTHEN=(WHEN=(03,08,CH,EQ,C' '),OVERLAY=(03:C',')),
       IFTHEN=(WHEN=(04,07,CH,EQ,C' '),OVERLAY=(04:C',')),
       IFTHEN=(WHEN=(05,06,CH,EQ,C' '),OVERLAY=(05:C',')),
       IFTHEN=(WHEN=(06,05,CH,EQ,C' '),OVERLAY=(06:C',')),
       IFTHEN=(WHEN=(07,04,CH,EQ,C' '),OVERLAY=(07:C',')),
       IFTHEN=(WHEN=(08,03,CH,EQ,C' '),OVERLAY=(08:C',')),
       IFTHEN=(WHEN=(09,02,CH,EQ,C' '),OVERLAY=(09:C',')),
       IFTHEN=(WHEN=(10,01,CH,EQ,C' '),OVERLAY=(10:C','))
                                                         
//SORTIN   DD *
                                                         
         0
1234567 9
12345 78
123 567
1 3456
1 3 5
12 4
1 3
12
1


Output is:

Code:
         
         0
1234567 9,
12345 78,
123 567, 
1 3456,   
1 3 5,   
12 4,     
1 3,     
12,       
1,       
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Sun Apr 15, 2012 5:34 pm    Post subject:
Reply with quote

Many thanks Bill for your inputs.

Regards
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Apr 16, 2012 9:57 pm    Post subject:
Reply with quote

sudhanaveenkumar wrote:
Good call, worked a treat!

Thanks a lot gcicchet and Bill.

There will be a space in last byte and no embedded spaces.


If there are no embedded spaces then you can use the following DFSORT JCL
Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
1234567890                                     
123456789                                       
12345678                                       
1234567                                         
123456                                         
12345                                           
1234                                           
123                                             
12                                             
1                                               
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  OPTION COPY                                   
  INREC BUILD=(1,10,SQZ=(SHIFT=LEFT,TRAIL=C','))
//*   
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Tue Apr 17, 2012 12:34 pm    Post subject:
Reply with quote

Thanks Kolusu.

I have one more question.

I want to do a specific processing for the last record in an input file and i dont know how many records are in the input file and i cant uniquely identify the last record.

For the same sample jcl you have given above ,
For example if i want to append semicolon (;) to the last record alone in an input file.How can it be done?






Thanks a lot
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Tue Apr 17, 2012 12:40 pm    Post subject:
Reply with quote

Of course, i can include all possibilities as mentioned in Bill Woodger sample jcl.

But It will be too lengthy if the field size increases to 20(10 shown above).

Would you please advise much simpler way to perform specific processing on last record alone where i cant uniquely identify it?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Apr 17, 2012 10:01 pm    Post subject:
Reply with quote

sudhanaveenkumar wrote:
Thanks Kolusu.

I have one more question.

I want to do a specific processing for the last record in an input file and i dont know how many records are in the input file and i cant uniquely identify the last record.

For the same sample jcl you have given above ,
For example if i want to append semicolon (;) to the last record alone in an input file.How can it be done?
Thanks a lot


Use the following DFSORT/ICETOOL JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                   
1234567890                                                         
123456789                                                         
12345678                                                           
1234567                                                           
123456                                                             
12345                                                             
1234                                                               
123                                                               
12                                                                 
1                                                                 
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)         
//LR       DD DSN=&&LR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)         
//TOOLIN   DD *                                                   
  SUBSET FROM(IN) TO(LR) DISCARD(T1) INPUT KEEP TRAILER USING(CTL1)
//CTL1CNTL DD *
  INREC BUILD=(1,10)                                                     
  OUTFIL FNAMES=LR,OVERLAY=(1,10,SQZ=(SHIFT=LEFT,TRAIL=C','))     
//*                                                               
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&T1,DISP=SHR                                   
//         DD DSN=&&LR,DISP=SHR                                   
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
//*
Back to top
View user's profile Send private message
sudhanaveenkumar

New User


Joined: 29 Apr 2010
Posts: 28
Location: chennai

PostPosted: Tue Apr 17, 2012 10:43 pm    Post subject:
Reply with quote

Thanks Kolusu.
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 Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us