Not knowing the type of report and with the lack of code, if you give more information it is easier to know and be able to analyze, but I still leave here this example that is working well. Also available on Github.
public static void PrintInvoice(StdBSInterfPub pso,
ErpBS bso,
string reportPath,
string DocType,
string DocSeries,
int DocNumber)
{
var reportTemplate = "GCPVLS01";
try
{
var strSelFormula = $"{{CabecDoc.TipoDoc}}=\'{DocType}\' and {{CabecDoc.Serie}} = \'{DocSeries}\' AND {{CabecDoc.NumDoc}}={Convert.ToString(DocNumber)}";
pso.Mapas.Inicializar("VND");
var strFormula = new StringBuilder();
strFormula.Append($"StringVar Nome:='{bso.Contexto.IDNome}';");
strFormula.Append($"StringVar Morada:='{bso.Contexto.IDMorada}';");
strFormula.Append($"StringVar Localidade:='{bso.Contexto.IDLocalidade}';");
strFormula.Append($"StringVar CodPostal:='{bso.Contexto.IDCodPostal} {bso.Contexto.IDCodPostalLocal}';");
strFormula.Append($"StringVar Telefone:='{bso.Contexto.IDTelefone}';");
strFormula.Append($"StringVar Fax:='{bso.Contexto.IDFax}';");
strFormula.Append($"StringVar Contribuinte:='{bso.Contexto.IFNIF}';");
strFormula.Append($"StringVar CapitalSocial:='{bso.Contexto.ICCapitalSocial}';");
strFormula.Append($"StringVar Conservatoria:='{bso.Contexto.ICConservatoria}';");
strFormula.Append($"StringVar Matricula:='{bso.Contexto.ICMatricula}';");
strFormula.Append($"StringVar MoedaCapitalSocial:='{bso.Contexto.ICMoedaCapSocial}';");
pso.Mapas.SetFormula("DadosEmpresa", strFormula.ToString());
var strParametros = new StringBuilder();
strParametros.Append("NumberVar TipoDesc;");
strParametros.Append("NumberVar DecQde;");
strParametros.Append("NumberVar DecPrecUnit;");
strParametros.Append("StringVar MotivoIsencao;");
strParametros.Append("BooleanVar UltimaPag;");
strParametros.Append("StringVar PRI_TextoCertificacao;");
strParametros.Append("TipoDesc:= 0;");
strParametros.Append("DecQde:=3;");
strParametros.Append($"DecPrecUnit:={pso.FuncoesGlobais.DaCasasDecimais("Moedas", "DecArredonda")};");
strParametros.Append("UltimaPag:=False;");
strParametros.Append($"PRI_TextoCertificacao:='{bso.Vendas.Documentos.DevolveTextoAssinaturaDoc(DocType, DocSeries, DocNumber, "000")}';");
pso.Mapas.SetFormula("InicializaParametros", strParametros.ToString());
pso.Mapas.Destino = 0;
pso.Mapas.SetFileProp(StdBSTipos.CRPEExportFormat.efPdf, reportPath);
pso.Mapas.ImprimeListagem(reportTemplate, "Invoice", "P", 1, "N", strSelFormula, 0, false, true);
}
catch (Exception ex)
{
throw new Exception("Error while printing the document. \n" + ex.Message);
}
}
You’re passing all the necessary formulas?
– Sérgio Sereno
@Sérgiosereno yes, besides it was working on V9.
– Bruno Gomes