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

String different occurances of 3 variables to a variable.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sarat6900

New User


Joined: 02 Mar 2009
Posts: 12
Location: India

PostPosted: Thu May 13, 2010 1:03 pm
Reply with quote

Hi Team,

I am looking to string three variables as an input to a store procedure from different records

Var 1 - X(10)
Var 2 - X(20)
Var 3 - X(80)


I want to string it as Var 1,Var 2,Var 3|Var1,Var2,Var3|Var1,Var2,Var3|Var1,Var2,Var3|
to Final String X(1000)

For Eg:

Input has 4 Records

Rec 1
-----
Var 1 - A1
Var 2 - AAAAA
Var 3 - AAAAAAAAA

Rec 2
-----
Var 1 - B11
Var 2 - BBBBB
Var 3 - BBBBBBBBBB

Rec 3
-----
Var 1 - C11
Var 2 - CCCCC
Var 3 - CCCCCCCCCC

Rec 4
-----
Var 1 - D
Var 2 - DDDDD
Var 3 - DDDDDDDDDD


Out put string

When Rec 1 (Remove the trailing space and add delimiter | )

Final String
------------
A1,AAAAA,AAAAAAAAA|


When Rec 2 (Remove the trailing space and add delimiter | and build from REC 1 )
Final String
------------
A1,AAAAA,AAAAAAAAA|B11,BBBBB,BBBBBBBBBB|


When Rec 3 (Remove the trailing space and add delimiter | and build from REC 2 )
Final String
------------
A1,AAAAA,AAAAAAAAA|B11,BBBBB,BBBBBBBBBB|C11,CCCCC,CCCCCCCCCC|

When Rec 4 (Remove the trailing space and add delimiter | and build from REC 3 )
Final String
------------
A1,AAAAA,AAAAAAAAA|B11,BBBBB,BBBBBBBBBB|C11,CCCCC,CCCCCCCCCC|D,DDDDD,DDDDDDDDDD|


In need to find the length of the Final string i.e. excluding space.

Is this possible..

Any help is greatly appreciated..

Thanks,
Sarat.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu May 13, 2010 4:38 pm
Reply with quote

What have you tried so far and what results have you gotten?

Have you clicked on the manuals link at the top of the page and read the COBOL Language Reference manual on the STRING statement?

Quote:
Is this possible..
Yes, it is possible. However, this is a HELP forum, not a DO-YOUR-JOB-FOR-YOUR forum, so don't expect us to just give you the code. We can guide you when you have problems, but since most of us responders are paid for our professional work output, asking for code will not typically get you much unless you're willing to pay the going daily rates (typically about 1000 U.S. dollars per day or fraction thereof).
Back to top
View user's profile Send private message
sarat6900

New User


Joined: 02 Mar 2009
Posts: 12
Location: India

PostPosted: Thu May 13, 2010 7:02 pm
Reply with quote

Sorry Robert.

I had a solution of my own (delimited by ' ') 3 spaces and string. I did not like for a generic solution

I just wanted to know if there is a better way for that.

Dont get me wrong, I dint want you to code for me!!!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu May 13, 2010 7:12 pm
Reply with quote

unless any of the var's can contain all spaces:
simply string a var, delimited by spaces,a '|', then then next var, etc.
then do an inspect tally reverse for first non-space will give you the length.
or simply increment an index until a space is encountered.
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Tue May 18, 2010 12:31 pm
Reply with quote

If this is an array you can use 'with pointer' clause in the string function
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
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top