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
 

 

Header and Footer inclusion in a data file through SORT

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

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Fri Oct 31, 2008 3:52 am    Post subject: Header and Footer inclusion in a data file through SORT
Reply with quote

Can some one help the way for writing the data records in a file as shown below by using the SORt card?

Header record1
Header record2
Header record3
Data record 1
Data record 2
;
;
; These data records can be vary on each time. These records to include in this file each time.
;
etc
Footer record1
Footer record2

Is any of doing this through SORT
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Oct 31, 2008 4:21 am    Post subject:
Reply with quote

It's not clear what you want to do. Does your input file have just the data records? Or does your input file have the header, data and trailer records?

Do you want to add the header and trailer records? Or do you want to replace the header and trailer records? Or do you want to keep the header and trailer records where they are and sort the data records?

You need to do a better job of explaining your requirement. Show an example of the input records and what you expect for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of any relevant fields.
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Fri Oct 31, 2008 4:28 am    Post subject: Reply to: Header and Footer inclusion in a data file through
Reply with quote

I have a file with the header and footer records which is same all the times. I need to amend the data records as a result of output from the data file. the number of data records vary each time.
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Fri Oct 31, 2008 4:41 am    Post subject: Reply to: Header and Footer inclusion in a data file through
Reply with quote

Please find the two files as input and ouput
-------------------------------------------------

Input file1:
----------
123456
123456
123456

Input file2:
-------------
This is header1
This is header 2


This is footer1
This is footer2



i am output file as below:
----------------------------
This is header1
This is header 2

123456
123456
123456


This is footer1
This is footer2

The data records are variable length records.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Oct 31, 2008 4:56 am    Post subject:
Reply with quote

We're getting closer.

So you want to insert the two header records (records 1 and 2) from input file2 before the data records from input file1, and you want to insert the two footer records (records 3 and 4) from input file2 after the data records from input file1 - right?

Quote:
The data records are variable length records.


You mean input file 1 has RECFM=VB - right?

Does input file2 have RECFM=VB as well, or does it have RECFM=FB? If it has RECFM=FB what is it's LRECL?

Is there anything in the header records that identify them as header records (e.g. first character is '0')? Is there anything in the footer records that identify them as footer records (e.g. first character is '9')?
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Fri Oct 31, 2008 5:07 am    Post subject:
Reply with quote

Frank Yaeger wrote:
We're getting closer.

So you want to insert the two header records (records 1 and 2) from input file2 before the data records from input file1, and you want to insert the two footer records (records 3 and 4) from input file2 after the data records from input file1 - right?

Yes

Quote:
The data records are variable length records.


You mean input file 1 has RECFM=VB - right? Yes

Does input file2 have RECFM=VB as well, or does it have RECFM=FB? If it has RECFM=FB what is it's LRECL?

It is also VB the same as inputfile1.


Is there anything in the header records that identify them as header records (e.g. first character is '0')? Is there anything in the footer records that identify them as footer records (e.g. first character is '9')?


Nothing to identify the header or footer. But i can say that the header and footer is always with the charecters but where as data records are always start with numbers.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Oct 31, 2008 5:56 am    Post subject:
Reply with quote

Ok, I think I have all the information I need now. It's quitting time here. I'll give you a solution tomorrow.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Oct 31, 2008 8:59 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. Be sure to use a MOD data set for //OUT.

Code:

//S1   EXEC  PGM=ICETOOL                                         
//TOOLMSG   DD  SYSOUT=*                                         
//DFSMSG    DD  SYSOUT=*                                         
//DATA DD DSN=...  input file1 (data)                             
//HT DD DSN=...  input file2 (headers/trailers)     
//**>> Use MOD for //OUT                         
//OUT DD DISP=MOD,DSN=...  output file   
//TOOLIN DD *                                                   
COPY FROM(HT) TO(OUT) USING(CTL1)                               
COPY FROM(DATA) TO(OUT)                                           
COPY FROM(HT) TO(OUT) USING(CTL2)                               
/*                                                               
//CTL1CNTL DD *                                                 
  OPTION STOPAFT=2     
/*                                         
//CTL2CNTL DD *                                                 
  OPTION SKIPREC=2                                               
/*
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Fri Oct 31, 2008 10:33 pm    Post subject:
Reply with quote

Pleae find the my code it was copying correctly BUT the header records are copying again after the data records and the finally it is displaying the footer record. We need to avoid the header record coying after the data records. Please find my code below

Code:

//TOOLIN DD *                   
COPY FROM(HT) TO(OUT) USING(CTL1)
COPY FROM(DATA) TO(OUT)         
COPY FROM(HT) TO(OUT) USING(CTL2)
/*                               
//CTL1CNTL DD *                 
  OPTION STOPAFT=16             
/*                               
//CTL2CNTL DD *                 
  OPTION SKIPREC=4               
/*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Oct 31, 2008 10:47 pm    Post subject:
Reply with quote

I don't understand. You showed me a specific example with two header records and two footer records. I asked you specifically if you wanted to treat record 1 and 2 as the header records and records 3 and 4 as the footer records and you said YES. So I showed you the job for that SPECIFIC SITUATION using STOPAFT=2 and SKIPREC=2. Now you've changed the job to use STOPAFT=16 and SKIPREC=4 and you don't understand why it doesn't work. Unbelievable!

STOPAFT=2 and SKIPREC=2 works for two header records (and any number of footer records) - that's the requirement we discussed, so I gave you the solution for that situation.

If you actually have a different number of header records, then why didn't you tell me that? For the general solution, you need STOPAFT=n and SKIPREC=n where n is the number of header records. For example, if you have 16 header records, then you'd use STOPAFT=16 (stop after the 16 header records) and SKIPREC=16 (skip the 16 header records).
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Sat Nov 01, 2008 2:05 am    Post subject: Reply to: Header and Footer inclusion in a data file through
Reply with quote

Thanks Frank it works successfully.

Thanks alot for your patience to give the detailed information on every thing icon_cool.gif
Back to top
View user's profile Send private message
saquib.ahsan

New User


Joined: 22 Sep 2008
Posts: 6
Location: Pune

PostPosted: Fri Jan 16, 2009 3:12 am    Post subject:
Reply with quote

I have a problem wherein i need to insert multiple line header before the actual data. Let me explain it further, and then come back to the question:

File1 (FixedBlock):
Data record1
Data record2

Each record has the following format
Date <2 spaces> count

I need to append a header as below:
Date <2 spaces> Number of breaks

I can add the header using OUTFIL HEADER1 and then append the data using OUTREC, but since the second field in the header is large, i want it in the following format:
Date <2 spaces> Number of
breaks
i.e. i want the header on two rows
Can someone help me out on this. I do not want to hard code the header format in a file and then merge the two files. Can it be done using OUTFIL HEADER1 options?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jan 16, 2009 3:17 am    Post subject:
Reply with quote

Please post this as a new Topic. If you want a DFSORT solution, post it in the DFSORT Forum. Otherwise, post it in the JCL Forum. Show an example of the records in the input file (relevent fields only) and what you expect for output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of each relevant field.
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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


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