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
 

 

SYNCSORT Squeezing the count in trailer record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Sat Apr 23, 2011 3:23 pm    Post subject: SYNCSORT Squeezing the count in trailer record
Reply with quote

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
View user's profile Send private message

kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Mon Apr 25, 2011 3:09 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Apr 25, 2011 3:52 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Mon Apr 25, 2011 5:03 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Apr 25, 2011 5:12 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Apr 25, 2011 5:17 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Mon Apr 25, 2011 6:44 pm    Post subject:
Reply with quote

Hi Anuj,

It was for you. icon_smile.gif

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. icon_lol.gif )
Back to top
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Mon Apr 25, 2011 7:15 pm    Post subject: Reply to: SYNCSORT Squeezing the count in trailer record
Reply with quote

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 icon_sad.gif

Thanks for your help again.

Regards,
Ram.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Tue Apr 26, 2011 12:38 am    Post subject:
Reply with quote

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
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Tue Apr 26, 2011 6:58 am    Post subject: Reply to: SYNCSORT Squeezing the count in trailer record
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Tue Apr 26, 2011 8:38 am    Post subject:
Reply with quote

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
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Tue Apr 26, 2011 11:49 am    Post subject:
Reply with quote

Arun,

OP is trying to correct what he mentioned wrongly in the intial post thinking we might misunderstand it icon_wink.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Apr 26, 2011 6:12 pm    Post subject: Re: Reply to: SYNCSORT Squeezing the count in trailer recor
Reply with quote

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.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Apr 26, 2011 6:20 pm    Post subject:
Reply with quote

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!
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Apr 27, 2011 7:19 am    Post subject:
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Apr 27, 2011 1:53 pm    Post subject:
Reply with quote

I picked up the sort he shows in his first post and showed a way for the given example, well.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Apr 27, 2011 10:11 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Apr 29, 2011 1:46 pm    Post subject:
Reply with quote

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
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Tue May 10, 2011 4:19 pm    Post subject: Thanks
Reply with quote

Thanks Arun.

Your solution worked great.

Regards,
Ram.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed May 11, 2011 4:44 pm    Post subject:
Reply with quote

You're welcome. icon_smile.gif
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Syncsort - NULL in Integer field chec... nartcr SYNCSORT 4 Thu Oct 06, 2016 6:47 am


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