cancel
Showing results for 
Search instead for 
Did you mean: 

Factory Action on multiple instances does not refresh list report

jheisler
Explorer
0 Kudos
198

Hi,
i have a fiori elements app based on the list report floorplan. It allows me to do CRUD operations on a custom table. I added a factory action that allows users to select multiple entries, enter the actions parameter "Year" and then all entries are being duplicated with the newly entered year.

The Problem: When doing this, the list report won´t update. I need to manually press "Go" to also have the newly created entries in the list.

factory action copyEntries parameter Z..._INPUT_copyEntries [1];

Implementation of the factory action:

METHOD copyEntries.
    DATA: create_duedates TYPE TABLE FOR CREATE z...\\DueDates.
    DATA(new_year) = VALUE #( keys[ 1 ]-%param-period_year OPTIONAL ).

    READ ENTITIES OF z... IN LOCAL MODE
        ENTITY DueDates
            ALL FIELDS WITH CORRESPONDING #( keys )
            RESULT DATA(r_duedates_to_copy)
            FAILED DATA(f_diedates_to_copy).

    create_duedates = VALUE #( FOR duedate IN r_duedates_to_copy
                                 ( %cid = keys[ %key-Companycode = duedate-Companycode
                                                %key-Period = duedate-Period
                                                %key-Periodyear = duedate-Periodyear
                                                %key-Type = duedate-Type ]-%cid
                                   %data = CORRESPONDING #( duedate MAPPING Periodyear = DEFAULT new_year ) ) ).

    MODIFY ENTITIES OF z... IN LOCAL MODE
        ENTITY DueDates
            CREATE FIELDS ( Companycode Duedate Period Periodyear Type )
            WITH create_duedates
            MAPPED mapped.
  ENDMETHOD.

 I already tried adding a side effect, but that did not change anything

  side effects {
    action copyEntries affects $self;
  }

Does anyone have an idea?

Technical background: S/4HANA OP 2023, minUI5 version 1.120.0

View Entire Topic
ClearQueries
Explorer
0 Kudos

Hi @jheisler,

In order for you to request newly created record, you've to re-request the record from the entity on which List report has been bound.

I can think of couple of options using which you can achieve this -

1. Option 1 - You've to ensure you're passing right combination of Key and %CID in mapped parameter of action.

I've uploaded a video on our YouTube channel for the same. 

Please Checkout - https://youtu.be/aCzCIAvYDkg

thanks @mainak-aich for the input.  

2. Option 2 - add a local annotation on your Fiori LR to refresh the list report table -

            <Annotations Target="SAP__self.copyEntries(SAP__self.RelevantEntityType)">
                <Annotation Term="Common.SideEffects">
                    <Record Type="Common.SideEffectsType">
                        <PropertyValue Property="TargetEntities">
                            <Collection>
                                <NavigationPropertyPath>/service/RelevantEntitySet</NavigationPropertyPath>
                            </Collection>
                        </PropertyValue>                    
                    </Record>
                </Annotation>
            </Annotations > 

Refer this documentation for more details.

 2. Option 3 - Find an hook or handler method on UI and trigger refresh/rebind for the list report table.

Hope this resolves your query.

Please accept the solution if it does.

Regards,

ClearQueries.com 

Follow on LinkedIn

Subscribe to our YouTube Channel - ClearQueries

jheisler
Explorer
0 Kudos
To let you know, i am currently not able to get it to refresh with the local annotation. Option two is not an option i want to use. If i get this to via annotations i will let you now.
ClearQueries
Explorer
0 Kudos

Hi @jheisler,

I've prepared short video explaining how to solve the issue you are facing.

I've also updated the answer posted above. With this approach, you should be able to achieve the required behavior without any backend or UI side effect, solely using RAP Action implementation.

Checkout the video - https://youtu.be/aCzCIAvYDkg.

Thanks.

jheisler
Explorer
0 Kudos
@ClearQueries thanks for the video, but unfortunately it does not help. I checked and - besides you using UUIDs as a key in the view - we are doing exactly the same, as you can see from the code i posed in the initial post. I also confirmed in debugger, that the correct cid and key is set. Do you have a complete working sample of local annotations in any repository i could check out? To see if mine somehow differs from a working solution?