2007 Jun 14 12:34 PM
DEAR ALL ,
CAN ANY ONE HELP ME TO USE AT END OF AND OTHER CONTROL
STATEMENTS INTO 'ALV REPORTS' .
2007 Jun 14 1:04 PM
hi,
We use ALV Reports to improve the perfomance of report program.
by using ALV, we avoid processing logic to improve perfomance.
LOOP AT <internal table>.
WRITE:/
ENDLOOP. "
AT END OF and other control statements are valid inside the LOOP Statement only.
but the ALV avoiding LOOP and ENDLOOP statements to improve perfomance of program. so we can't use control statements in ALV's directly.
we can get the functionality of CONTROL STATEMENTS in ALV through functions like SORTING, SUM,
regards,
Ashokreddy.
DEAR ALL ,
CAN ANY ONE HELP ME TO USE AT END OF AND OTHER CONTROL
STATEMENTS INTO 'ALV REPORTS' .
2007 Jun 14 12:37 PM
Hi
You should not use the Control break statements in ALV report
Instead build a SORT Internal table based on the fields you require
and pass that I_SORT itab to the fun module (grid_display)
see the doc of AT new NOT for ALV
All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table
FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.
Some time you will get * when mopving data from this int table to other table using these commands
so you have to use
READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them
DATA: sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate,
sflight_wa LIKE LINE OF sflight_tab.
SELECT *
FROM sflight
INTO TABLE sflight_tab.
LOOP AT sflight_tab INTO sflight_wa.
AT NEW connid.
WRITE: / sflight_wa-carrid,
sflight_wa-connid.
ULINE.
ENDAT.
WRITE: / sflight_wa-fldate,
sflight_wa-seatsocc.
AT END OF connid.
SUM.
ULINE.
WRITE: / 'Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
SKIP.
ENDAT.
AT END OF carrid.
SUM.
ULINE.
WRITE: / 'Carrier Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
NEW-PAGE.
ENDAT.
AT LAST.
SUM.
WRITE: / 'Overall Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
ENDAT.
ENDLOOP.
Reward points for useful Answers
Regards
Anji
2007 Jun 14 12:40 PM
2007 Jun 14 12:52 PM
Hi,
check out this alv program for sorting..
This example program ll sort based on purchase org..
&----
*& Report ZREPORT2SJ *
*& *
&----
*& *
*& *
&----
REPORT zreport2sj.
TABLES : ekko,ekpo.
TYPE-POOLS : slis.
DATA : total TYPE i.
DATA : BEGIN OF itab2 OCCURS 0,
ekorg LIKE ekko-ekorg,
ebeln LIKE ekko-ebeln,
lifnr LIKE ekko-lifnr,
zterm LIKE ekko-zterm,
matnr LIKE ekpo-matnr,
menge LIKE ekpo-menge,
netpr LIKE ekpo-netpr,
END OF itab2.
DATA : w_report_id LIKE sy-repid.
DATA : w_title TYPE lvc_title VALUE 'PURCHASE ORDER DETAIL REPORT'.
DATA : w_fieldcat TYPE slis_t_fieldcat_alv.
data : w_header type slis_t_listheader.
data : w_layout type slis_layout_alv.
data : w_sort type SLIS_T_SORTINFO_ALV.
data : w_event type slis_t_event.
START-OF-SELECTION.
SELECT-OPTIONS : date foR ekko-aedat.
SELECT ekkoebeln ekkolifnr ekkoekorg ekkozterm ekpomatnr ekpomenge ekpo~netpr
INTO CORRESPONDING FIELDS OF TABLE itab2 FROM ( ekko INNER JOIN ekpo ON ekkoebeln = ekpoebeln )
WHERE ekko~aedat IN date AND
ekko~bstyp EQ 'F' AND
ekko~bsart EQ 'ZWT' AND
ekko~statu EQ '9' .
<b>sort itab2 by ekorg.</b>
w_report_id = sy-repid.
PERFORM fieldcat CHANGING w_fieldcat.
perform build_layout changing w_layout.
perform sort changing w_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = w_report_id
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = w_title
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = w_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
<b>IT_SORT = W_SORT[]</b>
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = w_event
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
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab2.
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.
&----
*& Form fieldcat
&----
text
----
<--P_W_fieldcat text
----
FORM fieldcat CHANGING p_w_fieldcat.
PERFORM event USING 'EBELN' 'itab2' 'po num' '' '' ''.
PERFORM event USING 'LIFNR' 'itab2' 'vendor num' '' '' ''.
PERFORM event USING 'EKORG' 'itab2' 'purchase org' '' '' ''.
PERFORM event USING 'ZTERM' 'itab2' 'payment term' '' '' ''.
PERFORM event USING 'MATNR' 'itab2' 'material num' '' '' ''.
PERFORM event USING 'MENGE' 'itab2' 'qty' 'X' 'QUAN' ''.
PERFORM event USING 'NETPR' 'itab2' 'net value' 'X' 'CURR' ''.
ENDFORM. " fieldcat
&----
*& Form build_layout
&----
text
----
<--P_W_LAYOUT text
----
form build_layout changing p_w_layout.
clear w_layout.
w_layout-zebra = 'X'.
w_layout-colwidth_optimize = 'X'.
endform. " build_layout
&----
*& Form sort
&----
text
----
<--P_W_sort text
----
form sort changing p_w_sort.
data : ws_sort type slis_sortinfo_alv .
ws_sort-FIELDNAME = 'EKORG'.
ws_sort-SPOS = 1.
ws_SORT-down = 'X'.
ws_SORT-SUBTOT = 'X'.
append ws_sort to w_sort.
endform. " sort
&----
*& Form event_table
&----
text
----
<--P_W_EVENT text
----
*& Form event
&----
text
----
-->P_0212 text
-->P_0213 text
-->P_0214 text
-->P_0215 text
-->P_0216 text
-->P_0217 text
----
form event using value(p_0212)
value(p_0213)
value(p_0214)
value(p_0215)
value(p_0216)
value(p_0217).
DATA: l_line_fieldcat TYPE slis_fieldcat_alv.
CLEAR l_line_fieldcat.
l_line_fieldcat-fieldname = p_0212.
l_line_fieldcat-ref_tabname = p_0213.
l_line_fieldcat-seltext_m = p_0214.
l_line_fieldcat-do_sum = p_0215.
l_line_fieldcat-datatype = p_0216.
l_line_fieldcat-key = p_0217.
APPEND l_line_fieldcat TO w_fieldcat.
endform. " event
Reward if useful..
Regards,
Pranathi.
2007 Jun 14 12:58 PM
<b>Add Default Sorting to ALVgrid report </b>
In order to display an ALV report with specific columns already sorted by default you will need to build a sort catalogue. This is fairly straight forward and is done in the following way:
ALV data declarations
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
perform build_sortcat.
*&------------------------------------------------------------------*
*& Form build_sortcat
*&------------------------------------------------------------------*
* Build Sort catalog
*-------------------------------------------------------------------*
FORM build_sortcat .
wa_sort-spos = 1.
wa_sort-fieldname = 'EBELN'.
wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
wa_sort-spos = 2.
wa_sort-fieldname = 'EBELP'.
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
ENDFORM. " build_sortcat
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
reward points if it is usefull ...
Girish
2007 Jun 14 1:04 PM
hi,
We use ALV Reports to improve the perfomance of report program.
by using ALV, we avoid processing logic to improve perfomance.
LOOP AT <internal table>.
WRITE:/
ENDLOOP. "
AT END OF and other control statements are valid inside the LOOP Statement only.
but the ALV avoiding LOOP and ENDLOOP statements to improve perfomance of program. so we can't use control statements in ALV's directly.
we can get the functionality of CONTROL STATEMENTS in ALV through functions like SORTING, SUM,
regards,
Ashokreddy.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |