Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
¿Cómo descargar un archivo json que proviene del servicio odata en sapui5?

Necesito descargar un archivo JSON del servicio OData presionando un botón en SAPUI5 . Por ejemplo, la ruta es "/abcd()" y el archivo es un JSON codificado en base 64. Realmente agradecería si alguien pudiera decirme cómo consumirlo y descargarlo como texto sin formato/formato JSON. Gracias por adelantado. Por favor ayuda.

Estoy tratando de hacer como:

Para XML:

 <form:SimpleForm layout="ResponsiveGridLayout" width="30rem" editable="true" visible="{model>/download}"> <form:toolbar> <Toolbar> <Title id="idTitle" text="{i18n>title}" /> </Toolbar> </form:toolbar> <Button id="idDownload" text="Download" press="onDataDownload" /> </form:SimpleForm>

Para JS:

 onDataDownload: function () { return model.getInstance().getOdataWrapper().getEntitySet({ path: "/abcd" }).then((res) => { const blob = new Blob([res], { type: "application/json" }); if (window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveBlob(blob, "filename"); } else { const ele = window.document.createElement("a"); ele.href = window.URL.createObjectURL(blob); ele.download = "filename"; document.body.appendChild(ele); ele.click(); document.body.removeChild(ele); } }); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

He resuelto este problema.

 onDataDownload: function () { //call the function let obj = model.getInstance().getModelService().bindContext("/abcd(...)", undefined, { $$updateGroupId: "anyName" }); obj.execute("anyName").then(function () { var encoded = obj.getBoundContext().getObject().value; var decoded = atob(encoded); const blob = new Blob([decoded], { type: "application/json" }); if (window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveBlob(blob, "ABCD.json"); } else { const ele = window.document.createElement("a"); ele.href = window.URL.createObjectURL(blob); ele.download = "ABCD.json"; document.body.appendChild(ele); ele.click(); document.body.removeChild(ele); } }); model.getInstance().getModelService().submitBatch("anyName"); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!