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

Compare 2 records of the same PS file based on 15 byte key.


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

New User


Joined: 31 Jan 2020
Posts: 4
Location: India

PostPosted: Fri Jan 31, 2020 3:25 pm
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: 2455
Location: Hampshire, UK

PostPosted: Fri Jan 31, 2020 4:50 pm
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: 4
Location: India

PostPosted: Fri Jan 31, 2020 5:00 pm
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

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Fri Jan 31, 2020 11:27 pm
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: 1742
Location: Tirupur, India

PostPosted: Fri Jan 31, 2020 11:29 pm
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3049
Location: NYC,USA

PostPosted: Sat Feb 01, 2020 2:56 am
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: 4
Location: India

PostPosted: Sat Feb 01, 2020 10:28 am
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: 2455
Location: Hampshire, UK

PostPosted: Sat Feb 01, 2020 7:15 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Mon Feb 10, 2020 5:13 pm
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

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Tue Feb 11, 2020 12:43 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top