Skip to Content
Author's profile photo Former Member

Attachments for Purchase Order Approval APP from content server

In the standard SAP Fiori App for the PO Approval , when the attachments are created as store business documents option (Which will be saved on the content server) these were not displayed in the App.

By following the below steps the attachment list can be displayed in the Fiori APP.


After creating the PO in SAP ECC the Attachments are attached to the PO using Business Object services as shown above and the objective is to show the above list in the SAP Fiori App.

As per the SAP note instructions 1937715, the addon will be installed on Backend system which creates the below package.






Goto GET_HEADER_GOS_ATTACHMENTS method and here write an Implicit enhancement as shown below.



We will be getting the PO number as the input parameter for this method. With the PO number get all the list of attachments data using the Standard FM ARCHIV_GET_CONNECTIONS.


Fill the ET_ATTACHMENTS internal table by preparing and moving the data as shown.

For object ID, attach GUID from the connections data, get the MIME filed from the standard FM by passing the reserve filed of the connection data.

Get the description from the table TOASP by passing the AR Object and the language

Calculate the size by getting the content of the attachment using standard FM PT_ARQ_ATTACHMENT_DETAIL_GET.



From the above code the attachment list will be displayed in the App.


To download the content of the attachment we have to write code by implementing the Enhancement spot GBAPP_APV_PO.



After implementing the Enhancement spot using the Custom class. We have to write a piece of code in


The attach key will be a importing parameter for this method .



By passing the attach key to the standard FM ARCHIV_GET_CONNECTIONS we can get the attachment details.

Get the Content of the attachment using the standard FM PT_ARQ_ATTACHMENT_DETAIL_GET.

Get the description of the downloaded file by getting the File description from the table toasp by passing the connection data and the language

Concatenate the file description along with the file extension and get the MIME type from the standard FM SDOK_MIMETYPE_GET.



If we click on the attachment it will download the file to the space on the local disk.

In this way we can achieve the functionality of attaching the Documents of different types which gets saved on content server for a purchase order in Fiori APP.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Masayuki Sekihara
      Masayuki Sekihara

      Thank you for sharing a BADI solution. Each customer has different contents storage and retrieving data from contents server is a challenge.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks for the Review Masa !!!

      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Hi Pavan, I have the same problem, thank you for the guide.

      I'm trying to implement this, but I can't find it very clear.

      Can you add the code in text instead of photo?

      If I try to follow what I see in the photos, I find that some variables that you are using are not declared and the code line before the implementation is 91, btu after is 110.

      Can you share what is in between? Are you declaring there the variables that are not declared?

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Ramirez ,

      I have attached the file with sample code , you can have a look at it.

      Thanks & Regards


      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Yes, great, thank!

      I'm having some issues like that I don't have the FM PT_ARQ_ATTACHMENT_DETAIL_GET and the second part is not being triggered by my fiori app, but I guess it will be fine.

      Great post, thanks.

      Author's profile photo Ramakrishna Karnati
      Ramakrishna Karnati


      Hi Pavan,

      could you please share code to me as well.


      Author's profile photo Kevin Barter
      Kevin Barter

      Where was the sample code attached?  I cannot find the file on this post.


      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Hi Pavan.

      I was trying this. The first part worked fine for me, and I can see now the attachments tab with all the attachments, but the second part is not working, and when I click to download, I'm just getting a blank txt file with name $value,txt

      This is what i did, screen by screen.

      Go to SE18 and select Enhancement Spot GBAPP_APV_PO


      Inside there, go to the second BADi Definition, GBAPP_APV_PO_RDP and select the example class CL_GBAPP_APV_PO_RDP_EXAMPLE




      Inside there, create an enhancement implementatino and write the code provided.


      To troubleshoot this, I set an external breakpoint inside the enhancement, but is never triggered.

      Do you have any suggestions?

      Thank you in advance.


      Author's profile photo Former Member
      Former Member
      Blog Post Author


      From the above screenshot i can see that you have written an implicit enhancement in the BADI method.

      There is no need of any implicit enhancement in BADI method. you just have to write the code in the BADI method with out any implicit enhancement.

      You can compare the screenshots of IF_GBAPP_EX_APV_PO_RDP~CHANGE_ATTACHMENT_CONTENT_API done by you and me. you will get to know the issue.

      If you place an external break-point it will get trigger once you solve the above issue.

      Thanks & Regards


      Author's profile photo Manuel Ramirez
      Manuel Ramirez


      Thank you for your reply.

      So should I re implement the method?


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Yes Normal BADI Implementation.

      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Thanks, it is triggering now, but still the file is wrong.

      Unfortunatelly, I don't have PT_ARQ_ATTACHMENT_DETAIL_GET in my system. Do you know some alternative?


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      You can have look at the below mentioned blog, Similar scenario with a different approach

      Attachment Issue in Approve Purchase Order and Purchase Requisition Fiori Apps

      Thanks & Regards


      Author's profile photo Jeline Alexandra T. Co
      Jeline Alexandra T. Co

      Hi Pavan,

      I encountered the same problem as Manuel, I didn't have the listed FM PT_ARQ for loading the actual file into a stream.

      After some searching, was able to use the following:

      • As a subtitute to FM 'PT_ARQ_ATTACHMENT_DETAIL_GET' when getting the file size, I used FM ARCHIVOBJECT_STATUS. Got the file size from COMPONENTS's compsize field
      • As a substitute to FM 'PT_ARQ_ATTACHMENT_DETAIL_GET' for getting the file contents, I used FM 'ARCHIVOBJECT_GET_TABLE' to get the file contents in binary format. Converted the binary file to stream by calling FM ' SCMS_BINARY_TO_XSTRING' and passing the binary table with bin length

      Seems to work on desktop, will try it out on the mobile device and hope it works in the same way.


      We tried using the URL before (the other method posted), but it behaved differently on Android. I forget the details, but this one you posted is a great alternative. Thanks!

      Author's profile photo Ramakrishna Karnati
      Ramakrishna Karnati


      can you please send me code

      Author's profile photo Christopher Solomon
      Christopher Solomon

      Likely not as it is owned by the company and is not "free".

      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      HI Pavan.

      Finally I did it, it looks fine, but when I download the file, is always a 0 bytes file with name "$value()".

      I was looking and I found people with a similat issue on Approve Travel request and there is a note for that, but is on the odata for that app.

      Do you have any idea about this?


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Manuel

      If the file size is 0 bytes then the content is not getting transferred, please check it while debugging and try to pass the file content into cs_stream .

      The file name you can pass it in the parameters cv_file_name.

      Also you have to pass the MIME type into cv_mime_type

      I don't think any SAP Note is required to achieve this functionality.

      Please check the sample code once again and everything is available to resolve the above issue.

      Thanks & Regards


      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Ok, got it, you have to clear cache and it works.

      Thank you!

      Author's profile photo Umer Siddique
      Umer Siddique

      Hello Former Member,

      Your first part of code works perfectly and attachments are showing.But when i click on the attachment then it opens a blank window and my external debugger on content api method is also not triggering. Can you please tell me why this issue is coming.




      Author's profile photo Milroy Fernando
      Milroy Fernando

      Could you share the code ?

      Author's profile photo Farkathulla Cikkanther
      Farkathulla Cikkanther


      Could you share the sample code?