[ABAP] SALV IDA: SAP List Viewer with Integrated Data Access

* Beispielprogramme:
* Paket: SALV_IDA_TEST

CONSTANTS: co_table_name TYPE dbtabl VALUE 'SBOOK'.

DATA: lv_carrid TYPE sbook-carrid.

SELECT-OPTIONS: so_carr FOR lv_carrid.

START-OF-SELECTION.

  TRY.
* SALV Table IDA erzeugen
      DATA(o_salv_ida) = cl_salv_gui_table_ida=>create( iv_table_name = co_table_name ).

* Authority Check (löst evtl. Exception aus, wenn Berechtigungen fehlen)
      o_salv_ida->add_authorization_for_object( iv_authorization_object = 'S_CARRID'
                                                it_activities           = VALUE #( ( auth_field = 'ACTVT' value = '03' ) )
                                                it_field_mapping        = VALUE #( ( auth_field = 'CARRID' view_field = 'CARRID' ) ) ).

* SELECT-Konditionen festlegen
      DATA(o_cond_factory) = o_salv_ida->condition_factory( ).

* RANGE definieren: SELECT-OPTIONS
      DATA(o_ranges) = NEW cl_salv_range_tab_collector( ).
      o_ranges->add_ranges_for_name( iv_name = 'CARRID' it_ranges = so_carr[] ).
      o_ranges->get_collected_ranges( IMPORTING
                                        et_named_ranges = DATA(it_name_range_pairs) ).
* RANGE definieren: manuell
      DATA(it_fixed_ranges) = VALUE if_salv_service_types=>yt_named_ranges( ( name = 'FORCURKEY' sign = 'E' option = 'EQ' low = 'GBP' high = '' ) ).

      APPEND LINES OF it_fixed_ranges TO it_name_range_pairs.

* SELECT-Konditionen und RANGES übergeben
      o_salv_ida->set_select_options( it_ranges    = it_name_range_pairs
                                      io_condition = o_cond_factory->equals( name = 'FLDATE' value = '20120523' )->and(
                                                     o_cond_factory->covers_pattern( name = 'PASSNAME' pattern = '*Anna*')->and(
                                                     o_cond_factory->equals( name = 'FORCURKEY' value = 'EUR' )->or(
                                                     o_cond_factory->equals( name = 'FORCURKEY' value = 'USD' ) ) ) ) ).

* Spaltenüberschrift ändern
      o_salv_ida->field_catalog( )->set_field_header_texts( iv_field_name        = 'PASSNAME'
                                                            iv_header_text       = 'Name des Passagiers'
                                                            iv_tooltip_text      = 'Standard: 40 Zeichen zur Verfügung'
                                                            iv_tooltip_text_long = 'Erweiterung: 100 Zeichen zur Verfügung bei richtiger SAP GUI und SAP Basis Version' ).

* Sortierungen festlegen
      DATA(it_sort_order) = VALUE if_salv_gui_types_ida=>yt_sort_rule( ( field_name = 'PASSNAME'
                                                                         descending = abap_false
                                                                         is_grouped = abap_false ) ).

      o_salv_ida->default_layout( )->set_sort_order( it_sort_order = it_sort_order ).

* manuelle Sortierung für Spalte ausschalten
      o_salv_ida->field_catalog( )->disable_sort( iv_field_name = 'PASSNAME' ).

* Filter ausschalten
      o_salv_ida->field_catalog( )->disable_filter( iv_field_name = 'PASSNAME' ).

* nur bestimmte Spalten darstellen 1
      o_salv_ida->field_catalog( )->get_all_fields( IMPORTING ets_field_names = DATA(it_field_names) ).
      DELETE it_field_names WHERE table_line CP 'SEATS*'.

* nur bestimmte Spalten darstellen 2
*        DATA(it_field_names) = VALUE if_salv_gui_types_ida=>yts_field_name( ( CONV #( 'CARRID' ) )
*                                                                            ( CONV #( 'CONNID' ) )
*                                                                            ( CONV #( 'FLDATE' ) )
*                                                                            ( CONV #( 'FORCURKEY' ) )
*                                                                            ( CONV #( 'CUSTTYPE' ) )
*                                                                            ( CONV #( 'PASSNAME' ) ) ).

      o_salv_ida->field_catalog( )->set_available_fields( its_field_names = it_field_names ).

* passenden Beschreibungstext anhand der Domäne darstellen
      o_salv_ida->field_catalog( )->display_options( )->set_formatting( iv_field_name        = 'CUSTTYPE'
                                                                        iv_presentation_mode = if_salv_gui_types_ida=>cs_presentation_mode-description ).

* Textsuche im Gitter für Spalten 'CARRID' und 'PASSNAME' aktivieren (Button mit Lupe oben rechts)
      o_salv_ida->field_catalog( )->enable_text_search( 'CARRID' ).
      o_salv_ida->field_catalog( )->enable_text_search( 'PASSNAME' ).
      o_salv_ida->standard_functions( )->set_text_search_active( abap_true ).

* Layouts verwalten
      o_salv_ida->layout_persistence( )->set_persistence_options( is_persistence_key           = VALUE #( report_name = sy-repid )
                                                                  i_global_save_allowed        = abap_true
                                                                  i_user_specific_save_allowed = abap_true ).

      o_salv_ida->toolbar( )->enable_listbox_for_layouts( ).

* Titel
      o_salv_ida->display_options( )->set_title( 'Überschrift' ).

* Text für leere Tabelle
      o_salv_ida->display_options( )->set_empty_table_text( 'Keine Daten vorhanden.' ).

* Zebrastreifen
      o_salv_ida->display_options( )->enable_alternating_row_pattern( ).

* Datenbankfähigkeiten abfragen
      IF abap_true = cl_salv_gui_table_ida=>db_capabilities( )->is_text_search_supported( ).
* unscharfe Suche (Fuzzy) -> wird nur von HANA unterstützt
        o_salv_ida->text_search( )->set_field_similarity( '0.8' ).
        o_salv_ida->text_search( )->set_search_term( |Fehler| ).
      ENDIF.

* Wird eine Beschränkung der Anzahl der Datensätze empfohlen?
      IF cl_salv_gui_table_ida=>db_capabilities( )->is_max_rows_recommended( ).
* max. Anzahl der Datensätze beschränken
        o_salv_ida->set_maximum_number_of_rows( iv_number_of_rows = 500 ).
      ENDIF.

      o_salv_ida->fullscreen( )->display( ).

    CATCH cx_root INTO DATA(lo_exc).
      WRITE: / lo_exc->get_text( ).
  ENDTRY.

Links

[Android] Activity fullscreen darstellen

package com.example.Hello;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class MainActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setFullScreen(this);

        setContentView(R.layout.main);
    }

    protected void setFullScreen(Context ctx)
    {
        ((Activity) ctx).requestWindowFeature(Window.FEATURE_NO_TITLE);
        ((Activity) ctx).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}