on 2024 Dec 11 8:27 AM
Hi Experts,
We have a enhancement for a custom button in various Tcodes ME*, VA*, VF*, FB*, F-*, etc. which display a popup that create DMS document for the respective document and allows attachments upload.
The enhancement is working fine in almost all cases, except for only one Tcode - F-53 that also in the Posting screen of open items.
Here when user clicks on our button, it will create a new DMS. I have checked this and in debug mode, the document is created using the below BAPI
CLEAR ls_return.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = ls_documentdata
IMPORTING
documenttype = lv_documenttype
documentnumber = lv_documentnumber
documentpart = lv_documentpart
documentversion = lv_documentversion
return = ls_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Here the document is created successfully and document number, type, part, version is generated.
Just below this we have a get document BAPI
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
documenttype = lv_documenttype
documentnumber = lv_documentnumber
documentpart = lv_documentpart
documentversion = lv_documentversion
IMPORTING
documentdata = es_document_data
TABLES
documentfiles = et_document_files.
This BAPI returns error that the document does't exist. Now I can understand if this happens in all scenarios but it is only happening in F-53 and specifically in the Posting of Open item screen.
System Message: 26/003
Any help is appreciated and thanks.
Request clarification before answering.
Hello,
I will try to answer your question according to my own knowledge. Maybe I can't give you the exact solution, but it can be a suggestive answer. I have not developed F-53 related enhancement before but I have used BAPIs.
First of all; I checked the message 26/003 and the content of the message is: “Document &1 does not exist” So somehow your document creation with BAPI might have a problem.
1. Check ls_return returning from the BAPI_DOCUMENT_CREATE2 function.
If it returns S, it is successful and you can use the commit function. Returns can be of the following types; S Success, E Error, W Warning, I Info, A Abort.
2. I suppose BAPI_TRANSACTION_COMMIT is not working properly. After calling the BAPI_TRANSACTION_COMMIT function, you can try to perform the commit process waiting for 1 second. In this case; I suppose you should know what is LUW (Logical Unit of Work). Read more here: https://community.sap.com/t5/application-development-blog-posts/what-is-luw-how-luw-works-different-...
You can also check and try the updated code as below.
CLEAR ls_return.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = ls_documentdata
IMPORTING
documenttype = lv_documenttype
documentnumber = lv_documentnumber
documentpart = lv_documentpart
documentversion = lv_documentversion
return = ls_return.
"check if the document was created successfully
"(S Success, E Error, W Warning, I Info, A Abort)
IF ls_return-type = 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WAIT UP TO 1 SECONDS. "wait 1 secod to commit
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
documenttype = lv_documenttype
documentnumber = lv_documentnumber
documentpart = lv_documentpart
documentversion = lv_documentversion
IMPORTING
documentdata = es_document_data
TABLES
documentfiles = et_document_files.
ENDIF.
If you cannot solve the problem with this suggestions, could you please let me know? I would like to know exactly what the problem is.
Regards
Ahmet E.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ahmet,
The BAPI return is initial when it has successfully created the document.
The problem is somewhere with in the BAPI COMMIT. I tried with your suggestion but still the document is not saved.
Even after complete execution, the document is not avaliable in the CV03N tcode
Below it tries to read but the document is not being saved by COMMIT so it return with no values while running BAPI_DOCUMENT_GETDETAIL2. Inside the BAPI, it generates the respective error message as mentioned.
Hello Amarjit,
Can you try these 2 methods?
Method 1; Using IN UPDATE TASK.
Can you try writing IN UPDATE TASK just below CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'?
Example;
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
IN UPDATE TASK "only this line added
EXPORTING
documentdata = ls_documentdata
IMPORTING
documenttype = lv_documenttype
documentnumber = lv_documentnumber
documentpart = lv_documentpart
documentversion = lv_documentversion
return = ls_return.
Method 2; Using COMMIT WORK.
You can write COMMIT WORK. after the BAPI_TRANSACTION_COMMIT function.
Example;
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
COMMIT WORK. "only this line added
These 2 methods also allow you to commit.
I solved a similar issue I had in the past with COMMIT WORK.
Regards
Ahmet E.
User | Count |
---|---|
60 | |
9 | |
8 | |
6 | |
5 | |
4 | |
3 | |
3 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.