View previous topic :: View next topic
|
Author |
Message |
jackal Currently Banned New User
Joined: 21 Jan 2006 Posts: 48 Location: india
|
|
|
|
I have doubt regarding unstring verb:-
I have a two fields on DB2 table
A value -> Agent Smith
B value -> Community loan and Trust
In code we are formatting this name and it is breaking both values when there is spaces:-
Inspect TV-326-CDD-Fld-Vl-Tx
Converting WS-Lower-Case To WS-Upper-Case -->giving AGENT SMITH
Unstring TV-326-CDD-Fld-Vl-Tx
Delimited By Spaces
Into TV-326-Frst-Nm --- give AGENT
Count In TV-326-Sub-1-Sq
End-Unstring
same for second element B -> Community loan and Trust
Inspect TV-326-CDD-Fld-Vl-1-Tx
Converting WS-Lower-Case To WS-Upper-Case
Unstring TV-326-CDD-Fld-Vl-1-Tx
Delimited By Spaces
Into TV-326-Last-Nm --- give COMMUNITY
Count In TV-326-Sub-2-Sq
End-Unstring
finnally
Move TV-326-Last-Nm
To TV-326-Frmt-Nm (TV-326-Sub-1-Sq:TV-326-Sub-2-Sq)
so getting final o/p as AGENT COMMUNITY
BUT my reqr is to get:- AGENT SMITH COMMUNITY LOAN AND TRUST
so how can i modify on DB2 table to get this o/p?
or is there any code change suggestion to display this string?Thanks..... |
|
Back to top |
|
|
shrivatsa Warnings : 1 Active User
Joined: 17 Mar 2006 Posts: 174 Location: Bangalore
|
|
|
|
If I understand your problem correctly..
After converting into upper case why you are using UNSTRING
Use STRING to CONCATE the two fileds |
|
Back to top |
|
|
jackal Currently Banned New User
Joined: 21 Jan 2006 Posts: 48 Location: india
|
|
|
|
Shrivatsa,
Actual code is in prod i cannot modify with having PM permission...is there any way to get the expected results?Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
only reason you would want to unstring and then string is because of the possibility of double spaces between words within a column.
if you don't have any imbedded double spaces between words in each of the two columns, why don't you use trim and concatenate within the sql.
if you have 'adam smite ' in one column, (two spaces between adam and smite) then you will need to unstring to left justify.
If you have variable number of words in each column, you need to clean up your table, (remove all double spaces between words within a column) and use the trim/concatenate sql.
If you can not clean up the table and can have a variable number of words within a column, then the unstring, string logic becomes tedious, even though you could do it with an internal cobol table.- |
|
Back to top |
|
|
Thyaga
New User
Joined: 19 Mar 2008 Posts: 2 Location: Chennai
|
|
|
|
U can use string,instead of unstring. |
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
Hi jackal,
The below code may help you.
Code: |
STRING
A
DELIMITED BY SIZE
' '
B
DELIMITED BY SIZE
INTO
WS-RESULT
END-STRING
INSPECT WS-RESULT
CONVERTING 'abcdefghijklmnopqrstuvwxyz'
TO 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
In Rajesh S's example, if A contains more that 1 trailing space, the solution is not applicable for the OP's requirement.
If you can not trim and concatenate with the sql, you will need to unstring and then string the multi-parts generated by the unstring and include a space between.
I believe that the 'DELIMITED BY' phrase is required. thus, Rajesh_mbt's solution will not even compile. If it is an optional phrase, then there must be a default, which must be 'SIZE'. |
|
Back to top |
|
|
jackal Currently Banned New User
Joined: 21 Jan 2006 Posts: 48 Location: india
|
|
|
|
Thanks alott!!!! |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
Is the UPPER-CASE function in COBOL completely unknown? You can eliminate the costly INSPECT if you use UPPER(columnname) on your SQL or use MOVE UPPER-CASE(TV-326-CDD-Fld-Vl-Tx) to TV-326-CDD-Fld-Vl-Tx |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
How about
Code: |
SELECT UCASE(TRIM(A) CONCAT ' ' CONCAT TRIM(B))
|
That would get you the two values already combined and uppercased. |
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
Hi Dick Brenholtz
I dont understand what is the problem with my code. I've tested the program and worked fine. Why do you assume that there would be a trailing space before A ? In jackal query that he had not mentioned anything about trailing space. The sample code has been posted based on what he required for his query |
|
Back to top |
|
|
|