× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Looks as if they are responding with a floating point value no matter what you send. Seems truly dumb to me but what do I know.

From the sample, they are sending you regular decimal values sometimes. I think you really need to get them to define for you which values will be sent back as floats and which as decimals. It is always possible they have a setting that controls this - but as an absolute minimum they must know which elements are floats.

Assuming they won't/can't do away with the floats then you can apparently deal with it by defining the fields as floats in the DS and then move it to your target field. I had forgotten that Data-Into could handle floats. So this works:

**free
ctl-opt dftactgrp(*no);
dcl-s jsondata varchar(1000)
inz('{"tax": {-
"amount_to_collect": 55.0,-
"breakdown": {-
...
"county_taxable_amount": 1.0e3,-
...
} ] } } }');

// Tax Response From API Call
Dcl-ds TaxResponse Qualified;

Dcl-ds tax;

amount_to_collect Packed(7 : 2);

Dcl-ds breakdown;

...
county_taxable_amount Float(4);
...
End-Ds;
End-Ds;
End-Ds;
End-Ds;

Dcl-s tempTax packed(7 : 2);

Data-Into TaxResponse %data( jsondata : 'countprefix=cnt_ ')
%parser('YAJL/YAJLINTO');

tempTax = TaxResponse.Tax.breakdown.county_taxable_amount;

Dsply %Char(tempTax);

*inlr = *on;

As I say this will work but you MUST know which fields to define as float and only the supplier can tell you that - unless you have a swagger document for the service which should tell you


Jon P.

On Sep 18, 2023, at 10:47 AM, (WalzCraft) Jerry Forss <JForss@xxxxxxxxxxxxx> wrote:

Tried it. No change. Ug!!

All "support" is in India and only during the day there. All responses I get from them are around 3am here.

Request
{
"from_country": "US",
"from_zip": "54603",
"from_state": "WI",
"from_city": "La Crosse",
"from_street": "2600 Hemstock St",
"to_country": "US",
"to_zip": "53532-9139",
"to_state": "WI",
"to_city": "DEFOREST",
"to_street": "6669 CHURCH HILL CT",
"amount": 1000.00,
"shipping": 0,
"line_items": [
{
"id": "1",
"quantity": 1,
"unit_price": 1000.00,
"discount": 0
}
]
}

Response
{"tax":{"amount_to_collect":55.0,"breakdown":{"city_tax_collectable":0.0,"city_tax_rate":0.0,"city_taxable_amount":0.0,"combined_tax_rate":0.055,"county_tax_collectable":5.0,"county_tax_rate":0.005,"county_taxable_amount":1.0e3,"line_items":[{"city_amount":0.0,"city_tax_rate":0.0,"city_taxable_amount":0.0,"combined_tax_rate":0.055,"county_amount":5.0,"county_tax_rate":0.005,"county_taxable_amount":1.0e3,"id":"1","special_district_amount":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_amount":50.0,"state_sales_tax_rate":0.05,"state_taxable_amount":1.0e3,"tax_collectable":55.0,"taxable_amount":1.0e3}],"shipping":{"city_amount":0.0,"city_tax_rate":0.0,"city_taxable_amount":0.0,"combined_tax_rate":0.055,"county_amount":0.0,"county_tax_rate":0.005,"county_taxable_amount":0.0,"special_district_amount":0.0,"special_tax_rate":0.0,"special_taxable_amount":0.0,"state_amount":0.0,"state_sales_tax_rate":0.05,"state_taxable_amount":0.0,"tax_collectable":0.0,"taxable_amount":0.0},"special_district_tax_collectable":0.0,"special_district_taxable_amount":0.0,"special_tax_rate":0.0,"state_tax_collectable":50.0,"state_tax_rate":0.05,"state_taxable_amount":1.0e3,"tax_collectable":55.0,"taxable_amount":1.0e3},"freight_taxable":true,"has_nexus":true,"jurisdictions":{"city":"DE FOREST","country":"US","county":"DANE COUNTY","state":"WI"},"order_total_amount":1.0e3,"rate":0.055,"shipping":0.0,"tax_source":"destination","taxable_amount":1.0e3}}

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jon Paris
Sent: Monday, September 18, 2023 9:13 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: External DATA-INTO not matching variable

Why on earth would they convert it to an exponent form? Makes no sense.

If you included a decimal e.g. 1000.00 would they still do that?


Jon P

On Sep 18, 2023, at 9:53 AM, (WalzCraft) Jerry Forss <JForss@xxxxxxxxxxxxx> wrote:

Fortunately, the element in question is a repeat of what I am sending them. Rather inconsequential.
So I just changed it to send 1001 instead of 1000.

This is using the TaxJar web service so I can verify our taxes on an order.
All I am interested in is the Tax Rates that are returned for the ship to address.

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jon
Paris
Sent: Monday, September 18, 2023 8:44 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: External DATA-INTO not matching variable

Data-Into uses %Dec rules to convert the character string to numeric. Those rules state:

If the parameter is a character expression • See Rules for converting
character values to numeric values using built-in functions for the rules for character expressions for %DEC.
• Floating point data, for example '1.2E6', is not allowed.
• If invalid numeric data is found, an exception occurs with status code 105.

In other words the exact symptoms you are experiencing.

The only simple thing I can think of - assuming the folks who send you the JSON won't change it - is to change any fields that may exhibit this issue to character and then manually convert them using $Dec or whatever. That would allow you to use Monitor blocks to trap conversion errors and process them appropriately.




Subject to Change Notice:

WalzCraft reserves the right to improve designs, and to change specifications without notice.

Confidentiality Notice:

This message and any attachments may contain confidential and privileged information that is protected by law. The information contained herein is transmitted for the sole use of the intended recipient(s) and should "only" pertain to "WalzCraft" company matters. If you are not the intended recipient or designated agent of the recipient of such information, you are hereby notified that any use, dissemination, copying or retention of this email or the information contained herein is strictly prohibited and may subject you to penalties under federal and/or state law. If you received this email in error, please notify the sender immediately and permanently delete this email. Thank You

WalzCraft PO Box 1748 La Crosse, WI, 54602-1748
www.walzcraft.com<http://www.walzcraft.com> Phone: 1-800-237-1326
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.