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

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

Former Member
0 Likes
1,825

Dear Experts,

I hv created a report using ALV.

Problem is , until I call "CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'" function module, my internal table is sorted fine. but after this function module ( i hv seen in debug mode) , the sort order is getting changed.

I hv not used any kind of sort in update catalog funcion.

 w_repid = sy-repid.
  PERFORM update_catalog.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM                 = w_repid
     I_CALLBACK_USER_COMMAND            = 'USER_COMMAND'
     I_CALLBACK_TOP_OF_PAGE             = 'TOP-OF-PAGE'
     IT_FIELDCAT                        = i_fcat[]
     I_SAVE                             = 'X'
    TABLES
      T_OUTTAB                          = i_faglflexa_all
*  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.

can any one suggest something.

Regards,

maverick

12 REPLIES 12
Read only

nikhil_chitre
Active Participant
0 Likes
1,553

Hi,

What is the change that is happening in sort order of your internal table...

Also I would suggest you to check the sequence of your fieldcatlog table and internal table.

Regards,

Nikhil

Read only

0 Likes
1,553

Hi

check the field catlog defination it may be possible that u sorted any colomn by passing 'X' in field catlog

thax

Read only

Former Member
0 Likes
1,553

Hi,

Problem is , until I call "CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'" function module, my internal table is sorted fine. but after this function module ( i hv seen in debug mode) , the sort order is getting changed.

Can you elaborate this?

Thanks,

Archana

Edited by: Rob Burbank on Feb 2, 2010 9:27 AM

Read only

0 Likes
1,553

Thanks for ur reply.

itab_open.

status doc no

open 101

open 102

open 103

itab_all.

append itab_open[] to itab_all.

sort itab_all by date.

itab_clear

status doc no

clear 104

clear 105

claer 106

loop at itab_clear.

append itab_clear to itab_all.

endloop.

i hv sorted my internal table itab_all based on date only once after copying the data from itab_open. Then i appended the data from itab_clear.

now I call CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM                 = w_repid
     I_CALLBACK_USER_COMMAND            = 'USER_COMMAND'
     I_CALLBACK_TOP_OF_PAGE             = 'TOP-OF-PAGE'
     IT_FIELDCAT                        = i_fcat[]
     I_SAVE                             = 'X'
     IT_SORT                            = ''
    TABLES
      T_OUTTAB                          = itab_all
*  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.

and i get the following output.

status doc no

open 101

open 102

clear 104

clear 105

claer 106

open 103

tha's the problem. why one open item is displayed at the end. i sorted itab_all after copying the data from itab_open and after itab_clear.

regards,

Maverick

Read only

0 Likes
1,553

Hi ,

First Sort the first internal table and then you are writting the some logic to append , then again sort the another internal table and then based on the some condition your appending to final intenal table which is your output by using the Grid FM.

Try to sort the final internal table which is used for GRID display and make the SORT as 'X.

Check this.

Regards,

Bharani

Read only

Former Member
0 Likes
1,553

Hi,

I saw your this statement 'i sorted itab_all after copying the data from itab_open and after itab_clear'. May be because of that you are getting such output you sorted the table twice once after copying itab_open and again after copying itab_clear.

Instead of that why can't you sort the itab_open and itab_clear before appending to itab_all.

Hope this should solve your problem.

Regards,

Manohar

Read only

0 Likes
1,553

Thanks for ur reply

sorry for typing mistake.

the statement was as

i sorted itab_all after copying the data from itab_open and after after itab_clear.

i sorted itab_all after copying the data from itab_open and not after after itab_clear.

Regards,

Maverick

Read only

0 Likes
1,553

Hi,

You have sorted based on date. Please Check the date for the record Open 103 .

Edited by: Tharani on Feb 2, 2010 1:44 PM

Read only

0 Likes
1,553

Hi,

According to your question, you are getting output as follows:

status doc no

open 101

open 102

clear 104

clear 105

claer 106

open 103

And you don't want open item to be displayed at the end. So, after appending the data from itab_open, you sorted itab_all by date. Then appended data from itab_clear. So, after appending data from itab_clear, did you check how itab_all is appearing? Whether it is same as output displayed finally?

Thanks,

Archana

Read only

0 Likes
1,553

Thanks for ur reply.

Yes I hv checked right bofore the call of

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM                 = w_repid
     I_CALLBACK_USER_COMMAND            = 'USER_COMMAND'
     I_CALLBACK_TOP_OF_PAGE             = 'TOP-OF-PAGE'
     IT_FIELDCAT                        = i_fcat[]
     I_SAVE                             = 'X'
    TABLES
      T_OUTTAB                          = i_faglflexa_all
*  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.

.

it is in the order i want.

if iput a break point at

IF SY-SUBRC  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

i get the sort order changed.

My field catlog is like

i_fcat-fieldname  = 'W_STATUS'.
  i_fcat-seltext_m  = 'Status'.
  i_fcat-col_pos    = 0.
  i_fcat-sp_group   = 'X'.
  i_fcat-outputlen  = 12.

  append i_fcat to i_fcat.
  clear  i_fcat.

I m not using any sort condition here.

Regards,

Mavericl

Read only

0 Likes
1,553

Hi Maverickk.

Just add STABLE to your SORT Statment.

That is SORT IT_TABLE STABLE by FIELD .

Rahul.

Read only

0 Likes
1,553

<li>Put two breakpoints. one is one REUSE_ALV_GRID_DISPLAY function module and another on IF SY-SUBRC eq 0 after REUSE_ALV_GRID_DISPLAY function module. Now check the the values in itab_all internal table. Thanks Venkat.O