Skip to Content

Modify field after validation

In BYD , we have a problem that after a field validation, the user can’t edit the value to correct the problem.

We created an extension field via adaption mode. In PDI, we added a check on event-BeforeSave on this field. In Validation-OnSave, we trigger our error. When the user processes the inbound delivery and leaves a field empty based on a condition, error messages is triggered as expected. However, the user can’t correct the mistake that he made. We always endup with error: Technical error AP_ESI_COMMON 107. The error is triggered because technically, the system tries to edit in ‘read only’ mode. How can we correct a value after a check that we build via the Validation-OnSave?

We also tried to put all logic in the Validation-OnSave but without success.

Event-BeforeSave

import ABSL;

import AP.LogisticsExecution.Global;

// get header in order get customs ID

var customID = "";

var header = this.GetFirst();

if (header.IsSet()) {

customID = header.CustomsID;

header.douaneIdValid = true;

}

// get location

if (!header.ShipToLocation.IsSet()){

return;

}

// get location business partner

var location = header.ShipToLocation.Location;

if (location.ID.content.IsInitial()){

return;

}

// if business partner = E1000 and no douaneID, set error

if (location.ID.content == "E1000") {

if (customID == "") {

header.douaneIdValid = false;

raise Message_DouaneID_Missing.Create("E");

}

}

Validation-OnSave

import ABSL;

import AP.LogisticsExecution.Global;

// get header

var header = this.GetFirst();

if (header.IsSet()) {

return header.douaneIdValid;

} else {

return true;

}

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 28, 2018 at 02:33 PM

    Hi Jimmy,

    The BeforeSave action is intended to allow developers to adjust values or do whatever desired except validations. The correct place where to enter validations is the Validation-OnSave. On this method you will return True/False which will determine whether the save is allowed or not.

    My suggestion would be to adjust your code in order to movev all the checks into the Validation-OnSave.

    Hope this helps you.

    Cheers.

    Alejandro.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Alejandro

      We tried with the following code on Validation-OnSave. We still get the error message AP_ESI_COMMON 107. This error is displayed when user tries to correct the error.

      import ABSL;

      import AP.LogisticsExecution.Global;

      // get header in order get customs ID

      var customID = "";

      var header = this.GetFirst();

      if (header.IsSet()) {

      customID = header.CustomsID;

      }

      // get location

      if (!header.ShipToLocation.IsSet()){

      return true;

      }

      // get location business partner

      var location = header.ShipToLocation.Location;

      if (location.ID.content.IsInitial()){

      return true;

      }

      // if business partner = E1000 and no douaneID, set error

      if (location.ID.content == "E1000") {

      if (customID == "") {

      raise Message_DouaneID_Missing.Create("E");

      return false;

      }

      }

      // look like everything is OK, so send OK to backend

      return true;

  • Nov 29, 2018 at 01:13 PM

    Hi Jimmy,

    As per my understandingn, your approach is correct.

    The mentioned error is a generic error as per what I have been reading on other threads. Why don't you raise an inncident to SAP in order to get further details about the root cause?

    Regards.

    Alejandro.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 30, 2018 at 07:09 AM

    Dear Jimmy,

    The error Technical error AP_ESI_COMMON 107 usually raised by a partner Add-on. This message is typically raised when a partner tries to modify extension elements of BOs that are set to read-only.

    In general such errors have to be fixed by the Addon- creator. The Add-on creator has to make sure to only modify extension elements when the BO is in a writable state. The information when a BO is writable has to be provided by SAP application development. This typically depends on some state elements of the BO.

    If you cannot fix this issue from your side, feel free to report an incident as Alejandro mentioned. We can debug your code and pin point the exact absl code with line number.

    Regards
    Anant

    Add comment
    10|10000 characters needed characters exceeded

    • Dear Anant,

      Is it possible that after onSave validation the extension fields are not put back in write mode?

      So this extension field I made is in write modus before the validation.

      Just before the onSave validation, BYD set this extension field to read only.

      I return false via my validation script, but then BYD set all necessary fields back to write mode except our own created extension field?

      I look forward to your response

      Best Regards,

      Jimmy