2 weeks ago
I have a single determination in my behavior definition as follows,
determination setCountryCode on save { field Country; create; update; }
following is the implementation in behavior pool,
CLASS lhc_ZI_INVESTOR DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.
METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION
IMPORTING REQUEST requested_authorizations FOR zi_investor RESULT result.
METHODS setcountrycode FOR DETERMINE ON save
IMPORTING keys FOR zi_investor~setcountrycode.
ENDCLASS.
CLASS lhc_ZI_INVESTOR IMPLEMENTATION.
METHOD setCountryCode.
READ ENTITIES OF zi_investor IN LOCAL MODE
ENTITY zi_investor
FIELDS ( Country Mobile )
WITH CORRESPONDING #( keys )
RESULT DATA(lt_mobile).
IF lt_mobile IS NOT INITIAL.
LOOP AT lt_mobile ASSIGNING FIELD-SYMBOL(<fs_mobile>).
IF <fs_mobile>-Country = 'India'.
<fs_mobile>-Mobile = |+91 | & |{ <fs_mobile>-Mobile }|.
ENDIF.
ENDLOOP.
ENDIF.
MODIFY ENTITIES OF zi_investor IN LOCAL MODE
ENTITY zi_investor
UPDATE FIELDS ( Mobile )
WITH VALUE #( FOR item IN lt_mobile ( %tky = item-%tky Mobile = item-Mobile ) ).
ENDMETHOD.
ENDCLASS.
This modify statement at the end is somehow going in an infinte loop, how can I fix this, I saw one post but there, two determinations were calling each other, but here I only have a single determination, I also have a validation but that should not be relevant, please help, thanks.
Request clarification before answering.
you have update statement in your determination , which cause your determination called again
determination setCountryCode on save { field Country; create; update; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Infinite loop is designed behavior. You should check if the mobile number needs an update and call the Modify statement only if the number needs an update. Currently your code doesn't have any such checks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
41 | |
15 | |
10 | |
9 | |
7 | |
6 | |
6 | |
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.