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

Sort up and sort Down push buttons in module pool with table control wizard

Former Member
0 Kudos
1,579

hi,

i have created 2 buttons for Sort up and sort Down push buttons in module pool with table control wizard

please any one can help me.

regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
863

Hi

Following code is to enable and disable the tbl control using two buttons. Just alter the code and for each button write the sort code.

REPORT  YJAN27_SCREEN                                               .

TABLES: SFLIGHT, YFLIGHT_28.

TYPES: BEGIN OF struct1,
      carrid like sflight-carrid,
      connid like sflight-connid,
      fldate like sflight-fldate,
       END OF struct1.

CONTROLS TBL1 TYPE TABLEVIEW USING SCREEN 2700.

DATA: OK_CODE LIKE SY-UCOMM,
      CARRID LIKE SFLIGHT-CARRID,                                    "cols in tbl ctrl
      CONNID LIKE SFLIGHT-CONNID,
      FLDATE LIKE SFLIGHT-FLDATE,
      itab TYPE TABLE OF STRUCT1 WITH HEADER LINE,
      cols like line of TBL1-COLS,
      FLAG TYPE I.

FLAG = 1.


CALL SCREEN 2700.

*&---------------------------------------------------------------------*
*&      Module  STATUS_2700  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_2700 OUTPUT.
  SET PF-STATUS 'BACK'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_2700  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2700  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_2700 INPUT.

OK_CODE = SY-UCOMM.

CASE OK_CODE.
  WHEN 'BACK'.
    LEAVE PROGRAM.
  WHEN 'DIS'.                                                         "write code for sort up
    loop AT TBL1-COLS INTO COLS.
       COLS-SCREEN-INPUT = 0.
        MODIFY TBL1-COLS FROM COLS.
    ENDLOOP.
    FLAG = 2.
  WHEN 'ENA'.                                                       "write code for sort down
    loop AT TBL1-COLS INTO COLS.
        COLS-SCREEN-INPUT = 1.
        MODIFY TBL1-COLS FROM COLS.
    ENDLOOP.
    FLAG = 1.

ENDCASE.
ENDMODULE.                 " USER_COMMAND_2700  INPUT

*&---------------------------------------------------------------------*
*&      Module  GET_DATA  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_DATA OUTPUT.

  select carrid connid fldate from SFLIGHT into table itab.

ENDMODULE.                 " GET_DATA  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  POPULATE_TBL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE POPULATE_TBL OUTPUT.

    MOVE-CORRESPONDING ITAB TO SFLIGHT.

ENDMODULE.                 " POPULATE_TBL  OUTPUT



*&---------------------------------------------------------------------*
*&      Module  CHANGE_SCREEN  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE CHANGE_SCREEN OUTPUT.    " use this module if you want to hide the other button
CASE FLAG.
  WHEN 1.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_ENA'.
        SCREEN-INVISIBLE = 1.
         MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_DIS'.
        SCREEN-INVISIBLE = 0.
         MODIFY SCREEN.
      ENDIF.
   ENDLOOP.
  WHEN 2.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_DIS'.
        SCREEN-INVISIBLE = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_ENA'.
        SCREEN-INVISIBLE = 0.
         MODIFY SCREEN.
      ENDIF.
   ENDLOOP.

ENDCASE.

ENDMODULE.                 " CHANGE_SCREEN  OUTPUT


PROCESS BEFORE OUTPUT.
 MODULE STATUS_2700.
 MODULE CHANGE_SCREEN.     " use this if you want to display one button at a time

 MODULE GET_DATA.
 loop at itab WITH control TBL1.
    MODULE POPULATE_TBL.       " populate tbl ctrl
 endloop.

PROCESS AFTER INPUT.
 MODULE USER_COMMAND_2700.    " do the sort operations
 loop at itab.
  endloop.

Hope this helps

Regards,

Jayanthi.K

7 REPLIES 7
Read only

Sandra_Rossi
Active Contributor
0 Kudos
863

what is your question?

Read only

0 Kudos
863

Hi,

I have created 2 push buttons one is for sort Asending order and 2nd one is for sort desending order.

Please let me know how to write a code for these buttons in module pool.

regards

Read only

Former Member
0 Kudos
863

Hi,

Check this documentation

[Table Controls: Examples with Modifications |http://help.sap.com/erp2005_ehp_04/helpdata/EN/9f/dbac5e35c111d1829f0000e829fbfe/frameset.htm]

and the respective demo program in sap DEMO_DYNPRO_TABCONT_LOOP_AT

Regards,

Manoj Kumar P

Read only

0 Kudos
863

Hi,

When you use the Table control wizard to make your table control [sort buttons etc], it will automatically put in the code for the functionality of the buttons. You dont have to write anything in that case.

Regards.

Read only

Former Member
0 Kudos
863

Hi Nani,

I don't get your requirment clearly.. still what i think. Write the function code on the attribute list of both push button. You can get the attribute list by clicking on the push button on the screen painter.

For example if your fc code is Push1 & Push2 respectively for first & second puch button

then in th PAI module of that screen write a code

case sy-ucomm.

when 'Push1'.

"do your sorting coding here."

when 'Push2'.

"do ur descending sorting coding here".

endcase.

Regards

Mudit

Read only

Former Member
0 Kudos
863

Hi Nani,

I don't get your requirment clearly.. still what i think. Write the function code on the attribute list of both push button. You can get the attribute list by clicking on the push button on the screen painter.

For example if your fc code is Push1 & Push2 respectively for first & second puch button

then in th PAI module of that screen write a code

case sy-ucomm.

when 'Push1'.

"do your sorting coding here."

when 'Push2'.

"do ur descending sorting coding here".

endcase.

Regards

Mudit

Read only

Former Member
0 Kudos
864

Hi

Following code is to enable and disable the tbl control using two buttons. Just alter the code and for each button write the sort code.

REPORT  YJAN27_SCREEN                                               .

TABLES: SFLIGHT, YFLIGHT_28.

TYPES: BEGIN OF struct1,
      carrid like sflight-carrid,
      connid like sflight-connid,
      fldate like sflight-fldate,
       END OF struct1.

CONTROLS TBL1 TYPE TABLEVIEW USING SCREEN 2700.

DATA: OK_CODE LIKE SY-UCOMM,
      CARRID LIKE SFLIGHT-CARRID,                                    "cols in tbl ctrl
      CONNID LIKE SFLIGHT-CONNID,
      FLDATE LIKE SFLIGHT-FLDATE,
      itab TYPE TABLE OF STRUCT1 WITH HEADER LINE,
      cols like line of TBL1-COLS,
      FLAG TYPE I.

FLAG = 1.


CALL SCREEN 2700.

*&---------------------------------------------------------------------*
*&      Module  STATUS_2700  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_2700 OUTPUT.
  SET PF-STATUS 'BACK'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_2700  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2700  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_2700 INPUT.

OK_CODE = SY-UCOMM.

CASE OK_CODE.
  WHEN 'BACK'.
    LEAVE PROGRAM.
  WHEN 'DIS'.                                                         "write code for sort up
    loop AT TBL1-COLS INTO COLS.
       COLS-SCREEN-INPUT = 0.
        MODIFY TBL1-COLS FROM COLS.
    ENDLOOP.
    FLAG = 2.
  WHEN 'ENA'.                                                       "write code for sort down
    loop AT TBL1-COLS INTO COLS.
        COLS-SCREEN-INPUT = 1.
        MODIFY TBL1-COLS FROM COLS.
    ENDLOOP.
    FLAG = 1.

ENDCASE.
ENDMODULE.                 " USER_COMMAND_2700  INPUT

*&---------------------------------------------------------------------*
*&      Module  GET_DATA  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_DATA OUTPUT.

  select carrid connid fldate from SFLIGHT into table itab.

ENDMODULE.                 " GET_DATA  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  POPULATE_TBL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE POPULATE_TBL OUTPUT.

    MOVE-CORRESPONDING ITAB TO SFLIGHT.

ENDMODULE.                 " POPULATE_TBL  OUTPUT



*&---------------------------------------------------------------------*
*&      Module  CHANGE_SCREEN  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE CHANGE_SCREEN OUTPUT.    " use this module if you want to hide the other button
CASE FLAG.
  WHEN 1.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_ENA'.
        SCREEN-INVISIBLE = 1.
         MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_DIS'.
        SCREEN-INVISIBLE = 0.
         MODIFY SCREEN.
      ENDIF.
   ENDLOOP.
  WHEN 2.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_DIS'.
        SCREEN-INVISIBLE = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
    LOOP AT SCREEN.
      IF SCREEN-NAME = 'B_ENA'.
        SCREEN-INVISIBLE = 0.
         MODIFY SCREEN.
      ENDIF.
   ENDLOOP.

ENDCASE.

ENDMODULE.                 " CHANGE_SCREEN  OUTPUT


PROCESS BEFORE OUTPUT.
 MODULE STATUS_2700.
 MODULE CHANGE_SCREEN.     " use this if you want to display one button at a time

 MODULE GET_DATA.
 loop at itab WITH control TBL1.
    MODULE POPULATE_TBL.       " populate tbl ctrl
 endloop.

PROCESS AFTER INPUT.
 MODULE USER_COMMAND_2700.    " do the sort operations
 loop at itab.
  endloop.

Hope this helps

Regards,

Jayanthi.K