Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

open purchase reprot

TABLES : ekko.

TYPES : BEGIN OF ty_po,

ebeln TYPE ekko-ebeln,

ebelp TYPE ekpo-ebelp,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

menge1 TYPE ekbe-menge,

bwart TYPE ekbe-bwart,

open TYPE ekpo-menge,

status TYPE c,

END OF ty_po.

DATA : gt_po TYPE STANDARD TABLE OF ty_po,

wa_po TYPE ty_po.

DATA : p_101 LIKE ekbe-bwart,

p_102 LIKE ekbe-bwart.

SELECT-OPTIONS : s_ebeln FOR ekko-ebeln.

START-OF-SELECTION.

SELECT a~ebeln

b~ebelp

b~matnr

b~menge

INTO TABLE gt_po

FROM ekko AS a

INNER JOIN ekpo

AS b ON aebeln = bebeln

WHERE a~ebeln IN s_ebeln.

LOOP AT gt_po INTO wa_po.

CLEAR p_101.

SELECT SUM( menge ) FROM ekbe INTO p_101

WHERE ebeln = wa_po-ebeln

AND ebelp = wa_po-ebelp

AND bwart = '101'.

CLEAR p_102.

SELECT SUM( menge ) FROM ekbe INTO p_102

WHERE ebeln = wa_po-ebeln

AND ebelp = wa_po-ebelp

AND bwart = '102'.

wa_po-open = wa_po-menge - ( p_101 + p_102 ).

IF wa_po-open EQ 0.

WRITE :/ wa_po-status , 'CLOSED'.

ELSE.

WRITE :/ wa_po-status , 'OPEN'.

ENDIF.

write : wa_po-ebeln,

wa_po-ebelp,

wa_po-matnr,

wa_po-menge,

wa_po-menge1,

wa_po-open,

wa_po-status.

but it going to run time error.

please tell me where i did mistake.

Tags:
Not what you were looking for? View more on this topic or Ask a question