on 08-08-2008 11:56 AM
Hi,
In my Invoice Form, I need to display net price, which uses the following calculation : NETPR = NETWR / FKIMG.
Here NETWR & NETPR are CURR fields.
FKIMG is QUAN field.
I'm calling the Subroutine in my Script as follows:
/: PERFORM CALC_NETPRICE IN PROGRAM ZRECHNUN
/: USING &VBDPR-NETWR&
/: USING &VBDPR-FKIMG&
/:CHANGING &VBDPR-NETPR&
/:ENDPERFORM.
In my Print program, I'm using the following logic :
FORM calc_netprice TABLES itab STRUCTURE itcsy
otab STRUCTURE itcsy.
DATA: v_field1 TYPE netwr,
v_field2 TYPE fkimg,
v_result TYPE netwr.
READ TABLE itab WITH KEY name = 'VBDPR-NETWR'.
IF sy-subrc = 0.
v_field1 = itab-value.
CONDENSE v_field1.
ENDIF.
READ TABLE itab WITH KEY name = 'VDBPR-FKIMG'.
IF sy-subrc = 0.
v_field2 = itab-value.
CONDENSE v_field2.
ENDIF.
*--to modify PACK value
*--write your logic to get the value inTO RESULT.
IF V_FIELD2 NE 0.
V_RESULT = V_FIELD1 / V_FIELD2.
ENDIF.
READ TABLE OTAB WITH KEY NAME = 'VBDPR-NETPR'.
OTAB-VALUE1 = V_RESULT.
MODIFY OTAB TRANSPORTING VALUE1 WHERE NAME = 'VBDPR-NETPR'.
ENDFORM.
But the program is going for short-dump, displaying the following message :
Unable to interpret " 10,91 " as a number
or
Unable to convert type P of BCD format.
Pls guide me with the exact code which can handle CURR & QUAN conversions during a subroutine call in Scripts.
Thanks in advance..
Rgds,
LP
Hi,
Try this code, declared fields are same data type as ur script fields. i.e., the Domain names of each field declared are same as the fields which u r calling in SAPScript PERFORM using and changing parameters.
FORM CALC_NETPRICE TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
Data : w_netwr type lips-netwr,
w_fkimg type vbrp-fkimg,
w_netpr type fplt-netpr.
READ TABLE in_tab INDEX 1.
w_netwr = in_tab-value.
READ TABLE in_tab INDEX 2.
w_fkimg = in_tab-value.
IF w_fkimg NE 0.
w_netpr = w_netwr / w_fkimg.
ENDIF.
READ TABLE out_tab INDEX 1.
MOVE w_netpr TO out_tab-value.
MODIFY out_tab INDEX sy-tabix.
ENDFORM. "CALC_NETPRICE
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, changing the local variables to 'C' type doesnt help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try by using character type . for the field in which ur get the result.
v_result TYPE char18.
Regards
Anbu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.