Thanks for your reply Marshall
As it happens, the user no longer wants/needs this information\
But based upon previous experience, I am saving this because they will probably change their minds yet again
Alan Shore
Solutions Architect
IT Supply Chain Execution
[cid:image001.png@01D91541.F2EF0AF0]
60 Orville Drive
Bohemia, NY 11716
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
E-mail : ASHORE@xxxxxxxxxxxxxxxxxxxx
'If you're going through hell, keep going.'
Winston Churchill
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Marshall Akins
Sent: Wednesday, December 21, 2022 11:18 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: [EXTERNAL] Re: Web service call to determine distance between 2 zip codes
Here's one that we use to get miles from google. Just need to fill in
your api key.
D origin s 32a
D destination s 32a
d xorigin s like(origin)
d xdestination s like(destination)
d url s 2000a
d httphdr s 256a
d estatus s 10a
d status s 32a
d value s 7s 0
d miles s 7s 0
d ok s 10a inz('OK ')
d apikey s 39a inz('put your api key here')
C *entry plist
C origin parm origin parm1 32
C destination parm destination parm2 32
C parm miles parm3 15 5
C
C*
miles = 0;
exec sql
set :origin = compress(:origin),
:destination = compress(:destination);
exec sql
select coalesce(miles,0) into :miles
from googmiles
where upper(:origin) = upper(orig) and
upper(:destination) = upper(dest)
fetch first row only;
if miles <> 0;
return;
endif;
xorigin = origin;
xdestination = destination;
httphdr = '<httpHeader connectTimeout="1500"></httpHeader>';
value = 0;
exec sql
set :origin = systools.urlencode(trim(:origin),'UTF-8');
exec sql
set :destination = systools.urlencode(trim(:destination),'UTF-8');
url = '
https://maps.googleapis.com/maps/api/distancematrix/xml<
https://maps.googleapis.com/maps/api/distancematrix/xml>' +
'?origins=' + %trim(origin) + '&destinations=' + %trim(destination) +
'&units=imperial' + '&key=' + apikey;
exec sql
select coalesce(origin,' '), coalesce(destination,' '),
coalesce(estatus, ' '), coalesce(distance_value,0), status
into :origin, :destination, :estatus, :value, :status
from
xmltable('/DistanceMatrixResponse'
passing(xmlparse(document
systools.httpgetblob(:url, :httphdr)))
Columns
status char(32) path 'status',
origin char(32) path 'origin_address',
destination char(32) path 'destination_address',
estatus char(10) path 'row/element/status',
duration_text char(20) path 'row/element/duration/text',
duration_value decimal(7,0) path 'row/element/duration/value',
distance_text char(20) path 'row/element/distance/text',
distance_value decimal(7,0) path 'row/element/distance/value'
) as a;
if estatus = ok;
miles =%dech(value/1609.34:7:0);
exec sql
insert into googmiles(orig, dest, miles)
values(upper(:xorigin), upper(:xdestination), :miles);
else;
miles = 0;
endif;
return;
From: "mlazarus" <mlazarus@xxxxxxxxxxxx<mailto:mlazarus@xxxxxxxxxxxx>>
To: "Midrange Systems Technical Discussion"
<midrange-l@xxxxxxxxxxxxxxxxxx<mailto:midrange-l@xxxxxxxxxxxxxxxxxx>>
Date: 12/02/2022 08:08 AM
Subject: Re: Web service call to determine distance between 2 zip
codes
Alan,
I don't have code, but check out the Google geolocation APIs. You
need to set up an account and you'll get a key to use for your
requests. Under a certain number of uses per month it's free.
-mark
On 12/2/2022 8:11 AM, Alan Shore via MIDRANGE-L wrote:
Hi everyone
We are on V7r3
I have been given a task to extract data concerning packages that have
shipped
Part of that data is to determine the distance between the origin zip
code and the destination zip code
Does anyone have code (and is willing to share it) for a web service
call to obtain this information?
As always - all answers gratefully accepted
Alan Shore
Solutions Architect
IT Supply Chain Execution
[cid:image001.png@01D90625.BD2AB6B0]
60 Orville Drive
Bohemia, NY 11716
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
E-mail : ASHORE@xxxxxxxxxxxxxxxxxxxx<mailto:ASHORE@xxxxxxxxxxxxxxxxxxxx>
'If you're going through hell, keep going.'
Winston Churchill
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx>
To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l<
https://lists.midrange.com/mailman/listinfo/midrange-l>
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>
Before posting, please take a moment to review the archives
at
https://archive.midrange.com/midrange-l<
https://archive.midrange.com/midrange-l>.
Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx> for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link:
https://amazon.midrange.com<
https://amazon.midrange.com>
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx>
To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l<
https://lists.midrange.com/mailman/listinfo/midrange-l>
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>
Before posting, please take a moment to review the archives
at
https://archive.midrange.com/midrange-l<
https://archive.midrange.com/midrange-l>.
Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx> for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com<
https://amazon.midrange.com>
As an Amazon Associate we earn from qualifying purchases.