cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Modify statement in a determination giving short dump, going in infinite loop.

sahu10114
Explorer
0 Kudos
814

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.

Accepted Solutions (1)

Accepted Solutions (1)

junwu
SAP Champion
SAP Champion

you have update statement in your determination , which cause your determination called again

 

determination setCountryCode on save { field Country; create; update; }

 

sahu10114
Explorer
0 Kudos

Thanks for the response but I also want to add the determination during update mode, is that not possible?

junwu
SAP Champion
SAP Champion
just add a check if country code is already added, don't call MODIFY ENTITIES, then your determination won't be called infinitely

Answers (1)

Answers (1)

Juwin
Active Contributor

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.