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

ALV Hide zero in certain row

Former Member
0 Likes
10,830

Hi,

I am aware of NO_ZERO='X' solution but it hides all zeros in certain column.

What I want to do is hide zero values but only for certain rows ?

i.e. I have columns A, B, C, all numerical (like mseg-dmbtr)


A     B     C
0     2     [empty]
2     2     0.00
2     1     1.00

C is empty if A = 0

C is 0.00 if A=B

otherwise C = A-B

I'd like to solve it by not converting the fields into character fields.

Any clues ?

Thanks in advance,

Bart

Hi,

I am aware of NO_ZERO='X' solution but it hides all zeros in certain column.

What I want to do is hide zero values but only for certain rows ?

i.e. I have columns A, B, C, all numerical (like mseg-dmbtr)


A     B     C
0     2     [empty]
2     2     0.00
2     1     1.00

C is empty if A = 0

C is 0.00 if A=B

otherwise C = A-B

I'd like to solve it by not converting the fields into character fields.

Any clues ?

Thanks in advance,

Bart

21 REPLIES 21
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
6,267

Hello,

I am aware of NO_ZERO='X' solution but it hides all zeros in certain column.

Possibility 1 ruled out completely.

I'd like to solve it by not converting the fields into character fields.

You don't want to take this approach.

You must be aware character type variables have ' ' (space) as initial values (TYPE I, P, NUMC have zeroes as initial value) so i think that you can achieve this defining Column C as character.

May be other SDNers have some better ideas. Lets see !!!

BR,

Suhas

Read only

0 Likes
6,267

Hi Suhas,

Thats a remedy

But surely the user will come saying the sum functionality of that particular field is not working.

Read only

Former Member
0 Likes
6,267

Hi,

The user is aware of sum problems thus I stated:

"I'd like to solve it by not converting the fields into character fields."

Cheers,

Bart

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
6,267

Check what sourav has suggested here

Just try

if input = '0.00' or input is initial.

output = ' '.

endif.

Read only

rainer_hbenthal
Active Contributor
0 Likes
6,267

Create a fourth column in your internal table named D. Declare that column as Character. Put that new column in your fieldcatalog, dont put colum C in your fieldcatalog.

Right before displaying loop over your table:

loop at it_out assigning <p>.
  if <p>-a is initial.
    clear <p>-d.
  elseif <p>-a = <p>-b.
    <p>-d = '0.00'.
  else.
    tmp = <p>-a - <p>-b.
    write tmp to <p>-d.
  endif.
endloop.

Read only

0 Likes
6,267

@ Rainer Hübenthal

Final column D will still be character thus no sums right?

@ Mohaiyuddin Soniwala

Sorry, I forgot to mention, it's not OOALV.

@ Sourav Bhaduri

Very clever idea, however, inside the conversion exit I will not be able to distinguish whether the zero value should be displayed or not. I might use some magic value and put it into cell for conversion exit but then SUM would sum those values as well.

Read only

0 Likes
6,267

Yes its still character and cant be summed up. I cant see any possibility using the FM LIST_DISPLAY.

With GRID_DISPLAY there might be another solution. For every cell you can have separate colors, search the wiki for that. Setting foreground color to background color will make the content invisible. Dont know if its bpossible to set foreground color, but may its working.

Read only

0 Likes
6,267

Hi,

Sounds interesting. How do I set foreground color of a cell ?

I know how to set background color of row via:

l_layout-info_fieldname = 'KOLOR'.

or cell/row background color via:

l_layout-coltab_fieldname = 'KOLOR'.

I don't know how to set foreground color though.

Btw i use REUSE_ALV_GRID_DISPLAY.

Cheers,

Bart

Read only

0 Likes
6,267

[As i said, search the wiki|http://wiki.sdn.sap.com/wiki/display/Snippets/ColorindividualcellsofanALVGRID], i'm sure you find an entry on how to color individual cells using the GRID_DISPLAY FM.

But. just an idea, dont know if its possible to set foreground color.

Read only

0 Likes
6,267

Hi,

I misunderstood your sentence a bit. Been to wiki already, but it's background color which is set set there. I've never seen font color changed in ALV.

Cheers,

Bart

Read only

0 Likes
6,267

  • i_color in output table should be 4 characters

  • character 1: Always C

  • character 2: number between 1 and 7

  • character 3: 1 or 0 (intensified or not)

  • character 4: 1 or 0 (1 sets background as normal and colors text)

Read only

0 Likes
6,267

How do I set foreground color of a cell ?

ALV Hide zero in certain row

I guess that this thread will get locked.

Read only

0 Likes
6,267

Hi,

Sorry, went out of topic a bit. (Rainer Hübenthal that colours row and doesn't affect font color)

So far solution giving some hope is to use the conversion exit (Sourav Bhaduri). My field has 2 decimal places. I'll raise its precision, put a marker on let's say 8th decimal place and on it's base I'll decide whether to display the (FAKE) zeros in cell or not. Output conversion will then strip the number back to 2 decimal places for display. I doubt I'll be having that many records so that the sum of markers will affect 2nd decimal place.

Cheers,

Bart

Read only

0 Likes
6,267

I hope the business requirement is worth all this effort!

matt

Read only

0 Likes
6,267

> I guess that this thread will get locked.

OP is looking for a solution to an interesting problem, uses a meaningful subject, is being polite, follows up on the replies...perfect

I personally don't see a way of doing this using the REUSE_... function modules.

Maybe it can be done via the CL_SALV... classes, but I'm not enough of a geek in that area. Anybody?

Thomas

Read only

0 Likes
6,267

Hi,

Some times back,

The threads which were diverted into a different question from the actual question was locked and warned by Rob

It was stated to post the new question in a new thread

Regards,

Keshav

Read only

0 Likes
6,267

Possibly, but here we're still looking for a solution to the original problem, and the positive aspects outweigh, in my opinion.

Shouldn't stop you from keeping your eyes open, thanks for your ongoing help.

Thomas

Read only

Former Member
6,267

I haven't tried this but you may give it a try and let us know.

SET_ZERO method of CL_SALV_COLUMN.

I think this is as good as no_zero....I don't think it is possible to display 0.00 in such cases...For a change you may color such cells to distinguish them

Regards,

Mohaiyuddin

Edited by: Mohaiyuddin Soniwala on Mar 4, 2010 5:01 PM

Read only

Pranay_Panchbha
Participant
0 Likes
6,267

hiiiiiiiiiiii

use alv grid display

and use wa_fieldcatalog-no_zero = 'X'.

Read only

6,267

>

> hiiiiiiiiiiii

> use alv grid display

> and use wa_fieldcatalog-no_zero = 'X'.

Nonsense. This will affect all rows, and this is against requirement.

Read only

Pierre_A
Newcomer
0 Likes
4,194

Hi,

Proposal : Use (not only color but) style with ALV_STYLE_CHECKBOX_NO  '00060000'  from INCLUDE <CL_ALV_CONTROL>. 

Regards
 Pierre