05-10-2006 5:42 PM
Dear All,
I am having a problem in SAP Script. I have 2 fields total and Tax, I have to perform a arthematic operation and get sub-total, Total - Tax. I am using below code but I am getting error as CONVT_NO_NUMBER. UNABLE TO INTERPRET ' 01500.00'as a number.
Please help me in this regard. please seee the code ..as I am a new-bie, I might making some silly mistake. Please look at this problem and suggest me.
I have been suggested by my friend to use ..Move but I am not sure ..how to do that. Please kindly spare some time.
/: PERFORM GET_SUBTOTAL IN PROGRAM ZGET_SUBTOTAL
/: USING &BSEG-WRBTR&
/: USING &BSEG-WMWST&
/: CHANGING &S_SUBTOTAL&
/: ENDPERFORM.
Sub-routine Program.
PROGRAM ZGET_SUBTOTAL.
FORM GET_SUBTOTAL TABLES INT_COND STRUCTURE ITCSY
OUT_COND STRUCTURE ITCSY.
DATA : W_WRBTR TYPE BSEG-WRBTR, " Total
W_WMWST TYPE BSEG-WMWST. " Tax
READ TABLE INT_COND INDEX 1.
W_WRBTR = INT_COND-VALUE.
READ TABLE INT_COND INDEX 2.
W_WMWST = INT_COND-VALUE.
OUT_COND-NAME = 'S_SUBTOTAL'.
OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1.
ENDFORM.
Thanking you.
With kind Regards
Venkat
05-10-2006 5:47 PM
05-10-2006 5:47 PM
05-10-2006 6:03 PM
Hi Rich,
Thank you very much for your quick response.
I tried that but getting same error.
I guess this is conversion error.
Anyway, Please kindly complete the code.
right Now I am using.
PROGRAM ZGET_SUBTOTAL.
FORM GET_SUBTOTAL TABLES INT_COND STRUCTURE ITCSY
OUT_COND STRUCTURE ITCSY.
DATA : W_WRBTR TYPE BSEG-WRBTR,
W_WMWST TYPE BSEG-WMWST.
READ TABLE INT_COND INDEX 1.
clear w_wrbtr.
W_WRBTR = W_WRBTR + INT_COND-VALUE. 'I am having small confusion here, both fields are same.
READ TABLE INT_COND INDEX 2.
clear w_wmwst.
W_WMWST = W_WMWST + INT_COND-VALUE.
OUT_COND-NAME = 'S_SUBTOTAL'.
OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1.
ENDFORM.
Thanking you.
Regards
Venkat
05-10-2006 6:13 PM
Do like this :
PROGRAM ZGET_SUBTOTAL.
FORM GET_SUBTOTAL TABLES INT_COND STRUCTURE ITCSY
OUT_COND STRUCTURE ITCSY.
DATA : W_WRBTR TYPE BSEG-WRBTR,
W_WMWST TYPE BSEG-WMWST,
<b>new_var TYPE BSEG-WMWST.</b>
READ TABLE INT_COND INDEX 1.
clear w_wrbtr.
W_WRBTR = W_WRBTR + INT_COND-VALUE. 'I am having small confusion here, both fields are same.
READ TABLE INT_COND INDEX 2.
clear w_wmwst.
W_WMWST = W_WMWST + INT_COND-VALUE.
OUT_COND-NAME = 'S_SUBTOTAL'.
<b>new_var = W_WRBTR - W_WMWST.</b>
<b>write new_var to OUT_COND-VALUE.</b>
MODIFY OUT_COND INDEX 1.
ENDFORM.
Hope thisll give you idea!!
<b>P.S award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
05-10-2006 6:13 PM
Please check the value of INT_COND-VALUE right before the execution of the statement. You will need a break-point here. If the value of this field contains any non-numerical value, you will get this dump. I'm thinking that a comma may be causing the problem. If so, we can take care of that. First, check the value of the field at runtime.
Regards,
Rich Heilman
05-10-2006 6:17 PM
Hi venkat,
<b>READ TABLE INT_COND INDEX 1.
clear w_wrbtr.
W_WRBTR = W_WRBTR + INT_COND-VALUE.
READ TABLE INT_COND INDEX 2.
clear w_wmwst.
W_WMWST = W_WMWST + INT_COND-VALUE.</b>
here you need to change your logic little,
see you will get the data as chars. so you need to move the data to currecncy field.
then do calculation.
some thing like this..
READ TABLE INT_COND INDEX 1.
clear w_wrbtr.
write int_cond-value to x_wrbtr . "x_wrbtr of type wrbtr
W_WRBTR = W_WRBTR + x_wrbtr.
now you will not get that error.
i think <b>clear</b> not required. i think you are doing it item wise and printing, in this case one all items over you can print.
can you confirm it ...
Regards
vijay
05-10-2006 6:26 PM
Hi Rich / Khan / Aman,
Thank you very much for your inputs ...
I tried to debug, the value of INT_COND-VALUE is ' 1,500.00'. morever I am getting many blank spaces before '1,500.00'
with old code, error was at arthematic operation but now just after this step, it causes dump.
Please advice me further.
Anyway, I guess the problem would be same for Khan's suggestion. however I will try and let you know.
looking farward for futher suggestions.
Thanking you.
Venkat
05-10-2006 6:28 PM
The comma is definitly your problem, you can remove it by using the translate statement.
DATA : W_WRBTR TYPE BSEG-WRBTR, " Total
W_WMWST TYPE BSEG-WMWST. " Tax
READ TABLE INT_COND INDEX 1.
<b>translate INT_COND-VALUE using ', '.
condense INT_COND-VALUE no-gaps.</b>
W_WRBTR = INT_COND-VALUE.
READ TABLE INT_COND INDEX 2.
<b>translate INT_COND-VALUE using ', '.
condense INT_COND-VALUE no-gaps.</b>
W_WMWST = INT_COND-VALUE.
Regards,
Rich Heilman
05-10-2006 6:51 PM
Hi All,
Thank you very much once again. I will try all your suggestions and get back to you.
Anyway, Vijay.. I am getting snytax error with your code.
it says
<b>X_WRbtr must be a Charecter-type field (data type C,N,D,T).</b>
Please advice me futher.
Thanking you .. will allot points to all of you as a token of gratitude.
Regards
Venkat.
05-10-2006 6:58 PM
Ok, but you need to make it as currency field with out commas and you will be able to do manipulations.
i think Rich's suggestion will work.
Regards
vijay
05-10-2006 7:51 PM
Hi All,
Thanks for your inputs,
Rich I followed your suggestion but I am unable to get OUT_COND-VALUE. it just shoes blank spaces.
I guess that I am doing some silly mistake.
Please have a look at this code.
PROGRAM ZGET_SUBTOTAL.
Thanking you.
Regards
Venkat
FORM GET_SUBTOTAL TABLES INT_COND STRUCTURE ITCSY
OUT_COND STRUCTURE ITCSY.
DATA : W_WRBTR TYPE BSEG-WRBTR,
W_WMWST TYPE BSEG-WMWST.
READ TABLE INT_COND INDEX 1.
translate INT_COND-VALUE using ', '.
condense INT_COND-VALUE no-gaps.
W_WRBTR = INT_COND-VALUE.
READ TABLE INT_COND INDEX 2.
translate INT_COND-VALUE using ', '.
condense INT_COND-VALUE no-gaps.
W_WMWST = INT_COND-VALUE.
OUT_COND-NAME = 'S_SUBTOTAL'.
OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1.
ENDFORM.
05-10-2006 7:59 PM
Hi Venkat,
are you getting any value of the below diff.
*OUT_COND-NAME = 'S_SUBTOTAL'. "this is not required
OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1.
Regards
vijay
05-10-2006 8:05 PM
Hi Vijay,
No, I am unable to get that difference.
I could get values for INT_COND-VALUE for 2 times
as 1500.00 and 0.00 respectively but could not get the difference i,e OUT_COND-VALUE
Moreover, if *OUT_COND-NAME = 'S_SUBTOTAL'.
is not required, how can I print on form.
sorry for my ingnorance. Thanking you.
Regards
Venkat
05-10-2006 8:12 PM
Hi,
some how try to move to some number fields then find the difference , and then use move.
MOVE v_diff TO out_tab-value.
*OUT_COND-NAME = 'S_SUBTOTAL'.
and you are having that already(in index1) then why do you need?
try to take some number variables and then convert them to numbers and find diff.
and use move
Regards
vijay
05-10-2006 8:35 PM
/: PERFORM GET_SUBTOTAL IN PROGRAM ZGET_SUBTOTAL
/: USING &BSEG-WRBTR&
/: USING &BSEG-WMWST&
/: CHANGING &S_SUBTOTAL&
/: ENDPERFORM.
As you are already passing the S_SUBTOTAL with the changing paramter and in the Form you have that value in table OUT_COND.
So no need to for this statment OUT_COND-NAME = 'S_SUBTOTAL'.
As you have only 1 value in the CHANGING . If there are multipal values in the CHANGING then you need to READ THE TABLE OUT_COND WITH INDEX.
05-10-2006 6:13 PM
Delete the <b>BOLD</b> part and enter <u><i>Underline and Italic</i></u> part.
/: PERFORM GET_SUBTOTAL IN PROGRAM ZGET_SUBTOTAL
/: USING &BSEG-WRBTR&
/: USING &BSEG-WMWST&
/: CHANGING &S_SUBTOTAL&
/: ENDPERFORM.
Sub-routine Program.
PROGRAM ZGET_SUBTOTAL.
FORM GET_SUBTOTAL TABLES INT_COND STRUCTURE ITCSY
OUT_COND STRUCTURE ITCSY.
DATA : W_WRBTR TYPE BSEG-WRBTR, " Total
W_WMWST TYPE BSEG-WMWST. " Tax
READ TABLE INT_COND INDEX 1.
W_WRBTR = INT_COND-VALUE.
READ TABLE INT_COND INDEX 2.
W_WMWST = INT_COND-VALUE.
<b>OUT_COND-NAME = 'S_SUBTOTAL'.</b>
<i><u>READ TABEL OUT_COND INDEX 1.</u></i>
OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1.
ENDFORM.
05-10-2006 6:15 PM
05-10-2006 8:23 PM
Hi Venkat,
Pls make the following changes in form routine.
PROGRAM ZGET_SUBTOTAL.
FORM GET_SUBTOTAL TABLES INT_COND STRUCTURE ITCSY
OUT_COND STRUCTURE ITCSY.
DATA: STR_AMT(255) TYPE C.
W_WRBTR TYPE BSEG-WRBTR, " Total
W_WMWST TYPE BSEG-WMWST. " Tax
READ TABLE INT_COND INDEX 1.
STR_AMT = INT_COND-VALUE.
SY-SUBRC = 0.
WHILE SY-SUBRC = 0.
REPLACE ',' WITH ' ' INTO STR_AMT.
ENDWHILE.
CONDENSE STR_AMT NO-GAPS.
MOVE STR_AMT TO W_WRBTR.
READ TABLE INT_COND INDEX 2.
STR_AMT = INT_COND-VALUE.
SY-SUBRC = 0.
WHILE SY-SUBRC = 0.
REPLACE ',' WITH ' ' INTO STR_AMT.
ENDWHILE.
CONDENSE STR_AMT NO-GAPS.
MOVE STR_AMT TO W_WMWST.
READ TABLE OUT_COND INDEX 1.
IF SY-SUBRC EQ 0.
OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1.
ENDIF.
ENDFORM.
Hope this give you some idea!!!
Cheers,
Vikram
Pls reward points for helpful replies!!
05-10-2006 8:43 PM
Hi All.
Thanks you very much !!!!!!
Finally I got it ... But dont know how to keep it in form. I used a Number field and got the difference, But I wondering ..which field should I keep in form.
Here is my code. I got the result in debug mode.
PROGRAM ZGET_SUBTOTAL.
FORM GET_SUBTOTAL TABLES INT_COND STRUCTURE ITCSY
OUT_COND STRUCTURE ITCSY.
DATA : W_WRBTR TYPE BSEG-WRBTR,
W_WMWST TYPE BSEG-WMWST,
Num1 type p decimals 2.
READ TABLE INT_COND INDEX 1.
translate INT_COND-VALUE using ', '.
condense INT_COND-VALUE no-gaps.
W_WRBTR = INT_COND-VALUE.
READ TABLE INT_COND INDEX 2.
translate INT_COND-VALUE using ', '.
condense INT_COND-VALUE no-gaps.
W_WMWST = INT_COND-VALUE.
OUT_COND-NAME = 'NUM1'.
NUM1 = W_WRBTR - W_WMWST.
MOVE Num1 TO out_cond-value.
*OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1.
ENDFORM.
In SAP script editor my Perform statement is :
/: PERFORM GET_SUBTOTAL IN PROGRAM ZGET_SUBTOTAL
/: USING &BSEG-WRBTR&
/: USING &BSEG-WMWST&
/: CHANGING &S_SUBTOTAL&
/: ENDPERFORM
Finally, please suggest me how to populate this on form.
Thanks very much
Regards
Venkat
05-10-2006 8:47 PM
hi venkat,
from your post you are getting the difference showing it as subtotal.
as you are getting the diff , and movig the content to sub_total, after calling the perform, you can use &S_SUBTOTAL&
Regards
vijay
05-10-2006 8:50 PM
hi venkat,
since you have only one changing field,
you should not do like this..
*OUT_COND-NAME = 'NUM1'. X wrong
NUM1 = W_WRBTR - W_WMWST.
MOVE Num1 TO out_cond-value.
*OUT_COND-VALUE = W_WRBTR - W_WMWST.
MODIFY OUT_COND INDEX 1. "this is holds the reference of sub total
ENDFORM.
05-10-2006 8:57 PM
Hi Vijay,
Yeah Thats true, I tried keeping &S_SUBTOTAL& but this is not populating on form.
I expanded the window but it is not there.
Moreover I used &NUM1& as I am moving NUM1 INTO OUT_COND-VALUE.
but this is also not working, I believe that I am doing some small mistake.
Thank you very much for your help, Today I learned some new things chating with you guys. Thats really nice.
Anyway, I woonder ,why it is not populating on form. just to that field, I hard coded a text and I could see that. which makes me believe that ..this particular statement is executing. Please suggest me.
Thanks & Regards
Venkat
05-10-2006 9:04 PM
Every thing looks fine now.
Please check the variable name &S_SUBTOTAL& along with changing parameter of PERFORM and where you are printing &S_SUBTOTAL&.
Both have exact spelling.
Also check the value of OUT_COND in Debugger by putting break point in the form ENDFORM.
Message was edited by: Amandeep Singh
05-10-2006 9:06 PM
/: PERFORM GET_SUBTOTAL IN PROGRAM ZGET_SUBTOTAL
/: USING &BSEG-WRBTR&
/: USING &BSEG-WMWST&
/: CHANGING &S_SUBTOTAL& <<<<<<<<
/: ENDPERFORM
what ever you use here , using that only yuo should print.
in the out_cond index 1 will hold S_SUBTOTAL , num is declared in side the form, while calling the perform you gave s_subtotal , so you should give s_subtotal only,
and also no need of out_cond-name = is not required.
move NUM1 INTO OUT_COND-VALUE <<<what ever you move only value goes. nothing else.
in script you can access it with &s_subtotal&
Regards
vijay
05-10-2006 9:25 PM
Hi All,
MOVE NUM1 TO OUT_COND-VALUE ..
in debug mode..
I am getting value in NUM1
BUT not in OUT_COND-VALUE.
I took Num1 as pack with decimal.
this might be wrong ????
Thanks vijay for bareing with my post.
regards
Venkat
05-10-2006 9:40 PM
I think you need to remove the formatting before your PERFORM statement. You do not want the thousands separator or any other formatting. You can do this with the "(KT)" option in SAPscript.
Example..
/: PERFORM GET_SUBTOTAL IN PROGRAM ZGET_SUBTOTAL
/: USING &BSEG-WRBTR(KT)&
/: USING &BSEG-WMWST(KT)&
/: CHANGING &S_SUBTOTAL&
/: ENDPERFORM
When passing currency fields with a PERFORM, I have seen some decimal places set as ','. If this occurs, you should translate.
TRANSLATE INT_COND-VALUE using ',.'.
05-10-2006 9:53 PM
I just found some code where I am also doing a PERFORM in SAPscript with the field BSEG-WRBTR.
As I listed in the previous thread, I pass the USING variable like &BSEG-WRBTR(KT)& and do a TRANSLATE in the ABAP program (TRANSLATE INT_COND-VALUE USING ',.'). It seems to work fine.
05-11-2006 2:01 AM
Dear All,
Atlast .. I got !!!!!!!!!!
Thank you .Special thanks to Khan / Rich / Vijay.
I am closing this thread. awarding points.
Regards
Venkat