Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us