cancel
Showing results for 
Search instead for 
Did you mean: 

How to set default value in CRM WebUI for BID Product list -> Quantity field

Former Member
0 Kudos

Hi,

I need to set default value as '1' in Quantity field for the new item/entries in product ->edit list for BIDS in WEbUI.

Please guide me the steps/logic .I identified the bsp component 'BT130I_OPPT'  and by setting breakpoint at do_handle_event,I 'was able ti track the event.

By means of F2 button,I can see product ->edit list - > new line item -> Quantity field belongs to BTSchedulin View and struct.quantity attribute.

Can someone locate me ,where exactly i should write my code logic,to display value as '1' in quantity field of line item ,whenever new entry is made in Product -> edit list of BID in CRM WeUI

Thanks in Advance and awaiting quick response.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Srividhya,

You can code that in DO_PREPARE_OUTPUT method .

   lr_entity ?= lr_entity_admini.

  lr_collection = lr_entity->get_related_entities(

           iv_relation_name = 'BTItemSchedlinExt' ).

  lr_entity_admini = lr_collection->get_current( ).

  IF lr_entity_admini IS NOT BOUND.
    lr_entity_admini = lr_entity->create_related_entity(
           iv_relation_name = 'BTItemSchedlinExt' ).
  ENDIF.


  lr_entity ?= lr_entity_admini.
  lr_collection = lr_entity->get_related_entities(
         iv_relation_name = 'BTSchedlinFirst' ).

  lr_entity_admini_1 = lr_collection->get_current( ).

  IF  lr_entity_admini_1 IS NOT BOUND.
    lr_entity_admini_1 = lr_entity->create_related_entity(
           iv_relation_name = 'BTSchedlinFirst' ).
  ENDIF.

  IF  lr_entity_admini_1 IS BOUND.
    lr_entity_admini_1->set_property( iv_attr_name = 'QUANTITY'     iv_value = '1.00' ).
  ENDIF.

Regards,

Nithish

Former Member
0 Kudos

Hi Nitish,

Could you please tell me the data declaration for lr_entity and other variables as well?

Awaiting your response at the earliest.

Thanks & Regards,

Srividya

Former Member
0 Kudos

Hi Srividya,

You can check any standard code for these declarations.

data :

lr_entity type ref to cl_crm_bol_entity,

lr_entity_admini type ref to if_bol_bo_property_access,

lr_entity_admini_1 type ref to if_bol_bo_property_access,

lv_collection TYPE REF TO if_bol_entity_col.


to get lr_entity_admini in do_prepare_output.

lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).

Regards,

Nithish

Former Member
0 Kudos

Hi Nitish,

I have written the following code in method do_prepare_output as per your above suggestions

   METHOD do_prepare_output.
  DATA : lr_entity TYPE REF TO cl_crm_bol_entity,
         lr_entity_admini TYPE REF TO if_bol_bo_property_access,
         lr_entity_admini_1 TYPE REF TO if_bol_bo_property_access,
         lr_collection TYPE REF TO if_bol_entity_col.

  lr_entity ?= lr_entity_admini.

  lr_collection = lr_entity->get_related_entities( iv_relation_name = 'BTItemSchedlinExt' ).

  lr_entity_admini = lr_collection->get_current( ).
*  lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).

  IF lr_entity_admini IS NOT BOUND.
    lr_entity_admini = lr_entity->create_related_entity( iv_relation_name = 'BTItemSchedlinExt' ).
  ENDIF.


  lr_entity ?= lr_entity_admini.
  lr_collection = lr_entity->get_related_entities( iv_relation_name = 'BTSchedlinFirst' ).

  lr_entity_admini_1 = lr_collection->get_current( ).

  IF  lr_entity_admini_1 IS NOT BOUND.
    lr_entity_admini_1 = lr_entity->create_related_entity( iv_relation_name = 'BTSchedlinFirst' ).
  ENDIF.

  IF  lr_entity_admini_1 IS BOUND.
    lr_entity_admini_1->set_property( iv_attr_name = 'QUANTITY' iv_value = '1.00' ).
  ENDIF.

*  call method super->do_prepare_output
*    exporting
*      iv_first_time = iv_first_time.
*
*  if iv_first_time = abap_true.
*
*  endif.

ENDMETHOD.

---------------------------------------------------------------------------------------------------------------------------------

Error : when i execute the Bid  -> in product editlist -> to create new line item

SAP Note
 
  • The following error text was processed in the system:
    Dereferencing the NULL reference
Exception ClassCX_SY_REF_IS_INITIAL
Error Name
ProgramZL_BT130I_O_ITEMDETAILS_IMPL==CP
IncludeZL_BT130I_O_ITEMDETAILS_IMPL==CM004
ABAP ClassZL_BT130I_O_ITEMDETAILS_IMPL
MethodDO_PREPARE_OUTPUT
Line9
Long textAn attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object.
Former Member
0 Kudos

Hi Srividya,

Please call super method first and next the logic to default quanity.

After super class call, then check whether the lr_entity_admini is getting isnstatinated using

  lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).

check lr_entity_admini is bound.


then after continue the code from


lr_entity?= lr_entity_admini.

.......

........

Regards,

Nithish

Former Member
0 Kudos

Hi Srividya,

Please call super method first and next the logic to default quanity.

After super class call, then check whether the lr_entity_admini is getting isnstatinated using

  lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).

check lr_entity_admini is bound.


then after continue the code from


lr_entity?= lr_entity_admini.

.......

........

Regards,

Nithish

Former Member
0 Kudos

Hi Srividya,

Please call super method first and next the logic to default quanity.

After super class call, then check whether the lr_entity_admini is getting isnstatinated using

  lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).

check lr_entity_admini is bound.


then after continue the code from


lr_entity?= lr_entity_admini.

.......

........

Regards,

Nithish

Former Member
0 Kudos

Hi Nithish,

Thanks for that solution .

However  ,the quantity field holds '1.000' as value and if i enter product,it changes to '1' in display

Can you help me to resolve this 1.000,if i din't give any product,it stays as '1.000' instead i need it to display as '1'

Former Member
0 Kudos

Hi srividya,

Try setting the value of quantity as 1 rather than 1.00.

    lr_entity_admini_1->set_property( iv_attr_name = 'QUANTITY' iv_value = '1' ).

Regards,

Nithish

Former Member
0 Kudos

Hi Nithish,

I did try that already.

But somewhere <DATA> field symbol holds 1.000 and that appears as ouput,eventhough we passed '1.00' earlier

Former Member
0 Kudos

Hi Srividya,

If you check out the method GET_QUANTITY, the utility method  cl_bsp_utility=>make_string expects a quantity and a quantity unit to convert decimal( 1.00) to a string ( 1). So you need to enter quantity unit before entering the quantity.

If you still want to control the display of the quantity field irrespective of quantity unit , you can redefine GET_QUANTITY and call super method , then check out the VALUE field and place your logic there to modify VALUE parameter.

Regards,

Nithish

Former Member
0 Kudos

I tried modifying the get_quantity method as per ur suggestion.But I get this error

'Class ZL_BT130I_O_ITEMDETAILS_CN08,Method GET_QUANTITY

You must not change field "1".-

this was my code

   method GET_QUANTITY.
CALL METHOD SUPER->GET_QUANTITY
*  EXPORTING
*    ATTRIBUTE_PATH =
*    iterator       =
  RECEIVING
    VALUE          = '1'
    .
endmethod.

Former Member
0 Kudos

Ohh..I suppose this in not the right way to redefine.

CALL METHOD SUPER->GET_QUANTITY
EXPORTING
   ATTRIBUTE_PATH = attribute_path

    iterator       = iterator
  RECEIVING
    VALUE          =  value.

if value = '1.00'.

value = '1'.

endif.

or instead of hardcoding you can place any other logic after super call for all decimal values.

Regards,

Nithish

    .

Former Member
0 Kudos

Unfortunately,the quantity field was 1.000 ,only when i clicked pencil button(near delete button in line item),once i type a product id and hit enter

but the requirement what they are looking for is,in Bid->product->edit list,the line item field(Product) i give some value and hit enter on same screen(not that i click pencil icon to edit product and default qty).

Main screen of the bid,where we see Product->edit list,same screen,line item,when i give a product and hit enter,the quantity field is not defaulting to 1.Please help at the earliest with details on bsp component,view and method to change and the logic behind

Former Member
0 Kudos

Press F2 and check the component and view where you want to default the value.

Use the same code and place a check to read the product id entered on screen and then set the value.

  lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).

check lr_entity_admini is bound.

     CALL METHOD lr_current->get_property_as_value
                      EXPORTING
                        iv_attr_name = 'ORDERED_PROD'

                     IMPORTING
                        ev_result    = lv_product_id.

Check lv_product_id is initial.

............................

...................

Regards,

Nithish.

Former Member
0 Kudos

By pressing F2,I see BT111H_OPPT component and view as Itemlist ->field Quantity.

Please define the variable lv_product_ld and lr_current that need to be declared as DATA in ur above code suggestion.Also i see orderedprod and not ordered_prod in BT111H_OPPT ->view itemlist.

please correct the below code,wherever required

METHOD do_prepare_output.

  DATA :   lr_entity TYPE REF TO cl_crm_bol_entity,
           lr_entity_admini TYPE REF TO if_bol_bo_property_access,
           lr_entity_admini_1 TYPE REF TO if_bol_bo_property_access,
           lr_collection TYPE REF TO if_bol_entity_col,
           lv_product_id TYPE string.

  CALL METHOD super->do_prepare_output
    EXPORTING
      iv_first_time = iv_first_time.

  IF iv_first_time = abap_true.

  ENDIF.

  lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).
  CHECK lr_entity_admini IS BOUND.
  CALL METHOD lr_current->get_property_as_value
    EXPORTING
      iv_attr_name = 'ORDEREDPROD'
    IMPORTING
      ev_result    = lv_product_id.

  CHECK lv_product_id IS INITIAL.

  lr_entity_admini = me->typed_context->btadmini->collection_wrapper->get_current( ).

  CHECK lr_entity_admini IS BOUND.
  lr_entity ?= lr_entity_admini.
  lr_collection = lr_entity->get_related_entities( iv_relation_name = 'BTItemSchedlinExt' ).
  lr_entity_admini = lr_collection->get_current( ).

  IF lr_entity_admini IS NOT BOUND.
    lr_entity_admini = lr_entity->create_related_entity( iv_relation_name = 'BTItemSchedlinExt' ).
  ENDIF.

  lr_entity ?= lr_entity_admini.
  lr_collection = lr_entity->get_related_entities( iv_relation_name = 'BTSchedlinFirst' ).

  lr_entity_admini_1 = lr_collection->get_current( ).

  IF  lr_entity_admini_1 IS NOT BOUND.
    lr_entity_admini_1 = lr_entity->create_related_entity( iv_relation_name = 'BTSchedlinFirst' ).
  ENDIF.

  IF  lr_entity_admini_1 IS BOUND.
    lr_entity_admini_1->set_property( iv_attr_name = 'QUANTITY' iv_value = '1' ).
  ENDIF.

*  DATA: lr_btadmini             TYPE REF TO cl_crm_bol_entity,
*        lr_col_wrap             TYPE REF TO cl_bsp_wd_collection_wrapper,
*        lr_itr                  TYPE REF TO if_bol_bo_col_iterator,
*        ls_btadmini             TYPE crmst_admini_btil,
*        lt_btadmini             TYPE zcrmst_admini_btil,
*        lv_err_num              TYPE zcrmst_error_number.
*
*  CALL METHOD super->do_prepare_output
*    EXPORTING
*      iv_first_time = iv_first_time.
*
*  " Sort by item number and higher level item
*  IF gv_sort = abap_false .
*    sort_collection( ).
*  ENDIF.
*
*  " Remove New button
*  DATA  ls_button TYPE crmt_thtmlb_button.
*  LOOP AT ab_button INTO ls_button.
*    IF ls_button-type = 'NEW'.
*      DELETE ab_button.
*    ENDIF.
*  ENDLOOP.
*
** Defect 979
** Carlos Hidalgo - 7/3/2011 - Ecenta
** Validate the % of package quantity
*
*  lr_col_wrap = me->typed_context->btadmini->get_collection_wrapper( ).
*  lr_itr ?= lr_col_wrap->get_iterator( ).
*
*  lr_btadmini ?= lr_itr->get_first( ).
*  " get the item list
*  WHILE lr_btadmini IS BOUND.
*    lr_btadmini->if_bol_bo_property_access~get_properties(
*                            IMPORTING es_attributes = ls_btadmini ).
*
*    APPEND ls_btadmini TO lt_btadmini.
*
*    lr_btadmini ?= lr_itr->get_next( ).
*  ENDWHILE.
*
*  zvalidate_pckg_quan( EXPORTING it_btadmini = lt_btadmini IMPORTING ev_err_num = lv_err_num ).
*
*  CLEAR: lr_btadmini, lr_itr, lr_col_wrap, ls_btadmini, lt_btadmini.
*
** End defect 979
*
*  IF iv_first_time = abap_true.
*    EXIT.
*  ENDIF.
*
*  IF me->view_group_context->is_view_in_display_mode( me ) <> abap_true.
*    update_override_price( ).
*  ENDIF.

ENDMETHOD.

Former Member
0 Kudos

please let me know  the data declaration of lv_product_id and lr_current for  the above code and also how  to initialize the lr_current to hold orderedprod logic

Former Member
0 Kudos

please respond for the above request

Answers (1)

Answers (1)

0 Kudos

Hi Srividya,

Which is the view that you are referring to here?

Best Regards,

Leon

Former Member
0 Kudos

ItemDetails or ItemList

I would say,check the BSP Component 'item list'(i guess) and its element ,by clicking F2 button on the BID(Web UI),Product->edit list,item level Quantity field(BTSchedulin->struct.quantity)