Skip to Content
avatar image
Former Member

Problem attach document with the FileUpload UI.

I am trying to attach a document to a CRM Notification from application Web Dynpro for ABAP, I have build a FM that includes the method

cl_crm_documents=>create_with_file

When I test the FM from SE37 transaction, I am able to attach a file from a local disk succesfully. But If I call this FM from Web Dynpro, trying to do the same operation, document cannot attach to notification and Method returns the following error: “Error loading file ” (Class of message CRM_DOCUMENTS and number 100).

Thanks in advance.

FUNCTION z_crm_anexar_docs_inc.

*"----

-


""Interfase local

*" IMPORTING

*" VALUE(GUID) TYPE CRMT_OBJECT_GUID

*" VALUE(FILENAME) TYPE SDOK_FILNM

*" VALUE(PATH) TYPE SDOK_CHTRD OPTIONAL

*" VALUE(DESCRIPTION) TYPE STRING

*"----

-


DATA: ls_bor TYPE sibflporb,

lv_loio TYPE skwf_io,

lv_phio TYPE skwf_io,

lv_error TYPE skwf_error.

MOVE: 'BUS2000116' TO ls_bor-typeid, "aqui le pasamos el tipo de objeto que estemos tratando

'BO' TO ls_bor-catid,

guid TO ls_bor-instid.

DATA: wa_result_tab TYPE string.

DATA: result_tab TYPE STANDARD TABLE OF string.

DATA: lin TYPE i.

DATA: long_nombre TYPE i.

DATA: long_total TYPE i.

DATA: desplazamiento TYPE i.

DATA: filename_aux TYPE skwf_descr.

SPLIT filename AT '' INTO TABLE result_tab.

DESCRIBE TABLE result_tab LINES lin.

READ TABLE result_tab INDEX lin INTO wa_result_tab.

IF sy-subrc EQ 0.

long_total = STRLEN( filename ).

long_nombre = STRLEN( wa_result_tab ).

desplazamiento = long_total - long_nombre.

path = filename(desplazamiento).

filename = wa_result_tab.

filename_aux = wa_result_tab.

ENDIF.

  • aqui le pasamos el guid del documento sap crm que estemos tratando

CALL METHOD cl_crm_documents=>create_with_file

EXPORTING

  • aqui le pasamos el nombre del fichero que queremos anexar

file_name = filename

  • 'c:' "aqui le pasamos la ruta del fichero que queremos anexar

directory = path

business_object = ls_bor

IMPORTING

loio = lv_loio

phio = lv_phio

error = lv_error.

  • aqui llamamos a este método porque de lo contrario el sistema crea el anexo con el nombre que

  • le da la gana y no con el que hemos indicado en el punto anterior. por eso renombramos el fichero

CALL METHOD cl_crm_documents=>rename_object

EXPORTING

is_io = lv_loio

iv_name = filename_aux.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

  • IMPORTING

  • RETURN =

ENDFUNCTION.

Call from WDA.

CALL FUNCTION 'Z_CRM_ANEXAR_DOCS_INC'

EXPORTING

guid = guid_jarcode

  • guid = stru_importing-guid

filename = stru_importing-filename

  • PATH =

description = stru_importing-description.

ENDMETHOD.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jun 29, 2007 at 03:24 AM

    Hi Angel,

    I dont think cl_crm_documents=>create_with_file will work in the Webdynpro UI as it is meant for the SAP GUI.So for file upload , use the file upload UI element provided by the WebDynpro and once you upload the data.It will be available in the attribute of the context and you could this to pass the data to other function modules.

    Thanks

    Anzy

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Chandrashekhar Mahajan

      hi, Chandrashekhar

      I get the string 'R3MATCLASS#SOGOU#SG001#点火装置#点火装置##R3MATCLASS#SOGOU#SG002#仪表#仪表' from file.

      How can i split the string by 'Enter' and 'Tab'?

      Thank you very much!