Vous êtes sur la page 1sur 9

SALV_DEMO_TABLE_COLUMNS

Include type instead of field catalog


http://scn.sap.com/thread/1317072

Naimesh Patel Apr 22, 2009 9:56 PM (in response to Dean Atteberry)
In SALV model, system creates the Field cataloge automatically based on the structure of the table. Yes, you need to
get the COLUMNS objects to be able to work with it.

Try like this:

* Get the column object


DATA: lo_cols

TYPE REF TO cl_salv_columns.

lo_cols = me->wo_salv->get_columns( ).
* modify individual properties
DATA: lo_column

TYPE REF TO cl_salv_column.

TRY.
lo_column = lo_cols->get_column( 'AVAILDATE' ).
lo_column->set_long_text( 'Avl Date' ).

"#EC NOTEXT

lo_column->set_medium_text( 'Avl Date' ).

"#EC NOTEXT

lo_column->set_short_text( 'Avl Date' ).

"#EC NOTEXT

lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found.

"#EC NO_HANDLER

ENDTRY.

Explore class CL_SALV_COLUMN for different methods to change the properties of the column.

See program SALV_DEMO_TABLE_COLUMNS

You can also check: [SALV Table Display - Column Properties|http://help-abap.blogspot.com/2008/09/salv-model-7changing-column-settings.html]

Regards,
Naimesh Patel

http://zevolving.com/tag/salv-table/page/2/
http://zevolving.com/2008/09/salv-table-1-normal-alv-table-display/
wiki:
http://wiki.scn.sap.com/wiki/display/ABAP/ALV+Grid+Report++with+Object+Oriented+SALV+Classes
multiple header lines:
http://scn.sap.com/thread/1588852

Re: ALV multiply header lines using ALV Factory

Sravanthi Veeramachaneni Jan 25, 2010 11:28 AM (in response to Dan K.)
Hi,

You can usee the below code.

DATA : obj_header

TYPE REF TO cl_salv_form_layout_grid,

sp_obj_header TYPE REF TO cl_salv_form_layout_grid.

TRY.

CALL METHOD cl_salv_table=>factory(


IMPORTING
r_salv_table = obj_output
CHANGING
t_table

= it_display ). "Internal table to dispaly ALV output

CATCH cx_salv_error.

ENDTRY.

CREATE OBJECT sp_obj_header.

Create a header grid with required column and rows


obj_header = sp_obj_header->create_grid( row = 2
column = 1
colspan = 6 ).

obj_header->create_label(
row

=1

column = 1
text

= 'Test line1' ).

obj_header->create_label(
row

=2

column = 1
text

= 'Test line2').

obj_output->set_top_of_list( obj_header ).

Display Table
obj_output->display( ).

Hope this may be helpful.

Regards,
Sravanthi.V

Report Abuse

Like (0)

Reply

Re: ALV multiply header lines using ALV Factory

Dan K. Jan 25, 2010 11:37 AM (in response to Sravanthi Veeramachaneni)


Thanks!

Report Abuse

Like (0)

Reply

Re: ALV multiply header lines using ALV Factory

Guest Jan 25, 2010 11:29 AM (in response to Dan K.)

data : dl_text(255) type c.


document->add_gap(
width

= 1
).

document->add_text(
EXPORTING
text

= 'SAP Labs Inc.'

sap_fontsize

= 'Large'

sap_color

= cl_dd_area=>list_key_int

).
CALL METHOD document->new_line.
document->add_gap(
width

= 4
).

document->add_text(
EXPORTING
text

= 'Report:

sap_fontsize

= 'Medium'

).

ZFRS6596'

CALL METHOD document->new_line.


document->add_gap(
width

= 4
).

document->add_text(
EXPORTING
text

= 'Date:'

sap_fontsize

= 'Medium'

).
CONCATENATE sy-datum+4(2) ' / ' sy-datum+6(2) ' / ' sy-datum(4)
into dl_text separated by cl_abap_char_utilities=>horizontal_tab.
call method document->add_text
exporting
text

= dl_text.

Option 2 for multipke header lines:


http://scn.sap.com/thread/1006299

Re: ALV grid with 2 labels on the output

Vijay Dudla Aug 14, 2008 2:34 PM (in response to Praneet sai)
Using the Gird Functions it is not possible, you can get the with the help of ALV list function.

If you use this aproach you will loose some Functionalities, Your Report Output will Distorted.
cehck this image..
http://img100.imageshack.us/img100/3846/output6ef.th.gif

REPORT ZTEST_ALV message-id zz .


TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

L_LAYOUT type slis_layout_alv,


x_events type slis_alv_event,
it_events type SLIS_T_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
MALE type i,
female type i,
END OF ITAB.
SELECT VBELN
POSNR
FROM VBAP
UP TO 20 ROWS
INTO TABLE ITAB.

X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'MALE'.
X_FIELDCAT-SELTEXT_L = 'MALE'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'FEMALE'.
X_FIELDCAT-SELTEXT_L = 'FEMALE'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.

APPEND X_FIELDCAT TO IT_FIELDCAT.


CLEAR X_FIELDCAT.
x_events-NAME = SLIS_EV_TOP_OF_PAGE.
x_events-FORM = 'TOP_OF_PAGE'.
APPEND x_events TO iT_EVENTS.
CLEAR x_events .
L_LAYOUT-NO_COLHEAD = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_events = it_events
TABLES
T_OUTTAB = ITAB
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 TOP_OF_PAGE.
*-To display the headers for main list
FORMAT COLOR COL_HEADING.
WRITE: / SY-ULINE(103).
WRITE: / SY-VLINE,
(8) ' ' ,
SY-VLINE,
(8) ' ' ,
SY-VLINE,
(19) '***'(015) centered,
sy-vline.
WRITE: / SY-VLINE,
(8) 'VBELN'(013) ,

SY-VLINE,
(8) 'POSNR'(014) ,
SY-VLINE,
(8) 'MALE'(016) ,
sy-vline,
(8) 'FMALE'(017) ,
sy-vline.
FORMAT COLOR OFF.
ENDFORM.

Vous aimerez peut-être aussi