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
 

 

INSPECT with REPLACING problem

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
bshkris

New User


Joined: 21 Mar 2005
Posts: 22
Location: pune

PostPosted: Wed May 05, 2010 9:27 pm    Post subject: INSPECT with REPLACING problem
Reply with quote

I have one problem in removing the space and replacing with one string.

The total length of the variable is X(30).

so, the varaible may contains data, for ex: I AM BAD PERSON
the space may occur at any place in the length of 30.
I need to replace the space with "%20".
When i tried with INSPECT with REPLACING, it throws compilation error since, the space is like i char, and trying to fill with larger data item of 3 chars.
so i need to implement some tricky logic to convert the spaces into "%20".
But not able to do.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Wed May 05, 2010 9:33 pm    Post subject:
Reply with quote

Quote:
If some has any idea, please share it ASAP.
If you have to have an answer quickly, you've picked the worst possible way to get one. You should talk to your coworkers, team leader, or site support group if you need a quick answer. We are a help forum and we don't do fast.

Second, why are you doing this -- %20 is an HTML way of identifying a space, which would not work on any EBCDIC based mainframe since spaces on the mainframe are hex '40' not hex '20' as in ASCII.

Third, why are you doing this? Typically such transformations are handled by the web services and not your application.

Finally, you can define a 90-byte variable (to allow for all 30 characters of your input variable to be spaces and use reference modification to check each byte and move it or the replacement into the output variable.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed May 05, 2010 9:33 pm    Post subject: Reply to: INSPECT with REPLACING problem
Reply with quote

Quote:
If some has any idea, please share it ASAP.

sorry but we do not do ASAP
answering is on voluntary effort, time, benevolence factor towards the requesting

using terms like ASAP or URGENT lowers dramatically the benevolence factor
Back to top
View user's profile Send private message
bshkris

New User


Joined: 21 Mar 2005
Posts: 22
Location: pune

PostPosted: Thu May 06, 2010 1:03 pm    Post subject:
Reply with quote

Robert Sample wrote:
Quote:
If some has any idea, please share it ASAP.
If you have to have an answer quickly, you've picked the worst possible way to get one. You should talk to your coworkers, team leader, or site support group if you need a quick answer. We are a help forum and we don't do fast.

Second, why are you doing this -- %20 is an HTML way of identifying a space, which would not work on any EBCDIC based mainframe since spaces on the mainframe are hex '40' not hex '20' as in ASCII.

Third, why are you doing this? Typically such transformations are handled by the web services and not your application.

Finally, you can define a 90-byte variable (to allow for all 30 characters of your input variable to be spaces and use reference modification to check each byte and move it or the replacement into the output variable.



Thanks for acknowledging,
I am adding the sentence to URL which hardcoded in working storage section variables.
as like
"http://www.xxxx.usernotification/expiry/date?quryName: I%20BAD%20NAME

Updo quryName in URL, we did in working storage value.
The last value is redriving from db2 table where it has some group of words having spaces.

we are generating the URL with dynamic values and putting in output dataset for the client reference.

I have tried in many ways, like using arrays, using INSPECT...but none of them is working out. ofcourse bit interesting and same time time brain storming thing.

Thanks.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu May 06, 2010 1:29 pm    Post subject:
Reply with quote

OK, this is in the COBOL forum.
You want to replace one character with more than one character.
Define an area larger than the original area and using a perform to loop scan and move, one byte at a time from the original to the destination area, replacing the one byte with the multiple bytes as needed.
This is a fifteen minute exercise and you should have fun doing it.
If you get stuck, please post what you have and we all can advise.
Back to top
View user's profile Send private message
Pravesh

New User


Joined: 30 Jul 2009
Posts: 32
Location: Gurgaon

PostPosted: Thu May 06, 2010 3:17 pm    Post subject: Reply to: INSPECT with REPLACING problem
Reply with quote

You can try something like this:-

Code:
01 VAR-A      PIC X(30).
01  VAR-B     PIC  X(90).
01  m            PIC 99 value zero.
01  n             PIC 99.

Perform varying n from 1 by 1 until n<30
  If VAR-A(n:1) = ' '
      MOVE '%20'  to VAR-B(m : 3)
      m=m+3
   Else
     MOVE  VAR(n:1)    TO   VAR-B(m : 1)
     m= m+1
  End-if


Regards,
Pravesh
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 06, 2010 4:47 pm    Post subject:
Reply with quote

Code:
Perform varying n from 1 by 1 until n<30


Pravesh,
you need to double check you code when you post a solution.
Howmany characters do you think the above perform will move?

VAR-B should also be INITIALIZED.
Back to top
View user's profile Send private message
Pravesh

New User


Joined: 30 Jul 2009
Posts: 32
Location: Gurgaon

PostPosted: Thu May 06, 2010 5:29 pm    Post subject: Reply to: INSPECT with REPLACING problem
Reply with quote

yeah that is the reason I specified

'You can try something like this:- '

in my post.....



Regards,
Pravesh[/quote]
Back to top
View user's profile Send private message
bshkris

New User


Joined: 21 Mar 2005
Posts: 22
Location: pune

PostPosted: Fri May 07, 2010 1:58 pm    Post subject:
Reply with quote

Thank you all for timely suggestions.
Today i will do this and let you know about tjhe results.
Back to top
View user's profile Send private message
bshkris

New User


Joined: 21 Mar 2005
Posts: 22
Location: pune

PostPosted: Fri May 07, 2010 5:53 pm    Post subject:
Reply with quote

hi all,
this peice of code worked at last.

Code:
 MOVE    0            TO WS-CNT1                           
 move   +1            TO WS-CNT2                           
                                                           
 PERFORM VARYING WS-CNT1 FROM 1 BY 1 UNTIL WS-CNT1 > 30   
   IF WS-TEXT1(WS-CNT1:1) = ' '                           
      MOVE '%20'      TO WS-TEXT2(WS-CNT2:3)               
      COMPUTE WS-CNT2 = WS-CNT2 + 3                       
   ELSE                                                   
      MOVE WS-TEXT1(WS-CNT1:1)      TO WS-TEXT2(WS-CNT2:1)
      COMPUTE WS-CNT2 = WS-CNT2 + 1                       
   END-IF                                                 
 END-PERFORM                                           



Thank you very much.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri May 07, 2010 7:14 pm    Post subject:
Reply with quote

bshkris wrote:
this peice of code worked at last
Looks good, kind of fun, wasn't it?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 11, 2010 6:00 am    Post subject:
Reply with quote

Quote:
We are a help forum and we don't do fast.
Kind of reminds me of, "You can have it cheap, you can have it fast, you can have it good -- pick any two." icon_lol.gif
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Tue May 11, 2010 9:32 am    Post subject:
Reply with quote

bshkris wrote:
this piece of code worked at last.
What do you mean by "at last"? It shouldn't have been too difficult, following Pravesh pseudo-code.
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 Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm
No new posts TXT2PDF problem - printing @ in PDF vipul65 All Other Mainframe Topics 9 Thu Aug 25, 2016 12:48 am


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