MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

String Command with Tables/Arrays

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Disco_Stu
Beginner


Joined: 04 Feb 2003
Posts: 19
Topics: 7

PostPosted: Wed Jun 09, 2004 3:37 pm    Post subject: String Command with Tables/Arrays Reply with quote

I am working with a table of data that I need to String together to send to another process. If my table has 5 columns and 4 rows, how would I use the String command to put all the data in this table together?? I know how to use the String command to put together many different variables, but am unsure how to use it with Tables and subscripts. Any help is greatly appreciated.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jun 10, 2004 5:10 am    Post subject: Reply with quote

Disco stu,

Can you give us an example?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Disco_Stu
Beginner


Joined: 04 Feb 2003
Posts: 19
Topics: 7

PostPosted: Thu Jun 10, 2004 6:47 am    Post subject: Example Reply with quote

Table looks like this: 3 rows of data with 4 columns

abc xyz n 12345 12345
abc xyz y 56789 56789
abc ooo n 2468 2468

And I would like data to be strung together so it looks like this:

abc;xyz;n;12345;12345;abc;xyz;y;56789;56789;abc;ooo;n;2468;2468

Thanks for all your help.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Jun 10, 2004 7:34 am    Post subject: Reply with quote

I am not sure about this.

But, CONCAT function (or, ||) might be what you are looking for. However, it takes only two arguements; string1 and string2. So, probably, you may want to nest the concatenation function.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jun 10, 2004 8:12 am    Post subject: Reply with quote

Disco_stu,

A Very simple exercise. Let us say your table structre is ws-tbl1 (assumption made on your example data)

Now define another table stucture WS-TBL2 but with delimiters and redefine this table with a single field so that you get the desired results.

Code:

01 WS-TBL1.                                     
   05 WS-FLD-TBL1 OCCURS 3 TIMES.               
      10 WS-FLD1  PIC X(03).                     
      10 WS-FLD2  PIC X(03).                     
      10 WS-FLD3  PIC X(01).                     
      10 WS-FLD4  PIC X(05).                     
      10 WS-FLD5  PIC X(05).                     
                                                 
01 WS-TBL2.                                     
   05 WS-FLD-TBL2 OCCURS 3 TIMES.               
      10 WS-FLD1  PIC X(03).                     
      10 FILLER   PIC X(01) VALUE ';'.           
      10 WS-FLD2  PIC X(03).                     
      10 FILLER   PIC X(01) VALUE ';'.           
      10 WS-FLD3  PIC X(01).                     
      10 FILLER   PIC X(01) VALUE ';'.           
      10 WS-FLD4  PIC X(05).                     
      10 FILLER   PIC X(01) VALUE ';'.           
      10 WS-FLD5  PIC X(05).                     
      10 FILLER   PIC X(01) VALUE ';'.           

01 WS-STRING REDEFINES WS-TBL2 PIC X(66). 

PROCEDURE DIVISION.
                                                   
   MOVE CORRESPONDING WS-FLD-TBL1(1) TO WS-FLD-TBL2(1)
   MOVE CORRESPONDING WS-FLD-TBL1(2) TO WS-FLD-TBL2(2)
   MOVE CORRESPONDING WS-FLD-TBL1(3) TO WS-FLD-TBL2(3)
                                                   
   DISPLAY WS-STRING                                   



Once you have the populated the WS-TBL1 with your example data , then ws-string will contain

Code:

ABC;XYZ;N;12345;12345;ABC;XYZ;Y;56789;56789;ABC;OOO;N;2468 ;2468 ;


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Jun 10, 2004 8:23 am    Post subject: Reply with quote

I was half-sure that, he meant WS. But, I felt DB2 table sounded more obvious.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jun 10, 2004 8:40 am    Post subject: Reply with quote

Cogito,

hmm may be you are right. I just assumed that he wanted a cobol solution as he mentioned "he was unsure how to use it with Tables and subscripts."

May be Disco_stu needs to clarify.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Jun 10, 2004 8:44 am    Post subject: Reply with quote

Oh, now I read more carefully. Maybe, you are right. Smile
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Disco_Stu
Beginner


Joined: 04 Feb 2003
Posts: 19
Topics: 7

PostPosted: Thu Jun 10, 2004 9:07 am    Post subject: Reply with quote

This is for a Cobol program so the solution you gave would work. But to add some more difficulty to it, what if I do not know the actual number of table entries. If Table is set up for 100 occurs, but only 25 actually are in it, would solution you mentioned still give me result I am looking for or would I have a whole lot of delimiters on the end?? Thanks for all your help.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jun 10, 2004 9:32 am    Post subject: Reply with quote

Disco_stu,

You will have a lot of delimiters at the end if the table is partially filled. If you don't want the delimiters , you can use reference modification to chop off the delimiters.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group