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
 

 

Regarding Unstring

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

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Thu Mar 20, 2008 1:32 pm    Post subject: Regarding Unstring
Reply with quote

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
View user's profile Send private message

shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 171
Location: Bangalore

PostPosted: Thu Mar 20, 2008 2:19 pm    Post subject: Reply to: Regarding Unstring.
Reply with quote

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
View user's profile Send private message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Thu Mar 20, 2008 3:07 pm    Post subject: Regarding unstring verb
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Mar 20, 2008 3:27 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Thyaga

New User


Joined: 19 Mar 2008
Posts: 2
Location: Chennai

PostPosted: Thu Mar 20, 2008 3:52 pm    Post subject:
Reply with quote

U can use string,instead of unstring.
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 95
Location: India

PostPosted: Thu Mar 20, 2008 4:42 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Mar 20, 2008 4:54 pm    Post subject:
Reply with quote

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
View user's profile Send private message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Thu Mar 20, 2008 4:54 pm    Post subject:
Reply with quote

Thanks alott!!!!
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Mar 20, 2008 5:43 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Mar 20, 2008 6:12 pm    Post subject:
Reply with quote

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
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 95
Location: India

PostPosted: Thu Mar 20, 2008 6:35 pm    Post subject:
Reply with quote

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 icon_confused.gif ? 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 icon_cry.gif
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 Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts Problem with UNSTRING of CSV data Bill Woodger COBOL Programming 14 Tue Dec 15, 2015 5:32 pm
No new posts Unstring in Cobol Govardhana krishna COBOL Programming 7 Thu Oct 17, 2013 8:52 pm
No new posts Unstring the message d katkuri COBOL Programming 13 Wed Aug 14, 2013 12:28 pm
No new posts UNSTRING of Variable length Data kedianirmal COBOL Programming 9 Thu Jul 18, 2013 3:25 pm


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