Open manuelroemer opened 1 year ago
Customer API implementation:
METHOD customerset_get_entityset.
DATA(filter) = io_tech_request_context->get_osql_where_clause( ).
SELECT *
FROM z00t1_customer
WHERE (filter)
ORDER BY name ASCENDING
INTO CORRESPONDING FIELDS OF TABLE @et_entityset.
ENDMETHOD.
METHOD customerset_get_entity.
DATA(id) = get_key( it_key_tab = it_key_tab key = 'Id' ).
SELECT SINGLE *
FROM z00t1_customer
WHERE id = @id
INTO @er_entity.
ENDMETHOD.
METHOD customerset_create_entity.
io_data_provider->read_entry_data( IMPORTING es_data = er_entity ).
GET TIME STAMP FIELD DATA(now).
er_entity-mandt = sy-mandt.
er_entity-id = cl_system_uuid=>create_uuid_c36_static( ).
er_entity-createdat = now.
er_entity-updatedat = now.
INSERT z00t1_customer FROM er_entity.
ENDMETHOD.
METHOD customerset_update_entity.
io_data_provider->read_entry_data( IMPORTING es_data = er_entity ).
DATA(id) = get_key( it_key_tab = it_key_tab key = 'Id' ).
GET TIME STAMP FIELD DATA(now).
UPDATE z00t1_customer
SET name = @er_entity-name,
customercode = @er_entity-customercode,
updatedat = @now
WHERE id = @id.
ENDMETHOD.
METHOD customerset_delete_entity.
DATA(id) = get_key( it_key_tab = it_key_tab key = 'Id' ).
DELETE FROM z00t1_customer WHERE id = @id.
DELETE FROM z00t1_fschemares WHERE customerid = @id.
ENDMETHOD.
METHOD verify_customer_exists.
SELECT COUNT( * )
FROM z00t1_customer
WHERE id = @id
INTO @DATA(count).
IF count = 0.
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
message = |The customer with the ID { id } does not exist.|
http_status_code = 404.
ENDIF.
ENDMETHOD.
Postman:
Description
As a user, I want to be able to associate a filled out questionnaire with a customer. For this sake, I need the system to manage customer data for me.
This requires the creation of a new OData entity called
Customer
with the following attributes:Id: string
- a GUIDName: string
- the customer's display nameCustomerCode: string
- an internal code number assigned to the customerCreatedAt: string
- the creation dateUpdatedAt: string
- the last modified dateThe OData service should offer the following endpoints:
GET /CustomerSet
GET /CustomerSet('id')
POST /CustomerSet
PATCH /CustomerSet('id')
DELETE /CustomerSet('id')
Acceptance Criteria
FormSchemaResult
has a newcustomerId
foreign key. This is also returned by the API.customerId
of aFormSchemaResult
, the API throws a 404 exception/error when no customer with the given ID existsapi
folder is updated to the new customer API:CustomerEntity.ts
with OData API wrappers existscustomerId
attribute of theFormSchemaResultEntity
has been added to the interface(s)Additional Information
None.