I am trying to validate multiple records in Fiori List Object page application. Validation is needed when user tries to update status for multiple records in List control at once through Action button.
I want to update Status column with Yes with condition Age Column (value > 25) and show warning messages for remaining 2 records (Age = 23 and 20). Please refer below screen for reference.
Below is current code.
METHOD statusUpdate. //Reading Entity READ ENTITIES OF zrap_i_student_5001 IN LOCAL MODE ENTITY Student ALL FIELDS WITH CORRESPONDING #( keys ) RESULT DATA(students) FAILED failed. SORT students BY Status DESCENDING. // Filling Invalid records to failed-student
LOOP AT students ASSIGNING FIELD-SYMBOL(<lfs_students>). IF <lfs_students>-Age < 25. APPEND VALUE #( %tky = <lfs_students>-%tky ) TO failed-student. ELSE. <lfs_students>-Status = abap_true. ENDIF. ENDLOOP. // If we get any Invalid records per condition. sending those to reported-student IF failed-student IS NOT INITIAL. LOOP AT failed-student ASSIGNING FIELD-SYMBOL(<lfs_error_rec>). APPEND VALUE #( %tky = <lfs_error_rec>-%tky %msg = new_message_with_text( severity = if_abap_behv_message=>severity-warning text = <lfs_students>-Firstname && ' has Age less then 25, status not Updated ' ) ) TO reported-student. ENDLOOP. ENDIF. // Delete Invalid records SORT students by Status DESCENDING. DELETE students WHERE Status is INITIAL. // Finally Modify the remaining Valid records MODIFY ENTITIES OF zrap_i_student_5001 IN LOCAL MODE ENTITY Student UPDATE FIELDS ( Status ) WITH CORRESPONDING #( students )/ ENDMETHOD.
Below errors are getting displayed correctly (Ignore the q, its just value is not updated)
but Once I click on Close I am seeing below error message and correct record is not getting updated...