on 01-25-2012 7:23 AM
Hi,
I have created a push button 'NEW' on planned activity of Opportunity. Now after clicking on this push button - I want to call CREATE ACTIVITY view and transfer the opportunity no. in the reference field of activity.
I have created an event for this new button. Can anybody help me - how to call the 'CREATE ACTIVITY' view and how to transfer the opportunity no in activity screen.
Thanks,
just write the code as follows. this is for creating the erporder in runtime. just change it accordingly to create your activity.
lref_core = cl_crm_bol_core=>get_instance( ).
lref_fac = lref_core->get_entity_factory( 'ERPOrder' ).
lt_params = lref_fac->get_parameter_table( ).
ls_params-name = 'AUART'.
ls_params-value = lv_proc_type.
APPEND ls_params TO lt_params.
ls_params-name = 'TRVOG'.
ls_params-value = '0'.
APPEND ls_params TO lt_params.
create ERP sales order entity
lref_btorder = lref_fac->create( lt_params ).
CHECK lref_btorder IS BOUND.
lref_entity_admh ?= lref_btorder->get_related_entity( iv_relation_name = 'ERPOrderHeader' ). "#EC NOTEXT
IF NOT lref_entity_admh IS BOUND.
TRY.
in case the ERPOrderHeader was not yet created.
lref_entity_admh = lref_btorder->create_related_entity( iv_relation_name = 'ERPOrderHeader'). "#EC NOTEXT
CATCH: cx_crm_genil_duplicate_rel cx_crm_genil_model_error.
RETURN.
ENDTRY.
ENDIF.
set the adminh attributes
lref_entity_admh->if_bol_bo_property_access~get_properties( IMPORTING es_attributes = ls_attributes ).
ls_attributes-kunag = lv_partner.
lref_entity_admh->if_bol_bo_property_access~set_properties( ls_attributes ).
first create navigation descriptor and check if navigation is supported
CALL METHOD cl_crm_ui_descriptor_obj_srv=>create_entity_based
EXPORTING
ir_entity = lref_btorder
iv_ui_object_action = lc_ui_action
RECEIVING
rr_result = lref_descriptor_object.
lref_nav_serv = cl_crm_ui_navigation_service=>get_instance( ).
TRY.
check if navigation is supported
IF lref_nav_serv->is_dynamic_nav_supported( ir_descriptor_object = lref_descriptor_object )
= abap_true.
CREATE OBJECT lref_data_collection
TYPE
cl_crm_bol_bo_col.
CHECK lref_data_collection IS BOUND.
lref_data_collection->insert( iv_bo = lref_descriptor_object
iv_index = 1 ).
lref_nav_serv->navigate_dynamically( iv_data_collection = lref_data_collection ).
ENDIF.
CATCH cx_sy_ref_is_initial. "#EC NO_HANDLER
ENDTRY.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have used dynamic navigation by using the following code and it's working perfect.
cl_crm_ui_descriptor_obj_srv=>create_ui_object_based(
EXPORTING iv_ui_object_type = 'BT125_TASK'
iv_ui_object_action = 'D'"'D'
RECEIVING rr_result = lr_nav_descr ).
Now my requirement is to default some values on TASK view. When the Task is opened I want to default the REFERENCE field as opportunity and give the opportunity no.
Now 2 questions;
1- How to get the current opportunity no? (As it's triggered from opportunity screen - from event handler)
2- How to make default values as mentioned above.
Thanks,
Check my reply in below thread how you can save your current opportunity no to a parameter before you click new button and then read that value in your activity and set it in using coding in do_prepare_output method in activity view controller.
http://forums.sdn.sap.com/thread.jspa?threadID=1879031&messageID=9973225#9973225
Thanks,
Shobhit
Thanks for the help.
I have created a new button in BTDOCFLOW/HdrDocFlowOV View, which is different then opportunity view. Now,
1- How to get the current opportunity no; I mean in side this custom event I don't have opportunity no. How to get this..any method for this..any code snippet?
2- How to make the default values - any code snippet for this.
Thanks for your help again.
When you are saving the opportunity, in the save event save the current opportunity no in the parameter using below code
DATA: lr_gdc TYPE REF TO if_crm_ui_data_context.
lr_gdc = cl_crm_ui_data_context_srv=>get_instance( me ).
CALL METHOD lr_gdc->set_data_attribute
EXPORTING
i_value = value
iv_name = 'PARAMETERNAME'.
And to set the default value in your final view you need to read the entity and use the method set_attribute, see one sample
DATA: lr_entity TYPE REF TO cl_crm_bol_enity.
***where lv_value you can get from parameter using code
lr_gdc = cl_crm_ui_data_context_srv=>get_instance( me ).
CALL METHOD lr_gdc->get_data_attribute
EXPORTING
iv_name = 'PARAMETERNAME'
IMPORTING
e_value = lv_value.
lr_entity ?= typed_context->header->collection_wrapper->get_current( ).
lr_entity->set_property( iv_attr_name = 'OPPT_NO' iv_value = lv_value ).
Rgds,
Shobhit
I have followed your the way you suggested but it's not working. I want to set the attribute 'OBJTYPEA' of BT125H_TASK.
I have redefine the set_attribute of BT125H_TASK/TASK_DETAILS View in the following way.
DATA: lr_gdc TYPE REF TO if_crm_ui_data_context.
DATA: lr_entity TYPE REF TO cl_crm_bol_enTity.
***where lv_value you can get from parameter using code
lr_gdc = cl_crm_ui_data_context_srv=>get_instance( me ).
lr_entity ?= typed_context->BTDOCFLOW->collection_wrapper->get_current( ).
lr_entity->set_property( iv_attr_name = 'OBJTYPEA' iv_value = 'OPPORTUNIT' ).
CALL METHOD SUPER->SET_ATTRIBUTE
EXPORTING
NAME = 'OBJTYPEA'
VALUE = 'OPPORTUNIT'
.
Please suggest.
Thanks,
Edited by: WD ABAP on Feb 8, 2012 7:05 AM
set_attribute method is never called. I put a break point but its not being called. Then I put the same code in prepare_output method. But did not worked. Then I put the following code in prepare_output and it worked.
me->typed_context->btdocflow->set_objtypea( attribute_path = 'OBJTYPEA'
value = 'OPPORTUNIT' ).
Please let me know if there is problem putting this code in prepare output method.
Now can you please let me know how to get current opportunity no? I need to populate opportunity/reference value field with number.
Thanks,
I wrote this code and it's working in BT125H_TASKDETAILS-DO_PREPARE_OUTPUT;
me->typed_context->btdocflow->set_objtypea( attribute_path = 'OBJTYPEA'
value = 'OPPORTUNIT' ).
But to populate the value field, I wrote the following code which is not working;
me->typed_context->btdocflow->set_objkeya( attribute_path = 'OBJKEYA'
value = lv_value ).
I need to press enter on the task screen in order to get the key attribute ('OBJKEYA') worked. When I press enter on the task screen - it populates the opportunity no in the reference field. How can I do it without pressing the ENTER.
If I write the following code in prepare_output
lr_entity ?= typed_context->btdocflow->collection_wrapper->get_current( ).
lr_entity->set_property( iv_attr_name = 'OBJKEYA' iv_value = lv_value ).
I get the below exception. Please help.
Procedure for System Administration
Activate checkpoint group BSP_WD_EXCEPTION_DISPLAY. To do this, use transaction SAAB. If the error recurs, further details are displayed.
Exception Details
CX_CRM_CIC_PARAMETER_ERROR - Entry parameter of method CL_CRM_BOL_ENTITY->SET_PROPERTY contains value OBJKEYA, which is not allowed
Method: CL_CRM_BOL_ENTITY=>IF_BOL_BO_PROPERTY_ACCESS~SET_PROPERTY
Edited by: WD ABAP on Feb 9, 2012 6:01 PM
This code is written in do_prepare_output method of class ZL_BT125H_T_TASKDETAILS_IMPL. I want to pre-populate the 'Reference' with 'Opportunity' and Opportunity no.
With this code - it's working BUT I need to hit ENTER on the task screen then it works.
CALL METHOD super->do_prepare_output.
DATA: lr_gdc TYPE REF TO if_crm_ui_data_context.
DATA: lr_entity TYPE REF TO cl_crm_bol_entity.
DATA: lv_value TYPE string." TYPE i.
**
*****where lv_value you can get from parameter using code
lr_gdc = cl_crm_ui_data_context_srv=>get_instance( me ).
** lr_entity ?= typed_context->btdocflow->collection_wrapper->get_current( ).
** lr_entity->set_property( iv_attr_name = 'OBJTYPEA' iv_value = 'OPPORTUNIT' ).
me->typed_context->btdocflow->set_objtypea( attribute_path = 'OBJTYPEA'
value = 'OPPORTUNIT' ).
CALL METHOD lr_gdc->get_data_attribute
EXPORTING
iv_name = 'OBJKEYA'
IMPORTING
e_value = lv_value.
me->typed_context->btdocflow->set_objkeya( attribute_path = 'OBJKEYA'
value = lv_value ).
My 2nd question is :
I want to get the current opportunity no which I will use in taskdetails view to populate the field. I am writting below code on my CUSTOM Event "ONNEWT"
DATA: lr_entity TYPE REF TO cl_crm_bol_entity.
DATA: lv_value TYPE string.
**
lr_entity ?= typed_context->btadminh->collection_wrapper->get_current( ).
lr_entity->get_object_id( iv_attr_name = 'STRUCT.OBJECT_ID' iv_value = lv_oppor ).
This is the syntax error which I am getting;
Field "BTADMINH->COLLECTION_WRAPPER->GET_CURRENT(" is unknown. It is
not contained in one of the specified tables nor is it defined by a
"DATA" statement.
Hi,
In your code you are getting the value from gdc but first you need to set it somewhere maybe when you click on New button and set the gdc parmeter with your opportunity number. Also the parameter which you will use you should define it in spro customizing to use gdc or use some existing parameter. It is similar to memory id in abap but not same.
The functionality which you want to use is same as from account screen you can create an opportunity by clicking on New button and SAP standard populates some data from BP. Similar scenario you need to implement. I suggest check the SAP coding and look in to EH_ONNEW method of Comp/view: BP_BPBT/AccountOpportunitiesOV for clear understanding.
Rgds,
Shobhit
I could not get that.
I am in new custom event of BTDOCFLOW which is view for PLANNED ACTIVITIES on Opportunity Screen.
BTDOCFLOW/HdrDocFlowOV
I have created a New button.
I want to get current opportunity no in my custom event code - any way I can get this?
Thanks,
Edited by: WD ABAP on Feb 10, 2012 5:41 PM
Since both are 2 different component you can user component controller to get the opportunity id (you can find many post how to fetch data using component controller) http://forums.sdn.sap.com/thread.jspa?threadID=2014259
Rgds,
Shobhit
Edited by: Shobhit Srivastava on Feb 10, 2012 3:46 PM
I created the component usage and followed the link which you have mentioned. Added the context node 'BTADMINH' in BTDOCFLOW(On both component level and View level) and did the binding in WD_USAGE_INITIALIZE. But when i try to access the attrubite of BTADMINH in one of the event of 'BTDOCFLOW/HdrDocFlowOV' then I get syntax error.
--->>>lr_entity ?= lr_comp->typed_context->btadminh->collection_wrapper->get_current( ).
Field "BTADMINH->COLLECTION_WRAPPER->GET_CURRENT(" is unknown. It is not
contained in one of the specified tables nor is it defined by a "DATA"
statement. "DATA" statement.
Thanks,
I found a little hint - may be you can help me
DATA: lr_comp TYPE REF TO zl_btdocflo_bspwdcomponen_impl.
lr_comp ?= me->comp_controller.
lr_comp->typed_context->btadminh->get_object_id( EXPORTING attribute_path = 'OBJECTID' " correct
RECEIVING value = lv_oppor ).
The problem is when I double click on above line(On BTADMINH) in editor it says - 'BTADMINH' does not exist. Infact it is still going to standard context class to see whether BTADMINH exist or not. But BTADMINH was created in ZL_xxxxxxxxxxx__CTXT.
I cross checked the BTADMINH in ZL_xxxxxxxxxxx__CTXT and it does exists.
What change should i make so that it will tell the system that BTADMINH is part of ZL_xxxxxxxxxxx__CTXT class not the standard class.
Please suggest.
Thanks,
Edited by: WD ABAP on Feb 14, 2012 1:20 AM
Edited by: WD ABAP on Feb 14, 2012 1:21 AM
when i replaced typed_context with ztyped_context -now atleast syntax error is gone.
Now the problem is with binding/comp usage;
In the first component (from where I want to get the opportunity no) I have created a BTADMINH context node in interface controller and in WD_USAGE_INITIALIZE method - wrote the following code;
WHEN 'CUBTDocFlow_CA'.
CALL METHOD iv_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = 'BTADMINH'.
But when I open the opportunity I get the following exception
Cannot display view BT111H_OPPT/Details of UI Component BT111H_OPPT
An exception has occurred Exception Class CX_BSP_WD_INCORRECT_IMPLEMENT - The view controller or custom controller "" was implemented incorrectly
Method: CL_BSP_WD_COMPONENT_USAGE=>IF_BSP_WD_COMPONENT_USAGE~BIND_CONTEXT_NODE
Source Text Row: 24
Edited by: WD ABAP on Feb 14, 2012 8:24 PM
Create binding of BTADMINH context nodes to component controllers of both views. Also use below code to bind other component.
CALL METHOD iv_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>CO_TYPE_COMPONENT
iv_name = 'Component name/component usage name'
iv_target_node_name = 'BTADMINH'
iv_node_2_bind = 'BTADMINH' .
Rgds,
Shobhit
You need to expose the source component in the interface controller in RuntimeRep and in the destination component i.e. BTDOCFLOW you need to make component usage of BT125H_TASK and should implement method wd_usage_initialize in BTDOCFLOW component. This makes BT125H_TASK data i.e. Oppt no. available in BTDOCFLOW.
I hope you are doing the same or is it other way around.
Rgds,
Shobhit
Thanks for the reply. I will check the options which you have suggested. For the time being - I am able to get the current opportunity ID from one of the attribute from PARENTNODE context node. So for the time being I don't need to read it from external component.
However, I have one more problem which I explained earlier and below is the way you responded
copy paste your do_prepare_output code, also which field your are trying to populate in task, if it's a reference object assignment block field then you should write your code in view BT125H_TASK/RefObjectsEF or BT125H_TASK/RefObjectsView.
Rgds,
Shobhit
Yes, the assignment block where I want to put the defualt value is 'REFERENCE'. But when I try to put the same code in do_prepare_output of the views which you have mentiond (BT125H_TASK/RefObjectsEF or BT125H_TASK/RefObjectsView). The debugger is not going into this code. Do I need to put somewhere else other than do_prepare_output.
Thanks,
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.