01-22-2009 6:34 PM
HI guys: Please help me... I have a requirement where the client wants to put the amount in words on a check sap script as follows:
If the amount is 27,150.95 USD
they want "27,150 DOLLARS AND 95 CENTS"
this is a combination of amounts and words in the "amounts in words" window of the sap script
please help
thanks
Brian
01-22-2009 9:24 PM
Hi,
In the window where the amount is displayed in words,
add the following code:
Script:
Say you have the amt in &amt&
/: DEFINE &DOLLARS& = SPACE
/: DEFINE &CENTS& = SPACE
/: PERFORM split_amount USING &AMT(T)&
/: CHANGING &DOLLARS&
/: CHANGING &CENTS&
P &DOLLARS& Dollars &CENTS& Cents Only
( P can be any paragraph format you want to use.
(T) in the AMT while passing will get your amount rid of thousand seperators)
-
Code should be put as follows in the Routine program:
DATA: amt(10) TYPE C, (Length specified should correspond to the total length of the amount field including the decimal)
p_dollar(7) TYPE c,
p_cents(2) TYPE c.
FORM split_amount USING in_tab STRUCTURE itcsy
CHANGING out_tab1 STRUCTURE itcsy
CHANGING out_tab2 STRUCTURE itcsy.
READ TABLE in_tab INDEX 1.
MOVE in_tab-value TO amt.
CHECK sy-subrc EQ 0.
SPLIT amt AT '.' INTO p_dollar p_cents.
IF sy-subrc NE 0.
SPLIT amt AT ',' INTO p_dollar p_cents.
ENDIF. (We have two SPLIT cos we may either have dot OR comma for decimal notation. This will cover both the cases)
READ TABLE out_tab1 INDEX 1.
CHECK sy-subrc EQ 0.
MOVE p_dollars INTO out_tab1-value.
MODIFY out_tab INDEX sy-tabix.
READ TABLE out_tab2 INDEX 1.
CHECK sy-subrc EQ 0.
MOVE p_cents INTO out_tab1-value.
MODIFY out_tab INDEX sy-tabix.
Plz let me know if you have questions.
Thanks
Geetha
01-22-2009 6:37 PM
lv_string = 27,150.95 USD
split lv_string at '.' into l_a l_b.
Concatenate l_a 'DOLLARS' l_b 'CENTS' into lv_final.
01-22-2009 6:39 PM
Sandeep...should i insert this code into the SAP Script or in a program? sorry i am not too familiar with SAP script
thanks
Brian
01-22-2009 6:42 PM
his code can be writen in print program and need to call it in Script...
the code I provided need to be split in print program and call it in Script ..like I mentioned..
01-22-2009 6:38 PM
split the amount at . point and split into two variables...
/E: &itab-amount& Dollars &lv_point& only.
01-22-2009 9:24 PM
Hi,
In the window where the amount is displayed in words,
add the following code:
Script:
Say you have the amt in &amt&
/: DEFINE &DOLLARS& = SPACE
/: DEFINE &CENTS& = SPACE
/: PERFORM split_amount USING &AMT(T)&
/: CHANGING &DOLLARS&
/: CHANGING &CENTS&
P &DOLLARS& Dollars &CENTS& Cents Only
( P can be any paragraph format you want to use.
(T) in the AMT while passing will get your amount rid of thousand seperators)
-
Code should be put as follows in the Routine program:
DATA: amt(10) TYPE C, (Length specified should correspond to the total length of the amount field including the decimal)
p_dollar(7) TYPE c,
p_cents(2) TYPE c.
FORM split_amount USING in_tab STRUCTURE itcsy
CHANGING out_tab1 STRUCTURE itcsy
CHANGING out_tab2 STRUCTURE itcsy.
READ TABLE in_tab INDEX 1.
MOVE in_tab-value TO amt.
CHECK sy-subrc EQ 0.
SPLIT amt AT '.' INTO p_dollar p_cents.
IF sy-subrc NE 0.
SPLIT amt AT ',' INTO p_dollar p_cents.
ENDIF. (We have two SPLIT cos we may either have dot OR comma for decimal notation. This will cover both the cases)
READ TABLE out_tab1 INDEX 1.
CHECK sy-subrc EQ 0.
MOVE p_dollars INTO out_tab1-value.
MODIFY out_tab INDEX sy-tabix.
READ TABLE out_tab2 INDEX 1.
CHECK sy-subrc EQ 0.
MOVE p_cents INTO out_tab1-value.
MODIFY out_tab INDEX sy-tabix.
Plz let me know if you have questions.
Thanks
Geetha