cancel
Showing results for 
Search instead for 
Did you mean: 

Assistance Class

Former Member
0 Kudos

Hi Experts,

I know assistance class is being useful for passing the value throughout the components. I have two WDP components which is CompA and CompB. In CompA I have to key in a value in which it need to be used in the following components. When it goes to CompB, the value will be used to populate a table which is from database. So far I have created the assistance class with belows method:

method GET_USER_PROFILE.

SELECT * FROM PA0002

INTO CORRESPONDING FIELDS OF TABLE LT_USER

WHERE PERNR = USRID AND endda > sy-datum AND begda < sy-datum.

endmethod.

USRID is the Importing parameter while LT_USER is the exporting parameter which is a table.

This method works well in CompA which is the table is created successfully. But the table is actually to be used in CompB. So how am I going to do that? Besides, I'm so confuse of using assistance class in WDP. It would be great if someone can clarify the usage of that. Thanks.

Regards,

YC

Edited by: ycwong on Mar 12, 2011 11:23 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member450736
Active Participant
0 Kudos

Hi,

i think you are using same assistance class for two components A and B, which may not work becuase in both components instance of assistance class would be different.

inorder to share data between two components you should probabaly have singleton class which will have only one instance and share data.

Thanks,

kranthi.

Former Member
0 Kudos

Hi Karanthi,

This is very much possible with Assistance class. Moreover assistance class is a singleton class whose life time is controlled by the main component.

For the thread owner :

The component-B usage should be created passing the parameter assistance class.

You can pass your WD_ASSIST reference while you create a component.

lo_cmp_usage = wd_this->wd_cpuse_com_code_sh( ).

IF lo_cmp_usage->has_active_component( ) IS INITIAL.

lo_cmp_usage->create_component(

assistance_class = wd_assist ).

ENDIF.

create component method has the following importing parameters.

COMPONENT_NAME Importing Type STRING

CONFIGURATION_ID Importing Type WDY_CONFIG_KEY

MODEL_USAGE Importing Type Ref To IF_WD_COMPONENT_USAGE

ASSISTANCE_CLASS Importing Type Ref To OBJECT

MODEL_USAGE_NAME Importing Type STRING

Former Member
0 Kudos

HI Ycwong ,

Assistance Class in WD is used for storing common reusable logic apart from component controller.

It can also be used to store Text Symbols for displaying messages or lables for the WD application.

Per WD session there will be one instance of assistance class ( if mentioned ) will be automatically instantiated and you can access it by wd_assist.

It can also be used to store a reusable set of constants, public attributes, types etc.

Assistance class has some standard methods like get_text to fetch text from text symbols.

To craete an assistance class you have to create a normal class and then mention CL_WD_COMPONENT_ASSISTANCE as superclass. Since CL_WD_COMPONENT_ASSISTANCE is an abstract class we can use it as a super class and create our own class. Then you can metion you class name in WD Component Header Details.

To have a look of assistance class you can look at CL_WD_COMPONENT_ASSISTANCE class then navigate to all its Subclasses ( Assistance Class ). The methods will give you an idea of the usage.

Regards

former_member450736
Active Participant
0 Kudos

Hi Bhaskaran,

i used same assistance class for two components, however i have two different instances of assistant classes in two components and not able to share data, however as you said when i pass assistance class instance wd_assist to create component , i am able to share data

comp A with assistance class AS

comp B with assistance class AS

assitance class with attribute "myattr"

in component controller method wddoinit of comp A i have statement

wd_assist->myattr = 'Comp A'.

in the view controller method wddoinit of comp B i created component usage of A ( i have declared component usage of A in B )

and then

lv_string = wd_assist->myattr.

lv_string is empty after this statement..

what i felt is wd_assit is not singleton class because if it is then it should have only one instance is't it??? and i should be able to share data.

however when i create component usage by passing wd_assist to create_component method it is working.. i am not sure of this behaviour of assistance class.

correct me if i am wrong...

Former Member
0 Kudos

Karanthi,

what i felt is wd_assit is not singleton class because if it is then it should have only one instance is't it???

Strictly speaking it is not a singleton class but it closely matches the Singleton pattern. You cannot create a instance on your own, framework does it for you and the life time of the assistance class is controlled by the main Component.

however when i create component usage by passing wd_assist to create_component method it is working.. i am not sure of this behaviour of assistance class.

This is because the used component creation life time is under the mercy of main component, so ,when you pass the instance of the assistance class , the component uses this instance instead of creating new instance.

see this link [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/1f6442a3d9e72ce10000000a1550b0/content.htm|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/1f6442a3d9e72ce10000000a1550b0/content.htm]