Free SAP Training & Tutorial A Free SAP Functional And Technical Tutorial And Training For ABAP, SAP QUERY, ALV, SMARTFORMS, SD, PP, MM, QM, FICO
22.07.2010 | Author: | Posted in ABAP 

In today’s tutorial I want to teach you how to change the font style in your ALV list display. In this example I want to change certain columns font style into italic and bold printed.

Here’s how you do it.

1. Let’s create a new ABAP program in SE38.
2. Copy this code below:


"A sample code to change font style in ALV list
"ABAP www.freesaptutorial.com

* Include styles for ALV
INCLUDE <cl_alv_control>.

* Internla table for KNA1
DATA: t_kna1 TYPE STANDARD TABLE OF kna1.

* declate the field catalog
DATA: i_fields TYPE lvc_t_fcat.

* declare the field symbol
FIELD-SYMBOLS: <wa_fields> TYPE lvc_s_fcat.

PERFORM get_data_and_display_alv.

FORM  get_data_and_display_alv.

  " Begin selecting data from table customers
SELECT * FROM kna1 INTO TABLE t_kna1.

IF sy-subrc = 0.

* Get the field catalog
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
   EXPORTING
      i_structure_name             = 'KNA1'
    CHANGING
      ct_fieldcat                  = i_fields
   EXCEPTIONS
     inconsistent_interface       = 1
     program_error                = 2
     OTHERS                       = 3
            .
  IF sy-subrc = 0.

*   Here we will change the font style into italic and bold
    LOOP AT i_fields ASSIGNING <wa_fields>.
      IF sy-tabix > 4.
        <wa_fields>-style  =  ALV_STYLE_FONT_ITALIC.
      ELSE.
        <wa_fields>-style  =  ALV_STYLE_FONT_BOLD.
      ENDIF.
    ENDLOOP.

  ENDIF.

* Display the ALV using selected style
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_structure_name = 'KNA1'
      i_grid_title     = 'Style demo'(001)
      it_fieldcat_lvc  = i_fields
    TABLES
      t_outtab         = t_kna1
    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.

ENDIF.
ENDFORM.

Popularity: 3% [?]

 


 
 

Related Tutorial " ABAP" 

  •  
     
    Recent Tutorials
    Create Table Maintenance Display In SAP Create table display to maintain tables values using SM30
    Create Table Maintenance Generator In SAP Maintaining SAP Transparent table values using maintenance generator
    Table Relationship In SAP Learn How To Find Tables Relationships in SAP
    Convert Number To words Using ABAP Find out how to convert numbers into words Using ABAP
    How To Maintain Long Text Object in SAP Maintain long text object in SAP
    How To Know What TCODE Used In ABAP Program Find TCODE For your ABAP Program Report
    How does CRM Work? Learn how CRM system works to run your business
    Why SAP CRM is the Best Choice? The reasons why CRM application is the best choice
    Difference Between CRM System and CRM Strategy What's the difference between CRM system and its strategy
    CRM for a Better Customer Service Learn how CRM could make your customer service much better
    Costs of Implementing CRM Software Learn the how much cost you need to prepare when implementing CRM
     
    Popular Tutorials
  • (none)
  •  
    Categories
    ABAP   Basis & Configuration  
    ALV SAP BW (Business Warehouse)
    BAPI   SAP Interview Questions
    SAP Tables   SAP Overview
    Transaction Codes FI SAP Query
      MM SAP Script  
      PP SAP Tutorial FI Module
      QM   MM Module
      SD   PM Module
    SAP Functional MM   PP Module
      SD   QM Module
    White Papers     SD Module
    Uncategorized   SmartForms  
      User-Exits  
     
     

     

    Home | About | Contribute | Privacy

    Copyright 2011 freesaptutorial.com.

    Free SAP Tutorial is not associated with SAP AG in Germany or in any other country.

    SAP is a registered trade mark of SAP AG.