View previous topic :: View next topic
|
Author |
Message |
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
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 |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
Back to top |
|
|
HARLEEN SINGH MANN Warnings : 2 New User
Joined: 03 Aug 2007 Posts: 17 Location: Pune
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
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 |
|
|
HARLEEN SINGH MANN Warnings : 2 New User
Joined: 03 Aug 2007 Posts: 17 Location: Pune
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Harleen,
Quote: |
sorry for the wrong info previously. |
Not to worry
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 |
|
|
sandy_venkat
New User
Joined: 16 May 2007 Posts: 35 Location: India
|
|
|
|
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 |
|
|
sandy_venkat
New User
Joined: 16 May 2007 Posts: 35 Location: India
|
|
|
|
The code posted b4 also gave an error MAX CC = 12
'EXPECTED DELIMITED BUT FOUND INTO' |
|
Back to top |
|
|
balakrishna reddy
Active User
Joined: 13 Jul 2007 Posts: 128 Location: Guntur
|
|
|
|
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 |
|
|
sandy_venkat
New User
Joined: 16 May 2007 Posts: 35 Location: India
|
|
|
|
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 |
|
|
balakrishna reddy
Active User
Joined: 13 Jul 2007 Posts: 128 Location: Guntur
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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
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
|
|
Back to top |
|
|
|