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

ALV sort option

Former Member
0 Likes
2,224

Hi all,

i am trying to use SORT option in reuse_ALV_grid_display. Here is what i have done, but i am getting dump with error as CALL_FUNCTION_CONFLICT_TYPE

.

data:it_fieldcat type slis_t_fieldcat_alv,

wa_fieldcat like line of it_fieldcat,

TITLE TYPE LVC_TITLE VALUE 'SUJAY',

layout type SLIS_LAYOUT_ALV,

sort type SLIS_T_SORTINFO_ALV with header line.

select-options: s_matnr for mara-matnr.

perform it_populate.

perform it_struct.

LAYOUT-WINDOW_TITLEBAR = 'Management trainees'.

layout-zebra = 'X'.

layout-COLWIDTH_OPTIMIZE = 'X'.

perform alv_display.

sort-fieldname = ' it_tab-matkl '.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

IT_SORT = SORT

so please help me out to solve this problem.

Thanks

Sujay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,368

Hi,

You need to pass the BODY of the Sort internal table... here is the sample

DATA: it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,

wa_sort-fieldname = 'BUKRS'.
wa_sort-tabname = 'IT_SORT'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'BELNR'.
wa_sort-tabname = 'IT_SORT'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gs_layout
it_fieldcat = ct_fieldcat
it_sort = it_sort[]
i_save = 'A'
TABLES
t_outtab = itab.

Regards

Sudheer

Hi all,

i am trying to use SORT option in reuse_ALV_grid_display. Here is what i have done, but i am getting dump with error as CALL_FUNCTION_CONFLICT_TYPE

.

data:it_fieldcat type slis_t_fieldcat_alv,

wa_fieldcat like line of it_fieldcat,

TITLE TYPE LVC_TITLE VALUE 'SUJAY',

layout type SLIS_LAYOUT_ALV,

sort type SLIS_T_SORTINFO_ALV with header line.

select-options: s_matnr for mara-matnr.

perform it_populate.

perform it_struct.

LAYOUT-WINDOW_TITLEBAR = 'Management trainees'.

layout-zebra = 'X'.

layout-COLWIDTH_OPTIMIZE = 'X'.

perform alv_display.

sort-fieldname = ' it_tab-matkl '.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

IT_SORT = SORT

so please help me out to solve this problem.

Thanks

Sujay

9 REPLIES 9
Read only

Former Member
0 Likes
1,368

Pass the fieldname parameter of the SORT table as MATKL only. Pass the table name as IT_TAB. Set the up/down parameter to 'X' depending on whether the sort has to be in ascending/descending order.

Manoj

Read only

0 Likes
1,368

can u eloborate on up/down option bcoz it is not in reuse_alv_grid_diplay.

what i have done is

perform alv_display.

sort-fieldname = 'matkl'.

sort-down = 'X'.

Read only

0 Likes
1,368

In Reuse up/down option is available.

  DATA:   wa_sortinfo TYPE slis_sortinfo_alv.
       i_sortcat TYPE slis_t_sortinfo_alv.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program     = report_id
            i_grid_title           = ws_title
*            i_callback_top_of_page = 'TOP-OF-PAGE'
            is_layout              = wa_layout
            it_fieldcat            = i_fieldcat[]
            it_sort                = i_sortcat
            i_save                 = 'A'
            it_events              = i_events
       TABLES
            t_outtab               = i_reportdata1
       EXCEPTIONS
            program_error          = 1
            OTHERS                 = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  PERFORM sortcat_init CHANGING i_sortcat.

FORM sortcat_init CHANGING i_sortcat TYPE slis_t_sortinfo_alv.

  CLEAR wa_sortinfo.
  wa_sortinfo-fieldname = 'EBELN'. (sales order)
  wa_sortinfo-tabname = 'I_REPORTDATA1'.
  wa_sortinfo-spos = 1.            " First sort by this field.
  wa_sortinfo-up = 'X'.            "   Ascending
  wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
  APPEND wa_sortinfo TO i_sortcat.

  CLEAR wa_sortinfo.
  wa_sortinfo-fieldname = 'EBELP'.
  wa_sortinfo-tabname = 'I_REPORTDATA1'.
  wa_sortinfo-spos = 2.            " Sec sort by this field.
  wa_sortinfo-up = 'X'.            "   Ascending
  wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
  APPEND wa_sortinfo TO i_sortcat.

ENDFORM.                    " sortcat_init

Hope this oslves ur problem, please reward points and close the thread if this solves.

Read only

Former Member
0 Likes
1,369

Hi,

You need to pass the BODY of the Sort internal table... here is the sample

DATA: it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,

wa_sort-fieldname = 'BUKRS'.
wa_sort-tabname = 'IT_SORT'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.

wa_sort-fieldname = 'BELNR'.
wa_sort-tabname = 'IT_SORT'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gs_layout
it_fieldcat = ct_fieldcat
it_sort = it_sort[]
i_save = 'A'
TABLES
t_outtab = itab.

Regards

Sudheer

Read only

0 Likes
1,368

it was helpful but it didnt resolve problem, i am not getting dump but not getting the desired result also.

Read only

0 Likes
1,368

Got ur problem

sort-fieldname = ' it_tab-matkl '.

Dont specify like this

<b>sort-fieldname = ' MATKL'.</b>

This will solve ur problem.

Read only

0 Likes
1,368

THIS IS MY COMPLETE PROGRAM -

CHECK THE OUTPUT

&----


*& Report ZSUJAY_ALV

*&

&----


*&

*&

&----


report zsujay_alv.

type-pools: slis.

tables: mara.

data: begin of it_tab occurs 0,

matnr like mara-matnr,

matkl like mara-matkl,

ersda like mara-ersda,

end of it_tab.

data:it_fieldcat type slis_t_fieldcat_alv,

wa_fieldcat like line of it_fieldcat,

title type lvc_title value 'SUJAY',

layout type slis_layout_alv,

sortinfo type slis_sortinfo_alv,

sortcat type slis_t_sortinfo_alv.

select-options: s_matnr for mara-matnr.

perform it_populate.

perform it_struct.

layout-window_titlebar = 'Management trainees'.

layout-zebra = 'X'.

layout-colwidth_optimize = 'X'.

perform alv_display.

sortinfo-fieldname = ' it_tab-ersda '.

sortinfo-tabname = 'sortcat'.

sortinfo-down = 'X'.

append sortinfo to sortcat.

&----


*& Form IT_POPULATE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form it_populate .

select matnr matkl ersda from mara into table it_tab where matnr in s_matnr.

append it_tab.

*endselect.

endform. " IT_POPULATE

&----


*& Form ALV_DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form alv_display .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = 'ZSUJAY_ALV'

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME = it_tab

  • I_BACKGROUND_ID = ' '

i_grid_title = title

  • I_GRID_SETTINGS = I_GRID_SETTINGS

is_layout = layout

it_fieldcat = it_fieldcat

  • IT_EXCLUDING = IT_EXCLUDING

  • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

it_sort = sortcat

  • IT_FILTER = IT_FILTER

  • IS_SEL_HIDE = IS_SEL_HIDE

  • I_DEFAULT = 'X'

  • I_SAVE = 'A'

  • IS_VARIANT = IS_VARIANT

  • IT_EVENTS = IT_EVENTS

  • IT_EVENT_EXIT = IT_EVENT_EXIT

  • IS_PRINT = IS_PRINT

  • IS_REPREP_ID = IS_REPREP_ID

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS = IT_ALV_GRAPHICS

  • IT_HYPERLINK = IT_HYPERLINK

  • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

  • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

  • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

  • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

tables

t_outtab = it_tab

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " ALV_DISPLAY

&----


*& Form it_struct

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form it_struct.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-seltext_m = 'MATERIAL NO'.

append wa_fieldcat to it_fieldcat.

wa_fieldcat-fieldname = 'MATKL'.

wa_fieldcat-seltext_m = 'MATERIAL GROUP'.

append wa_fieldcat to it_fieldcat.

wa_fieldcat-fieldname = 'ERSDA'.

wa_fieldcat-seltext_m = 'CREATED ON'.

append wa_fieldcat to it_fieldcat.

endform. " it_struct

Read only

0 Likes
1,368

sortinfo-fieldname = ' it_tab-ersda '.

sortinfo-tabname = 'sortcat'.

sortinfo-down = 'X'.

append sortinfo to sortcat.

change above code as below.

sortinfo-fieldname = ' ERSDA '.

sortinfo-down = 'X'.

append sortinfo to sortcat.

Read only

0 Likes
1,368

Hi,

As I said in my previous reply change

sortinfo-fieldname = 'ERSDA'.
sortinfo-tabname = 'IT_TAB'.
sortinfo-spos = 1.
sortinfo-down = 'X'.
append sortinfo to sortcat.

This will solve. Please close thethread by rewarding points if this solves, else revert back.

Tab name shoulpd be the output table name in CAPS

Message was edited by:

Judith Jessie Selvi