cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop decimals appearing for a quantity field?

former_member195355
Participant
0 Kudos

Hiya,

I have this field/column in my webdynpro:

It's nice but it always displays 3 decimals places - does anyone know how to suppress the decimals?

So that instead of 15,000.000 it shows just 15,000?

If it helps the binding in the context is to EKPO-MENGE i.e.:

Any help would be gratefully received!

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

It's an automatic conversion by system based on data type. If you don't want to show decimal places, create a packed data element with no decimals and assign it to the attribute. Then in the program do the conversion to remove decimals and assign it to the attribute.

If it is of initial value( 000.00) you can set the formatting options. under properties of attribute in context change it to zeros as blanks.

Regards,

Kiran

former_member195355
Participant
0 Kudos

Thanks Kiran,

When you say


If you don't want to show decimal places, create a packed data element with no decimals and assign it to the attribute.

Are you saying that I need to create a data dictionary element of type packed?

And then assign that in my context for the quantity attribute?

Couldn't I just use an existing one, or doesn't it exist?

Thanks again.

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert,

I suspect you are missing some thing and system will take care of decimals display based on unit automatically. We do not need to do any thing.

Please make sure that the below points are okay from your end.


  • Let us say you have strcture ZST_EKPO with fields MENGE and MEINS
  • You need to have reference to quantity fields as below ( i.e. referencing into same structure's unit )

Now, system auto converts decimals based on UNIT field

Example: if unit is of type NUMBER , quantity field may not have decimals

                if uinit is of type quantity measuring weight.... it may have decimals based on unit

If you do not want to have decimals in any case, then  as suggested, please use any suitable data element which doesn't have decimals

Example: refer where used list for domains like DEC13 or DEC_13

Hope this helps you.

Regards,

Rama

former_member184578
Active Contributor
0 Kudos

Hi,

Yes, I meant the same. Create a new data element ( say DEC 13) with no decimal places and assign it to the attribute in the context instead of the one which has decimal places.

Then in your program after fetching the data ( which has decimal places ) convert it to DEC 13 ( or type P no decimals ) with no decimals and then bind it to the context.

Regards,

Kiran

former_member195355
Participant
0 Kudos

Hi Ramakrishnappa,

Thank you for the reply and i think you're idea is correct and I am getting the quanitity from EKPO but I'm having trouble doing what you say...

Originally I was just passing the EKPO value into my context attribute (which was also of type EKPO-MENGE) i.e.

webdynpro_menge = wa_ekpo-menge.

However if I change it to:

Write wa_ekpo-menge to webdynpro_menge unit 'CPY'.

this doesn't work either.

Do you know what I might be doing wrong?

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert,

Write statement with unit will not be retained while displaying data in WD, as its again converted by framework with reference to unit in the context attribute

I think your context node's data dictionary structure is not mapped properly

Please follow the below points to achieve your requirement

  • let us say you have table EKPO to use in context node
  • Create a context node using EKPO table and then create attributes from this DDIC ( please refer below snap shot

         

  • Now, it should have the context attributes mapped to EKPO, hence MENGE should automatically reference the unit field from EKPO ( i.e. WD framework will take care of displaying decimals for the quantity )

Hope this helps you.

Regards,

Rama

former_member195355
Participant
0 Kudos

Hi Ramakrishnappa,

Oh right I hadn't done that - my context has a whole bunch of fields mixed in, some from EKPO some from Z tables...

I thertefore don't think I can do what you say...

Looks like I'll have to try your other suggestion of creatign a data element of type DEC13 and using that as a type for the quantity attribute in my context.

Thanks for your help.

ramakrishnappa
Active Contributor
0 Kudos

Oh, okay.

Its better if you create a z-structure with all your fields and then use the z-structure to create context node as suggested earlier. Hence conversion headache will not be there

Any way, it all depends how we do.

All the best

Regards,

Rama

former_member195355
Participant
0 Kudos

Hi Everyone,

I created this:

Bound it to the MENGE in my context :

and it worked:

Many thanks to Kiran and Ramakrishnappa.

former_member195355
Participant
0 Kudos

Sorry one last question:

I simply pass the value from the quantity field (which has 3 decimal places) into the DEC13 field type and it seems to work:

data: output_menge type zrfq-dec13,

          wa ekpo_menge type ekpo-menge.              

output_menge = wa ekpo_menge.

Would anyone disagree or see anything wrong with this solution?

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert.

There should be no issues with that but only thing is decimals will be rounded ( up/down ) upto 0 decimals. Hope your users are aware of it

Regards,

Rama

former_member195355
Participant
0 Kudos

That's great - thanks again!

ramakrishnappa
Active Contributor
0 Kudos

Welcome

Answers (0)