cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_DOCUMENT_CREATE2 throws communication failure exception

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Abhishek,

First you have to check that your RFC destination is working properly: Use the TCode SM59 and select your Destination and test it using the option remote login.

Check all the resources that you use are activated!.

Regards

Vinod V

Former Member
0 Kudos

Hi Abhishek,

This link may be helpful for you

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi fahad,

i have gone through this thread, all i want to know is "Why is this service call throwing an exception". Is there something i am missing out ?

regards,

abhishek

Former Member
0 Kudos

Got the answer we need to specify the RFC destination

Former Member
0 Kudos

Hi

can u send how u solve eg.

cheers

Santosh