IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to use input file in cobol with 2 diffrent layout


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
trumpcards
Warnings : 1

New User


Joined: 03 Jul 2006
Posts: 11

PostPosted: Fri Apr 18, 2008 12:56 pm
Reply with quote

There are 2 different JCLs which uses the same COBOL program. But The input file length is different in two jcls. How can we define and use in the COBOL program.

EX:

JCL1 has input file of 650 length and JCL2 has 750 length. Output file lenths are same. These 2 jCls have to call the same program. How can we define and use in the COBOL program.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Fri Apr 18, 2008 2:57 pm
Reply with quote

Hi,


This can be handled using PARM of JCl

you have to define SELECT statement for both of th file means for input files having length 650 and 750,

so when you are executing program with input file length 650 code as below.

JCL1

Code:
// JOB CARD
//STEP1 EXEC PGM = COBOLPGM, PARM = '1'
//INFILE1  DD  DSN = DATA.SET.NAME(650 LENGTH), DISP=SHR
//OUPUT    DD  DSN = OUT.PUT.DATA(SAME LENGTH), DISP=SHR
//SYSIN    DD  DUMMY
//SYSOUT   DD  SYSOUT=*
//SYSPRINT DD  SYSOUT=*


You can handle the PARM value in cobol program if PARM value is 1, open the dataset having length 650 and process write the output file.

If ur executing a program with input file having length 750

JCL2

Code:

// JOB CARD
//STEP1 EXEC PGM = COBOLPGM, PARM = '2'
//INFILE1  DD  DSN = DATA.SET.NAME(650 LENGTH), DISP=SHR
//OUPUT    DD  DSN = OUT.PUT.DATA(SAME LENGTH), DISP=SHR
//SYSIN    DD  DUMMY
//SYSOUT   DD  SYSOUT=*
//SYSPRINT DD  SYSOUT=*


You can handle the PARM value in cobol program if PARM value is 2, open the dataset having length 750 and process and write the output file.


You can change the PARM value acording to your desire........ icon_biggrin.gif
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Fri Apr 18, 2008 3:05 pm
Reply with quote

Why can't you pre-process the input files and make them both the same length BEFORE calling the program?
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Fri Apr 18, 2008 3:27 pm
Reply with quote

Hi Superk,

I also took the assignment of same scenario, so i hamdled like this and also requirement was also like this only, so i didnot get any chance to preprocess the file.

if you have any idea please suggest us.
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Fri Apr 18, 2008 3:37 pm
Reply with quote

Hi Superk,

Quote:
Why can't you pre-process the input files and make them both the same length BEFORE calling the program


Could you please tell me how can i do approach for this?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 18, 2008 7:53 pm
Reply with quote

Hello,

Quote:
Could you please tell me how can i do approach for this?
Sort, IEBGENER, etc.

Just copy the file to another with the common dcb info.

If the data actully has different lengths, will there not be some inconsistencies in the "common" cobol program? What will be done to handle the "missing" or "extra" bytes?
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Fri Apr 18, 2008 10:30 pm
Reply with quote

Hello,

dick scherrer wrote:


Quote:
Could you please tell me how can i do approach for this?
Sort, IEBGENER, etc.

Just copy the fine to another with the common dcb info.

If the data actully has different lengths, will there not be some inconsistencies in the "common" cobol program? What will be done to handle the "missing" or "extra" bytes?


Is that good coding practice more over he given requirement cleary that there are 2 JCL which uses common COBOL program but 2 JCL(Which could be RUN at different interval)

Is I am correct Dick,
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 18, 2008 11:09 pm
Reply with quote

Hello Raghu,

It is rather common to have a program that is executed in multiple jobs (often even more than 2). What is not so common is to have the same program process the "same" file with different lrecls. The original question needs clarification. . .

Usually if lrecls are different, that means the files are different and would usually be dealt with in different code. Even if the "short" file were copied to a file with the longer lrecl, the last 100 bytes would be useless.

If we had better information we could make better suggestions.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Apr 18, 2008 11:20 pm
Reply with quote

Interestingly, that (almost) same subject was just resolved lately with the non obvious title of Program abends with SOC4 while reading the 231st record
Back to top
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Fri May 16, 2008 10:43 am
Reply with quote

You can also use one fd by coding record contains 0.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top