Data sharing between multiple WD component using same assistance class
Welcome to my first blog and here I am going to tell you a trick. Sometimes, there are multiple WD components reusing each other and share a common assistance class. Each component requires a separate instance of assistance class, however, some common data also we want to share between these WD components.
Now, there are few other ways using which we can achieve the same:
- We can share the assistance class object in the used component, by sharing the same assistance class object at runtime. For more detail, you can refer link
- We can do external mapping between the using and used component using Component Interface Controller.
- The third way that I am going to explain is a bit different and it is based on the OOPS ABAP concept and without runtime code and external mapping.
Consider that we have two WD components, ZWD_MAIN and ZWD_USED.
Both the components are using the same assistance class ZCL_WD_ASSIST.
What we know is that each WD component will have its own instance of assistance class. Each object will be different and have different instance of the ZCUSTOMERS. So how can we make sure that both the object points to same attribute? I think you have guessed it 😉
If not, here is the magic trick, if we want to share the ZCUSTOMERS list between two WD components, then just by changing the attribute ZCUSTOMERS from Instance Attribute to Static Attribute, all the assistance class object can share the ZCUSTOMERS data. Isn’t it very simple 🙂 .
Comments and suggestions are welcome.