cancel
Showing results for 
Search instead for 
Did you mean: 

EML | Modify Business partner

induthiru
Participant
0 Kudos

Hello,

Can we use EML to create/update business partners? I looked at I_BUSINESSPARTNERTP_3, but somehow have not been able to get it working in S/4 Hana Cloud.

I have a Fiori app, that selects business partners from I_BUSINESSPARTNER and a custom button to update the last name of the selected partner. So, I have a base CDS on top of I_BUSINESSPARTNER, a root view entity and a projection view. Created the behavior definition for root and projection view with an action and implemented the behavior in the class.

In my action method, I wrote the logic using READ ENTITIES/ MODIFY ENTITIES. The READ works, but the MODIFY fails. I am not sure if this is the right way to do it and do we need COMMIT ENTITIES (mentioned in the documentation)?

READ ENTITIES OF ZIT_BUPA2_CONSMP_VIEW IN LOCAL MODE ENTITY bupa ALL FIELDS
WITH CORRESPONDING #( keys )
RESULT DATA(partner) FAILED DATA(ls_failed) REPORTED DATA(ls_reported).

LOOP AT partner ASSIGNING FIELD-SYMBOL(<new_partner>).
<new_partner>-lastname = <new_partner>-lastname && '_test'.
MODIFY ENTITY i_businesspartnertp_3
UPDATE FROM VALUE #( ( VALUE #(
%data-lastname = <new_partner>-lastname
%control-lastname = cl_abap_behv=>flag_changed
%is_draft = if_abap_behv=>mk-off
%tky = CORRESPONDING #( <new_partner>-%tky )
) ) ) REPORTED DATA(modify_reported) FAILED DATA(modify_failed).
EXIT.
ENDLOOP.

Any help is appreciated!

Marissa
Advisor
Advisor
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

Accepted Solutions (1)

Accepted Solutions (1)

ravenclaw
Participant
0 Kudos

Hey Indu - One more thing I noticed is that the ABAP EML statement MODIFY ENTITY used by you is inside the loop.

induthiru
Participant
0 Kudos

Hi Tanmay,

In the blog that I mentioned, the MODIFY is outside the loop. I had tried this way and it did not work as well.

I then moved the MODIFY inside the LOOP, as seen in the documentation of the object.

I don't think the MODIFY inside/outside the LOOP does not matter as I might be missing something else here.

Answers (1)

Answers (1)

ravenclaw
Participant
0 Kudos

Hello Indumati,

May I know where are you writing the ABAP EML MODIFY ENTITY statement? As per documentation, ABAP EML MODIFY statements must not be used in the RAP Saver methods - check_before_save, adjust_numbers, save, save_modified. The ABAP EML MODIFY statements can be used only in the RAP interaction phase and in the finalize saver method in the RAP save sequence.

Try this out!

induthiru
Participant
0 Kudos

Hi Tanmoy,

I have an action and the MODIFY is written in the behavior implementation for the action method.

https://blogs.sap.com/2023/06/05/sap-s-4hana-cloud-public-edition-abap-environment-case-4-work-cente...

The approach is similar to the one mentioned in this blog.