on 12-18-2021 3:04 PM
Hi Experts,
I am building a RAP based SAP Fiori Elements application. I am on S/4 HANA 2020 on premise release, FPS02.
I have a requirement to create an action button called 'Create as Copy'. The user will select some existing entry and hit this Create as Copy button to create a copy of the instance. The copy should be created in edit mode, so that before getting saved, user has an option to change few of the copied attributes. I was able to achieve the copy functionality, however, the copied entry gets saved to the DB directly with a new primary key, and I am landed to object page for the newly created entry in display mode. So user has to now manually click Edit and do an update operation if he wants to same change values in the newly created entry. Is there any way we can open this object page in edit mode directly?
Thanks,
Aman Garg
HI Aman Garg,
I am not sure if you are looking for this resolution without draft functionality still providing it here for others refrence. Instead of Instance Factory action create Static Factory action with input parameter same as entity and when pressing the copy button you will get a Dialog of all the values of the selected entity there you can change the values. But there is a downside that the action button will work even of no record is selected and dialog will appear asking all the details and will be difficult to implement for deep structures.
As of now Instance action doesnt support parameters that is why it has to be impletemented on Static factory method.
Regards,
Arun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aman,
Yes, There is possibility to create to Object in draft mode.
Once you create the object in Draft mode , Object page opens in edit mode with CREATE button where user needs to confirm.
To do this, you have to add below code while creating new records in the copy method.
%is_draft = '01' " for draft records<br>
sample code in my example is.
METHOD copyRequisition.
DATA : prhead TYPE TABLE FOR CREATE zrk_i_pur_req_h\\_PRHead.
READ ENTITIES OF zrk_i_pur_req_h IN LOCAL MODE
ENTITY _PRHead
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(pr_head_read_result) FAILED failed.
LOOP AT pr_head_read_result ASSIGNING FIELD-SYMBOL(<fs_head>).
APPEND VALUE #( %cid = keys[ 1 ]-%cid
%is_draft = '01'
%data = CORRESPONDING #( <fs_head> EXCEPT objectId ) )
TO prhead ASSIGNING FIELD-SYMBOL(<fs_new_req>).
TRY.
cl_numberrange_runtime=>number_get(
EXPORTING
* ignore_buffer =
nr_range_nr = '01'
object = 'ZRK_NR_PR'
quantity = 1
* subobject =
* toyear =
IMPORTING
number = DATA(number_range_key)
returncode = DATA(number_range_return_code)
returned_quantity = DATA(number_range_returned_quantity)
).
CATCH cx_number_ranges.
"handle exception
ENDTRY.
DATA(max_id) = number_range_key - number_range_returned_quantity.
<fs_new_req>-ObjectId = |PR{ max_id }|.
<fs_new_req>-Description = |Copy of { <fs_head>-ObjectId }|.
<fs_new_req>-StatCode = 'OPEN'.
ENDLOOP.
MODIFY ENTITIES of zrk_i_pur_req_h IN LOCAL MODE
ENTITY _PRHead
CREATE FIELDS ( ObjectId Description StatCode )
WITH prhead
MAPPED DATA(mapped_create)
FAILED DATA(failed_create)
REPORTED DATA(reported_create).
READ ENTITIES OF zrk_i_pur_req_h IN LOCAL MODE
ENTITY _PRHead
ALL FIELDS WITH CORRESPONDING #( mapped_create-_prhead )
RESULT DATA(read_created_result).
mapped-_prhead = mapped_create-_prhead.
ENDMETHOD.<br>
Best wishes,
Ramjee Korada.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello koradaramjee789
I've tried your code, however there is a porblem within the append value statement "no compenent exists with the name %cid"
i have also tried following solution but it gives the same error for %is_draft
loop at input_result ASSIGNING FIELD-SYMBOL(<fs_read_result>).
APPEND value #( %cid = <fs_read_result>-Stdpd %is_draft = '01' %data = CORRESPONDING #( <fs_read_result> EXCEPT Stdpd Uname ) ) to lv_mvgensd ASSIGNING FIELD-SYMBOL(<nfs_read_result>).
any sugetions are welcomed
Mohammed
koradaramjee789 Hi again,
with the factory action, the error within the %cid is gone however the %is_draft still having the same error.
Hi ,
Do you need draft feature ? if yes, please check if draft is enabled in behavior definition.
If no, then ignore it.
managed;
with draft;
define behavior for /DMO/R_Travel_D alias Travel
implementation in class /DMO/BP_I_TRAVEL_D unique
persistent table /DMO/A_TRAVEL_D
draft table /DMO/D_TRAVEL_D
lock master
total etag LastChangedAtmanaged;
Best wishes,
Ramjee Korada.
Hi Aman,
please have a look at the implementation of the action "Copy Travel" provided in the RAP developer guide on the SAP Help Portal: SAP S/4HANA 2021 | SAP BTP ABAP Environment (aka Steampunk). This action is provided as example in the SAP S/4HANA documentation as of edition 2021, but the implementation should work on SAP S/4HANA 2020 as well.
You can have a closer look at the implementation code and test the action on the Steampunk trial. The implementation is provided in sub-package /DMO/FLIGHT_MANAGED of the Flight Reference Scenario (/DMO/FLIGHT).
Hope this helps you further.
Kind regards,
Carine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Carine,
Thank you for taking out time to share answer and links.
I have tried implementing the same way, and I am able to create a copy using action, however, we want to present the copied instance in editable mode to the end user. But with this soultion, copy is created and user is landed to object page of newly created item in display mode. Is there any way we can open newly created item in edit mode? Or can we have possibility to edit items even before copying?
Thanks,
Aman Garg
Hello Carine ,
Thank you for your contribution.
I've tried to implement factory action for one of our RAP (Managed implementation type with draft) based SAP Fiori elements with SAP S/4HANA 2020 FPS02, however, got an error that "Instance Factory Actions are not yet supported".
Please could you confirm that the factory action implementation work for SAP S/4HANA 2020 FPS02?
Thank you.
Warm Regards,
Mohandoss Palanisamy
Hello Mohandoss,
Factory Actions are supported for both implementation types, managed and unmanaged, on SAP BTP ABAP Environment.
They are currently only supported for the unmanaged implementation type on SAP S/4HANA on-premise. (restriction in RAP Dev Guide@SAP S/4HANA)
Kind regards,
Carine
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.