cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform error: Incorrect nesting

Former Member
0 Kudos

Hi,

I have been trying to use Spell_Amount in smartform. The code I have used is working fine in report but giving following error in smartform :

Incorrect nesting: Before statement "Form", the structure introduced by "Function" must be concluded with "Endfunction".

Code I have used is:

TABLES SPELL.

DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.

Data : S_WRBTR LIKE BSEG-WRBTR.

SY-TITLE = 'SPELLING NUMBER'.

PERFORM SPELL_AMOUNT USING s_wrbtr 'inr'.

FORM spell_amount USING s_wrbtr pwaers.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

amount = s_wrbtr

currency = pwaers

filler = space

language = 'E'

IMPORTING

in_words = t_spell

EXCEPTIONS

not_found = 1

too_large = 2

OTHERS = 3.

endform.

Can I have some help?

Thnx

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi ,

There are 2 ways you can solve this

1). Call the Function module directly in the program lines, instead of calling it in a sub routine.

2). if you really want to use a sub routine , then your FORM ENDFORM should be in the form routines tab of the global definitions. The FORM ENDFORM should not be written anywhere else in the form. But you call the PERFORM anywhere in the smartform.

Hope this helps.

Regards,

Praveenkumar T.

Former Member
0 Kudos

i dont understand why u are making this so complex.

as per ur requirement u need to just print the amount in words.


in Global defination declare 
t_spell type spell.
in main window-create program lines.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
 AMOUNT          = AMOUNT
*   CURRENCY        = ' '
*   FILLER          = ' '
 LANGUAGE        = SY-LANGU
IMPORTING
 IN_WORDS        = T_SPELL
EXCEPTIONS
 NOT_FOUND       = 1
 TOO_LARGE       = 2
 OTHERS          = 3
        .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

print &t_spell-word& in TEXT created wherever u need.

tell me if i misunderstood your requirement.

Former Member
0 Kudos

Try the following code:

it worked for me.

In Global Definitions --> Global Data Define:

WORDS type Spell
wt_total type tablename-fieldname " wt_total is the field you want in words.

Create a Window Words and place it after you have the value of wt_total.

In Window Words:

Rt. Click--> Create --> flow Logic --> Program Lines

Output Parameters --> wt_total,

Words.

call function 'SPELL_AMOUNT'
 exporting
   amount          = wt_total
*   CURRENCY        = ' '
*   FILLER          = ' '
*   LANGUAGE        = SY-LANGU
 importing
   in_words        = words
* EXCEPTIONS
*   NOT_FOUND       = 1
*   TOO_LARGE       = 2
*   OTHERS          = 3
          .
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

3. Create a text and put value

&Words-word& in it.

Let me know if it worked...

<removed by moderator>

Edited by: Thomas Zloch on Feb 17, 2012

Former Member
0 Kudos

I would try the following; first try the function call outside the perform block.

If this doesn't help, try to find out whether there is a block before your function call that is not properly closed yet. Maybe you have a spelling error in the code preceding your function call.

Former Member
0 Kudos

Hi,

Try the below two options

1. Declare the form code in global defination FORM ROUTINE TAB in smartform

FORM spell_amount USING s_wrbtr pwaers.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

amount = s_wrbtr

currency = pwaers

filler = space

language = 'E'

IMPORTING

in_words = t_spell

EXCEPTIONS

not_found = 1

too_large = 2

OTHERS = 3.

endform.

Or

2. call the FM directly in the program line without using the PERFORM.

Revert back

Regards,

Madhukar Shetty

Former Member
0 Kudos

Hi,

Can you tel me where have u writen the given code in smartform ?

or either u can do is just call the function module directly with out using the perform .

Regards,

Madhukar Shetty

Former Member
0 Kudos

i have written the code in program lines

Former Member
0 Kudos

Hi,

FORM spell_amount USING s_wrbtr pwaers.

In this statement, you are not using the data type of s_wrbtr and pwaers.

For spell_amount using s_wrbtr type <>

pwaers type <>

This should solve your query.

Regards

Tarun

Former Member
0 Kudos

Just try to activate anyway, and then check with Ctr+F2 , and reply if the problem still exists.

former_member186052
Active Participant
0 Kudos

Hi,

I'm not sure but, can you once erase your form and end form and try creating again by double clicking on the name in the PERFORM statement, which will help you create the FORM & ENDFORM automatically.

Hope this works.

Regards,

-Sandeep