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: 

calculate purches order value

Former Member
0 Kudos

Hi Experts,

i am creating a report of purchasing order report and t code is ME2N and in this report it will show STILL TO BE DELIVERY field . if this is 0 then i want to remove that field and this have value then show this. i already create this report but for that some condition i m below now please tell me how to find these things.

1) how to find goods receipt value.

2) i want to separate the movement type-wise.

3) separate out item no wise also.

all above values u can this value after entering T-CODE ME2N execute directly and double click on any po no it will show all fields.

goods receipt, movement type , item no.

Thank's ,

subodh......

6 REPLIES 6

Former Member
0 Kudos

Try tables EKBE & MSEG.

Regards

Sathar

Former Member
0 Kudos

Hi,

You need to look into the Table EKBE(Purchase Order History) Table to get the Quantity of Goods Recieved against the Purchase Order.

You need to consider the Two Primary Movement Types: 101 & 102.

EKBE records with Movement Type 101 represents the PO Good Receipts

EKBE records with Movement Type 102 represents the PO Good Reversal

Open PO Qty(Still to be Delievry) = PO Qty - Sum(101 EKBE PO Records) + Sum(102 EKBE PO Records).

I would suggest you to get the above logic first verified by the Functional Consultant/User , or you itself get the same verified for any PO having Still to be Deliver/Open PO qty.

There might be a case where the client might be using some other Movement Types also and you may want to consider them also, either as PO receipt or PO reversal.

In one of my Project, I even get EKBE records with EMPTY Movement Types and based on the system study, i treated them as PO receipt so as to get the results as reflected in ME21N.

So please get your logic either user/functional consultant tested or self tested.

One Last Point..Don't forgot to eliminate the deleted PO or PO Lines Items in your Select statements.

0 Kudos

hi ajay,

thanks !! but i can get clearly this ans, can you send me code for that,

i want to calculate

still to be delivery = qty(ekpo-menge) - good reciept (101 mseg-erfmg) - (102 and 122 movement type)

but this is item wise

because conditions are

their movement type 101 for reciept and 102 and 122 are for reversal of goods.

and differentiate the item no wise because one po contains no of material. and

i want to show these only whose material is pending if it is fully delivery thin don't show this feild.

please help send this code with all conditions.

thank's .....

subodh.

0 Kudos

Hi,

Please find the required code here:

https://wiki.sdn.sap.com/wiki/display/sandbox/OPENPOQTYREPORT-CODE

0 Kudos

hi subodh

where it_mseg1 is the entries contained of 101 movement type.



SELECT    MBLNR
            MJAHR
            ZEILE
            BWART
            MATNR
            WERKS
            LIFNR
            ERFMG
            EBELN
            EBELP
            LFBNR
            LFPOS FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_MSEG1 FOR ALL ENTRIES IN IT_MSEG
                                                            WHERE BWART = '122' "purchase return
                                                             AND WERKS EQ IT_MSEG-WERKS
                                                             AND LIFNR EQ IT_MSEG-LIFNR
                                                             AND LFBNR EQ IT_MSEG-LFBNR
                                                             AND LFPOS EQ IT_MSEG-LFPOS.


  LOOP AT IT_MSEG INTO WT_MSEG.
    READ TABLE IT_MSEG1 INTO WT_MSEG1 WITH KEY WERKS = WT_MSEG-WERKS
                                               LIFNR = WT_MSEG-LIFNR
                                               LFBNR = WT_MSEG-LFBNR
                                               LFPOS = WT_MSEG-LFPOS.
    IF SY-SUBRC EQ 0.
      WT_RES-REC_QTY = WT_MSEG-ERFMG(101) - WT_MSEG1-ERFMG(122).
      MODIFY IT_RES FROM WT_RES TRANSPORTING REC_QTY WHERE LFBNR = WT_MSEG-LFBNR
                                                      AND  LFPOS = WT_MSEG-LFPOS .

    ELSE.
      WT_RES-REC_QTY = WT_MSEG-ERFMG  .
      MODIFY IT_RES FROM WT_RES TRANSPORTING REC_QTY WHERE LFBNR = WT_MSEG-LFBNR
                                                      AND  LFPOS = WT_MSEG-LFPOS.
    ENDIF.
  ENDLOOP.

note: here i mentioned the 122 movement type . for your requirement you have to mention the 102 mtype instead of 122.

regards
surender.s

Former Member
0 Kudos

use the below BAPI, it fetches everything.......

BAPI_PO_GETDETAIL1