cancel
Showing results for 
Search instead for 
Did you mean: 

Error refreshing data using side effects

Song
Explorer
0 Kudos
521

Hi Expert:

I am using RAP to build my own fiori application.

My application needs to recalculate the amount field on the header when changing the amount of line items,

So I use side effects to implement my functions.

However, when I modified the amount of the line item and clicked the save button,

The system prompts that an error has occurred and I need to refresh the data.

side effects

{

field Amount

affects field _POPaymentPrg . ClearPrepaidAmount, field _POPaymentPrg . OutstandingAmount,

field _POPaymentPrg . prepaidamount, field _POPaymentPrg . InvoicePaymentAmount,

field _POPaymentPrg . paidamount, field _POPaymentPrg . RemainingAmount,

field _POPaymentPrg . PogressStatus, messages;

}

determination CalculateAmount on modify { field Amount;}

METHOD CalculateAmount.

READ ENTITIES OF zi_popaymentprg IN LOCAL MODE

ENTITY advpayapply

BY \_popaymentprg

FIELDS ( orderuuid )

WITH CORRESPONDING #( keys )

RESULT DATA(lt_travels).

"update involved instances

MODIFY ENTITIES OF zi_popaymentprg IN LOCAL MODE

ENTITY popaymentprg

EXECUTE recalctotalprice

FROM VALUE #( FOR <fs_key> IN lt_travels ( %tky = <fs_key>-%tky ) ).

ENDMETHOD.

METHOD ReCalcTotalPrice.

DATA update TYPE TABLE FOR UPDATE zi_popaymentprg\\popaymentprg.

DATA lt_advpaymentAmount TYPE zi_advpayapply-Amount.

READ ENTITIES OF zi_popaymentprg IN LOCAL MODE

ENTITY popaymentprg

ALL FIELDS

WITH CORRESPONDING #( keys )

RESULT DATA(lt_popayments).

LOOP AT lt_popayments ASSIGNING FIELD-SYMBOL(<Fs_popayment>).

READ ENTITIES OF zi_popaymentprg IN LOCAL MODE

ENTITY popaymentprg

BY \_AdvPayApply

ALL FIELDS

WITH VALUE #( ( %tky = <Fs_popayment>-%tky ) )

RESULT DATA(lt_advancdPayments).

LOOP AT lt_advancdPayments INTO DATA(lt_advancdPayment).

lt_advpaymentAmount += lt_advancdPayment-Amount.

ENDLOOP.

APPEND VALUE #( %tky = <Fs_popayment>-%tky

prepaidamount = lt_advpaymentAmount

) TO update.

ENDLOOP.

MODIFY ENTITIES OF zi_popaymentprg IN LOCAL MODE

ENTITY popaymentprg

UPDATE FIELDS ( prepaidamount )

WITH update.

ENDMETHOD.

I would greatly appreciate it if you could help me solve this problem.

Marissa
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi songjw,

Could you please confirm if you're working with SAP S/4HANA Cloud, public edition?

Best regards,
Marissa

Song
Explorer
0 Kudos

Hi Marissa

I‘m working on SAP S/4HANA CLOUD 2302 Development 080.

Best Regards

Song

Marissa
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

We helped you to accept the answer, since there were no updates after 7 days.

You can unaccept it anytime if the answer provided was not helpful enough and you have further questions.

Best regards,
Marissa

View Entire Topic

Hi Jiangwei,

this error message comes up if you do not maintain side effects in your projection behavior definition. Just like other behavior, side effects must be reused for consumption in the projection BDEF with the syntax

use side effects

Please check ABAP RESTful Application Programming Model - Side Effects or Developing side effects for further information.

Should this not be the problem in your implementation, please provide further details.

Best regards,

Marina

Song
Explorer
0 Kudos

Thank you for your reply. I have already used the use side effects syntax in my BDEF.