Skip to Content
0
Former Member
Dec 11, 2007 at 06:53 AM

Open close PO's

73 Views

Hi All,

I want help in changing my code for getting open & close PO’s. I wrote the code in Start-of-Selection. This code is working fine with my PO’s whether close or open basing on the status of delivery or on the quantity delivered and invoiced. My problem is that when this PO is having line items & if the 1st two or any of the PO’s closed & last item yet to be delivered it is giving correct result that this PO’s is still open. If my last item in PO’s is closed & 1st two or three items are open it is giving closed. Basing on last item my program is working. It is not checking on each line item to decide whether it is closed or open. Kindly help to change the code to check each line item whether closed or open & give the final result. Your help is appreciated.

Regards,

Ram

<b><u>This is the code I have written</u>.</b>

DATA: SUBTOTAL LIKE EKPO-MENGE.

DATA: STATUS TYPE I VALUE 1.

SELECT EKKO~EBELN

EKKO~LIFNR

EKKO~BEDAT

EKKO~WAERS

EKKO~EKGRP

INTO CORRESPONDING FIELDS OF TABLE IEKKO

FROM EKKO

WHERE EKKO~EBELN IN S_EBELN

AND LIFNR IN S_LIFNR

AND EKGRP IN S_EKGRP

AND EKKO~BUKRS IN S_BUKRS

AND BEDAT IN S_BEDAT.

SELECT EKPO~EBELN

EKPO~EBELP

EKPO~NETWR

EKPO~ELIKZ

FROM EKPO

INTO CORRESPONDING FIELDS OF TABLE IEKPO

FOR ALL ENTRIES IN IEKKO

WHERE EKPO~EBELN EQ IEKKO-EBELN

AND EKPO~LOEKZ <> 'L'.

IEKPO1[] = IEKPO[].

LOOP AT IEKKO.

LOOP AT IEKPO WHERE EBELN EQ IEKKO-EBELN.

LOOP AT IEKPO1 WHERE EBELN EQ IEKPO-EBELN AND EBELP EQ IEKPO-EBELP.

STATUS = 1.

IF IEKPO-ELIKZ NE 'X'.

STATUS = '0'.

ELSE.

IEKPO1-CK = 'X'.

MODIFY IEKPO1.

ENDIF.

ENDLOOP.

ENDLOOP.

IF STATUS EQ '0'.

IEKKO-POSTA = 'Open'.

MODIFY IEKKO.

ELSE.

IEKKO-POSTA = 'Close'.

MODIFY IEKKO.

ENDIF.

ENDLOOP.

  • Status consideration based on Quantity delivered and invoiced

SELECT EKET~EBELN

EKET~EBELP

EKET~ETENR

EKET~WEMNG

EKET~MENGE

FROM EKET

INTO CORRESPONDING FIELDS OF TABLE IEKET

FOR ALL ENTRIES IN IEKPO

WHERE EKET~EBELN EQ IEKPO-EBELN

AND EKET~EBELP EQ IEKPO-EBELP.

LOOP AT IEKPO.

LOOP AT IEKET WHERE EBELN EQ IEKPO-EBELN AND EBELP EQ IEKPO-EBELP.

IEKPO-QTYRC = QTYRC + IEKET-WEMNG.

IEKPO-QTYOR = QTYOR + IEKET-MENGE.

ENDLOOP.

MODIFY IEKPO.

ENDLOOP.

LOOP AT IEKKO.

LOOP AT IEKPO WHERE EBELN EQ IEKKO-EBELN.

SUBTOTAL = IEKPO-QTYRC - IEKPO-QTYOR.

ENDLOOP.

IF SUBTOTAL <> '0'.

IEKKO-POSTA = 'Open'.

MODIFY IEKKO.

ELSE.

IEKKO-POSTA = 'Close'.

MODIFY IEKKO.

ENDIF.

ENDLOOP.

LOOP AT IEKKO.

LOOP AT IEKPO WHERE EBELN EQ IEKKO-EBELN.

IEKKO-TOTAL = IEKKO-TOTAL + IEKPO-NETWR.

ENDLOOP.

MODIFY IEKKO.

ENDLOOP.

*Finished Status consideration based on Quantity delivered and invoiced

  • Fetch Vendor Name

LOOP AT IEKKO.

SELECT LFA1~NAME1

INTO IEKKO-NAME1

FROM LFA1

WHERE LFA1~LIFNR EQ IEKKO-LIFNR.

MODIFY IEKKO.

ENDSELECT.

  • Fetch

SELECT T024~EKNAM

INTO IEKKO-EKNAM

FROM T024

WHERE T024~EKGRP EQ IEKKO-EKGRP.

MODIFY IEKKO.

ENDSELECT.

ENDLOOP.

<b></b><b></b>