cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Recordsmanagement, store document in the KPRO

Former Member
0 Kudos

Hi,

I'm developing an extension of the SAP Case Management. The requirement is to store a WordDoc or PPT in in the knowledge provider. Can somebody give me some advice how to do this?

Thanks

M.Sigal,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks,

that works. But the next problem came up immediately.

How can I retreive the documents again which have been written into the KPRO?

M.Sigal

0 Kudos

Hi M.,

you can do this via the case where the document is attached to. To to this you have to know the GUID of the case,record.

As you have seen in my code example above I qualified an anchor which is used to identify and retreive the documents which are attached at the case.

First you have to get a list of the documents. Using this anchor (BDATT, see above, you can name the anchor in every way you want) you can retrieve a list of the attached documents in the following way:


FUNCTION udm_dc_attchs_get.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(IM_GUID) TYPE  SCMG_CASE_GUID
*"  EXPORTING
*"     VALUE(ES_RETURN) TYPE  BAPIRET2
*"     VALUE(ET_DOCUMENT_LIST) TYPE  BDM_T_DOCUMENT_LIST
*"----------------------------------------------------------------------

*Create Calls according to
*FDM_AR_BD_DISPUTE_NOTES_GET (AXA)
*BDM_DISPUTE_NOTES_GET (BYA)
*UDM_DC_NOTES_GET (SE3)

* case instances
  DATA: li_if_scmg_case_api TYPE  if_scmg_case_api_type.
  DATA: li_cl_scmg_case_api TYPE REF TO cl_scmg_case_api.
* list of documents
  DATA: wa_documents TYPE udm_case_document_list.
  DATA: ex_documents TYPE udm_t_case_document_list.
* extended list of documents, see type definiton
  DATA: doclist TYPE TABLE OF doctype.
  DATA: wa_docs TYPE doctype.
* record elements
  DATA: lt_srm_rec_elem_tab TYPE srm_rec_elem_tab.
  DATA: wa_i_s_s_r_et TYPE REF TO if_srm_sp_record_element.
* POID object
  DATA: li_if_srm_poid TYPE REF TO if_srm_poid.
  DATA: li_cl_srm_poid TYPE REF TO cl_srm_poid.
* POID parameters
  DATA: lt_srm_list_poid TYPE srm_list_poid.
  DATA: wa_srmpoid TYPE srmpoid.
* work area for document export
  DATA: wa_bdm_document_list TYPE bdm_document_list.
* properties of doc
  DATA: ls_properties TYPE bapiproptb.
  DATA: lt_properties TYPE TABLE OF bapiproptb.


  CALL METHOD cl_scmg_case_api=>if_scmg_case_api~get_case
    EXPORTING
      im_case_guid = im_guid "CASE_GUID
    RECEIVING
      re_case      = li_if_scmg_case_api
    EXCEPTIONS
      failed       = 1
      invalid_guid = 2.

  IF sy-subrc EQ 1.
    CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
      EXPORTING
        i_number  = '009'
      IMPORTING
        es_return = es_return.
    EXIT.
  ELSEIF sy-subrc EQ 2.
    CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
      EXPORTING
        i_number     = '038'
        i_message_v1 = im_guid
      IMPORTING
        es_return    = es_return.
    EXIT.
  ENDIF.
  if 1 = 2.       "for cross reference
    MESSAGE E009(UDM_MSG).
  endif.
  if 1 = 2.        "for cross reference
    MESSAGE E038(UDM_MSG) with im_guid.
  endif.

* casting of IF to CL
  li_cl_scmg_case_api ?=  li_if_scmg_case_api.
* fill document structures
  wa_documents-scmg_case_api = li_cl_scmg_case_api.
  wa_docs-scmg_case_api = wa_documents-scmg_case_api.

* get all records
  CALL METHOD li_if_scmg_case_api->get_all_objects
    RECEIVING
      re_elements = lt_srm_rec_elem_tab
    EXCEPTIONS
      failed      = 1
      OTHERS      = 2.

  IF sy-subrc <> 0.

    CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
      EXPORTING
        i_number  = '161'
      IMPORTING
        es_return = es_return.
    EXIT.

  ENDIF.
    if 1 = 2.        "for cross reference
              MESSAGE E161(UDM_MSG).
    endif.

* loop at record elements
  LOOP AT lt_srm_rec_elem_tab INTO
       wa_i_s_s_r_et.


* only allow anchor=='BDATT' >>>>>>>>>>>>>>>>>
    DATA:  lt_element_attr    TYPE srm_xml_attr_tab,
           l_anchor           TYPE udm_anchor,
           ls_element_attr    TYPE srmxmlar.

    TRY.
        lt_element_attr = wa_i_s_s_r_et->attributes_get( ).
      CATCH cx_srm_sp_record_element.

        CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
          EXPORTING
            i_number     = '162'
            I_MESSAGE_V1 = 'CX_SRM_SP_RECORD_ELEMENT'
          IMPORTING
            es_return    = es_return.
        exit.

    ENDTRY.
    if 1 = 2.        "for cross reference
              MESSAGE E162(UDM_MSG) with 'CX_SRM_SP_RECORD_ELEMENT'
              .
    endif.

    LOOP AT lt_element_attr
        INTO ls_element_attr
        WHERE name CS 'ANCHOR'.

      l_anchor = ls_element_attr-val.
      EXIT.

    ENDLOOP.

    IF l_anchor NE 'BDATT'. CONTINUE. ENDIF.
* <<<<<<<<<<<<<<<<<<<<<<<<only allow anchor=='BDATT'

* get POID object and cast IF to CL
    TRY.
        CALL METHOD
          wa_i_s_s_r_et->if_srm_sp_record_elem_instance~poid_get
          RECEIVING
            poid = li_if_srm_poid.
      CATCH cx_srm_sp_record_element.
        CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
          EXPORTING
            i_number     = '163'
            I_MESSAGE_V1 = 'CX_SRM_SP_RECORD_ELEMENT'
          IMPORTING
            es_return    = es_return.

        exit    .
    ENDTRY.
    if 1 = 2.        "for cross reference
              MESSAGE E163(UDM_MSG) with 'CX_SRM_SP_RECORD_ELEMENT' .
    endif.

    li_cl_srm_poid ?= li_if_srm_poid.

* add POID-data to document data
    wa_documents-srm_poid = li_cl_srm_poid.
    wa_docs-srm_poid = li_cl_srm_poid.

* if there is no POID go to next record element
    IF li_cl_srm_poid IS INITIAL.
      CONTINUE.
    ENDIF.

* get Service Provider ID and add it to the document data
    TRY.
        CALL METHOD li_cl_srm_poid->if_srm_poid~get_sp_id
          RECEIVING
            re_sp_id = wa_documents-sp_id.
        wa_docs-sp_id = wa_documents-sp_id.
      CATCH cx_srm_initialization .
        CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
          EXPORTING
            i_number     = '164'
            I_MESSAGE_V1 = 'CX_SRM_INITIALIZATION'
          IMPORTING
            es_return    = es_return.
        exit.

      CATCH cx_srm_poid.
        CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
          EXPORTING
            i_number     = '164'
            I_MESSAGE_V1 = 'CX_SRM_POID'
          IMPORTING
            es_return    = es_return.

        exit.
    ENDTRY.
    if 1 = 2.        "for cross reference
              MESSAGE E163(UDM_MSG) with 'CX_SRM_INITIALIZATION'.
    endif.
    if 1 = 2.        "for cross reference
              MESSAGE E164(UDM_MSG) with 'CX_SRM_POID'.
    endif.

* get POID parameters
* get document class and document ID of uploaded DOCS
* docid has to be changed to UDM_DOCBD, because UDM_DOC01 is for workflow
* best solution: customizing for the upload via Biller Direct
* only UDM_DOCBD or UDM_DOC01 and UDM_DOCBD for BD
    TRY.
        CALL METHOD li_cl_srm_poid->if_srm_poid~get_sp_poid
          RECEIVING
            re_sp_poid = lt_srm_list_poid.
        CLEAR: wa_docs-idclass, wa_docs-objectid.
        LOOP AT lt_srm_list_poid INTO wa_srmpoid.
          IF  wa_srmpoid-id NE 'DOC_ID'.
            CONTINUE.
          ENDIF.
          IF wa_srmpoid-value(9) CS 'UDM_DOC0'.

            wa_docs-idclass  = wa_srmpoid-value(9).
            wa_docs-objectid = wa_srmpoid-value+10.
          ELSE.
            CLEAR: wa_docs-idclass, wa_docs-objectid.
          ENDIF.

        ENDLOOP.
      CATCH cx_srm_initialization .
        CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
          EXPORTING
            i_number     = '165'
            I_MESSAGE_V1 = 'CX_SRM_INITIALIZATION'
          IMPORTING
            es_return    = es_return.
        exit.

      CATCH cx_srm_poid.
        CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
          EXPORTING
            i_number     = '165'
            I_MESSAGE_V1 = 'CX_SRM_POID'
          IMPORTING
            es_return    = es_return.
        exit.

    ENDTRY.
    if 1 = 2.        "for cross reference
              MESSAGE E165(UDM_MSG) with 'CX_SRM_INITIALIZATION'.
               MESSAGE E165(UDM_MSG) with 'CX_SRM_POID'.


    endif.

* currently only process the documents with UDM_DOC01
    IF wa_docs-idclass(8)  NE 'UDM_DOC0'.
      CONTINUE.
    ENDIF.

    IF wa_documents-sp_id CS 'SCMG_SP_DOCUMENT' .
*         wa_documents-sp_id = 'SCMG_SP_AL_DOCUMENT'.
*      TRY.
*          CALL METHOD WA_I_S_S_R_ET->DESCRIPTION_GET
*            RECEIVING
*              DESCRIPTION = wa_documents-description.
*          wa_docs-description = wa_documents-description.
*        CATCH CX_SRM_SP_RECORD_ELEMENT .
*      ENDTRY.
      CALL FUNCTION 'BAPI_SRM_DOC_GETPROPERTIES'
        EXPORTING
          objectid             = wa_docs-objectid
          documentclass        = wa_docs-idclass
*         WHOLE_DOCUMENT       = ''
*         DOC_CONTEXT          =
        IMPORTING
          RETURN               = ES_RETURN
        TABLES
          properties           = lt_properties
                .
      LOOP AT lt_properties INTO ls_properties WHERE name = 'DESCRIPTION'.
        wa_documents-description = ls_properties-value.
        wa_docs-description = wa_documents-description.
      ENDLOOP.

      APPEND wa_documents TO ex_documents.
      APPEND wa_docs TO doclist.
    ENDIF.
  ENDLOOP.

  SORT doclist BY objectid.
  DELETE ADJACENT DUPLICATES FROM doclist COMPARING objectid.


  LOOP AT doclist INTO wa_docs.

    wa_bdm_document_list-case_guid = wa_docs-objectid.
    wa_bdm_document_list-idclass   = wa_docs-idclass.
    wa_bdm_document_list-description = wa_docs-description.
    APPEND wa_bdm_document_list TO et_document_list.

  ENDLOOP.
ENDFUNCTION.

0 Kudos

I submitted my post too early.

The second part is:

Afterwards you can select one entry form the list (you have to have a closer look at the function modules/methods which are called and maybe to define some of your own data elements/types) and get one single Document in the following way:


FUNCTION FDM_AR_BD_DISPUTE_FILE_GET.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(OBJECTID) LIKE  BAPISRMDOC-GUID
*"     REFERENCE(IDCLASS) LIKE  BAPISRMDOC-DOCCLASS
*"  EXPORTING
*"     REFERENCE(COMP_ID) TYPE  BAPIDOCID
*"     REFERENCE(MIMETYPE) TYPE  BAPIMIMETYPE
*"     REFERENCE(COMP_SIZE) TYPE  BAPIPOS
*"     REFERENCE(E_RETURNCODE) LIKE  SY-SUBRC
*"     REFERENCE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2
*"  TABLES
*"      BIN_CONTENT STRUCTURE  BAPICONTEN
*"----------------------------------------------------------------------
data:
        lt_DOCCOMP type table of BAPIDOCCOMP,
        wa_doccomp type BAPIDOCCOMP,
        l_rfcdest       TYPE rfcdest
        .

  CALL FUNCTION 'FDM_COM_DESTINATION_GET'
    IMPORTING
      e_destination = l_rfcdest
      es_return     = return.




  if return is initial.
*----------------------------------------------
    IF l_rfcdest EQ 'NONE'.
*-- one system scenario ---
      TRY.

          CALL FUNCTION 'BAPI_SRM_DOC_CHECKOUT_VIA_TAB'
            EXPORTING
              OBJECTID                = OBJECTID
              DOCUMENTCLASS           = IDCLASS
*      VERSION                 = 0
*      VARIANT                 = 0
*      X_SET_CHECKED_OUT       = ' '
*      DO_COMMIT               =
            IMPORTING
              RETURN                  = RETURN
            TABLES
              COMPONENTS              = lt_DOCCOMP
*      ASCII_CONTENT           =
              BIN_CONTENT             = BIN_CONTENT
                    .


*   get exception CALL_FUNCTION_NOT_FOUND
        CATCH cx_sy_dyn_call_illegal_func.
          CALL FUNCTION 'BALW_BAPIRETURN_GET2'
            EXPORTING
              type   = 'E'
              cl     = 'EU'
              number = '096'
              par1   = 'BAPI_SRM_DOC_CHECKOUT_VIA_TAB'
            IMPORTING
              return = RETURN.

      ENDTRY.


    ELSE.

      TRY.

    CALL FUNCTION 'BAPI_SRM_DOC_CHECKOUT_VIA_TAB' DESTINATION l_rfcdest
       EXPORTING
         OBJECTID                = OBJECTID
         DOCUMENTCLASS           = IDCLASS
*      VERSION                 = 0
*      VARIANT                 = 0
*      X_SET_CHECKED_OUT       = ' '
*      DO_COMMIT               =
       IMPORTING
         RETURN                  = RETURN
       TABLES
         COMPONENTS              = lt_DOCCOMP
*      ASCII_CONTENT           =
         BIN_CONTENT             = BIN_CONTENT
               .

*   get exception CALL_FUNCTION_NOT_FOUND
        CATCH cx_sy_dyn_call_illegal_func.
          CALL FUNCTION 'BALW_BAPIRETURN_GET2'
            EXPORTING
              type   = 'E'
              cl     = 'EU'
              number = '096'
              par1   = 'BAPI_SRM_DOC_CHECKOUT_VIA_TAB'
            IMPORTING
              return = RETURN.

      ENDTRY.

*------------------------------------------------
    endif.

    read table lt_DOCCOMP into wa_doccomp index 1.
    if sy-subrc = 0.
      COMP_ID   = wa_doccomp-COMP_ID .
      MIMETYPE  = wa_doccomp-MIMETYPE.
      COMP_SIZE = wa_doccomp-COMP_SIZE.
    endif.
  endif.
ENDFUNCTION.

There seems to be some additional code but this is due to the fact that a one and two system scenarion is supported by this coding.

Regards,

Ruediger

Former Member
0 Kudos

Thanks for the examples.

I finally managed to solve my poblem.

M.S.

Answers (1)

Answers (1)

0 Kudos

Hi M.,

Please have a look at the following example. It contains a little bit more but especially the function modules

SRM_DOCUMENT_CREATE and

SRM_DOCUMENT_CHECKIN_VIA_TAB

are the important ones

Regards,

Ruediger


FUNCTION UDM_BD_CREATE_ATTACHMENT.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(I_GUID) TYPE  SCMG_CASE_GUID
*"     REFERENCE(I_CASE) TYPE REF TO  IF_SCMG_CASE_API
*"     REFERENCE(I_TESTRUN) TYPE  TESTRUN
*"  TABLES
*"      BIN_CONTENT STRUCTURE  BAPICONTEN
*"      COMPONENTS STRUCTURE  BAPIDOCCOMP
*"  CHANGING
*"     REFERENCE(ES_RETURN) TYPE  BAPIRET2
*"  RAISING
*"      CX_SRM_INITIALIZATION
*"      CX_SRM_SP_RECORD_ELEMENT
*"      CX_SRM_SP_RECORD
*"      CX_SRM_SK
*"      CX_SRM_FRAMEWORK
*"----------------------------------------------------------------------

  DATA:

    ANCHOR TYPE  STRINGVAL,
    SPS_ID TYPE  STRINGVAL,
    SP_ID  TYPE  STRINGVAL,
    RMS_ID TYPE  STRINGVAL,
    SRM_LIST TYPE  SRM_LIST_POID,
    lref_rec TYPE REF TO if_srm_sp_record,
    lref_element TYPE REF TO if_srm_sp_record_element,
    lref_ele     TYPE REF TO if_srm_sp_record_elem_instance,
    lt_sp_poid TYPE srm_list_poid,
    ls_sp_poid TYPE srmpoid,
    lo_bor_poid TYPE REF TO if_srm_poid,
    okay type c,
    lref_api TYPE REF TO if_scmg_case_api

    .

  DATA: l_docid TYPE bapidocid,
      l_objid TYPE bapiguid,
      l_docclass TYPE bapidclass
      .


  DATA:
      lt_filename TYPE filetable,
      ls_filename TYPE file_table,
      l_rc        TYPE i,
      file_tab   TYPE TABLE OF bapidocfiles,

      l_fname     TYPE string,
      l_path      TYPE string,
      lt_tab      TYPE STANDARD TABLE OF string,
      l_lines     TYPE i.

  DATA:
      i_toadd_line      TYPE toadd,
      wa_file    TYPE bapidocfiles,
      l_mime            TYPE string,
      i_toadd           TYPE STANDARD TABLE OF toadd,
      l_extension TYPE string.

  data:
        ls_components type BAPIDOCCOMP,
        lt_COMPONENTS type table of BAPIDOCCOMP,
        lt_bin_content type table of BAPICONTen.


  lt_COMPONENTS = components[].
  lt_bin_content = bin_content[].
  loop at lt_components into ls_components.
    exit.
  endloop.


  CALL FUNCTION 'UDM_GET_DOCUMENT_DATA'
    EXPORTING
      I_GUID     = I_GUID
      I_CASE     = I_CASE
    IMPORTING
      E_ANCHOR   = ANCHOR
      E_SPS_ID   = SPS_ID
      E_SP_ID    = SP_ID
      E_RMS_ID   = RMS_ID
      E_SRM_LIST = SRM_LIST.


  if i_case is initial.
    CALL METHOD cl_scmg_case_api=>get_case
      EXPORTING
        im_case_guid = i_guid
        im_enqueue   = 'X'
      RECEIVING
        re_case      = lref_api
      EXCEPTIONS
        failed       = 1
        invalid_guid = 2.
    IF sy-subrc EQ 1.
      CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
        EXPORTING
          i_number  = '009'
        IMPORTING
          es_return = es_return.
      EXIT.
    ELSEIF sy-subrc EQ 2.
      CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
        EXPORTING
          i_number     = '038'
          i_message_v1 = i_guid
        IMPORTING
          es_return    = es_return.
      EXIT.
    ENDIF.
    if 1 = 2.        "for cross reference
              MESSAGE E009(UDM_MSG).
    endif.
    if 1 = 2.        "for cross reference
              MESSAGE E038(UDM_MSG) with i_guid.
    endif.
    .

  else.
    lref_api = i_case.
  endif.


  CONCATENATE sy-datum sy-uzeit sp_id INTO l_docid.

  data description type BAPIDESCR.
  data tmprmsid type BAPIRMSID.
  data tmpspsid type BAPISPSID.
  tmprmsid = RMS_ID.
  tmpspsid = SPS_ID.
  description = ls_components-comp_id.
  l_fname = description.
  CALL FUNCTION 'SRM_DOCUMENT_CREATE'
    EXPORTING
      RMS_ID                  = tmprmsid
      SPS_ID                  = tmpspsid
      DOCUMENTID              = l_docid
      DESCRIPTION             =      description
      DO_COMMIT               = 'X'
*      DOC_CONTEXT             =
    IMPORTING
      RETURN                  = es_return
      OBJECTID                = l_objid
      DOCUMENTCLASS           = l_docclass
   EXCEPTIONS
     INTERNAL_ERROR          = 1
     PARAMETER_ERROR         = 2
     DOC_ID_NOT_UNIQUE       = 3
     NOT_AUTHORIZED          = 4
     CUSTOMIZING_ERROR       = 5
     OTHERS                  = 6
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* no handling necessary because error is passed through es_return
    exit.
  ENDIF.



  SELECT * FROM toadd INTO TABLE i_toadd
           WHERE  mimetype = ls_components-mimetype.

  IF sy-subrc ne 0.

    l_mime = ls_components-mimetype.

  ELSE.

    l_mime = 'text/x-doctype'.                              "#EC NOTEXT

  ENDIF.
  wa_file-comp_count = 1.
  wa_file-comp_id = ls_components-comp_id.
  wa_file-directory = l_path.
  wa_file-filename = l_fname.
  wa_file-mimetype = l_mime.
  wa_file-comp_num = 1.
  APPEND wa_file TO file_tab.

  if i_testrun is initial.
    CALL FUNCTION 'SRM_DOCUMENT_CHECKIN_VIA_TAB'
      EXPORTING
        OBJECTID                = l_objid
        DOCUMENTCLASS           = l_docclass
*     AS_NEW_VERSION          =
*     DO_COMMIT               =
*     DOC_CONTEXT             =
*   IMPORTING
*     X_NEW_DOC_CREATED       =
*     RETURN                  =
      TABLES
        COMPONENTS              = lt_components
*     ASCII_CONTENT           =
        BIN_CONTENT             = lt_bin_content
    EXCEPTIONS
     INTERNAL_ERROR          = 1
     PARAMETER_ERROR         = 2
     NOT_AUTHORIZED          = 3
     DOC_NOT_FOUND           = 4
     YET_LOCKED              = 5
     OTHERS                  = 6
              .
    IF SY-SUBRC <> 0.
      CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
        EXPORTING
          i_number     = '166'
          i_message_v1 = i_guid
        IMPORTING
          es_return    = es_return.
      EXIT.

    ENDIF.
    if 1 = 2.        "for cross reference
              MESSAGE E166(UDM_MSG) with i_guid.
    endif.


    CALL METHOD lref_api->get_backend_record
      RECEIVING
        re_record_backend = lref_rec
      EXCEPTIONS
        failed            = 1
        OTHERS            = 2.
    IF sy-subrc <> 0.
      CALL FUNCTION 'UDM_GEN_PREPARE_RETURN'
        EXPORTING
          i_number     = '167'
          i_message_v1 = i_guid
        IMPORTING
          es_return    = es_return.
    ENDIF.
    if 1 = 2.        "for cross reference
              MESSAGE E167(UDM_MSG) with i_guid.
    endif.

    CALL METHOD lref_rec->element_create
      RECEIVING
        element = lref_element.
    lref_element->DESCRIPTION_SET( l_fname ).
    lref_ele ?= lref_element.


    REFRESH lt_sp_poid.
    ls_sp_poid-id    = 'DOC_ID'.
    CONCATENATE l_docclass l_objid INTO ls_sp_poid-value SEPARATED BY space.
*ls_sp_poid-value = l_docid.
    INSERT ls_sp_poid INTO TABLE lt_sp_poid.
    ls_sp_poid-id    = 'VARIANT'.
    ls_sp_poid-value = '0'.
    INSERT ls_sp_poid INTO TABLE lt_sp_poid.
    ls_sp_poid-id    = 'VERSION'.
    ls_sp_poid-value = '0'.
    INSERT ls_sp_poid INTO TABLE lt_sp_poid.

    lo_bor_poid = cl_scmg_case_api=>g_client_service->poid_get_instance(
                                 im_sps_id  = sps_id
                                 im_rms_id  = rms_id
                                 im_sp_poid = lt_sp_poid ).

    CALL METHOD lref_ele->poid_set
      EXPORTING
        poid = lo_bor_poid.
    lref_element->type_set( if_srm_sp_record_element=>type_instance ).

    try.

        CALL METHOD lref_rec->element_add_by_anchor
          EXPORTING
            anchor  = 'BDATT'
            element = lref_element.

      catch CX_SRM_SP_RECORD.
        CALL METHOD lref_rec->element_add_by_anchor
          EXPORTING
            anchor  = '#INITIAL#'
            element = lref_element.
    endtry.


**>>>> workaround because LREF_API->SAVE does not save the
**     records backend
*    TRY.
*        CALL METHOD LREF_REC->SAVE
*          EXPORTING
*            NEW_VERSION = space.
*      CATCH CX_SRM_SP_RECORD .
*      CATCH CX_SRM_GSP_BACK .
*    ENDTRY.
**<<<<<<<<
*
**    lref_api->save( ).
**    g_d_att_not_yet_saved = 'X'.
*    CALL METHOD LREF_API->SAVE
*       EXPORTING
*         IM_DEQUEUE     = SPACE
**        IM_NEW_VERSION = SPACE
**      IMPORTING
**        EX_MESSAGES    =
*       EXCEPTIONS
*         FAILED         = 1
*         others         = 2
*            .
*    IF SY-SUBRC <> 0.
*      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*    else.
*      message ID 'UDM_MSG'
*      TYPE 'S'
*      NUMBER 157
*            .
*    ENDIF.


  endif.

*  CALL METHOD LREF_API->DEQUEUE
*    RECEIVING
*      RE_OKAY = okay
*    EXCEPTIONS
*      FAILED  = 1
*      others  = 2.
*  IF SY-SUBRC <> 0.
*    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.



ENDFUNCTION.

Former Member
0 Kudos

Hi Ruediger ,

Can you please tell how can I upload an image file from XI to KPro.

Actually the requirement is like this:

The users will be scanning documents and will be saving it into a particular folder on which java program is written. This Java program will give the image file to XI. Now i have to take the file from XI to KPro.

If you can provide any diffent method of doing this, I would be thankful.

Thanks And Regards

Rajiv Roshan