Skip to content

RDSTableNames - cDRReport

Methods - Properties - Events

Method Type

Function

Return Type

Array of tDRTableName values

Arguments

Argument Description
sReportID ID of the report. Can be ID of the main report or the ID of a sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.

Description

Returns all the Runtime Data Source tables defined in the report whose ID is passed. The result is an array with the report IDs and the table names and numbers.

This is an advanced method used by code generated by the integration wizard to make it easier to discover all the RDS table names in a report.

This method cannot be used before the report OCX object is initialized. The COM object creation is - when not done before - created as part of the OpenReport method.

DataFlex Framework usage

  • Web
  • Windows
  • FlexTron

Sample

Object oReport is a cDRReport
    Set psReportName to 'MyReport.dr'

    Procedure OnInitializeReport
        String sReportId

        Get psReportId to sReportId
        Send LoadRDSData sReportId 0
    End_Procedure

    Procedure LoadRDSData String sReportId Integer iLevel
        Variant[][] vData
        Integer iElements iElement iSubReports iSubReport
        tDRTableName[] TableNames
        String sSubReportId

        Get RDSTableNames sReportId to TableNames
        Move (SizeOfArray(TableNames)) to iElements
        If (iElements > 0) Begin
            Decrement iElements
            For iElement from 0 to iElements
                Get AddRDSData TableNames[iElement].sTableName iLevel to vData
                Send TableData sReportId TableNames[iElement].iTable vData
            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 (iLevel + 1)
            Loop
        End
    End_Procedure

    Function AddRDSCustomerData Returns Variant[][]
        Integer iRow
        Variant[][] vData

        Send Clear of oCustomer_DD
        Send Request_Read of oCustomer_DD GT Customer.File_Number 1
        While (Found)
            Move Customer.Customer_Number to vData[iRow][0]
            Move (Trim(Customer.Name)) to vData[iRow][1]
            Increment iRow
            Send Locate_Next of oCustomer_DD
        Loop
        Function_Return vData
    End_Function

    Function AddRDSOrderHeaderData Returns Variant[][]
        Integer iRow
        Variant[][] vData

        Send Clear of oOrderHea_DD
        Send Request_Read of oOrderHea_DD GT OrderHea.File_Number 1
        While (Found)
            Move OrderHea.Customer_Number to vData[iRow][0]
            Move OrderHea.Order_Number to vData[iRow][1]
            Move OrderHea.Order_Total to vData[iRow][2]
            Move OrderHea.Order_Date to vData[iRow][3]
            Increment iRow
            Send Locate_Next of oOrderHea_DD
        Loop
        Function_Return vData
    End_Function

    Function AddRDSData String sTableName Integer iLevel Returns Variant[][]
        Variant[][] vData

        Case Begin
            Case (iLevel = 0 and sTableName = "Customer")
                Get AddRDSCustomerData to vData
                Case Break
            Case (iLevel = 1 and sTableName = "Orders")
                Get AddRDSOrderHeaderData to vData
                Case Break
        Case End

        Function_Return vData
    End_Function
End_Object

Object oRunReportButton is a Button
    Set Label to 'Run Report'

    Procedure OnClick
        Send RunReport Of oReport
    End_Procedure
End_Object