Hi all!
I have an AE that is getting input from a database staging table which is populated from an external system. One of the fields is a Char(400) text field which will potentially have CR/LF characters in it. These are causing significant errors, as the AE pgm which processes the data sees the CR/LF and assumes a new record of data has been encountered.
So I find that I need to trap the CR/LF characters and handle them somehow (temporary translation?) to prevent these issues.
I'm stuck on how to isolate the CR/LF characters in the field in question. There may be multiple occurrences of the CR/LF in the field. I reviewed the CHAR(), CODE(), and STRING() Peoplecode functions but either I'm missing something or they won't do the trick.
Anyone dealt with this previously? Any ideas?
Regards,
Larry
| Title | Under | Posted on |
|---|---|---|
| Required Peoplesoft HRMS Functional Training | PeopleSoft Functional | 05/07/2013 - 10:29pm |
| Error while saving Voucher | PeopleSoft Functional | 05/02/2013 - 1:55am |
| santosh asking que | PeopleSoft Technical | 04/30/2013 - 10:22am |
| How can i implement Email functionality to alerts in peoplesoft. | PeopleSoft Technical | 04/30/2013 - 5:01am |
Larry, I've used a function that was created by PeopleSoft at one point to clean some strings. See function below. I think char(13) is ascii for CR so something like the code below might work!
I know i have something else that I have done but can't find it at the moment. Let me know if the below helps!
Declare Function string_scrubber PeopleCode FUNCLIB_LCINTFC.NUM_CHECK FieldFormula;
&CHAR_SET = char(13);
&cleanString = string_scrubber(&StringValue, &CHAR_SET);
Function string_scrubber(&STRING, &CHAR_SET) Returns string
&LENGTH = Len(&STRING);
For &X = 1 To (&LENGTH)
&CHAR = Substring(&STRING, &X, 1);
&TEST = Find(&CHAR, &CHAR_SET);
If &TEST = 0 Then
&RESULT_STRING = &RESULT_STRING | &CHAR;
End-If;
End-For;
Return &RESULT_STRING;
End-Function;
Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog
Larry i think i found what you are looing for.
take a look at the delivered PS function ContainsOnlyCharType in Peoplebooks. I've created a method that uses that function and basically loop through the text and remove none Alphanumeric (7-bit ASCII codes; A-Z, a-z, 1-9, punctuation) characters from the string.
Here is my code below:
* class BadChar
* Remove none Alphanumeric (7-bit ASCII codes; A-Z, a-z, 1-9, punctuation) characters from a string
* @author Maher Ardat
* @version 1.0
* @created 03/01/2010
**************************************/
class BadChar
method RemoveBadChar(&text As string, &replaceValue As string) Returns string;
end-class;
method RemoveBadChar
/+ &text as String, +/
/+ &replaceValue as String +/
/+ Returns String +/
Local string &charValue, &takeValue, &cleantext;
Local number &i, &goodChar, &badChar;
/* checking if the passed string has any none Alphanumeric (7-bit ASCII codes; A-Z, a-z, 1-9, punctuation)*/
&badChar = ContainsOnlyCharType(&text, 0);
If &badChar <> 1 Then
MessageBox(0, "Invalid Character Being Saved", 20090, 100, "message not found", &text);
/*unwanted character exists. Loop through the string, find it and remove it*/
For &i = 1 To Len(&text)
&charValue = Substring(&text, &i, 1);
&goodChar = ContainsOnlyCharType(&charValue, 0);
If &goodChar = 1 Then
&takeValue = Substring(&text, &i, 1);
&cleantext = &cleantext | &takeValue;
Else
&cleantext = &cleantext | &replaceValue;
End-If;
End-For;
Return &cleantext;
Else
/*no bad characters in string*/
Return &text;
End-If;
end-method;
How about the function Clean(&string);