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

concatenating the two strings


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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
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
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
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 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