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: 

Restraining decimal points for selective values of a single field?

0 Kudos

Hello everyone,

here is my sample code ...

" types: begin of ty_x,

     (some fields)

     .

     .

     .

     .

     menge           type P decimals 3,

     currkey          type waers,

     end of ty_x. (let us say this is my final output structure )

data:      i_x      type table of ty_x,

     w_x     type ty_x.

loop at it into wa.

.

.

.

if currkey is not maintained in TCURX table

then menge should be diaplayed with 3 decimal values

else.

menge should be diaplayed without decimal values

endif.

append w_x to i_x.

endloop.

reuse alv grid ( to display the output).

"

here what should be the type of menge so that i can get the output as i have mentioned in the if clause?

output example:

field1     field2     field3     field4      QUANTITY(MENGE)     CURRENCYKEY

A          A          A          A          123.456                               USD

B          B          B          B          11100.253                       USD

C          C          C          C          11100                             KRW

D          D          D          D          1255                               JPY

i have tried to restrict the type to p with decimals 0. but that would reflect to all the values in the field quantity.
kindly help me with this..

Thanks in advance,

jyothi reddy.

5 REPLIES 5

FredericGirod
Active Contributor
0 Kudos

Hi,

instead of doing a MOVE ... TO i_x-menge,  try to do a WRITE ... TO i_x-menge CURRENCY i_x-waers.

regards

Fred

former_member223133
Active Participant
0 Kudos

Hi,

  • Declare one more field in the final output structure like MENGE1 TYPE p DECIMALS 2.
  • Move the values accordingly based on the condition and display the output.

Thanks

Gangadhar

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

HI,

If you displaying your output in ALV for these ideally you must pass the currency field parameter in the fieldcatalog.

For your currency field use cfieldname in the fiedcatalog if you want to display for quantity fields pass

qfieldname. The ALV by default takes care of the decimals to be displayed.

You can find lots of example for this in BC ALV.

If your requirement is different kindly ignore.

Regards,

Vasanth

Former Member
0 Kudos

Hi,

  Use a string in ALV field catalog to display menge. Based on your currency key condition, assign the value with decimals / without decimals to this field in ALV.

-Ashwin