View previous topic :: View next topic
|
Author |
Message |
p.parthasaradhi
New User
Joined: 19 Feb 2005 Posts: 4 Location: PUNE(NATIVE ANDRA PRADESH)
|
|
|
|
I have a 3 strings
i.e address1 pic x(30) value 'ALBERT DRIVE'
address2 pic x(30) value '1 WAVERLEY PLACE'
address3 pic x(30) value 'something special'
i want to concatenate these string.each string between one space.
for example my out put is like this
ALBERT DRIVE 1 WAVERLEY PLACE SOMETHING SPECIAL.
THANKS
PARTHA |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
If you define the 3 addresses in a row, you could unstring the 90 byte filed delimiting by spaces into your result field with reference modification and unstring's count in and pointer fields. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Using INSPECT and Ref Mod'n ... chk it out...
Code: |
WS-STRING-1 PIC X(30) VALUE 'ALBERT DRIVE '.
WS-STRING-2 PIC X(30) VALUE '1 WAVERLEY PLACE '.
WS-STRING-3 PIC X(30) VALUE 'something special '.
WS-EDITED-STRING PIC X(90) VALUE SPACE.
WS-LEN-LEAD-SPACE-1 PIC 99 VALUE ZEROES.
WS-LEN-LEAD-SPACE-2 PIC 99 VALUE ZEROES.
WS-LEN-LEAD-SPACE-3 PIC 99 VALUE ZEROES.
WS-LEN-ACTUAL-STR-1 PIC 99 VALUE ZEROES.
WS-LEN-ACTUAL-STR-2 PIC 99 VALUE ZEROES.
WS-LEN-ACTUAL-STR-3 PIC 99 VALUE ZEROES.
WS-EDITED-STRING PIC X(90) VALUE SPACES.
INITIALIZE WS-LEN-LEAD-SPACE-1
WS-LEN-LEAD-SPACE-2
WS-LEN-LEAD-SPACE-3.
INSPECT FUNCTION REVERSE(WS-STRING-1) TALLYING WS-LEN-LEAD-SPACE-1 FOR LEADING SPACES.
COMPUTE WS-LEN-ACTUAL-STR-1 = 30 - WS-LEN-LEAD-SPACE-1.
MOVE WS-STRING-1 (1: WS-LEN-ACTUAL-STR-1) TO WS-EDITED-STRING.
INSPECT FUNCTION REVERSE(WS-STRING-2) TALLYING WS-LEN-LEAD-SPACE-2 FOR LEADING SPACES.
COMPUTE WS-LEN-ACTUAL-STR-2 = 30 - WS-LEN-LEAD-SPACE-2.
MOVE WS-STRING-2 (1: WS-LEN-ACTUAL-STR-2)
TO WS-EDITED-STRING (WS-LEN-ACTUAL-STR-1 + 2: WS-LEN-ACTUAL-STR-2).
INSPECT FUNCTION REVERSE(WS-STRING-3) TALLYING WS-LEN-LEAD-SPACE-3 FOR LEADING SPACES.
COMPUTE WS-LEN-ACTUAL-STR-3 = 30 - WS-LEN-LEAD-SPACE-3.
MOVE WS-STRING-3 (1: WS-LEN-ACTUAL-STR-3) TO
WS-EDITED-STRING (WS-LEN-ACTUAL-STR-1 + WS-LEN-ACTUAL-STR-1 + 2: WS-LEN-ACTUAL-STR-3). |
|
|
Back to top |
|
|
p.parthasaradhi
New User
Joined: 19 Feb 2005 Posts: 4 Location: PUNE(NATIVE ANDRA PRADESH)
|
|
|
|
Thanks agraval
my doubt is clare
thanks
Partha |
|
Back to top |
|
|
trgk03
New User
Joined: 20 Jan 2006 Posts: 12 Location: kochi
|
|
|
|
Hi p.parthasaradhi,
Put it like this ,
Code: |
STRING variable1
' '
variable2
' '
variable3
DELIMITED BY SIZE
INTO variable4 |
CHEERS,
sD |
|
Back to top |
|
|
|