cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP CDS BOPF Action to Copy object

smith_john
Active Participant

Hi,

Can anyone help me out with a bit of sample code to define a copy action in a Bopf?

The not so helpful guide here https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.6/en-US/208bd589387c411390dd8c50775... mentions how to setup the action in the CDS view, this is the easy part, the harder part is the actual code in the Bopf action.

Accepted Solutions (1)

Accepted Solutions (1)

smith_john
Active Participant

In case anyone reads this and has the same issue... the solution is to call the method

io_modify->end_modify( abap_true ).

and

io_read->retrieve

after doing the create

Answers (7)

Answers (7)

suresh_muthusamy
Explorer
0 Kudos

paulmcfarling I need to create/update data in subnodes also but there is provision to output only one node. So how to make this work?

Regards,

Suresh.

praseenair86
Discoverer
0 Kudos

Hello,

I have a similar requirement. I need to add a copy action but also want to return the newly created data.

I keep getting a type mismatch dump when I pass data from retrieve method to et_data. My Et_data shows structure with 1 column of type C(1).

How can I pass this data after retrieve to et_data?

Thanks,

Praseena

pmcfarling
Participant

Just to follow up in case someone else stumbles on this. You need to go into Eclipse/ADT. Open up the BOPF. <CTRL>+Click on the action and set the Exporting Type to "Node". Then set BO and Node fields and make sure to set the multiplicity to "1".

The fraemwork will then redirect to your newly created record and you won't get that dump on et_data = et_data.

Attila
Active Participant
0 Kudos

Hi Neil,

I am populating the et_data parameter with the new/changed entities of method

/bobf/if_frw_action~execute

This results sending back the data on BOPF-SADL-GW lane, to the browser in the response to the action.

You should see your record in the response at the end starting like this, which updates your OData model:

{"d":{"results":[

If you do not populate the et_data, (in combination with configuring the action in ADT(or tx. BOBX) to export node instances, you might work with

"refreshAfterChange": true in the manifest.json of your UI5 application to configure your OData model to refresh resources after modification operations, will work when you have a control fetching the entity through a binding(list or a view root bound to that new entity).

I do not use the second approach due it corrupts my BOPF message management with batch request(known limitation by SAP), implementing custom applications(not Fiori Elements).

BR, Attila

suresh_muthusamy
Explorer
0 Kudos

hi,

I have the same issue and the BOPF update works in backend but the UI does not refresh and I have to perform some action to perform the refresh action. I am still not able to find a solution for this.

In the action, I need to update the current node and also update some additional information in the subnodes, and now how do I refresh the UI.

regards,

Suresh.

suresh_muthusamy
Explorer
0 Kudos

Also we are using Fiori based application created from template and how do we set the autorefresh after bopf modify call.

Regards,

Suresh.

breinelt
Explorer
0 Kudos

Hi Neil,

I tried to call this methods, but it doesn't work. I called the end_modify and retrieve methods, but nothing happens.

How did you implemented the copy function?

My solution:

1) Retrieve table

2) loop over table

3) create new entry with line

4) endloop

5) end_modify, retrieve

Wenn I do the retrieve in the loop I get an short dump.

Can you help me out here?

Thank you.

Best regards,

Bettina

smith_john
Active Participant
0 Kudos

Hi,

The retrieve isn't done in the loop, it's after the loop.

My code looks like this...

  METHOD /bobf/if_frw_action~execute.

    DATA ... blah blah blah

    io_read->retrieve

    LOOP AT ... do stuff here for new entry to be created
        io_modify->create
      ENDLOOP.
     
 io_modify->end_modify( abap_true ).
      io_read->retrieve

    ENDMETHOD.
0 Kudos

Hi Neil,

After pressing Copy button on UI.. Record is immediately saved in DB.

How to control in Copy action.

Regards,

Ashutosh

0 Kudos

Hello Ashutosh, have you been able to solve this?

0 Kudos

Hi,

When I am pressing "COPY" Action....New page is opening in display mode. How to make it editable ??

smith_john
Active Participant
0 Kudos

ok, so I figured out how to do a copy, not as simple as one might expect. anyway... My copy action works but the new record added to the table is not visible until the view is refreshed (F5)

next question is does anyone know how to make the screen refresh automatically after performing the action?

suresh_muthusamy
Explorer
0 Kudos

hi,

I have the same issue and the BOPF update works in backend but the UI does not refresh and I have to perform some action to perform the refresh action. I am still not able to find a solution for this.

regards,

Suresh.