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: 

Popup for selection with sorting capability?

Former Member
0 Kudos
757

I'm looking for a functional module showing a pop up window where a user can choose among any number of items. Moreover the user can sort selected values. I mean a capability to define the selected values order. I need functionality similar to choosing ALV sort criteria (LVC_SORT_DIALOG).

1 ACCEPTED SOLUTION

Former Member
0 Kudos
256

Hi, I found out the FM ALV_LIST_SORTING_DEFINE, try to call it, you can see it should be the one you need.( I_TYPE = 'S')

But I'm still not clear how to fill its paramter.

Maybe you can reference the standard sap code.

I will continue the research when I'm free.

Hope my reply is helpful.

Thanks a lot

10 REPLIES 10

Former Member
0 Kudos
256

Mikola - I don't know of any FM to help out here. But I did exactly this a while ago. It involved creating a new window with a new status when the user requested the sort and then making the sort order field input on.

When the user pressed enter in the new window, I had to read in the report (from the new window), evaluate the input and pass it to a sort.

Not pretty, but it works.

Rob

Former Member
0 Kudos
257

Hi, I found out the FM ALV_LIST_SORTING_DEFINE, try to call it, you can see it should be the one you need.( I_TYPE = 'S')

But I'm still not clear how to fill its paramter.

Maybe you can reference the standard sap code.

I will continue the research when I'm free.

Hope my reply is helpful.

Thanks a lot

0 Kudos
256

Here is some sample coding for the mentioned function module. It works as far as returning the users inputs, but if you try to move fields to the other column, it breaks. Give it a try. By the way, Nice work Zhenglin. If i knew this was out there, i would have used it many times already.



report zrich_0002 .

type-pools: kkblo.

data: begin of itab occurs 0,
      fielda(10) type c,
      fieldb(10) type c,
      fieldc(10) type c,
      end of itab.

data:
  kkblo_control type kkblo_control,
  it_fieldcat type kkblo_t_fieldcat,
  wa_fieldcat type kkblo_fieldcat,
  it_sort type  kkblo_t_sortinfo,
  wa_sort type kkblo_sortinfo.

clear wa_fieldcat.
wa_fieldcat-fieldname = 'FIELDA'.
wa_fieldcat-tabname = 'ITAB'.
append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.
wa_fieldcat-fieldname = 'FIELDB'.
wa_fieldcat-tabname = 'ITAB'.
append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.
wa_fieldcat-fieldname = 'FIELDC'.
wa_fieldcat-tabname = 'ITAB'.
append wa_fieldcat to it_fieldcat.


clear wa_sort.
wa_sort-spos = '1'.
wa_sort-fieldname = 'FIELDA'.
wa_sort-seltext   = 'Field A'.
wa_sort-tabname   = 'ITAB'.
wa_sort-up = 'X'.
append wa_sort to it_sort.

clear wa_sort.
wa_sort-spos = '3'.
wa_sort-fieldname = 'FIELDB'.
wa_sort-seltext   = 'Field B'.
wa_sort-tabname   = 'ITAB'.
wa_sort-down = 'X'.
append wa_sort to it_sort.

clear wa_sort.
wa_sort-spos = '2'.
wa_sort-fieldname = 'FIELDC'.
wa_sort-seltext   = 'Field C'.
wa_sort-tabname   = 'ITAB'.
append wa_sort to it_sort.




call function 'ALV_LIST_SORTING_DEFINE'
  exporting
    I_CONTROL             = kkblo_control
    it_fieldcatalog       = it_fieldcat
    i_type                = 'S'
* IMPORTING
*   E_SAVE                =
*   E_EXIT                =
  changing
    ct_sort               = it_sort
 exceptions
   no_change             = 1
   program_error         = 2
   others                = 3
          .
check sy-subrc  = 0.

Regards,

Rich Heilman

0 Kudos
256

Got it working..... I needed to set a field in the field catalog. Check out this code. Here you can move stuff from the one column to the other and back allow you to change the sequence and the sort order. This is really working good.



report zrich_0002 .

type-pools: kkblo.

data: begin of itab occurs 0,
      fielda(10) type c,
      fieldb(10) type c,
      fieldc(10) type c,
      end of itab.

data:
  kkblo_control type kkblo_control,
  it_fieldcat type kkblo_t_fieldcat,
  wa_fieldcat type kkblo_fieldcat,
  it_sort type  kkblo_t_sortinfo,
  wa_sort type kkblo_sortinfo.

clear wa_fieldcat.
wa_fieldcat-fieldname = 'FIELDA'.
<b>wa_fieldcat-seltext   = 'Field A'.</b>
wa_fieldcat-tabname = 'ITAB'.
append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.
wa_fieldcat-fieldname = 'FIELDB'.
<b>wa_fieldcat-seltext   = 'Field B'.</b>
wa_fieldcat-tabname = 'ITAB'.
append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.
wa_fieldcat-fieldname = 'FIELDC'.
<b>wa_fieldcat-seltext   = 'Field C'.</b>
wa_fieldcat-tabname = 'ITAB'.
append wa_fieldcat to it_fieldcat.


clear wa_sort.
wa_sort-spos = '1'.
wa_sort-fieldname = 'FIELDA'.
wa_sort-seltext   = 'Field A'.
wa_sort-tabname   = 'ITAB'.
wa_sort-up = 'X'.
append wa_sort to it_sort.

clear wa_sort.
wa_sort-spos = '3'.
wa_sort-fieldname = 'FIELDB'.
wa_sort-seltext   = 'Field B'.
wa_sort-tabname   = 'ITAB'.
wa_sort-down = 'X'.
append wa_sort to it_sort.

clear wa_sort.
wa_sort-spos = '2'.
wa_sort-fieldname = 'FIELDC'.
wa_sort-seltext   = 'Field C'.
wa_sort-tabname   = 'ITAB'.
append wa_sort to it_sort.

call function 'ALV_LIST_SORTING_DEFINE'
  exporting
    i_control             = kkblo_control
    it_fieldcatalog       = it_fieldcat
    i_type                = 'S'
* IMPORTING
*   E_SAVE                =
*   E_EXIT                =
  changing
    ct_sort               = it_sort
 exceptions
   no_change             = 1
   program_error         = 2
   others                = 3
          .
check sy-subrc  = 0.

Regards,

Rich Heilman

Message was edited by: Rich Heilman

Message was edited by: Rich Heilman

0 Kudos
256

If these answers have helped you, please award points accordingly. Thanks.

Regards,

Rich Heilman

Former Member
0 Kudos
256

Hi, there is some code in FM LVC_FILTER_990927, should how to call ALV_LIST_SORTING_DEFINE.

I paste parts of them as following:


          DATA: LS_CONTROL_KKBLO TYPE KKBLO_CONTROL.
          DATA: LT_FIELDCAT_KKBLO TYPE KKBLO_T_FIELDCAT.
          DATA: LT_SORT TYPE KKBLO_T_SORTINFO.
          LS_CONTROL_KKBLO-LISTTYPE = 'S'.
          IF LS_CONTROL_KKBLO-LISTTYPE = 'S'.
            LS_CONTROL_KKBLO-HEADER_TEXT  = 'H'.
          ELSE.
            LS_CONTROL_KKBLO-HEADER_TEXT  = 'H'.
          ENDIF.

          CALL FUNCTION 'LVC_FILTER_TO_SORT'
               EXPORTING
                    IT_FILTER = CT_FILTER[]
               CHANGING
                    CT_SORT   = LT_SORT.
          CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
            EXPORTING
                 IT_FIELDCAT_LVC           = IT_FIELDCAT
*            IT_SPECIAL_GROUPS_LVC     = GT_GROUPS
            IMPORTING
                 ET_FIELDCAT_KKBLO         = LT_FIELDCAT_KKBLO
*            ET_SPECIAL_GROUPS_KKBLO   = LT_KKBLO_GROUPS
*        TABLES
*             IT_DATA                   =
*        EXCEPTIONS
*             IT_DATA_MISSING           = 1
*             IT_FIELDCAT_LVC_MISSING   = 2
*             OTHERS                    = 3
                  .

          CALL FUNCTION 'ALV_LIST_SORTING_DEFINE'
            EXPORTING
                I_CONTROL       = LS_CONTROL_KKBLO
                IT_FIELDCATALOG = LT_FIELDCAT_KKBLO
                I_TYPE          = 'F'
*       IMPORTING
*            E_EXIT          = G_MEMO
            CHANGING
                CT_SORT         = LT_SORT[]
            EXCEPTIONS
                NO_CHANGE       = 1
                OTHERS          = 2.

I think write you code simulatively, your problem will be solved. If further problem, make me know.

Thanks

Former Member
0 Kudos
256

Hi Mikola

Please check the follwing links:

Ashish Jain

Former Member
0 Kudos
256

hi, Rich. Thanks for you supply for my former reply.

As the time difference, I read your code just now.

Glad to hear it works good.

Thanks a lot

andreas_mann3
Active Contributor
0 Kudos
256

Hi,

for own sorting in lists use fm <b>RKE_SORT_ELEMENTS</b>

Andreas

Former Member
0 Kudos
256

i think you need to use FM

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

TITLEBAR = TB

TEXT_QUESTION = TQ

TEXT_BUTTON_1 = TB1

ICON_BUTTON_1 = IB1

TEXT_BUTTON_2 = TB2

ICON_BUTTON_2 = IB2

DEFAULT_BUTTON = DB

DISPLAY_CANCEL_BUTTON = ''

START_COLUMN = 25

START_ROW = 6

POPUP_TYPE = PTYPE

IMPORTING

ANSWER = ANSWER1.

IF SY-SUBRC <> 0.

ENDIF.

HERE YOU WILL GET THERE BUTTON , THEY RETURN VALUE 'Y'...

JUST CHECK IT BY DOING

WRITE SY-UCOMM.

REGARDS