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: 

How to call function module in SAPscript

Former Member
0 Kudos

Hello Experties,

I hav a function Module 'ZIN_SPELL_AMOUNT'

to print amount in words that i want to call in SAPscript.I hav written the code in follwing manner

IN SAPSCRIPT WINDOW

Perform sub_amt in program ztestscript

/: USING &AMT&

/:CHANGING &AMT_WORD&

/:ENDPERFORM

IN ZTESTSCRIPT PROGRAM

REPORT ZTESTSCRIPT.

FORM sub_amt

TABLES in_par structure itcsy

out_par structure itcsy.

data : amt LIKE BSEG-WRBTR.

DATA : l_word TYPE string.

READ table in_par with key 'regud-WAERS'.

CHECK sy-subrc = 0.

amt = in_par-value.

CALL FUNCTION 'ZIN_SPELL_AMOUNT'

EXPORTING

P_NUMBER = amt

IMPORTING

AMTWORD = l_word

EXCEPTIONS

AMOUNT_NOT_ENTERED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ table out_par with key 'amt_word'.

out_par-value = l_word.

MODIFY out_par INDEX SY-TABIX.

ENDFORM. "sub_amt

BUT ABOVE CODE IS NOT WORKING .

SO PLZ ANYONE GUIDE ME FOR THE SAME,

THANKSS & REGARDS,

SADIK.

6 REPLIES 6

Former Member
0 Kudos

Hi Sadik,

Use 'AMT' in place of 'regud-WAERS' in the statement below.

READ table in_par with key 'regud-WAERS'.

Try out with above change.

And also use

READ table out_par with key name = 'amt_word'.

instead of

READ table out_par with key 'amt_word'.

Ajay Kodali.

Former Member
0 Kudos

hi,

have a look at <b>READ TABLE</b> statement. it must be <b>READ TABLE <ITAB> WITH KEY out_par-name = 'AMT_WORD'</b>

also look at the case sensitiveness.

reward if useful...

Former Member
0 Kudos

Hello,

Debug the script and check wether &AMT& is getting populated.

Next debug report and see wether in the report the in_par-value value is getting populated.

Next see the amt field is getting populated.

When u are reading the

READ table out_par with key 'amt_word'.

make this 'amt_word' caps

Please check and let me know.

Regards

Former Member
0 Kudos

HI sadik,

1. CAPITAL

2. READ table out_par with key 'amt_word'.

should be

READ table out_par with key <b>'AMT_WORD'.</b>

regards,

amit m.

Former Member
0 Kudos

Hi,

See the bold one ..

Perform sub_amt in program ztestscript

/: USING &AMT&

/:CHANGING &AMT_WORD&

/:ENDPERFORM

IN ZTESTSCRIPT PROGRAM

REPORT ZTESTSCRIPT.

FORM sub_amt

TABLES in_par structure itcsy

out_par structure itcsy.

data : amt LIKE BSEG-WRBTR.

DATA : l_word TYPE string.

<b>READ table in_par with key 'AMT.</b>

CHECK sy-subrc = 0.

amt = in_par-value.

CALL FUNCTION 'ZIN_SPELL_AMOUNT'

EXPORTING

P_NUMBER = amt

IMPORTING

AMTWORD = l_word

EXCEPTIONS

AMOUNT_NOT_ENTERED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ table out_par with key 'amt_word'.

out_par-value = l_word.

MODIFY out_par INDEX SY-TABIX.

ENDFORM. "sub_amt

Regards

Sudheer

Former Member
0 Kudos

Try this.. If works mark it is answered..

REPORT ZTESTSCRIPT.

FORM sub_amt

TABLES in_par structure itcsy

out_par structure itcsy.

data : amt LIKE BSEG-WRBTR.

DATA : l_word TYPE string.

<b>READ table in_par INDEX 1.</b>

CHECK sy-subrc = 0.

amt = in_par-value.

CALL FUNCTION 'ZIN_SPELL_AMOUNT'

EXPORTING

P_NUMBER = amt

IMPORTING

AMTWORD = l_word

EXCEPTIONS

AMOUNT_NOT_ENTERED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

<b>READ table out_par with key 'AMT_WORD'.</b>

out_par-value = l_word.

MODIFY out_par INDEX SY-TABIX.

ENDFORM. "sub_amt

Regs

Rakesh