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: 

negative value for currency field in table control

Former Member
0 Kudos

hi all,

can one of you resolve this issue for me.

i have a table control on a screen which has one field as a currency field (afrv-hrbet).

i also have a separate I/O field on the screen of the same type as the table control currency field.

i am supplying values to both of these from the program (module pool). the trouble comes when i try to supply negative values....the I/O field accepts and displays the negative value but the table control field does not do so and execution ends up giving a dump for a conversion failure.

plz let me know why this is happening.

here is a test code extract in the module pool

DATA : BEGIN OF itab OCCURS 0,

fld1(10),

fld2(10),

fld3(10),

fld4 TYPE afrv-hrbet,

sel TYPE c,

END OF itab.

afrv-hrbet = '-100'.

*this is the I/O field that refers to dict definition,

*the table control field (itab-fld4) does not..it picks *up its type from the program....is this the issue?????

itab-fld1 = 'abc'.

itab-fld2 = 'abc'.

itab-fld3 = '100'.

itab-fld4 = '100'.

APPEND itab.

itab-fld1 = 'pqr'.

itab-fld2 = 'pqr'.

itab-fld3 = '200'.

itab-fld4 = '200'.

APPEND itab.

************************the above code runs fine but the following gives a dump

itab-fld1 = 'abc'.

itab-fld2 = 'abc'.

itab-fld3 = '100'.

itab-fld4 = '-100'.

APPEND itab.

itab-fld1 = 'pqr'.

itab-fld2 = 'pqr'.

itab-fld3 = '200'.

itab-fld4 = '-200'.

APPEND itab.

regards,

PJ

5 REPLIES 5

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Have you tried using this field as character?

0 Kudos

yes i have....no problems with that.

what i want to know is why the standalone I/O field is accepting a negative value while an I/O field that is a part of the table control is not, given that both are of the same type (afrv-hrbet).

regards,

PJ

0 Kudos

In dyupro u need to set the reference currency for the particular currency field. did u set that ?

Regards

Jeevi

0 Kudos

hi priyank,

may be this will your solve ur problem as i suggest it below.

take the negativ values into a character field of length same as the output legth of the field afrv-hrbet.

then use MOVE command i.e

MOVE charfield to amountfield(afrv-hrbet) and then assign this amount field to your itab field and then append your itab.

this should work for both positive as well as negative values.

normally the negative values automatically come in for amount fields.

so you cannot pass acharcter type values to the itab field with afrv-hrbet declartions.

hope this helps you out.

if this has helped pls do reward me up

thanks & regards,

venugopal

0 Kudos

hey Venkat

i have already done what u r saying.

hey Venu

i have tried using character fields and i have no problems....the issue is why is it happening with currencies only in a table control.

Thanks for your suggestions anyway....the way i have worked it out by specifying the text of the table control I/O field as ________V. this way at least it is not giving any dumps and i am able to display negative value in the table control

but i still keep the thread open for rewarding those who tell me why i did not need to do the same for the standalone I/O field and only for the I/O field in the table control.

any answers?? some points up for grabs here...:-)

regards,

PJ