Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Concatenating 3 strings into one sentence

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Concatenating 3 strings into one sentence
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: 3158
Location: Tucson AZ

PostPosted: Tue Dec 26, 2006 7:53 pm    Post subject:
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: 1452
Location: Chicago, IL

PostPosted: Wed Dec 27, 2006 1:34 am    Post subject: Re: Concatenating 3 strings into one sentence
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Concatenating 2 VB & 1 FB file an... raja_natural SYNCSORT 3 Sun Sep 27, 2015 2:36 am
No new posts Copy records with matching strings fr... mkk157 DFSORT/ICETOOL 5 Tue Mar 17, 2015 1:09 pm
No new posts Replacing record Based on matching st... mrdinesh DFSORT/ICETOOL 7 Thu Sep 25, 2014 8:22 pm
No new posts How to use GDGORDER for concatenating... manas121 JCL & VSAM 4 Fri Aug 01, 2014 10:27 pm
No new posts Syncsort - put strings side by side ramas.kamal SYNCSORT 4 Wed May 21, 2014 4:22 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us