Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Script ~ Put Amount in words & amounts

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

5 REPLIES 5

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.

0 Kudos

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

0 Kudos

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..

former_member156446
Active Contributor
0 Kudos

split the amount at . point and split into two variables...

/E: &itab-amount& Dollars &lv_point& only.

Former Member
0 Kudos

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