cancel
Showing results for 
Search instead for 
Did you mean: 

CCM/CSE_OCIMINQTY BADI for minimum quantity check

Former Member
0 Kudos

HI,

i want to use this BADI for check minimun Quantity. Is it possible to have an example of code of this BADI ?

When the quantity you enter is less than the minimum order quantity for the item, i want to display an message error and i do not allow to transfer the item to the shopping cart? Is this functionality setting to customizing or in program code?

Regards,

Mario.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks,

but i have not method /ccm/if_ex_cse_enrichment~validate_data,

i have method /CCM/IF_EX_CSE_ENRICHMENT~ENRICH_DATA.

Is it necessary to customize in order to display this method?

I have SRM 4.0 SP09, component:

CCM 100 0009 SAPK-10009INCCM SAP CATALOG CONT. MGMT. 1.0: Installatio

Any ideas in order to solve the problem?

Thanks in advances.

Former Member
0 Kudos

Hi

Also refer to OSS note - 888425

<u>Here is the sample code for VALIDATE_DATA Method.</u>

METHOD /ccm/if_ex_cse_enrichment~validate_data.
  DATA: lr_history TYPE REF TO /ccm/cl_history,
        ls_component_api LIKE LINE OF it_component_api,
        lt_existing_item_and_quan TYPE /ccm/t_item_and_quan,
        ls_existing_item_and_quan TYPE /ccm/s_item_and_quan,
        ls_char_value_min_quan TYPE /ccm/s_char_value_api,
        ls_char_value_order_unit TYPE /ccm/s_char_value_api,
        ls_short_text TYPE /ccm/s_short_text_api,
        lt_item_list TYPE /ccm/t_object_guid,
        ls_data_list LIKE LINE OF it_data_list,
        msg_param TYPE syst-msgv1,
        lines LIKE sy-tabix,
        ls_msg TYPE bapiret2,
        lt_selected_item type /CCM/T_OBJECT_GUID
        .

  FIELD-SYMBOLS: <ls_data_list> LIKE LINE OF it_data_list.

  CLEAR lt_existing_item_and_quan.

  lr_history = /ccm/cl_catalog_handler=>get_history( ).
  lt_existing_item_and_quan = lr_history->get_item_and_quan( ).

  READ TABLE it_data_list WITH KEY name = 'MIN_ORDER_QTY' INTO ls_data_list.

*-- check the call parameter and compare if necessary
  IF iv_validated EQ abap_false AND ls_data_list-value NE space.
    IF it_component_api IS NOT INITIAL.

      LOOP AT it_component_api INTO ls_component_api.

      clear: ls_char_value_min_quan, ls_char_value_order_unit.
      clear ls_existing_item_and_quan.   

        READ TABLE lt_existing_item_and_quan WITH KEY item = ls_component_api-guid
          INTO ls_existing_item_and_quan.
*-- no history availabe -> set to default quantity
        IF sy-subrc <> 0.
          ls_existing_item_and_quan-quantity = 1.
        ENDIF.

        READ TABLE ls_component_api-char_value_tab WITH KEY id-id = '/CCM/MINIMUM_QUANTITY'
          INTO ls_char_value_min_quan.

        READ TABLE ls_component_api-char_value_tab WITH KEY id-id = '/CCM/ORDER_UNIT'
          INTO ls_char_value_order_unit.

        IF ( ls_char_value_order_unit-value EQ ls_char_value_min_quan-unit )
        AND ( ls_existing_item_and_quan-quantity < ls_char_value_min_quan-value ).

          READ TABLE ls_component_api-short_text_tab INDEX 1
            INTO ls_short_text.

          Describe table it_component_api lines lines.

          if lines eq 1.
            clear lt_item_list.
            append ls_component_api-guid to lt_item_list.

            lr_history->update_selected_items(
              exporting
                IT_SELECTED_ITEMS = lt_item_list ).
          endif.

          msg_param = ls_short_text-short_text.

          IF ls_data_list-value EQ 'E'.
            ls_msg-type   = 'E'.
            ls_msg-id     = '/CCM/CAS_MESSAGE'.
            ls_msg-number     = 009.
            ls_msg-message_v1 = msg_param.
            APPEND ls_msg TO ct_msgs.
            cv_block_transfer = abap_true.
          ENDIF.

          IF ls_data_list-value EQ 'W'.
            ls_msg-type   = 'W'.
            ls_msg-id     = '/CCM/CAS_MESSAGE'.
            ls_msg-number     = 009.
            ls_msg-message_v1 = msg_param.
            APPEND ls_msg TO ct_msgs.
            cv_block_transfer = abap_false.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDIF.

ENDMETHOD.

Regards

- Atul

Former Member
0 Kudos

Hi

Please read this.

<u>In SE18 Transaction, Use the BADI -> /CCM/CSE_ENRICHMENT (BAdI: Characteristic Enhancement in SAP Catalog Search Engine)</u>

Method - /CCM/CSE_OCIMINQTY: 
--------------------------------------------------------------
The method that this sample implementation contains is used to check whether the call parameter MIN_ORDER_QUAN was transferred. Depending on the value specified for this call parameter, the method is also used to compare the minimum purchase order quantity and the specified purchase order quantity. A message is added to a message table for every item where the specified quantity is less than the minimum purchase order quantity. This message table can then be evaluated in a method that calls the BAdI. If the import parameter IV_VALIDATED has the value X, the order quantities will not be compared. This prevents the same item from being evaluated several times.

----


<b>Sample code for this BADI Implementation -></b>

<u>Implementation name -> /CCM/CSE_OCIMINQTY

Short text -> Validation of Minimum Order Quantity Before OCI Transfer</u>

METHOD /ccm/if_ex_cse_enrichment~validate_data.
  DATA: lr_history TYPE REF TO /ccm/cl_history,
        ls_component_api LIKE LINE OF it_component_api,
        lt_existing_item_and_quan TYPE /ccm/t_item_and_quan,
        ls_existing_item_and_quan TYPE /ccm/s_item_and_quan,
        ls_char_value_min_quan TYPE /ccm/s_char_value_api,
        ls_char_value_order_unit TYPE /ccm/s_char_value_api,
        ls_short_text TYPE /ccm/s_short_text_api,
        lt_item_list TYPE /ccm/t_object_guid,
        ls_data_list LIKE LINE OF it_data_list,
        msg_param TYPE syst-msgv1,
        lines LIKE sy-tabix,
        ls_msg TYPE bapiret2,
        lt_selected_item type /CCM/T_OBJECT_GUID
        .

  FIELD-SYMBOLS: <ls_data_list> LIKE LINE OF it_data_list.

  CLEAR lt_existing_item_and_quan.

  lr_history = /ccm/cl_catalog_handler=>get_history( ).
  lt_existing_item_and_quan = lr_history->get_item_and_quan( ).

  READ TABLE it_data_list WITH KEY name = 'MIN_ORDER_QTY' INTO ls_data_list.

*-- check the call parameter and compare if necessary
  IF iv_validated EQ abap_false AND ls_data_list-value NE space.
    IF it_component_api IS NOT INITIAL.

      LOOP AT it_component_api INTO ls_component_api.

      clear: ls_char_value_min_quan, ls_char_value_order_unit.
      clear ls_existing_item_and_quan.   "correction note #888425

        READ TABLE lt_existing_item_and_quan WITH KEY item = ls_component_api-guid
          INTO ls_existing_item_and_quan.
*-- no history availabe -> set to default quantity
        IF sy-subrc <> 0.
          ls_existing_item_and_quan-quantity = 1.
        ENDIF.

        READ TABLE ls_component_api-char_value_tab WITH KEY id-id = '/CCM/MINIMUM_QUANTITY'
          INTO ls_char_value_min_quan.

        READ TABLE ls_component_api-char_value_tab WITH KEY id-id = '/CCM/ORDER_UNIT'
          INTO ls_char_value_order_unit.

        IF ( ls_char_value_order_unit-value EQ ls_char_value_min_quan-unit )
        AND ( ls_existing_item_and_quan-quantity < ls_char_value_min_quan-value ).

          READ TABLE ls_component_api-short_text_tab INDEX 1
            INTO ls_short_text.

          Describe table it_component_api lines lines.

          if lines eq 1.
            clear lt_item_list.
            append ls_component_api-guid to lt_item_list.

            lr_history->update_selected_items(
              exporting
                IT_SELECTED_ITEMS = lt_item_list ).
          endif.

          msg_param = ls_short_text-short_text.

          IF ls_data_list-value EQ 'E'.
            ls_msg-type   = 'E'.
            ls_msg-id     = '/CCM/CAS_MESSAGE'.
            ls_msg-number     = 009.
            ls_msg-message_v1 = msg_param.
            APPEND ls_msg TO ct_msgs.
            cv_block_transfer = abap_true.
          ENDIF.

          IF ls_data_list-value EQ 'W'.
            ls_msg-type   = 'W'.
            ls_msg-id     = '/CCM/CAS_MESSAGE'.
            ls_msg-number     = 009.
            ls_msg-message_v1 = msg_param.
            APPEND ls_msg TO ct_msgs.
            cv_block_transfer = abap_false.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDIF.

ENDMETHOD.

Regards

- Atul