‎2012 Feb 29 10:58 AM
Hello Experts,
I have written a routine for requirement-pricing.
it is working fine, it calculate value of z condition type depending on other condition values record from ztables and quantity.
but that routine is getting executed every time means for every sales process,
now if a sales order is created or changed it will calculate value of z cond type depending on values present in ztable at that instant.
same thing happen for invoice, now what i want once invoice is made, i.e. vf01 is saved my routine should not get executed for that invoice again, including its delivey and sales order or scheduling agreement.
hope i am clear in explaining where i am getting trouble,
please suggest if anyone has idea.
Thanks,
Amar
‎2012 Feb 29 11:03 AM
restrict routin for transaction level like check sy-tcode = 'VF01'.
‎2012 Feb 29 11:13 AM
thanks for your reply,
Yes, i have done that by checking vf02 and vf03.
but now what problem is if someone open closed sales order for reference it will again calculate that zcondition depending on current data. i want everything blocked once invoice for that cycle is created.
Thanks,
Amar
‎2012 Feb 29 11:19 AM
You are checking for VF02 and VF03 so close order will always execute the piece of code, but if you check with VF01 then an order can create once only, so second time that routine will not execute
‎2012 Feb 29 11:38 AM
ok means you are saying if i check it against vf01 then the code will not execute for any other sale cycle including vf02 vf03 vl02n vl03n after saving invoice?
‎2012 Feb 29 11:47 AM
Hi,
Try
IF SY-TCODE = 'VF01'.
Your code
Endif.
If sy-tcode is not equal to VF01, it will not execute the code at all.
Thanks,
Harish
‎2012 Feb 29 12:10 PM
Hi Gagan,
I have included vf01 but it is still executing for closed sales orders, it is not just executing for vf01,vf02 and vf03.
‎2012 Feb 29 2:48 PM
Hi,
then write a select statement to fetch the data from table VBFA check whether invoice is done for the sales order.
if invoice is created don't execute the code.
Regards,
Sateesh
‎2012 Mar 01 6:41 AM
Hi Amar,
I am not getting you exactly, routine will always execute weather it will VF01,VF02 or VF03, but if your code is written in prior check like
if sy-tcode = 'VF01'
-
your code
-
endif.
then your code will not execute for VF02 and VF03 or closed invoice display, its doesn;t matter if routine is executing, but aim is your code should not execute, isn't it what u are looking for?
‎2012 Mar 01 7:18 AM
Hi,
thanks gagan and prabhu for the replies.
yes actually i was thinking wrong about what is happening, i will tell u what exact my requirement is..
for a material price is maintained for PR00 and ZCON.
what i need to do is fetch 1 value from ztable depending on material let say zvalue then i need to do
ZCON = (PR00 - ZCON + ZVALUE ) * quantity ( all are maintained in system)
now i get new value for zcon, which i need to save while VF01, actually i was working in wrong direction for solving problem the problem is not with TCODE vf01 or vf02 or anything else, what happening is when I do VF01 new value for ZCON is calculated and displayed. but when invoice is saved only the actual value of ZCON which is already maintained is saved in database not the one which i calculate.
Eg: PR00 - 100
ZCON - 50
ZVALUE - 10
quantity - 5 .
i need ZCON rate as 60 and amount 300 after routine execution
actual is 50 and 250.
when i do vf01 it displays 60 300
and saves 50 250?
i am posting my routine here.
FORM KOBED_604.
*{ INSERT DEVK900117 1
DATA: it_komv TYPE TABLE OF komv,
wa_komv TYPE komv,
kbetr TYPE kbetr,
fkbetr TYPE kbetr,
fkwert TYPE kwert,
vbeln TYPE vbfa-vbeln,
flag TYPE c,
kwert TYPE kwert.
amt TYPE zprice-rate.
if sy-tcode ne 'VF02'.
if sy-tcode ne 'VF03'.
it_komv[] = tkomv[].
if it_komv[] IS NOT INITIAL.
loop at tkomv WHERE kschl = 'ZROH'.
kbetr = tkomv-kbetr.
kwert = tkomv-kwert.
READ TABLE it_komv INTO wa_komv with key kschl = 'ZPR0' kposn = tkomv-kposn.
select single rate from zprice into rate where matnr = komp-matnr.
fkbetr = wa_komv-kbetr - kbetr + rate..
fkwert = fkbetr * komp-MGLME.
tkomv-kbetr = fkbetr.
tkomv-kwert = fkwert / 1000.
BREAK abapuser.
MODIFY tkomv.
*
ENDLOOP.
*
*
ENDIF.
endif.
endif.
endif.
sy-subrc = 0.
*} INSERT
ENDFORM.
‎2012 Mar 01 6:47 AM
Hi ,
are able to restrict users from changing the SO once invoice raised for it ? , if you able to do it then you wont have any issues ...
regards
Prabhu
‎2012 Mar 01 9:16 AM
‎2012 Mar 01 1:04 PM