Versão atual:

Erro execução de dataset

Estou executando um dataset customizado para preencher os campos do formulário porém está apresentando o erro:

2019-06-24 17:34:34,179 INFO  [com.datasul.technology.webdesk.dataset.business.DatasetBO] (default task-4) Executando Dataset com ID dsGetItem do tipo Avançado.
2019-06-24 17:34:34,179 INFO  [com.datasul.technology.webdesk.dataset.business.DatasetBO] (default task-4) Builder rodando sem o mobile 
2019-06-24 17:34:34,193 INFO  [com.datasul.technology.webdesk.customization.ScriptingLog] (default task-4) Servico: com.totvs.technology.foundation.dataservice.service.WebServiceProvider@2fb3ed5b
2019-06-24 17:34:34,193 INFO  [com.datasul.technology.webdesk.customization.ScriptingLog] (default task-4) Iniciando...
2019-06-24 17:34:34,193 INFO  [com.datasul.technology.webdesk.customization.ScriptingLog] (default task-4) Helper: com.totvs.technology.foundation.dataservice.service.WSWrapper@4a054fc9
2019-06-24 17:34:34,194 INFO  [com.datasul.technology.webdesk.customization.ScriptingLog] (default task-4) Instancia: com.totvs.WsConsultaSQL@182efa7a
2019-06-24 17:34:34,197 INFO  [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-4) Creating Service {http://www.totvs.com/}wsConsultaSQL from WSDL: http://url/wsConsultaSQL/MEX?wsdl
2019-06-24 17:34:34,251 INFO  [com.datasul.technology.webdesk.customization.ScriptingLog] (default task-4) WS: org.apache.cxf.jaxws.JaxWsClientProxy@c5bb9e3
2019-06-24 17:34:34,254 INFO  [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-4) Creating Service {http://www.totvs.com/}IwsConsultaSQLService from class com.totvs.IwsConsultaSQL
2019-06-24 17:34:34,286 INFO  [com.datasul.technology.webdesk.customization.ScriptingLog] (default task-4) Params: CODCOLIGADA=1;IDMOV=216923;IDFLUIG=185
2019-06-24 17:34:34,901 ERROR [com.datasul.technology.webdesk.customization.ScriptingLog] (default task-4) Erro na comunicação com o Progress OpenEdge: JavaException: javax.xml.ws.soap.SOAPFaultException: Conversion failed when converting the varchar value 'undefined' to data type int.

Alguém sabe o que pode ser?

Código do dataset:

function createDataset(fields, constraints, sortFields) {

    var NOME_SERVICO = "WSCONSSQL";
    var CAMINHO_SERVICO = "com.totvs.WsConsultaSQL";

    var dataset = DatasetBuilder.newDataset();

    try{
        var servico = ServiceManager.getServiceInstance(NOME_SERVICO);
        log.info("Servico: " + servico);

        log.info("Iniciando...");

        var serviceHelper = servico.getBean();
        log.info("Helper: " + serviceHelper);    

        var instancia = servico.instantiate(CAMINHO_SERVICO);
        log.info("Instancia: " + instancia);

        var ws = instancia.getRMIwsConsultaSQL();    
        log.info("WS: " + ws);

        //var serviceHelper = servico.getBean();

        var authService = serviceHelper.getBasicAuthenticatedClient(ws, "com.totvs.IwsConsultaSQL", 'usuario', 'senha');           

        log.info("Params: " + "CODCOLIGADA="+fields[1] + ";IDMOV="+fields[0] + ";IDFLUIG="+fields[2]);

        var consulta = "NUCSQL0006";
        var coligada = parseInt(fields[1]);
        var sistema = "T";
        var params = "CODCOLIGADA="+fields[1] + ";IDMOV="+fields[0] + ";IDFLUIG="+fields[2];
        // Executa uma consulta previamente disponibilizada e cadastrada no RM
        var result = authService.realizarConsultaSQL("NUCSQL0006", parseInt(fields[1]) , "T", "CODCOLIGADA="+fields[1] + ";IDMOV="+fields[0] + ";IDFLUIG="+fields[3]);
        log.info("result: " + result);

        if ((result != null) && (result.indexOf("===") != -1))
        {
            var msgErro = result.substring(0, result.indexOf("==="));

            throw msgErro;
        }

        var xmlResultados = new XML(result);  

        dataset.addColumn("IDFLUIG");
        dataset.addColumn("COLIGADA");
        dataset.addColumn("FILIAL");
        dataset.addColumn("IDMOV");
        dataset.addColumn("NUMEROMOV");
        dataset.addColumn("DATAEMISSAO");
        dataset.addColumn("CENTROCUSTO");
        dataset.addColumn("USUARIOCRIACAO");
        dataset.addColumn("ITEM");
        dataset.addColumn("UNIDADE");
        dataset.addColumn("QUANTIDADE");
        dataset.addColumn("PRECOUNITARIO");
        dataset.addColumn("VALORTOTAL");

        for each(mov in xmlResultados.Resultado) {
            dataset.addRow(new Array(mov.IDFLUIG.toString(),
                    mov.COLIGADA.toString(),
                    mov.FILIAL.toString(),
                    mov.IDMOV.toString(),
                    mov.NUMEROMOV.toString(),
                    mov.DATAEMISSAO.toString(),
                    mov.CENTROCUSTO.toString(),
                    mov.USUARIOCRIACAO.toString(),
                    mov.ITEM.toString(),
                    mov.UNIDADE.toString(),
                    mov.QUANTIDADE.toString(),
                    mov.PRECOUNITARIO.toString(),
                    mov.VALORTOTAL.toString()));        
        }

        return dataset;

    } catch (e) {
        if (e == null)    e = "Erro desconhecido; verifique o log do AppServer";
        var mensagemErro = "Erro na comunicação com o Progress OpenEdge: " + e;
        log.error(mensagemErro);
        dataset.addColumn("ERROR");
        dataset.addRow(new Array(mensagemErro));
        return dataset;
    }    
}

function parseContext(constraints){
    var context = "";

    if ((constraints != null) && (constraints.length > 0) && (constraints[0].getFieldName() == "RMSContext"))
        {
            context = constraints[0].getInitialValue();
        }

    return context;
}

//Transforma o conceito de constraints do Fluig para o Filtro do TBC.
function parseConstraints(constraints)
{
    var filter = "";
    for    each(con in constraints) {

        if (con.getFieldName().toUpperCase() == "RMSCONTEXT")
            continue;

        filter += "(";

        if (con.getFieldName().toUpperCase() == "RMSFILTER")
        {
            filter += con.getInitialValue();
        }
        else if (con.getConstraintType() == ConstraintType.SHOULD)
        {
            filter += "(";
            filter += con.getFieldName();
            filter += "=";
            filter += con.getInitialValue();            
            filter += ")";
            filter += " OR ";
            filter += "(";
            filter += con.getFieldName();
            filter += "=";
            filter += con.getFinalValue()();            
            filter += ")";
        }
        else
        {
            if (con.getInitialValue() == con.getFinalValue())
            {
                filter += con.getFieldName();

                if (ConstraintType.MUST == con.getConstraintType())
                {
                    filter += " = ";
                }
                else if (ConstraintType.MUST_NOT == con.getConstraintType())
                {
                    filter += " <> ";
                }

                filter += con.getInitialValue();
            }
            else
            {
                filter += con.getFieldName();
                filter += " BETWEEN ";
                filter += con.getInitialValue();
                filter += " AND ";
                filter += con.getFinalValue()
            }
        }

        filter += ")";

        filter += " AND ";
    }

    if (filter.length == 0)
    {
        filter = "1=1";        
    }
    else
        filter = filter.substring(0, filter.length-5);

    return filter;
}

Consulta SQL:

SELECT IDFLUIG,
CAST(c.CODCOLIGADA AS VARCHAR) + ' - ' + c.NOMEFANTASIA AS COLIGADA,
CAST(f.CODFILIAL AS VARCHAR) + ' - ' + f.NOMEFANTASIA AS FILIAL,
m.IDMOV,
m.NUMEROMOV,
m.DATAEMISSAO,
cc.CODCCUSTO + ' - ' + cc.NOME AS CENTROCUSTO,
m.USUARIOCRIACAO,
p.CODIGOPRD + ' - ' + p.NOMEFANTASIA AS ITEM,
p.CODUNDCOMPRA AS UNIDADE,
im.QUANTIDADE,
im.PRECOUNITARIO,
im.QUANTIDADE * im.PRECOUNITARIO AS VALORTOTAL
FROM TITMMOVWFLUIG i
INNER JOIN TMOV m ON i.CODCOLIGADA = m.CODCOLIGADA AND i.IDMOV = m.IDMOV
INNER JOIN GCOLIGADA c ON m.CODCOLIGADA = c.CODCOLIGADA
INNER JOIN GFILIAL f ON m.CODCOLIGADA = f.CODCOLIGADA AND f.CODFILIAL = m.CODFILIAL
INNER JOIN GCCUSTO cc ON m.CODCOLIGADA = cc.CODCOLIGADA AND m.CODCCUSTO = cc.CODCCUSTO
INNER JOIN GUSUARIO u ON m.USUARIOCRIACAO = u.CODUSUARIO
INNER JOIN TITMMOV im ON i.CODCOLIGADA = im.CODCOLIGADA AND i.IDMOV = im.IDMOV AND i.NSEQITMMOV = im.NSEQITMMOV
INNER JOIN TPRD p ON im.CODCOLIGADA = p.CODCOLIGADA AND im.IDPRD = p.IDPRD
WHERE i.CODCOLIGADA = :CODCOLIGADA
AND i.IDMOV = :IDMOV
AND i.IDFLUIG = :IDFLUIG

Versão (1):

Ver a versão formatada

Erro execução de dataset

Comentário

new question