Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
A few days ago sdfraga asked how to use the Function Import Parameter Length Check that is available in SAP_GWFND 752 and higher in a lower release Question to conversion blog post.

Since there are currently no plans to downport the feature to 750 sdfraga plans to post his implementation as a blog post.

The above mentioned feature is a so called model feature. Model features can be set for the OData model of an SEGW based SAP Gateway service and they can influence the behavior of your OData Service.

The first tricky thing is to find that parameter since it is actually named USE_STRICT_FUNCTION_PARAM_CHK due to the restrictions in ABAP to use that long object names. (we will fix this typo in the documenation ;-))

When the model feature USE_STRICT_FUNCTION_PARAM_CHK is being enabled for the model of an OData service in the model provider extension class the SAP Gateway framework will check whether the length of a parameter exceeds the max-length used when defining the parameter.

So when you define a max-length for function import parameter as 10 in SEGW and when you execute the function import URI request with parameter value greater than 10 it will result in error.

How can this feature be enabled?


Model features are being enabled in the DEFINE method of your model provider extension class. To get a quick result I decided to redefine the sample service /IWBWEP/GWSAMPLE_BASIC.


 

Here I redefined the DEFINE( ) method of the model provider extension class and added the following coding.
  METHOD define.
super->define( ).
DATA model_feature TYPE /iwbep/if_mgw_appl_types=>ty_s_model_features.
model_feature-use_strict_function_param_chk = abap_true.
model->set_model_features( model_feature ).
ENDMETHOD.

When checking the type /iwbep/if_mgw_appl_types=>ty_s_model_features you can find other model features as well.

You can test this behavior in the SAP Gateway client (transaction /n/iwfnd/gw_client).

Using the uri and choosing the http method POST
/sap/opu/odata/SAP/Z_REDEF_GWSAMPLE_SRV/SalesOrder_Confirm?SalesOrderID='0500000000_too_long'

fails with the error message Malformed URI literal syntax.
{
"error" : {
"code" : "005056A509B11EE1B9A8DBD9EA7BB778",
"message" : {
"lang" : "de",
"value" : "Malformed URI literal syntax"
},
"innererror" : {
"transactionid" : "2CC63F1F947000D0E005F9B1B27A30E8",
"timestamp" : "20201103074652.3120690",
"Error_Resolution" : {
"SAP_Transaction" : "For backend administrators: use ADT feed reader \"SAP Gateway Error Log\" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details",
"SAP_Note" : "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"
}
}
}
}

Whereas using the following uri
/sap/opu/odata/SAP/Z_REDEF_GWSAMPLE_SRV/SalesOrder_Confirm?SalesOrderID='0500000012'&$format=json

works (provided that your sales order in the EPM demo data has the status 'N') and you get the following response:
{
"d" : {
"__metadata" : {
"id" : "https://hostname:port/sap/opu/odata/SAP/Z_REDEF_GWSAMPLE_SRV/SalesOrderSet('0500000012')",
"uri" : "https://hostname:port/sap/opu/odata/SAP/Z_REDEF_GWSAMPLE_SRV/SalesOrderSet('0500000012')",
"type" : "GWSAMPLE_BASIC.SalesOrder"
},
"SalesOrderID" : "0500000012",
"Note" : "EPM DG: SO ID 0500000012 Deliver as fast as possible",
"NoteLanguage" : "EN",
"CustomerID" : "0100000005",
"CustomerName" : "TECUM",
"CurrencyCode" : "EUR",
"GrossAmount" : "24704.40",
"NetAmount" : "20760.00",
"TaxAmount" : "3944.40",
"LifecycleStatus" : "P",
"LifecycleStatusDescription" : "In Bearbeitung",
"BillingStatus" : "",
"BillingStatusDescription" : "Initial",
"DeliveryStatus" : "",
"DeliveryStatusDescription" : "Initial",
"CreatedAt" : "\/Date(1593122400000)\/",
"ChangedAt" : "\/Date(1604389733043)\/",
"ToBusinessPartner" : {
"__deferred" : {
"uri" : "https://hostname:port/sap/opu/odata/SAP/Z_REDEF_GWSAMPLE_SRV/SalesOrderSet('0500000012')/ToBusinessPartner"
}
},
"ToLineItems" : {
"__deferred" : {
"uri" : "https://hostname:port/sap/opu/odata/SAP/Z_REDEF_GWSAMPLE_SRV/SalesOrderSet('0500000012')/ToLineItems"
}
}
}
}

 

 

 

 
4 Comments