|
View previous topic :: View next topic
|
| Author |
Message |
vinothsubramanian
New User
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.
Kindly help me out with this requirement.
JCL:
| Code: |
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
10
20
30
40
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,TRAILER1=(C'COUNT:',COUNT),FTOV,VLTRIM=X'40'
/*
|
Output Received:
| Code: |
10
20
30
40
COUNT: 4
|
Expected Output:
| Code: |
10
20
30
40
COUNT:4
|
Thanks for your help.
Regards,
Ram. |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
There is no provision to make them left justified, But it can be done outside through another card
| Code: |
OUTREC IFTHEN=(WHEN=(1,6,CH,EQ,C'COUNT:'),
BUILD=(1,6,8,8,SQZ=(SHIFT=LEFT))) |
|
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
COUNT is a number which will be a right-justified 8-digit field with leading zeros suppressed. To get what you need, use some edit mask like:
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,TRAILER1=(C'COUNT:',COUNT=(M11,LENGTH=1)),FTOV,
VLTRIM=X'40'
/* |
|
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Quote: |
| To get what you need, use some edit mask like: |
Hi Anuj,
I am n't sure of what the OP is trying to "gain" by left shifting the trailer count. But do you think the above code will do it? |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi Arun,
With SYNCSORT FOR Z/OS 1.3.2.2R:
| Code: |
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
10
20
30
40
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,TRAILER1=(C'COUNT:',COUNT=(M11,LENGTH=1)),FTOV,
VLTRIM=X'40'
/* |
SORTOUT:
| Code: |
Display Filter View Print Options Help
-------------------------------------------------------------------------------
SDSF OUTPUT DISPLAY Qanuj JOB21023 DSID 105 LINE 0 COLUMNS 02- 81
COMMAND INPUT ===> SCROLL ===> CSR
********************************* TOP OF DATA **********************************
10
20
30
40
COUNT:4
******************************** BOTTOM OF DATA ******************************** |
I don't really question about "gains" these days -- for this thread, may be, that's needed for representation purpose, in some report. |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| Quote: |
| do you think the above code will do it |
A lon....g pose -- by "above" you really expected me to reply back or was it for kratos86? |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 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. ) |
|
| Back to top |
|
 |
vinothsubramanian
New User
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 used the following code in my SYSIN:
| Code: |
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
11, A07, C007
12, A08, C008
13, A09, CD009
10, A10, C010
10, A11, CD011
10, A12, CD012
10, A13, CD013
20, A14, CD014
30, A15, CD015
40, A16, CD016
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(2,1,ZD,NE,0),FTOV,VLTRIM=X'40',
BUILD=(1,80,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),
REMOVECC,TRAILER1=(C'9,',COUNT+1=(M10,LENGTH=18))
OUTFIL FILES=02,INCLUDE=(2,1,ZD,EQ,0),FTOV,VLTRIM=X'40',
BUILD=(1,80,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),
REMOVECC,TRAILER1=(C'9,',COUNT+1=(M10,LENGTH=18))
/* |
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
Thanks for your help again.
Regards,
Ram. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| vinothsubramanian wrote: |
| I used the following code in my SYSIN: |
Are you saying that you used this code to achieve what you wanted?.
Also the sample input shown above does not seem to have any 'quote's in it. Then why do you need a "PAIR=QUOTE"? |
|
| Back to top |
|
 |
vinothsubramanian
New User
Joined: 01 Sep 2006 Posts: 39 Location: Chennai, India
|
|
|
|
Hi Arun,
Sorry for not clearing that up. Still I couldn't achieve the original requirement i.e., squeezing the count in trailer record.
| Quote: |
| Are you saying that you used this code to achieve what you wanted?. |
That is the JCL I used and not SYSIN
| Quote: |
| Then why do you need a "PAIR=QUOTE"? |
I have provided only few records of the input file. The actual input file can have Quotes surrounding the column value with spaces in it.
Thanks.
Ram. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 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.
| Quote: |
| That is the JCL I used and not SYSIN |
Sorry..what did you mean by this? |
|
| Back to top |
|
 |
kratos86
Active User

Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
Arun,
OP is trying to correct what he mentioned wrongly in the intial post thinking we might misunderstand it  |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

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
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. |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

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
. 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! |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 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. |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| I picked up the sort he shows in his first post and showed a way for the given example, well. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| I think an additional pass solution shown by kratos86 to have the count left justified might help the OP to achieve what he wants. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 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
| Code: |
//STEP01A EXEC PGM=SORT
//SORTIN DD DSN= Input file (FB/LRECL=80)
//SYSOUT DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(2,1,ZD,NE,0),
OVERLAY=(81:SEQNUM,10,PD,START=2,
81:81,10,PD,M10,LENGTH=18),HIT=NEXT),
IFTHEN=(WHEN=(2,1,ZD,EQ,0),
OVERLAY=(99:SEQNUM,10,PD,START=2,
99:99,10,PD,M10,LENGTH=18),HIT=NEXT),
IFTHEN=(WHEN=ANY,
BUILD=(1,80,SQZ=(SHIFT=LEFT,PAIR=QUOTE),
81:C'9,COUNT:',81,18,SQZ=(SHIFT=LEFT),
107:99,18,SQZ=(SHIFT=LEFT)))
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(2,1,ZD,NE,0),FTOV,
BUILD=(1,80),REMOVECC,TRAILER1=(81,26)
OUTFIL FILES=02,INCLUDE=(2,1,ZD,EQ,0),FTOV,
BUILD=(1,80),REMOVECC,TRAILER1=(81,8,107,18)
/* |
|
|
| Back to top |
|
 |
vinothsubramanian
New User
Joined: 01 Sep 2006 Posts: 39 Location: Chennai, India
|
|
|
|
Thanks Arun.
Your solution worked great.
Regards,
Ram. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
You're welcome.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|