If the line length is not too long, how about creating a master file to read it, and manipulate it in a TABLE FILE or alternatively, -READ it in a loop and -WRITE it out
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
January 25, 2018, 05:53 AM
Frans
Can you convince your recieving party to use records instead of data? Although anything is possible, but somethimes it's better to stick to standard.
You could install a javascript interpreter on your server, for example nodejs, and execute a script through that to convert the JSON message.
Added bonus, I suspect you can do something similar for JSCHART graphs to create output suitable for inclusion in PDF, Excel, etc.
It's something I've been meaning to experiment with, but haven't gotten around to.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
January 25, 2018, 12:18 PM
Tony A
Check out "putddrec" in the help files.
SET HOLDLIST = PRINTONLY
SET PAGE = NOLEAD
FILEDEF PUTDD1 DISK putdd1.dat
-RUN
TABLE FILE EMPLOYEE
PRINT EMP_ID
CURR_JOBCODE AS 'JOB'
CURR_SAL
COMPUTE SALA/A12 = FPRINT(CURR_SAL, 'D12.2c', 'A12'); NOPRINT
COMPUTE EMP1/A50= LAST_NAME | FIRST_NAME | EMP_ID | CURR_JOBCODE | SALA; NOPRINT
COMPUTE OUT1/I1 = PUTDDREC('PUTDD1',6, EMP1, 50, OUT1); NOPRINT
BY LAST_NAME
BY FIRST_NAME
ON TABLE SAVE
END
-RUN
CMD TYPE putdd1.dat
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
January 25, 2018, 01:14 PM
Francis Mariani
I can't see how PUTDDREC is different than regular DEFINE or COMPUTE. Reading the doc didn't clarify it for me.
Thanks,
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 25, 2018, 01:41 PM
Surenther
Thanks all for your response.
I have used javascript to remove "records" and i have converted JSON to JS object. That worked.
I am not sure how it's going to affect performance! . Have to check with larger data set.
Seems i need to wait for 8.2.2 for getting in built responsive tabular report with WebViewer ON. Current implementation of Webviewer is adding Iframe and its breaking all responsiveness.
I can't see how PUTDDREC is different than regular DEFINE or COMPUTE.
Admittedly, the above is only a simple example, but you can perform multiple PUTDDREC operations within the same table request.
For instance, if your requirement was a more hierarchical format -
FILEDEF PUTDD1 DISK focalpoint/putdd1.json
-RUN
TABLE FILE CAR
SUM COMPUTE CNTR1/I3 = LAST CNTR1 + 1;
COMPUTE CNTR2/I3 = IF COUNTRY NE LAST COUNTRY THEN 1 ELSE LAST CNTR2 + 1;
COMPUTE CNTR3/I3 = IF CAR NE LAST CAR THEN 1 ELSE LAST CNTR3 + 1;
COMPUTE CNTR4/I3 = IF MODEL NE LAST MODEL THEN 1 ELSE LAST CNTR4 + 1;
COMPUTE ROW6/I3 = IF CAR NE LAST CAR AND CNTR1 NE 1 THEN PUTDDREC('PUTDD1', 20, ' ] } },', 50, 'I3');
COMPUTE ROW5/I3 = IF COUNTRY NE LAST COUNTRY AND CNTR1 NE 1 THEN PUTDDREC('PUTDD1', 20, ' ] } },', 50, 'I3');
COMPUTE ROW1/I3 = IF CNTR1 EQ 1 THEN PUTDDREC('PUTDD1', 20, '{"data": { [', 50, 'I3');
COMPUTE ROW2/I3 = IF CNTR2 EQ 1 THEN PUTDDREC('PUTDD1', 20, ' {"country": {"' || COUNTRY || '" [', 50, 'I3');
COMPUTE ROW3/I3 = IF CNTR3 EQ 1 THEN PUTDDREC('PUTDD1', 20, ' {"car": {"' || CAR || '" [', 50, 'I3');
COMPUTE ROW4/I3 = IF CNTR4 EQ 1 THEN PUTDDREC('PUTDD1', 20, ' {"model": "' || MODEL || '", "sales": ' || LJUST(12, FPRINT(SALES, 'D10.2', 'A12'), 'A12') || '}', 100, 'I3');
BY COUNTRY
BY CAR
BY MODEL
ON TABLE SAVE
END
-RUN
-SET &Line7 = ' ] } },';
-SET &Line8 = ' ] } },';
-SET &Line9 = '] } }';
FILEDEF PUTDD1 DISK focalpoint/putdd1.json (APPEND
-RUN
-WRITE PUTDD1 &Line7
-WRITE PUTDD1 &Line8
-WRITE PUTDD1 &Line9