Remove blank space and dash

5 pts.
Tags:
AS/400
RPGLE
RPGLE code
Hi, I wanted to know how can write code in RPGLE for input as 123-456-7 8 9  and output as 123456789? Please help.

Answer Wiki

Thanks. We'll let you know when a new response is added.

You need to write a routine that will loop through each character in the input field and output to a new field.

You can use %SUBST

IF %SUBST(yourfield : ipos : 1) <> ‘ ‘ AND

    %SUBST(yourfield
: pos : 1) <> ‘-‘

    %Subst(newfield
: opos : 1) = %SUBST(yourfield : ipos : 1)

     opos = opos +
1

EndIf

You increment ipos with your loop

(DO or FOR) depending on the release you are on.

 

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    What controls are in place to ensure that the only characters are blanks, dashes and digits? Or can any character show up in any position? Are the blanks or dashes always in the same positions? -- Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    A loop could be needed if unpredictable characters might appear. But if it's all blanks, dashes and digits, it's a fairly straightforward single statement. Details of the total problem are needed. -- Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following