cancel
Showing results for 
Search instead for 
Did you mean: 

Component Usage in Standard component

Former Member
0 Kudos

Hello Friends,

I am new to webdynpro. I browsed this forum before posting this message , but all were not somewhat closer to my requirement. I tried most of them, but couldn't succeed.

I have a scenario where in there is a standard component and a z component(which i have developed)

The z component has custom fields, and 2 buttons(OK,CANC).

Now , i have enhanced the standard component to place a button on the view(there is only one view) .

And when I click on the button.. it opens up the z component. I have managed to map the z components component cont node (which are custom fields) into the comp controller context and also to the view's context where the rest of the std fields are available.

I have managed to put the custom fields inside an include and used the include in the standard tables.

Now , when the user fills up the custom fields and clicks on OK button(which is in the z comp), i need to read the custom fields and make sure that are available in the standard component to store it in the tables.

If somebody has a method to do this, can you please post the step by step approach in resolving this.

Regards,

Vinay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

Make a method in your z component and make check its interface part. Make a exporting parameter ie the data that you want to send to the standard component .

Call your method into the standard component and you will get the data from input fields there.

Regards

Kuldeep

Answers (3)

Answers (3)

RicardoRomero_1
Active Contributor
0 Kudos

Hi Vinay,

You can create an event in the component controller of your Z component and mark it as interface.

Then within the action of your button OK in your Z comp. you can trigger this event.

You need to create a method as event handler for the event in the standard component.

With this you can read the data just at the time when the button is pressed on your component Z.

Hope this help you.

Regards.

Former Member
0 Kudos

Hello Ricardo,

I have created an event handler and a corresponding method for the button event on the component controller.

I have also coded to raise an that event in button click event in the VIEW since the button is available in the view.

But when i try to compile this , system throws an error saying the method is not recognized.

I hope i followed the right process, if not could you help further.

Regards,

Vinay

RicardoRomero_1
Active Contributor
0 Kudos

HI,

The error is compiling the Z component, isn't it?

For trigger the event you can use the following code within your Z view:

DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
  lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).

    lo_componentcontroller->fire_YOUR_EVENT_NAME_evt(
    ).

Former Member
0 Kudos

Thanks for the reply , Ricardo, my z comp is activated as you directed in my z comp.

Now what i have done I declared a method as under

Method : GET_DETAILS

Method Type : Event Handler

inteface : checked.

Description : get details

Event : BTN_OK

Controller : COMPONENTCONTROLLER

So..the code in the view's button click is as shown below.

DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .

lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).

lo_componentcontroller->fire_btn_ok_evt(

).

I have put a external debugging for the method GET_DETAILS.

But in portal it does not stop in this method and i am unable to get the details of the custom fields on the pop up window.

Am i missing something here?

Regards,

Vinay

RicardoRomero_1
Active Contributor
0 Kudos

I don't know, It seems that is ok.

The event is created in your Z comp. and is marked as interface, isn't it?

And the method GET_DETAILS is created in the standard comp. ?

EDIT:

It's not necessary to mark "Interface" in your event handler method.

The controller must be INTERFACECONTROLLER of your Z comp.

You need to add your Z comp. as used component in the properties tab of the component controller in the standard comp.

Edited by: Ricardo Romero Mata on Nov 22, 2011 3:38 PM

Former Member
0 Kudos

Ricardo..

The method GET_DETAILS is a method in the Z component controller.

Is my approach incorrect?

Regards,

Vinay

RicardoRomero_1
Active Contributor
0 Kudos

yes, that's incorrect.

You need to create the event handler method in the standard component. With this when you push the button in your Z comp. the method is triggered in the standard comp. And you can read the custom fields in the context and do what you want...

I guess you've added the Z component as used component in your standard comp.

For read the context of your Z component from the standard one you must to mark the node as interface. With this you can create a binding between the context in both components...

Former Member
0 Kudos

Hello Ricardo,

Today, I managed to do as you have directed and could succeed to some extent.

I have used the z comp as a usage in the std component and used the drag and drop method from the

z comp context to the std component controller context.

During activation , the compiler gives the following error.

Mapping for <node_name> to <node_name> not possible due to recursion.

I have not declared the <node_name> as recursive in my Z comp.

Regarding the usage.. i have checked SDN in bits and pieces to include it my z component and that's why this inconsistencies.

Is my mapping correct?

I would entreat you to give me an example , with steps, on how to make a z comp as a usage to my std component.

If I understand this and am able to fetch one field from the z comp to the std component , then i will be able to better understand the webdynpro concepts which will be easy for me going forward.

Awaiting your reply.

Regards,

Vinay

RicardoRomero_1
Active Contributor
0 Kudos

HI,

I don't know why you got this error...

Try to check this thread:

The steps for do it are the following:

1. Create your Z comp:


1.1: In component controller:
       -Create an event and mark it as inteface. 
       -Create a context node and mark it as interface. 

1.2: In the MAIN view:
      - Map the context node in component controller to the view context and 
         add the fields you want to the layout.

      - Put a button 'OK', within the action of this button do the validations 
         you want and fire the event created in component controller like this:
                
            ' DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
            ' lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
            ' lo_componentcontroller->fire_YOUR_EVENT_NAME_evt(  ). 

2. Add the Z comp. to the standard one:


2.1: Add the Z comp. as Used Component.
2.2: In the tab properties of the view from you want to call the Z comp.
         Add the Z comp. as used component. Two lines must be added. 
2.3: Drag and drop the context node of your Z comp. to the context.
2.4 Add a button to call your Z comp. Use the wizard for do that.
       -  The code inserted use the method 'create_window_for_cmp_usage'
2.5 eate a method as event handler for the event of your Z comp.
       - Within this method you can read the context node of your Z comp. 
          and assign some data to the standard nodes.

I hope I haven't forgotten any step. With this is working for me. Hope this help you.

If you want to pass some data from the standard comp. to your popup, you can create other interface node in your Z comp. and set the data before to before to call it.

The nodes in your Z comp. and standard comp. must have different names.

Regards.

Former Member
0 Kudos

Hi Ricardo,

Thanks for the detailed info.

I followed the process step-by-step and the std component got activated. THANKS A TON.

Should we declare the event and event handler at std component controller level or at the view level.

What I understand is that : declaring it in the std component controller level will have global access for both the components ..

i mean at the std and z component.

I have not tested the scenario still.. will keep working on it.

Regards,

Vinay

Former Member
0 Kudos

Hi Ricardo,

EXCELLENT.. SOLVED...Now i am able to get the custom fields onto the std component and finally load into the tables.

Thanks for the DETAILDE steps that you have posted.

I have a null exception message when try to close the z components window from the std component window.

As i am firing the event in my z comp view , button ok method, i am closing the window in the same method. using the following code.

DATA LO_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER.

LO_COMPONENTCONTROLLER = WD_THIS->GET_COMPONENTCONTROLLER_CTR( ).

LO_COMPONENTCONTROLLER-><my_own_component_name>->CLOSE( ).

Any other methods for closing ?

Regards,

Vinay

RicardoRomero_1
Active Contributor
0 Kudos

I think the better way to do is create an attribute in the view of the standard component called for example ZZ_WINDOW TYPE REF TO IF_WD_WINDOW.

Then replace the var "lo_window" inserted by the wizard when you created the popup by "wd_this->ZZ_WINDOW".

In the method handler for the event, use the following sentence in order to close the window:

wd_this->ZZ_WINDOW->close( ),

Regards.

Former Member
0 Kudos

Hello Ricardo,

You are a master to me. It worked.

I have a button cancel as well which is on the Z component view . When i used the same code.. it gave me the same exception.

How to close the window when the user clicks cancel from the Z component view.

Regards,

Vinay

Former Member
0 Kudos

Hello Ricardo,

Its working now.. I used the same concept of creating event handler in std component and firing int he z component.

Thanks for a GREAT help.

Regards,

Vinay

RicardoRomero_1
Active Contributor
0 Kudos

Yes, you can use the same concept for "Cancel" button.

I've been rereading your first post. And I think maybe we could have done more easily. using the method "subscribe_to_button_event" after calling the popup.

but hey, is solved!

Former Member
0 Kudos

Hello Ricardo,

As I move on ahead with development, a new issue has come up.

Now in the standard component, there are 2 fields(hdr guid and item number) which i need to access , to set my custom fields,

based on the item no that the user is currently accessing during run time.

But these two fields are part of a another standard enh and when i try to access them using get_element( ) fn and compile it,

system throws an error saying "cannot inclue attributes of another enhancement".

My idea is to access these two fields in my Z component and when i try to use the std comp as a comp usage for my z component.. it does no show up in the F4 selection of the used component.

Any other approach can you think of? Major logic depends the item no as the custom fields are based on the item no.

Regards,

Vinay

RicardoRomero_1
Active Contributor
0 Kudos

Hi,

I don't know if I understood good your new issue. The problem is reading the context of standard component from Z component, isn't it?

I think you can do the following: Create a new interface node in the component cotroller of your Z component, called for example INPUT_PARAMETERS.

Then in the standard component do the binding with this node. And you only need to set the values you want in this node before to call the popup.

In the method WDDOINIT or WDDOMODIFYVIEW of your Z component you can read this node before to render the view.

Hope this help you.

Former Member
0 Kudos

Hello Ricardo,

Just to clarify the issue.

The issue is in the std component and not in the Z component.

This was my idea to solve the issue by including the two fields in the z component and pass it to the std component.

But, the control will be stil in std component b4 the pop is displayed.

If the user in in display mode, i need to fetch the values from DB and set it b4 the pop is displayed in the custom bt click method of the std component.

These details should be shown at line item level.

Since the guid and item no are part of another std enhancement i am unable to access those in my own z enh in my

std component.

FYI.. i am in SRM 7 and the Std component is /SAPSRM/WDC_DODC_SC_I_BD.

Std. ENh in the component /SAPPSSRM/WD_SC_IT_BD_OPT.

need to access the fields : HEADER and NUMBER_INT which are part fo the another ENH.

Regards,

Vinay

Edited by: Vinay Reddy on Nov 28, 2011 1:14 PM

RicardoRomero_1
Active Contributor
0 Kudos

Hi Vinay,

Sorry, but i still don't understand your scenario... may be is better to open a new thread for this part in the SRM forum.

If you want to read the item guid you can read the context node ITEM_BASIC_DATA.

or wich node do you want to read?

Former Member
0 Kudos

What i would do is , use a singleton OO class with attributes and methods. You can set and get your context nodes which are common to both of your components. In your case you can set the std component context in the OO class as attribute. From custom component access them. Vice versa also possible.

Former Member
0 Kudos

Can anyone , please help me with the steps.