× 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.



Stephen,

You are passing '1208' in the permissions ("authorities") parameter.  I suspect you meant to use the CCSID parameter?

If it helps, you can look at the code inside yajl_saveBuf(). This is RPG code that already does something very similar to what you're trying to do (though, it doesn't append, so you'd have to make that small change).  This code is well-tested, so should give you a very clear idea of what you need to code yourself.

-SK

On 3/22/19 2:01 PM, Stephen Piland wrote:
Basically.. I'm trying to build a larger, not well-formed JSON file. I say that because at the top level the 3rd party vendor wants multiple objects and they cannot, at this time accommodate a List. So what I'm doing is building 1 file with its 1 and only object at the top level, letting it write out to IFS, then appending any subsequent files to the first file I create.

Before writing out to IFS each individual file using yajl save buffer, I am retrieving the yajl buffer size and that is what I'm using as the file size.

All within a loop...

// done for every file generated
yajl_getBuf(jsonAddr:jsonSize);
yajl_saveBuf(jsonFilename:errMessage);
yajl_genClose();

// on 2nd file and on... Attempt to append json created in previous stmts to larger, master file
masterFd = open(%trim(masterFilename):O_WRONLY+O_CREAT+O_APPEND:1208);
callp write(masterFd:%addr(jsonFilename):jsonSize);


-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Thursday, March 21, 2019 4:54 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Append to IFS File

Hi Stephen,

There isn't a lot of information, here, but...   from the symptoms, I'd guess that the length that you're passing to write() (SecondFileSize) is wrong.   How are you reading the file and calculating the length?

-SK

On 3/20/19 12:21 PM, Stephen Piland wrote:
I believe I have a CCSID but I'm not sure...

I'm trying to add several smaller IFS files together into one. I build the first one, close it, and it looks good on IFS with CCSID 1208. Next, I build the 2nd IFS file and it looks good one IFS as CCSID 1208.

I try and open the first file (and masterFd=1) using...
masterFd = open(%trim(masterFilename):O_WRONLY+O_CREAT+O_APPEND:1208);

Next I try and write/append the 2nd IFS file but I get junk looking characters (see below), using...
callp write(masterFd:%addr(SecondFilename):SecondFileSize);

{"type":"string1","externalId":"FOOBAR1","description":"FOOBAR description1","description2":"FOOBAR description21","description3":"F
OOBAR description31"} Na a a a a m m K

Thoughts? Thanks!
--
Scott Klement
http://www.scottklement.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@xxxxxxxxxxxx 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.

This thread ...

Follow-Ups:
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.