Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

cl_salv_table -> 'blanc lines'

Former Member
0 Kudos

Hi together,

Is it possible to insert blanc lines in ALV output.

- I´m using cl_salv_table

- SET_ZERO (CL_SALV_COLUMN_TABLE) VALUE has to be set to 'TRUE'

Thanks for any help

6 REPLIES 6

franois_henrotte
Active Contributor
0 Kudos

just insert a blank record into your data table...

can't see what's the problem ?

it works with a call to REUSE_ALV_GRID_DISPLAY which is used by SALV class

0 Kudos

Hi,

I´m not using 'REUSE....' but class 'cl_salv_table'.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = lr_alv_table

CHANGING

t_table = it_output.

I´ve already inserted blanc lines to 'it_output'. But since 'SET_ZERO' has to be set to 'TRUE'

I get '0.00' with my empty cells.

0 Kudos

What François is saying is that class CL_SALV_TABLE is calling good old REUSE_ALV_GRID_DISPLAY under the hood.

Sorry, NO_ZERO works down the entire column, I don't think there is way to show a space instead for single rows for amount fields. I vaguely remember though that this has been asked before, please use the search box.

Thomas

0 Kudos

If the "0,00" cell is a quantity/currency amount field, you can "play" with the unit/currency code to display or not the zeroes - Read [Value Display with Currency/Quantity Unit|http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649b1f17411d2b486006094192fe3/content.htm]

- amount initial + currency initial -> space

- amount initial + currency not initial -> zeroes displayed like 0 or 0.00 (depending on currency definition)

Regards,

Raymond

0 Kudos

Hi Raymond,

Could you please give me an example / more details on this.

You not use any fieldcat together with cl_salv_table. There is only table 'it_output' (see below).

Thanks in advance

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = lr_alv_table

CHANGING

t_table = it_output.

0 Kudos

Hello Gerd,

As mentioned by Thomas, SALV technique calls the FM 'REUSE_ALV_GRID_DISPLAY' under the hood. The developer does not pass the fieldcatalog explicitly, but maintains it via the CL_SALV_COLUMN* classes

The fieldcatalog is populated, again "under the hood", depending on the values passed by the user in these classes.

Check this demo code, you can see that the Price against GBP is "0.00", but for the empty line is blank.


REPORT zsalv_demo_table_simple NO STANDARD PAGE HEADING.

DATA: gs_test TYPE g_type_s_test.

DATA: gt_outtab TYPE STANDARD TABLE OF alv_t_t2.

DATA: gr_table   TYPE REF TO cl_salv_table.
*----------------------------------------------------------------------*
* SELECTION-SCREEN - for demonstration purposes only                   *
*----------------------------------------------------------------------*
PARAMETERS: p_amount TYPE i DEFAULT 30.
*----------------------------------------------------------------------*
* START-OF-SELECTION                                                   *
*----------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM select_data.

*----------------------------------------------------------------------*
* END-OF-SELECTION                                                     *
*----------------------------------------------------------------------*
END-OF-SELECTION.

  PERFORM display_fullscreen.

*&---------------------------------------------------------------------*
*&      Form  select_data
*&---------------------------------------------------------------------*
* §1 to display the data, you first have to select it in some table
*----------------------------------------------------------------------*
FORM select_data.

  DATA: ls_outtab LIKE LINE OF gt_outtab.

  SELECT * FROM alv_t_t2 INTO CORRESPONDING FIELDS OF TABLE gt_outtab
        UP TO p_amount ROWS.                          "#EC *

  INSERT INITIAL LINE INTO gt_outtab INDEX 7. "Add an initial line

* Empty the price where currency is 'GBP'
  MODIFY gt_outtab FROM ls_outtab TRANSPORTING price
    WHERE currency = 'GBP'. "This is to show the behaviour of CURRENCY
ENDFORM.                    " select_data

*&---------------------------------------------------------------------*
*&      Form  display_fullscreen
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM display_fullscreen .

*... §2 create an ALV table
*    §2.2 just create an instance and do not set LIST_DISPLAY for
*         displaying the data as a Fullscreen Grid
  TRY.
      cl_salv_table=>factory(
        IMPORTING
          r_salv_table = gr_table
        CHANGING
          t_table      = gt_outtab ).
    CATCH cx_salv_msg.                                  "#EC NO_HANDLER
  ENDTRY.

*... §3 Functions
*... §3.1 activate ALV generic Functions
  DATA: lr_functions TYPE REF TO cl_salv_functions_list.

  lr_functions = gr_table->get_functions( ).
  lr_functions->set_default( abap_true ).

*... set the columns technical
  DATA: lr_columns TYPE REF TO cl_salv_columns.

  lr_columns = gr_table->get_columns( ).
  lr_columns->set_optimize( abap_true ).

  PERFORM set_columns_properties USING lr_columns.

*... §4 display the table
  gr_table->display( ).

ENDFORM.                    " display_fullscreen
*&---------------------------------------------------------------------*
*&      Form  set_columns_technical
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM set_columns_properties USING ir_columns TYPE REF TO cl_salv_columns.

  DATA: lr_column TYPE REF TO cl_salv_column.

* Set the currency column
  TRY.
      lr_column = ir_columns->get_column( 'PRICE' ).
      lr_column->set_currency_column( 'CURRENCY' ).
      lr_column->set_zero( if_salv_c_bool_sap=>true ).
    CATCH cx_salv_not_found.                            "#EC NO_HANDLER
    CATCH cx_salv_data_error.                           "#EC NO_HANDLER

  ENDTRY.

ENDFORM.

BR,

Suhas

PS: I'll suggest you debug the SALV Model in your spare time. Some very smart OO-technique is applied there!

Edited by: Suhas Saha on Nov 25, 2011 12:47 PM