cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error During ChangeSet Offline Call

Angelo_Ab14
Participant
0 Likes
783

Hi,

from yesterday I have a problem during ChangeSet offline call.

The app return this error: "Error: Attempt to get length of null array"

In the Mobile Client Log Upload i have this:

commit change set error Params: {"serviceUrl":"https://xxxxxxxxxx.hana.ondemand.com/s4-backend-odata/sap/opu/odata/sap/ZSERVICE","offlineEnabled":true} Error: Attempt to get length of null array

The previous week I can call ChangeSet without problem.

I checked every change I made and all seems ok. I do not understand what's the problem. 

I checked all the rules and actions and all seems ok.

I checked also all the arrays in the rules with some alerts and all of them has correct length.

The error seems to come from the Framework.

Someone experienced the same issue ? Any idea ?

ChangeSet action code:

{
    "_Type": "Action.Type.ODataService.ChangeSet",
    "ActionResult": {
        "_Name": "ChangeSetCreateSalesOrder"
    },
    "OnFailure": "/somanagement/Actions/CreateSalesOrderActions/MessageErrorChangeSetCreateSalesOrder.action",
    "OnSuccess": {
        "Name": "/somanagement/Actions/GenericToastMessage.action",
        "Properties": {
            "Message": "$(L,'SalesOrderCreatedSuccess')"
        }
    },
    "Target": {
        "Service": "/somanagement/Services/ServiceV2.service"
    },
    "Actions": [
        "/somanagement/Actions/CreateSalesOrderActions/CreateSalesOrderHead.action",
        "/somanagement/Rules/CreateSalesOrder/CreateSalesOrderItems.js",
        "/somanagement/Rules/CreateSalesOrder/CreateSalesOrderTexts.js"
    ]
}

Thank you,

Angelo.

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert

When an entity like your Item entity

<EntityType Name="Item" m:HasStream="true" sap:content-version="1">

is defined as HasStream true this indicates that is is a media entity.  Media entities must have media in order to create a record in the entity set.  The properties are actually secondary to the storage of the media.

In order to create a record in a Media entity set you use CreateMedia instead of CreateEntity which is consistent with your update.

If not every Item will have media you might want to redesign your service to leave the Item entity set without the HasStream true and create a linked ItemAttachment entity set as a media entity to store the attachment when needed.

Answers (3)

Answers (3)

Angelo_Ab14
Participant
0 Likes

@bill_froelich 

Update:

after the deactivation of Media property(in SEGW) in the Entity Item I'm able to use CreateEntity action.

Seems like that when an Entity is configured to transfer a Stream you cannot use CreateEntity but you can only use a createMedia.

I do not know if this is a standard OData behavior but it seems to be the case.

Angelo_Ab14
Participant
0 Likes

@bill_froelich 

Item actually do not have any link to Head.

 

<EntityType Name="Item" m:HasStream="true" sap:content-version="1">
 <Key>
  <PropertyRef Name="OrderS"/>
  <PropertyRef Name="Posnr"/>
 </Key>
 <Property Name="Discount" Type="Edm.Decimal" Nullable="false" Precision="3" Scale="1" sap:unicode="false" sap:label="Cliente" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="OrderS" Type="Edm.String" Nullable="false" MaxLength="10" sap:unicode="false" sap:label="Doc. commerc." sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
 <Property Name="Posnr" Type="Edm.String" Nullable="false" MaxLength="6" sap:unicode="false" sap:label="Posizione" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="Matnr" Type="Edm.String" Nullable="false" MaxLength="40" sap:unicode="false" sap:label="Materiale" sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
 <Property Name="EAN" Type="Edm.String" Nullable="false" MaxLength="18" sap:unicode="false" sap:label="Cd. EAN/UPC" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="CustMaterial" Type="Edm.String" Nullable="false" MaxLength="35" sap:unicode="false" sap:label="Mat. cliente" sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
 <Property Name="ShipTo" Type="Edm.String" Nullable="false" MaxLength="10" sap:unicode="false" sap:label="Cliente" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="Qty" Type="Edm.Decimal" Nullable="false" Precision="13" Scale="13" sap:unicode="false" sap:unit="UM" sap:label="Qtà prevista" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="UM" Type="Edm.String" Nullable="false" MaxLength="3" sap:unicode="false" sap:label="Unità mis. base" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" sap:semantics="unit-of-measure"/>
 <Property Name="DataCons" Type="Edm.DateTime" Precision="0" sap:unicode="false" sap:label="Data" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="Tester" Type="Edm.String" Nullable="false" MaxLength="1" sap:unicode="false" sap:label="Casella di spunta" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="Value" Type="Edm.String" Nullable="false" MaxLength="500" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="Url" Type="Edm.String" Nullable="false" MaxLength="500" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="Storage" Type="Edm.String" Nullable="false" MaxLength="4" sap:unicode="false" sap:label="Magazzino" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="TypePos" Type="Edm.String" Nullable="false" MaxLength="4" sap:unicode="false" sap:label="Cat. pos." sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
 <Property Name="Plant" Type="Edm.String" Nullable="false" MaxLength="4" sap:unicode="false" sap:label="Divisione" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
 <Property Name="DescriptionMat" Type="Edm.String" Nullable="false" MaxLength="40" sap:unicode="false" sap:label="Descrizione" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
</EntityType>

<EntitySet Name="ItemSet" EntityType="ZXXXXXSRV.Item" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:pageable="false" sap:addressable="false" sap:content-version="1"/>

 

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes

Without the full app it is hard to guess what might be the issue.  If it was working previously I would also check the offline store to make sure it is initialized correctly.  Could something have changed on the backend?

Are you doing any reads in before create/update?

You mentioned checking all your array references which would be my next suggestion as well.

Angelo_Ab14
Participant
0 Likes

Hi Bill,

after some research I found some clues.

Premise:

  • The Service have the Entity Item. This Entity is Stream Enabled.
  • Before not working scenario, the Item Entity do not was Stream Enabled.

I tried to switch the service completely Online and the error changed in: 

"Error: Stream link for createMedia call in change set is missing inline data for entity type: Item"

In the ChangeSet call I do not have any createMedia request but I have sequentially this calls:

  • CreateEntity(Head)
  • CreateEntity(Texts)
  • CreateEntity(Item)

Angelo_Ab_0-1725485372583.png

Based on Error message, why I need to set a createMedia call for Item Entity if I do not need to send a stream ?

The purpose of Stream in Item Entity is a separate functionality that manage an Excel file but, in the ChangeSet call I need only to send normal data to backend for Sales Order creation.

The problem seems linked to the Item creation.

This is the rule:

import ItemsHandler from "./ItemsHandler";
/**
 * Describe this function...
 * @Param {IClientAPI} clientAPI
 */
export default async function CreateSalesOrderItems(clientAPI) {
  //get page proxy
  let pageProxy = clientAPI.getPageProxy();
 
  //get items
  let items = ItemsHandler.getItems();
  for (var i = 0; i < items.length; i++){
    pageProxy.setActionBinding(items[i]);
    await clientAPI.executeAction("/somanagement/Actions/CreateSalesOrderActions/CreateSalesOrderItems.action");
  }
  return Promise.resolve();
}
 
and this is the Action:
 
{
    "_Type": "Action.Type.ODataService.CreateEntity",
    "ActionResult": {
        "_Name": "CreateSalesOrderItems"
    },
    "Target": {
        "Service": "/somanagement/Services/ServiceV2.service",
        "EntitySet": "ItemSet"
    },
    "Properties": {
        "Discount": "{Discount}",
        "OrderS": "{OrderS}",
        "Posnr": "{Posnr}",
        "Matnr": "{Matnr}",
        "EAN": "{EAN}",
        "CustMaterial": "{CustMaterial}",
        "ShipTo": "{ShipTo}",
        "Qty": "{Qty}",
        "UM": "{UM}",
        "DataCons": "{DataCons}",
        "Tester": "{Tester}",
        "Value": "{Value}",
        "Url": "{Url}",
        "Storage": "{Storage}",
        "TypePos": "{TypePos}",
        "Plant": "{Plant}",
        "DescriptionMat": "{DescriptionMat}"
    },
    "RequestOptions": {
        "RemoveCreatedEntityAfterUpload": true
    }
}

What am I missing ?

Thank you,

Angelo.

 

 

 

 

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes
Can you share the $metadata for the entity set? Typically I would expect this to be creating related entities or include links between the items and header.