Galera, estou realizando uma query para m relatório que utiliza a classe Treport:
Static Function PrintReport(oReport)
Local oSection := oReport:Section(1)
Local cQryReport := GetNextAlias()
Local nRegs := 0
Local aArea := GetArea()
//Montando consulta de dados
cQryReport += " SELECT SC7.C7_EMISSAO AS DATA_DISPONIBILIZADA, " + CRLF
cQryReport += " SCR.CR_DATALIB AS DATA_RECEBIMENTO, " + CRLF
cQryReport += " SA2.A2_NOME AS RAZAO_SOCIAL, " + CRLF
cQryReport += " SC7.C7_FORNECE AS COD_FORNECEDOR, " + CRLF
cQryReport += " SF1.F1_DOC AS NOTA, " + CRLF
cQryReport += " SCR.CR_TOTAL AS VALOR, " + CRLF
cQryReport += " SCR.CR_NUM AS NUM_PEDIDO, " + CRLF
cQryReport += " USR.USR_NOME AS APROVADOR, " + CRLF
cQryReport += " SCR.CR_STATUS STATUS_APROV, " + CRLF
cQryReport += " CASE " + CRLF
cQryReport += " WHEN SCR.CR_STATUS = 1 THEN 'Aguardando nível anterior' " + CRLF
cQryReport += " WHEN SCR.CR_STATUS = 2 THEN 'Pendente' " + CRLF
cQryReport += " WHEN SCR.CR_STATUS = 3 THEN 'Liberado' " + CRLF
cQryReport += " WHEN SCR.CR_STATUS = 4 THEN 'Bloqueado' " + CRLF
cQryReport += " WHEN SCR.CR_STATUS = 5 THEN 'Liberado por outro aprovador' " + CRLF
cQryReport += " WHEN SCR.CR_STATUS = 6 THEN 'Rejeitado' " + CRLF
cQryReport += " WHEN SCR.CR_STATUS = 7 THEN 'Rejeitado/Bloqueado por outro aprovador' " + CRLF
cQryReport += " ELSE 'SEM STATUS' " + CRLF
cQryReport += " END as STATUS " + CRLF
cQryReport += " FROM " + RetSqlName("SC7")+" SC7"+ CRLF
cQryReport += " INNER JOIN " + RetSqlName("SCR") + " SCR ON SC7.C7_NUM = SCR.CR_NUM AND SC7.D_E_L_E_T_ <> '*' AND SCR.D_E_L_E_T_ <> '*' " + CRLF
cQryReport += " INNER JOIN " + RetSqlName("SA2") +" SA2 ON A2_COD = SC7.C7_FORNECE AND SA2.D_E_L_E_T_ <> '*' " + CRLF
cQryReport += " INNER JOIN SYS_USR USR ON USR.USR_ID = SCR.CR_USER AND USR.D_E_L_E_T_ <> '*' " + CRLF
cQryReport += " INNER JOIN " + RetSqlName("SF1") +" SF1 ON SF1.F1_FORNECE = SC7.C7_FORNECE AND SF1.F1_LOJA = SC7.C7_LOJA AND SF1.D_E_L_E_T_ <> '*' " + CRLF
cQryReport += " WHERE SCR.CR_STATUS IN ('2', '3')" + CRLF
cQryReport += " AND SC7.C7_EMISSAO >= '" + DtoS(dDataDe) + "' AND SC7.C7_EMISSAO <= '"+ DtoS(dDataAt) +"'"+ CRLF
cQryReport += " ORDER BY SF1.F1_DOC DESC, SCR.CR_NIVEL ASC" + CRLF
TcQuery cQryReport New Alias (cQryReport := GetNextAlias())
Count to nRegs
If nRegs > 0
(cQryReport)->(DBGoTop())
while (cQryReport)->(!EoF())
oSection:Init()
oSection:Cell('C7_EMISSAO'):SetValue(AllTrim((cQryReport)->C7_EMISSAO))
oSection:Cell('CR_DATALIB'):SetValue(AllTrim((cQryReport)->CR_DATALIB))
oSection:Cell('C7_FORNECE'):SetValue(AllTrim((cQryReport)->C7_FORNECE))
oSection:Cell('A2_NOME'):SetValue(AllTrim((cQryReport)->A2_NOME))
oSection:Cell('F1_DOC'):SetValue(AllTrim((cQryReport)->F1_DOC))
oSection:Cell('CR_TOTAL'):SetValue(AllTrim((cQryReport)->CR_TOTAL))
oSection:Cell('CR_NUM'):SetValue(AllTrim((cQryReport)->CR_NUM))
oSection:Cell('USR_NOME'):SetValue(AllTrim((cQryReport)->USR_NOME))
oSection:Cell('CR_STATUS'):SetValue(AllTrim((cQryReport)->CR_STATUS))
oSection:PrintLine()
oReport:ThinLine()
(cQryReport)->(DBSkip())
oSection:Finish()
ENDDO
ENDIF
oSection:Print()
(cQryReport)->(DBCloseArea())
RestArea(aArea)
Return
Alguém sabe onde estou errando? O erro dá o seguinte: : TOP Error -19 - Invalid Select / Query Statement : SCGN000110