cancel
Showing results for 
Search instead for 
Did you mean: 

Global Data Declarations

Former Member
0 Kudos

Hi Experts,

Could anybody explain, how to define global datas ?

For example, I have a node called sales_header in which I have 10 fields from VBAK tables.

When I am defining any attribute in the component controller like GT_HEADER TYPE ELEMENTS_SALES_HEADER, I am not able to acess in the methods.

The only way is defile local tables inside the methods.

Any example will be highlt apprciated.

Thanks

Sanjaya

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sanjaya,

there is check box field (Public) for the component controller attribute, check that... you will be able to access the attribute now in the methods.

Reg,

Rajesh.

ChrisPaine
Active Contributor
0 Kudos

Hi,

saw the title of your post and felt compelled to respond...

Global Data Declarations ... are bad!

there are (in my opinion) very limited cases where using globally accessable variable is good coding practice.

If you insist on using variable that can be accessed throughout the controller method - you can use attributes of the controller - defined on attributes tab and referenced using wd_this->attribute_name.

I perfer to hold persistant references like this either 1) in the context if they are relevant to the display of the data. Or 2) as a private instance attribute of an assistance class where it can be used in the processing of the data.

The only time I tend to hold component attributes is when I have a flag/reference that I need to share which is used in the display of the data but is not data or meta data - for example a reference to the window of a popup window.

But I'm a bit extreme... you might be fine with just using the component attributes for your global tables.

Good luck whatever approach you take,

Chris

Former Member
0 Kudos

Hi Chris,

Thanks for the reply.

WD_this>attribute_name works fine when that is a variable. However I am more concerned about strctures and tables.

However when I have a structure ot table defined in the context.

For e.g. say my structure in the context is node_vbak with some five fields.

And in the attributes i define GS_VBAK type element_node_vbak.

then in the method I get the chid node and the all the instantiaion for that node .

After that is I want to access WD_THIS->GS_VBAK-VBELN it gives error the component VBELn does not exits.

so the way left for me is declare a local work area ls_vbak in each methoh and then access the fields.

Is there any way to have a global parameter and use it across.

Thanks

Sanjaya

ChrisPaine
Active Contributor
0 Kudos

Hi Sanjaya,

define your attribute as a data dictionary structure - not a reference to a context generated structure. Likewise, define the context as being a reference to a DD structure. This way importing and exporting values to the context via the assistance classes is much easier.

Former Member
0 Kudos

As Chris suggested, use your assistance class for global data declarations and definition.

In this class you can create your own types and data and use them in your WD component.