cancel
Showing results for 
Search instead for 
Did you mean: 

Add ARCHIVED Documents to workitems as attachments

Former Member
0 Kudos

Hi All,

In most of the documents like ECC POs, PRs, Trips, Invoices etc, the attachments are stored in the system as ARCHIVED Documents.

We have to retrieve these attachments and add them to the approval workitems as attachments.

In our case the workitems would be executed from Portal UWL. The Portal UWL users are not within the company network to open the SAP backend system. Hence we have requirement to retrieve the ARCHIVED Documents and add these to the workitems as attachments.

Please let me know how this can be done ?

I know that FMs  ARCHIV_GET_CONNECTIONS and  ALINK_RFC_TABLE_GET can be used to read the ARCHIVED Documents.

I also know that we need to use FM  SAP_WAPI_ATTACHMENT_ADD to add the attachments to workitem.

But please let me know what operation and conversion we need to perform on the data returned by FM ALINK_RFC_TABLE_GET.

I have tried attaching the output of ALINK_RFC_TABLE_GET to workitem but when we try to open this attachment the system gives error that there is no program associated with the file type and unable to open the file.

So i guess I am missing some step after getting the data from FM ALINK_RFC_TABLE_GET and before passing to FM SAP_WAPI_ATTACHMENT_ADD.

Thanks,

Sameer.

Accepted Solutions (1)

Accepted Solutions (1)

SandySingh
Active Contributor
0 Kudos

Hello Sameer,

Please note that the attaching the document to workitem will consume a LOT of disk space and it not a recommended practise. Archive link content server is used to store the documents and user can access with links. This is quite popular solution with Vendor invoice management using Open text

1. Convert document from the content server to a binary table with ARCHIV_GET_TABLE

2. Convert binary to xstring whith SCMS_BINARY_TO_XSTRING

3. Create an attachment to the workitem using SAP_WAPI_ATTACHMENT_ADD

Sample Code

  DATA lt_binary_data     TYPE TABLE OF tbl1024.

  DATA lv_binary_length   TYPE sapb-length .

  DATA lv_length          TYPE i.

  DATA lv_file_content    TYPE xstring.

  DATA lv_object_id       TYPE saeobjid .

  IF i_person IS INITIAL .

    RETURN.

  ENDIF.

  lv_object_id = i_person.

  CALL FUNCTION 'ARCHIV_GET_TABLE'

    EXPORTING

      sap_object               = 'PREL' <SAP_OBJECT>

      object_id                = lv_object_id

      ar_object                = 'HRICOLFOTO'

    IMPORTING

      binlength                = lv_binary_length

    TABLES

      binarchivobject          = lt_binary_data

    EXCEPTIONS

      error_archiv             = 1

      error_communicationtable = 2

      error_connectiontable    = 3

      error_kernel             = 4

      error_parameter          = 5

      not_unique               = 6

      OTHERS                   = 7.

  IF sy- subrc <> 0.

    RETURN.

  ENDIF.

  .

  lv_length = lv_binary_length.

* Convert binary data table to XString

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

    EXPORTING

      input_length = lv_length

    IMPORTING

      buffer       = lv_file_content

    TABLES

      binary_tab   = lt_binary_data

    EXCEPTIONS

      failed       = 1

      OTHERS       = 2.

  IF sy- subrc <> 0.

    RETURN.

  ENDIF.

  r_photo = lv_file_content.

If you want to attach this Xtsring doco to GOS then use method CL_FITV_GOS=>SAVE

http://scn.sap.com/thread/3701703


Regards

sandy

Answers (1)

Answers (1)

ronen_weisz
Active Contributor
0 Kudos

I agree with Sandy that it's a bad idea to attach the documents directly to the workitems, I usually use this method for doing so, but this should also require calling the backend system (using wingui from the UWL).

But if the users do not have access to the backend system, how is their decision transferred to the backend system? could the same way of calling it be used to display the documents?