View Full Version : vvFormat_toJSON() when pulling from many files?
mjhaston
06-26-2008, 02:06 PM
What would I use in place of vvFormat_toJSON() when pulling data from multiple files to be displayed on a single screen/panel? This vvFormat_toJSON() method uses the data structure of a single file.
sean.lanktree
06-26-2008, 03:15 PM
What we do here is create an external file structure that we can use to populate our data and then pass on to vvFormat_toJSON.
For example, suppose I wanted to show the following info on a single grid:
Order Number
Order Total
Customer Number
Customer Name
This information is not available in a single file, I need to access two different file: the order header (ORDHDR) and the customer master (CUSMASTER).
I would then create a new physical file (PFDS001) with the 4 above fields. Normally, I would compile this file with no members because it will never actually hold records.
Now I am ready to go....
d $records e ds extname(pfds001)
d dim(100) qualified
d @count s 3 0
/free
setll *loval ordhdr;
read ordhdr;
dow not %eof(ordhdr) and @count<%elem($records);
chain cusNumber cusmaster;
@count+=1;
$records(@count).ordNum =ordNumber;
$records(@count).ordTotal=ordTotal;
$records(@count).cusNum =cusNumber;
$records(@count).cusName=cusName; // retrieved from file CUSMASTER
enddo;
if @count>0;
vvFormat.object='PFDS001';
@data = vvFormat_toJSON(vvFormat:%addr($records):@count);
endif;
/end-free
Just be sure that you create the new object in a library that is available to the Valence CGI job.
mjhaston
06-26-2008, 03:24 PM
Makes perfect sense! Still just RPG coding. Nice.
Thanks for the quick reply.
vBulletin® v3.7.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.