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

Split single record in to multiple records of diff length


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

New User


Joined: 16 Apr 2008
Posts: 14
Location: Chennai

PostPosted: Tue Jan 19, 2010 7:05 pm
Reply with quote

Hi

I have a string of size 32000.I need to split this string in to multiple records.the delimiter is new line character "\n".

Please help me how to do this.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jan 19, 2010 7:14 pm
Reply with quote

UNSTRING or reference modification, depending upon the details you didn't give us.
Back to top
View user's profile Send private message
senthil_1983

New User


Joined: 16 Apr 2008
Posts: 14
Location: Chennai

PostPosted: Tue Jan 19, 2010 7:21 pm
Reply with quote

I have stirng of length 32000.In that string there will be special characters "\n".Whenever i encountered "\n".I need to write the data in to a record.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jan 19, 2010 8:07 pm
Reply with quote

Terminology notes:
1. There is no such thing as "\n" in COBOL. That particular byte is called LOW-VALUE and represents 8 bits of all zeroes -- if you mean a null-terminated string when you say "\n". If you mean the line feed character, that is a different bit pattern and you can find it in any EBCDIC collating sequence table (hint: Google is your friend).
2. You cannot write data to a record. You write data to a file. The data written to a file is called a record.
3. COBOL does not recognize "strings". COBOL has variables. These variables may be alphabetic, alphanumeric, national, or numeric -- but they are not ever, under any circumstances, "strings".

Unmentioned details in your posts (the second of which is merely a repeat of the first and adds absolutely no new information):
1. Write the entire 32000 bytes to a file? If not, are you wanting to write just the data since the last LOW-VALUES (or line feed -- further references below will imply this since you haven't specified what "\n" means to you) byte to the file?
2. How many LOW-VALUE bytes can you have in a variable?
3. Is every variable exactly 32000 bytes or can they vary in length?
4. Can the number of LOW-VALUES bytes in the variable vary or will you have exactly the same number every time?
5. Is this to be done for one variable, two variables, or a batch of variables?
6. What is the source of the variables? If another system, has the ASCII to EBCDIC conversion been handled already?
7. Is the data national?
8. Is the data SBCS or DBCS?
9. How long can the field between two occurrences of "\n" be?
10. Are you wanting the output file to be fixed length or variable length?
11. What research have you done already?
12. What have you tried that hasn't worked already?
Back to top
View user's profile Send private message
senthil_1983

New User


Joined: 16 Apr 2008
Posts: 14
Location: Chennai

PostPosted: Tue Jan 19, 2010 8:48 pm
Reply with quote

Here my requirement details

i will get the details im MQ,where the message length is 32000.

In that single message there will be n records.After every record delimiter "\n" will be there.The request is coming form external systems.

Based on the delimiters i need to split the records and send it to another system.

I though using UNSTRING but i dont know how many records will be there in single MQ message,because the record length will vary.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Jan 19, 2010 8:51 pm
Reply with quote

Quote:
but i dont know how many records will be there in single MQ message,because the record length will vary.


what about looking at the application specifications ??
especially at all that concern the interfaces
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Jan 19, 2010 9:02 pm
Reply with quote

Robert Sample wrote:
There is no such thing as "\n" in COBOL.
I smell ill effect of using too much of language C here...sniff sniff...icon_biggrin.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jan 19, 2010 9:03 pm
Reply with quote

Quote:
I though using UNSTRING but i dont know how many records will be there in single MQ message,because the record length will vary.
If you cannot use UNSTRING, you need reference modification -- as you were told in my first post. I recommend you click on the manuals link at the top of the page, find the COBOL Language Reference and Application Programming Guide manuals, search each of them for reference modification, and start reading.

Before you write code, however, you need to find out from somebody just what a "\n" character is -- is it a LOW-VALUE byte or is it a line feed byte? The difference is not important to your code but it would affect your test results drastically.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jan 19, 2010 9:04 pm
Reply with quote

Perl has "\n" as well, Anuj.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jan 19, 2010 9:32 pm
Reply with quote

Hello,

Quote:
but i dont know how many records will be there in single MQ message,because the record length will vary.
Coded properly, it will not matter. . .

The code should parse the input until all of the input has been processed. . .

As has already been mentoined, you need to better understand the "requirement" before you begin slinging code. . .
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top