02-12-2009 12:44 PM
Hi all,
this is my problem:
i have an ALV GRID in which I display several columns in a proper order, es : A B C D E F G
when i create an excel from this display i obtain a different order of the columns!
in particular the 3 columns which represent numeric values (es C D E) are the last 3 colums in the excel, instead in the alv grid this 3 comuns stay in the middle!
so in the excel i obtain : A B F G C D E!!!!
please can anyone help me to fix this problem?
02-12-2009 12:57 PM
While creating the field catalog..
use
For A
fieldcat-colpos = 1.
For B
fieldcat-colpos = 2.
for each field as 1,2,3 in the order which u want
Regards,
Prashant
02-12-2009 1:04 PM
sure i'm already doing this!
in fact in the alv i display correctly the order of the columns
the problem is that the order change only when i create the file excel
the order of the columns is different in my excel!!!!
the colpos u say affect the position in the alv!
here it seems that there isn't a corrispondence between the alv i diplay and the file i'm going to create!!!!
how is it possible?
02-12-2009 1:10 PM
02-12-2009 1:23 PM
hi,
if you do a debugging it will go into the function module alv_xxl_call.
in this we can find the code as below.
catch system-exceptions import_mismatch_errors = 1.
import l_xxl_toggle_date from database ltdx(XL) id
'bcalv_xxl_toggle_date'.
endcatch.
here place a break point and check what value is it coming for this variable l_xxl_toggle_date.
if it is coming as X. then this problem will arrive.
here manually change the variable to space and check , the output will be coming perfectly.
if value is coming as X.
THEN WE CAN DO ONE THING.
HERE we are having a report bcalv_toggle_date which MUST EXECUTED ONCE ONLY.
WHEN IT IS EXECUTED IT DOES NOT DISPLAY ANYTHING.
after executing once the variable will be changed from X TO SPACE.
but we must run this report as other program excel sheet download order might get disturbed.
my might suggestion copy thwe standard gui to custom one and right a code for that excel icon in your code as shown below.
we need to copy the function module alv_xxl_call and comment the code
catch system-exceptions import_mismatch_errors = 1.
import l_xxl_toggle_date from database ltdx(XL) id
'bcalv_xxl_toggle_date'.
endcatch.
if l_xxl_toggle_date is initial.
and endif of the above if.
WHEN 'XXL'.
DATA : v_fieldcat TYPE STANDARD TABLE OF kkblo_fieldcat.
DATA : wa_fieldcat TYPE kkblo_fieldcat.
DATA : w_fieldcat LIKE LINE OF gt_fieldcat.
DATA : g_sort TYPE slis_t_sortinfo_alv.
DATA : g_filter TYPE slis_t_filter_alv.
DATA : a_fieldcat TYPE slis_t_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
es_layout = gs_layout
et_fieldcat = a_fieldcat[]
et_sort = g_sort
et_filter = g_filter
es_variant = gs_variant.
DELETE a_fieldcat WHERE no_out = 'X'.
LOOP AT a_fieldcat INTO w_fieldcat.
MOVE-CORRESPONDING w_fieldcat TO wa_fieldcat.
APPEND wa_fieldcat TO v_fieldcat.
ENDLOOP.
CALL FUNCTION 'ZALV_XXL_CALL'
EXPORTING
i_tabname = 'IT_FINAL'
IS_LAYOUT =
it_fieldcat = v_fieldcat[]
I_CALLBACK_TOP_OF_PAGE =
I_TITLE =
I_MODE =
TABLES
it_outtab = it_final
EXCEPTIONS
FATAL_ERROR = 1
NO_DISPLAY_POSSIBLE = 2
OTHERS = 3.
02-12-2009 1:25 PM
all the above which i had given is if you are using
list-export-spreadsheet
02-13-2009 9:26 AM