Copyright 2024 - BV TallVision IT

You need to read a big PDF file which is handed to you by some webserver as some-one uploaded it. It contains a resume or maybe a pricelist that needs to be available from SAP. So how ? From the backend, there is a toolset available for you to accomplish this. Read on !

First of all read the file in binary mode in bits. And compose a table with binary data for this:

DATA: lv_filename TYPE string,
      lv_content TYPE rcf_attachment_content,
      lt_binary_content TYPE SDOKCNTBINS,
      lv_hex_container TYPE xstring.

lv_filename = '/usr/sap/interface/pricelist.pdf'.
CLEAR: lv_content, lt_binary_content[].
*--------------------------------------------------
OPEN DATASET lv_filename FOR INPUT IN BINARY MODE.
*--------------------------------------------------
DO.
*--------------------------------------------------
  READ DATASET lv_filename
    INTO lv_hex_container MAXIMUM LENGTH 1000.
*--------------------------------------------------
  IF sy-subrc <> 0.
    EXIT.
  ELSE.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer                = lv_hex_container
       append_to_table       = 'X'
      TABLES
        binary_tab            = lt_binary_content.

  ENDIF.
ENDDO.
*--------------------------------------------------
CLOSE DATASET lv_filename.
*--------------------------------------------------

Then transform this result in to a single X-string variabele, that will contain the whole document:

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
  EXPORTING
    input_length       = 1000000000
  IMPORTING
    buffer             = lv_content
  TABLES
    binary_tab         = lt_binary_content
  EXCEPTIONS
    OTHERS             = 4.

Do note that there are quite a few function modules for "big data manupilation/handling" available:

SCMS_BINARY_TO_FTEXT  
SCMS_BINARY_TO_STRING  
SCMS_BINARY_TO_TEXT 
SCMS_BINARY_TO_XSTRING  
SCMS_FTEXT_TO_BINARY  
SCMS_FTEXT_TO_STRING  
SCMS_FTEXT_TO_TEXT 
SCMS_FTEXT_TO_XSTRING  
SCMS_STRING_TO_FTEXT  
SCMS_STRING_TO_XSTRING 
SCMS_TEXT_TO_BINARY  
SCMS_TEXT_TO_FTEXT 
SCMS_TEXT_TO_XSTRING  
SCMS_XSTRING_TO_BINARY