cancel
Showing results for 
Search instead for 
Did you mean: 

Avoid new deliveries for a purchase order

LuisRocco
Explorer
0 Kudos

Hi, I need some help on how should be the logic to avoid the creation of a new delivery for a purchase order.

I tried through abap code at USEREXIT_SAVE_DOCUMENT_PREPARE of MV50AFZ1, but with no luck.

      SELECT vbeln posnr vgbel vgpos
        INTO CORRESPONDING FIELDS OF TABLE lt_lips
        FROM lips
        FOR ALL ENTRIES IN xlips
        WHERE vgbel = xlips-vgbel
          AND vgpos = xlips-vgpos.

      SORT lt_lips BY vgbel vgpos.

      LOOP AT xlikp ASSIGNING <fs_likp> WHERE updkz NE 'D'.
        LOOP AT xlips ASSIGNING <fs_lips>
                         WHERE vbeln EQ <fs_likp>-vbeln
                           AND updkz NE 'D'.

          READ TABLE lt_lips TRANSPORTING NO FIELDS WITH KEY vgbel = <fs_lips>-vgbel
                                                             vgpos = <fs_lips>-vgpos BINARY SEARCH.
          IF sy-subrc EQ 0.
            MESSAGE e002(zmm76).
          ENDIF.
        ENDLOOP.
      ENDLOOP.

Accepted Solutions (1)

Accepted Solutions (1)

LuisRocco
Explorer
0 Kudos

Hi, finally I got the solution, the check should be against EKBE table.

  DATA: lt_ekbe     TYPE TABLE of ekbe.

  IF sy-batch EQ abap_true.
    IF likp-vbeln+0(1) EQ '$'.

      LOOP AT xlips INTO DATA(ls_lips).
        SELECT belnr buzei
          INTO CORRESPONDING FIELDS OF TABLE lt_ekbe
          FROM ekbe
          WHERE ebeln = ls_lips-vgbel
            AND ebelp = ls_lips-vgpos.
        IF sy-subrc EQ 0.
          MESSAGE w000(zmm76) WITH 'Ya existe una entrega para la PO '
                              ls_lips-vgbel
                              'posición'
                              ls_lips-vgpos.
          LEAVE SCREEN.
        ENDIF.
      ENDLOOP.

    ENDIF.
  ENDIF.

 

Answers (3)

Answers (3)

Lakshmipathi
Active Contributor
0 Kudos

Is it that you want to prevent delivery creation only for one purchase order or multiple open POs ?  What exactly the Business requirement is ?  Please share some information on Business requirement so that, it will be easy to assist you.

rob_ariaans
Contributor
0 Kudos

Why not just tick the "Delivery completed" checkbox on the purchase order item?

0819
Explorer
0 Kudos

Hi,

Is there any information for select? All logic is executed but no message?