AS/400 CLLE: Scan and replace with other character in CL program

450 pts.
Tags:
AS 400
CL Program
CLLE
How to scan for a position and replace that with some other character in CL program? eg : Name = 'Vivek' i should replace 'e' with 'o'. How can I do that in CLLE?
1

Answer Wiki

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

Check out the manual here for the explanation and some examples.

Discuss This Question: 8  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.
  • Splat
    Show us your code & we can make suggestions.
    12,855 pointsBadges:
    report
  • vivekntt21
    The example is here eg : Name = 'Vivek' i should replace 'e' with 'o'. How can I do that in CLLE? 
    450 pointsBadges:
    report
  • ToddN2000
    text = 'Vivek'
    newtext = %ScanRpl('e' : 'o' : text);
    129,825 pointsBadges:
    report
  • GalBerman
    Hi, 
     The function %SCANRPL is not supported on CLP/CLLE
    10 pointsBadges:
    report
  • samk5a5
    Hi, how abot this


     DCL        VAR(&NAME) TYPE(*CHAR) LEN(10) VALUE('vivek')
     DCL        VAR(&I) TYPE(*DEC) LEN(1) VALUE(1)           
     DOUNTIL    COND(%SST(&NAME &I 1) *EQ ' ')               
     IF         COND(%SST(&NAME &I 1) *EQ 'i') THEN(DO)      
     CHGVAR     VAR(%SST(&NAME &I 1)) VALUE('o')             
     enddo                                                   
     CHGVAR     VAR(&I) VALUE(&i+1)                          
     enddo                                                   
     SNDUSRMSG  MSG(&NAME)                                   
    10 pointsBadges:
    report
  • ToddN2000
    Went back and read this again...I missed the CLLE apparently. Not sure why it's needed in a CLLE program. Are you trying to validate a parm or are you trying to change values coming in from a RCVF? My suggestion is to do your validation before it ever gets to a CL program. CL programs are just not that powerful of flexible. 
    129,825 pointsBadges:
    report
  • azohawk
    The example provided in the OP made me think the source code needed to be corrected, but if this is actual code that is to validate a field (parm or from a file) the question becomes a little more complicated. You may want to change 'vivek' to 'vivok', but do you also want to change 'blues' to 'bluos'?  (same position of the 'e'). Then you also have the issue of upper/lower case characters.
    4,015 pointsBadges:
    report
  • ToddN2000
    Like Azohawk mentioned, there are too many possible variables. Is it always the same char in the same position, is it that one word or any word with that character? If this data is coming in from a file on the i-Series and you are using the RCVF to pull in the data record, my suggestion is to call a custom data scrubbing program. Write one in RPG, SQL or another language that has a lot more flexibility to manipulate your data before it gets read into your CL program. 
    129,825 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.

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

Following

Share this item with your network: