Monday, December 24, 2012

Reading files from Business Object repository

Use the following list of FMs to read the documents from Business Object Repository.



CALL FUNCTION 'BDS_ALL_CONNECTIONS_GET'
  EXPORTING
*    logical_system   = logical_system
    classname        = classname
    classtype        = classtype
    objkey           = objkey
    client           = sy-mandt
    all              = ' '     " <- br="br" get="get" newest="newest" the="the" version="version">    no_gos_docs      = ' '     " <- br="br" docs="docs" get="get" gos="gos" too="too">  IMPORTING
    count            = i_count
  TABLES
    signature        = signature
    all_connections  = i_connections
    framework        = framework
  EXCEPTIONS
    no_objects_found = 1
    error_kpro       = 2
    internal_error   = 3
    not_authorized   = 4
    OTHERS           = 5.
IF SY-SUBRC =  0.
 READ SINGATURE INTO I_SIGNATURE INDEX 1.

REFRESH : signature[ ].
 pass I_SIGNATURE-doc_id to below FM AND and get PHIO data
  CALL FUNCTION 'BDS_PHIO_GET_RIGHT'
       EXPORTING
            client         = client
            doc_id         = doc_id
       TABLES
            infoobjects    = i_infoobjects
            signature      = signature
       EXCEPTIONS
             nothing_found   = 1
             parameter_error = 2
             not_allowed     = 3
             error_kpro      = 4
             internal_error  = 5
             not_authorized  = 6
             OTHERS          = 9.
  IF sy-subrc = 0.
Pass the i_infoobjects to as PH_object for below FM and the file content will be downloaded into ASCII & BINARY data tables.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
         EXPORTING
              object_id           = ph_object
              client              = client
              text_as_stream      = 'X'
         TABLES
              file_access_info    = i_file_access_info
              file_content_ascii  = i_file_content_ascii
              file_content_binary = i_file_content_binary
         EXCEPTIONS
              not_existing        = 1
              not_authorized      = 6
              no_content          = 7
              bad_storage_type    = 8
              OTHERS              = 49.
    IF sy-subrc = 0.
    ENDIF.
  ENDIF.
ENDIF.