cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP RESTful programming copy action- Item Level

Hello All,

I am building application using fiori elements on S4HANA 2021 onPremise. I have followed link for CopyTravel on help sap and it working perfectly fine and creating new request ID but not navigating to the newly created request.

Is it that I am using copy function on item level there is issue with navigation or can anyone help me hoe can i modify result parameter to navigate to new request some how .

Thanks

Tisha

former_member14709
Contributor
0 Kudos

Hi Tisha,

I have implemented copy action, and it navigates me correctly to the newly created item. Could you share the action definition and implentation?

Thanks,

Aman

Former Member
0 Kudos

Hey Tisha,

Have you found a solution to the problem?

regards

Accepted Solutions (0)

Answers (4)

Answers (4)

Ramjee_korada
Active Contributor

Hello Tisha,

When you are creating new instance ( Copy ) , Then the action must be

  1. Factory action
  2. Result cannot be "$self " but actual entity zi_rtr_sams_asset_storage
  3. "Result" parameter needs to be mapped ( seems you are still doing as I can see the logic is commented )

I think point # 1, 2 can help that are missing currently.

Best wishes,

Ramjee Korada

0 Kudos

I tried all possible above ways and still it doesnot seem to work.

dhegde
Participant

Hi Tisha

So, this is not an `instance factory` action?

I have a similar action and implementation looks like this. `mapped` from `MODIFY ENTITIES.... CREATE...` is passed to `mapped` parameter of action.

For each `key`, corresponding `result` is filled.

"-- MODIFY ENTITIES OF .... CREATE.... MAPPED ... FAILED.... REPORTED ... 
    .
    .
    .

    mapped    = CORRESPONDING #( DEEP ls_mapped ).
    failed    = CORRESPONDING #( DEEP ls_failed ).
    reported  = CORRESPONDING #( DEEP ls_reported ).

    READ ENTITIES OF ZR_HeaderEntityTP
      ENTITY Header
        ALL FIELDS WITH CORRESPONDING #( mapped-header )
        RESULT DATA(created_header).

    CHECK created_header IS NOT INITIAL.

    "-- Map results to importing keys -> Important to open the new draft instance in edit mode
    " navigation will not work if key and result are not mapped correctly
    INSERT INITIAL LINE INTO TABLE result ASSIGNING FIELD-SYMBOL(<result>).
    <result>        = CORRESPONDING #( keys[ 1 ] ).
    <result>-%param = CORRESPONDING #( created_header[ 1 ] ).

What confuses me in your coding is that -

Looks like the action is defined on the `storage` entity. so, $self is the `storage` entity? But, you want to navigate to `storage item` entity when it is copied?

Hope this helps.

Regards,

Dhananjay

0 Kudos

Yes I want tp navigate to header once all the data is copied or same page is fine but it should navigate newly created request

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Maybe you should post an excerpt from the code of your Behavior Definition (BDEF) to answer the question how your action is actually defined.

dhegde
Participant
0 Kudos

Hello Tisha

Please check if you are mapping the %CID coming in your payload back to "mapped" parameter correctly along with created instance's %TKY component group.

Without this, UI would not know which instance was created for the %CID and hence would not be able to navigate to that instance.

For Copy action on item level navigates to created instance's draft page without any issue.

If all this looks good, please provide the coding of Copy action, that might be helpful to identify the issue.

Regards,

Dhananjay

0 Kudos

Below is my code . Can you help me figure out what is wrong here ?

 action ( features : instance ) returnfromstorage result[1] $self;


*----loop on header and fetch all the data
    LOOP AT lt_storage ASSIGNING FIELD-SYMBOL(<fs_storage>).
      APPEND VALUE #( %cid     = <fs_storage>-uuid  %data = CORRESPONDING #( <fs_storage> ) )  TO
          lt_storage_target ASSIGNING FIELD-SYMBOL(<fs_storage_target>).
      APPEND VALUE #( %cid_ref = <fs_storage>-uuid )
      TO lt_storage_target_item ASSIGNING FIELD-SYMBOL(<fs_storage_target_item>).
      <fs_storage_target>-requestno = <fs_storage>-requestno .
      <fs_storage_target>-storagecategory = 'RETURN'.
*4. Copy the ‘Receiving Plant’ value in the Original request to ‘Sending Plant’ in the Return request.
      <fs_storage_target>-sendingplant = <fs_storage>-recievingplant .

*Purpose of Ship default value must be: Storage Return (default non-editable)
      <fs_storage_target>-purposeofshipping = 'RETURN' .
*      <fs_storage_target>-%is_draft  = if_abap_behv=>mk-on .

*----loop on item and build the item target
      LOOP AT lt_storage_item ASSIGNING FIELD-SYMBOL(<fs_storage_item>).
        APPEND VALUE #( %cid     = <fs_storage_item>-uuid  && <fs_storage_item>-itemuuid
                        %data    = CORRESPONDING #( <fs_storage_item>  ) ) TO <fs_storage_target_item>-%target
                         ASSIGNING FIELD-SYMBOL(<fs_storage_target_item_new>).

        <fs_storage_target_item_new>-requestno = <fs_storage_item>-requestno.
*        <fs_storage_target_item_new>-%is_draft = if_abap_behv=>mk-on .
      ENDLOOP.
    ENDLOOP.

*--create new request now
    MODIFY ENTITIES OF zi_rtr_sams_asset_storage IN LOCAL MODE
    ENTITY assetstorage
    CREATE FIELDS (  requestno requesttype status statustext sendingcocode sendingplant recievingcocode shipmentrequired
                    shipmentdate expectedreturndate purposeofshipping freightterm taxcode shipmentmode brokername storagecategory
                    createrfullname createdby createremail createdon requestorid requestorfullname requestoremail requestermanager )
    WITH lt_storage_target
    CREATE BY \_item FIELDS (  requestno seqno companycode assetnumber  description inventorynumber manufacturer  serialnumber costcentre
                                plant location usedasset acquistioncost acquistionunit modelnumber )
    WITH lt_storage_target_item
    MAPPED DATA(mapped_create)
    FAILED DATA(failed_create)
    REPORTED DATA(reported_create).
**--read and show the newly created request
*    READ ENTITIES OF zi_rtr_sams_asset_storage IN LOCAL MODE
*       ENTITY assetstorage BY \_item
*         ALL FIELDS WITH CORRESPONDING #( mapped_create-assetstorageitem )
*         RESULT DATA(read_created_result_item).
*
*             READ ENTITIES OF zi_rtr_sams_asset_storage IN LOCAL MODE
*       ENTITY assetstorage
*         ALL FIELDS WITH CORRESPONDING #( mapped_create-assetstorage )
*         RESULT DATA(read_created_result).
*BREAK-POINT.
*    result = VALUE #( FOR newitem IN read_created_result_item ( %param = newitem  uuid = newitem-uuid  itemuuid = newitem-itemuuid  ) ).
*    result = CORRESPONDING #( result FROM mapped_create-assetstorageitem USING KEY entity  uuid = uuid  itemuuid = itemuuid
*                                MAPPING Uuid = Uuid  Itemuuid = Itemuuid ).
*    result = CORRESPONDING #( result FROM keys          USING KEY entity  uuid = uuid itemuuid = itemuuid  MAPPING %cid_ref  = %cid_ref ).
*