View previous topic :: View next topic |
Author |
Message |
Bravo Beginner
Joined: 05 Dec 2005 Posts: 26 Topics: 12
|
Posted: Fri Dec 23, 2005 7:33 pm Post subject: Question with delimited data. |
|
|
Hi All,
I am getting the following with pipe | as delimited in VB format. I want to unstring and move the data to three different fields which is declared as
A PIC X(5)
B PIC X(10)
C PIC X(15)
input as
"1"|"2"|"3"
"11"|"22"|"33"
"111"|"222"|"333"
o/p should be
First record
A = 1
B = 2
C = 3
2nd record
A = 11
B = 22
C = 33
3rd record
A = 111
B = 222
C = 333
Could you please suggest me the efficient to handle the above data.
|
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Fri Dec 23, 2005 7:59 pm Post subject: |
|
|
Bravo,
Try this untested code.
Code: |
01 W-STR PIC X(30).
MOVE '"11"|"22"|"33"' TO W-STR
INSPECT W-STR REPLACING ALL '"' BY ' '
UNSTRING W-STR DELIMITED BY '|' INTO A,B,C
DISPLAY A
DISPLAY B
DISPLAY C
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Bravo Beginner
Joined: 05 Dec 2005 Posts: 26 Topics: 12
|
Posted: Sat Dec 24, 2005 4:19 pm Post subject: |
|
|
I just gave the sample data but the real time data could be any values other than the provided in my post.
I do not want to hard code the data in the program.Is there any alternative way. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Sat Dec 24, 2005 6:44 pm Post subject: |
|
|
Quote: |
I just gave the sample data but the real time data could be any values other than the provided in my post.
I do not want to hard code the data in the program.Is there any alternative way
|
Bravo,
The above posted code works for any kind of data. Just move your input data to w-str and you are all set
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|