l.nethaji
New User
Joined: 16 Mar 2008 Posts: 90 Location: tamil nadu
|
|
|
|
Hi,
Below is my requirement.
i have doing a unload file order by custid and acctid
We can have maximum of 10 mtn's for custid & acctid combination in the unload file
unload file
custid 1,acctid1,mtn1
custid 1,acctid1,mtn2
custid 2 ,acctid2,mtn1
custid 2,acctid2,mtn2
custid 2,acctid2,mtn3
custid 2,acctid2,mtn4
custid 2,acctid2,mtn5
custid 2,acctid2,mtn6
custid 2,acctid2,mtn7
custid 2,acctid2,mtn8
custid 2,acctid2,mtn9
custid 2,acctid2,mtn10
custid 3,acctid3,mtn1
custid 4,acctid4,mtn1
Output file layout :-
CUSTID
ACCTID,
MTN occurs 10 times
I have to create a output file as below.
custid1,acctid1,mtn1,mtn2
custid2,acctid2,mtn1,mtn2,mtn3,mtn4,mtn5,mtn6,mtn7,mtn8,mtn9,mtn10
custid 3,acctid3,mtn1
custid 4,acctid4,mtn1
Please help me in writing a logic for the above .
I tried writing it but i got to recursive if condition loop.
Regards,
L.Nethaji |
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
You may continue with SORT as TheMFKid Suggested.
If you really want to GO with COBOL, this might help you. Make sure the file is sorted by CUSTID & ACCTID.
Code: |
01 ws-records.
05 ws-custid
05 ws-acctid
05 ws-MTN occurs 10 times.
Read Input-File.
move custid,acctid to ws-custid, ws-acctid.
move 0 to ctr1.
Loop until End-Of-File
if custid = ws-custid and
acctid = ws-acctid
add 1 to ctr1
move MTN to ws-MTN(ctr1)
else
write output-file from ws-records
move custid,acctid to ws-custid, ws-acctid
move 1 to ctr1
move MTN to ws-MTN(ctr1)
end-if
Read Input-File
end-Read-Loop.
/* For last set of records */
if ctr1 > 0
write output-file from ws-records. |
You may add validations for empty input file.
If you have any further doubt/question, please post what have you tried along with question. |
|