cancel
Showing results for 
Search instead for 
Did you mean: 

save functinality for a zcomponent (table view)

Former Member
0 Kudos

Hi ,

I have created a zcomponent with a table view in it.

i have include the zcomponent(table view) in BP page.

Now when i press on save button of BP page ,i need to save the data entered in the custom table view.

so i need to redefine the save evenet (which is there in bp_head).

How could i access the conents of table view in bp_head?

thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can do this way.

1. As you have used the component usage, enhance the component controller of the BP.

2. Add the same context node in the component controller.

3. Redefine the method WD_USAGE_INITIALIZE of the comp controller of the bp and bind both the context nodes.

(i.e custom component context node and component controller context node). Do not forget the uncomment the super class method call as it contains all the existing bindings.

4. So in the save event of the overview page, you just access the component controller which is available.

(me->COMP_CONTROLLER).

5. Go to its attribute TYPED_CONTEXT and you will get your custom table view entity.

6. Save your entity with your custom codes. Do not interrupt the savings of the standard code. (You can save your custom bol after you super class call finished)

Former Member
0 Kudos

Thanks ,

IN BP page i need a table view with 3 coloumns .

The data which i need to display in table is taken from

BP_DATA/AccountRelationshipsOV

Where should be the vie created in BP_DATA/BP_HEAD

and how can i accesss AccountRelationshipsOV and populate in my table.

Former Member
0 Kudos

I have redefined the method

WD_USAGE_INITIALIZE

DATA: lr_usage_data TYPE REF TO cl_bsp_wd_context_node.

super->wd_usage_initialize( iv_usage = iv_usage ).

CASE iv_usage->usage_name.

WHEN 'CU_ZBTV2'.

DATA:

lr_node1 TYPE REF TO ZL_ZTBV2TBV_COST_CN00 ,

lr_node2 TYPE REF TO ZL_ZTBV2TBV_COMPROFILE_CN00 .

lr_node1 ?= iv_usage->get_context_node( iv_cnode_name = 'COST' )."#EC NOTEXT

lr_node2 ?= iv_usage->get_context_node( iv_cnode_name = 'COMPROFILE' )."#EC NOTEXT

iv_usage->bind_context_node( iv_controller_type = cl_bsp_wd_controller=>co_type_component

iv_target_node_name = 'BUILHEADER'

iv_node_2_bind = 'PARTNER' ).

ENDCASE.

BUILHEADER is the node which i have created in my zcomponent.

now in save event how can i access the data of my zcomponent.

Former Member
0 Kudos

To answer ur qs

ideally u should create ur own custom component and add it in the standard BSP component using component usage.

The other way is create the view in the same standard component in which u want to display.

So if you want to display ur custom view in BP_HEAD/BPHEADOverview, create ur custom view there or create the custom bsp component separately and add here thru comp usage.

let me know in which overview page u want to integrate ur custom view. accordingly the data needs to be bound.

Former Member
0 Kudos

The ideal code should look like this .. where BUILHEADER is the context node in the component controller

and PARTNER is the context node in the custom component. Remember that the context node name in '' should match the exact name as it is declared in the method create_++++++ method. check in debugging if binding works.

e.g.

lr_model = owner->create_model( class_name = 'CL_BT112H_S_BSPWDCOMPONEN_CN01'

model_id = 'BTAdminH' ). "#EC NOTEXT

wd_usage code should be like this.

CHECK iv_usage IS BOUND.

CASE iv_usage->usage_name.

WHEN 'CU_ZBTV2'.

iv_usage->bind_context_node( iv_controller_type = cl_bsp_wd_controller=>co_type_component

iv_target_node_name = 'BUILHEADER' "

iv_node_2_bind = 'PARTNER' ).

WHEN OTHERS.

CALL METHOD super->wd_usage_initialize

EXPORTING

iv_usage = iv_usage.

ENDCASE.

if binding is success. go the save method

access the component controller code like this

data: lv_comp_controller type ref to CL_BSP_WD_COMPONENT_CONTROLLER." u might have to change this to refer to the zclass of the comp controller.

lv_comp_controller ?= me->COMP_CONTROLLER.

  • then access the partner context node of the comp controller like below

lcl_ent ?= lv_comp_controller->typed_context->partner->collection_wrapper->get_current( ).

Former Member
0 Kudos

Thanks again ,

ok i have created a view in BP_HEAD .

Now how to access the data ...

I mean i have to retrive the values from the relationship block ,i need the employee responsible and thre relationship type for the BP to be displayed in table view.

How can i do.

please help me with the steps.

Former Member
0 Kudos
  • assuming that lcl_ent1 is builheader entity. use the below mentioned code to get the values. Check lv_str and you will find

  • all the data u need .. For further info, go to tcode bol_model_browser. Enter BP and display. Go to root object BUILHEADER and check its relation. U will find the relation .. BuilEmplResponsRel.. See the attribute structure to understand which fields are available.

DATA: lv_str type CRMT_BUPA_IL_RELATION.

IF lcl_ent1 IS BOUND. " this must be buildheader entity

lcl_ent2 = lcl_ent_btadminh->get_related_entity( 'BuilEmplResponsRel' ).

if lcl_ent2 is bound.

lr_ent2->get_properties( IMPORTING es_attributes = lv_str ).

endif.

ENDIF.

Former Member
0 Kudos

Thnaks ,

i used component controller

lr_customctrl ?= me->get_custom_controller( controller_id = 'BP_HEAD/bpHead' )."#EC NOTEXT

lr_template ?= lr_customctrl->typed_context->BUILHEADER->collection_wrapper->get_current( ).

lr_entity ?= lr_template.

lr_ent1 = lr_entity->get_related_entities( iv_relation_name = 'BuilRelationshipICRel' ).

lr_entd ?= me->typed_context->DIST->collection_wrapper->get_current( ).

lr_entc = lr_ent1->get_first( ).

while lr_entc IS BOUND.

role = lr_entc->get_property_as_string( 'RELATIONSHIPCATEGORY' ).

and got the requried values.

Now i need to populate into the table view ?

how can i add.

if i have 3 values.... 1 2 3

1

2

3

how can i add these values to table view?

Former Member
0 Kudos

This code need to be written in the on_new_focus method of the table view context node class and call the on_new_focus from the create_xxx method at the end. (xxx is the table context node name)

  • assuming the table has 3 columns x1, x2 , x3

TYPES: BEGIN OF x_test,

x1 TYPE test,

x2 TYPE sy-datum,

x3 TYPE test1,

END OF x_test.

DATA: ls_test TYPE x_test,

li_test TYPE STANDARD TABLE OF x_test,

lr_tabline TYPE REF TO x_test,

lr_col TYPE REF TO if_bol_bo_col,

lr_valuenode TYPE REF TO cl_bsp_wd_value_node.

  • create collection object to transfer data

CREATE OBJECT lr_col

TYPE

cl_crm_bol_bo_col.

DO 3 TIMES. " in actual code use the internal table or something else.

"...create line object

CREATE DATA lr_tabline.

"...create value object with current line for colleciton

CREATE OBJECT lr_valuenode

EXPORTING

iv_data_ref = lr_tabline.

ls_test-x1 = 'test1'.

ls_test-x2 = 'test2'.

ls_test-x3 = 'test3'.

lr_valuenode->set_properties( ls_test ).

"...add current line to collection

lr_col->add( lr_valuenode ).

ENDDO.

  • set collection

me->set_collection( lr_col ).

Former Member
0 Kudos

Thanks for your kind help..

sloved the problem.

could you please explain me one thing like...

BP = lr_entc->get_property_as_string( 'PARTNER1' ).

CALL FUNCTION 'CRM_BUPA_DESCRIPTION_READ'

EXPORTING

iv_partner = BP

IMPORTING

ev_description = lv_description_name

EXCEPTIONS

OTHERS = 0.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = BP

IMPORTING

OUTPUT = BP.

lr_entd->set_property(

iv_attr_name = 'NAME1'

iv_value = lv_description_name ).

SELECT SINGLE partner2 FROM but050 INTO lv_partner

WHERE PARTNER1 = BP and RELTYP = 'BUR011'.

i want the employee responsible for the BP. Im doing it in BP_HEAD ,owm created view.

actually i have used select stement over here..how can i replace this this get_related or any other ?

Former Member
0 Kudos

HI,

In my earlier post, i have mentioned how to retrieve the emp resp from builheader entity.. what is the lr_entc entity ??if it is builheader you can use the below mentioned code.

DATA: lv_str type CRMT_BUPA_IL_RELATION.

IF lcl_ent1 IS BOUND. " this must be buildheader entity

lcl_ent2 = lcl_ent1->get_related_entity( 'BuilEmplResponsRel' ).

if lcl_ent2 is bound. " this is the emp resp entity...

lr_ent2->get_properties( IMPORTING es_attributes = lv_str )." you can retrieve the partner2 directly..

  • in lv_str, partner2 will be the employee responsible...

endif.

ENDIF.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

The best possible solution would be is to add the table with EEWB(you can also use AET if you are on EHP1). Once you add a table and bring it on to the UI by doing post processing for EEWB, the whole save, create, modify and reading of the values will be taken care by SAP itself. Hassle free.

Thanks!!

Bhargava.