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

Button with icon_collapse doesn't hide fields

Former Member
0 Likes
590

Dear experts,

I have created a button (with icon_expand/icon_collapse as label) in order to expand/collapse some fields in the block of a selection screen.

The problem is, the fields are not collapsed back, although they expand properly. screen-invisible is set to 1...

The coding is the following:

SELECTION-SCREEN BEGIN OF BLOCK additional_fields WITH FRAME TITLE text-111.

   SELECTION-SCREEN: "Button for additional fields

     BEGIN OF LINE,

       PUSHBUTTON 1(4) add_fld USER-COMMAND addfld MODIF ID nn1,

       COMMENT 8(70) text-fld MODIF ID nn1,

     END OF LINE.

     PARAMETERS: p_addfld  NO-DISPLAY.

     SELECT-OPTIONS: s_matnr FOR gs_mara-matnr MODIF ID mat,

                     s_werks FOR gs_marc-werks MODIF ID mat.

SELECTION-SCREEN END OF BLOCK additional_fields.


......


INITIALIZATION.

   title = text-101 .

   p_addfld = ''.

   IF add_fld IS INITIAL.

     add_fld = icon_expand.

   ENDIF.

   LOOP AT SCREEN.

     CASE screen-group1.

       WHEN 'MAT'.

         screen-input = 0.

         screen-active = 0.

         screen-invisible = 1.

         MODIFY SCREEN.

     ENDCASE.

   ENDLOOP.

.....

AT SELECTION-SCREEN ON BLOCK additional_fields.

   IF sy-ucomm = 'ADDFLD'.

     IF p_addfld = 'X'.

        p_addfld = ''.

        add_fld = icon_expand.

        LOOP AT SCREEN.

          CASE screen-group1.

            WHEN 'MAT'.

              screen-input = 0.

              screen-active = 0.

              screen-invisible = 1.

              MODIFY SCREEN.

           ENDCASE.

        ENDLOOP.

     ELSE.

        p_addfld = 'X'.

        add_fld = icon_collapse.

        LOOP AT SCREEN.

          CASE screen-group1.

            WHEN 'MAT'.

              screen-input = 1.

              screen-active = 1.

              screen-invisible = 0.

              MODIFY SCREEN.

          ENDCASE.

        ENDLOOP.

     ENDIF.

   ENDIF.


Please advise me how to proceed.

Thank you!


BR,

Matei

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
546

Hi,

Change your code as below and try,

AT SELECTION-SCREEN ON BLOCK additional_fields..

   IF sy-ucomm = 'ADDFLD'.

     IF p_addfld = 'X'.

       p_addfld = ''.

       add_fld = icon_expand.

     ELSE.

       p_addfld = 'X'.

       add_fld = icon_collapse.

     ENDIF.

   ENDIF.

AT SELECTION-SCREEN OUTPUT.

   LOOP AT SCREEN.

     IF screen-group1 = ' MAT'.

       IF p_addfld = ''.

         screen-active = '0'.

       ENDIF.

       IF p_addfld = 'X'.

         screen-active = '1'.

       ENDIF.

     ENDIF.

     MODIFY SCREEN.

   ENDLOOP.



Regards,

Danny

2 REPLIES 2
Read only

Former Member
0 Likes
547

Hi,

Change your code as below and try,

AT SELECTION-SCREEN ON BLOCK additional_fields..

   IF sy-ucomm = 'ADDFLD'.

     IF p_addfld = 'X'.

       p_addfld = ''.

       add_fld = icon_expand.

     ELSE.

       p_addfld = 'X'.

       add_fld = icon_collapse.

     ENDIF.

   ENDIF.

AT SELECTION-SCREEN OUTPUT.

   LOOP AT SCREEN.

     IF screen-group1 = ' MAT'.

       IF p_addfld = ''.

         screen-active = '0'.

       ENDIF.

       IF p_addfld = 'X'.

         screen-active = '1'.

       ENDIF.

     ENDIF.

     MODIFY SCREEN.

   ENDLOOP.



Regards,

Danny

Read only

0 Likes
546

That space in the following line at ' MAT' gave me some trouble )) but I have adjusted it and it works like a charm.


IF screen-group1 = ' MAT'.


Thank you!