File formatting query



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

File formatting query

Postby chetan_mfguy » Mon Jul 02, 2012 9:50 pm

Input file:

HDR|DISP|20120628|DTS|TAXI|0001|
DTS|DISP|1234567890122|   2000000|P|Y|20120627|        |
DTS|NOTE|1234567890122|DTS1  |PERM      |         1|20120627|DTS#
2000000. This is a sample note. AS3807
|
TRL|     4|

This input file is pipe delimited. We want to create the output file in below format.

Output File:

HDR|DISP|20120628|DTS|TAXI|0001|
DTS|DISP|1234567890122|   2000000|P|Y|20120627|        |
DTS|NOTE|1234567890122|DTS1  |PERM      |         1|20120627|DTS#2000000. This is a sample note. AS3807|
TRL|     4|

The fields which are coming after DTS# can come in next 300 lines. In present case it is coming in 2 lines.

Is there anyway to get file formated in this way. Please suggest. Any help is greatly appreciated. Let me know if you want more info.
chetan_mfguy
 
Posts: 4
Joined: Sat Dec 24, 2011 6:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File formatting query

 

Re: File formatting query

Postby NicC » Mon Jul 02, 2012 11:03 pm

So you want to format the file so that all data for record is in one record an not split over multiple lines? And each record begins DTS| except the first DTS| is part of the header which is defined by HDR in cc1 and the trailer has TLR in cc1 in the last record and I presume the 4 is the record count including header and trailer? A DTS record can be made up of 300 lines? What record length?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: File formatting query

Postby chetan_mfguy » Tue Jul 03, 2012 2:36 pm

Thanks for your reply.

Yes, your assumptions for Header and trailer record are correct.
Rest records start with "DTS|".
The characters after the DTS# covers length of 300 characters and it can be splitted over maximum 300 lines or less.
The record length of our file is 380 chars and fixed block.
You understood this correct that we want to bring these splitted characters in a single record through cobol.
chetan_mfguy
 
Posts: 4
Joined: Sat Dec 24, 2011 6:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File formatting query

Postby BillyBoyo » Tue Jul 03, 2012 4:22 pm

Presumably your output is going to be VB?

If you have up to 300 records of 380 bytes you are going to have problems.

Putting that aside for now, you will need to store records in a table with OCCURS (300) until you know you need to write.

When you get a DTS record, you need to store it in the table. Also store any which are not HDR/DTS/TRL. When you get a HDR/DTS/TRL check if table has anything to write out and write those first before processing the next record.

If you use OCCURS DEPENDING ON for the table, you would be able to use that table as the concatenated output record.

Remember when you have used the table to reset to zero the number of entries in the table.

HDR/TRL can be stored in the table if you want to code the same way for all, or they can be written immediately after the table has been checked/emptied. If you store everything, remember to check/empty the table on end-of-input.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post