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

Classical Report Expand-Collapse functionality

Former Member
0 Likes
897

Hi All!

I am doing a program that displays a classical report as an output. It has buttons on the top of the output (using Menu Painter) and it has "Expand" and "Collapse" buttons. I do not know how to implement this expand and collapse functionality. Please help.

The output of the report looks like this:

Plant: <data>

<data>

<data>

Plant: <data>

<data>

<data>

When I click on "Expand" button, the output will look like the one above. When I click on "Collapse" button, the output will look like this:

Plant: <data>

Plant: <data>

Please help me achieve this functionality.

Thank you!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
724

Hi,

Try this sample code....

DATA : BEGIN OF itab OCCURS 0,
       state   TYPE char20,
       city    TYPE char18,
       flag,
       END   OF itab.
DATA   disptab LIKE itab OCCURS 0.
DATA   sel_lin TYPE char20.
START-OF-SELECTION.
  itab-state = 'Tamil Nadu'.
  itab-city  = 'Chennai'.
  APPEND itab.
  itab-state = 'Tamil Nadu'.
  itab-city  = 'Coimbatore'.
  APPEND itab.
  itab-state = 'West Bengal'.
  itab-city  = 'Kolkata'.
  APPEND itab.
  itab-state = 'West Bengal'.
  itab-city  = 'Durgapur'.
  APPEND itab.
END-OF-SELECTION.
  LOOP AT itab.
    AT NEW state.
      WRITE /3 itab-state COLOR 4 HOTSPOT.
    ENDAT.
  ENDLOOP.
AT LINE-SELECTION.
  MOVE sy-lisel+2(20) TO sel_lin.
  LOOP AT itab.
    AT NEW state.
      WRITE /3 itab-state COLOR 4 HOTSPOT.
    ENDAT.
    IF itab-flag <> 'X'.
      IF itab-state = sel_lin.
        itab-flag = 'X'.
      ENDIF.
    ELSE.
      IF itab-state = sel_lin.
        itab-flag = ' '.
      ENDIF.
    ENDIF.
    IF itab-flag = 'X'.
      WRITE /5 itab-city  COLOR 2.
    ENDIF.
    MODIFY itab.
    CLEAR itab.
  ENDLOOP.

Cheers,

jose.

4 REPLIES 4
Read only

Former Member
0 Likes
725

Hi,

Try this sample code....

DATA : BEGIN OF itab OCCURS 0,
       state   TYPE char20,
       city    TYPE char18,
       flag,
       END   OF itab.
DATA   disptab LIKE itab OCCURS 0.
DATA   sel_lin TYPE char20.
START-OF-SELECTION.
  itab-state = 'Tamil Nadu'.
  itab-city  = 'Chennai'.
  APPEND itab.
  itab-state = 'Tamil Nadu'.
  itab-city  = 'Coimbatore'.
  APPEND itab.
  itab-state = 'West Bengal'.
  itab-city  = 'Kolkata'.
  APPEND itab.
  itab-state = 'West Bengal'.
  itab-city  = 'Durgapur'.
  APPEND itab.
END-OF-SELECTION.
  LOOP AT itab.
    AT NEW state.
      WRITE /3 itab-state COLOR 4 HOTSPOT.
    ENDAT.
  ENDLOOP.
AT LINE-SELECTION.
  MOVE sy-lisel+2(20) TO sel_lin.
  LOOP AT itab.
    AT NEW state.
      WRITE /3 itab-state COLOR 4 HOTSPOT.
    ENDAT.
    IF itab-flag <> 'X'.
      IF itab-state = sel_lin.
        itab-flag = 'X'.
      ENDIF.
    ELSE.
      IF itab-state = sel_lin.
        itab-flag = ' '.
      ENDIF.
    ENDIF.
    IF itab-flag = 'X'.
      WRITE /5 itab-city  COLOR 2.
    ENDIF.
    MODIFY itab.
    CLEAR itab.
  ENDLOOP.

Cheers,

jose.

Read only

0 Likes
724

Hi jose!

The code you provided solved the problem I encountered involving the hotspots that I will use in the program.

However, I still need help regarding the "Expand" and "Collapse" pushbuttons that I created using Menu Painter.

The functionality of the pushbuttons is that if I press "Expand", all the objects that are in collapse mode will be expanded. If "Collapse" button is pressed, all objects in expand mode will be collapsed.

Can you help me in solving this problem?

Read only

Former Member
0 Likes
724

Only part of the problem is solved.

Read only

0 Likes
724

Hi,

AT USER-COMMAND.
 read CURRENT LINE line value into wa.
  CASE sy-ucomm.
    WHEN 'EXPAND' .

    WHEN 'COLLAPSE'.

  ENDCASE.

Cheers,

jose.