Skip to Content
0
Former Member
Jul 03, 2007 at 06:00 AM

BAPI_DOCUMENT_CREATE2 throws communication failure exception

46 Views

Hello to all,

I want to upload a file in WebDynpro ABAP by placing a service call to BAPI_DOCUMENT_CREATE2.

But i am getting "communication failure" exception. Request your help on this issue.

<b>(RFC Exception COMMUNICATION_FAILURE with Message RFC destination Create document does not exist. Occurred)</b>

Code for this service call is as follows :-

METHOD EXECUTE2_BAPI_DOCUMENT_CREATE2 .

DATA: ls_doc typE bapi_doc_draw2,

ls_return typE bapiret2.

  • key fields of the document

DATA: lf_doctype typE bapi_doc_draw2-documenttype,

lf_docnumber typE bapi_doc_draw2-documentnumber,

lf_docpart typE bapi_doc_draw2-documenttype,

lf_docversion typE bapi_doc_draw2-documenttype.

**.... Originals that are checked in simultaneously

DATA: "lt_files typE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

lt_files type standard table of bapi_doc_files2,

wa_lt_files like line of lt_files,

**.... Short texts

lt_drat typE standard table of bapi_doc_drat,

wa_lt_drat like line of lt_drat,

**.... Object links

"lt_drad typE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

lt_drad typE standard table of bapi_doc_drad,

wa_lt_drad like line of lt_drad.

**----


  • Allocate document data

ls_doc-documenttype = 'DRW'.

ls_doc-documentnumber = '4711'.

ls_doc-documentversion = '00'.

ls_doc-documentpart = '000'.

ls_doc-statusextern = 'AF'.

ls_doc-laboratory = '001'.

  • Check in original 1 simultaneously in the SAP Database

REFRESH lt_files.

CLEAR lt_files.

wa_lt_files-storagecategory = 'DMS_C1_ST'.

wa_lt_files-docfile = 'c:\original_acy.txt'.

wa_lt_files-wsapplication = 'TXT'.

APPEND wa_lt_files to lt_files.

"----


  • declarations for context navigation

DATA lo_element TYPE REF TO if_wd_context_element.

DATA lt_elements TYPE wdr_context_element_set.

  • declarations for parameters

  • get all involved child nodes

  • get input from context

  • the invocation - errors are always fatal !!!

DATA lv_rfc_error TYPE c LENGTH 120.

DATA lv_rfc_message TYPE string.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

DESTINATION 'Create document'

EXPORTING

documentdata = ls_doc

" hostname = wd_this->hostname

" docbomchangenumber = wd_this->docbomchangenumber

" docbomvalidfrom = wd_this->docbomvalidfrom

" docbomrevisionlevel = wd_this->docbomrevisionlevel

" cad_mode = wd_this->cad_mode

" pf_ftp_dest = wd_this->pf_ftp_dest

pf_http_dest = 'SAPHTTPA'

IMPORTING

documenttype = lf_doctype

documentnumber = lf_docnumber

documentpart = lf_docpart

documentversion = lf_docversion

return = ls_return

TABLES

" characteristicvalues =

" classallocations =

documentdescriptions = lt_drat

objectlinks = lt_drad

" documentstructure =

documentfiles = lt_files

" longtexts =

" components =

EXCEPTIONS

system_failure = 1 MESSAGE lv_rfc_error

communication_failure = 2 MESSAGE lv_rfc_error.

  • error handling

CASE sy-subrc.

WHEN 1.

lv_rfc_message = lv_rfc_error.

RAISE EXCEPTION TYPE cx_wd_no_handler

EXPORTING

textid = cx_wd_no_handler=>kind_rfc

old_exception = `SYSTEM_FAILURE`

rfc_message = lv_rfc_message.

WHEN 2.

lv_rfc_message = lv_rfc_error.

RAISE EXCEPTION TYPE cx_wd_no_handler

EXPORTING

textid = cx_wd_no_handler=>kind_rfc

old_exception = `COMMUNICATION_FAILURE`

rfc_message = lv_rfc_message.

ENDCASE.

  • store output to context

ENDMETHOD.