‎2007 Mar 23 5:44 PM
Hi,
I'm facing one big issue in scripts.ie: in printing totals.
for totals i write a subroutine in scripts.
it's working fine.it's displaying totals well.here my problem is first i see the print preview.at that time total is correct.but when i came back and see the print preview again it displaying wrong.ie if first time the total is 'A'.Then second time it displaying like (A+A).
other problem is when i see the print preview and displays it and go back and took the print at that time also it displaying (A+A).
My code is like :
&----
*
*& Form GET_EXTPR_TOT
&----
this routine will get the LINE ITEM EXTENDED PRICE TOTALS When
there is no PROMO CODE.
----
----
form get_extpr_tot tables it_input structure itcsy it_output structure itcsy.
data: v_vbeln2(10) type n.
clear it_input.
clear v_vbeln2.
read table it_input index 1.
move it_input-value to v_vbeln2.
read table it_input index 2.
move it_input-value to v_extpr_tot.
v_extpr_tot1 = v_extpr_tot1 + v_extpr_tot.
read table it_output index 1.
write v_extpr_tot1 to it_output-value left-justified.
modify it_output index 1.
clear it_output.
endform. "GET_EXTPR_TOT
Please Send ur valuable answers.
Thanks,
Srinivas.
‎2007 Mar 26 1:41 PM
Hi Raj,
im calling that from scripts.
in se71:
/E ITEM_LINE_PRICE_QUANTITY
/* Begin of modification (RICEF/Issue Number:F-SD-04) by sbhavanam
/: PERFORM GET_EXTPR_TOT IN PROGRAM ZSP_SD_ORDCM.
/: USING &VBDKA-VBELN&
/: USING &V_PRICE&
/: CHANGING &V_EXTPR_TOT1&
/: ENDPERFORM
My ABAP code is:
FORM get_extpr_tot TABLES it_input STRUCTURE itcsy it_output STRUCTURE itcsy.
DATA: v_vbeln2(10) TYPE n
.
CLEAR it_input.
CLEAR v_vbeln2.
CLEAR v_extpr_tot.
READ TABLE it_input INDEX 1.
MOVE it_input-value TO v_vbeln2.
READ TABLE it_input INDEX 2.
MOVE it_input-value TO v_extpr_tot.
v_extpr_tot1 = v_extpr_tot1 + v_extpr_tot.
v_extpr_tot_tst = v_extpr_tot_
READ TABLE it_output INDEX 1.
WRITE v_extpr_tot1 TO it_output-value LEFT-JUSTIFIED.
MODIFY it_output INDEX 1.
CLEAR it_output.
ENDFORM. "GET_EXTPR_TOT
Please send ur valuable input's.
Thanks & Regards,
Srinivas
‎2007 Mar 23 5:53 PM
Try clearing the variable as show below:
Thanks,
Santosh
&----
*
*& Form GET_EXTPR_TOT
&----
this routine will get the LINE ITEM EXTENDED PRICE TOTALS When
there is no PROMO CODE.
----
----
form get_extpr_tot tables it_input structure itcsy it_output structure itcsy.
data: v_vbeln2(10) type n.
clear it_input.
clear v_vbeln2.
read table it_input index 1.
move it_input-value to v_vbeln2.
read table it_input index 2.
move it_input-value to v_extpr_tot.
v_extpr_tot1 = v_extpr_tot1 + v_extpr_tot.
<b>clear v_extpr_tot1.</b><b></b>
read table it_output index 1.
write v_extpr_tot1 to it_output-value left-justified.
modify it_output index 1.
clear it_output.
Message was edited by:
SKJ
‎2007 Mar 23 5:56 PM
Hi Srinivasa,
You are not clearing the value of v_extpr_tot1 after moving to the totals and you maintained this as global one in the program, so its scope will be entire program.
So, clear this value and re run the script once.
data: v_vbeln2(10) type n.
clear it_input.
clear v_vbeln2.
read table it_input index 1.
move it_input-value to v_vbeln2.
read table it_input index 2.
move it_input-value to v_extpr_tot.
v_extpr_tot1 = v_extpr_tot1 + v_extpr_tot.
read table it_output index 1.
write v_extpr_tot1 to it_output-value left-justified.
modify it_output index 1.
<b>clear v_extpr_tot1.</b>
clear it_output.
Thanks,
Vinay
‎2007 Mar 23 6:22 PM
Hi Srinivasa,
You have defined the variable v_extpr_tot1 as a global variable in external program, instead you should be defining it in the script (MAIN windows )and passing in as an input to the perform. That way when you reexecute the script (i.e go back into print preview for the second time ) it will be redefined and cleared. And your totals will not change even you repeatedly go back into print preview.
-Kalyan
‎2007 Mar 23 7:56 PM
Hi Vinay,
when i clear v_extpr_tot1.then it's clear the values.
for example i have 3 line items.then at this time it's displaying 3rd line item.
i.e: 1 st line item is having 10
2 nd line item is having 20
3 rd line item is having 30.
here we need to calculate 102030---. 60
but when we use clear v_extpr_tot1 then it displays -
>total value is 60 only,
please send ur valuble suggestions for this problem.
Thanks,
Srinivas
‎2007 Mar 23 8:31 PM
Hi Kalyan
can u give some clear view with small example please.
Thanks,
Srinivas.
‎2007 Mar 24 1:56 AM
Hi Srinivas,
You must be calling this routine some where in a loop. Make sure that you clear the variable "v_extpr_tot1" before entering the loop.
Hope this solves your problem. If this solution did not solve your problem then paste the code from where you are calling this subroutine.
Enjoy SAP. Reward points if this solution is useful
Rajasekhar
‎2007 Mar 26 1:41 PM
Hi Raj,
im calling that from scripts.
in se71:
/E ITEM_LINE_PRICE_QUANTITY
/* Begin of modification (RICEF/Issue Number:F-SD-04) by sbhavanam
/: PERFORM GET_EXTPR_TOT IN PROGRAM ZSP_SD_ORDCM.
/: USING &VBDKA-VBELN&
/: USING &V_PRICE&
/: CHANGING &V_EXTPR_TOT1&
/: ENDPERFORM
My ABAP code is:
FORM get_extpr_tot TABLES it_input STRUCTURE itcsy it_output STRUCTURE itcsy.
DATA: v_vbeln2(10) TYPE n
.
CLEAR it_input.
CLEAR v_vbeln2.
CLEAR v_extpr_tot.
READ TABLE it_input INDEX 1.
MOVE it_input-value TO v_vbeln2.
READ TABLE it_input INDEX 2.
MOVE it_input-value TO v_extpr_tot.
v_extpr_tot1 = v_extpr_tot1 + v_extpr_tot.
v_extpr_tot_tst = v_extpr_tot_
READ TABLE it_output INDEX 1.
WRITE v_extpr_tot1 TO it_output-value LEFT-JUSTIFIED.
MODIFY it_output INDEX 1.
CLEAR it_output.
ENDFORM. "GET_EXTPR_TOT
Please send ur valuable input's.
Thanks & Regards,
Srinivas
‎2007 Mar 27 2:36 PM
Hi Srinivas,
In your script you can define the total variable in one of the header related elements that will be called. for exaple you can define it in the element
/E HEADER_TARGET_VALUE
/: DEFINE &V_EXTPR_TOT1& = ' '
and change your code in ITEM_LINE_PRICE_QUANTITY element as follows
/E ITEM_LINE_PRICE_QUANTITY
/* Begin of modification (RICEF/Issue Number:F-SD-04) by sbhavanam
/: PERFORM GET_EXTPR_TOT IN PROGRAM ZSP_SD_ORDCM.
/: USING &VBDKA-VBELN&
/: USING &V_PRICE&
/: CHANGING &V_EXTPR_TOT1&
/: ENDPERFORM
your abap should look like this.
FORM get_extpr_tot TABLES it_input STRUCTURE itcsy it_output STRUCTURE itcsy.
DATA: v_vbeln2(10) TYPE n
.
* CLEAR it_input.
CLEAR v_vbeln2.
CLEAR v_extpr_tot.
READ TABLE it_input INDEX 1.
MOVE it_input-value TO v_vbeln2.
READ TABLE it_input INDEX 2.
MOVE it_input-value TO v_extpr_tot.
read table it_input index 3.
move it_input-value to v_extpr_tot1.
v_extpr_tot1 = v_extpr_tot1 + v_extpr_tot.
* v_extpr_tot_tst = v_extpr_tot_
READ TABLE it_output INDEX 1.
WRITE v_extpr_tot1 TO it_output-value LEFT-JUSTIFIED.
MODIFY it_output INDEX 1.
CLEAR it_output.
ENDFORM. "GET_EXTPR_TOT
that should solve your issues.
-Kalyan
‎2007 Mar 27 3:45 PM
Hi Kalyan,
it's working fine.thanks for ur reply.
Thanks,
Srinivas.