Skip to Content
Author's profile photo Alessandro Iannacci

Simulate an instance attribute and share the value between bo and solutions

Hi again,

today is a great day!

I am going to solve the biggest problem in the SAP Cloud Application studio!

Raise your hands those who have never had the problem of


sharing a value between two different BOs, or between two different solutions.

Unfortunately the SAP Cloud Application studio has this limitation.

So what can we do?

We will never be able to share contents between BOs and Solutions?

Oh no guys, we will not give up so easily. We all are SAP developers and simply we don’t give up, never 🙂

This is why there is already an out of the box solution.

Just follow the steps below, and let me know if you liked it 🙂

I will be in SAP TechEd in Berlin 11-12-13 November for all the people that wants to share ideas and discuss about Cloud 4 Customer.

Ok let’s start!

Step 1.

– Download the solution template Attributes_sharing_bt_objects_and_solutions_V2.zip from SAP-Cloud-4-Customer—Ready-Templates/Attributes_sharing_bt_objects_and_solutions_V2.zip at master · Gh14Cc10/SAP-Cloud…

– Create a new solution “just for this feature” (you can name it ContentShareManager for example)

– Import the template in your solution as shown in the Figure 1

– Activate all the objects in the solution template (right click on the root and activate all objects)

1.PNG

Figure 1

Step 2.

– Now is the time to update the WebService Integration with the correct WSDL containing your solution namespace (the embedded wsdl contains MY namespace 😀 ). Take a look to Figure 2 and Figure 3

2,5.PNG

Figure 2

2,8.PNG

Figure 3

Step 3.

– Now activate your Brain. It is time to think a little. I embedded into the solution template a webservice consumer, named “ExternalWebServiceIntegration”. This consumer is there just for your tests, but you need to re-create this consumer on each solution where you want to use the sharing functionality.

So just create an External Web Service integration, give him the WSDL that you downloaded at point 2, and for each of these ws consumers create the associated communication scenario (A2X) and Integration arrangement (integration arrangement you need to create also for the Test consumer because it is not possible to include it in the solution template). So sorry for that.

0.PNG

Figure 4 – SEE THE PART HIGHLIGHTED WITH ‘1’

2.PNG

Figure 5

3.PNG

Figure 6

Step 4.

– Don’t worry… we reached our destination… the last step is to use the feature 🙂 . Create your test BO inside the “ContentShareManager” solution, or in one of your solutions (if you already trust me 😀 ).

0.PNG

Figure 7 – SEE THE PART HIGHLIGHTED WITH ‘2’

– Now you have to write the actions implementation. Yeah. I am not giving you any help for this, only two docx files with my code 😎

Retrieve:

SAP-Cloud-4-Customer—Ready-Templates/Retrieve.docx at master · Gh14Cc10/SAP-Cloud-4-Customer—Ready-Templates · GitHu…

Store

SAP-Cloud-4-Customer—Ready-Templates/Store.docx at master · Gh14Cc10/SAP-Cloud-4-Customer—Ready-Templates · GitHub

Generates the screens for your test BO, assign the permission of the WOC to your user, and start the debug. Et voilà!

end2.PNG

Figure 8

– And don’t forget to give the right permissions to use the WS to the users you provided in the communication arrangements, and for the user that is using the functionality!

end1.PNG

Figure 9

How it works

STORE

When store is pressed, a new AttributesManager instance will be created using the parameters your provided. The instance is automatically saved because the WS call is happening in a different session of the actual user session.

During the before-save event of the AttributesManager, if existing, a collection of attributes matching the provided attribute is retrieved inside the newborn instance. This is not the case because we are storing a new attribute 🙂

6.PNG

After that, the instance is retrieved again (using another ws call). On this instance is called the “CREATE_ATTRIBUTE” action, that save persistently the attribute in the AttributeDataCenter BO.

Finally the last ws call is performed: the AttributesManager instance is removed because is no longer useful.

7.PNG

RETRIEVE

When the retrieve button is pressed we have 4 steps:

Again a new AttributesManager instance will be created using the parameters your provided. The instance is automatically saved because the WS call is happening in a different session of the actual user session.

During the before-save event of the AttributesManager, if existing, a collection of attributes matching the provided attribute is retrieved inside the newborn instance. In this case, yes! The collection will contain your new created attribute.

Second call: we need to read again the instance now, because the first call was only useful for the creation. Let’s read our instance with the data 🙂

Third call: let’s delete the attribute now… we don’t need it anymore for our example.

Last call: always remember to remove the AttributesManager instance or your AttributesManager table will be full of unuseful things.

Assigned Tags

      17 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      Hi Alessandro,

      It seems promising... However my lack of knowledge in webservices in cloud i have following doubts.. and i will share the steps i have done..

      /wp-content/uploads/2014/10/step1_567480.jpg

      As you can see in my solution explorer.. I have highlighted 3 BOs.

      1. Trade BO ( Custom )

      2. Opportunity BO ( Standard )

      3. RelationshipForTradeOpportTemp ( where i want to statically store Trade id and USer ID)

      Hence I have created Webservice by rightclicking on BO RelationshipForTradeOpportTemp and created service integration. With Create Read and Update...

      Then I Created Communication scenario. with A2X

      and gave Customer Inbound and Outbound services. ( Here i dont know why i need two services but i created 🙁 )

      /wp-content/uploads/2014/10/step2_567481.jpg

      then i have made folowing setting in communication arrangement.

      /wp-content/uploads/2014/10/step3_567530.jpg

      is the path and service url correct??? and what i have to do after this?

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      Because every time i click on check connection it gets failed 🙁

      Due to authorization error

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Hi!

      First: the path seems not correct. There is something else after the "?" or not? It should have the following format:

      https://myxxxxx.crm.ondemand.com:443/sap/bc/srt/scs/sap/xxxxxxxxxx_manageattributesman?sap-client=000

      Second: try using the username and password authentication method.

      Third: why are you using a bo called "relationshipfortrade...." with itsown inbound webservice instead of importing my solution template? It will not work because it is not so simple to implement the static attributes simulation, and you need more than 1 bo.

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      Hi Aleesabdro,

      Now i am not using inbound webservice i am using only outbound now i am able to user Read operation as of npw..

      and that BO will be used to store runtime entry  of trade id along with user id..

      So am i following some wrong approach??

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      I don't know... can you share your BO definition and the actions you are exposing with the webservice definition?

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      My BO Def ( RelationshipBO : CRBO)...

      businessobject RelationshipForTradeOpportTemp  {

        [AlternativeKey] element currentuser : BusinessPartnerInternalID;

        element tradeid : BusinessTransactionDocumentID;

        element OpportunityUUID : UUID;

        element is_save_cancel : Indicator;

      }

      I want to store data of USer ID and tradeid and

      in Opportunity before save i want to use them....

      And for this i have not created any action in this BO...

      I have created Action in Trade BO where i want to save the entries in the CRBO with userid and tradeid. I will explain my whole scenario...

      1. BO Trade ( in TI i am calling Opportunity quick create but i want to pass my trade id to opportunity because i want to create a link )

      2. BO CRBO where in runtime i will store the entry using web service which would get invoked in the action which gets triggered before quick create of opportunity..

      /wp-content/uploads/2014/10/step1_567615.jpg

      3. BO Opportunity BO : I will use the read operation of webservice to read the data which we stored in the above Event - Action.

      Thus i will get my trade id in opportunity before save and will do the rest.

      But in your store.docx file ur using below code...

      //2 - Store the attribute via manager object

      var StoreRequest : Library::ExternalWebServiceIntegration_att.CreateAtt.Request;


      what is CreateAtt? because in my web service i have only 3 operatiuon create read update...


      and i hope i am clear now so you can guide me further as always!


      and thanks a lot!!

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      To use the read operation in the opportunity BO you need to have the UUID of the created instance in this BO. You will not have. What you can do you can query all the created instances and later filter them using your user ID.

      Alternatively you can delete your CRBO and use my ready solution.

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      Hi Alessandro,

      I want to use read operation just based on User id... and i will fetch the trade id in the opportunity Before save...

      as soon as i fetch then i want to delete that entry in BO...

      Opportunity UUID will actully never going to be stored in the BO..

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      I don't know if you can use the read operation based on the alternative key. Webservice usually let you read only using the UUID of the instance (the uuid is automatically created you don't need to store it).

      Maybe you need to activate the query operation in the webservice other than the read operation.

      Try, I am not sure about it.

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      okay! i will check that but currently when i try to call the Create Method in the action

      it is giving me error

      Error 11 Methods or actions are not permitted. C:\Users\TEC1007015\Documents\copernicusisolatedshell\Projects\SYBIT_DEV\YV3R6L49Y\Trade_BusinessObject\Sy_Trade-Root-Action-method_crbo.absl 26 71 Sy_Bau_Addon (In Development)
      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      It works like a charm now thanks a lot for the idea!

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      Hi Alessandro ,

      One small doubt if i Upload the Template in a tenant do i need to create Communication  Scenario Defination (.csd) file new?

      and if i uplaod this template i need to Delete the old WSID and create the new one with new WSDL right?

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Hi Druvin

      no you just need to update the wsdl in the ws consumer and create the communication arrangement. Let me know if you need help

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      Hi Alessandro,

      Soon I will upload this in Customer specific in a week then I will follow the steps you suggested 🙂

      Author's profile photo Former Member
      Former Member

      Hi Alessandro, the template is not compatible with 1511 system, can you recreated it again.

      Cheers Ognian

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      GitHub version updated!

      Author's profile photo Former Member
      Former Member

      Hi Alessandro, it is working now. Thanks.