3 weeks ago
Hi Everyone,
Currently we are on S4HANA 2020 on premise. We have a requirement where we need to use Custom Business Object ( CBO ) which will be exposed as a service and config on BAS.
We will be doing with all CRUD operation on the above application build from CBO and also had to trigger a BAPI call to create Sales Order on one action button.
Please suggest how I can add the BAPI functionality here on Action button. Secondly, how we can add action button on UI build through CBO.
Best Regards
Hello!
I am unsure with your version if you can call the BAPI directly inside the Implementation method of your action, implemented in the Behaviour Implementation Class.
If not, you will have to create a Class and method to call the BAPI and expose it as C1 to call it inside your RAP Behaviour Implementation.
The only tricky thing is the commit that you need to perform. For that, we came up with a workaround by wrapping the BAPI in a custom RFC function module, similar to this (this is for Planned Order creation but the logic is the same):
CALL FUNCTION 'ZPP_FM_CUTSIZE_CREATE_ORDER'
STARTING NEW TASK 'Z_ORDER'
DESTINATION 'NONE'
CALLING response_action ON END OF TASK
EXPORTING
logical_system = mv_logsys
order_type = '5'
ext_number_assignment = 'X'
commit_control = 'E' "E
strategy_profile = ls_strategy_profile
event_control = '1'
planning_mode_usage = '1'
TABLES
order_head = lt_order_head
order_structure = lt_order_structure
order_components = lt_order_components
characteristics_val_io = lt_characteristics_val_io
order_modes = lt_o_mode
mapping_data = lt_mapping_data
return = lt_ret
extension_in = lt_extension_in
CHANGING
cv_complete = lv_is_complete
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
WAIT UNTIL lv_is_complete EQ abap_true.
response action method to receive the result:
METHOD response_action.
DATA lt_mapping_data TYPE TABLE OF bapi10503ordmapreto.
RECEIVE RESULTS FROM FUNCTION 'ZPP_FM_CREATE_ORDER'
IMPORTING return = mt_bapi_create_ret
mapping_data = lt_mapping_data .
READ TABLE lt_mapping_data ASSIGNING FIELD-SYMBOL(<fs_mapping_data>) INDEX 1.
CHECK <fs_mapping_data> IS ASSIGNED.
mv_planned_order = <fs_mapping_data>-order_number.
ENDMETHOD.
code inside ZPP_FM_CREATE_ORDER:
CALL FUNCTION 'BAPI_MOSRVAPS_SAVETMPLPPM' DESTINATION 'NONE'
EXPORTING
logical_system = logical_system
order_type = order_type
ext_number_assignment = ext_number_assignment
commit_control = commit_control
strategy_profile = strategy_profile
planning_mode_usage = planning_mode_usage
event_control = event_control
TABLES
order_head = order_head
order_structure = order_structure
order_components = order_components
characteristics_val_io = characteristics_val_io
characteristics_val_act = characteristics_val_act
order_modes = order_modes
mapping_data = mapping_data
return = return
extension_in = extension_in
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc NE 0.
DATA ls_ret TYPE bapiret2.
MOVE sy-msgid TO ls_ret-id.
MOVE sy-msgno TO ls_ret-number.
MOVE sy-msgty TO ls_ret-type.
MOVE sy-msgv1 TO ls_ret-message_v1.
MOVE sy-msgv2 TO ls_ret-message_v2.
MOVE sy-msgv3 TO ls_ret-message_v3.
MOVE sy-msgv4 TO ls_ret-message_v4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno INTO ls_ret-message
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
APPEND ls_ret TO return.
ENDIF.
cv_complete = abap_true.
Let me know if this helps you in any case. We have implemented it and it works well. I can try to help if you need further help 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
9 | |
9 | |
8 | |
8 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.