View previous topic :: View next topic
|
Author |
Message |
senthil_1983
New User
Joined: 16 Apr 2008 Posts: 14 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
UNSTRING or reference modification, depending upon the details you didn't give us. |
|
Back to top |
|
|
senthil_1983
New User
Joined: 16 Apr 2008 Posts: 14 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
senthil_1983
New User
Joined: 16 Apr 2008 Posts: 14 Location: Chennai
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Perl has "\n" as well, Anuj. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|