on 12-17-2021 10:02 PM
I am developing a simple RAP service using BTP ABAP trial environment.
I have implemented a validation with the following code.
This BO is managed, draft-enabled, and the validation is triggered at the point of save.
validation mandatory_check on save {create; update; field FirstName, LastName; }
METHOD mandatory_check.
"Get Mandatory Fields
READ ENTITIES OF zi_person_m IN LOCAL MODE
ENTITY Person
FIELDS ( FirstName LastName )
WITH CORRESPONDING #( keys )
RESULT DATA(persons).
"Do check
LOOP AT persons INTO DATA(person).
APPEND VALUE #( %tky = person-%tky
%state_area = 'mandatory_check')
TO reported-person.
IF person-FirstName IS INITIAL.
"Set failed keys
APPEND VALUE #( %tky = person-%tky )
TO failed-person.
"Set message
APPEND VALUE #( %tky = person-%tky
%element-FirstName = if_abap_behv=>mk-on
%state_area = 'mandatory_check'
%msg = new_message(
id = 'ZRAP_MSG_YASU2122_2'
number = 001
severity = if_abap_behv_message=>severity-error
v1 = 'First Name'
) )
TO reported-person.
ENDIF.
ENDLOOP.
ENDMETHOD.<br>
However, specifying %state_area = 'mandatory_check' causes the app to throw error. The following screen appears after the validation gets triggered.
Below code (without %state_area)works fine.
"Do check
LOOP AT persons INTO DATA(person).
IF person-FirstName IS INITIAL.
"Set failed keys
APPEND VALUE #( %tky = person-%tky )
TO failed-person.
"Set message
APPEND VALUE #( %tky = person-%tky
%element-FirstName = if_abap_behv=>mk-on
%msg = new_message(
id = 'ZRAP_MSG_YASU2122_2'
number = 001
severity = if_abap_behv_message=>severity-error
v1 = 'First Name'
) )
TO reported-person.
ENDIF.
ENDLOOP.<br>
According to the doc, state message can be used for validation on save in Managed Scenario.
Business Object with Draft Capabilities: Determinations and Validation that are allocated to the PREPARE or a determine action
Unmanaged Business Object: Finalize/Check Before Save Code Exit
Managed Scenario: Determinations/Validation on Save
Do you have any idea what is causing this error? Should I use state message for my scenario or not?
Best regards,
Mio
Hi Mio,
Perhaps this link will explane the problem to you. (This is a known backend problem that will be fixed with the upcoming release.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I'm on a 2021 SP2 system and couldn't find on the link mentioned above which release had or solved the issue. Please, are you aware if by any chance this error also affects messages on child entities in any way?
I have a validation running on save for Child entity, which is a list item within my object page, and I'm unable to properly highlight a field as you can see on the following print - the row is marked as unknown.
I checked this over and over but couldn't figure out what is missing. Shouldn't the following set of parameters be enough to provide a message with a highlight? I'm also feeding %tky to failed-child.
reported-child=
VALUE #(
BASE reported-child(
%tky = ls_child-%tky
%path = VALUE #(
root-%is_draft = ls_child-%is_draft
root-%key-RootUUID = ls_child-RootUUID
)
%msg = new_message(
id = 'ZTEST_MSG'
number = '018'
severity = if_abap_behv_message=>severity-error
)
%element-%field-allocatedquantity = if_abap_behv=>mk-on
"%state_area = 'qty_not_null'
"%element-%assoc-_root = if_abap_behv=>mk-on
)
).
"OData response
{
"error": {
"code": "ZTEST_MSG/018",
"message": "Allocated Quantity must be informed.",
"target": "$Parameter/_it/_Child(ChildUUID=000d3a17-2339-1eed-ae8d-a23793571f23,IsActiveEntity=true)/AllocatedQuantity",
"@SAP__common.ExceptionCategory": "Provider_Application_Error",
"innererror": {
"ErrorDetails": {
"@SAP__common.Application": {
"ComponentId": "BC-ESI-ESF-GW",
"ServiceRepository": "SRVD",
"ServiceId": "ZTEST_SRV",
"ServiceVersion": "0001"
},
"@SAP__common.TransactionId": "039B658AE04600D0E0063F06F0085867",
"@SAP__common.Timestamp": "20230301220915.319091",
"@SAP__common.ErrorResolution": {
"Analysis": "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",
"Note": "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"
}
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
8 | |
8 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.