- In this post will show you Create Query in OData.
- For creating query Kinldy follow all the step's till 9 from this link and process further step's.
- Step 10: Expand the Service Implementation, Select the Required Entity Set as “SalesHeaderSet”, Expand the Entity Set “GetEntitySet (Query) as show in Below
- Step 11: Right click on “GetEntitySet (Query) and select the “Got to ABAP Workbench”
- Step 14: Implement logic inside the Method
- Step 15: Output:
- Method Code:
METHOD salesheaderset_get_entity.
DATA: ls_key_val TYPE zcl_zodata_project_mpc=>ts_salesheader. "Refer to Type "ER_ENTITY
"Read Key value (IT_KEY_TAb - is obsolete now, below method convert the value to internal ex. adding leadinf zero etc.
io_tech_request_context->get_converted_keys(
IMPORTING es_key_values = ls_key_val ).
IF ls_key_val-salesorder IS NOT INITIAL.
SELECT
SINGLE FROM zms_sales_head
FIELDS vbeln AS SalesOrder,
audat AS DocumentDate,
audat AS OrderType,
vkorg AS SalesOrganization,
vtweg AS DistributionChannel,
spart AS Division
WHERE vbeln EQ @ls_key_val-salesorder
INTO @DATA(zls_sales_head).
IF sy-subrc EQ 0.
er_entity = CORRESPONDING #( zls_sales_head ).
ENDIF.
ENDIF.
ENDMETHOD.
- Query: /sap/SalesHeaderSet?filter=(SalesOrder eq '1200001025')&$filter=json
No comments:
Post a Comment