MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Counting and appending a constant

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
rajvasan
Beginner


Joined: 10 Dec 2002
Posts: 14
Topics: 4

PostPosted: Fri Dec 20, 2002 1:06 am    Post subject: Counting and appending a constant Reply with quote

Dear All,
I have a doubt. Say, I have a 1000 records. Now, can I append a constant, say at the end of every 50 records. Hence, there would be a constant at the 50th, 100th, 150th records and so on... Is it possible ???

With Best Regards,
Rajvasan
Back to top
View user's profile Send private message
Premkumar
Moderator


Joined: 28 Nov 2002
Posts: 77
Topics: 7
Location: Chennai, India

PostPosted: Fri Dec 20, 2002 1:20 am    Post subject: Reply with quote

You can do that using Sort.

  1. Append 2 digit SEQNUM to all the records using INREC.
  2. Append the constant for the records that have 00 or 50 in the SEQNUM column, using OUTREC.
  3. Remove the SEQNUM column using OUTFIL OUTREC.
Back to top
View user's profile Send private message Send e-mail
rajvasan
Beginner


Joined: 10 Dec 2002
Posts: 14
Topics: 4

PostPosted: Fri Dec 20, 2002 2:47 am    Post subject: Reply with quote

Prem,
Thanks for the quick reply. But as per what you said, I need to code about 20 outrec statements (for 1000 records) . Is there any method to do it ??

With Best Regards,
Rajvasan
Back to top
View user's profile Send private message
Premkumar
Moderator


Joined: 28 Nov 2002
Posts: 77
Topics: 7
Location: Chennai, India

PostPosted: Fri Dec 20, 2002 4:39 am    Post subject: Reply with quote

Raj,

You need not code 20 outrec statements. Your sort control cards for FB80 file will be,
Code:

OPTION COPY                                       
INREC  FIELDS=(SEQNUM,2,ZD,1,80)                   
OUTREC FIELDS=(3,80,1,2,CHANGE=(5,C'00',C'12345',
                                  C'50',C'12345'),
                       NOMATCH=(C'     '))       


I coupled removing the SEQNUM with OUTREC itself.
Your output file will be FB85 with every 50th record having '12345' appended and other records having 5 blanks appended.

Hope this helps.
Back to top
View user's profile Send private message Send e-mail
Premkumar
Moderator


Joined: 28 Nov 2002
Posts: 77
Topics: 7
Location: Chennai, India

PostPosted: Fri Dec 20, 2002 4:50 am    Post subject: Reply with quote

In case, you don't want Syncsort throwing the message,
WER238I POTENTIALLY INEFFICIENT USE OF INREC
modify the sort control statements as follows.
Code:

OPTION COPY                                       
OUTREC FIELDS=(SEQNUM,2,ZD,1,80)                 
OUTFIL OUTREC=(3,80,1,2,CHANGE=(5,C'00',C'12345',
                                  C'50',C'12345'),
                        NOMATCH=(C'     '))       
Back to top
View user's profile Send private message Send e-mail
rajvasan
Beginner


Joined: 10 Dec 2002
Posts: 14
Topics: 4

PostPosted: Fri Dec 20, 2002 9:20 am    Post subject: Reply with quote

Prem,
Thanks once again for a prompt reply. Suppose the no of records go up to say 1000,000 how do we go about solving this problem

Thanks,
Rajvasan
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Fri Dec 20, 2002 9:37 am    Post subject: Reply with quote

Rajvasan,

Premkumar's solution will work for any number of records.The solution has to be changed only when you need it for some other sequence.Right now you are changing every 50th record to have a constant value.If tommorrow you decide to change it to every 25th record , then you need to change the control cards as follows:

Code:

 OPTION COPY                                       
 OUTREC FIELDS=(SEQNUM,2,ZD,1,10)                       
 OUTFIL OUTREC=(3,10,1,2,CHANGE=(5,C'00',C'12345',       
                                  C'25',C'12345',       
                                  C'50',C'12345',       
                                  C'75',C'12345'),     
                         NOMATCH=(C'     '))             


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rajvasan
Beginner


Joined: 10 Dec 2002
Posts: 14
Topics: 4

PostPosted: Fri Dec 20, 2002 9:55 am    Post subject: Reply with quote

Kolusu/Prem,
I understand the reply that you both have given me. But, for a lot of records, I have to go ahead coding the outrec as below

Code:

OPTION COPY                                       
OUTREC FIELDS=(SEQNUM,2,ZD,1,10)                       
OUTFIL OUTREC=(3,10,1,2,CHANGE=(5,C'00',C'12345',       
                                  C'25',C'12345',       
                                  C'50',C'12345',       
                                  C'75',C'12345',       
                                  C'100',C'12345',       
                                  ................
                                  C'10000',C'12345'),
                                 NOMATCH=(C'     '))             


I would like to another if there is any other way than this ???

Best Regards,
Rajvasan

[/code]
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Fri Dec 20, 2002 10:07 am    Post subject: Reply with quote

Rajvasan,

You don't have to code all the control cards as you showed.Since the seqnum is only 2 bytes,it will start over once again from 01 after every 100 records.To explain this clearly , let us say your file has 250 records.
so the seqnum will be

Code:

01
02
...
50
...
00   - 100th record
01   - 101 record
...

50   - 150th record
....
00   - 200th record
01   - 201 record   
..
50   - 250th record



So the seqnum keeps starting from 1 for every 100 records.This is applicable for 'n' no: of records in your input file.Since we want to change only multiples of 50, all we need is to change control cards for records which has seqnum 00 & 50

50 - 50th record
00 - 100th record

Hope this helps....

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rajvasan
Beginner


Joined: 10 Dec 2002
Posts: 14
Topics: 4

PostPosted: Sat Dec 21, 2002 5:38 am    Post subject: Reply with quote

Kolusu/Prem
Thanks a lot guys for your help

With Best Regards,
Rajvasan
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group