Replace characters in string in 4GL

 6 Replies
 0 Subscribed to this topic
 18 Subscribed to this forum
Sort:
Author
Messages
Lorena
Advanced Member
Posts: 37
Advanced Member
Hi,
I need to replace spaces by _ in a string in 4GL.
Does anyone know if Lawson provides any routine for this?

Example:
Input: Boca Raton
Output: Boca_Raton

Thanks,
Lorena
Woozy
Veteran Member
Posts: 709
Veteran Member
New Poster
New Poster
Congrats on posting!
The cobol "INSPECT" should do this for you:

INSPECT {VARIABLE} REPLACING ALL " " BY "_".
Kelly Meade
J. R. Simplot Company
Boise, ID
Lorena
Advanced Member
Posts: 37
Advanced Member
Thank you.
maalimsimo
Veteran Member
Posts: 49
Veteran Member
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
In trying to replace Carriage Return and Line Feed characters from a string (CMTAPI), I have tried to use INSPECT CMTAPI-EXT-TEXT REPLACING ALL x"0D" BY SPACES (for CR) and x"0A" (for LF). None seems to achieve my desired end as my output file still breaks up into two lines at the point where the user has put a hard return.
Any idea what else I need to try? A lot of Lawson pgms have x"A" replaced - what character is this?
Woozy
Veteran Member
Posts: 709
Veteran Member
New Poster
New Poster
Congrats on posting!
Hi maalimsimo,

I haven't tried this, but I have a couple of suggestions for you to try. 

First, use a capital "X" rather than "x", so INSPECT CMTAPI-EXT-TEXT REPLACING ALL X"0D" BY SPACES
Second, if it is a CRLF then try INSPECT CMTAPI-EXT-TEXT REPLACING ALL X"0D0A" BY SPACES

Good Luck.
Kelly Meade
J. R. Simplot Company
Boise, ID
Woozy
Veteran Member
Posts: 709
Veteran Member
New Poster
New Poster
Congrats on posting!
Actually, LineFeed may be "25" instead of "0A", so if the other doesn't work, try  INSPECT CMTAPI-EXT-TEXT REPLACING ALL X"0D25" BY SPACES 
Kelly Meade
J. R. Simplot Company
Boise, ID
maalimsimo
Veteran Member
Posts: 49
Veteran Member
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Never mind, it was a error in placement of the INSPECT statement in my code. It works just fine now