on 2024 Jun 27 1:08 AM
Hi community,
A common request from customers is that a report execute a certain process and if one of the process "fail" not continue with the others process. In S/4HANA Public Cloud, the replacement for BAPI's are the Local APIs (Business Object Interfaces - BOI) for example I_MaterialDocumentTP. Only for reference, this example is obtained from the standard Knowledge Transfer Document. In theory, the REPORTED structure must return messages in case of an error occurs, but that is not the case.
MODIFY ENTITIES OF i_materialdocumenttp
ENTITY MaterialDocument
CREATE FROM VALUE #( ( %cid = 'CID_001'
goodsmovementcode = '01'
postingdate = '31129999'
documentdate = '31129999'
%control-goodsmovementcode = cl_abap_behv=>flag_changed
%control-postingdate = cl_abap_behv=>flag_changed
%control-documentdate = cl_abap_behv=>flag_changed
) )
ENTITY MaterialDocument
CREATE BY \_MaterialDocumentItem
FROM VALUE #( (
%cid_ref = 'CID_001'
%target = VALUE #( ( %cid = 'CID_ITM_001'
plant = '1010'
material = 'RAW_MATERIAL_01'
GoodsMovementType = '501'
storagelocation = '101A'
QuantityInEntryUnit = 1
entryunit = 'ST'
%control-plant = cl_abap_behv=>flag_changed
%control-material = cl_abap_behv=>flag_changed
%control-GoodsMovementType = cl_abap_behv=>flag_changed
%control-storagelocation = cl_abap_behv=>flag_changed
%control-QuantityInEntryUnit = cl_abap_behv=>flag_changed
%control-entryunit = cl_abap_behv=>flag_changed
) )
) )
MAPPED DATA(ls_create_mapped)
FAILED DATA(ls_create_failed)
REPORTED DATA(ls_create_reported).The "errors" only are obtained when the COMMIT ENTITIES in the REPORTED structure.
COMMIT ENTITIES
RESPONSE OF i_materialdocumenttp
FAILED DATA(commit_failed)
REPORTED DATA(commit_reported).Of course, in the context of ABAP RAP, the use of COMMIT is not supported.
If I'm developing an application with ABAP RAP and I have an action that need to create a material document and report if an error occurs, who could I achieve that?
I know the existence of different methods of "asynchronous code execution" (app. jobs, bgPF and events), if this is the only way... what could be the best option to report/show to the user that material document is processing in background and when the process ends show the errors or the new document created?
Request clarification before answering.
Hi Christian,
this requirement is being adressed with the feature "ABAP Pushchannel for SAP Fiori" which is planned for SAP S/4HANA Cloud Public Edition 2502.
"... You can use RAP side-effects to indicate dependencies on the UI for synchronous changes: changes can have impact on other fields, messages, and feature control. But how can you indicate these dependencies in case they're performed asynchronously, for example by using the background processing framework? For asynchronous programming patterns, we want to integrate Web-Sockets natively into the transactional RAP programming model to be interpreted on client side, like for example by SAP Fiori Elements."
Kind regards,
Andre
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andre_Fischer,
As S/4HANA Cloud version 2502 was released last week, do you know where to find additional information about this feature?
Thanks!
Mattijs
Hello @Andre_Fischer @ChristianLopez , I’m also very interested in this topic.
I’m not sure I understand how the improvement mentioned in the roadmap relates to Christian Lopez’s issue. I’ve developed a similar application (also using I_MaterialDocumentTP), and in my case, the messages are reflected in the UI without any problem.
The real challenge is that these messages are not tied to a specific table row. For example, if my action creates one material document per row, I want to know which row produced which success or error message when the action is executed on multiple rows. This feels like a very basic requirement, and I don’t understand why it’s so complicated to handle properly.
I haven’t tried the Background Processing Framework or job-based workarounds, but I’m not even sure they would work, since material document creation is always tricky due to commit handling (which, fortunately, is managed correctly by the RAP Business Object I_MaterialDocumentTP—a pleasant surprise). You’ve helped in the past to retrieve the created material document ID (which is also tricky but doable). However, as I can see in this GitHub repository, errors are simply not handled in SAP’s examples.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.