Replace occurrences of character in a string with another

In Customer Shipment Entry, the ship to is a single string delimited with a tilde. I am writing a BPM to email shipment notifications and am needing to replace that tilde with a carriage return chr(10). The string looks like this…
COMPANY NAME~STREET ADDRESS~CITY STATE ZIP~COUNTRY

Any help would be greatly appreciated!
Thanks,
Chris

It looks lik your address string is in the format of a list.

You can split the list into an array as follows and then deal with each element array as an address line:

List AddressLines = ShipTo Addr.Split(new char[0]).ToList();

foreach (string AddressLine in AddressLines)

{ …

}

Kind Regards,

Steve Dakin

ERP Specialist

Steve,
Is this ABL for E9??

Thanks,
Chris

Sorry didn’t notice you were on E9.
I have only used this c# functionalitly in E10 on a custom code element of a BPM workflow.

I have not worked on E9 so don’t know if its relevant.

Steve,

Thanks anyways. Appreciate the attempt.

Chris

I believe you’ll find the answer here: http://download.psdn.com/documentation/openedge/dvref.pdf on page 1076, the Replace function.

Mark W.

Whoops…

MArk is correct REPLACE() not SUBSTITUTE()

EDIT: Added link below

https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref%2Freplace-function.html%23

https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/replace-function.html

REPLACE ( string , “~” , Chr(10) )

Something like this? I haven’t touched ABL in a while…

Exactly what I have tried:
strShipTo = replace(ttShipHead.AddrList, ‘~’, chr(10))
but validating gives me this error:
More than 32000 characters in a single statement–use -inp parm.

I have NO-UNDO the strShipTo variable definition…

Ahhhh haha Got it! ~ is a special character in Progress ABL so I have to do this:

strShipTo = replace(ttShipHead.AddrList, ‘~~’, chr(10))

It works! Thanks all!

2 Likes

BTW - 9.05.702A Ran into this not working as it did in 605.
When attempting to execute the BAQ it throws ye olde:
Table: , Level:, Type: , RowID: , Text: Business Query Execution error. Please contact your System Administrator.
So
Replace(OrderHed.SalesRepList, '~~' , ', ')
stopped working, not sure why, maybe using the tilde as a break makes Progress think the query is being hacked or something… might be a setting or issue with OpenEdge, who knows.
What did work was using the ASCII value for the tilde, 126:
Replace(OrderHed.SalesRepList, CHR(126) , ', ' )

Just in case someone is still on 9 or on their way to 10 had to upgrade to 702A.