We submit jobs from within RPG programs, so finding an easier way to insert the parameters in the submit string would help, which lead to creating FindReplace. The procedure finds the specified value and replaces it with the supplied string. Only the first occurrence is changed and capitalization is ignored. This procedure eliminated the need to worry about array locations, concatenating strings, changes to the string messing up substitutions, etc. (the target, "@1", could be any sequence of characters). We're finding new uses for this every day.
D CM S 80 ctdata perrcd(1) dim(1) * Change all occurrences of FIND to REPLACE in SOURCE d FindReplace pr 1024 d Source 1024 varying value d Find 255 varying value d Replace 255 varying value c eval target=findreplace( c cm(1) c :'@1' c :'January' c ) c eval *inlr=*on * Change 1st occurrence of FIND to REPLACE in SOURCE p FindReplace b d pi 1024 d Source 1024 varying value d Find 255 varying value d Replace 255 varying value d Work s like(Source) c eval Work = Source c if %scan(Find:Work) > 0 c eval Work = %replace(Replace c :Work c :%scan(Find:Work) c :%len(Find) c ) c endif c return Work p e ** SUBMIT COMMAND ARRAY CM SBMJOB CCCHECKSOK CDAJOBD CMD(CALL CC0012 PARM('@1'))
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Visit the ITKnowledge Exchange and get answers to your developing questions fast.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.