05-09-2006 4:36 PM
Hi All,
i used alv grid function module and i sorted the fields...
there is no problem in the report but when i try to print the same output(i.e..,what i got in filter data)
it is not printing in the same manner ...
plz help me out in this case
thanks in advance.
regards,
Ravi V Ganji
05-09-2006 4:40 PM
please see to it that u use the code and sort it in the following format
FORM SORT_FUNC.
DATA: WA_SORT TYPE SLIS_SORTINFO_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV.
WA_SORT-SPOS = '1'.
WA_SORT-FIELDNAME = 'MTART'.
WA_SORT-TABNAME = 'IT_MARA'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = '2'.
WA_SORT-FIELDNAME = 'MATKL'.
WA_SORT-TABNAME = 'IT_MARA'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = '3'.
WA_SORT-FIELDNAME = 'MATKL'.
WA_SORT-TABNAME = 'IT_MARA'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = '4'.
WA_SORT-FIELDNAME = 'NTGEW'.
WA_SORT-TABNAME = 'IT_MARA'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = '5'.
WA_SORT-FIELDNAME = 'MATNR'.
WA_SORT-TABNAME = 'IT_MARA'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
ENDFORM. "SORT_FUNC
<b>reward points if helpful</b>
Message was edited by: Rahul Kavuri
Message was edited by: Rahul Kavuri
05-09-2006 4:51 PM
Ravi,
How did you create your field catalog, I guess manually. Try to create a field catalog using a structure passing to the function RESUE_ALV_FIELDCATALOG_MERGE.
That should fix the problem.
Regards,
Ravi
Note : Please mark the helpful answers
05-09-2006 4:57 PM
Hi Ravi,
I understand your problem is in sorting the output in display. You need to sort the fields explicitly e.g.
Code section :
-
data: tmp_sort type line of slis_t_sortinfo_alv.
clear sort.
refresh sort.
clear tmp_sort.
tmp_sort-fieldname = 'FIELD1'.
tmp_sort-up = 'X'.
append tmp_sort to sort.
clear tmp_sort.
tmp_sort-fieldname = 'FIELD2'.
tmp_sort-up = 'X'.
append tmp_sort to sort.
clear tmp_sort.
-
Description : You need to build internal table 'sort' with the fields on which display should be sorted. FiELD1 and FIELD2 are the fields of the internal table and note that it should be given in CAPITAL letter.
Then you need to pass this sort table to the List or Grid FM.
Code description :
-
DATA: lv_exit_caused_by_caller(1) TYPE c,
ls_exit_caused_by_user TYPE slis_exit_by_user.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = ls_layout
Pass sort table to the parameter
it_sort = sort
it_fieldcat = GT_FIELDCAT[]
i_save = 'X'
is_variant = ls_variant
importing
e_exit_caused_by_caller = lv_exit_caused_by_caller
es_exit_caused_by_user = ls_exit_caused_by_user
tables
t_outtab = i_display_first_report
exceptions
program_error = 1
others = 2.
-
Cheers,
Vikram.
Please reward helpful replies. Tx!!!
05-09-2006 5:24 PM
Hi Ravi,
offen i sort a ALV_GRID not in the Report. At the Output
i insert a layout (f. Example with Sort Fields) and it works like i want.
When i print the Output with this layout, i don't have
any Problems.
You can set a special layout as default.
Hope i can help you.
Regards,
Dieter
05-10-2006 8:17 AM
Hi Ravi,
Please check the following URLs,
http://help.sap.com/saphelp_46c/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
Regards,
Ranjit Thakur.
Please Mark The Helpful Answer.
05-10-2006 8:25 AM
Hai Ravi Vardhan
Check the following Code
&----
*& Report ZALV_GRID *
*& *
&----
*& *
*& *
&----
REPORT ZALV_GRID .
TABLES: MARA.
TYPE-POOLS : SLIS.
*----
Data declaration
*----
DATA: BEGIN OF I_MARA OCCURS 0.
INCLUDE STRUCTURE MARA.
DATA: END OF I_MARA.
DATA: V_REPID LIKE SY-REPID.
*----
selection-screen
*----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
PARAMETERS: P_MTART LIKE MARA-MTART DEFAULT 'ROH'.
SELECTION-SCREEN END OF BLOCK B1.
*----
initialisation
*----
INITIALIZATION.
S_MATNR-LOW = '1400'.
S_MATNR-HIGH = '1500'.
APPEND S_MATNR.
V_REPID = SY-REPID.
*----
start-of-selection
*----
START-OF-SELECTION.
SELECT * FROM MARA
INTO TABLE I_MARA
WHERE MATNR IN S_MATNR AND
MTART = P_MTART.
CHECK SY-SUBRC = 0.
*----
end of selection
*----
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'MARA'
IS_LAYOUT =
IT_FIELDCAT =
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_MARA
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.
Thanks & regards
Sreenivasulu P