<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: BOPF: Create instance in another object in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735861#M34864</link>
    <description>&lt;P&gt;I tested the action in BOBT transaction.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2018 11:41:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2018-10-23T11:41:32Z</dc:date>
    <item>
      <title>BOPF: Create instance in another object</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735857#M34860</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;
  &lt;P&gt;I have two independent BOs, which at the moment are not related to each other (there is no association defined), let's call them First and Second. &lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;If I try to create an instance in Second through a simple ABAP program, I can perfectly do something like this and the entry in the database will be created:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt; transaction_manager = 
   /bobf/cl_tra_trans_mgr_factory=&amp;gt;get_transaction_manager( ).


service_manager =
      /bobf/cl_tra_serv_mgr_factory=&amp;gt;get_service_manager( 
           zif_i_secondnode_c=&amp;gt;sc_bo_key ).


object_configuration =
      /bobf/cl_frw_factory=&amp;gt;get_configuration(
        zif_i_secondnode_c=&amp;gt;sc_bo_key ).
        
data: second_node type ref to z_combined_structure.  

second_node-&amp;gt;key = /bobf/cl_frw_factory=&amp;gt;get_new_key( ).
second_node-&amp;gt;concept = 'C0017'.
second_node-&amp;gt;date = '20181017'.
second_node-&amp;gt;description = 'brief description for this item'.
second_node-&amp;gt;cost = '9.00'.

APPEND VALUE /bobf/s_frw_modification(
              node        = zif_i_secondnode_c=&amp;gt;sc_node-zsecond_node
              change_mode    = /bobf/if_frw_c=&amp;gt;sc_modify_create
              key            = second_node-&amp;gt;key
              data           = second_node  )  TO mod_table.
              
service_manager-&amp;gt;modify( 
EXPORTING it_modification = mod_table                 
IMPORTING eo_change = DATA(change_object)                 
          eo_message      = DATA(messages) ).   


IF change_object-&amp;gt;has_failed_changes( ) = abap_false.
  
  "This doesnt give any error when running from an ABAP program
  "But from an action from FIRST_NODE, I get a dump
  transaction_manager-&amp;gt;save( 
   IMPORTING ev_rejected =  DATA(was_rejected)
             eo_message  =  messages   ).
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;However, running this same code in a BOPF action from my object First, I get a runtime error. &lt;/P&gt;
  &lt;P&gt;How can I achieve such a result? Storing instances in BOs inside the Action for another BO.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 11:25:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735857#M34860</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-10T11:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: BOPF: Create instance in another object</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735858#M34861</link>
      <description>&lt;P&gt;Did you check, what happens if you dont do save-call from transactionmanager in action of first node?&lt;/P&gt;&lt;P&gt;How is the bopf action called? There should be the save-call and not inside the action.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 08:29:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735858#M34861</guid>
      <dc:creator>cwolter90</dc:creator>
      <dc:date>2018-10-11T08:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: BOPF: Create instance in another object</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735859#M34862</link>
      <description>&lt;P&gt;Hi Christian,&lt;/P&gt;&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I don't do the save call, nothing happens. The entry is not saved in second_node. &lt;/P&gt;&lt;P&gt;The action is called CLOSE, I didn't understand your last sentece, did you mean the transaction_manager-&amp;gt;save( ) call should not happen inside the CLOSE action from FIRST_NODE? &lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 08:44:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735859#M34862</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-16T08:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: BOPF: Create instance in another object</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735860#M34863</link>
      <description>&lt;P&gt;My question was mistakable...&lt;/P&gt;&lt;P&gt;Where is the close-action called? Do you call the action yourself with a servicemanager or is it called by any framework? I guess the save-call should happen after the action is called.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 08:06:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735860#M34863</guid>
      <dc:creator>cwolter90</dc:creator>
      <dc:date>2018-10-19T08:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: BOPF: Create instance in another object</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735861#M34864</link>
      <description>&lt;P&gt;I tested the action in BOBT transaction.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 11:41:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735861#M34864</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-23T11:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: BOPF: Create instance in another object</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735862#M34865</link>
      <description>&lt;P&gt;Finally I got it working, &lt;/P&gt;&lt;P&gt;The modification had to be done using the transaction manager rather than the service manager, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;transaction_manager-&amp;gt;modify(EXPORTING it_modification = 
                       VALUE #( (node = zif_i_secondnode_c=&amp;gt;sc_node-zsecond_node
                                 change_mode = /bobf/if_frw_c=&amp;gt;sc_modify_create
                                 data = second_node) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;There was no need to call the SAVE change from the transaction manager either&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 11:45:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bopf-create-instance-in-another-object/m-p/735862#M34865</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-23T11:45:10Z</dc:date>
    </item>
  </channel>
</rss>

