Reading and Writing Attributes of a Business Object

Florin Wach florin.wach at gmx.net
Thu Mar 4 08:02:18 EST 2010


-------- Original-Nachricht --------
> Datum: Thu, 4 Mar 2010 08:49:39 +0000
> Von: Ali Husain <mr_mago40 at hotmail.com>
> An: sap-wug at mit.edu
> Betreff: Reading and Writing Attributes of a Business Object

> 
> 
> Hello WF Experts,
> 
> I have two questions regarding reading/writing attributes of a business
> object.
> 
> 
> 
> 1.      
> How to read a value of an
> attribute from within another attribute?
> 
> 
> When programming an attribute we can access the keys directly
> from within the attribute by using OBJECTKEY-NAME. How would I access the
> value of other attributes using a similar
> way?

DATA: lv_value     TYPE C.
swc_get_property self 'PropertyName' lv_value.
  "Take care about endless loops when using get_property within db-attributes



> 
> 
> 2.      
> How to write different variables
> to different attributes while programming in one attribute?
> 
> 
> Let’s say I have calculated many values within the
> attribute and I want each of them to be a separate attribute. I want to
> avoid
> re-programming the same thing in the other attributes since would have
> already
> retrieved the needed data from within one attribute. I also don’t want
> to use a
> multiline attribute since I need each value to be its own attribute.

More tricky. Let's assume that you have two attributes: Attrib_A and Attrib_B.
In Attrib_A you do the calculation for both, A and B.
In Attrib_B you want to pick up the calculation of A, but you don't know, if A was already executed or not.

This is how I did it:

GET_PROPERTY attrib_a.
   object-attrib_a = 23.   "Let's say, that is the result of the calc
   object-attrib_b = 42.   "This will make Mike happy
   swc_set_element container 'ATTRIB_A' object-attrib_a.  "Must-do for virtual attributes

END_PROPERTY.

GET_PROPERTY attrib_b.
   IF object-attrib_b IS INITIAL.
      "Refresh
      swc_get_property self 'Attrib_a' object-attrib_a.
   ENDIF.
   swc_set_element container 'ATTRIB_B' object-attrib_b.
END_PROPERTY.





> 
> 
> Thanks a lot for the help.
> 
> Ali
> 
> 
>  		 	   		  
> _________________________________________________________________
> Hotmail: Powerful Free email with security by Microsoft.
> http://clk.atdmt.com/GBL/go/201469230/direct/01/



More information about the SAP-WUG mailing list