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 syntax needed

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


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Nov 09, 2005 5:29 am    Post subject: String syntax needed Reply with quote

Hi all,

I am basically trying to generate a output like this :


Code:

TODAY IS WEDNESDAY@WED




So i declared the variables like this :

Code:

01 P PIC X(30) VALUE SPACES.
01 Q PIC X(1)  VALUE SPACES.
01 R PIC X(30) VALUE SPACES.
01 S PIC X(30) VALUE SPACES.


PROCEDURE DIVISION.

MOVE 'TODAY IS WEDNESDAY' TO P.
MOVE '@'                  TO Q.
MOVE 'WED'                TO R.
STRING P Q R DELIMITED BY SIZE INTO S.
DISPLAY "S IS:" S.




OUTPUT
------

Code:

S IS:TODAY IS WEDNESDAY




But i am not able to get the desired output.Can anybody help me out to get the desired result ?
_________________
Shekar
Grow Technically
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: Wed Nov 09, 2005 5:38 am    Post subject: Reply with quote

shekar123,

check this link for a detailed explanation of the string command

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/6.2.37?DT=20020920180651

See this topic for an example . you need to use delimited by space.

http://www.mvsforums.com/helpboards/viewtopic.php?p=21816#21816

Btw by now you should be able to look up the syntax from the manuals

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


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Nov 09, 2005 5:52 am    Post subject: string syntax needed Reply with quote

Kolusu,

If i use

Code:

STRING P Q R DELIMITED BY SPACE INTO S


i get the result as :

Code:

TODAY IS WEDNESDAY



I am interested in getting the desired output.I still get the same output as before.How can i get the desired output ?

Code:

TODAY IS WEDNESDAY@WED


_________________
Shekar
Grow Technically
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: Wed Nov 09, 2005 5:55 am    Post subject: Reply with quote

shekar123,

Did you even read the example I posted ? Twisted Evil Read the string statement in my example post once again.

You can specify the delimited clause for individual fields ! spend some time reading

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


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Nov 09, 2005 6:14 am    Post subject: string syntax needed Reply with quote

Kolusu,

I have tried out the different options after reading the material & here is what i have tried


Code:

STRING P DELIMITED BY SPACE Q DELIMITED BY SPACE       
                            R DELIMITED BY SPACE INTO S.



OUTPUT

Code:

TODAY@WED





Code:

STRING P DELIMITED BY SIZE  Q DELIMITED BY SPACE       
                            R DELIMITED BY SPACE INTO S.



OUTPUT

Code:

TODAY IS WEDNESDAY



My desired result is

Code:

TODAY IS WEDNESDAY@WED


_________________
Shekar
Grow Technically
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: Wed Nov 09, 2005 8:38 am    Post subject: Reply with quote

Shekhar123,

Try this.

Code:

01 P PIC X(30) VALUE SPACES.                       
01 Q PIC X(1)  VALUE SPACES.                       
01 R PIC X(30) VALUE SPACES.                       
01 S PIC X(50) VALUE SPACES.                       
01 WS-LEN   PIC S9(04) COMP.                       
01 WS-TALLY  PIC S9(04) COMP.                       
                                                   
PROCEDURE DIVISION.                                 
                                                   
    MOVE 'TODAY IS WEDNESDAY' TO P.                 
    MOVE '@'                  TO Q.                 
    MOVE 'WED'                TO R.                 
                                                   
    INSPECT FUNCTION REVERSE(P) TALLYING WS-TALLY   
        FOR LEADING SPACES                         
                                                   
    COMPUTE WS-LEN  = LENGTH OF P - WS-TALLY       
                                                   
    STRING P(1:WS-LEN) DELIMITED BY SIZE           
           Q DELIMITED BY SIZE                     
           R DELIMITED BY SPACE                     
      INTO S.                                       
                                                   
    DISPLAY "S IS:" S.                             


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
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Nov 09, 2005 8:54 am    Post subject: string syntax needed Reply with quote

Thanks Kolusu,

You are great.The code worked fine and it gave me expected result.The logic used by you is really awesome and i was able to put light that even intrsinsic functions as well as reference modifications can also be used in Character Functions.


Code:

S IS:TODAY IS WEDNESDAY@WED


_________________
Shekar
Grow Technically
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