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



On 2024-03-01 11:01 a.m., Greg Wilburn wrote:
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.


The IBM example uses the subfield names to generate the table header.
https://www.ibm.com/docs/en/i/7.5?topic=code-example-data-gen-generator

If you want the header to have different names from "id", "name", "addr1" etc, you can use renameprefix to add extra subfields to your data structure. For example, add subfield
rename_addr1 char(10) inz('Address 1')
then have option "renameprefix=rename" for DATA-GEN.

To be similar to the sample, you would specify csv.customers, either with %SUBARR for the whole array or repeated DATA-GEN calls for each element. To get the header, the generator would call QrnDgGetSubfieldName to get the name of the subfield, either the real subfield name or the renameprefix name if you coded it for any subfield.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.