{
"transmittedMaterialData": [
{
"transmittedProduct": "TG80%%01",
"transmittedCustomerMaterial": "8001"
}
],
"referenceMaterialData": [
{
"delivery": "D01",
"soldToParty": "S01",
"referenceProduct": "TG8001",
"referenceCustomerMaterial": "80--01"
}
]
}
[
{
"delivery": "D01",
"soldToParty": "S01",
"transmittedProduct": "TG80%%01",
"transmittedCustomerMaterialNumber": "8001",
"referenceProduct": "TG8001",
"referenceCustomerMaterialNumber": "80--01"
}
]
METHOD if_rest_application~get_root_handler.
io_router->attach(
EXPORTING
iv_template = '/sbcMaterialMapping' " Unified Name for Resources
iv_handler_class = 'ZCL_SBC_MATERIAL_MAP_PROVIDER' " Object Type Name
).
ro_root_handler = io_router.
ENDMETHOD.
method IF_REST_RESOURCE~POST.
DATA(lo_entity) = mo_request->get_entity( ).
DATA(lv_data) = lo_entity->get_string_data( ).
DATA : ls_sbcreq TYPE ZMATERIALMAPPINGAPIREQUEST.
DATA : ls_json TYPE string.
DATA resp TYPE ZMATERIALMAPPINGAPIRESPONSE.
/ui2/cl_json=>deserialize(
EXPORTING
json = lv_data " JSON string
CHANGING
data = ls_sbcreq " Data to serialize
).
LOOP AT ls_sbcreq-transmittedMaterialData ASSIGNING FIELD-SYMBOL(<tran>).
DATA : tranProduct TYPE string.
DATA : tranCustomerMaterial TYPE string.
tranProduct = <tran>-transmittedProduct.
tranCustomerMaterial = <tran>-transmittedCustomerMaterial.
replace all occurrences of PCRE '[^\w]' in tranProduct with ''.
replace all occurrences of PCRE '[^\w]' in tranCustomerMaterial with ''.
LOOP AT ls_sbcreq-referenceMaterialData ASSIGNING FIELD-SYMBOL(<ref>).
DATA : refProduct TYPE string.
DATA : refCustomerMaterial TYPE string.
refProduct = <ref>-referenceProduct.
refCustomerMaterial = <ref>-referenceCustomerMaterial.
replace all occurrences of PCRE '[^\w]' in refProduct with ''.
replace all occurrences of PCRE '[^\w]' in refCustomerMaterial with ''.
IF ( tranProduct = refProduct and tranCustomerMaterial = refCustomerMaterial )
or ( tranProduct = refProduct and ( tranCustomerMaterial = '' or refCustomerMaterial = '' ) )
or ( tranCustomerMaterial = refCustomerMaterial and ( tranProduct = '' or refProduct = '' ) ).
INSERT VALUE #( TRANSMITTEDPRODUCT = <tran>-transmittedProduct
transmittedCustomerMaterial = <tran>-transmittedCustomerMaterial
delivery = <ref>-delivery
soldToParty = <ref>-soldToParty
referenceProduct = <ref>-referenceProduct
referenceCustomerMaterial = <ref>-referenceCustomerMaterial
) INTO TABLE resp-MAPPEDMATERIALS.
ENDIF.
ENDLOOP.
ENDLOOP.
/ui2/cl_json=>serialize(
EXPORTING
data = resp " Data to serialize
RECEIVING
r_json = ls_json " JSON string
).
mo_response->create_entity( )->set_string_data( iv_data = ls_json ).
endmethod.
{
"transmittedMaterialData": [
{
"transmittedProduct": "",
"transmittedCustomerMaterial": "TG80 03"
},
{
"transmittedProduct": "TG80%%05",
"transmittedCustomerMaterial": "8005"
}
],
"referenceMaterialData": [
{
"delivery": "80002264",
"soldToParty": "24100001",
"referenceProduct": "TG8003",
"referenceCustomerMaterial": "TG80**03"
},
{
"delivery": "80002265",
"soldToParty": "24100001",
"referenceProduct": "TG8005",
"referenceCustomerMaterial": "80--05"
}
]
}
{
"MAPPEDMATERIALS": [
{
"TRANSMITTEDPRODUCT": "",
"TRANSMITTEDCUSTOMERMATERIAL": "TG80 03",
"DELIVERY": "80002264",
"SOLDTOPARTY": "24100001",
"REFERENCEPRODUCT": "TG8003",
"REFERENCECUSTOMERMATERIAL": "TG80**03"
},
{
"TRANSMITTEDPRODUCT": "TG80%%05",
"TRANSMITTEDCUSTOMERMATERIAL": "8005",
"DELIVERY": "80002265",
"SOLDTOPARTY": "24100001",
"REFERENCEPRODUCT": "TG8005",
"REFERENCECUSTOMERMATERIAL": "80--05"
}
]
}
Create the destination on SAP BTP.
Log on to the SAP BTP Cockpit (Cloud Foundry environment) with your registered subaccount.
Choose Connectivity Destination New Destination to create a new destination for aligning transmission data.
For self-billing with automatic posting:
Destination Property | Value |
---|---|
Name | SELFB_DEST_SBWAP_MATERIAL_MAPPING |
Type | HTTP |
Description | Destination for product mapping extensions for self-billing with automatic posting |
URL | <The URL path of the RESTful API created in the previous step> |
Proxy Type |
|
Authentication | Basic Authentication |
User | <User with the authorization of the RESTful API created in the previous step) |
Password | <Password of the user> |
Destination Property | Value |
---|---|
Name | SELFB_DEST_SBINV_MATERIAL_MAPPING |
Type | HTTP |
Description | Destination for product mapping extensions for self-billing with invoice creation |
URL | <The URL path of the RESTful API created in the previous step> |
Proxy Type |
|
Authentication | Basic Authentication |
User | <User with the authorization of the RESTful API created in the previous step> |
Password | <Password of the user> |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 |