Wednesday, April 17, 2013

SAP CRM add message Web UI




lr_msg_srv  type ref to cl_bsp_wd_message_service.
 lr_msg_srv = me->view_manager->get_message_service( ).
    lr_msg_srv->add_message( iv_msg_type   = 'I'
                             iv_msg_id     = 'CRM_UIU_SEARCH'
                             iv_msg_number = '001'  ).

SAP CRM Advanced Query




  CALL METHOD cl_crm_advs_qheader_list=>create
    EXPORTING
      is_header_data = ls_qheader
    IMPORTING
      ev_guid        = lv_qid.

  ls_qterm-fieldname ='PROSPECT'."'CURR_PHASE'.
  ls_qterm-sign = 'I'.
  ls_qterm-operator = 'EQ'.
  ls_qterm-low = '1'.

  CALL METHOD cl_crm_advs_qterm_list=>create
    EXPORTING
      iv_header_guid = lv_qid
      is_attributes  = ls_qterm.


  DATA lv_catguid TYPE comt_category_guid.

  SELECT SINGLE category_guid FROM comv_cat_hiernew
         INTO lv_catguid
         WHERE category_id = ls_selected_pr-dkey.
  IF sy-subrc IS INITIAL.
    ls_qterm-fieldname ='PROD_HIERARCHY'.
    ls_qterm-sign = 'I'.
    ls_qterm-operator = 'EQ'.
    ls_qterm-low = lv_catguid.

    CALL METHOD cl_crm_advs_qterm_list=>create
      EXPORTING
        iv_header_guid = lv_qid
        is_attributes  = ls_qterm.

  ENDIF.

  CALL METHOD cl_ppm_dyns_filter_impl=>fire_query
    EXPORTING
      iv_queryid    = lv_qid
    IMPORTING
      ev_bol_entity = lr_opp_col.

SAP CRM Dynamic query






DATA: lr_core TYPE REF TO cl_crm_bol_core,
  lr_query TYPE REF TO cl_crm_bol_dquery_service,
  lr_result TYPE REF TO if_bol_entity_col.
  "lr_entity TYPE REF TO cl_crm_bol_entity.


  lr_core = cl_crm_bol_core=>get_instance( ).
  lr_core->load_component_set( 'BTBP' ).

  lr_query = cl_crm_bol_dquery_service=>get_instance(
  iv_query_name = 'BTQOpp' ).


  CALL METHOD lr_query->add_selection_param
    EXPORTING
      iv_attr_name = 'PROSPECT'
      iv_sign      = 'I'
      iv_option    = 'EQ'
      iv_low       = '0001000426'
*     iv_high      =   iv_high
    .

  lr_opp_col = lr_query->get_query_result( ).

Tuesday, April 2, 2013

Lifetime of a static class/variable

Ever felt a need to keep the values in a static class for a longer time before the garbage collector picks it up....

Here is an excerpt from SAP Help to achieve this

http://help.sap.com/saphelp_nw70/helpdata/en/c3/225b5f54f411d194a60000e8353423/content.htm


Object Lifetime

An object exists for as long as it is being used in the program. An object is in use by a program for as long as at least one reference points to it, or at least one method of the object is registered as an event handler.
As soon as there are no more references to an object, and so long as none of its methods are registered as event handlers, it is deleted by the automatic memory management (garbage collection). The ID of the object then becomes free, and can be used by a new object.



The trick is make your class an event handler for a Event of the main object - and yes this only works if there is some main object.