on 01-13-2021 3:11 AM
Hello experts.
I'm currently doing a V4 Odata service with a code base implementation. I'm not using CDS views.
I've gone through the blogs of andre.fischer which has really helped me getting started. However I'm currently stuck on actions and functions. As far as I can see when I develop the service, if I do a function Import it will automattically distinguish as a GET request, where action is a POST. In my usecase I need a post.
I've created an action import called delete data where I'm setting a category as a parameter. When I try to call that action import I get an error message back
"error": {"code": "/IWBEP/CM_V4S_RUN/025","message": "Parameter 'Category' is missing; Omitting is not supported",
When I debug I can see that it fails on this piece of code.
But I can't see what this "provided" refers to.
Below is my ABAP code for the action import.
lo_action = io_model->create_action(/s4as/if_cost_center_types=>gcs_function_names-delete_data ).
lo_action->set_edm_name('FuDeleteData').
**"Function Parameters
lo_parameter = lo_action->create_parameter('CATEGORY').
lo_parameter->set_edm_name('Category').
lo_parameter->set_primitive_type('CATEGORY').
** "Function Return
lo_return = lo_action->create_return().
lo_return->set_primitive_type('STRING_MESSAGE').
** "Function Import
lo_action_import = lo_action->create_action_import(/s4as/if_cost_center_types=>gcs_function_import_names-delete_data ).
lo_action_import->set_edm_name('DeleteData').
This feature is available with SAP ABAP platform 2021.
Is is also available in lower ABAP platform releases down to SAP NetWeaver 7.52, see SAP Note: 2512479-SAP Gateway Foundation Support Package Stack Definition
Because this would be incompatible, you have to enable this via a service feature. Example in
/iwbep/cl_v4_tea_tech_model_03->/iwbep/if_v4_mp_basic~define()
...
io_model->set_service_features( VALUE #( use_vc_to_flag_omitted_data = abap_true ) ).
In addition you need a so-called Value Control Field. This is an additional property that is filled with /iwbep/if_v4_runtime_types=>gcs_value_control-indicate_omit at runtime if the parameter was omitted.
MPC definition for a Value Control Field, example:
/iwbep/cl_v4_tea_tech_model_02->define_action_inputs()
...
lo_action_parameter = lo_action->create_parameter( /iwbep/if_v4_tea_tech_types_02=>gcs_operation_parameter_names-internal-prim_parameter ).
lo_action_parameter->set_primitive_type( /iwbep/if_v4_tea_tech_types_02=>gcs_primitive_type_names-action_primitive_type ).
lo_action_parameter->set_is_nullable( ).
lo_action_parameter->set_value_control_field( 'PRIM_PARAMETER_VC' ).
DPC example:
/iwbep/cl_v4_tea_tech_data_02->act_single_input()
...
IF ls_parameter_data-prim_parameter_vc = /iwbep/if_v4_runtime_types=>gcs_value_control-indicate_omit.
ls_parameter_data-prim_parameter = 666.
ELSEIF ls_parameter_data-prim_parameter_vc = /iwbep/if_v4_runtime_types=>gcs_value_control-indicate_null.
ls_parameter_data-prim_parameter = 600.
ENDIF.
Best regards
Bernhard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Odata API when integrated with SAC was working fine when they are calling the function import. But i could not test it from SAP gateway or Postman.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Jakob,
I am also getting the same parameter is missing error while doing a function import post call. Did you manage to resolve it by any chance ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
65 | |
8 | |
7 | |
7 | |
6 | |
5 | |
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.