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.

/wp-content/uploads/2016/07/1_1001706.png

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.

/wp-content/uploads/2016/07/2_1001711.png

/wp-content/uploads/2016/07/3_1001712.png

Navigate to CL_GBAPP_APV_PO_RDP->Methods->Redefinition>/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY

       

/wp-content/uploads/2016/07/4_1001713.png

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

/wp-content/uploads/2016/07/5_1001714.png

/wp-content/uploads/2016/07/7_1001715.png

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.

/wp-content/uploads/2016/07/8_1001716.png

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.

/wp-content/uploads/2016/07/9_1001729.png

/wp-content/uploads/2016/07/10_1001730.png

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

/wp-content/uploads/2016/07/11_1001731.png

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

/wp-content/uploads/2016/07/12_1001732.png

/wp-content/uploads/2016/07/13_1001733.png

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

IF_GBAPP_EX_APV_PO_RDP~CHANGE_ATTACHMENT_CONTENT_API

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

/wp-content/uploads/2016/07/14_1001734.png

/wp-content/uploads/2016/07/15_1001735.png

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.

/wp-content/uploads/2016/07/16_1001736.png

/wp-content/uploads/2016/07/17_1001737.png

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

      22 Comments
      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

      Pavan

      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.

      Thanks

      Author's profile photo Kevin Barter
      Kevin Barter

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

      Thanks

      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

      /wp-content/uploads/2016/09/bapi1_1029247.png

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

      /wp-content/uploads/2016/09/bapi2_1029317.png

      Then, select the method IF_GBAPP_EX_APV_PO_RDP~CHANGE_ATTACHMENT_CONTENT_API

      /wp-content/uploads/2016/09/bapi3_1029318.png

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

      /wp-content/uploads/2016/09/bapi4_1029319.png

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

      Do you have any suggestions?

      Thank you in advance.

      Regards.

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

      Hi

      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

      Pavan

      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Hi.

      Thank you for your reply.

      So should I re implement the method?

      Regards.

      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?

      Regards.

      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

      Pavan

      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?

      Regards.

      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

      Pavan

      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

      Hi,

      Could you share the sample code?

      Thanks...