View previous topic :: View next topic
|
Author |
Message |
Twinkle22
New User
Joined: 31 Jan 2020 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Twinkle22
New User
Joined: 31 Jan 2020 Posts: 4 Location: India
|
|
|
|
The requirement is to do it via a cobol code only as the output is to be passed to MQ. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2023 Location: USA
|
|
|
|
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???
|
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
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 |
|
|
Twinkle22
New User
Joined: 31 Jan 2020 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
bappamajumdar
New User
Joined: 29 Aug 2019 Posts: 2 Location: USA
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
bappaM- the problem statement says that COBOL is to be used. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2023 Location: USA
|
|
|
|
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"??? |
|
Back to top |
|
|
|