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

Compare 2 input files based on a column and output result


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Tue Jan 10, 2012 7:57 pm
Reply with quote

Hello All,

I have 2 input PS files as below

File1
-----

Code:
First_name     Last_name                   State
-------------    ---------------------        ------
Raj                Shhhh                         FX
Tuz                   ddd                          FX
Ryan              tttttt                            ML
Reg                eeeeeeeee                  PN


File2
-----
Code:
State           city          area
-------------------------------
FX             abc          pqr
ML             ddd        iii
FX             XYZ         rdt
ML             hhh          uuu
PN             rrr           eee

I am trying to code a cobol program whose output file will be like this

Output file
-----------
Code:
First_name     Last_name                   State         City         Area
-------------    ---------------------        ------           ----        ------
Raj                Shhhh                         FX             abc         pqr
Tuz               ddd                             FX             abc         pqr
Raj                Shhhhh                        FX             XYZ       rdt
Tuz                 ddd                            FX             XYZ       rdt
 Ryan              tttttt                            ML            ddd       iii
Ryan              tttttt                            ML             hhh       uuu

I also searched in existing forum for any similar type of program but did not find any.

Please let me know at earliest if any one have code for this.

Thank you,
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue Jan 10, 2012 8:25 pm
Reply with quote

Too bad you couldn't find this sticky.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jan 10, 2012 8:25 pm
Reply with quote

Sorry to be so slow, but yes, people will have code for this.

When posting your data, please include it within the Code tags, as this will preserve spacing.

What state are you talking about which only has one city? Usually states have lots of cities, towns, etc.

If the requirment is as simple as you make out, solutions will be available using your sort product.

If you've found the two-file match program at the top of the Cobol forum, and follow the advice in the topic you tailgated, then that will give you something.
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Tue Jan 10, 2012 8:45 pm
Reply with quote

Akatsukami,

Thank you for the link. I was out of COBOL coding activities for quite few years and so I was not very active in this forum. So its kind of new for me

Thanks,
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jan 10, 2012 8:49 pm
Reply with quote

if that is all You have to do <sort> might be the fastest way around
quite a lots of examples, search for JOINKEYS
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Tue Jan 10, 2012 9:40 pm
Reply with quote

Thank you Enrico, let me check joins related topics too
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: Wed Jan 11, 2012 6:03 am
Reply with quote

Hello,

When posting data, code, jcl, screen info, and etc, you need to use the "Code" tag to improve readability and alignment. I tried to Code your data, but you had already tried to align in the Reply Editor (which destroys the alignment).
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Wed Jan 11, 2012 7:48 pm
Reply with quote

Thank you D.Sch. Thats realy a more precise way of posting.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Jan 12, 2012 3:01 am
Reply with quote

Hi,

maybe I'm missing something, why isn't state PN also a match in output file ?


Gerry
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Thu Jan 12, 2012 4:04 pm
Reply with quote

attachment deleted, a useless waste of space.
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: Thu Jan 12, 2012 10:08 pm
Reply with quote

Hello,

Yup, attachments are most often not a good thing. . .

What about the question Gerry asked?
Quote:
maybe I'm missing something, why isn't state PN also a match in output file ?
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Thu Jan 12, 2012 10:14 pm
Reply with quote

Hello All,
Is is possible to achieve the same merge function using ICETOOL only? my JCL is working fine in mainframe for the above code but in UNIX it is giving parsing error : syntax error at ","

Thanks,
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: Thu Jan 12, 2012 10:32 pm
Reply with quote

Hello,

You are quite close to having your topic locked and probably getting a Warning.

You still have not answered Gerry's question (which is just rude) and now present this question about ICETOOL and UNIX .

You posted a COBOL question (or so we understood) so how does ICETOOL even relate. . . icon_confused.gif

d
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Thu Jan 12, 2012 10:39 pm
Reply with quote

Sorry , I missed Gary's post. Gary is right. PN will also be a match in last rows starting with Reg in first field.
I missed to post that row in output file.

I started this thread with a COBOL code in mind but my goal was achieved with JOINKEYS in SORT utility to get a desired output file. I am just checking if the output file with same format can be generated using ICETOOL/ICEMAN.

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 12, 2012 11:59 pm
Reply with quote

Perhaps if you can confirm which Sort product you are using and full details of the problem you are having, including the Unix bit (which Unix, etc), the topic can be moved/split into the appropriate forum. Full sort code, full messages, sample input/required output, all in the Code tags.

Take the time to get it all right.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Jan 13, 2012 7:59 am
Reply with quote

Hi,

I have been called many other names before but Gary is not one of them.


Gerry
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Fri Jan 13, 2012 11:32 am
Reply with quote

Hi Gerry,

I am sorry, I mispelled.

Thanks,
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Fri Jan 13, 2012 2:21 pm
Reply with quote

Hi Bill,

Please find the details below:

Server where code is failing:
SunOS 5.10.
Full Sort Code
---------------
Code:
//JOIN01   EXEC PGM=SORT                                           
//SYSOUT DD SYSOUT=*                                               
//SORTJNF1  DD DSN=FILE1,DISP=SHR         
//SORTJNF2  DD DSN=FILE2,DISP=SHR         
//SORTOUT  DD DSN=MERGED FILE,DISP=OLD                     
//*********************************************                     
//SYSIN  DD *                                                       
   JOINKEYS FILES=F1,FIELDS=(19,2,A)                               
   JOINKEYS FILES=F2,FIELDS=(1,2,A)                                 
   REFORMAT FIELDS=(F1:1,5,F1:7,10,F1:19,4,F2:1,3,F2:6,5,F2:12,4)
   SORT FIELDS=COPY
//
%%%%%%%%%%%%%%%%%%%%%%%

Error msg
=======
064230 M SRT0001M parsing starts.
JOINKEYSFILES=F1064230 U MSGXXXXU
parsing error : syntax error at ","[line:0,col:3]

064230 E SRT6001E sort_cmd_parse() fails. rc=-111.
064230 E SRT6001E sortpar_parse fails. rc=-111

-111 stands for internal error
============================
Sample input/output will be same as in my first post.

I am not sure of which sort product the system uses[seems of IBM only], Could you please tell if there any command/way to check whose product
is it?


Thanks,
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Jan 13, 2012 2:28 pm
Reply with quote

wouldn' t it be time to speak to Your support...
the forum is for zOS related stuff ...
the chances of getting help for SUN related thoings is pretty slim.

I also wonder what <thing> are You using on the SUN server which understands zOS jcl and <sort> control statements ?
Back to top
View user's profile Send private message
Amit S

New User


Joined: 30 Jul 2010
Posts: 17
Location: india

PostPosted: Fri Jan 13, 2012 2:30 pm
Reply with quote

Oh,ok. I got the point. Thank you Enrico
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 Jan 13, 2012 9:04 pm
Reply with quote

Hello,

Quote:
I am not sure of which sort product the system uses[seems of IBM only], Could you please tell if there any command/way to check whose product is it?


Every sort product i've worked with provides product information when executed. . .

Which unix commands (script?) "execute" the sort jcl posted?

Might the "internal error" be due to statements that are NOT sort control statements (ie. the jcl posted)?

What led you to try to submit mainframe jcl/control statements on the unix system?

Someone who supports the unix system will know which sort product is used on that system. There is also the native unix "sort" command.

When i was a unix admin, we used Syncsort (which ran on HP-UX, AIX, and Sun.
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top