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: 

Duplicate check for Purchase Orders

Former Member
0 Kudos

Hi all,

I have Purchase Requisitions from external system getting posted into SAP as idocs and creating a PO. Sometimes the same PR is sent twice which is creating a duplicate PO in SAP.

Is there a Function module / BAPI to check whether the PR has alrady been posted in SAP ?

Thanks,

Surya

8 REPLIES 8

Former Member
0 Kudos

Hello,

You may make use of method PROCESS_ITEM of the BADI ME_PROCESS_REQ_CUST (SE18/SE19) to check duplicates of Purchase Requisitions.

Thanks,

Venu

0 Kudos

Hi Venu,

Just days back our system is upgraded from 4.7 to 6.

I can able to see the method.. Could you please tell where and how to use this method..

Thanks,

Surya

0 Kudos

Hi all,

My requirement here is, Whenever the the data is read and before the PO is being created, I have to keep a check with reference to PR number (EKKO-UNSEZ) to see whether a PO for this particular PR is already created in SAP or not.

I have to use a FM / BAPI for this purpose.

Can you please suggest a way to do this ?

Thanks,

Surya.

0 Kudos

Create an implementation of Badi " ME_PROCESS_PO_CUST".

Add the following code in method "CHECK"

method if_ex_me_process_po_cust~check.

  types : begin of ty_ekko,
           ebeln type ebeln,
           unsez type unsez,
          end of ty_ekko.

  data : it_ekko type standard table of ty_ekko.

  data: ls_mepoheader type mepoheader.
  ls_mepoheader = im_header->get_data( ).

  if ls_mepoheader-unsez is not initial.
    select ebeln unsez
    from ekko
    into table it_ekko
    where unsez = ls_mepoheader-unsez.
    
    if sy-subrc eq 0.
       Message 'Purchase Requistion already referenced' type 'E'.
    endif.
  endif.	
endmethod.

Regards

Vinod

0 Kudos

Hi Vinod,

Thanks for the reply.

May I know what I have to pass in the CALL METHOD.

And what ls_mepoheader = im_header->get_data( ). will fill in the ls_mepoheader.

what are the values to be passed to the method.

Pleaes let me know these as I am very new to this..

Thanks in advance,

Surya.

0 Kudos

Hi surya,

In "ls_mepoheader = im_header->get_data( ). ", you dont need to pass any parameters. This method will pass the currently processing purchase order header data into the structure "ls_mepoheader". Once the header data is assigned to "ls_mepoheader" you can use it for further processing.

Regards

Vinod

0 Kudos

Hi Vinod,

The FM that processes the IDoc segments and creates a PO ( by calling a PO) is IDOC_INPUT_PORDCR.

So in this FM, after the segments of the Idoc are read I have to place to code for checking whether the PO has been created with a particular UNSEZ.

How should I call the method and what parameters to be passed. Could you please explain me the flow of this particular method .?

Thanks in advance,

Surya.

0 Kudos

If you are creating the PO through IDOC, do the validation in the Customer Exit "EXIT_SAPLMEWP_002" (Enhancement : "SAPLMEWP"). UNSEZ field value is available in Bapi structure field "PO_HEADER_ADD_DATA-OUT_REF"

Example code:

select eblen unsez from ekko
into <itab>
where unsez = PO_HEADER_ADD_DATA-our_ref.

if sy-subrc eq 0.
	raise <appropriate error>.
endif.

Regards

Vinod