cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic "Zeros as blank"

Former Member
0 Kudos

Hi guys,

I have a QUAN field in a table. I need the first 2 rows to display the zeros, and the rest of the rows to display zeros as blank. Something like transaction CAT2. Is this possible without having to change the field to STRING? I want to keep the standard validations when users enter invalid numeric values.

Thanks,

Raúl

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor
0 Kudos

Hi Raul,

I haven't tried this myself, but IF_WD_CONTEXT_NODE_INFO has a method SET_ATTRIBUTE_FORMAT_PROPS. This method has a parameter, FORMAT_PROPERTIES-NULL_AS_BLANK which you can set to one of the following values:

  • space = Default Value
  • X = Zeros as Blanks
  • - = Retain Zeros

This probably changes the property for the whole node though. Another option is to create two context attributes, one with leading zeros and one without, then in your table use cell variants to display one attribute or the other.

Cheers,

Amy

Former Member
0 Kudos

Thanks for your answer Amy! About the 2nd approach: Can you please explain me how to change (dynamically) the context binding of the input field (which is within a table) to the other context attribute?

Thanks again,

Raúl

former_member185241
Active Participant
0 Kudos

Follow this link  http://scn.sap.com/docs/DOC-10230

Thanks

Abhi

amy_king
Active Contributor
0 Kudos

Hi Raul,

My second suggestion wasn't to change the context binding of the view field but to use cell variants to allow each row of the table to actually display a different field in the column for QUAN. So if your table contains two fields for quantity: QUAN_WITH_ZERO and QUAN_WITHOUT_ZERO, then row #1 could display field QUAN_WITH_ZERO and row #2 could display field QUAN_WITHOUT_ZERO, and so on.

I wrote a blog post about using this approach to change the search help for each row of a table; maybe the blog post will give you an idea of how cell variants can help for your scenario. Otherwise the document by Thomas Jung that Abhi mentions may hep you if you prefer to change the context binding.

Cheers,

Amy

Former Member
0 Kudos

Hi Amy,

Thanks to your suggestion and your blog post, I've finally accomplished it. Thank you very much for your help!

I created a variant for the field with zeros, and left the other field (no zeros) with no variant to make it the default one.

Regards,

Raulie

Answers (0)