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 

copying a portion of a file
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 10:18 am    Post subject: copying a portion of a file Reply with quote

Hello,

I have a report which has both the detailed records and the summary records. I want to copy the summary records along with the header into another file.

To give an idea, the report has,

Report-id Title Date
page-num
header1
header2
-----------------------------------------------------------------
detail1
detail2
detail3


-----------------------------------------------------------------
Report-id Title Date
page-num
header1
header2
------------------------------------------------------------------
Summary for report:

Summary1
Summary2

grand total

Now, I want to use sort, preferably syncsort, to write the summary portion of the report into another file.

What would the best way be? I am thinking on the lines,

1. get the line number of the record having 'Summary for report' - as this has a fixed position always. Lets say it is 'n'
2. subtract 5 lines to get the line number of the previous header record
3. use SKIPREC=n-5 or using STARTREC and ENDREC

I am not sure if I can do an arithmetic operation in the SKIPREC statement.

Any ideas as to how good this is? or any other alternatives?

Regards
Vallish
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 22, 2004 10:38 am    Post subject: Reply with quote

vallish,

Everything you asked for is achievable. Let me know the following details.

1. What is the LRECL & RECFM of the input file
2. What is the position of the string 'Summary for report'?
3. post a sample of input and expected output. I was confused with your logic of subtracting 5 from record number.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 10:53 am    Post subject: Reply with quote

1. LRECL = 132, RECFM=FB
2. The position of 'SUMMARY OF REPORT' is 1
3. Sample of input:

Quote:

RPT:00001 BANK AMOUNTS REPORT Date:22/7/2004
Page: 1
__________________________________________________________________
Bank Code: ABC
Bank Name: ABC Bank
__________________________________________________________________

Customer1 - 10000 USD
Customer2 - 20000 USD
Customer3 - 30000 USD
--------------------------------------------------------------------------------------------
RPT:00001 BANK AMOUNTS REPORT Date:22/7/2004
Page: 2
__________________________________________________________________
Bank Code: DEF
Bank Name: DEF Bank
__________________________________________________________________

Customer5 - 50000 USD
Customer1 - 500 USD
--------------------------------------------------------------------------------------------
RPT:00001 BANK AMOUNTS REPORT Date:22/7/2004
Page: 3
__________________________________________________________________
Bank Code:
Bank Name:
__________________________________________________________________
Summary for report
Customer 1 : 10500 USD
Customer 2 : 20000 USD
Customer 3 : 30000 USD
Customer 5 : 50000 USD
Total : 110500 USD
__________________________________________________________________


Expected output:

Quote:

RPT:00001 BANK AMOUNTS REPORT Date:22/7/2004
Page: 3
__________________________________________________________________
Bank Code:
Bank Name:
__________________________________________________________________
Summary for report
Customer 1 : 10500 USD
Customer 2 : 20000 USD
Customer 3 : 30000 USD
Customer 5 : 50000 USD
Total : 110500 USD
__________________________________________________________________


The solid lines '__' are present in the report and '----' indicates page breaks.

The reason why I thought of the logic to subtract 5 lines was, I want to copy the header record for that portion of the report too along with the summary details into the new file. Makes sense?

- Vallish
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 22, 2004 11:10 am    Post subject: Reply with quote

Valish,

The following JCL will give you the desired results. If you want the header record for the summary page, you actually need to subtract 6 from the record no: of "summary report"

A brief description of the job. The first copy operator takes in the input report file and adds a seqnum to all the records. This is the record no: of each record. Now using include on outfil we select the "summary report" record and create dynamic control cards.

The next copy step uses this dynamically created control card and copies the desired records to the output file.

Code:

//STEP0100 EXEC PGM=SYNCTOOL                   
//TOOLMSG   DD SYSOUT=*                       
//DFSMSG    DD SYSOUT=*                       
//IN        DD *                             
RPT:00001 BANK AMOUNTS REPORT DATE:22/7/2004 
PAGE: 1                                       
______________________________________________
BANK CODE: ABC                               
BANK NAME: ABC BANK                           
______________________________________________
CUSTOMER1 - 10000 USD                         
CUSTOMER2 - 20000 USD                         
CUSTOMER3 - 30000 USD                         
----------------------------------------------
RPT:00001 BANK AMOUNTS REPORT DATE:22/7/2004 
PAGE: 2                                       
______________________________________________
BANK CODE: DEF                               
BANK NAME: DEF BANK                           
______________________________________________
CUSTOMER5 - 50000 USD                         
CUSTOMER1 - 500 USD                           
----------------------------------------------
RPT:00001 BANK AMOUNTS REPORT DATE:22/7/2004 
PAGE: 3                                       
______________________________________________
BANK CODE:                                               
BANK NAME:                                               
______________________________________________
SUMMARY FOR REPORT                                       
CUSTOMER 1 : 10500 USD                                   
CUSTOMER 2 : 20000 USD                                   
CUSTOMER 3 : 30000 USD                                   
CUSTOMER 5 : 50000 USD                                   
TOTAL : 110500 USD                                       
______________________________________________
//TOOLIN    DD *                                         
  COPY FROM(IN)  USING(CTL1)                             
  COPY FROM(IN)  USING(CTL2)                             
//OUT       DD SYSOUT=*                                   
//CTL1CNTL  DD *                                         
  OUTREC FIELDS=(1,132,SEQNUM,8,ZD)                       
  OUTFIL FNAMES=CTL2CNTL,                                 
  INCLUDE=(1,18,CH,EQ,C'SUMMARY FOR REPORT'),             
  OUTREC=(C' OUTFIL FNAMES=OUT,STARTREC=',               
          +6,SUB,133,8,ZD,EDIT=(TTTTTTTT),80:X)           
//CTL2CNTL  DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
/*                                           


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 12:26 pm    Post subject: Reply with quote

Kolusu,

What does EDIT=(TTTTTTTT) mean?

However, I get this error on executing:
Quote:

CTL1CNTL :
OUTREC FIELDS=(1,132,SEQNUM,8,ZD)
OUTFIL FNAMES=CTL2CNTL,
INCLUDE=(1,18,C'SUMMARY FOR REPORT'),
*
OUTREC=(C' OUTFIL FNAMES=OUT,STARTREC=',+6,SUB,133,8,ZD,
EDIT=(TTTTTTTT),80:X)
WER428I CALLER-PROVIDED IDENTIFIER IS "0001"
WER251A INCL INVALID COND
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE


- Vallish
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 12:34 pm    Post subject: Reply with quote

Sorry! I found the mistake with the INCLUDE statement. I corrected that.
Now I get an error with OUTFIL statement,
Quote:

CTL1CNTL :
OUTREC FIELDS=(1,132,SEQNUM,8,ZD)
OUTFIL FNAMES=CTL2CNTL,
INCLUDE COND=(1,18,C'SUMMARY FOR REPORT'),
*
OUTREC=(C' OUTFIL FNAMES=OUT,STARTREC=',+6,SUB,133,8,ZD,
*
EDIT=(TTTTTTTT),80:X)
*
WER428I CALLER-PROVIDED IDENTIFIER IS "0001"
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER269A OUTREC STATEMENT : DUPLICATE STATEMENT FOUND
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE


Can I not edit my post? I wanted to delete the earlier reply.
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 22, 2004 1:07 pm    Post subject: Reply with quote

valishar,

The problem with your include cond is that you don't have the format and the relational operator.

The format is CH & and the relational operator is EQ. So your INCLUDE cond should be as follows:
Code:

INCLUDE=(1,18,CH,EQ,C'SUMMARY FOR REPORT'),


Quote:

What does EDIT=(TTTTTTTT) mean?


That is an EDIT mask. After performing the arthimetic operation , I want the result to be 8 bytes in length and I want every byte to be printed.

Look at the control cards in my job. The job I posted runs without any errors.So try running that job.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 1:33 pm    Post subject: Reply with quote

Kolusu,

The job runs fine, but it is copying all the records into the output.
RECFM=FBA, LRECL=133.

regards
Vallish
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 22, 2004 1:42 pm    Post subject: Reply with quote

vallishar,

In your previous post you mentioned that your input file is FB and is 132 bytes in length.

Now you are saying that it is FBA and the LRECL is 133. If that is the case then the string "summary report" actually starts from pos 2. so change your include condition to
Code:

INCLUDE=(2,18,CH,EQ,C'SUMMARY FOR REPORT'),


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 1:49 pm    Post subject: Reply with quote

Thanks Kolusu. It works.

I am still not very clear about the second OUTREC. Can you please explain?

Quote:

OUTREC=(C' OUTFIL FNAMES=OUT,STARTREC=',
+6,SUB,133,8,ZD,EDIT=(TTTTTTTT),80:X)



If I have to use DFSORT instead of SYNCSORT what changes should i do?

Many thanks,
Vallish
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 1:51 pm    Post subject: Reply with quote

Also, In the output can I replace the PAGE:3 to page:1 by overriding it?
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 22, 2004 2:03 pm    Post subject: Reply with quote

vallish,

Quote:

I am still not very clear about the second OUTREC. Can you please explain?


Sure can.We are creating a dynamic control card CTL2CNTL. let us say we have a file of 100 records and we want to copy from 50 record onwards. For achieving this we Usually code(one of the n number of ways)
Code:

  OUTFIL STARTREC=50


I am doing the same over here also. I am just writting to a DD name OUT. once we found the record no(with include cond), we are subtracting 6 from the record no.

80:X is used to pad spaces to the 80th byte after writting the other outrec fields.

So basically the output will look like this
Code:

  OUTFIL FNAMES=OUT,STARTREC=00000020


C' OUTFIL FNAMES=OUT,STARTREC=', means write a text of OUTFIL FNAMES=OUT,STARTREC

+6,SUB,133,8,ZD means subtract 6 from the value at 133 which is of 8 bytes long and

EDIT=(TTTTTTTT) means print out the result after the arthimetic operation is complete

80:X) means pad spaces to the 80th byte.

Quote:

If I have to use DFSORT instead of SYNCSORT what changes should i do?


All you need is to change the pgm name to ICETOOL

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 2:08 pm    Post subject: Reply with quote

Thanks for the detailed explanation.

1. Why should it be 80 bytes in the control card, though we are having the record length as 133?

2. I want to over-ride the page number to show as 1 always, as this is a one page report. What change should I do?

Regards
Vallish
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 22, 2004 2:22 pm    Post subject: Reply with quote

Vallish,

Quote:
Also, In the output can I replace the PAGE:3 to page:1 by overriding it?


Sure can. we use CHANGE parm to change the page number. if the position 2 has the value of PAGE we change the value in the bytes 7 thru 4. I assumed the page number can go upto a max of 9999 pages. Change your control cards to the following.

Code:

//CTL1CNTL  DD *                                               
  OUTREC FIELDS=(1,133,SEQNUM,8,ZD)                             
  OUTFIL FNAMES=CTL2CNTL,                                       
  INCLUDE=(2,18,CH,EQ,C'SUMMARY FOR REPORT'),                   
  OUTREC=(C' OUTFIL FNAMES=OUT,STARTREC=',                     
          +6,SUB,134,8,ZD,EDIT=(TTTTTTTT),C',',80:X)           
//CTL2CNTL  DD DSN=&C1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)     
//          DD *                                               
  OUTREC=(1,6,7:2,4,CHANGE=(4,C'PAGE',C' 1  '),                 
          NOMATCH=(7,4),11,123)                                 
/*                                                             


Quote:
Why should it be 80 bytes in the control card, though we are having the record length as 133?


The SYSIN data set(control cards) usually resides in the input stream; however, it can be defined as a sequential data set or as a member of a partitioned data set.

The data set must be defined with a RECFM of F or FB. The LRECL can be 80, or more (when valid). If the LRECL is greater than 80, DFSORT will use the first 80 bytes of each record.

check this link which explains in detail about the control cards(sysin) dataset

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA00/2.4.3?SHELF=&DT=20031124143823&CASE=


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Thu Jul 22, 2004 3:57 pm    Post subject: Reply with quote

Kolusu,

Thanks again. I was getting an error message when i used the OUTREC statement after making some changes for the position.
Quote:

CTL2CNTL :
OUTFIL FNAMES=OUT,STARTREC=00000002
OUTREC=(1,114,115,5,CHANGE=(13,C'PAGE:',C'PAGE: 1'),
*
NOMATCH=(115,13),128,4)
*
WER428I CALLER-PROVIDED IDENTIFIER IS "0002"
WER268A OUTREC STATEMENT : SYNTAX ERROR


I changed it to,
OUTREC FIELDS=(1,114,115,5,CHANGE=(13,C'PAGE:',C'PAGE: 1'),
NOMATCH=(115,13),128,4)
since the position of the page was at 115.

What difference will it make if we use or don't use the FIELDS parameter?
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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