Attach XSTRING file as GOS?

Viewed 450

I have created a SICF Service for GOS.

Basically it takes a pdf on frontend, converts it to base64 or binary and send it to the backend.

Now on the backend I have that PDF as xstring and want to create a business document "attachment". Manually it's quite easy with the FM ARCHIV_CREATE_FILE / ARCHIVOBJECT_CREATE_FILE, but they need the file path as input param.

How can I use my xstring as "filepath" to attach those data?

1 Answers

Try ARCHIV_CREATE_TABLE module:

DATA: ls_toadt   TYPE toadt,
      lv_flength TYPE sapb-length,
      lv_number  TYPE i.

DATA: lt_binary TYPE STANDARD TABLE OF tbl1024.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer     = iv_pdf                 " your PDF xstring!
  TABLES
    binary_tab = lt_binary.

  DESCRIBE TABLE lt_binary LINES lv_number.

  lv_flength = lv_number * 1024.

  CALL FUNCTION 'ARCHIV_CREATE_TABLE'
    EXPORTING
      ar_object                = ar_object
      object_id                = object_id
      sap_object               = sap_object
      flength                  = lv_flength
    IMPORTING
      outdoc                   = ls_toadt
    TABLES
      binarchivobject          = lt_binary
    EXCEPTIONS
      error_archive            = 01
      error_communicationtable = 02
      error_connectiontable    = 03
      error_kernel             = 04
      error_parameter          = 05
      OTHERS                   = 06.
Related