0

I am using VDM to query a function import. It returns null, which is not expected. It does not go to exception flow, so not able to figure out whether the call was a success or not.

    PurchaseRequisitionHeaderBOView resultPojo = null;
    try {
        resultPojo = sspprService.purchaserequisition_WdActivation(purchaseRequisition, draftUUID, isActiveEntity)
                .execute(new ErpConfigContext(s4destination));
        if (resultPojo == null)
            logger.error("VDM call returned null!");
    } catch (ODataException e) {
        logger.error(EXCEPTION_ACTIVATING_CART, e);
        throw new org.apache.olingo.odata2.api.exception.ODataException(EXCEPTION_ACTIVATING_CART, e);
    }

Expected:If call was a success a non-null POJO. If call failed it should hit the catch block.

Response of the function import

{
  "d" : {
    "__metadata" : {
      "id" : "https://uyt700-er9003.wdf.sap.corp/sap/opu/odata/sap/MMPUR_REQ_GPR_MAINTAIN_SRV/I_Purchaserequisition_Wd(PurchaseRequisition='12444947',DraftUUID=guid'00000000-0000-0000-0000-000000000000',IsActiveEntity=true)",
      "uri" : "https://uyt700-er9003.wdf.sap.corp/sap/opu/odata/sap/MMPUR_REQ_GPR_MAINTAIN_SRV/I_Purchaserequisition_Wd(PurchaseRequisition='12444947',DraftUUID=guid'00000000-0000-0000-0000-000000000000',IsActiveEntity=true)",
      "type" : "MMPUR_REQ_GPR_MAINTAIN_SRV.I_Purchaserequisition_WdType",
      "etag" : "W/\"20190920072451.9970020m\""
    },
    "Activation_ac" : false,
    "Edit_ac" : true,
    "Preparation_ac" : false,
    "Validation_ac" : false,
    "PurReqnDescription_fc" : 3,
    "PurReqnSSPRequestor_fc" : 3,
    "PurchaseRequisition" : "12444947",
    "PurReqnSSPRequestor" : "00001076",
    "PurReqnSSPAuthor" : "CSAC",
    "PurchaseRequisitionType" : "NB",
    "CreationDate" : "\/Date(1568937600000)\/",
    "LastChangeDateTime" : "20190920072451.9970020",
    "IsOnBehalfCart" : "",
    "BusinessUser" : "CSAC",
    "PurReqnIsCreatedInExpertMode" : false,
    "PurReqnDescription" : "",
    "EmployeeFullName" : "Don Draper",
    "PurReqnOrigin" : "S",
    "IsSrchEnabled" : false,
    "PurReqnLifeCycleStatus" : "",
    "PurReqnLifeCycleStatusName" : "",
    "NumberOfItems" : 0,
    "TotalNetAmount" : "0.00",
    "Currency" : "",
    "IsExtPurgScenario" : false,
    "PurReqnIsCopyDraft" : false,
    "HasDraftEntity" : false,
    "DraftUUID" : "00000000-0000-0000-0000-000000000000",
    "DraftEntityCreationDateTime" : null,
    "DraftEntityLastChangeDateTime" : null,
    "HasActiveEntity" : false,
    "IsActiveEntity" : true,
    "DraftAdministrativeData" : {
      "__deferred" : {
        "uri" : "https://uyt700-er9003.wdf.sap.corp/sap/opu/odata/sap/MMPUR_REQ_GPR_MAINTAIN_SRV/I_Purchaserequisition_Wd(PurchaseRequisition='12444947',DraftUUID=guid'00000000-0000-0000-0000-000000000000',IsActiveEntity=true)/DraftAdministrativeData"
      }
    },
    "SiblingEntity" : {
      "__deferred" : {
        "uri" : "https://uyt700-er9003.wdf.sap.corp/sap/opu/odata/sap/MMPUR_REQ_GPR_MAINTAIN_SRV/I_Purchaserequisition_Wd(PurchaseRequisition='12444947',DraftUUID=guid'00000000-0000-0000-0000-000000000000',IsActiveEntity=true)/SiblingEntity"
      }
    }
  }
}
Sachin C Nambiar
  • 135
  • 2
  • 11
  • As there are function imports that actually return `null` or nothing in a success case we cannot genericly throw an exception on a `null` return value. Can you maybe check what the actual endpoint responds to the request the vdm is making? – Christoph Schubert Jul 18 '19 at 09:27
  • You can build your own request with the following format: `//?=...$format=json`. You can find the `` in the service interface and the `` as well as the ``s in the implementation of the function import. – Christoph Schubert Jul 18 '19 at 09:31
  • Hi Christoph, I accessed the function import through POSTMAN. And it works in some cases. (If the parameter value points to an existing shopping cart). And if the parameter is wrong, it throws an exception. – Sachin C Nambiar Jul 19 '19 at 07:46
  • In the success case, we get an entity back. (In postman). But when we call using VDM, Success or failure, I get null as value back and no exception traces of any sort in the logs as well. – Sachin C Nambiar Jul 19 '19 at 07:47
  • @Sachin can you please extend your question with the _(simplified)_ JSON response you receive with POSTMAN when calling the function import? We are especially interested in the response structure. The Cloud SDK expects the entity being in `{ 'd' : { 'THE_FUNCTION_IMPORT_NAME' : { /* entity */ } } }`. I assume this expectation is not fitting in your case. – Alexander Dümont Jul 22 '19 at 10:01
  • Please attach (a sample of) the POJO `PurchaseRequisitionHeaderBOView` with at least two properties. It's likely that an annotation is missing on class level or property level. – Alexander Dümont Jul 22 '19 at 15:36
  • @AlexanderDümont you are right. The response does not contain the name. But as per https://www.odata.org/documentation/odata-version-2-0/json-format/ this does not seem to be what the odata v2 spec says. – Sachin C Nambiar Sep 20 '19 at 07:31
  • @AlexanderDümont strange thing is we also call another function import, this function import returns in the structure that CSDK expects and thus works. – Sachin C Nambiar Sep 20 '19 at 07:34
  • @SachinCNambiar: Has your other function import call only a primitive type as a return value? – Christoph Schubert Sep 20 '19 at 13:42
  • @ChristophSchubert the function import that returns the name in the response - returns complex type. – Sachin C Nambiar Sep 20 '19 at 14:19
  • @SachinCNambiar This naming convention of having the function name as additional wrapper object in the JSON response arose from the implicit default behavior of all OData services that we have encountered in _SAP API Business Hub_. Currently it's only possible to take an alternative identifier, different from the function name itself, by overriding `FluentHelperFunction#getJsonResponseObjectName()`. But it's not possible to drop the wrapper object at all. For the future, would you agree to adding _"customizable parsing of function-import-responses"_ as feature request to the _SAP Cloud SDK_? – Alexander Dümont Sep 25 '19 at 17:32

1 Answers1

0

Please update your dependency of SAP Cloud SDK to 3.6.0 as it fixes the issue of parsing OData function import responses. A customization is no longer required. Please let me know, if it works for you.

Alexander Dümont
  • 903
  • 1
  • 5
  • 9