‎2011 Jul 20 6:10 PM
Hi Guys,
I am using this bapi to create one document number but I am getting error: BAPI Error creating REF doc
Below is my code can somebody tell me wht I am missing?
data: ls_doc like bapi_doc_draw,
ls_return like bapiret2.
data: lf_doctype like bapi_doc_draw-documenttype,
lf_docnumber like bapi_doc_draw-documentnumber,
lf_docpart like bapi_doc_draw-documenttype,
lf_docversion like bapi_doc_draw-documenttype.
Allocate document data
ls_doc-documenttype = 'REF'.
ls_doc-documentnumber = doknr.
ls_doc-documentversion = '000'.
ls_doc-documentpart = '00'.
ls_doc-description = dktxt.
ls_doc-statusextern = 'FR'.
ls_doc-authoritygroup = p_auth_group.
call function 'BAPI_DOCUMENT_CREATE'
exporting: documentdata = ls_doc
importing: documenttype = lf_doctype
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
return = ls_return.
clear bdc_status.
bdc_status-session_name = e_group.
bdc_status-tran_id = 'BAPI'.
bdc_status-object_id = part32.
bdc_status-plant = ' '.
bdc_status-process_date = sy-datum.
bdc_status-process_time = sy-uzeit.
Error occurred ??
if ls_return-type ca 'EA'.
rollback work.
bdc_status-message_type = 'E'.
bdc_status-message_nbr = '000000'.
concatenate 'BAPI Error creating REF doc' doknr
into bdc_status-messages separated by space.
append bdc_status.
bdc_status-messages = ls_return-message.
append bdc_status.
else.
bdc_status-message_type = 'S'.
bdc_status-message_nbr = '000000'.
concatenate 'REF doc' doknr 'Created successfully'
into bdc_status-messages separated by space.
append bdc_status.
commit work and wait.
endif.
Thanks!
‎2011 Jul 20 6:30 PM
Did you try running this BAPI from se37 with all the parameters you are passing through the program. if not try it, . You can see teh messages and understand if any error occurs.
‎2011 Jul 20 7:33 PM
It worked in SE37. But not workin in program. I don't know what I am missing in code
‎2011 Jul 20 10:05 PM
Hi,
do you run the BAPI several times in a loop, if yes then does it work first time? If yes, that would mean that the BAPI buffer has not been refreshed between the 2 calls. To do it, you must use function modules BAPI_TRANSACTION_COMMIT and BAPI_TRANSACTION_ROLLBACK, instead of COMMIT WORK and ROLLBACK WORK respectively.
There seems to be some batch input somewhere (I see variables BDC...) in your program, around the BAPI?, how do they work together?
BR
Sandra