Joined: 01 Sep 2006 Posts: 39 Location: Chennai, India
Hi,
I am using the following JCL to create a VB file with trailer record giving the count of records in the input file. Is there any way to squeeze the trailer count to be left justified instead of right justified. I have given the JCL, output and expected output below.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Hi Anuj,
It was for you.
You have the number of digits in the counter = 1 and there's no question of justification since we have only one digit. But it will not really left-justify the trailer count on real input data, will it?
Let me know if I got this wrong.(I have n't been here for a while. )
Joined: 01 Sep 2006 Posts: 39 Location: Chennai, India
Hi,
Anuj thanks for your reply.
I tried your solution. However it didn't work when the number of records crossed 9. When I gave input file with 10 records the output was "0". Obviously that's because we gave the length as 1 for count.
I hope I will clear Arun's question on "Gains". To explain in detail, the requirement is:
1. Split the input file into two files
2. Convert into CSV files by Squeezing the records and write them to VB files
3. Add trailer record to the output files based on the count on each file. And in trailer we wanted to remove the leading zeroes and store them left justified in the trailer record as it is a CSV file.
I hope I am clear and logical now. I know that it is unnecessary to remove leading zeroes, however that is how the downstream system expects the file from us
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
vinothsubramanian wrote:
The actual input file can have Quotes surrounding the column value with spaces in it.
Though it does n't seem to have an effect on your particular requirement, it would always be better to provide all the processing rules and nature of your "real" input in the initial post itself rather than after somebody posting a solution based on your input and then you complain about the solution not working on your "real" input.
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
vinothsubramanian wrote:
I tried your solution. However it didn't work when the number of records crossed 9. When I gave input file with 10 records the output was "0". Obviously that's because we gave the length as 1 for count.
Well, code works for the example records you show.
If you anticipate the count for records will go in two-digits, use length=2. As I said ealier, COUNT is a number which will be a right-justified 8-digit field with leading zeros suppressed. In your very first example, you showed just four-records in input - the count appeared at 8th position as
Code:
#######4
where # stand for suppressed zeros. So, if you insist to use COUNT and records'-count can go up to 2-digits, use LENGTH=2. If records'-count can go up to 3-digits, use LENGTH=3 and so on.
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
Arun Raj wrote:
You have the number of digits in the counter = 1 and there's no question of justification since we have only one digit. But it will not really left-justify the trailer count on real input data, will it?
My perception about the problem is - OP wants to count the number of input reocrds and that count should appear in the last record of output just after the colon in
Quote:
COUNT:
. So there is no "trailer", for me, in the input to start with.
I do not left justify any number - instead if the count is 0-9, use LENGTH=1, if the count is 10-99, use LENGHT=2...etc. It'll appear, as the human eyes of OP wants to!
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Anuj,
Here the requirement from my understanding is to have the count in the trailer(of course we need to include the trailer and it is not present in input) JUSTIFIED LEFT.
Quote:
I do not left justify any number - instead if the count is 0-9, use LENGTH=1, if the count is 10-99, use LENGHT=2
In general we can only assume the maximum number of input records coming in and we may not be varying the length based on the input count, say for the OP he fixes it as 999999.
On a given day, if the count happens to be less than 6 digits, the trailer in your output will have leading zeros which the OP does not seem to be interested in.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
vinothsubramanian,
The below Syncsort job does what you want to achieve, without an additional data pass to left shift the trailer count.
I have assumed the input to be FB/LRECL=80. SORTOF01/SORTOF02 will be of VB/LRECL=84