cancel
Showing results for 
Search instead for 
Did you mean: 

Adding 'Create' button on the Assignment block of the Overview Page

Former Member
0 Kudos

Hello Friends,

On the Account Overview Page (BP_HEAD), i have added the Custom Assignment Block (Contracts) by creating a Z view. Now we have a requirement to add the 'Create' button on the Contracts assignment block. so that by clicking the 'Create' button, the Contract creation page should be displayed and Also it should be linked to the Account.

Friends how should i proceed in this case. please help me out.

Accepted Solutions (1)

Accepted Solutions (1)

dharmakasi
Active Contributor
0 Kudos

Hi Dev,

Your requirement seems like item assignment block to item over view page relationship.

You can use component usage and navigation links concepts to achieve this requirement.

There is similar functionality existed in sap standard system. Check the component BT115QIT_SLSQ and view ItemsOV. Here we have a event called EH_ONNEW, which is used to create a new item by navigation to item overview page.

New button is displayed as a toolbar button in an assignment block, once user clicks on it system will navigate to overview page of the items. I hope your requirement also similar to this one.

Let us know if you need more clarifications.

Best Regards,

Dharmakasi.

Former Member
0 Kudos

Hello Dharmakasi/Deepika,

Thanks for your prompt reply.

My requirement is to add the button on Contracts Assignment block on the Account Overview Page.

when we click on the Create button, it should navigate to the Create Contract page and under the Business Partner block on the Contract Creation page, it should link the Account No from which we navigated.

Please help me out. how should i implement this requirement.

former_member210661
Active Contributor
0 Kudos

Hi Dev,

the same requirement you can observe in standard assignment block in corporate Account.

i will give you guidance how to create button and how to navigate from one component to another.

creating button:

Create toolbar button we have to declare attribute type crmt_thtmlb_button_t in impl class.

write the logic in do_prepare_output.

DATA: ls_button            TYPE crmt_thtmlb_button.


REFRESH : gt_view_button.

  ls_button-id = 'NAVIGATE_TO_TARGET'.
ls_button
-on_click = 'NEW'.
ls_button
-text = 'New'.
ls_button
-enabled = 'X'.

ls_button-type     = cl_thtmlb_util=>gc_icon_new.
APPEND ls_button TO gt_view_button.
CLEAR ls_button.
ENDMETHOD.



then go to .htm change like this


in  actions field provide like this "<=% controller->gt_view_button %>"

then you can see the button in your account ov.


now the task is when you click on that button you need to open create contract page.

so first of all you have to identify the component name of create contract. if you want to use one component in other component then you should define component usag.


calling create contract view.


when new button click one event gets generated so create one event.

on your account block.



write the logic like this.


1.first to get the account over view context node and lock that entity.

2.then create your create contract relation using create_related_entity.

3.then get the entity of your(contract view cnode) context node info.

4. add entity info to your context node.

5. get the component controller instance because when ever your are enter any info into contract view that field info will available in other component.

here we are navigating from one view to other view.


DATA: lr_window      TYPE REF TO cl_bsp_wd_window,

         lr_entity      TYPE REF TO cl_crm_bol_entity,

         lr_current     TYPE REF TO cl_crm_bol_entity,

         lv_collection  TYPE REF TO cl_bsp_wd_collection_wrapper,

*        lv_index       TYPE int4,

         lr_col         TYPE REF TO if_bol_bo_col,

         lr_coco        TYPE REF TO cl_bp_addr_bspwdcomponent_impl,

         lv_addr_time_dependant TYPE bu_development_active,

         lv_date_from   TYPE bu_datfrom,

         lv_date_to     TYPE bu_datto.


"1. step

* lock current business partner

   lr_entity ?= typed_context->accont contextnode->collection_wrapper->get_current( ).

   IF lr_entity->lock( ) = abap_true.

     TRY.

"2nd step

         lr_entity = lr_entity->create_related_entity(

          iv_relation_name = 'contract rel name' ).

       CATCH cx_crm_genil_model_error cx_crm_genil_duplicate_rel.

*               should never happen

     ENDTRY.


"4th step

      typed_context->contract cnode->collection_wrapper->add( iv_entity = lr_entity

                                                            iv_set_focus = abap_true ).

"5th step

*     Add & set focus at component controller

       lr_coco ?= me->comp_controller.

       lr_coco->typed_context->address->collection_wrapper->add(

                               iv_entity = lr_entity

                               iv_set_focus = abap_true ).


       lr_coco->typed_context->address->collection_wrapper->find( iv_bo = lr_entity ).


"6th step.

navigation get the window instance

*      RAISE EVENT history_trigger.

       lr_window = me->view_manager->get_window_controller( ).

       CREATE OBJECT lv_collection.

       lv_collection->add( iv_entity = lr_entity

                           iv_set_focus = abap_true ).

       lr_window->call_outbound_plug( iv_outbound_plug = 'outbound plug name'

                                      iv_data_collection = lv_collection ).


go through this doc.



if you want to know more about how to navigate then go to BP_ADDR/CorpAccountAddressesOV in that there an event EH_ONNEW . observe that then you can come to know..


Thanks & Regards,

Srinivas.

Former Member
0 Kudos

Thank you very much for your Detailed reply Srinivas.

I have 1 question why you have added the 4th step?

As, when we are creating an dependent entity using the relation it is creating the entity with blank values. and as per your 4th step we are adding the blank entity in the Contracts assignment block before creating the Contract on the new page.

Also, if user clicks on the Contract creation page, then how will we remove the blank entity on the Contracts Assignment block which you added in the 4th Step.

Please clarify my above doubts and let me know my shortcomings for the same.

Answers (1)

Answers (1)

deepika_chandrasekar
Active Contributor
0 Kudos

HI,

You can create a button for Create and on click event navigate to New View for Contract ( create new view for this) using Navigation link under Run time Repository. In new view create button 'save' and 'save and back'

1.On  'save' event save the relation

2. On 'save and back' event save the relation and navigate bac to Account page.

Creating relation you need to use create_related_entity if your contract entity is bol entity.

Regards,

Deepika.