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 Handling Help

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


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Fri Aug 12, 2005 5:36 am    Post subject: String Handling Help Reply with quote

Hi,

I have some variables defined in the Working Storage as:
Quote:

WS-A PICX(1)
WS-B PICX(1)
WS-C PICX(1)
WS-D PICX(1)
WS-OUTPUT PIC X(7)


Based on a SQL, WS-A,WS-B, WS-C, WS-D variables MAY or MAY NOT get populated.

What I want to do is, Say WS-A, WS-C are populated with A and C respectively. Now this has to formatted and moved to a WS-OUTPUT variable as A,C. If it is WS-A,WS-C and WS-D, then WS-OUTPUT should be populated with A,C,D

Can someone here help me with the Procedure Division Statements to achieve this using Cobol String Functions
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: Fri Aug 12, 2005 7:18 am    Post subject: Reply with quote

What have you attempted alaready? Let us know the errors that you are facing in your attempt.
_________________
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
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Fri Aug 12, 2005 7:33 am    Post subject: Reply with quote

sakreq,
String all the variables into a WS field(STRING ?? DELIMITED BY SPACE)
. Then reverse to remove the trailing blanks and move them to your output one by one, adding a ','.
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: Fri Aug 12, 2005 7:40 am    Post subject: Reply with quote

Suresh,
What sakreg wants can be acheived by declaring WS-OUTPUT as a group variable and using only MOVE statements. STRING, INSPECT REVERSE are not needed.
_________________
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
shivashunmugam Muthu
Beginner


Joined: 11 Aug 2005
Posts: 5
Topics: 0
Location: Chennai, India

PostPosted: Fri Aug 12, 2005 7:44 am    Post subject: Reply with quote

Yes,..with group variable & some simple validation for inputs 2 check spaces is enough!
Back to top
View user's profile Send private message Yahoo Messenger
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Fri Aug 12, 2005 9:10 pm    Post subject: Reply with quote

I was thinking to approach this using STRING and INSPECT verbs. I could not find a way how to use those.

But anyway to concat ',' with the DB values I have to use STRING I believe.

Can you guys please make it a bit more clear.

Thank You for having a look.
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: Sun Aug 14, 2005 6:10 am    Post subject: Reply with quote

Like this,
Code:

01 WS-OUTPUT.       
   05 WS-A-1  PIC X.
   05 FIL-1   PIC X.
   05 WS-B-1  PIC X.
   05 FIL-2   PIC X.
   05 WS-C-1  PIC X.
   05 FIL-3   PIC X.
   05 WS-D-1  PIC X.

Move commas to the FIL-x and the values to WS-A-1 or WS-B-1 as the need maybe.
_________________
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
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Mon Aug 15, 2005 11:41 am    Post subject: Reply with quote

Thanks Cogito-Ergo-Sum

Say IF WS-A-1 and WS-D-1 are Populated with A and D respectively, What I expect in WS-OUTPUT is A,D. As of now WS-OUTPUT would be A, , ,D.

Can this be done?
Back to top
View user's profile Send private message
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Mon Aug 15, 2005 4:27 pm    Post subject: Reply with quote

I think this code would do what you want. It accepts a 4 byte field as a JCL parm, so you can experiment with all kinds of combinations.
Code:

       WORKING-STORAGE SECTION.                                       
       01  WORK-LINE.                                                 
           03 F1W.                                                     
              05  F1                     PIC X.                       
              05                         PIC X VALUE ','.             
           03 F2W.                                                     
              05  F2                     PIC X.                       
              05                         PIC X VALUE ','.             
           03 F3W.                                                     
              05  F3                     PIC X.                       
              05                         PIC X VALUE ','.             
           03 F4W.                                                     
              05  F4                     PIC X.                       
              05                         PIC X VALUE SPACE.           
       01  WS-DISPLAY-LINE               PIC X(7) VALUE SPACES.       
       LINKAGE SECTION.                                               
       01  FIELDS.                                                     
           05  FIELDS-LENGTH             PIC 9(4) COMP.               
           03  F1W.                                                   
           05  F1                        PIC X.                       
           03  F2W.                                                     
           05  F2                        PIC X.                         
           03  F3W.                                                     
           05  F3                        PIC X.                         
           03  F4W.                                                     
           05  F4                        PIC X.                         
       EJECT                                                           
       PROCEDURE DIVISION USING FIELDS.                                 
           MOVE CORR FIELDS TO WORK-LINE                               
           STRING F1W IN WORK-LINE DELIMITED BY SPACE                   
                  F2W IN WORK-LINE DELIMITED BY SPACE                   
                  F3W IN WORK-LINE DELIMITED BY SPACE                   
                  F4W IN WORK-LINE DELIMITED BY SPACE                   
                  INTO WS-DISPLAY-LINE.                                 
           INSPECT WS-DISPLAY-LINE REPLACING ALL ', ' BY '  '.         
           DISPLAY 'DL=' WS-DISPLAY-LINE.                               
           GOBACK.                                                     

________
Mazda AZ-Wagon picture


Last edited by dtf on Tue Feb 01, 2011 2:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Fri Aug 19, 2005 2:58 am    Post subject: Reply with quote

That complies my expectations.

Thank You So Much, dtf
Back to top
View user's profile Send private message
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