cancel
Showing results for 
Search instead for 
Did you mean: 

Minimum order quantity

Former Member
0 Kudos

Hi All,

I am trying to set up minimum order quantity in internal catalogs.

I could able to upload it in the catalog. But it seems there are no valudations happening when the order qty is less than the minimum order qty.

Could you please help to enable that validation?

From the other threads, I found some hints. But not sure how to go with that.

BADI:

In BADI: /CCM/CSE_ENRICHMENT --> Implementation: /CCM/CSE_OCIMINQTY, there are two methods: ENRICH_DATA and VALIDATE_DATA.

1. Is it enough to activate only the BADI: /CCM/CSE_ENRICHMENT?

2. Or do we need to make any other changes?

Call structure:

1. In call structure, what should I enter: MIN_ORDER_QTY or MIN_ORDER_QUAN?

2. Where should I enter this in the sequence?

Please help me with some details.

Thanks,

SS

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Enable Minimum Order Quantity (MOQ) to display error message when user tries to purchase item at less than MOQ identified in catalog.

Badi Definition: /CCM/CSE_ENRICHMENT. Method: Validate Data

Create your own implementation and deactivate the SAP standard implementation.

Here is a sample code of the implementation:

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.

data: lv_existing_qty type f,

lv_minimum_qty type f.

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( ).

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.

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.

  • Make Ordered qty equal 1 if its 0.

"003+

if ls_existing_item_and_quan-quantity = 0 . "003+

ls_existing_item_and_quan-quantity = ls_char_value_min_quan-value."003+

endif. "003+

clear: lv_existing_qty,

lv_minimum_qty.

move ls_existing_item_and_quan-quantity to lv_existing_qty.

move ls_char_value_min_quan-value to lv_minimum_qty.

    • Error message

if ( ls_char_value_order_unit-value eq ls_char_value_min_quan-unit )

and ( lv_existing_qty < lv_minimum_qty ).

ls_msg-type = 'E'.

"003+

ls_msg-id = '/CCM/CAS_MESSAGE'.

"003+

ls_msg-number = 009.

read table ls_component_api-short_text_tab index 1 into ls_short_text.

move ls_short_text-short_text to ls_msg-message_v1.

"003+

append ls_msg to ct_msgs.

"003+

cv_block_transfer = abap_true.

"003+

describe table it_component_api lines lines.

if lines eq 1.

clear lt_item_list.

append ls_component_api-guid to lt_item_list.

endif.

endif.

endloop.

endif.

endmethod.

Regards

Anirban