Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to change number range of PO based on plant using BADi ME_PROCESS_PO_CUST

EkanshCapgemini
Active Contributor

Hi all,

I have a requirement to change the number range of PO based on the plant at the first line item and the document type at header. Then I would pass this combination into my Z  table and get the no. range id.

The user Exit MM06E003 is not useful since it does not capture item level data. So I have to use the badi ME_PROCESS_PO_CUST

Now my problem is which method is to use when implementing it. I tried almost all of them by inserting BREAK-POINT statement but it is of no use.

Can some one please help me in this?

1 ACCEPTED SOLUTION

EkanshCapgemini
Active Contributor
0 Kudos

I have done it so I am posting the solution for others:

1. Create a Z table like this:

2. implement BADi ME_PO_PRICING_CUST using method:

method IF_EX_ME_PO_PRICING_CUST~PROCESS_KOMK.

IF im_ekpo-EBELP = 0010.

**  FREE MEMORY ID 'ZMM_PLANT'.

*  EXPORT werks FROM im_ekpo TO MEMORY id 'ZMM_PLANT'.

   DATA: lv_werks TYPE werks_d.

   lv_werks = im_ekpo-werks.

   set PARAMETER ID 'WER' FIELD lv_werks.

ENDIF.

endmethod.

3. Goto CMOD, create  a new project, use exit MM06E003 , then implement function exit: EXIT_SAPMM06E_001 with the following code:

data: lv_werks TYPE werks_d,

       lv_bsart TYPE ESART,

       lv_range TYPE INRI-NRRANGENR,

       RETURN TYPE INRI-RETURNCODE,

       lv_ebeln TYPE ebeln.

DATA: wa TYPE ZMM_NO_RANGE_PO.

get PARAMETER ID 'WER' FIELD lv_werks.

lv_bsart = NEKKO-bsart.

SELECT SINGLE * FROM ZMM_NO_RANGE_PO INTO wa WHERE plant = lv_werks AND doc_type = lv_bsart.

IF  wa is NOT INITIAL.

   lv_range = wa-range.

*  *Get Next number based on number range.

     CALL FUNCTION 'NUMBER_GET_NEXT'

       EXPORTING

         NR_RANGE_NR = lv_RANGE

         OBJECT      = 'EINKBELEG'   "'BANF'

       IMPORTING

         NUMBER      = lv_ebeln  "NUMBER

         RETURNCODE  = RETURN.

     IF sy-subrc = 0.

       NUMBER = LV_EBELN.

       RANGE = LV_RANGE.

     ENDIF.

ENDIF.


1 REPLY 1

EkanshCapgemini
Active Contributor
0 Kudos

I have done it so I am posting the solution for others:

1. Create a Z table like this:

2. implement BADi ME_PO_PRICING_CUST using method:

method IF_EX_ME_PO_PRICING_CUST~PROCESS_KOMK.

IF im_ekpo-EBELP = 0010.

**  FREE MEMORY ID 'ZMM_PLANT'.

*  EXPORT werks FROM im_ekpo TO MEMORY id 'ZMM_PLANT'.

   DATA: lv_werks TYPE werks_d.

   lv_werks = im_ekpo-werks.

   set PARAMETER ID 'WER' FIELD lv_werks.

ENDIF.

endmethod.

3. Goto CMOD, create  a new project, use exit MM06E003 , then implement function exit: EXIT_SAPMM06E_001 with the following code:

data: lv_werks TYPE werks_d,

       lv_bsart TYPE ESART,

       lv_range TYPE INRI-NRRANGENR,

       RETURN TYPE INRI-RETURNCODE,

       lv_ebeln TYPE ebeln.

DATA: wa TYPE ZMM_NO_RANGE_PO.

get PARAMETER ID 'WER' FIELD lv_werks.

lv_bsart = NEKKO-bsart.

SELECT SINGLE * FROM ZMM_NO_RANGE_PO INTO wa WHERE plant = lv_werks AND doc_type = lv_bsart.

IF  wa is NOT INITIAL.

   lv_range = wa-range.

*  *Get Next number based on number range.

     CALL FUNCTION 'NUMBER_GET_NEXT'

       EXPORTING

         NR_RANGE_NR = lv_RANGE

         OBJECT      = 'EINKBELEG'   "'BANF'

       IMPORTING

         NUMBER      = lv_ebeln  "NUMBER

         RETURNCODE  = RETURN.

     IF sy-subrc = 0.

       NUMBER = LV_EBELN.

       RANGE = LV_RANGE.

     ENDIF.

ENDIF.