Application Development and Automation 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: 
Read only

spell_amount

Former Member
0 Likes
1,432

Hi..

Iam trying to print the time in words using spell_amount FM. I split the time in to 3 pieces but I got the error

" Offset Specification "+3" is greater than or equal to field length ("2"). My code is...

data : var1(2) type n,

var2(2) type n,

var3(2) type n.

parameters : p_var1 type t. "like payr_fi-rwbtr default '123456789.12'.

split p_var1 at space into : var10(2) var23(2) var3+6(2).

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = var1

CURRENCY = 'INR'

  • FILLER = ' '

LANGUAGE = SY-LANGU

IMPORTING

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

Can any body help me....?

Regarda,

Prathima.M

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,385

Hi

use ur code like dis....



data : var1(2) type n,
var2(2) type n,
var3(2) type n,
spell TYPE spell.

parameters : p_var1 type t. 

var1 = p_var1+0(2).
var2 = p_var1+2(2).
var3 = p_var1+4(2).


CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = var1
CURRENCY = 'INR'


FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = 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.

Your p_var1 wont contain the delimiter '' : ".

so your split stmt will fail.

Use as per the above code.

and pass your var1,var2,var3 to your FM.....by calling it 3 times.

Revert back if ny queries

Regards

Winnie

12 REPLIES 12
Read only

Former Member
0 Likes
1,385

>

> parameters : p_var1 type t.

> split p_var1 at space into : var10(2) var23(2) var3+6(2).

Do you know what is type T?

and how much its lenght and what data type?

and more important why you choose type T.

Read only

0 Likes
1,385

Hi..,

Type t holds 6 characters.

its a time field.

Regards,

Pratima.M

Read only

Former Member
0 Likes
1,385

Hi

you hav split your hr,min,sec into 3 variables.

var2 is of lenght 2 and in your split stmt you hav given var2+3(2).

that variable var2+3(2) means that ur var2 is of lenght 5 which is not.

use like this

split p_var1 at space into : var1 var2 var3.

and call ur FM spell_amount thrice passing these 3 variables

Regards

Winnie

Read only

Former Member
0 Likes
1,385

data : var1(2) type n,

var2(2) type n,

var3(2) type n.

parameters : p_var1 type t. "like payr_fi-rwbtr default '123456789.12'.

split p_var1 at space into : var10(2) var23(2) var3+6(2).

=====

in split statement

for VAR2+3(2) means from 4th character

but your var2 contains only 1st & 2nd chars mean var20(2) only allowed not var23(2)

Read only

SujeetMishra
Active Contributor
0 Likes
1,385

Hi Pratima..

DATA : MONEY TYPE I,

VALUE LIKE SY-WAERS,

LANG LIKE SY-LANGU,

IN_LETTERS TYPE SPELL.

MONEY = 1000.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = MONEY

IMPORTING

IN_WORDS = IN_LETTERS

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3.

IF SY-SUBRC 0.

ENDIF.

WRITE : / MONEY, VALUE, IN_LETTERS-word.

Read only

Former Member
0 Likes
1,385

Hi Pratima,

Time format will be XX:YY:ZZ.

So you need to use the following syntax while splitting.

SPLIT p_var1 AT ' : ' INTO var1 var2 var3.

Then you can pass the splitted variables into the function module.

Hope this will help you.

Regards,

Anand.

Read only

0 Likes
1,385

Hi..,

I passed the variables into FM. But the var2 and var3 not taking the values ... this is my code

tables: spell.

data : var1(2) type n,

var2(2) type n,

var3(2) type n.

parameters : p_var1 type t. "like payr_fi-rwbtr default '123456789.12'.

split p_var1 at ':' into var1 var2 var3.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = var1

CURRENCY = 'INR'

  • FILLER = ' '

LANGUAGE = SY-LANGU

IMPORTING

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

write :

spell-decword(64).

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = var2

CURRENCY = 'INR'

  • FILLER = ' '

LANGUAGE = SY-LANGU

IMPORTING

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

write : spell-decword(64).

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = var3

CURRENCY = 'INR'

  • FILLER = ' '

LANGUAGE = SY-LANGU

IMPORTING

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

write: spell-decword(64).

  • spell-word(64).

Suggest me Plz...

Why they are not taking the value???.

Read only

Former Member
0 Likes
1,386

Hi

use ur code like dis....



data : var1(2) type n,
var2(2) type n,
var3(2) type n,
spell TYPE spell.

parameters : p_var1 type t. 

var1 = p_var1+0(2).
var2 = p_var1+2(2).
var3 = p_var1+4(2).


CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = var1
CURRENCY = 'INR'


FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = 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.

Your p_var1 wont contain the delimiter '' : ".

so your split stmt will fail.

Use as per the above code.

and pass your var1,var2,var3 to your FM.....by calling it 3 times.

Revert back if ny queries

Regards

Winnie

Read only

0 Likes
1,385

Hi..,

My problem is solved with ur Answer.. I have a small doubt.. regarding my code,, when i use the Split statement the var2 and var3 variables are not taking the values..Why?. Here ur passing the input to variables using offset but in "split" not able to take...???

Thanks & Regards,

Prathima.M

Read only

0 Likes
1,385

Hi

if u go into debugging mode, u will see dat p_var1 doesnt contain delimiters.

for eg: if p_var1 u enter as 10:25:05

the value is stored as 102505...so as u see,there is no delimiter " : " by which u can use ur split stmt.

that is y var2 & var3 r empty , since all the values get stored into var1.

and since u hav used offset as var1+0(2)...only 10 will be stored in var1.------>dis is as per ur original code

Hope i hav cleard ur doubt.

Thanx 4 ur points.

Regards

Winnie

Read only

0 Likes
1,385

Hi Pratima,

While using SPLIT statement we need to specify field separator.

In your case, the field separator is not there (like space or , or - or / or . etc..).

So the statement is not working.

It will be better if you use offset statement and pass those values to the FM.

Regards,

Anand.

Read only

0 Likes
1,385

Hi.,

Thanx for ur Answer...

Regards,

Prathima.M