Page 1 of 1

Add text to each record using REXX.

PostPosted: Tue May 13, 2014 5:24 am
by Viswanathchandru
Dear all,

I have a requirement where I need to add a text to each record of a file. Given below is the input file.

RBE221VENUS TRANSACTION LISTING FOR DAY 121 OF YEAR 2014         
RBE1QC- TRANSACTION A2BA1     AT TERMINAL RBE0ZZ
RBE1QC- TRANSACTION VEHN      AT TERMINAL RBE0Z1
RBE1QC- TRANSACTION VEHX      AT TERMINAL DWT05P
RBE1QC- TRANSACTION MAIL      AT TERMINAL NAD068
RBE1QC- TRANSACTION INVN      AT TERMINAL ISM001
RBE221VENUS TRANSACTION LISTING FOR DAY 122 OF YEAR 2014         
RBE1QC- TRANSACTION A2BA1     AT TERMINAL RBE0ZZ
RBE1QC- TRANSACTION VEHN      AT TERMINAL RBE0Z1
RBE1QC- TRANSACTION VEHX      AT TERMINAL DWT05P
RBE1QC- TRANSACTION MAIL      AT TERMINAL NAD068
RBE1QC- TRANSACTION INVN      AT TERMINAL ISM001


So, here I have to add the date at the end of each record. For Eg: The output after processing should look like:
RBE1QC- TRANSACTION A2BA1     AT TERMINAL RBE0ZZ DAY 121 OF YEAR 2014
RBE1QC- TRANSACTION VEHN      AT TERMINAL RBE0Z1 DAY 121 OF YEAR 2014
RBE1QC- TRANSACTION VEHX      AT TERMINAL DWT05P DAY 121 OF YEAR 2014
RBE1QC- TRANSACTION MAIL      AT TERMINAL NAD068 DAY 121 OF YEAR 2014
RBE1QC- TRANSACTION INVN      AT TERMINAL ISM001 DAY 121 OF YEAR 2014
RBE1QC- TRANSACTION A2BA1     AT TERMINAL RBE0ZZ DAY 122 OF YEAR 2014
RBE1QC- TRANSACTION VEHN      AT TERMINAL RBE0Z1 DAY 122 OF YEAR 2014
RBE1QC- TRANSACTION VEHX      AT TERMINAL DWT05P DAY 122 OF YEAR 2014
RBE1QC- TRANSACTION MAIL      AT TERMINAL NAD068 DAY 122 OF YEAR 2014
RBE1QC- TRANSACTION INVN      AT TERMINAL ISM001 DAY 122 OF YEAR 2014



Can someone please assist me on how I can add the date at the end of each record. Any suggestions/help will be really helpful !


Thanks,
Viswa..

Re: Add text to each record using REXX.

PostPosted: Tue May 13, 2014 1:16 pm
by Blackthorn
What have you tried so far? It looks fairly straightforward.

Hint - have you read up on the DATE function in Rexx?

Re: Add text to each record using REXX.

PostPosted: Tue May 13, 2014 1:37 pm
by NicC
I would not bother with the date function. Simply read the dataset line by line. When the record type is RBE2221 save the portion that you want using SUBSTR. Do not write the record. Otherwise concatenate the saved string to each record before writing it.

Re: Add text to each record using REXX.

PostPosted: Tue May 13, 2014 1:44 pm
by Blackthorn
Good point. I must look at things more closely. :)