cancel
Showing results for 
Search instead for 
Did you mean: 

Odata V4 Action Parameter Ommitting is not supported

UxKjaer
Product and Topic Expert
Product and Topic Expert
0 Kudos

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').

Accepted Solutions (0)

Answers (3)

Answers (3)

bernhard_grusie
Product and Topic Expert
Product and Topic Expert

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

ravi_rajput
Participant
0 Kudos

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.

ravi_rajput
Participant
0 Kudos

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 ?

ravi_rajput
Participant
0 Kudos

The error is coming from this piece of code.