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
 

 

How to concatenate two fileds with AND in middle

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

Active User


Joined: 01 Feb 2007
Posts: 120
Location: USA

PostPosted: Sat Oct 20, 2007 11:11 am    Post subject: How to concatenate two fileds with AND in middle
Reply with quote

Hi,

My requirement is I had two fileds. Say
WS-FIELD1 PIC X(20).
WS-FILED2 PIC X(20).

If my WS-FILED1 has 'TULASI BHASKAR' and my WS-FIELD2 has 'SUNIL KUMAR'.
My output should be TULASI BHASKAR AND SUNIL KUMAR.
How can i achieve this. If i use delimited by space in string, after TULASI it is deleting. Can anyone tell me how can i achieve this.
Back to top
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Sat Oct 20, 2007 12:34 pm    Post subject:
Reply with quote

Bhaskar,

A simple search in the forum might have yielded this link to you -

http://ibmmainframes.com/archive/o_t__t_16964__start_0__index.html
Back to top
View user's profile Send private message
HARLEEN SINGH MANN
Warnings : 2

New User


Joined: 03 Aug 2007
Posts: 17
Location: Pune

PostPosted: Sat Oct 20, 2007 11:54 pm    Post subject:
Reply with quote

Mr Bhaskar.

Its quiet simple use : STRING WS-FIELD1 'AND' WS-FIELD2
INTO WS-FIELD3
DELIMITED BY SIZE

hope u read more about the string and gain ur experiance.

Regards,
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Oct 21, 2007 1:48 am    Post subject:
Reply with quote

Hello Harleen,

Code:
Its quiet simple use : STRING WS-FIELD1 'AND' WS-FIELD2
INTO WS-FIELD3
DELIMITED BY SIZE
Please try this on your machine. It is not syntactically correct. Also, it will not give the exact same result as the requirement asks for when the syntax is corrected. . . . It will be similar, but will not work for the requirement.

If you have questions about the result when you try it, post your code and any questions about it here.

Someone will be able to offer suggestions.
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 120
Location: USA

PostPosted: Mon Oct 22, 2007 8:53 am    Post subject: Reply to: How to concatenate two fileds with AND in middle
Reply with quote

Hi murmohk,

Thanks for providing the link. It worked for me.
I search in forum before posting it. But i didnt find it.
Any way thanks for you reply.
Back to top
View user's profile Send private message
HARLEEN SINGH MANN
Warnings : 2

New User


Joined: 03 Aug 2007
Posts: 17
Location: Pune

PostPosted: Mon Oct 22, 2007 10:15 pm    Post subject:
Reply with quote

scherrer,

It came to my notice that you are right I put it in a wrong way. Feel ashamed but wel this should work:

STRING WW-F1 DELIMITED BY 'AND' WW-F2 INTO WW-F3.
DISPLAY C.

sorry for the wrong info previously.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Oct 22, 2007 10:21 pm    Post subject:
Reply with quote

Hello Harleen,

Quote:
sorry for the wrong info previously.
Not to worry icon_smile.gif

Code:
STRING WW-F1 DELIMITED BY 'AND' WW-F2 INTO WW-F3.
Do note that a space is needed on both sides of the "AND" also. Otherwise, the values will "run together".
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Tue Oct 23, 2007 10:17 am    Post subject:
Reply with quote

Hi dick,

the code posted above by harleen would not work either. I tried it out. It just displays the two names with spaces in between. This works.

Code:


STRING  WW-F1 DELIMITED BY SIZE
       ' AND ' DELIMITED BY SIZE
       WW-F2 DELIMITED BY SIZE
            INTO WW-F3.
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Tue Oct 23, 2007 10:18 am    Post subject:
Reply with quote

The code posted b4 also gave an error MAX CC = 12

'EXPECTED DELIMITED BUT FOUND INTO'
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Tue Oct 23, 2007 11:19 am    Post subject:
Reply with quote

Hi guys,

I think we are going in a wrong way because if you put delimited by size then we will be remained with the trailing spaces as below

Code:

01 ws-fld1  pic  x(20) value "balakrishna".
01 ws-fld2  pic x(20) value "reddy".
01 ws-fld3  pic x(40).

if we put string ws-fld1 ' AND ' ws-fld2 delimited by size into ws-fld3

output will be like below:
balakrishna          AND reddy

 


but the requirement is "balakrishna and reddy" as i believe

i think you might have understood what i am trying to say.

Please correct me if i am wrong.
Back to top
View user's profile Send private message
sandy_venkat

New User


Joined: 16 May 2007
Posts: 35
Location: India

PostPosted: Tue Oct 23, 2007 4:37 pm    Post subject:
Reply with quote

I got what you are trying to say bala. I guess instead of using DELIMITED BY SIZE we can use DELIMITED BY SPACE and give extra spaces in the ' AND '. This way, we can acheive 'balakrishna and reddy'.
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Tue Oct 23, 2007 5:05 pm    Post subject:
Reply with quote

Hi Venkat,

As you have said we can use delimited by space instead of size, But it will work only for the string i have taken but what about the string which have space in between it like "bala krishna"

but what i am trying to say is if the string length is less than what we have given in the declaration then we will get trailing spaces when we use string function to concatenate.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Oct 23, 2007 8:29 pm    Post subject:
Reply with quote

Hello,

I misread the earlier post when i suggested putting spaces on both sides of the AND - i didn't recognize the code was in error icon_redface.gif

If the "names" fields will only have one space between the name components, the delimiter could be a double-space.

On a COBOL Enterprise system, this

Code:
*                                     
 01  WS-T PIC X(9) VALUE 'AA BBB  '.   
 01  WS-U PIC X(9) VALUE 'XXX YY  '.   
 01  WS-V PIC X(19) VALUE SPACES.     

    STRING WS-T ' AND ' WS-U DELIMITED BY '  '       
      INTO WS-V.                                     
    DISPLAY WS-V.             

gives
Code:
AA BBB AND XXX YY
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 Unload a table and converting fileds danylele74 DB2 2 Thu Nov 26, 2015 9:00 pm
No new posts Concatenate different LRECL GDG's Rohit Umarjikar DFSORT/ICETOOL 6 Wed Nov 18, 2015 3:30 am
No new posts Concatenate 2 different VB files to a... santhosh5983 DFSORT/ICETOOL 8 Sat Oct 10, 2015 2:12 am
No new posts How to concatenate a dataset with SYS... swathykrishnan CLIST & REXX 8 Tue Sep 01, 2015 6:08 pm
No new posts how to concatenate two cobol loadlib ... boyti ko CLIST & REXX 2 Mon Jun 29, 2015 4:41 pm


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