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: 

events doubt

Former Member
0 Kudos
171

Hi experts,

I need help to get some idea on my requirement. In alv am display 6 fields. but initially 3 fields will be hidden if we need it we can see by clicking respective button on alv application tool-bar. likewise I created 3 buttons for that hidden fields column via "salv_standard". its all working fine initially am getting 3 fields and after clicking those button i can see the hidden files.

now i need to hide the column when again i am hitting the button.

ex:

initial my alv look like with  A and B and C column.

button1 button2 button3

A   B   C

when i press button1

A   B    C    D

When i press button2 then

A   B    C    D   E

likewise it is displaying now.... i need when click button1  again that D column should get hide. likewise when click button2  again that E column should get hide.

please tell me how to do this .... is this possible in push button ???

Thanks in advance..

1 ACCEPTED SOLUTION

Former Member
0 Kudos
140

Hi Sazees,

Whenever a button is clicked, you can check the current mode of the corresponding field (Hidden or Display), and then just reverse its mode for each click. Can you please share your code to provide you a better explanation ?

9 REPLIES 9

Former Member
0 Kudos
141

Hi Sazees,

Whenever a button is clicked, you can check the current mode of the corresponding field (Hidden or Display), and then just reverse its mode for each click. Can you please share your code to provide you a better explanation ?

0 Kudos
140

Hi Rachna,

thanks for your reply.

whatever you saying is correct . now i need to reverse the operation for hide or display but my question is can that button1 itself able to do the reverse operation.

0 Kudos
140

Hi,

Depending upon hide or show click, call the fieldact which will have if condition for hide or show and display accordingly.

Regards-

Makarand

0 Kudos
140

Hi Makarand,

Thanks for your reply.

can u please say bit clearly...

in your case oly two condition may possible. but in my case first fields should be hidden and when click the button respective filed should display then if again click the same button that filed should get hide.

can that button do the reverse process....????

0 Kudos
140

Hi,

I guess, there is seperate button for each field to show and hide.

say, for the field D you have function code to display is Disp_D and for hide is Hide_D.

Depending upon this, modify your fieldcat.

Regards-

Makarand


0 Kudos
140

here is my code.



{code}

CASE E_salv_function.

       WHEN 'SCODE'.

          PERFORM SCODE.

        WHEN 'SCODE1'.

          PERFORM SCODE1.

         WHEN 'SCODE2'.

           PERFORM SCODE2.

           ENDCASE.

   FORM SCODE.

    l_columns = l_table->get_columnS( ).

    L_COLUMN ?= L_COLUMNS->GET_COLUMN( 'LNAME').

   L_COLUMN->SET_VISIBLE(

    EXPORTING

      VALUE  = IF_SALV_C_BOOL_SAP=>TRUE ).

   ENDFORM.

{code}

like FORM Scode i hve  form for scode1 and scode2.

i shoul not use the seperate button  for hide this field. scode for Lname fields . first time i click scode it should display lname field next time i click s code it should hide the lname field

tell me what to do??.

0 Kudos
140

Hi Sazees,

Please try the below code:

For Your Report, Intially All three columns are hidden,

You can declare three fields

Data: lv_show1(1) type c,

         lv_show2(1) type c,

         lv_show2(1) type c.

        

{code}

CASE E_salv_function.

       WHEN 'SCODE'.

          PERFORM SCODE.

        WHEN 'SCODE1'.

          PERFORM SCODE1.

         WHEN 'SCODE2'.

           PERFORM SCODE2.

           ENDCASE.

*Initialize lv_show1, lv_show2, lv_show3 to 'X'. and in perform  Scode you can clear the Scode before endform.

FORM scode.

   IF lv_show1 = 'X'.

     l_columns = l_table->get_columns( ).

     l_column ?= l_columns->get_column( 'LNAME').

     l_column->set_visible(

      EXPORTING

        value  = if_salv_c_bool_sap=>true ).

     CLEAR: lv_show1.

   ELSEIF lv_show1  IS INITIAL.

     l_columns = l_table->get_columns( ).

     l_column ?= l_columns->get_column( 'LNAME').

     l_column->set_invisible(

      EXPORTING

        value  = if_salv_c_bool_sap=>true ).

     lv_show1 = 'X'.

     ENDIF.

   ENDFORM.         

{code}

So using this code, before first click it will set the variable to 'X'.

on click it will display the column and will clear the variable.

On second click, as the variable is cleared, it will hide the column, and again set the variable to 'X', for next click and display of column.

Repeat the same for other buttons too.

Hope this will be useful.

Thanks,

Ashish

0 Kudos
140

Hi  Ashis Patil,

Thank you very much . your idea is perfect .

I got  the exact output.

thanks for all the replies friends.

0 Kudos
140

Hi Sazees,

If I am getting your approach correctly, then according to me the same buttons can be used for reversal effects also. You just need to add an if else condition in the code where you are changing the hidden fields to display mode in the very first click of the button. For e.g. if you current code is somewhat like this -

On event-button1-click.


      set field11 to display mode.

 

You can add the If-else condition in this way -

On event-button1-click.

     if field1 is in hidden mode.

             set field11 to display mode.

      elseif field1 is in display mode.

             set field1 to hidden mode.

      endif.

You can paste you part of code here to give you a better understanding of the approach.