cancel
Showing results for 
Search instead for 
Did you mean: 

Clear

Former Member
0 Kudos

hi sapscript masters,

i have a problem with the clearing of the VAT.

i have four line items with the value of 10000,10000,10000,10000 and the vat of the 4line items is 5600.

so am getting the correct vat where am happy with but the problem is using the transaction me22n i create the line items and and i get the VAT correctly but ...

once i see the vat and the total , i just go back and want to c again but now the VAT is increasing the double the vat .For ex the vat is 5600, so when i come next time it becomes 11200. its because the vat is not cleared when i come next time.

so i declared it globally and am clearing like this:

data: ka_kawrt like komvd-kawrt.

clear ka_kawrt. " clearing the vat amount.

clear output_table.

but when i debug and see my clear statement is not triggering as result i get double the amount of the vat.

so where can clear so that it can clear the old vat.

i try to stop and c where it gets stoped but it stops only at my subroutine and no where else to CLEAR the VAT.

please let me know if you have any idea as to where to CLEAR.

Thanks,

pasala.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

answered

Former Member
0 Kudos

Hi,

first check the variable name for VAT which you are printing in FORM, then find the variable in Print program. Now, before calculating the value just CLEAR the variable..

Hope it helps!!

Rgds,

Pavan

Former Member
0 Kudos

thats wat am doing but when i clear in subroutine what i have is the last value. if we clear globally then it would be fine... but the when i set the break point but it does not stop there to clear.

what else can i do to clear other than clearing it in subroutine.

former_member585865
Contributor
0 Kudos

Hi Bhasker,

you can clear the vat before calculating it,i.e just clear it in the top before calculation part.

so each time it first clears and then calculate the vat according to your condition.

Former Member
0 Kudos

hi suresh,

if that is the case i will only get one line item vat which is : 1400. because it clears the other vats before it looks into other line item.

i want the vat to as it is and calculate it according to the line items. in my case i would get 5600

when clear in subroutine it clears and what i left is the last value.

i want it to clear globally... please tell me how clear globally.

former_member585865
Contributor
0 Kudos

Hi Basker,

if you are calculating the vat each time from outside perform then try something like this,


  select ebeln ebelp from ekpo into CORRESPONDING FIELDS OF TABLE t_ebeln
                                 where ebeln = v_ebeln
                                 and   loekz NE 'L'.
  READ TABLE t_ebeln INDEX 1.
  if v_ebelp = t_ebeln-ebelp.
clear vat----------------------------->first time you clear vat then start caluculating vat
  endif.

from next time onwards it won't clear vat,but for next PO it starts from first.

pass your line items in v_ebelp.

but t_ebeln-ebelp always contains the first line item no i.e 10.

Former Member
0 Kudos

hi suresh,

thanks for the reply,

i have already the vat and this how i have coded it.

if sy-subrc = 0.

lv_kawrt = lv_fwste. "VAT amount

ka_kawrt = ka_kawrt + lv_fwste.

MOVE: 'KOMVD-KAWRT' TO output_table-name.

  • WRITE lv_kawrt TO output_table-value(21).

WRITE ka_kawrt TO output_table-value(21).

APPEND output_table.

so each time i have a line item it takes the vat and addes so by the end of the line items i get the value such as :5600.

but when i go back and come in again i have now the double the amount.

can you please help so that i can clear.

former_member585865
Contributor
0 Kudos

hi bhasker,

try something like this,


if sy-subrc = 0.
cnt = cnt + 1.----------------------------->have a variable called cnt.
if cnt = 1.
clear : lv_fwste------------------------->when back just check in debugging whether cnt starts from first or it keep on adds.
endif.
lv_kawrt = lv_fwste. "VAT amount
ka_kawrt = ka_kawrt + lv_fwste.

MOVE: 'KOMVD-KAWRT' TO output_table-name.
* WRITE lv_kawrt TO output_table-value(21).
WRITE ka_kawrt TO output_table-value(21).
APPEND output_table.

Former Member
0 Kudos

according to you it would clear all the time becase all the time it passes the code it would clear the vat as result we would get 0.

What do you say?

former_member585865
Contributor
0 Kudos

Hi Basker,

since we are declaring cnt as global variable i think it won't clear,have you checked in debugging is it clears when each time it comes,i hope we are clearing only for the first time.

Former Member
0 Kudos

hi suresh,

thank you for ur patience and time,

it clears but first time for the first line item.. then for the next 3line items it gives the values but however...

when i go back and come in the values are doubled again.

i have declared it as global varieable...even then i dont see any diff

b

former_member585865
Contributor
0 Kudos

Hi Basker,

have you getting the po number and line item no?

are you looping to get the vat?

if yes then check your condition like this,

if cnt = 1 or lineitem = '10'.

clear vat now.

endif.

try like this.