Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Write into FILE 3 the contents from File 1 and file 2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
t1nt1n

New User


Joined: 08 Jul 2005
Posts: 31

PostPosted: Mon Jul 25, 2005 4:25 pm    Post subject: Write into FILE 3 the contents from File 1 and file 2
Reply with quote

Hello

I have two sorted files as mentioned below

File 1 File 2
------ --------
1 2
2 3
4 4
6 5


I need a logic in COBOL to write into FILE 3 the contents from File 1 and file 2 in sorted order elminating the duplicates(as below).

File 3
-------
1
2
3
4
5
6

Can some one tell me the simplest logic in COBOL ?
Back to top
View user's profile Send private message

jyoti_sethy

New User


Joined: 20 Jun 2005
Posts: 4
Location: bangalore

PostPosted: Mon Jul 25, 2005 5:26 pm    Post subject:
Reply with quote

you can use it through mergesort

efore that your two af the file should be sorted one as you have given the two files are sorte dso you can use mergesort
use it

merge workfile on ascending key <field>
desceding key <filed2> using file1,file2 giving file3.

in your procedure division.

you can get the sorted out you are looking for.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Jul 25, 2005 5:47 pm    Post subject: Re: File logic
Reply with quote

Hi t1nt1n,

Try this code......

Code:
//STEP1     EXEC PGM=ICETOOL                     
//TOOLMSG   DD SYSOUT=*                         
//DFSMSG    DD SYSOUT=*                         
//IN     DD DSN=RECORDS.INPUT.FIRST,DISP=SHR 
//       DD DSN=RECORDS.INPUT.SECOND,DISP=SHR 
//OUT    DD DSN=RECORDS.OUT,           
//          DISP=(,KEEP,DELETE),               
//          SPACE=(80,(10,10),RLSE)             
//TOOLIN DD *                                   
SELECT FROM(IN) TO(OUT) ON(1,1,CH) FIRST       
//   


Regards,

Priyesh.
Back to top
View user's profile Send private message
karthikuma

New User


Joined: 29 Mar 2005
Posts: 62

PostPosted: Tue Aug 02, 2005 10:09 am    Post subject: Re: File logic
Reply with quote

hi friends,

tell me the logic in cobol.i'm waiting any one to give me the syntax of cobol how to do this.

regards,
kumar
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 02, 2005 11:14 am    Post subject: Re: File logic
Reply with quote

In COBOL u can do file comparison logic...

try to compare wit the key field's of the both files.. say x for file1 & y for file2

compare x &y (in sequential read), if both sorted asc

if x>y

x does nt hav y's entry
write y content in to outfile
read only y again
compare

if x=y
write again the common recd
read both x & y this time

if x<y
x content nt in y...so write x in outfile
read only x this time & compare....

proceed like this till eof for both...this is the simplest logic to avoid duplicates & merging both files
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 02, 2005 11:14 am    Post subject: Re: File logic
Reply with quote

In COBOL u can do file comparison logic...

try to compare wit the key field's of the both files.. say x for file1 & y for file2

compare x &y (in sequential read), if both sorted asc

if x>y

x does nt hav y's entry
write y content in to outfile
read only y again
compare

if x=y
write again the common recd
read both x & y this time

if x<y
x content nt in y...so write x in outfile
read only x this time & compare....

proceed like this till eof for both...this is the simplest logic to avoid duplicates & merging both files
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 02, 2005 11:14 am    Post subject: Re: File logic
Reply with quote

In COBOL u can do file comparison logic...

try to compare wit the key field's of the both files.. say x for file1 & y for file2

compare x &y (in sequential read), if both sorted asc

if x>y

x does nt hav y's entry
write y content in to outfile
read only y again
compare

if x=y
write again the common recd
read both x & y this time

if x<y
x content nt in y...so write x in outfile
read only x this time & compare....

proceed like this till eof for both...this is the simplest logic to avoid duplicates & merging both files
Back to top
View user's profile Send private message
shivashunmugam Muthu

Active User


Joined: 22 Jul 2005
Posts: 114
Location: Chennai

PostPosted: Tue Aug 02, 2005 11:15 am    Post subject: Re: File logic
Reply with quote

In COBOL u can do file comparison logic...

try to compare wit the key field's of the both files.. say x for file1 & y for file2

compare x &y (in sequential read), if both sorted asc

if x>y

x does nt hav y's entry
write y content in to outfile
read only y again
compare

if x=y
write again the common recd
read both x & y this time

if x<y
x content nt in y...so write x in outfile
read only x this time & compare....

proceed like this till eof for both...this is the simplest logic to avoid duplicates & merging both files
Back to top
View user's profile Send private message
sriteja

New User


Joined: 25 Jul 2005
Posts: 15
Location: Hyderabad

PostPosted: Tue Aug 02, 2005 12:17 pm    Post subject:
Reply with quote

Dear Priyesh,

Could you please elaborate what the below command line means in the JCL you have given above and how it helps for merge sort.

SELECT FROM(IN) TO(OUT) ON(1,1,CH) FIRST

Regards
Sri
Back to top
View user's profile Send private message
sriteja

New User


Joined: 25 Jul 2005
Posts: 15
Location: Hyderabad

PostPosted: Tue Aug 02, 2005 12:18 pm    Post subject:
Reply with quote

Dear Priyesh,

Could you please elaborate what the below command line means in the JCL you have given above and how it helps for merge sort.

SELECT FROM(IN) TO(OUT) ON(1,1,CH) FIRST

Regards
Sri
Back to top
View user's profile Send private message
sriteja

New User


Joined: 25 Jul 2005
Posts: 15
Location: Hyderabad

PostPosted: Tue Aug 02, 2005 12:18 pm    Post subject: Sort syntax
Reply with quote

Dear Priyesh,

Could you please elaborate what the below command line means in the JCL you have given above and how it helps for merge sort.

SELECT FROM(IN) TO(OUT) ON(1,1,CH) FIRST

Regards
Sri
Back to top
View user's profile Send private message
sriteja

New User


Joined: 25 Jul 2005
Posts: 15
Location: Hyderabad

PostPosted: Tue Aug 02, 2005 12:19 pm    Post subject: Sort syntax
Reply with quote

Dear Priyesh,

Could you please elaborate what the below command line means in the JCL you have given above and how it helps for merge sort.

SELECT FROM(IN) TO(OUT) ON(1,1,CH) FIRST

Regards
Sri
Back to top
View user's profile Send private message
sriteja

New User


Joined: 25 Jul 2005
Posts: 15
Location: Hyderabad

PostPosted: Tue Aug 02, 2005 12:19 pm    Post subject: Sort syntax
Reply with quote

Dear Priyesh,

Could you please elaborate what the below command line means in the JCL you have given above and how it helps for merge sort.

SELECT FROM(IN) TO(OUT) ON(1,1,CH) FIRST

Regards
Sri
Back to top
View user's profile Send private message
sriteja

New User


Joined: 25 Jul 2005
Posts: 15
Location: Hyderabad

PostPosted: Tue Aug 02, 2005 12:20 pm    Post subject: Sort syntax
Reply with quote

Dear Priyesh,

Could you please elaborate what the below command line means in the JCL you have given above and how it helps for merge sort.

"SELECT FROM(IN) TO(OUT) ON(1,1,CH) FIRST "

Regards
Sri
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 -> COBOL Programming 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 write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us