ConvertTableDataToJsonSampleData - cDRReport¶
Methods - Properties - Events
Method Type¶
Function
Return Type¶
Arguments¶
| Argument | Description |
|---|---|
vData |
A two dimensional variant array containing the RDS data. |
Description¶
Returns the RDS data converted to JSON data as UChar[] values.
The RDS data is converted to a tDRDataSourceRow variable and then converted to JSON. The results can be written out to disk via the DataFlex sequential I/O commands.
DataFlex Framework usage¶
- Web
- Windows
- FlexTron
Sample¶
Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Procedure LoadRDSData String sReportId Integer iSibling Integer iLevel
Variant[][] vData
Integer iElements iElement iSubReports iSubReport iChannel
tDRTableName[] ReportTableNames
String sSubReportId sFolder sFileName
Handle hoWorkspace
UChar[] ucTableData
Get RDSTableNames sReportId to ReportTableNames
Move (SizeOfArray(ReportTableNames)) to iElements
If (iElements > 0) Begin
Decrement iElements
For iElement from 0 to iElements
Get AddRDSData ReportTableNames[iElement].sTableName iSibling iLevel to vData
Send TableData sReportId ReportTableNames[iElement].iTable vData
Get ConvertTableDataToJsonSampleData vData to ucTableData
If (SizeOfArray(ucTableData) > 0) Begin
Move (Seq_New_Channel()) to iChannel
If (iChannel >= 0) Begin
Get phoWorkspace of ghoApplication to hoWorkspace
Get psHome of hoWorkspace to sFolder
If (Right(sFolder, 1) <> "\") Begin
Move (sFolder - "\") to sFolder
End
Move (sFolder - ReportTableNames[iElement].sTableName - '.json') to sFileName
Direct_Output channel iChannel sFileName
Write channel iChannel ucTableData
Close_Output channel iChannel
Send Seq_Release_Channel iChannel
End
End
Loop
End
Get SubReportCount sReportId to iSubReports
If (iSubReports > 0) Begin
Decrement iSubReports
For iSubReport from 0 to iSubReports
Get SubReportId sReportId iSubReport to sSubReportId
Send LoadRDSData sSubReportId iSubReport (iLevel + 1)
Loop
End
End_Procedure
End_Object
Object oRunReportButton is a Button
Set Label to 'Run Report'
Procedure OnClick
Get RunReport of oReport
End_Procedure
End_Object
Notes¶
- Set_Argument_Size (up to DataFlex 20.1) might be needed to get this method working correctly as the
tDRDataSourceRowstructure uses strings. - The function and the conversion to JSON are only available in libraries from DataFlex 19.0 and up.