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



Moved this to RPG list.. hopefully someone finds it helpful.

I looked into trying to mimic IBM's HTML example to modify the DATA-GEN program CSVGEN so that it would write a CSV header row based on the DS passed in.
I can't seem to get my arms around the calls and the parameters.

My DS looks like this:
dcl-ds csv qualified;
num_Customers int(10) inz;
dcl-ds Customers dim(50) inz;
id varchar(8) inz('');
name varchar(40) inz('');
addr1 varchar(40) inz('');
etc... many more fields
end-ds;
end-ds;

The initial call to the CSVGEN program when parm.event = QrnDgEvent_05_StartStruct, the number of subfields is only 1 and the subfield name is "csv".
The next call to CSVGEN under the condition, the subfields go to 49 (number of fields in csv.customers) and the subfield name is now "customers".

The example I copied from IBM (genHTMLtab) does not allow "nested" data structures.

So I'm unsure when to trigger the procedure that acquires the subfield names:
I was assuming the entire DS was available when the event is QrnDgEvent_05_StartStruct based on the following "tip".

Tip: If the names of the subfields are needed in advance, this subfield can be used together with the QrnDgGetSubfieldName callback to obtain the subfield names during the QrnDgEvent_05_StartStruct or QrnDgEvent_06_EndStruct events.

For now, I'm using Scott's suggestion of just passing in the field names as the first structure. It would be great if I had some time to figure this out.

I did some rudimentary testing with 3 programs to build the CSV file.
Speed wise:
1. RPG writing to the IFS using write() is the fastest
2. DATA-GEN using CSVGEN is a very close second
3. RPG running systools.generate_spreadsheet is a distant 3rd

Greg


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jon Paris
Sent: Wednesday, February 28, 2024 5:04 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: CSVGEN?

I looked at changing CSVGEN to do this but in the end, the requirement disappeared (the customer switched to json) so I never did the work.

Modifying the technique used by IBM's HTML table generator is the way to do it - it is not a difficult task.


Jon P.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.