If I'm understanding your question, you are trying to use url-encode but you are not using the CGI wrapper template that puts in the includes that would allow you to use the "URL-Encode" function. If this is the case, you can pull the encode function from the includes and put it into your own function. I think I pulled this one from 10.2B:
FUNCTION url-encode-mine RETURNS CHARACTER
(INPUT p_value AS CHARACTER) :
/****************************************************************************
Description: Encodes unsafe characters in a URL as per RFC 1738 section 2.2.
<
URL:http://ds.internic.net/rfc/rfc1738.txt>, 2.2
Input Parameters: Character string to encode, Encoding option where "query",
"cookie", "default" or any specified string of characters are valid.
In addition, all characters specified in the global variable url_unsafe
plus ASCII values 0 <= x <= 31 and 127 <= x <= 255 are considered unsafe.
Returns: Encoded string (unkown value is returned as blank)
Global Variables: url_unsafe, url_reserved
****************************************************************************/
DEFINE VARIABLE hx AS CHARACTER NO-UNDO INITIAL "0123456789ABCDEF":U.
DEFINE VARIABLE encode-list AS CHARACTER NO-UNDO INIT " <>~"#%~{}|~\^~~[]`~;/?
=&".
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE c AS INTEGER NO-UNDO.
/* Don't bother with blank or unknown */
IF LENGTH(p_value) = 0 OR p_value = ? THEN
RETURN "".
/* Loop through entire input string */
ASSIGN i = 0.
DO WHILE TRUE:
ASSIGN
i = i + 1
/* ASCII value of character using single byte codepage */
c = ASC(SUBSTRING(p_value, i, 1, "RAW":U), "1252":U, "1252":U).
IF c <= 31 OR c >= 127 OR INDEX(encode-list, CHR(c)) > 0 THEN DO:
/* Replace character with %hh hexidecimal triplet */
SUBSTRING(p_value, i, 1, "RAW":U) =
"%":U +
SUBSTRING(hx, INTEGER(TRUNCATE(c / 16, 0)) + 1, 1, "RAW":U) + /* high */
SUBSTRING(hx, c MODULO 16 + 1, 1, "RAW":U). /* low digit */
ASSIGN i = i + 2. /* skip over hex triplet just inserted */
END.
IF i = LENGTH(p_value,"RAW":U) THEN LEAVE.
END.
RETURN p_value.
END FUNCTION. /* url-encode */