
METHOD precheck_update.
"Loop on Entity to get current values from UI, all updated changed values will be available in <lfs_entity>
LOOP AT entities ASSIGNING FIELD-SYMBOL(<lfs_entity>).
"Check whic values are changed by user
"01 = value is updated / changed , 00 = value is not changed
"Check if Course or CourseDuration values is changed by User
CHECK <lfs_entity>-%control-Course EQ '01' OR <lfs_entity>-%control-Courseduration EQ '01'.
"Read Entity record and collect on Internal table
READ ENTITIES OF zi_student_5000 IN LOCAL MODE
ENTITY Student
FIELDS ( Course Courseduration ) WITH VALUE #( ( %key = <lfs_entity>-%key ) )
RESULT DATA(lt_studentsCourse).
IF sy-subrc IS INITIAL.
READ TABLE lt_studentsCourse ASSIGNING FIELD-SYMBOL(<lfs_db_course>) INDEX 1.
IF sy-subrc IS INITIAL.
"Collect the updated value from Frontend. If user has updated value on Frontend then get updated value
"Else get the value from Database
<lfs_db_course>-Course = COND #( WHEN <lfs_entity>-%control-Course EQ '01' THEN
<lfs_entity>-Course ELSE <lfs_db_course>-Course
).
<lfs_db_course>-Courseduration = COND #( WHEN <lfs_entity>-%control-Courseduration EQ '01' THEN
<lfs_entity>-Courseduration ELSE <lfs_db_course>-Courseduration
).
"Business logic per requirement, We are validating Course Duration for Computers can not be less then 5 Yerars
IF <lfs_db_course>-Courseduration < 5.
IF <lfs_db_course>-Course = 'Computers'.
"Return Error Message to Frontend.
APPEND VALUE #( %tky = <lfs_entity>-%tky ) TO failed-student.
APPEND VALUE #( %tky = <lfs_entity>-%tky
%msg = new_message_with_text(
severity = if_abap_behv_message=>severity-error
text = 'Invalid Course duration...'
) ) TO reported-student.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
23 | |
19 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |