|
The problem you face is that RPG does not supply that information to the
parser - nor could it really. The parser gives RPG a name and the string
associated with it. RPG then stores it in the DS after conversion if
needed. Even if you could do it (more in a minute) how would you report it
to your RPG program?
I think a better option is to make all the fields varchar of a length
longer than they could be. Then process the data into the real DS checking
length etc as you do so.
The only way I can think of to have the parser validate it is to pass the
parser an extra parm containing an array of all the field names and lengths
of the real DS and use that to validate the length before returning it to
RPG.
Jon P
On Sep 14, 2023, at 4:20 PM, Suren K <suren7437@xxxxxxxxx> wrote:attribute
Hi All,
I am planning to add logic in the DATA-INTO Parser Program, before
populating the value into Data Structure, I need to verify the length of
the fields to validate whether any truncation is happening.
For example
dcl-ds Ds_Input;
name char(5);
number zoned(4:0);
end-ds;
data = '{"name": "David John","number": 123}';
data-into Ds_Input %data(data:dataOption) %parser('mpParser':userParm);
In the above example, the name attribute is the character of length 5 but
the value will be 10 characters. I want to validate this in the Parser
Program.
Is it possible to get the attribute inside the parser program like the
attribute of the field "name" is a character of length 5 and the
of a field "number" is numeric of length 4 with 0 decimal places whenrelated questions.
parsing field by field?
Regards,
Suren
--
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
--
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 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.