Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Split single record in to multiple records of diff length

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Split single record in to multiple records of diff length
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: 7931
Location: Bellevue, IA

PostPosted: Tue Jan 19, 2010 7:14 pm    Post subject:
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    Post subject: Reply to: Split single record in to multiple records of diff
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: 7931
Location: Bellevue, IA

PostPosted: Tue Jan 19, 2010 8:07 pm    Post subject:
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    Post subject: Reply to: Split single record in to multiple records of diff
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Tue Jan 19, 2010 8:51 pm    Post subject: Reply to: Split single record in to multiple records of diff
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

Senior Member


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

PostPosted: Tue Jan 19, 2010 9:02 pm    Post subject:
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: 7931
Location: Bellevue, IA

PostPosted: Tue Jan 19, 2010 9:03 pm    Post subject:
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: 7931
Location: Bellevue, IA

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

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

Site Director


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

PostPosted: Tue Jan 19, 2010 9:32 pm    Post subject:
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    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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us