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 

Concatenate Header & Trailer

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Fri Sep 16, 2005 6:53 pm    Post subject: Concatenate Header & Trailer Reply with quote

Hai,

I am executing a COBOL-DB2 program wherein i am generating a output file by name UNIT.ABCD.OUTPUT.G in a GDG version.Moreover i am also assining values to HEADER and TRAILER datasets in my program at runtime.I would like to have in my output file first the header dataset to be printed,second the output file to be printed and then the trailer dataset like this:.Can anybody guide me if i am correct or not as i want to have that satisfied in STEP001 only instead of using one more step using IEBGENER to concatinate the datasets?

HEADER DATASET
OUTPUT DATASET
TRAILER DATASET

Code:

For example :  UNIT.ABCD.OUTPUT.G(+1)
------------
********************************* Top of Data **********************************
00000ABCD   HDR      TOP                     SHELL                                             
RAM         24
ANIL        18
MAHESH      46
ANDY        67
00000ABCD   TRL      BOT                     SHELL
********************************* Bottom of Data *******************************



My JCL
------
Code:

//STEP001  EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSABOUT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//HEADER   DD DSN=UNIT.ABCD.HEADER,DISP=SHR
//TRAILER  DD DSN=UNIT.ABCD.TRAILER,DISP=SHR
//ABCD     DD DSN=UNIT.ABCD.OUTPUT.G(+1),
//            DISP=(,CATLG),UNIT=SYSDA,
//            SPACE=(CYL,(10,10),RLSE),DCB=(LRECL=80,RECFM=FB)
//SYSTSIN  DD *
 DSN SYSTEM(DSNP)
 RUN PROGRAM(ABCD) PLAN(ABCD)
 END
/*
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Sat Sep 17, 2005 12:30 am    Post subject: Reply with quote

Shekar123,

I am not clear with your request. Let me know if my understanding is correct.

1. You are writing some data to your output file which is a GDG.
2. You want to include header and trailer records into that.
3. The Header and Trailer records are stored in two files UNIT.ABCD.HEADER and UNIT.ABCD.TRAILER.

Your question:
Can we write these header / trailer records into the output file in STEP01 or do we need to add a new IEBGENER/SORT step to concatenate these ?

Assuming this is your question, the answer will be - YES - you can achieve this in STEP01 ifself. Provided you need to change your program 'ABCD' a bit.

1. Before writing any records the output file, read your header file and write its contents to your output GDG. This will become the first record.

2. Read your database and generate DETAIL records.

3. Just before closing your output GDG, read the contents of TRAILER file and write them to your output file.

Does this solve your problem?

Thanks,
Phantom
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Sat Sep 17, 2005 12:21 pm    Post subject: Concatinate Header and Trailer Reply with quote

Hai,

Thanks for your reply,but your understanding is not correct .Basically i want to write data to a file which is a GDG.But in the GDG,first i want to write the header record which i have declared as a file , then the details records , then the trailer rec which also i have decalared as a file.The reason behind why i want to do this is ,i want to assign some values to both header record and trailer record in program execution.

With my JCL i can execute my program and generate the output routed to a simple GDG file without header and trailer and in the second step i can concatinate all of them three( header + detail + trailer ) and copy it to one more GDG.But i do not want to use two steps ,i want to use only one step which will execute the program and generate the ouput file in GDG with Header and trailer basically i want to avoid concatination step.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Sun Sep 18, 2005 4:36 am    Post subject: Reply with quote

Shekar123,

Quote:

With my JCL i can execute my program and generate the output routed to a simple GDG file without header and trailer and in the second step i can concatinate all of them three( header + detail + trailer ) and copy it to one more GDG.


I have few more questions.

1. Are you reading / updating the contents of Header & Trailer files. If not, what is the reason behind giving them as input to your program ?

2. Do you really need to GDGs ? one without header/trailer and other with header-detail-trailers

3. Do you have the authorization to change your COBOL program ? if Yes, then as I said earlier, why don't you change the program and read your Header/Trailer datasets and write their contents to your output GDG along with the detail records ?

Thanks,
Phantom
Back to top
View user's profile Send private message
Bill Dennis
Advanced


Joined: 03 Dec 2002
Posts: 579
Topics: 1
Location: Iowa, USA

PostPosted: Mon Sep 19, 2005 4:20 pm    Post subject: Re: Concatenate Header & Trailer Reply with quote

Try using REPRO to copy the header and trailer. Also, change the DISP on
OUTPUT to DISP=(MOD,CATLG)

------
Code:

//STEP001  EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSABOUT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//HEADER   DD DSN=UNIT.ABCD.HEADER,DISP=SHR
//TRAILER  DD DSN=UNIT.ABCD.TRAILER,DISP=SHR
//ABCD     DD DSN=UNIT.ABCD.OUTPUT.G(+1),
//            DISP=(MOD,CATLG),UNIT=SYSDA,
//            SPACE=(CYL,(10,10),RLSE),DCB=(LRECL=80,RECFM=FB)
//SYSTSIN  DD *
 REPRO INFILE(HEADER) OUTFILE(ABCD) 
 DSN SYSTEM(DSNP)
 RUN PROGRAM(ABCD) PLAN(ABCD)
 REPRO INFILE(TRAILER) OUTFILE(ABCD) 
 END
/*

_________________
Regards,
Bill Dennis

Disclaimer: My comments on this foorum are my own and do not represent the opinions or suggestions of any other person or business entity.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Sep 20, 2005 12:47 am    Post subject: Reply with quote

Bill,

This is a really good solution !!!

Shekar123,

This should be the simplest way to achieve your goal.

Thanks,
Phantom
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 -> Job Control Language(JCL) 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