‎2009 Sep 17 12:15 PM
Hi,
I have created a field catalog to be passed to the FM REUSE_ALV_GRID_DISPLAY, without calling the FM REUSE_ALV_FIELDCATALOG_MERGE.
The result is being displayed properly. But the problem is that, when I try to export the alv into a spreadsheet by clicking on the button 'Local File..', the data is saved in random manner in the excel file.(data is being placed in saome other column).
How to rectify this.
Please help.
Regards
s.a.k
‎2009 Sep 17 12:19 PM
‎2009 Sep 17 12:23 PM
Hi,
There are no special characters.
The only reason is that I dont want to create a structure/table type for this.
Regards
s.a.k
‎2009 Sep 17 12:28 PM
can you please how the code?
the field catalog and the alv fm call and the final table structure?
‎2009 Sep 17 12:37 PM
Hi,
data:
l_tbl_fieldcat TYPE slis_t_fieldcat_alv,
lv_fcat LIKE LINE OF l_tbl_fieldcat.
....
....
*********************Prepare field catalog***********************
*Column: Role Name
CLEAR lv_fcat.
lv_fcat-fieldname = 'AGR_NAME'.
lv_fcat-ref_fieldname = 'AGR_NAME'.
lv_fcat-tabname = 'AGR_1251'.
lv_fcat-col_pos = 1.
lv_fcat-seltext_s = text-003.
lv_fcat-seltext_m = text-003.
lv_fcat-seltext_l = text-003.
INSERT lv_fcat INTO TABLE l_tbl_fieldcat.
*Column: Role Description
CLEAR lv_fcat.
lv_fcat-fieldname = 'TEXT'.
lv_fcat-ref_fieldname = 'AGR_TITLE'.
lv_fcat-tabname = 'AGR_TEXTS'.
lv_fcat-col_pos = 2.
lv_fcat-seltext_s = text-004.
lv_fcat-seltext_m = text-004.
lv_fcat-seltext_l = text-004.
INSERT lv_fcat INTO TABLE l_tbl_fieldcat.
*Column: Transaction Code
CLEAR lv_fcat.
lv_fcat-fieldname = 'LOW'.
lv_fcat-ref_fieldname = 'TCODE'.
lv_fcat-tabname = 'TSTCT'.
lv_fcat-col_pos = 3.
lv_fcat-seltext_s = text-005.
lv_fcat-seltext_m = text-005.
lv_fcat-seltext_l = text-005.
INSERT lv_fcat INTO TABLE l_tbl_fieldcat.
***************************************************
Display ALV****
CLEAR l_wa_layout.
l_wa_layout-colwidth_optimize = lc_true.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = l_tbl_fieldcat
is_layout = l_wa_layout
TABLES
t_outtab = l_tbl_role_res
EXCEPTIONS
program_error = 1
OTHERS = 2.
Regards
s.a.k
‎2009 Sep 17 12:44 PM
Hi,
Also provide solution for the problem below:
My first screen is a selection screen. The user provides some data for a particular filed. And the ALV grid is displayed with the result.
The requirement is that the result should be displayed with the selection made by the user on top of the grid.
Please suggest.
Regards
s.a.k
‎2009 Sep 17 12:54 PM
As for the first, I suggest to drop col_pos , it is unnecessary here as you provide column in same order as they are appended to fieldcatalog.
Regarding the second question, please refer [Dispaly ALV report output in the SAME Selection Screen|http://wiki.sdn.sap.com/wiki/x/UoGCAw]
Regards
Marcin
‎2009 Sep 17 12:57 PM
hi s.a.k.
for your second problem, you need to use TOP_OF_PAGE event..
in ALV Fm there is one parameter called : I_CALLBACK_TOP_OF_PAGE
here you need to pass a subroutine name and in this subroutine you need to call REUSE_ALV_COMMENTARY_WRITE
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/bfa9e590-0201-0010-5990-a69ad5c284e2
‎2009 Sep 17 1:11 PM
Hi Marcin,
Thanks for your suggestion. I will remove that. But still the problem is not solved.
Reagrding the second question:
The output should be displayed in the second screen with the selection (not the selection screen fields)
i.e. say the seletion screen has 5 fields and the user provides value for only one field (screen field name: created date).
eg. 17/09/2009
The ALV will have the result shopwn corresponding to the date selected. On top of it, it should be something like
Created Date: 17/09/2009
and then the ALV .
And now if the user wants to download this into an spreadsheet(excel file), the above information should also be inserted into this.
Can it be done.
Kindly suggest.
Regards
s.a.k
Edited by: siemens.a.k on Sep 17, 2009 2:12 PM
‎2009 Sep 17 1:25 PM
Hi Somyaprakash,
Thank you very much. The code sample is really helpful.
I have gone through it and I saw that after calling the FM: REUSE_ALV_FIELDCATALOG_MERGE, the fieldcatalog table is being looped and its being modified depeneding on the fieldaname. In this case, there are only 3 fields. But what if there are say 30-50 fields or may be even more.
Is there any other way to to this thing.
The example is really helpful. I am just thinking how much the number of line will be if there are 100 fields in the internal table?
Just to make it more efficient.
Please suggest.
Thanks once again.:)
Regards
s.a.k
‎2009 Sep 17 1:42 PM
if there are 100 rows in your itab, and you say you are creating your field catalog manually how do you create in general? use the general way only.. no problem...
‎2009 Sep 17 1:48 PM
Hi,
Thank you.:)
And also thanks to all the other users who replied.:)
Regards
s.a.k
‎2009 Sep 17 12:46 PM
Hi,
Try like this sample code:
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
it_fieldcat = fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = lt_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
Thanks,
‎2009 Sep 17 12:52 PM
Hi Sindhu,
In the FM u are passing the fieldcatalog, which u must have prepared by calling the REUSE_ALV_FIELDCATALOG_MERGE function module. And in this we have to pass the structure(DDIC) or the internal table name.
But i dont want to create a DDIC object for this. I have created the fieldcatalog as shown in the previous post.
But on extraction the data is randomly arranged.
This is the main issue.
Please sugget.
Regards
s.a.k
‎2009 Sep 17 12:57 PM
Pl. Check the field catalog after REUSE_ALV_FIELDCATALOG_MERGE whether in the field catalog COL_POS is filled properly and your OUTPUT internal table fields in the same order
And also check your patch level of your SAPGui
a®
‎2009 Sep 17 1:16 PM
Hi a®s,
For calling the FM: REUSE_ALV_FIELDCATALOG_MERGE, i have to pass the structure/internal table. The structure should exist in the DDIC. But I dont want to create this structure.
I am able to prepare the fieldcatalog. but the problem is while saving it into a spreadsheet.
Kindly suggest some alternative.
Regards
s.a.k