View previous topic :: View next topic
|
Author |
Message |
saravanandj
New User
Joined: 24 Sep 2009 Posts: 2 Location: chennai
|
|
|
|
Hi,
I am reading an customer name (pic x(26)) from an input file which is in the format (lastname,firstname) . i need to write the cust name in output file in this format (firstname lastname).
How can we acheive ths without using inspect statement ?
i m trying
unstring customer-name delimited by ',' into ws-lstname,ws-fsname.
how can we define ws-lstname & ws-fstname ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
how can we define ws-lstname & ws-fstname ? |
We can't say as this depends on your site/application-specific data rules.
If you define them both as x(26), nothing would be lost due to overflow. . .
Quote: |
How can we acheive ths without using inspect statement ? |
I don't see how this might be achieved with inspect. . .
After the unstring, issue a string delimiting the 2 separate fields by space and inserting a space or a comma,space between the re-arranged data.
Keep in mind that this will only work for very simple names. . . |
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
Dick the Unstring will work, but if the name in the input field has leading spaces and not the first character then the new output field will reflect this and that is why I wrote our NAME subroutine using the inspect statements
so that I would find the actual beginning of each of the names.
Code: |
Examples: " lastname, firstname"
" lastname, firstname"
"lastname, firstname"
"lastname,firstname"
The INSPECCT statement allows you to locate the begining of each name
and then I use a STRING command to put the name in output. |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Yup, INSPECT could identify leading spaces, but wouldn't do the re-arranging. . .
This looked like a class exercise so i gave the "simple solution". . .
d |
|
Back to top |
|
|
|