Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

unload file to o/p file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: unload file to o/p file
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    Post subject:
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    Post subject:
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    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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us