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 the two strings

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Tue Feb 28, 2006 8:36 pm    Post subject: concatenating the two strings
Reply with quote

Hi,

I have a requirement to concatenate the two strings....

string1 is name of 20 characters and the values can be

"sangeetha"
"sangeetha nityanandam"
"vijay prabhi thinagaran"

string2 is just a character A

now I have to concate these two strings in such a way that string1 should be padded with the string2 i.e. A and need to give new string with
string1+'A'

Please advise how it can be done.....

Note : tested with STRING with DELIMITED BY SPACE and not getting the result what I want...

thx in advance.....

pavan
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Feb 28, 2006 8:50 pm    Post subject: Re: concatenating the two strings
Reply with quote

pavan,

Can you give a specific example of what you want the resuilt to look like?

string1 PIC X(20) VALUE "sangeetha"
string2 = "A"

result = "sangeethaA" or "sangeethaAAAAAAAAAAA" or other?

Please clarify.

Thanks,

Dave
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Wed Mar 01, 2006 10:48 am    Post subject:
Reply with quote

Hi,

the result should be "sangeetha nityanandamA"
if string1 is "sangeetha nityanandam" and
not some thing like "sangeethaAAAAAAAAAAA" or other

I hope it is clear


thx in adv.....

pavan
Back to top
View user's profile Send private message
ranjitbhingare

New User


Joined: 30 Nov 2005
Posts: 94
Location: PUNE

PostPosted: Wed Mar 01, 2006 11:06 am    Post subject:
Reply with quote

Hi ,

To get the desired result, you can use STRING DELIMITED BY SIZE instead of space.

Correct me if I am wrong!

Regards,
Ranjit....
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Wed Mar 01, 2006 3:29 pm    Post subject:
Reply with quote

Hi

I used STRING DELIMITED BY SIZE also but I am not getting the exact result I want.......





pavan
Back to top
View user's profile Send private message
hncs

New User


Joined: 01 Mar 2006
Posts: 11

PostPosted: Thu Mar 02, 2006 4:30 pm    Post subject: STRING CONCATENATION
Reply with quote

Try it out*********************
----------------------------------------------------------------

01 WS-STR1 PIC X(10) VALUE 'ABCDEF'.

01 WS-STR2 PIC X(10) VALUE 'A'.

01 WS-STR3 PIC X(20) VALUE SPACES.

PROCEDURE DIVISION.
MAIN-PARA.

STRING WS-STR1 DELIMITED BY SIZE
WS-STR2 DELIMITED BY SIZE
INTO WS-STR3
END-STRING

STOP RUN.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Mar 02, 2006 11:17 pm    Post subject: Re: concatenating the two strings
Reply with quote

hncs,

The code you supplied produces the following result

Code:

ABCDEF    A       
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Mar 03, 2006 12:39 am    Post subject: Re: concatenating the two strings
Reply with quote

pavan,

The code below functions as I think you want. You can also accomplish this by using INSPECT statement to find the length of the literals in the strings.


Code:

01  WS-STR1                     PIC X(10) VALUE 'DAVE AT K'   
01  WS-STR2                     PIC X(10) VALUE 'A'.           
01  WS-STR3                     PIC X(20) VALUE SPACES.       
01  SUB                         PIC S9(3) COMP-3 VALUE +0.     
01  LEN-STR1                    PIC S9(3) COMP-3 VALUE +0.     
01  LEN-STR2                    PIC S9(3) COMP-3 VALUE +0.     


    COMPUTE LEN-STR1 = LENGTH OF WS-STR1 - 1.         
                                                     
    PERFORM                                           
      VARYING SUB FROM LEN-STR1 BY -1                 
      UNTIL SUB < 1                                   
      OR WS-STR1(SUB:1) NOT = ' '                     
    END-PERFORM.                                     
                                                     
    MOVE SUB                    TO LEN-STR1.         
                                                     
    COMPUTE LEN-STR2 = LENGTH OF WS-STR2 - 1.         
                                                     
    PERFORM                                           
      VARYING SUB FROM LEN-STR2 BY -1                 
      UNTIL SUB < 1                                   
      OR WS-STR2(SUB:1) NOT = ' '                     
    END-PERFORM.                                     
                                                             
    MOVE SUB                    TO LEN-STR2.                 
                                                             
    STRING WS-STR1(1:LEN-STR1) DELIMITED BY SIZE             
           WS-STR2(1:LEN-STR2) DELIMITED BY SIZE             
        INTO WS-STR3                                         
    END-STRING.                                             
                                                             
    DISPLAY WS-STR3.                                         


Results in the string:

Code:

DAVE AT KA           


Dave
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Fri Mar 03, 2006 12:29 pm    Post subject:
Reply with quote

Hi,

Thank you one and all who are involved in this forum.........

pavan
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