cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Data Between Views:Custom Controller

Former Member
0 Kudos

Dear Experts,

I am not able to pass data between views.I read many threads in this forum, but still clueless.

Here is my requirement, Create a Custom component with 2 views. View one will have Service Request No and and View two will have some fields related to that service request.(Note I am not using a Search and Result page)

I have created a Custom Component and created 2 views and a view set and created custom controller (HeaderCuCo) , I am using BTAdminH in the model node. Binded the 2 views with the custom controller context node(BTAdminH).

When I Enter the serivce request number and press 'DISPLAY' button, it should give me values of that service request in view 2.

In the event handler EH_ONDISP ,I have written the below mentioned code.(This Event handler is triggered from Viewset)

DATA: lr_cuco type ref to ZL_ZRP_DETA_HEADERCUCO_IMPL,

lr_entity type ref to cl_crm_bol_entity.

lr_cuco ?= me->get_custom_controller( 'ZRP_DETAIL/HeaderCuCo' ) .

CHECK lr_cuco IS BOUND.

lr_entity ?= lr_cuco->typed_context->btadminh->collection_wrapper->get_current( ) .

CHECK lr_entity IS BOUND .

lr_cuco in BOUND, but lr_entity in not bound,

What I am missing? should I write this code in DO_PREPARE_OUTPUT of the view 2 also ??

please advice me ..

Regards,

Roopa.

Accepted Solutions (1)

Accepted Solutions (1)

suchita_phulkar
Active Contributor
0 Kudos

Hi Roopas,

If the you want to pass the data within views of same component, you dont need custom controller.

Custome controller is used when you want to share one view data with some other view in some other component.

If your case, component controller is fine as you are sharing data within views of same component.

have all context nodes of individual views also at component level and bind view nodes to component nodes.

You then will not have to bother about the data flow. It flows automatically when all same nodes are bound to componet controller nodes

Regards,

Suchita

Former Member
0 Kudos

@Gangadhar,

I tried that Gangadhar, but still no luck ??

@Suchita.

According to this link, Custom Controller is used to pass data between same component and Component Controller to pass data between different components ??

I am stuck with this kindly guide me.

Regards,

RoopaS

Former Member
0 Kudos

Hi Suchita,

The information that you have provided is not correct.

Its the custom controller which helps data to flow int he same component and the component controller which helps data to flow across compoents.PLease ensure you clarify this .

Thanks,

Suvidha

Former Member
0 Kudos

Hi Roopas,

Its the custom controller which helps data to flow int he same component and the component controller which helps data to flow across compoents.

I guess your requirement is to display a srvice req details based on the srv req no that you have entered.

In such a case ,you need to first trigger a search for your onoe order object (which in case of service req is BTQSrvReq).

For the searcg ,pass the entered parameter as the order no.Once the search is triggered,you will get a btorder object as a result.

Now,for this entity call the method,get_related_entities('relation name') and then get the btadminh .Set this atadminh to the custom controller btadminh node and then you will get the enity in the result view as well,since you have bound the result btadminh to the custom contorller.

For refrence ,check and one oredr serach component,for eg BT108S_LEA ,the in the view BT108S_LEA/Search ,check the method

EH_ONSEARCH.Here you will get an idea,how a one order search is triggered.

For any issues you can write back .

Thanks,

Suvidha

Former Member
0 Kudos

Hi Suvidha,

How to get the serivce request number entered by the user, to pass it to the Query ?

@gangadhar rao

When I press enter the value disappears.

Thanks.

Roopa

Former Member
0 Kudos

Hi ,

So now,use the following

lr_current ?= me->typed_context-><context node name>->collection_wrapper->get_current()

lv_attribute = lr_current->get_property_as_string( iv_attr_name = '<attribute name which contains srv req no in the context node>')

so lv_ttribute will now have the srv req no

Suvidha

Former Member
0 Kudos

Hi Nisha,

As per your suggestion, I tried with Query it worked

But, now I am hardcoding the Service Request number.

please guide me on how to get the service request number entered by the user in View 1 and dynamically pass it to the Query.

Regards,

Roopa.

Former Member
0 Kudos

Roopas,

My name is suvidha not Nisha.

And i already told you how to get the srv req no .

Im sure you are triggering the vent in the same view which has the context node where the srv req no is being enetred in the UI.

So you just have to get th eno from the current entity by using the method,

lr_current->get_property( iv_attribute_name ).

here lr_current is your current entity of the context node which contains the srv req no entered by the user.

Suvidha

Former Member
0 Kudos

My apologies Suvidha.

I have created View 1, View 2 and Viewset. I am triggering the event in Viewset.

I think again I am coming back to sqaure one

collection_wrapper->get_current is blank .. I am not able to get lr_current-get_property ??

is there any coding I need to do apart from Binding the views to custom controller ..??

I have done this developement based on some blog in sdn, the blog is completed after binding the views to custom controller.

Sorry for the trouble ..

Regards,

Roopa

Former Member
0 Kudos

Hi Roopas,

You can get the entered value in FORM_FIELDS, not sure its the right approach, but its simple.Get the Entered value here and pass it to the Query you are using.

Regards

R

Former Member
0 Kudos

Thanks R, that worked.

I closing the issue and awarding points to all.

Regards,

Roopas

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi ,

try with ithis

After entering the service request number hit enter and click on display

Regards,

Gangadhar.S

Former Member
0 Kudos

Hi ,

Did you tried with lr_cuco ?= me->get_custom_controller( 'GLOBAL.ZRP_DETAIL/HeaderCuCo' ) instead

of lr_cuco ?= me->get_custom_controller( 'ZRP_DETAIL/HeaderCuCo' ) .

Also what code you have wriiten in create_btadminh in context class of view1 for binding.

Regards,

Gangadhar.S

Former Member
0 Kudos

@Gangadhar.

Yes Gangadhar, I have tried with GLOBAL.ZRP_DETAIL/HeaderCuCo, but still no luck.

Below is the code written in CREATE_BTADMINH.

DATA:

model TYPE REF TO if_bsp_model,

coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,

entity TYPE REF TO cl_crm_bol_entity, "#EC *

entity_col TYPE REF TO if_bol_entity_col. "#EC *

model = owner->create_model(

class_name = 'ZL_ZRP_DETA_FIRST_CN00'

model_id = 'BTAdminH' ). "#EC NOTEXT

BTAdminH ?= model.

CLEAR model.

  • Added by wizard

  • bind Context Node to controller

owner->do_context_node_binding(

iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_CUSTOM

iv_name = 'GLOBAL.ZRP_DETAIL/HeaderCuCo' "#EC NOTEXT

iv_target_node_name = 'BTADMINH'

iv_node_2_bind = BTADMINH ).

@Nisha.

No Nisha, I am getting getting it even when I put that code in DO_PREPARE_OUTPUT ..

Any clues will be highly appreciated

Regards,

Roopa.

Former Member
0 Kudos

Hi ,

binding the context nodes

owner->do_context_node_binding(

iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_CUSTOM

iv_name = 'ZRP_DETAIL/HeaderCuCo' "#EC NOTEXT

iv_target_node_name = 'BTADMINH'

iv_node_2_bind = BTADMINH ).

and also check the context node name in custom contoller whether it is in caps or small letters and give it accordingly in target_node_name

and in view2

use lr_cuco ?= me->get_custom_controller( 'GLOBAL.ZRP_DETAIL/HeaderCuCo' )

Regards,

Gangadhar.S

Former Member
0 Kudos

Hi ,

To your requirement you need to bind the context node (BTAdminH ) of 1st view with the context node of the custom contoller HeaderCuCo in the create_BTAdminH method of the context class of the 1st view

No need to bind the context node of second view with custom controller.

and you can access this in the second view by clicking on display i.e in EH_ONDISP

DATA: lr_cuco type ref to ZL_ZRP_DETA_HEADERCUCO_IMPL,

lr_entity type ref to cl_crm_bol_entity.

lr_cuco ?= me->get_custom_controller( 'ZRP_DETAIL/HeaderCuCo' ) .

CHECK lr_cuco IS BOUND.

lr_entity ?= lr_cuco->typed_context->btadminh->collection_wrapper->get_current( ) .

CHECK lr_entity IS BOUND .

also try with lr_cuco ?= me->get_custom_controller( 'GLOBAL.ZRP_DETAIL/HeaderCuCo' ).

Regards,

Gangadhar.S

Edited by: gangadhar rao on Jan 3, 2011 8:16 AM

Edited by: gangadhar rao on Jan 3, 2011 8:27 AM

Former Member
0 Kudos

Hi Gangadhar,

I have done the binding of context node of view1 with custom controller

But still I am not getting the ref for lr_entity ?

Regards,

Roopa

Former Member
0 Kudos

Dear Experts,

Any Pointers ... I am clueless..

Former Member
0 Kudos

Hi,

Did you bind the data to the context node in the 1st view?

Regards,

madhumitha

nisha_vinod
Advisor
Advisor
0 Kudos

Hi Roopa,

Are you able to access the entity in do_prepare_output of View2? Then instead of the eventhandler of the viewset, you can handle your logic in do_prepare_output of view 2.

Regards,

Nisha