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

unload file to o/p file


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

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Fri Feb 14, 2014 9:50 am
Reply with quote

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
Back to top
View user's profile Send private message
TheMFKid

New User


Joined: 20 Nov 2013
Posts: 91
Location: India

PostPosted: Fri Feb 14, 2014 10:00 am
Reply with quote

Have you tried doing this using SORT before jumping on to Cobol?

Post the code you wrote, so experts here can help you identify where you went wrong.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Fri Feb 14, 2014 2:38 pm
Reply with quote

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.
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 rexx pgm to create multiple ps file IBM Tools 7
No new posts Remove commas from specific positions... DFSORT/ICETOOL 10
No new posts Uploading from desktop, a CSV file, s... DB2 2
No new posts Get two files from one file with diff... DFSORT/ICETOOL 10
No new posts View GDG data which is copied from a ... JCL & VSAM 2
Search our Forums:

Back to Top