Hmm, why do you declare a 1A character field as Varying? Not sure why that would be a problem, but it DOES seem weird...
-Eric DeLong
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Pete Helgren
Sent: Wednesday, April 13, 2011 2:10 PM
To: RPG Midrange Discussion
Subject: Interesting results when writing to an IFS file
Hmmm. I am not sure what I am missing here but I have a program that is
reading data into a data structure and then later I output that data
into a stream file in the IFS. I am formatting the data into a JSON
string and use the curly braces to begin and end each record. But is
seems that the double quote plus a right curly brace e.g. "} ends up
as a special character and doesn't end up as a correctly formatted string.
I am using the following D specs to set the values:
D q S 1A Varying
D Inz('"')
D c S 1A Varying
D Inz(',')
D sc S 3A Varying
D Inz('":"')
D lb S 1A Varying
D Inz('{')
D rb S 1A Varying
D Inz('}')
D lc S 1A Varying
D Inz(' ')
and in the code I concatenate the values into a string that is written
to the IFS. The formatting looks like this:
Line = lc + lb + q + 'msgtxt' + sc + msgtxt + q + c +
q + 'msgid' + sc + RCVM0200.MsgID + q + c +
q + 'jobName' + sc + RCVM0200.SndJobNam + q + c +
q + 'jobUser' + sc + RCVM0200.SndJobUsr + q + c +
q + 'jobNumber' + sc + RCVM0200.SndJobNbr + q + rb ;
it is that final +q+rb which is the literal combination "} that causes
the heartburn. Otherwise the line formats correctly.
The output is something like this: (wrapped so it will fit here)
{"msgtxt":"Job 586612/PETE/QDFTJOBD completed normally on 04/12/11 at
18:05:55.",
"msgid":"CPF1241","jobName":"QDFTJOBD ",
"jobUser":"PETE ",""jobNumber":"586612 ½,
Notice the '1/2' symbol at the end. It *should* be "} so that the
string would look like this:
{"msgtxt":"Job 586612/PETE/QDFTJOBD completed normally on 04/12/11 at
18:05:55.",
"msgid":"CPF1241","jobName":"QDFTJOBD ",
"jobUser":"PETE ",""jobNumber":"586612"},
Should I use a different technique for the literals?
Ideas how how to work around the issue would be welcome.
--
Pete Helgren
Value Added Software, Inc
www.asaap.com
www.opensource4i.com
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.