Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Compare 2 records of the same PS file based on 15 byte key.

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

New User


Joined: 31 Jan 2020
Posts: 3
Location: India

PostPosted: Fri Jan 31, 2020 3:25 pm    Post subject: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

I have a PS file of 500 bytes. The file will be sorted and contains

Account no (15)
Date (8)
Code(4)
Acc no2 (10)
Name(60)
Error code(20)
Error name(60)
Error msg(80)
Filler (243)

The file can contain duplicate multiple records for a single account number but the error code,errorname and error msg will differ in each line for a single account no.

The requirement is to compare each record and if the acc no(15) matches, write the detail of a account in a single line for a account

Expected output:-

Account no,date, code, acc no2, name, error code(1), error name(1), error msg(1), error code(2), error name(2), error msg(2)..... so on till 8 occurrence

It need to be done via a cobol code.
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2320
Location: Hampshire, UK

PostPosted: Fri Jan 31, 2020 4:50 pm    Post subject: Reply to: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

OK - you have your basic program specification so go and plan your processing and code it.

If this is not an exercise but a real life requirement then have you looked at a sort solution?
Back to top
View user's profile Send private message
Twinkle22

New User


Joined: 31 Jan 2020
Posts: 3
Location: India

PostPosted: Fri Jan 31, 2020 5:00 pm    Post subject: Reply to: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

The requirement is to do it via a cobol code only as the output is to be passed to MQ.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 726
Location: Maryland

PostPosted: Fri Jan 31, 2020 11:27 pm    Post subject: Re: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

Twinkle22 wrote:
I have a PS file of 500 bytes.


File 500 bytes?
Or record 500 bytes?
Or file of one single record?
Or file 500 bytes out of multiple short records?
Or file out of multiple records 500 bytes each?

Why do you expect other people must think about those details instead of yourself???
icon_evil.gif
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1687
Location: Tiruppur, India

PostPosted: Fri Jan 31, 2020 11:29 pm    Post subject:
Reply with quote

Twinkle22,

Welcome to the forum, people here help out in algorithms or debugging of programs and problems.
If you could tell us what have you tried so far, then someone can comment on it and provide inputs.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2358
Location: NY,USA

PostPosted: Sat Feb 01, 2020 2:56 am    Post subject:
Reply with quote

Welcome!!
Please start using the code tags when representing the data/code.
Quote:
It need to be done via a cobol code.

So are you new to Mainframes and don't know how to code or need a Cobol code? or something else ?
As said by Nic, you could use DFSORT as well to achieve this.
Back to top
View user's profile Send private message
Twinkle22

New User


Joined: 31 Jan 2020
Posts: 3
Location: India

PostPosted: Sat Feb 01, 2020 10:28 am    Post subject: Reply to: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

Input Record length is 500 bytes. Need to compare the previous account no everytime, if its same, write a single entry for that account with all the error codes and msgs else write the next account.

Below is the approach:-

dateI
identifierI
accnoI
fullnameI
error codeI
error nameI
error msgI

Output:: Declare the below variable::
Application idO Acct1,Acct2,Acct3,Acct4,Acct5,Acct6,Acct7,Acct8
dateO
identifierO
accnoO
fullnameO
error codeO(1)
error nameO(1)
error msgO(1)
error codeO(2)
error nameO(2)
error msgO(2)
error codeO(3)
error nameO(3)
error msgO(3)
error codeO(4)
error nameO(4)
error msgO(4)

====================================================
Logic
Initialize ouput variables
Read 1st record of the file.
If accnoO = SPACES
Move the error codeI TO error-codeO-1 and Move Application idI to Acct1(set first-record set to true)
else
If accnoO = accnoI

Tried this but not working.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2320
Location: Hampshire, UK

PostPosted: Sat Feb 01, 2020 7:15 pm    Post subject: Reply to: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

It is simple: (this is off the top of my head without too much consideration)
Code:

read a record
Do while more records
   If account is valid
   then do
      init output record with values from record
      read next
      do while account on input matches account on output
         update output record
         read next record
      end
      write output to MQ
   end
   else do
      error report
      read next record
   end
end
Back to top
View user's profile Send private message
bappamajumdar

New User


Joined: 29 Aug 2019
Posts: 2
Location: USA

PostPosted: Mon Feb 10, 2020 11:13 am    Post subject: Re: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

This can be achieved by SORT (either DFSORT or SYNCSORT--check your system which is system default) .

Twinkle22 wrote:

It need to be done via a cobol code.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2320
Location: Hampshire, UK

PostPosted: Mon Feb 10, 2020 5:13 pm    Post subject: Reply to: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

bappaM- the problem statement says that COBOL is to be used.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 726
Location: Maryland

PostPosted: Tue Feb 11, 2020 12:43 am    Post subject: Re: Compare 2 records of the same PS file based on 15 byte key.
Reply with quote

Twinkle22 wrote:
I have a PS file of 500 bytes. The file will be sorted and contains

Account no (15)
Date (8)
Code(4)
Acc no2 (10)
Name(60)
Error code(20)
Error name(60)
Error msg(80)
Filler (243)

The file can contain duplicate multiple records for a single account number but the error code,errorname and error msg will differ in each line for a single account no.

The requirement is to compare each record and if the acc no(15) matches, write the detail of a account in a single line for a account

Expected output:-

Account no,date, code, acc no2, name, error code(1), error name(1), error msg(1), error code(2), error name(2), error msg(2)..... so on till 8 occurrence

It need to be done via a cobol code.

Trying to re-read your post again, and again...

What prevents you from doing exactly what "needs to be done"??? icon_eek.gif
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 Trigger mainframe job , when file pla... Nandhinee All Other Mainframe Topics 0 Thu Apr 09, 2020 10:30 pm
No new posts compare two volumes kushkush All Other Mainframe Topics 4 Tue Apr 07, 2020 5:40 am
No new posts Add the name in the PS file and creat... dharmaraok DFSORT/ICETOOL 9 Wed Apr 01, 2020 10:43 am
No new posts Compare Two datasets and get the 1st ... ArunkumarGanesan DFSORT/ICETOOL 7 Fri Mar 27, 2020 2:00 am
No new posts DFSORT Output file order query A_programmers DFSORT/ICETOOL 2 Thu Mar 26, 2020 11:59 pm

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