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

Regarding sorting in ALV

Former Member
0 Likes
2,154

Hi Experts,

I am displaying purchase order in sort order in ALV.

when displaying in the output it is not displaying in the sort order.

This is causing issue when double clicking the purchase order to interactive list.

when i click on the first purchae order, it is displaying in the whatever there in the internal table first.

what is the cause for the problem? how i can display the output according to internal table sort order in ALV display.

Regards,

udupi

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
0 Likes
2,097

Dear Udupi,

Can you post your code:

Are you using cl_gui_alv_grid or something else ?

Hi Experts,

I am displaying purchase order in sort order in ALV.

when displaying in the output it is not displaying in the sort order.

This is causing issue when double clicking the purchase order to interactive list.

when i click on the first purchae order, it is displaying in the whatever there in the internal table first.

what is the cause for the problem? how i can display the output according to internal table sort order in ALV display.

Regards,

udupi

18 REPLIES 18
Read only

former_member214709
Participant
0 Likes
2,097

Dear Udupi,

Check the internal table which you have passed to the ALV Function module, that Internal table must be sorted and that too based on the PO number i think EBELN.

SORT ITAB by EBELN.

And for displaying the PO in ME23n you need to go for the SET PARAMETER ID using Sy-ucomm .

Regards

Dinesh

Read only

0 Likes
2,097

internal table is sorted both EBELN and EBELP.

But when dispplaying the layout in is not displaying in the sorted order.

and when user double click on the purchase order number , it is displaying in the order of the internal table.

Read only

0 Likes
2,097

Check the fieldcatalog definition where you have declared the field EBELN and the associated Table as well as the reference field in the fieldcatalog.

If everything works fine.

Then just put a break-point before the CALL FUNCTION REUSE_ALV_GRID is called as well as check the sy-ucomm and the sy-repid.

Read only

rosenberg_eitan
Active Contributor
0 Likes
2,098

Dear Udupi,

Can you post your code:

Are you using cl_gui_alv_grid or something else ?

Read only

0 Likes
2,097

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

        EXPORTING

          i_callback_program      = l_repid

          is_layout_lvc           = ls_layout

          it_fieldcat_lvc         = lt_fcat

          i_save                  = 'A'

          it_sort_lvc             = t_sort

          i_grid_settings         = ls_glay

          is_variant              = ls_variant

          it_events               = lt_events

          it_event_exit           = lt_event_exit

          i_screen_start_column   = im_screen_start_column

          i_screen_start_line     = im_screen_start_line

          i_screen_end_column     = im_screen_end_column

          i_screen_end_line       = im_screen_end_line

        IMPORTING

          e_exit_caused_by_caller = l_exit_by_caller

          es_exit_caused_by_user  = ls_exit_caused_by_user

        TABLES

*Begin of Modification by SREDDY on 19/OCT/2010 - SAP-6910.

*          t_outtab                = <table>

           t_outtab                = it_main

Read only

0 Likes
2,097

Can you show us please the code that is activate when you click on the  purchae order

Read only

0 Likes
2,097

Have a look at program ERPSLS_CUSTOMERS.

Note the the use of formUSER_COMMAND

Read only

0 Likes
2,097

FORM alv_user_command CHANGING ch_ucomm TYPE sy-ucomm
                               ch_selfield TYPE slis_selfield.

  CHECK NOT gf_controller IS INITIAL.
  CALL METHOD gf_controller->handle_user_command
    CHANGING
      ch_ucomm    = ch_ucomm
      ch_selfield = ch_selfield.

l_ehp4_active = cl_ops_switch_check=>mm_sfws_p2pse( ).
lo_const = cl_mmpur_constants=>get_instance( ).

IF i_ebeln IS INITIAL AND i_data_from_buffer IS INITIAL.
  MESSAGE e015(mepo) RAISING invalid_call.
ENDIF.
IF i_bstyp IS INITIAL OR (
   i_bstyp EQ lo_const->bstyp_k AND l_ehp4_active EQ lo_const->yes ).
  CALL FUNCTION 'ME_EKKO_SINGLE_READ'
    EXPORTING
      pi_ebeln         = i_ebeln
    IMPORTING
      po_ekko          = l_ekko
    EXCEPTIONS

   IF l_skip NE space.

     CALL TRANSACTION l_t

   ELSE.

     CALL TRANSACTION l_t

   ENDIF.

ELSE.

Read only

0 Likes
2,097

FORM alv_user_command CHANGING ch_ucomm TYPE sy-ucomm
                               ch_selfield TYPE slis_selfield."#EC CALLE

  CHECK NOT gf_controller IS INITIAL.
  CALL METHOD gf_controller->handle_user_command
    CHANGING
      ch_ucomm    = ch_ucomm
      ch_selfield = ch_selfield.

l_ehp4_active = cl_ops_switch_check=>mm_sfws_p2pse( ).
lo_const = cl_mmpur_constants=>get_instance( ).

IF i_ebeln IS INITIAL AND i_data_from_buffer IS INITIAL.
   MESSAGE e015(mepo) RAISING invalid_call.
ENDIF.
IF i_bstyp IS INITIAL OR (
    i_bstyp EQ lo_const->bstyp_k AND l_ehp4_active EQ lo_const->yes ).
   CALL FUNCTION 'ME_EKKO_SINGLE_READ'
     EXPORTING
       pi_ebeln         = i_ebeln
     IMPORTING
       po_ekko          = l_ekko
     EXCEPTIONS

isplay transaction

     IF l_skip NE space.

       CALL TRANSACTION l_tcode AND SKIP FIRST SCREEN.

     ELSE.

       CALL TRANSACTION l_tcode.

     ENDIF.

Read only

0 Likes
2,097

I am sorry but I am not familiar with this coding technic.

Now days we are using cl_gui_alv_grid and hotspots. it is much easier

then REUSE_ALV_GRID_DISPLAY .

Read only

0 Likes
2,097

Hello Udupi,

If you are not able display in sort order of PO number and item in ALV. That means I believe some where your sorting is getting overwritten by some other sort/code. Pls check that in debugging and wt are the values your passing for parameter  t_sort to FM Reuse... This parameter will have effect on sort of  final display of output.

I think if you sort out the first issue, then second issue will be resolved. If still problem exists for second after one sorting out first issue. Pls check the wt are the values are passing to parameter ch_selfield while calling form alv_user_command in debugging.

Pls let me know if you need any more help.

Shravan

Read only

0 Likes
2,097

Hi Sharvan,

Thanks for your reply.

In debugging mode, i deleted sort internal table, than also i am geting same output.

Read only

0 Likes
2,097

Hi Sharvan,

Thanks for your reply.

In debugging mode, i deleted sort internal table, than also i am geting same output.

Read only

0 Likes
2,097

Hi

I've checked your code, but it's not clear where you get the PO number (variable I_EBELN): I can't see in your form alv_user_command.

Max

Read only

0 Likes
2,097

Program not using AT USER_COMMAND. program populating events USER_COMMAND in the it_event in the internal table.

Read only

0 Likes
2,097

Hi Udupi,

Pls comment the below line of code in FM Reuse_alv...instead of deleting sort table in debugging mode.

  it_sort_lvc             = t_sort

Before calling this FM,  sort the internal table it_main with ebeln and ebelp and let me know how it goes.

Shravan

Read only

0 Likes
2,097

Hi

The concept is the same where I_EBELN is from?

Max

Read only

0 Likes
2,097

Thanks shravan