Thanks Charles/Alan...
I put it in the global area of the module because I may create other procedures that would return the same JSON result.
So I think I'll leave it there and define it as a TEMPLATE. Then create a separate DS in the procedure based on that template.
Thanks,
Greg
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg Wilburn
Sent: Wednesday, September 8, 2021 5:20 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: JSON DS in service program
I have a service pgm and procedure with a DS defined for a JSON response from an API.
The JSON DS is defined in the d-specs of the service program (not in the procedure).
Even though I have INZ keyword on the JSON DS, it still contains data from the previous call. What is the right way to handle this?
1. Clear JSON in calc specs?
2. Move the DS inside the procedure?
This is defined as a global variable in the module source (above the procedures). I'm thinking this only gets initialized the first time a calling PGM calls the procedure. But I'm not sure how to best fix this.
json(1).delivery_line_2 is the actual data field where I'm able to see it not initialized on subsequent calls
dcl-ds json qualified dim(3) inz;
input_id varchar(36);
input_index int(5) inz(0);
candidate_index int(5) inz(0);
delivery_line_1 varchar(50) inz('');
delivery_line_2 varchar(50) inz('');
last_line varchar(64) inz(''); // City, State & Zip combined
delivery_point_barcode varchar(12) inz(''); // POSTNET barcode
dcl-ds components;
primary_number varchar(10) inz(''); // House, P.O. or Building Nbr
[Logo]<
https://www.totalbizfulfillment.com/> Greg Wilburn
Director of IT
301.895.3792 ext. 1231
301.895.3895 direct
gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx>
1 Corporate Dr
Grantsville, MD 21536
www.totalbizfulfillment.com<
http://www.totalbizfulfillment.com>
--
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.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.