View previous topic :: View next topic
|
Author |
Message |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
The FM states: "One UNSTRING statement can take the place of a series of MOVE statements"
The rules for moving an alphanumeric elementary item are the same as those for the MOVE statement"
You might find this works better.
Code: |
01 NAME.
05 L PIC X(30).
05 F PIC X(30).
05 M PIC X(30).
* YOUR FORMAT IS L F M
01 FINAL-NAME PIC X(30).
PROCEDURE DIVISION.
MAIN-PARA.
MOVE SPACES TO NAME.
MOVE 'JOHN*ED*CAUSEY SATTELBERG*' TO WS-NAME.
UNSTRING WS-NAME DELIMITED BY '*' INTO
F,M,L.
DISPLAY 'F:' F.
DISPLAY 'M:' M.
DISPLAY 'L:' L.
STRING
L DELIMITED BY X'4040'
', ' DELIMITED BY SIZE
F DELIMITED BY X'4040'
SPACE DELIMITED BY SIZE
M DELIMITED BY X'4040'
INTO FINAL-NAME.
DISPLAY FINAL-NAME.
O/p:
F:JOHN
M:ED
L:CAUSEY SATTELBERG
CAUSEY SATTELBERG, JOHN ED |
So much for
cobolunni wrote: |
good thus we got a practical model |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
By jove, i think he's got it! |
|
Back to top |
|
|
vishwaroopa
New User
Joined: 08 Mar 2007 Posts: 8 Location: US
|
|
|
|
Thanks to Every body for your valuable inputs, this works. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Cool |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
cobolunni wrote: |
for your second problem from the code given by agkshirsagar the last string statement uses spaces to delimit the data in identifiers F M and L to avoid that you need to put some data for example VALUE ALL '#' to all your F M and L and replace the line in STRING statement as DELIMITED BY '#' hope that will solve your problem |
This wont work.
Because after unstring you will get trailing spaces in the F,M,L.
I would suggest one change..
Code: |
ACCEPT WS-NAME.
INSPECT WS-NAME REPLACING ALL SPACES BY '@'
UNSTRING WS-NAME DELIMITED BY '*' INTO
F,M,L. |
i.e. Replacing spaces by @ immediately after you get the value in your variable. ( I am sure you are not using ACCEPT )
Optimize the code after you get exactly what you wanted |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
People, I did not see all the replies, Juse saw the page 1 discussion and posted.
It seems you already got the solution. |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
agkshirsagar wrote: |
Because after unstring you will get trailing spaces in the F,M,L.
|
i dont think so , any way we got the solution |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
The UNSTRING copies characters from the source string, to the destination string, until a condition is encountered that terminates data movement.
When data movement ends for a particular destination string, the next destination string becomes the receiving area and characters are copied into it until once again a terminating condition is encountered.
Characters are copied from the source string to the destination strings according to the rules for alphanumeric moves.
There is space filling. |
|
|
Back to top |
|
|
|