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

Allowing Decimals on Screen Painter imported Variable fields

Former Member
0 Likes
1,573

I created this program using the screen painter, the program works but decimals don't work (doesn't allow them nor does the result screen use them) despite the fact that globally defined variables are defined with decimals like so:

DATA: value1 type p DECIMALS 2,
          value2 type p DECIMALS 2,
          result type p DECIMALS 2.

At this point I've set the imported fields as currency type. I dunno if theres anything I need do to the PAI module to make decimals work, but heres my coding on that anyway:

MODULE USER_COMMAND_0100 INPUT.
CASE sy-ucomm.
  WHEN 'OPAD'.
      result = value1 + value2.
      leave to screen 0200.
  WHEN 'OPSU'.
      result = value1 - value2.
      leave to screen 0200.
  WHEN 'OPMU'.
      result = value1 * value2.
      leave to screen 0200.
  WHEN 'OPDI'.
      result = value1 / value2.
      leave to screen 0200.
  WHEN others.
      leave program.
ENDCASE.
ENDMODULE.

Am I doing anything wrong? Why are the decimals not working? Thanks in advance.

1 ACCEPTED SOLUTION
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,115

Hi James,

You need to mention the data type as decimal in screen painter for the fields value1, value2 and value3.

That is, in attribute-> format -> select as DEC.

Arivazhagan S

I created this program using the screen painter, the program works but decimals don't work (doesn't allow them nor does the result screen use them) despite the fact that globally defined variables are defined with decimals like so:

DATA: value1 type p DECIMALS 2,
          value2 type p DECIMALS 2,
          result type p DECIMALS 2.

At this point I've set the imported fields as currency type. I dunno if theres anything I need do to the PAI module to make decimals work, but heres my coding on that anyway:

MODULE USER_COMMAND_0100 INPUT.
CASE sy-ucomm.
  WHEN 'OPAD'.
      result = value1 + value2.
      leave to screen 0200.
  WHEN 'OPSU'.
      result = value1 - value2.
      leave to screen 0200.
  WHEN 'OPMU'.
      result = value1 * value2.
      leave to screen 0200.
  WHEN 'OPDI'.
      result = value1 / value2.
      leave to screen 0200.
  WHEN others.
      leave program.
ENDCASE.
ENDMODULE.

Am I doing anything wrong? Why are the decimals not working? Thanks in advance.

5 REPLIES 5
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,116

Hi James,

You need to mention the data type as decimal in screen painter for the fields value1, value2 and value3.

That is, in attribute-> format -> select as DEC.

Arivazhagan S

Read only

0 Likes
1,115


done that now, decimals not working still.

Read only

0 Likes
1,115

Activate the entire program and run the TCode once again.

Arivazhagan S

Read only

0 Likes
1,115

ah its working now, thankyou

Read only

Former Member
0 Likes
1,115

Hi,

Did you checked the attributes of screen painter's > Dict> Format > DEC ?