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.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
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).
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
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.