Page 1 of 1

File formatting query

PostPosted: Mon Jul 02, 2012 9:50 pm
by chetan_mfguy
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.

Re: File formatting query

PostPosted: Mon Jul 02, 2012 11:03 pm
by NicC
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?

Re: File formatting query

PostPosted: Tue Jul 03, 2012 2:36 pm
by chetan_mfguy
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.

Re: File formatting query

PostPosted: Tue Jul 03, 2012 4:22 pm
by BillyBoyo
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.