IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Concatenating 3 strings into one sentence


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
p.parthasaradhi

New User


Joined: 19 Feb 2005
Posts: 4
Location: PUNE(NATIVE ANDRA PRADESH)

PostPosted: Tue Dec 26, 2006 7:17 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Dec 26, 2006 7:53 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Dec 27, 2006 1:34 am
Reply with quote

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
View user's profile Send private message
p.parthasaradhi

New User


Joined: 19 Feb 2005
Posts: 4
Location: PUNE(NATIVE ANDRA PRADESH)

PostPosted: Wed Dec 27, 2006 11:03 am
Reply with quote

Thanks agraval

my doubt is clare


thanks
Partha
Back to top
View user's profile Send private message
trgk03

New User


Joined: 20 Jan 2006
Posts: 12
Location: kochi

PostPosted: Wed Dec 27, 2006 11:57 am
Reply with quote

Hi p.parthasaradhi,

Put it like this ,

Code:
STRING variable1
             ' '
             variable2
             ' '
             variable3
             DELIMITED BY SIZE
             INTO variable4


CHEERS,
sD
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. How to search multiple strings in a PDS IBM Tools 3
No new posts Print next line strings when a condit... DFSORT/ICETOOL 9
No new posts Include current & next records if... DFSORT/ICETOOL 22
No new posts Search the strings present in ps file... All Other Mainframe Topics 8
No new posts Occurrence of various strings within ... JCL & VSAM 1
Search our Forums:

Back to Top