‎2007 May 10 7:28 AM
hi to all
how to trigger the page break in in alv on particular condition.and how to change the font color in alv
what is the difference betweeen sy_repid,sy-cprog.
‎2007 May 10 7:34 AM
hi,
check this link for System fields.
http://help.sap.com/saphelp_47x200/helpdata/en/7b/fb96c8882811d295a90000e8353423/frameset.htm
regards,
santosh
‎2007 May 10 7:35 AM
‎2007 May 10 7:36 AM
Hi
Sy-REPID - Report ID, what we give in SE38 tcode.
SY-CPROG - It is the calling Program Name
You can't change the FONT of the fields in ALV report.
for coloring the ALV fields see the doc;
1. add one more field to ur final internal table say COLOR(4)
2. in layout wa_layout-style_fname = 'COLOR'. " if its grid
wa_layout-style_fieldname = 'COLOR'. "if its list
3. read table itab index 3.
itab-color = 'C410'.
modify itab index 3
4. see program SHOWCOLO for all color codes
1. Add a field of data type CHAR(3) to the internal output table.
2. Enter the color code in the appropriate field of the row to be colored in the internal
output table:
Code: 'Cxy'
C = Color (all codes begin with 'C')
x = color number ('1' - '9')
y = highlight ('0' = off, '1' = on)
3. Assign the internal output table color code field name to the IS_LAYOUT importing
structure IS_LAYOUT-INFO_FIELDNAME field and pass this structure in the ALV call
interface.
To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, lets modify declaration of our list data table gt_list.
you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field INFO_FNAME of the layout structure.
e.g.
ps_layout-info_fname = <field_name_containing_color_codes>. e.g. ROWCOLOR
You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
You can color an entire row as described in the next section. However, this method is less time consuming.
Coloring Individual Cells
This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by more is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.
The structure that should be included must be of type LVC_T_SCOL. If you want to color the entire row, this inner table should contain only one row with field fname is set to space, some color value at field col, 0 or 1 at fields int (intensified) and inv (inverse).
If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field fname. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table.
Reward points if useful
Regards
Anji
‎2007 May 10 7:38 AM
<b>ALV grid color</b>
1. Define a column as follows in output table type
TYPES : BEGIN OF ty_output.
INCLUDE STRUCTURE MARA.
TYPES :
* For cell coloring
cellcolor TYPE lvc_t_scol,
END OF ty_output.
data : w_cellcolor TYPE lvc_s_scol, "For cell color
* Final output table
itab2 TYPE STANDARD TABLE OF ty_output,
wa2 TYPE ty_output,
w_layout TYPE lvc_s_layo.2. Colouring cell
CLEAR wa2.
READ TABLE itab2 INTO wa2 INDEX 7.
IF sy-subrc EQ 0.
w_cellcolor-fname = 'ERSDA'.
w_cellcolor-color-col = '7'.
w_cellcolor-color-int = '1'.
w_cellcolor-color-inv = '1'.
APPEND w_cellcolor TO wa2-cellcolor.
MODIFY itab2 FROM wa2 TRANSPORTING cellcolor WHERE matnr = wa2-matnr.
ENDIF.3. cell color
w_layout-ctab_fname = 'CELLCOLOR'."For cell coloring4. in display
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
* I_STRUCTURE_NAME = 'MARA'
IS_VARIANT = w_variant
I_SAVE = 'A'
it_toolbar_excluding = i_exclude
is_layout = w_layout
CHANGING
it_outtab = itab2
it_fieldcatalog = i_fieldcat.Regards
‎2007 May 10 7:43 AM
<b>Page break in ALV</b>
You can use the option of Grouping to achieve this.
For more details, read the documentation of the data element SLIS_CTRLS, which is used for the structure field slis_sortinfo_alv-group.
slis_sortinfo_alv is the line type of the parameter IT_SORT of the FM REUSE_ALV_GRID_DISPLAY.
If you use '*' as the value for slis_sortinfo_alv-group, it will initiate a page break and if you use 'UL', the ALV will use Underline to differentiate between the group.
Example:
sort-spos = '10'.
SORT-FIELDNAME = 'Years'.
SORT-TABNAME = 'DATA_TAB2'.
sort-UP = 'X'.
sort-subtot = 'X'.
SORT-GROUP = '* '.
APPEND SORT. CLEAR SORT.If you are looking for page break in terms of printing operation for new page option, then ALV grid function module has following option -
Function Module - REUSE_ALV_GRID_DISPLAY
Option from function module: IS_PRINT
NO_NEW_PAGE = 'X'.
There are many options available in IS_PRINT. You can use them as per your requirement.
Regards