Midrange News for the IBM i Community


Posted by: Doug Feeman
HTTPPOSTCLOBVERBOSE Have Variable Request Data
has no ratings.
Published: 16 Sep 2017
Revised: 18 Sep 2017 - 30 days ago
Last viewed on: 17 Oct 2017 (79 views) 

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.

HTTPPOSTCLOBVERBOSE Have Variable Request Data Published by: Doug Feeman on 16 Sep 2017 view comments(3)

Can HTTPPOSTCLOBVERBOSE use a variable as the request data? If I replace ':pData)) as UPS;' in the code below with 'GET_CLOB_FROM_FILE('/ifsdir/file.txt') )) as UPS;' the code works as expected and I receive data from UPS. If I use the code below it's like no request data is sent to UPS. So I wondering can the request data be a variable and how would the syntax look? We are on an Iseries V7.1. Thanks.

 

0172.11 C                   eval      pData      =
0172.12 C                               'GET_CLOB_FROM_FILE(~'
0172.13 C                             + %trim(#lcifsfilnam)
0172.14 C                             + '~)'
0172.15 C     $tilde:$quote xlate     pData         pData
0181.02 C* Transmit PLD upu178.txt to UPS and receive response message from UPS
0181.04  /free
0181.05   replystmf_Name = '/dfreeman/upu178rm.txt';
0181.06   replystmf_NL   = %len(%trimr(replystmf_name));
0181.07   replystmf_FO   = SQFOVR;
0181.17   exec sql
0181.23    SELECT responseMsg,responseHttpHeader
0181.24    INTO  :replyStmf, :replyHdr
0181.25    FROM   TABLE(SYSTOOLS.HTTPPOSTCLOBVERBOSE(
0181.29                  'https://onlinetools.ups.com/webservices/Track',
0181.30                  '<httpHeader>  +
0181.31                   <header name="Content-type" +
0181.32                          value="application/xml"/> +
0181.33                   </httpHeader>',
0181.34                  :pData) ) as UPS;

 

 

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: HTTPPOSTCLOBVERBOSE Have Variable Request Data
Posted: 30 days 17 hours 17 minutes ago

Yes but you may need to cast the data to a CLOB or BLOB depending on the situation.

Something like the following for that parameter:

cast(:reqData as clob(10k))

Also, I don't see where you are runing the GETCLOB_FROM_FILE rouitne. Normally I just use the SQL VALUES INTO statement to do that. 

Posted by: dfreeman
Comment on: HTTPPOSTCLOBVERBOSE Have Variable Request Data
Posted: 30 days 2 hours 42 minutes ago

Thanks for responding. The code below works as expected - I send a request to UPS and receive a response from UPS. I tried to cast the line GET_ CLOB_FROM_FILE('/path/myfile.txt') but it does not send anything to UPS. I would like to be able to change '/path/myfile.txt' to be '/path/myfile2.txt' or '/path/myfile3.txt', etc. in the SQLRPGLE. I'm not sure how to use CAST or code CAST to accomplish this. Any comments would be appreciated.

 

0181.02 C* Transmit PLD upu178.txt to UPS and receive response message fro
0181.04  /free
0181.05   replystmf_Name = '/path/responsemsg.txt';
0181.06   replystmf_NL   = %len(%trimr(replystmf_name));
0181.07   replystmf_FO   = SQFOVR;
0181.17   exec sql
0181.23    SELECT responseMsg,responseHttpHeader
0181.24    INTO  :replyStmf, :replyHdr
0181.25    FROM   TABLE(SYSTOOLS.HTTPPOSTCLOBVERBOSE(
0181.26                  'https://onlinetools.ups.com/webservices/Track',
0181.27                  '<httpHeader>  +
0181.30                   <header name="Content-type" +
0181.32                          value="application/xml"/> +
0181.35                   </httpHeader>',
0181.36                  GET_CLOB_FROM_FILE('/path/myfile.txt')
0181.37                  ))as UPS;
0181.50  /end-free

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: HTTPPOSTCLOBVERBOSE Have Variable Request Data
Posted: 29 days 23 hours ago
Edited: Mon, 18 Sep, 2017 at 15:35:29 (30 days ago)

I don't know what GET_CLOB_FROM_FILE('/path/myfile.txt') is so I can't help with it (Some user-written routine?)

But I use the VALUES INTO when I need the data from an IFS file.

Something like this:

EXEC SQL VALUES(:myStmf) INTO :sendData:nullIndy;

Where MYSTMF is another SQLFILE declaration, and then use the SENDDATA varaible as the parameter on the HTTPPOSTCLOBVERBOSE.