Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
DaviCastro
Explorer
514

Hello ABAPs.

I've been making a small prototype following the blog tutorial streams-in-rap-uploading-pdf-excel-and-other-files-in-rap-application , it works perfectly and I made a repository in git UploadFileWithAnnotationsRAP , but in some cases depending on the SAPUI5 version and version of the Odata service, the process carried out does not work, however it is possible to customize the application generated using VS Code by creating a simple section extension using VS Code's guided development, to achieve the expected result, some details of the steps to work successfully, I hope it helps:

 

Creating the session using VS Code guided development:

       1. Select the Add a custom section to an object page using extensions option.

          

DaviCastro_0-1722602539578.png

 

      2. A fragment will be created and the following implementation will be carried out:

         

DaviCastro_1-1722602539384.png

 

  • An Id was defined for the Link object that will have the action of downloading the file when clicked.

  • There is a simple logic using model, which checks if the Filename field is filled in, this FileName field is exactly the name of the field written in your CDS, as we are on the object page the default model of the page will be the displayed line itself, so just reference the field.

  • The FileUploader and Button objects are treated so that they are only displayed when the page is in editing mode, so a standard application model called “ui” is used, which contains some flags and one indicates whether it is being edited, as shown in the image the “editable” field is used.

  • The Btn Delete File id Button contains improved logic to prevent it from appearing without there being a file to delete.

   3. In the “object page” controller file, capture the fragment objects previously created in the standard “onAfterRendering” event as below and define the control events:

          

DaviCastro_2-1722602539386.png

 

  • Method/function that will edit the value of the field that will contain the file in Base64:

          

DaviCastro_3-1722602539388.png

 

 

     4. The procedure for paying for the file is the same as when adding the file, but changing the value to empty.

     5. File downloadFile download:                                  

DaviCastro_4-1722602539387.png

 

Note: all files can be seen in my git hub repository at the link: UploadFileWithSectionExtensionRAP

 

#RAP #FIORI #ABAP #VSCODE #EXTENSION #UPLOAD #FILE #SAP #ABAP RESTful Application Programming Model

1 Comment
Labels in this area