Skip to Content

Introduction

Created Custom Component to Dynamically Search the One Order Documents in the system. From page navigated to the overview page of the one order Document and navigate back. After this added Value of the User Accessing the Page to Search by User by default. Created Functionality of Edit and Save the Header of 1Order.

Created an Component: Z1ORD_ADVSEARCH

BOL Object used: BTOrder (Root Object) , BTQ1Order (Dynamic Query Object), BTQR1Order (Result Object), BTAdminH (Header Access Object)

Model Used in Component: BT (Business Transaction)

/wp-content/uploads/2016/07/11_scn_993285.jpg

In this Component Create Search View using ‘Empty View’ and object BTQ1Order & BTQR1Order (No need to define any higher level node). Result View would be an ‘Table View’ with BTOrder & BTQR1Order (BTQR1Order should be higher level node with relation).


Made a Custom Controller QueryCuCo. In The Search View Created the Binding between BTQR1Order with the Custom Controller context node BTQR1Order.

/wp-content/uploads/2016/07/22_scn_993286.jpg

In Result View created the binding of context node BTQR1Order with the custom controller context node BTQR1Order.

/wp-content/uploads/2016/07/33_scn_993287.jpg


Put both of these Views in a ViewSet. Set the Proper View Area.


Added this view set into MainWindow  and made it as By default.


/wp-content/uploads/2016/07/44_scn_993288.jpg

In Search View IMPL Class made CL_BSP_WD_ADVSEARCH_CONTROLLER as Super Class and in Context Node BTQ1Order CN00 Class made the super class as CL_BSP_WD_CONTEXT_NODE_ASP. Did the coding of HTM Page on Search View and set the attributes as below :

                        id                = “advs0”
fieldMetadata     = “<%= controller->GET_DQUERY_DEFINITIONS( ) %>”
header            = “<%= BTQ1ORDER->get_param_struct_name( ) %>”
fieldNames        = “<%= controller->GET_POSSIBLE_FIELDS( ) %>”
values            = “//BTQ1ORDER/PARAMETERS”
maxHits           = “//BTQ1ORDER/max_hits”
onEnter           = “search”
ajaxDeltaHandling = “false”


For the Search Button , created the event ‘Save’ in IMPL Class of Search View.


/wp-content/uploads/2016/07/55_scn_993289.jpg

In this Event write the code to set collection according to the result got.


data: lr_qu_serv TYPE REF TO cl_crm_bol_dquery_service,
lr_res
TYPE REF TO if_bol_bo_col.

lr_qu_serv ?=

me->typed_context->btq1order->collection_wrapper->get_current( ).
lr_res = lr_qu_serv ->get_query_result( ).
IF lr_res is not Initial.
me->typed_context->btqr1order->set_collection( lr_res ).

endif.


Page to dynamically search all the One Order Business Transaction in the system would be like this:


/wp-content/uploads/2016/07/66_scn_993293.jpg


In the Search Criteria set the ‘Created By’ field to the User’s name who is accessing the OVP. So the Search Result will be coming for that user by default.

/wp-content/uploads/2016/07/1_993295.jpg

For this requirement redefined and coded the Method BUILD_PARAMETER_TAB of Class *CN00 of BTQ1ORDER context Node in Search View.


/wp-content/uploads/2016/07/77_scn_993299.jpg

Code in BUILD_PARAMETER_TAB will be like below:


method BUILD_PARAMETER_TAB.
CALL METHOD SUPER->BUILD_PARAMETER_TAB  .

data: LS_PAR_temp type CRMS_THTMLB_SEARCH_CRITERION.
data: WA_ME LIKE LINE OF ME->PARAMETERS.
data: LS_PAR type CRMS_THTMLB_SEARCH_CRITERION.
Data: lt_para type CRMT_THTMLB_SEARCH_CRITERION.

loop at me->parameters into LS_PAR_temp.
if LS_PAR_temp-field = ‘CREATED_BY’.
LS_PAR_temp-VALUE1 = sy-uname.
endif.
append LS_PAR_temp to lt_para.
endloop.

refresh me->parameters.

move lt_para to me->parameters.
* Adjust criteria to reflect UI guidline
ME->ADJUST_CRITERIA_CONTEXT2UI(
changing CT_CRITERIA_UI = ME->PARAMETERS ).
endmethod.


Getting the Result for the User by using the Event Handler.


/wp-content/uploads/2016/07/2_993300.jpg

For this got the Instance of Class cl_crm_bol_dquery_service and through instance get the result objects. Through this result object set the Collection of BTQR1ORDER Object.

To show the Header data of the business transaction created another view (Form View) with Object BTOrder and BTADminH. BTOrder would be the higher level Node.

Bind the BTOrder context Node of this View with the custom Controller Node BTOrder.

Put this view into an Overview Page so that it can be seen on screen.

/wp-content/uploads/2016/07/88_scn_993301.jpg

Created the Hyperlink and Navigation to navigate to Header Component of 1Order Transaction.

/wp-content/uploads/2016/07/3_993305.jpg

For this Redefine the GET_P Method of BTQR1Order Attribute to set the Field Property as Hyperlink.

/wp-content/uploads/2016/07/99_scn_993306.jpg

In the Result View Created the Outbound Plug and in Runtime Repository a Navigational Link.

In Outbound Plug pass the Navigation Link name through the View Mnager.

In Result View created an Event ‘Select’ .

In this Event get the Index of the selected row and accordingly find the Entity through Find() Iterator . To get the Index of object which is selected here used the method get_event_info() of class cl_thtmlb_util. Through this index , get the Entity.

DATA: lv_index       TYPE int4,
lr_entity     
TYPE REF TO cl_crm_bol_entity, 

lr_collection  TYPE REF TO if_bol_bo_col.


CALL METHOD cl_thtmlb_util=>get_event_info
EXPORTING
iv_event = htmlb_event_ex
IMPORTING
ev_index = lv_index.
*    set entity as current one
lr_entity ?= me->typed_context->btqr1order->collection_wrapper->find( iv_index = lv_index ).


Later on added this Entity to Collection through Add(). And passed this to Outbound Plug.

CHECK lr_entity IS BOUND.

me->typed_context->result->collection_wrapper->publish_current( ).

CREATE OBJECT lr_collection TYPE cl_crm_bol_bo_col.
CHECK lr_collection IS BOUND.

lr_collection->add( lr_entity ).
op_Todetails( iv_data_collection = lr_collection ).


Header details of the Selected Document.


/wp-content/uploads/2016/07/4_993308.jpg

Edit and Save the data at BOL.


/wp-content/uploads/2016/07/5_993309.jpg

Created the Event EDIT & SAVE

Wrote the Code of EDIT as Below :

method EH_ONEDIT.

DATA   lr_entity  TYPE REF TO cl_crm_bol_entity.

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

IF lr_entity->is_locked( ) = abap_false.
lr_entity->lock( ).
ENDIF.
view_group_context->set_view_editable( me ).

endmethod.

Wrote the Code of SAVE as Below :

method EH_ONSAVE.

DATA: lr_ent  TYPE REF TO cl_crm_bol_entity,
lr_co   
TYPE REF TO cl_crm_bol_core,
lr_txn_con     
TYPE REF TO if_bol_transaction_context.

lr_ent ?= me->typed_context->btadminh->collection_wrapper->get_current( ).
lr_txn_con ?= lr_ent->get_transaction( ).
IF lr_txn_con IS NOT BOUND.
lr_co = cl_crm_bol_core=>get_instance( ).
lr_txn_con = lr_co->begin_transaction( ).
ELSE.
IF lr_txn_con->check_save_possible( ) = abap_true.
CHECK lr_txn_con->save( ) EQ abap_true.
lr_txn_con->commit( ).
ENDIF.
ENDIF.
me->view_group_context->reset( ).

endmethod.

To Rename the Component name :

/wp-content/uploads/2016/07/6_993310.jpg

Redefine the Method IF_BSP_WD_HISTORY_STATE_DESCR~GET_STATE_DESCRIPTION of IMPL Class of the View.

method IF_BSP_WD_HISTORY_STATE_DESCR~GET_STATE_DESCRIPTION.
CALL METHOD SUPER->IF_BSP_WD_HISTORY_STATE_DESCR~GET_STATE_DESCRIPTION
EXPORTING
IV_CURRENT_DESCRIPTION = IV_CURRENT_DESCRIPTION
RECEIVING
DESCRIPTION            =  DESCRIPTION
.
description =
‘Details of 1 Order Header’.

endmethod.

For the Search Page ::

method IF_BSP_WD_HISTORY_STATE_DESCR~GET_STATE_DESCRIPTION.
CALL METHOD SUPER->IF_BSP_WD_HISTORY_STATE_DESCR~GET_STATE_DESCRIPTION
EXPORTING
IV_CURRENT_DESCRIPTION = IV_CURRENT_DESCRIPTION
RECEIVING
DESCRIPTION            = DESCRIPTION
.

description = ‘All 1Order Docs Dynamic Search’.
endmethod.

For this Requirement Used Concept :

  • Creation of Custom Component (Creation of all the three types of views , Model Nodes).
  • Context Node Binding (with Custom and Component Controller)
  • Redefined many Methods. i.e. Setter/Getter, Do_prepare_Output, Do_Init_Context, Build_Parameter_Tab etc….
  • Navigations.
  • Basic Programming of BOL.
  • Configurations
  • Event Buttons and Handling.
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply