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
 

 

String different occurances of 3 variables to a variable.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: String different occurances of 3 variables to a variable.
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: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 13, 2010 4:38 pm    Post subject:
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    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Thu May 13, 2010 7:12 pm    Post subject:
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    Post subject:
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    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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm


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