Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Hello all! I'm trying to call the STRPCCMD command in my CL program, but it appears that the URL gets truncated when it hits the first apersand, missing the rest of the URL. I'm assuming there is a simple way around this issue, but I'm not sure how to code it.
If any of you have run into this issue could you please enlighten me? Here's an example of a URL that I'm trying to call. The only thing that is being sent to the browser is up to "track=yes".
call urltest ('https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z0E03670312546708&loc=en_us')
Here's the simple CL code:
PGM PARM(&URL)
DCL VAR(&URL) TYPE(*CHAR) LEN(123)
DCL VAR(&URLCALL) TYPE(*CHAR) LEN(123)
CHGVAR VAR(&URLCALL) VALUE('start' *BCAT &URL)
STRPCO PCTA(*NO)
MONMSG MSGID(IWS4010)
STRPCCMD PCCMD(&urlcall) PAUSE(*NO)
MONMSG MSGID(CPF0000)
ENDPGM
Thanks!
Good morning, everyone. I realize no one replied to my question and that's ok, it was a tough question, but after searching for two days I found the solution. I thought I'd share it just in case any of you ever run into the same situation. For the additional parms in the URL (requiring the ampersand) I needed to have a caret just before the ampersands. Here's the explanation I found online:
The problem was that the MS-DOS system uses the amersand as a special character that needs to be escaped. To escape it you must use the caret symbol Shift+6 on US keyboards. You can do this on the green screen, but
you can put it in your RPGLE code and it will compile and work properly.
cmdstring = 'STRPCCMD PCCMD(' + q + 'Start ' +
'http:' + '/' + '/' + 'example.com' +
'?parm1=' + foo + '^&parm2=' + %char(bar) + q +')
PAUSE(*NO)';
Just seeing this Chris, glad you found it, I figured it had to be escaped or encoded, but wasn't sure about the technique. Thanks!