View previous topic :: View next topic
|
Author |
Message |
narasridhar
New User
Joined: 12 Oct 2006 Posts: 32 Location: India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
narasridhar
New User
Joined: 12 Oct 2006 Posts: 32 Location: India
|
|
|
|
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 |
|
|
narasridhar
New User
Joined: 12 Oct 2006 Posts: 32 Location: India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
narasridhar
New User
Joined: 12 Oct 2006 Posts: 32 Location: India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
narasridhar
New User
Joined: 12 Oct 2006 Posts: 32 Location: India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
narasridhar
New User
Joined: 12 Oct 2006 Posts: 32 Location: India
|
|
|
|
Thanks Frank it works successfully.
Thanks alot for your patience to give the detailed information on every thing |
|
Back to top |
|
|
saquib.ahsan
New User
Joined: 22 Sep 2008 Posts: 6 Location: Pune
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
|