ABAP Naming Conventions

Call a Spade a Spade

Naming conventions must be concise, short and distinct. Any ambiguity is a burden for maintenance in the future. Using three categories of criteria it is possible to unambigously name virtually all variables and most signature parameters:

  1. Visibility: Global / Local / Class Context
  2. Type: Field / Structure / Table Type / Reference / Constants
  3. Structural Context: FORM routines / Function Modules / Methods

There are two general naming conventions:

  • Variables and Class Attributes: <Visibility>_<Type>_<Description>
  • Signature Parameters: <Structural Context>_<Type>_<Description>

Visibility & Type

We have three kinds of visibility: Global, Local and Class Context (which includes Interfaces as well) and seven different types (see below).

 

Visibility Prefix Type Prefix Example Coding
Global G Field D GD_MATNR DATA: gd_matnr TYPE matnr.
    Structure S GS_KNB1 DATA: gs_knb1 TYPE knb1.
    Table Type T GT_VBAK DATA: gt_vbak TYPE TABLE OF vbak.
    Class

Interface

O GO_GRID

GO_MSGLIST

DATA: go_grid TYPE REF TO cl_gui_alv_grid.

DATA: go_msglist TYPE REF TO if_reca_message_list.

    Data Object DO GDO_DATA DATA: gdo_data TYPE REF TO data.
    Constant C GC_LIGHTSPEED CONSTANTS: gc_lightspeed TYPE i VALUE ’300000′.
Local L Field D LD_MATNR DATA: ld_matnr TYPE matnr.
    Structure S LS_KNB1 DATA: ls_knb1 TYPE knb1.
    Table Type T LT_VBAK DATA: lt_vbak TYPE TABLE OF vbak.
    Class

Interface

O LO_GRID

LO_MSGLIST

DATA: lo_grid TYPE REF TO cl_gui_alv_grid.

DATA: lo_msglist TYPE REF TO if_reca_message_list.

    Data Object DO LDO_DATA DATA: ldo_data TYPE REF TO data.
    Constant C LC_LIGHTSPEED CONSTANTS: lc_lightspeed TYPE i VALUE ’300000′.
Class Context M Field D MD_MATNR DATA: md_matnr TYPE matnr.
    Structure S MS_KNB1 DATA: ms_knb1 TYPE knb1.
    Table Type T MT_VBAK DATA: mt_vbak TYPE TABLE OF vbak.
    Class

Interface

O MO_GRID

MO_MSGLIST

DATA: mo_grid TYPE REF TO cl_gui_alv_grid.

DATA: mo_msglist TYPE REF TO if_reca_message_list.

    Data Object DO MDO_DATA DATA: mdo_data TYPE REF TO data.
    Constant C MC_LIGHTSPEED CONSTANTS: mc_lightspeed TYPE i VALUE ’300000′.

 

The vast majority of variables within program objects are either global or local. And in the future there will be a remarkably shift towards class attributes (ABAP-OO). Thus, assigning a unique prefix to each group makes their visibility unambigous for every developer.

Class attributes (instance and static) are special because they are global within the class/instance whereas they appear local from outside the class/instance. Without referring to a class(name) or instance these attributes are “hidden” (i.e. local).

Question: Does the type prefix offer any benefit?

In ABAP forum posts you may find the following definitions for ALV grid instances:

  • GRID: global (?), local (?), class context (?); class reference (?)
  • G_ALV_GRID: global (!?), local (?), class context (?); class reference (!?)
  • GO_GRID: global class reference OUTSIDE any class context (my naming convention)

Answer: Yes, because we meet the developer’s expectation and anticipation.

You may argue: What a big fuss about such a little subtlety. My answer to this is: Every SAP developer who comes across a GO_GRID variable in any of my programs knows in advance(!) the meaning and scope of it.

Structural Context (1): FORM routine Signature

The SAP system does not care about which kind of formal parameters (USING or CHANGING) are used in FORM routine signatures. Both kinds of formal parameters can be changed within the routine and the modified contents transferred back to the calling program. This is ambiguity at its worst.

In order to make the signature of a FORM routine clear as crystal we define every Input = USING parameter and everyOutput = CHANGING parameter. Within the FORM routine all USING parameters should be regarded as “constants” meaning that they are not changed nor is any change transferred back to the calling program.

 

Parameter Prefix Type Prefix Example
USING U Field D UD_MATNR
Structure S US_KNB1
Table Type T UT_VBAK
ClassInterface O UO_GRIDUO_MSGLIST
Data Object DO UDO_DATA
CHANGING C Field D CD_MATNR
Structure S CS_KNB1
Table Type T CT_VBAK
ClassInterface O CO_GRIDCO_MSGLIST
Data Object DO CDO_DATA

 

Again, by defining Input = USING (prefix ‘U’) and Output = CHANGING (prefix ‘C’) we meet the developer’s expectation and alleviate understanding of the FORM routine.

Structural Context (2): Function Module Signature

The same logic applies to function modules parameters. In addition, we can facilitate the understanding of TABLESparameters (Yes, I know they are obsolete yet some still like to use ‘em) by the semantics of their Input/Output behaviour:

  • IT_ITAB = Input only
  • ET_ITAB = Output only
  • XT_ITAB = Input & Output

 

Parameter Prefix Type Prefix Example
IMPORTING I Field D ID_MATNR
Structure S IS_KNB1
Table Type T IT_VBAK
ClassInterface O IO_GRIDIO_MSGLIST
Data Object DO IDO_DATA
EXPORTING E Field D ED_MATNR
Structure S ES_KNB1
Table Type T ET_VBAK
ClassInterface O EO_GRIDEO_MSGLIST
Data Object DO EDO_DATA
CHANGING C Field D CD_MATNR
Structure S CS_KNB1
Table Type T CT_VBAK
ClassInterface O CO_GRIDCO_MSGLIST
Data Object DO CDO_DATA
TABLES “Importing” IT IT_VBAK
“Exporting” ET ET_VBAK
“Changing” XT XT_VBAK

 

Of course there is no technical difference whatsoever between “Importing”, “Exporting” and “Changing” TABLES parameters. Yet the different naming gives the developer already an idea about the function of this module without looking into the coding. Or in other words: Try to “express” the function of the module already in its signature.

 

 

 

Structural Context (3a): Method Signature

 

The logic explained above is just applied to method parameters as well and extended to the additional RETURNING parameters of methods.

Parameter Prefix Type Prefix Example
IMPORTING I Field D ID_MATNR
Structure S IS_KNB1
Table Type T IT_VBAK
ClassInterface O IO_GRIDIO_MSGLIST
Data Object DO IDO_DATA
EXPORTING E Field D ED_MATNR
Structure S ES_KNB1
Table Type T ET_VBAK
ClassInterface O EO_GRIDEO_MSGLIST
Data Object DO EDO_DATA
CHANGING C Field D CD_MATNR
Structure S CS_KNB1
Table Type T CT_VBAK
ClassInterface O CO_GRIDCO_MSGLIST
Data Object DO CDO_DATA
RETURNING R Field D RD_MATNR
Structure S RS_KNB1
Table Type T RT_VBAK
ClassInterface O RO_GRIDRO_MSGLIST
Data Object DO RDO_DATA

 

 

Structural Context (3b): Static vs. Instance Attributes

Static attributes are special because they exist only once for all instances of this class. Modifying a static attribute within a given instance makes this change visible to all other instances. Both types of attributes have the prefix ‘M’ (class context) in my naming convention. In order to distinguish between static and instance attributes I apply the following convention:

  • Instance Attribute: with self-reference me-> (e.g. me->md_key)
  • Static Attribute: without self-reference (.e.g. ms_row)

You can find an example of this naming convention in the coding of INCLUDE ZRSWBOSDR_C01 in my blog Multi-Purpose ALV Programming.

Another unambigous convention is to drop the self-reference prefix and use the full qualified name for static attributes:

  • Instance Attribute: md_key (with or with self-reference prefix)
  • Static Attribute: lcl_eventhandler=>ms_row

Field-Symbols

We can apply the same naming conventions even to field-symbols which makes them much more readable and understandable for every developer. This is particularly important because the contents of field-symbols cannot be analyzed statically but is only determined at runtime.

Visibility Prefix Type Prefix Example
Global G Field D <GD_MATNR>
Structure S <GS_KNB1>
Table Type T <GT_VBAK>
ClassInterface O <GO_GRID><GO_MSGLIST>
Data Object DO <GDO_DATA>
Local L Field D <LD_MATNR>
Structure S <LS_KNB1>
Table Type T <LT_VBAK>
ClassInterface O <LO_GRID><LO_MSGLIST>
Data Object DO <LDO_DATA>

SAP and Lego

Why has Lego become one of the world’s most famous toys? Part of the answer can be found here:

“Lego pieces of all varieties are a part of a universal system. \ Despite variation in the design and purpose of individual pieces over \ the years, each remains compatible in some way with existing pieces. \ Lego bricks from 1958 still interlock with those made in 2009, and Lego \ sets for young children are compatible with those made for teenagers.

\ Bricks, beams, axles, mini figures, and all other parts in the Lego \ system are manufactured to an exacting degree of precision. When \ snapped together, pieces must have just the right amount of strength \ and flexibility mixed together to stick together. They must stay \ together until pulled apart. They cannot be too easy to pull apart, or \ the resulting constructions would be unstable; they also cannot be too \ difficult to pull apart, since the disassembly of one creation in order \ to build another is part of the Lego appeal. In order for pieces to \ have just the right “clutch power”, Lego elements are manufactured \ within a tolerance of 2 µm.”

QUESTION: ”Have you ever seen a child which sits in front of a pile of Lego bricks claiming it can’t build anything because all bricks have the same size???”

For me SAP is just an incredibly huge pile of Lego bricks (for grown-ups). Consistent naming conventions are an indispensable standard which enables us to manufacture long-lasting developments that are easy to understand and maintain (pull apart and reassemble).

 

source:  <http://scn.sap.com/people/uwe.schieferstein/blog/2009/08/31/nomen-est-omen–abap-naming-conventions>

IT Differentiate

Note: Speed, Simplicity(KISS), Specificity

almost 75 %  of CFOs view IT as a source of Competitive Differentiation 

Top 3 ways IT create Differentiation

1. Improving Operational

2. Support Innovative

3. Improve Customer Retention / Releationships

Top 3 ways IT Fails To Differentiate

1. Implementations take too long

2. Return of Investment is better elsewhere in the business

3. Technology is a ” Commodity ” in our Company

 

Aspar sap plugin.

3-2-2013 5-07-58 PM   3-25-2013 2-45-36 PM

My first Application using MVC framework of Marcelo Araujo Ramos. Honestly i copy this framework from scratch in order for me to learn the techniques and UML pattern on it and it takes 3 week for me to understand all variable and function he’s used. even thought  I’m very busy with functional support at the office but i  really give some time on it by printing all abap OO manuals then i read it on my boarding house once i understand the whole concept i automatically apply it at the office.. hopefully i can make may own dream framework and make a history on it.

Status: On Development

REPORT  ZAP_AS_PAR NO STANDARD PAGE HEADING.

INCLUDE ZAP_AS_PAR_TOP.    ” Global Data ni

INCLUDE zap_as_par_view.   ” PA View Me
INCLUDE zap_as_par_model.  ” Model Cristine Reyes
INCLUDE zap_as_par_cntrl.  ” Controller

INCLUDE zap_as_par_PBO.    ” PBO-Modules
INCLUDE zap_as_par_PAI.    ” PAI-Modules

 

Production Order pending status Report

3-2-2013 4-54-24 PM3-2-2013 4-55-11 PM

This is my first abap OO  alv report using  Robin Vleeschhouwer Framework.  link


report  zagri503.

tables: caufv,afpo,afru,makt.

selection-screen begin of block nanat with frame title text-003.
select-options s_bukrs for caufv-bukrs obligatory no-extension.
select-options s_aufnr for afru-aufnr.
select-options s_matnr for afpo-matnr  NO-DISPLAY.
select-options s_auart for caufv-auart NO-DISPLAY.
select-options s_werks for caufv-werks obligatory.
select-options s_gstrp for caufv-gstrp obligatory.
selection-screen end of block nanat.

selection-screen begin of block bl1 with frame title text-001.
parameter : p_agri radiobutton group gr1,
p_pp   radiobutton group gr1.
selection-screen end of block bl1.

DATA: obj_line like BSVX-STTXT.
*----------------------------------------------------------------------*
* CLASS lcl_alv_om DEFINITION
*----------------------------------------------------------------------*
class lcl_alv_om definition inheriting from zcl_alv_om.
public section.
types: begin of tdata,
werks type caufv-werks, " Plant
aufnr type caufv-aufnr, " Production  ORder
gamng type caufv-gamng, " base quantity
wemng type afpo-wemng,  " delivery quantity
objnr type caufv-objnr, " STATUS NUMBER
auart type caufv-auart, " ORDER TYPE
matnr type afpo-matnr,  " material
maktx type makt-maktx,  " material Description
stats type BSVX-STTXT,  " Status
end of tdata.

DATA: tt_data  TYPE TABLE OF tdata,
dt_data  TYPE TABLE OF tdata.

methods set_rdata_pp.

protected section.
methods set_header      redefinition.
methods set_column      redefinition.
methods on_double_click redefinition.

PRIVATE SECTION.
METHODS fix_data.

endclass.                    "lcl_alv_om DEFINITION

*----------------------------------------------------------------------*
* CLASS lcl_alv_om IMPLEMENTATION
*----------------------------------------------------------------------*
class lcl_alv_om implementation.
"Set header
method set_header.
Data: l_count TYPE i,
lr_picture type ref to cl_salv_form_picture.

DESCRIBE TABLE dt_data LINES l_count.

*   create object lr_picture
*    exporting
*      picture_id   = 'SUMILOGO'.

*    call method io_header->set_element
*      exporting
*        row       = 1
*        column    = 5
*        r_element = lr_picture.

io_header->create_label( exporting row     = 6
column  = 1
text    = 'Pending Order :' ).

io_header->create_text( exporting  row     = 6
column  = 2
text    = l_count ).

endmethod.                    "set_header

"Set column
method set_column.
data: gr_functions type ref to cl_salv_functions.

if  iv_column_name <> 'WERKS'
and iv_column_name <> 'AUFNR'
and iv_column_name <> 'GAMNG'
and iv_column_name <> 'WEMNG'
and iv_column_name <> 'AUART'
and iv_column_name <> 'MATNR'
and iv_column_name <> 'MAKTX'
and iv_column_name <> 'STATS'.
io_column->set_visible( value = abap_false ).
*      lo_column->set_technical( abap_true ).
endif.

endmethod.                    "set_column

method set_rdata_pp.
DATA: obj_line  type bsvx-sttxt,
d_auart   type C.

" Get coois data to insert in ALV
select t0~werks t0~aufnr t0~gamng t1~wemng t0~objnr t0~auart t1~matnr t3~maktx
from caufv as t0
inner join afpo as t1 on t0~aufnr = t1~aufnr
inner join makt as t3 on t1~matnr = t3~matnr
into table me->tt_data
where
t0~bukrs  in s_bukrs   and "company
t0~aufnr  in s_aufnr   and "order number
t1~matnr  in s_matnr   and "material
t0~werks  in s_werks   and "werks
t0~auart  in s_auart   and "order type
t0~gstrp  in s_gstrp.

me->deletedup( EXPORTING fname  = 'AUFNR' changing RTABLE = me->tt_data ).
me->fix_data( ).

endmethod.                    "set_rdata

METHOD fix_data.
FIELD-SYMBOLS: <f_wa> TYPE tdata,
<f_w>  TYPE tdata,
<f_it> TYPE ANY.

CLEAR: makt.

LOOP AT me->tt_data ASSIGNING <f_w>.

CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
OBJNR            = <f_w>-OBJNR
SPRAS            = SY-LANGU
IMPORTING
LINE             = obj_line
EXCEPTIONS
OBJECT_NOT_FOUND = 1
OTHERS           = 2.

IF obj_line CS 'TECO' AND <f_w>-wemng EQ '0.000'.

ELSE.
<f_w>-stats = obj_line.
ASSIGN COMPONENT sy-index OF STRUCTURE <f_w> TO <f_it>.

APPEND <f_it> TO dt_data.
ENDIF.
ENDLOOP.

ENDMETHOD.
"On double click
method on_double_click.

IF IV_COLUMN EQ 'AUFNR'.
*     IS_ROW_DATA.
*     Set parameter ID for transaction screen field
SET PARAMETER ID 'ANR' FIELD IV_FIELD_DATA.
*     Sxecute transaction CO03, and skip initial data entry screen
CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.
ENDIF.
endmethod.                    "on_double_click
endclass.                    "lcl_alv_om IMPLEMENTATION

start-of-selection.

data: lo_alv    type ref to lcl_alv_om.

"Create and display ALV
create object lo_alv
exporting
iv_double_click = abap_true.

IF p_agri eq 'X'.
s_matnr-sign   = 'I'.
s_matnr-option = 'CP'.
s_matnr-low    = '*T*'.
append s_matnr.

s_auart-sign = 'I'.
s_auart-option = 'EQ'.
s_auart-low = 'ZG14'. append s_auart.
s_auart-low = 'ZG15'. append s_auart.
s_auart-low = 'ZG16'. append s_auart.
s_auart-low = 'ZG17'. append s_auart.
s_auart-low = 'ZG00'. append s_auart.
s_auart-low = 'ZP00'. append s_auart.
clear: s_auart, s_matnr.
else.
s_auart-sign = 'I'.
s_auart-option = 'EQ'.
s_auart-low = 'YP01'. append s_auart.
s_auart-low = 'YP03'. append s_auart.
s_auart-low = 'YP04'. append s_auart.
clear s_auart.
ENDIF.

lo_alv->set_rdata_pp( ).
lo_alv->set_data( changing ct_data = lo_alv->dt_data ).
lo_alv->display( ).

 

inventory posting

*&———————————————————————*
*& Report  ZMMR505
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT  ZMMR505.

TABLES: MARA,  ”General Material Data
T023T, ”Material Group Descriptions
MSEG,  ”Document Segment: Material
MBEW,  ”Material Valuation
skat,  ”G/L Account Master Record
T025T, ”Valuation Class Descriptions
T030.  ”Standard Accounts Table

TYPE-POOLS: slis.

selection-screen begin of block nanat with frame title text-003.
*parameters S_BUKRS TYPE MSEG-BUKRS OBLIGATORY. ” company
parameters S_LFGJA TYPE MBEW-LFGJA OBLIGATORY.  ” year
parameters S_LFMON TYPE MBEW-LFMON OBLIGATORY.  ” Period
selection-screen end of block nanat.
*&———————————————————————*
*& Scope of list
*&———————————————————————*

selection-screen begin of block ika_duha with frame title text-004.
PARAMETERS:  S_GLACC  AS CHECKBOX .              ” Per Account
selection-screen end of block ika_duha.

*&———————————————————————*
*& Per Material Group
*&———————————————————————*
“Primary Internal TABLE
TYPES: BEGIN OF tdata,
MATNR TYPE MBEW-MATNR,     ” MATRIAL id
LBKUM TYPE MSEG-LBKUM,     ” Quantity / Total Stock
VERPR TYPE MBEW-VERPR,     ” Moving Average Price/Periodic Unit Price
SALK3 TYPE MBEW-SALK3,     ” Total Value
LFGJA TYPE MBEW-LFGJA,     ” Year
LFMON TYPE MBEW-LFMON,     ” Period
END OF tdata.
“Secondary Internal Table
TYPES: BEGIN OF rdata,
MATNR TYPE MARA-MATNR,     ” MATRIAL id
MAKTX TYPE MAKT-MAKTX,     ” MATERIAL DESCRIPTION
MATKL TYPE MARA-MATKL,     ” MATERIAL GROUP OR CLASS
MEINS TYPE MARA-MEINS,     ” Units of Measurement of Various Types
WGBEZ TYPE T023T-WGBEZ,    ” Material Group Description
END OF rdata.

TYPES: BEGIN OF t_final,
MATKL TYPE MARA-MATKL,     ” MATERIAL GROUP OR CLASS ID
MATK1 TYPE MARA-MATKL,     ” ika-duha MATERIAL GROUP
WGBEZ TYPE T023T-WGBEZ,    ” Material Group Description
WGBE1 TYPE T023T-WGBEZ,    ” ika-duha Description
MATNR TYPE MBEW-MATNR,     ” MATERIAL id
MAKTX TYPE MAKT-MAKTX,     ” MATERIAL DESCRIPTION
MEINS TYPE MARA-MEINS,     ” Units of Measurement of Various Types
LFGJA TYPE MBEW-LFGJA,     ” Year
LFMON TYPE MBEW-LFMON,     ” Period
LBKUM TYPE MBEW-LBKUM,     ” Quantity
VERPR TYPE MBEW-VERPR,     ” Moving Average Price/Periodic Unit Price
SALK3 TYPE MBEW-SALK3,     ” Total Value
END OF t_final.

“get selection value
DATA: it_data  TYPE STANDARD TABLE OF tdata,
wa_data  TYPE tdata,
ir_data  TYPE STANDARD TABLE OF rdata,
wr_data  TYPE rdata,
it_final TYPE STANDARD TABLE OF t_final WITH HEADER LINE,
wa_final TYPE t_final.

“sorting og sum para bibo.
data: hs_sum TYPE HASHED TABLE OF t_final
WITH UNIQUE key MATNR MAKTX MATKL MATK1 WGBEZ WGBE1 MEINS LFGJA LFMON WITH HEADER LINE.

DATA : itab_sum TYPE STANDARD TABLE OF t_final WITH HEADER LINE .
*&———————————————————————*
*& Per material Group End
*&———————————————————————*

*&———————————————————————*
*& Per GL Account
*&———————————————————————*
TYPES: BEGIN OF GTAB,
BKLAS TYPE MBEW-BKLAS,    ” Valuation Class
MATNR TYPE MBEW-MATNR,    ” MATERIAL id
MAKTX TYPE MAKT-MAKTX,    ” MATERIAL DESCRIPTION
MEINS TYPE MARA-MEINS,    ” Units of Measurement of Various Types
LFGJA TYPE MBEW-LFGJA,    ” Year
LFMON TYPE MBEW-LFMON,    ” Period
LBKUM TYPE MBEW-LBKUM,    ” Quantity
VERPR TYPE MBEW-VERPR,    ” Moving Average Price/Periodic Unit Price
SALK3 TYPE MBEW-SALK3,    ” Total Value
END OF GTAB.

TYPES: BEGIN OF G_final,
SAKNR TYPE SKAT-SAKNR,    ” G/L Account
TXT20 TYPE SKAT-TXT20,    ” Short Text
MATNR TYPE MBEW-MATNR,    ” MATERIAL id
MAKTX TYPE MAKT-MAKTX,    ” Material Group Description
MEINS TYPE MARA-MEINS,    ” Units of Measurement of Various Types
LFGJA TYPE MBEW-LFGJA,    ” Year cur.period
LFMON TYPE MBEW-LFMON,    ” Current period (posting period)
LBKUM TYPE MBEW-LBKUM,    ” Total Stock
VERPR TYPE MBEW-VERPR,    ” Moving price
SALK3 TYPE MBEW-SALK3,    ” Total Value
END OF G_final.

DATA: it_gtab TYPE STANDARD TABLE OF GTAB,
wa_gtab TYPE GTAB,
ig_fina TYPE STANDARD TABLE OF G_final WITH HEADER LINE,
wa_ftab TYPE G_final.

DATA: Gs_sum TYPE HASHED TABLE OF G_final
WITH UNIQUE key SAKNR TXT20 MATNR MAKTX MEINS LFGJA LFMON WITH HEADER LINE.

DATA : G_sum TYPE STANDARD TABLE OF G_final WITH HEADER LINE.

*&———————————————————————*
*& Per GL Account end
*&———————————————————————*

DATA: i_events    TYPE slis_t_event,        ”Internal table for ALV Display events
totalIn     TYPE MBEW-VERPR.

DATA: sla         TYPE slis_layout_alv,
i_alv_top_of_page TYPE slis_t_listheader, ”Internal table for Top of Page info. in ALV Display
ivariant    LIKE disvariant,
i_repid     LIKE sy-repid,
i_excluding TYPE slis_t_extab.

DATA:  ls_fieldcat TYPE slis_fieldcat_alv,
gd_fieldcat TYPE slis_t_fieldcat_alv, ”Internal table for storing field catalog information
i_sort      TYPE slis_t_sortinfo_alv, ”Internal table for storing ALV sort information
wa_sort     TYPE slis_sortinfo_alv.
*&———————————————————————*
*& Constant declaration
*&———————————————————————*
CONSTANTS:
c_header   TYPE char1
VALUE ’H',                    ”Header in ALV
c_item     TYPE char1
VALUE ’S’.

************************************************************************
*Start-of-selection.

START-OF-SELECTION.

IF S_GLACC = ’X’.
PERFORM getPerGl.
ELSE.
PERFORM get_data.
ENDIF.

PERFORM fixData.
PERFORM build_header.

IF S_GLACC = ’X’.
PERFORM fieldcatikaduha.
ELSE.
PERFORM fieldcat_init.
ENDIF.

PERFORM sub_populate_layout.

END-OF-SELECTION.

*&———————————————————————*
*&      Form  get_data
*&———————————————————————*
* parameters S_LFGJA TYPE MBEW-LFGJA OBLIGATORY.  ” year
* parameters S_LFMON TYPE MBEW-LFMON OBLIGATORY.   ” Period      text
*———————————————————————-*
FORM get_data.

SELECT MATNR sum( LBKUM ) as LBKUM sum( VERPR ) as VERPR sum( SALK3 ) as SALK3 LFGJA LFMON
FROM MBEW
INTO TABLE it_data
WHERE  LBKUM <> 0 and salk3 <> 0
AND  LFGJA <= S_LFGJA
AND  LFMON <= S_LFMON

GROUP BY MATNR LFGJA LFMON.

IF it_data IS NOT INITIAL.

SORT it_data BY MATNR.

SELECT T1~MATNR T2~MAKTX T1~MATKL T1~MEINS T0~WGBEZ
FROM MARA AS T1
INNER JOIN T023T AS T0 ON T1~MATKL = T0~MATKL
INNER JOIN MAKT as t2 ON t2~MATNR = T1~MATNR
INTO TABLE ir_data FOR ALL ENTRIES IN it_data
WHERE T1~MATNR EQ it_data-MATNR.
ENDIF.

LOOP AT ir_data INTO wr_data.
READ TABLE it_data INTO wa_data with KEY MATNR = wr_data-MATNR BINARY SEARCH.

IF SY-SUBRC = 0.
SHIFT wa_data-MATNR LEFT DELETING LEADING ’0′. ”deleting 0 naa daghan
wa_final-MATKL = wr_data-MATKL.
wa_final-MATK1 = wr_data-MATKL.
wa_final-WGBEZ = wr_data-WGBEZ.
wa_final-WGBE1 = wr_data-WGBEZ.
wa_final-MATNR = wa_data-MATNR.
wa_final-MAKTX = wr_data-MAKTX.
wa_final-MEINS = wr_data-MEINS.
wa_final-LFGJA = wa_data-LFGJA.
wa_final-LFMON = wa_data-LFMON.
wa_final-LBKUM = wa_data-LBKUM.
wa_final-VERPR = wa_data-VERPR.
wa_final-SALK3 = wa_data-SALK3.

totalIn = wa_data-SALK3 / wa_data-LBKUM.

wa_final-VERPR = totalIn.

APPEND wa_final TO it_final.

CLEAR : wa_final.

ELSE.
MESSAGE ’Record not Found’ TYPE ’E’.

ENDIF.

CLEAR: wa_data, wr_data.

ENDLOOP.

ENDFORM.                    ”get_data

FORM getPerGl.

SELECT T0~BKLAS
T0~MATNR
T1~MAKTX
T2~MEINS
T0~LFGJA
T0~LFMON
sum( T0~LBKUM ) as LBKUM
sum( T0~VERPR ) as VERPR
sum( T0~SALK3 ) as SALK3
INTO CORRESPONDING FIELDS OF TABLE it_gtab
FROM MBEW AS T0
INNER JOIN MAKT AS T1 ON T0~MATNR = T1~MATNR
INNER JOIN MARA AS T2 ON T0~MATNR = T2~MATNR
WHERE  T0~LBKUM <> 0 and T0~salk3 <> 0
AND  T0~LFGJA <= S_LFGJA
AND  T0~LFMON <= S_LFMON
GROUP BY T0~BKLAS T0~MATNR T1~MAKTX T2~MEINS T0~LFGJA T0~LFMON.

IF it_gtab IS NOT INITIAL.
SORT it_gtab BY MATNR LFMON.
LOOP AT it_gtab INTO wa_GTAB.
CLEAR: T030, SKAT.
SELECT SINGLE * FROM T030 WHERE BKLAS = wa_GTAB-BKLAS.
SELECT SINGLE * FROM SKAT WHERE SAKNR = T030-KONTS AND SPRAS = ’EN’.

SHIFT wa_GTAB-MATNR LEFT DELETING LEADING ’0′. ”deleting 0 naa daghan
SHIFT SKAT-SAKNR LEFT DELETING LEADING ’0′. ”deleting 0 naa daghan
wa_ftab-SAKNR = SKAT-SAKNR.
wa_ftab-TXT20 = SKAT-TXT20.
wa_ftab-MATNR = wa_GTAB-MATNR.
wa_ftab-MAKTX = wa_GTAB-MAKTX.
wa_ftab-MEINS = wa_GTAB-MEINS.
wa_ftab-LFGJA = wa_GTAB-LFGJA.
wa_ftab-LFMON = wa_GTAB-LFMON.
wa_ftab-LBKUM = wa_GTAB-LBKUM.
wa_ftab-VERPR = wa_GTAB-VERPR.
wa_ftab-SALK3 = wa_GTAB-SALK3.

totalIn = wa_GTAB-SALK3 / wa_GTAB-LBKUM.

wa_ftab-VERPR = totalIn.

APPEND wa_ftab TO ig_fina.
ENDLOOP.
ENDIF.

ENDFORM.

“E han-ay ang data

*&———————————————————————*
*&      Form  build_header
*&———————————————————————*
*       text
*———————————————————————-*
FORM build_header.

*local data declaration
DATA: l_system     TYPE char10,           ”System id
l_line       TYPE slis_listheader,  ”Hold list Header
l_date       TYPE char10,           ”date
l_time       TYPE char10,           ”time
l_sus_re     TYPE i,
t_line       like l_line-info,
l_title(300) TYPE c,
ld_linesc(10) type c.

l_line-typ  = c_header.
CONCATENATE ’Inventory List Fy’ S_LFGJA ’-' S_LFMON INTO l_title SEPARATED BY space.
l_line-info = l_title.
APPEND l_line to i_alv_top_of_page.
CLEAR l_line.

l_line-typ = c_item.
WRITE: sy-datum  TO l_date MM/DD/YYYY.
l_line-key  = ’Todays Date :’(002).
l_line-info = l_date.
APPEND l_line TO i_alv_top_of_page.
CLEAR: l_line, l_date.

IF S_GLACC = ’X’.
describe table ig_fina lines l_sus_re.
ld_linesc = l_sus_re.
concatenate ’Total No. of Records Selected: ’ ld_linesc
into t_line separated by space.
l_line-typ  = ’A’.
l_line-info = t_line.
append l_line to i_alv_top_of_page.
clear: l_line, t_line.
else.

describe table it_final lines l_sus_re.
ld_linesc = l_sus_re.
concatenate ’Total No. of Records Selected: ’ ld_linesc
into t_line separated by space.
l_line-typ  = ’A’.
l_line-info = t_line.
append l_line to i_alv_top_of_page.
clear: l_line, t_line.

ENDIF.
ENDFORM.                    ”build_header

*&———————————————————————*
*&      Form  fixData
*&———————————————————————*
*       text
*———————————————————————-*
FORM fixData.
DATA: index LIKE sy-tabix.

IF S_GLACC = ’X’.
LOOP AT ig_fina.
Gs_sum = ig_fina.

COLLECT Gs_sum.

ENDLOOP.

SORT Gs_sum .

G_sum[] = Gs_sum[].

ELSE.

LOOP AT it_final.
hs_sum = it_final.

COLLECT hs_sum.

ENDLOOP.

SORT hs_sum.

itab_sum[] = hs_sum[].
ENDIF.

ENDFORM.

*&———————————————————————*
*&      Form  fieldcat_init
*&———————————————————————*
*       text
*———————————————————————-*

FORM fieldcat_init.

Define m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-row_pos      = ’1′.
ls_fieldcat-fieldname    = &1.
ls_fieldcat-tabname      = ’itab_sum’.
ls_fieldcat-seltext_l    = &2.
ls_fieldcat-key          = &3.
ls_fieldcat-do_sum       = &4.

APPEND ls_fieldcat TO gd_fieldcat.
END-OF-DEFINITION.

DEFINE m_sort.
add 1 TO wa_sort-spos.
wa_sort-fieldname = &1.
wa_sort-up        = ’X’.
wa_sort-subtot    = &2.
wa_sort-expa      = &3.
APPEND wa_sort TO i_sort.
END-OF-DEFINITION.

m_fieldcat ’MATKL’ ’Item Group ID’ ’X' ”.
m_fieldcat ’WGBEZ’ ’Item Group Description’ ’X' ”.
m_fieldcat ’MATNR’ ’MATERIAL#’ ’X' ”.
m_fieldcat ’MAKTX’ ’MAT Description’ ’X' ”.
m_fieldcat ’MEINS’ ’UOM’ ’X' ”.
m_fieldcat ’LFGJA’ ’Year’ ’X' ”.
m_fieldcat ’LFMON’ ’Period’ ’X' ”.
m_fieldcat ’LBKUM’ ’Quantity’ ” ’X’.
m_fieldcat ’VERPR’ ’Average Unit Code’ ” ’X’.
m_fieldcat ’SALK3′ ’Inventory Value’ ” ’X’.

m_sort ’WGBEZ’ ” ”.
m_sort ’MATKL’ ’X' ’X’.

sla-colwidth_optimize = ’X’.
sla-zebra             = ’X’.
i_repid = sy-repid.

CALL FUNCTION ’REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program      = i_repid
i_callback_top_of_page  = ’SUB_ALV_TOP_OF_PAGE’
it_fieldcat             = gd_fieldcat[]
it_sort                 = i_sort
it_events               = i_events
i_save                  = ’A’
i_default               = ’X’

is_variant              = ivariant
is_layout               = sla
it_excluding            = i_excluding
TABLES
t_outtab                = itab_sum
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.
ENDFORM.                    ”fieldcat_init

FORM fieldcatikaduha.

Define m_fieldcatika.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-row_pos      = ’1′.
ls_fieldcat-fieldname    = &1.
ls_fieldcat-tabname      = ’G_sum’.
ls_fieldcat-seltext_l    = &2.
ls_fieldcat-key          = &3.
ls_fieldcat-do_sum       = &4.

APPEND ls_fieldcat TO gd_fieldcat.
END-OF-DEFINITION.

DEFINE m_sortika.
add 1 TO wa_sort-spos.
wa_sort-fieldname = &1.
wa_sort-up        = ’X’.
wa_sort-subtot    = &2.
wa_sort-expa      = &3.
APPEND wa_sort TO i_sort.
END-OF-DEFINITION.

m_fieldcatika ’SAKNR’ ’G/L Account’ ’X' ”.
m_fieldcatika ’TXT20′ ’Short Text’ ’X' ”.
m_fieldcatika ’MATNR’ ’MATERIAL#’ ’X' ”.
m_fieldcatika ’MAKTX’ ’MAT Description’ ’X' ”.
m_fieldcatika ’MEINS’ ’UOM’ ’X' ”.
m_fieldcatika ’LFGJA’ ’Year’ ’X' ”.
m_fieldcatika ’LFMON’ ’Period’ ’X' ”.
m_fieldcatika ’LBKUM’ ’Quantity’ ” ’X’.
m_fieldcatika ’VERPR’ ’Average Unit Code’ ” ’X’.
m_fieldcatika ’SALK3′ ’Inventory Value’ ” ’X’.

m_sortika ’TXT20′ ” ”.
m_sortika ’SAKNR’ ’X' ’X’.

sla-colwidth_optimize = ’X’.
sla-zebra             = ’X’.
i_repid = sy-repid.

CALL FUNCTION ’REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program      = i_repid
i_callback_top_of_page  = ’SUB_ALV_TOP_OF_PAGE’
it_fieldcat             = gd_fieldcat[]
it_sort                 = i_sort
it_events               = i_events
i_save                  = ’A’
i_default               = ’X’

is_variant              = ivariant
is_layout               = sla

it_excluding            = i_excluding
TABLES
t_outtab                = G_sum
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.

ENDFORM.

*&———————————————————————*
*&      Form  sub_populate_layout
*&———————————————————————*
*       Populate ALV layout
*———————————————————————-*
*       No Parameter
*———————————————————————-*
FORM sub_populate_layout .

CLEAR sla.
sla-colwidth_optimize = ’X’.” Optimization of Col width

ENDFORM.

*&———————————————————————*
*&      Form  sub_alv_top_of_page
*&———————————————————————*
*       text
*———————————————————————-*
FORM sub_alv_top_of_page.                                   ”#EC CALLED

* To write header for the ALV
CALL FUNCTION ’REUSE_ALV_COMMENTARY_WRITE’
EXPORTING
it_list_commentary = i_alv_top_of_page.

ENDFORM.                    ”alv_top_of_page

slis_layout_alv documentations

A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
Output list description structure.
The parameters are described under the following heads:
-          Display options
-          Exceptions
-          Totals
-          Interaction
-          Detail screen
-          Display variants (only for hierarchical-sequential lists)
-          Color
-          Other
The layout table is of type slis_layout_alv_spec and has the following fields

1. Colwidth_optimize (1) TYPE c: This parameter optimizes the length of the different columns in the output. The width of the different col. now depends on the max. Length of the data in the column.
Value set: SPACE, ‘X’
‘X’ = optimizes the column width so that all contents are displayed completely.

2. No_colhead (1) TYPE c: This parameter suppresses the column headings Value set: SPACE, ‘X’. ‘X’ = column headers are not output

3. No_hotspot*(1) TYPE c :  The headings of the report output are not output as hotspot.  Value set: SPACE, ‘X’. ‘X’ = column headers are not output as hotspot

4. Zebra*(1) TYPE c : The report is output in the striped pattern.   Value set: SPACE, ‘X’.  ’X’ = striped pattern (e.g. for wide lists)

5. No_vline (1) TYPE c: The report output contains columns only separated by space and no lines.  It is not relevant for: hierarchical-sequential lists and multiple-line lists. Value set: SPACE, ‘X’. ‘X’ = columns separated by SPACE

6, No_min_linesize(1) TYPE c : The report  line size is equal to the width of the list. It is not relevant for block lists.
Value set: SPACE, ‘X’. ‘X’ = line size depends on list width ’  ‘ = Line size is set to 80 or MIN_LINESIZE (if > 0) .

7. Min_linesize LIKE sy-linsz: The report output contains a minimum possible length of line. If initial min_linesize is set to 80 by default, then this parameter is used to customize it. The prerequisite for this is that the parameter no_min_linesize should be ‘ ‘.
Value set: 0, 10 – 250
If the list is wider, the format uses the list width (maximum 250 or MAX_LINESIZE (if > 0)).

8. Max_linesize LIKE sy-linsz: The default max. Linesize is 250. To change this default value, this parameter can interactively-define the maximum list width setting.
Value set: 0, 80 – 1020.

9. Window_titlebar LIKE rsmpe-tittext: To set the titlebar on the report output.

10. No_uline_hs(1) TYPE c.

Exceptions
11. Lights_fieldname TYPE slis_fieldname: Internal output table field containing the codes of exceptions to be output.
Output table field code: ’1′ = red traffic light
’2′ = yellow traffic light
’3′ = green traffic light Fieldname for exception
Value set: SPACE, internal output table field name.

12. Lights_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter LIGHTS_FIELDNAME. If LIGHTS_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists. Only relevant for hierarchical-sequential lists.
Value set: SPACE, internal output table name.

13. Lights_rollname LIKE dfies-rollname: The documentation of this data element is displayed when you call F1 help for an exception column.
Value set: SPACE, data element name.

14. Lights_condense (1) TYPE c : If a list record is output with ‘red traffic light’, each  Subtotal that includes this record is also output with ‘red traffic light’.
Value set: SPACE, ‘X’
‘X’ = the ‘maximum’ exception of the items in the subtotal is output at subtotal level.
Sums

15*. No_sumchoice* (1) TYPE c: This parameter allows the choice for summing up Only by field catalog.
Value set: SPACE, ‘X’
‘X’ = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = ‘X’). The user should not be able to change this value interactively.

16. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals.
Value set: SPACE, ‘X’
‘X’ = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = ‘X’ in the field list.

17. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals.
Value set: SPACE, ‘X’
‘X’ = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.

18. No_subtotals(1) TYPE c : No subtotals possible
Value set: SPACE, ‘X’
‘X’ = no subtotals.

19*. Numc_sum*(1)  TYPE c : Totals only possible for NUMC-Fields.

20. No_unit_splitting TYPE c: No separate total lines by inh.units

21.totals_before_items TYPE c: Display totals before the items

22. Totals_only(1) TYPE c :  Show only totals Value set: SPACE, ‘X’ ’X’ = only total records are output.

23. Totals_text(60) TYPE c : Text for 1st col. in totals Value set: SPACE, string (max.60) ’ ‘ = The first column in the total record contains an appropriate number of ‘*’s to indicate the total by default. If the first column is wide enough, the string ‘Total’ is output after the asterisks.
‘String’ = The string passed is output after the total indicated by ‘*’, if the column is wide enough.

24. Subtotals_text(60) TYPE c : Texts for subtotals Value set: SPACE, string (max.60) ’ ‘ = In the first column of subtotal records, the subtotal is indicated by an appropriate number of ‘*’ by default. If the first column is not a subtotal criterion, the string ‘Total’ is output after the asterisks, if the column is wide enough.
‘String’ = the string passed is output after the subtotal indicated by ‘*’, if the column is wide enough and the first column is not a subtotal criterion. If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.
Interaction

25. Box_fieldname TYPE slis_fieldname: Fieldname for checkbox in the report output. If the list has checkboxes at the start of records (for selecting several records), this parameter contains the internal output table field name indicated by the checkbox selection column. The field is a checkbox at the start of list records without a list header.
Value set: SPACE, internal output table field name

26. Box_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter BOX_FIELDNAME. If BOX_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists.
Value set: SPACE, internal output table name.

27. Box_rollname LIKE dd03p-rollname: rollname for checkbox

28. Expand_fieldname TYPE slis_fieldname: fieldname flag ‘expand’. The user can show or hide the items by clicking on the folder symbol (hotspot). If the items for a header entry are only to be read by the calling program and passed to ALV when a header has been expanded interactively, this can be controlled via the CALLBACK event        ‘ITEM_DATA_EXPAND’.
29. Hotspot_fieldname TYPE slis_fieldname: Used to make the fieldname flag hotspot.
30. No_input(1) TYPE c : The fields are only display fields. Value set: SPACE, ‘X’ ’X’ = all ready-for-input fields in a list are displayed as not ready-for-input. (Record selection checkboxes and fields which can be made ready-for-input via the field list parameter FIELDCAT-INPUT = ‘X’)

31. F2code LIKE sy-ucomm: To assign an ALV standard function code to double-click (F2), assign the function code to this parameter. Ex.: to assign the ALV standard function ‘Detail’ (‘&ETA’) to F2. => LAYOUT-F2CODE = ‘&ETA’. Value set: SPACE, function code

32. Confirmation_prompt: confirm. Prompt when leaving Value set: SPACE, ‘X’ ’X’ = if one of the functions ‘Back (F03)’, ‘Exit (F15)’ or ‘Cancel (F12)’ occurs, a confirmation prompt appears.

33. Key_hotspot(1) TYPE c : The key fields are displayed as hotspot. The columns defined in the field catalog as key fields (FIELDCAT-KEY = ‘X’) are output as hotspots, i.e. clicking on a key column (highlighted in color in the list) calls the function under F2. Value set: SPACE, ‘X’.

34. Reprep(1) TYPE c : report report interface active.

35. Group_buttons (1) TYPE c :  group-buttons for COL1 – COL5 . Group output fields via FIELDCAT-SP_GROUP in the field list, and pass the group name to the list module in the interface parameter IT_SPECIAL_GROUPS. Value set: SPACE, ‘X’.

36. No_keyfix(1) TYPE c : Used to make the key fields scrollable. Value set: SPACE, ‘X’. ’ ‘ = The key columns defined in the field catalog by FIELDCAT-KEY = ‘X’ are fixed in the list output. These columns do not scroll horizontally. The item table key columns are fixed in hierarchical-sequential lists. The header table key fields are not considered here. ’X’ = key columns not fixed

37. Get_selinfos(1) TYPE c : To read selection screen. Value set: SPACE, ‘X’. If the calling program is a report with an ABAP/4 selection screen, setting this parameter makes ALV read the selection screen again. If the selections are read successfully, a pushbutton, via which the user can call a popup which lists the report selections in a simple form, becomes active on the results list output by ALV.

38.   group_change_edit(1) TYPE c :  Settings by user for new group
Value set: SPACE, ‘X’
‘X’ = the user can enter a format option for each sort criterion in the sort/subtotal popup, for the list format when this value changes (e.g. new page or underline).

39.   No_scrolling(1) TYPE c : Does not allow scrolling of the list to the right. Value set: SPACE, ‘X’.

40. Expand_all(1) TYPE c : Expand all positions Detailed screen

40.   Detail_popup(1) TYPE c : show detail in popup. Value set: SPACE, ‘X’ ’  ‘  = List record detail display in full-screen mode, with top-of-page. ’X'  = list record detail display in popup (without top-of-page).

41. Detail_initial_lines(1) TYPE c : show also initial lines Value set: SPACE, ‘X’ ’ ‘ = Only fields whose contents are not initial are output in the detail view. ’X’ = initial field contents are also output in detail.

41.   detail_titlebar(30) type c : Titlebar for detail screen Value set: SPACE, string (max.30) ’ ‘ = ‘ Detail: Display’ is output as the title of the detail window. ’String’ = the string passed is output as the title of the detail window.

Display variants


42. Header_text (20) TYPE c: Text for header button. Only relevant for hierarchical-sequential lists. You can toggle between display field and field list views via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.
Value set: SPACE, CHAR (20) ’ ‘ = The header table field pushbutton text is ‘Header’ by default. CHAR (20) = header table field pushbutton text.

43.item_text(20) TYPE c : Text for item button. Only relevant for hierarchical-sequential lists. You can toggle the view between the display fields and the field list via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.
Value set: SPACE, CHAR (20) ’ ‘ = The pushbutton text for the item table fields is ‘Item’ by default. CHAR (20) = item table field pushbutton text.

44.default_ item(1) TYPE c : Items as default. Only relevant for hierarchical-sequential lists.
Value set: SPACE, ‘X’ ’ ‘ = The header table fields are displayed by default in the display variant definition popup. The user can switch to the item table fields interactively. ’X’ = the item table fields are displayed by default in the display variant Definition Popup.    The user can switch to the header table fields interactively.

Colour


45. Info_fieldname TYPE slis_fieldname: infofield for listoutput. A whole list record can be colored individually using a color code in a column of the internal output table for the record. Assign the name of the field containing the color code to this parameter.
Value set: SPACE, internal output table field name The internal output table field must be of type CHAR(3).
The code must have the following syntax:  ‘Cxy’: C = color (all codes must start with ‘C’) X = color number (’1′-’9′)
Y = bold (’0′ = off, ’1′ = on)

46. Coltab_fieldname TYPE slis_fieldname: Cells can be colored individually using a color code which is contained in a column of the internal output table for the record containing the cell. Assign the name of the field to this parameter.
Others


47. List_append(1) TYPE c :  no call screen. It is only useful to output block-lists without specifying the above modules if the number of list blocks exceeds, or may exceed, the maximum number specified in the block module documentation. These operations are not possible for user-defined block lists.

Original Source: http://wiki.sdn.sap.com/wiki/display/ABAP/ALV+TUTOTIAL+FOR+BEGINERS+WITH+EXAMPLES

list of function modules (se37)

ABAP_DOCU_DOWNLOAD Download ABAP documentation in HTML format.
APPL_LOG_DELETE With this function module you delete logs in the database according to specified selection conditions
APPL_LOG_DISPLAY With this function module you can analyze logs in the database.
APPL_LOG_DISPLAY_INTERN With this function module you can analyze logs in local memory, e.g. when you have only collected log records at runtime and do not want to write to the database.
APPL_LOG_INIT This function module checks whether the specified object or sub-object exists and deletes all existing associated data in local memory.
APPL_LOG_READ_DB With this function module you read the log data in the database for an object or sub-object according to specified selection conditions.
APPL_LOG_READ_INTERN With this function module you read all log data whose log class has at least the specified value, from local memory, for the specified object or sub-object.
APPL_LOG_SET_OBJECT With this function module, you create a new object or sub-object for writing in local memory. With a flag you can control whether the APPL_LOG_WRITE_… messages are written in local memory or are output on the screen.
APPL_LOG_WRITE_DB With this function module you write all data for the specified object or sub-object in local memory to the database. If the log for the object or sub-object in question is new, the log number is returned to the calling program.
APPL_LOG_WRITE_HEADER With this function module, you write the log header data in local memory.
APPL_LOG_WRITE_LOG_PARAMETERS With this function module, you write the name of the log parameters and the associated values for the specified object or sub-object in local memory. If this function module is called repeatedly for the same object or sub-object, the existing parameters are updated accordingly. If you do not specify an object or sub-object with the call, the most recently used is assumed.
APPL_LOG_WRITE_MESSAGE_PARAMS With this function module you write a single message, with parameters, in local memory. Otherwise the function module works like APPL_LOG_WRITE_SINGLE_MESSAGE.
APPL_LOG_WRITE_MESSAGES With this function module you write one or more messages, without parameters, in local memory.
APPL_LOG_WRITE_SINGLE_MESSAGE With this function module you write a single message, without parameters, in local memory. If no header entry has yet been written for the object or sub-object, it is created. If you do not specify an object or sub-object with the call, the most recently used is assumed.
ARFC_GET_TID will return the IP address of the terminal in hex.
BAL_CNTL_CREATE Create Control for log display
BAL_CNTL_FREE Release Control
BAL_CNTL_REFRESH Put new data in log display
BAL_DB_DELETE Delete logs from the database
BAL_DB_DEQUEUE Unlock log
BAL_DB_ENQUEUE Lock log
BAL_DB_LOAD Load logs from the database
BAL_DB_LOAD Load log(s)
BAL_DB_SAVE Save logs in the database
BAL_DB_SAVE Save log(s)
BAL_DB_SAVE_PREPARE Prepare save
BAL_DB_SEARCH Find logs in the database
BAL_DSP_LOG_DISPLAY Display messages in memory
BAL_DSP_LOG_DISPLAY Display Log
BAL_DSP_LOG_PARAMETERS Either output extended long text or call a callback routine (based on the data in BAL_S_LOG-PARAMS)
BAL_DSP_LOG_TECHNICAL_DATA Output all log header data
BAL_DSP_MSG_LONGTEXT Display message long text
BAL_DSP_MSG_PARAMETERS Either output extended long text or call a callback routine (based on the data in BAL_S_MSG-PARAMS)
BAL_DSP_MSG_TECHNICAL_DATA Output technical data of a message such as work area, error number, etc.
BAL_DSP_OUTPUT_FREE End output
BAL_DSP_OUTPUT_INIT Initialize output
BAL_DSP_OUTPUT_SET_DATA Set dataset to be displayed
BAL_DSP_PROFILE_DETLEVEL_GET Message hierarchy in DETLEVEL
BAL_DSP_PROFILE_NO_TREE_GET Display without tree (fullscreen)
BAL_DSP_PROFILE_POPUP_GET Display without tree (popup)
BAL_DSP_PROFILE_SINGLE_LOG_GET Standard profile (SLG1) for one log
BAL_DSP_PROFILE_STANDARD_GET Standard profile (SLG1) for a lot of logs
BAL_GLB_AUTHORIZATION_GET Assign authorization
BAL_GLB_AUTHORIZATION_RESET Reset authorization
BAL_GLB_CONFIG_GET Read configuration
BAL_GLB_CONFIG_SET Set configuration
BAL_GLB_MEMORY_EXPORT Put function group memory in ABAP-MEMORY
BAL_GLB_MEMORY_IMPORT Get function group memory from ABAP-MEMORY
BAL_GLB_MEMORY_REFRESH (Partially) reset global memory
BAL_GLB_MEMORY_REFRESH (Partially) initialize memory
BAL_GLB_MSG_CURRENT_HANDLE_GET Get current message handle
BAL_GLB_MSG_DEFAULTS_GET Get message defaults
BAL_GLB_SEARCH_LOG Find logs in memory
BAL_GLB_SEARCH_MSG Find messages in memory
BAL_LOG_CREATE Create log with header data
BAL_LOG_CREATE Create log with header data
BAL_LOG_DELETE Delete log (from database also at Save)
BAL_LOG_EXIST Check existence of a log in memory
BAL_LOG_HDR_CHANGE Change log header
BAL_LOG_HDR_CHECK Check log header data for consistency
BAL_LOG_HDR_READ Read log header and other data
BAL_LOG_MSG_ADD Put message in log
BAL_LOG_MSG_ADD Put message in log
BAL_LOG_MSG_CHANGE Change message
BAL_LOG_MSG_CHANGE Change message
BAL_LOG_MSG_CHECK Check message data for consistency
BAL_LOG_MSG_CUMULATE Add message cumulated
BAL_LOG_MSG_DELETE Delete message
BAL_LOG_MSG_DELETE Delete message
BAL_LOG_MSG_EXIST Check existence of a message in memory
BAL_LOG_MSG_READ Read message and other data
BAL_LOG_MSG_REPLACE Replace last message
BAL_LOG_REFRESH Delete log from memory
BAL_LOG_REFRESH Delete log from memory
BAL_MSG_DISPLAY_ABAP Output message as ABAP-MESSAGE
BAL_OBJECT_SELECT Read Application Log objects table record
BAL_OBJECT_SUBOBJECT Check whether object and subobject exist and the combination is allowed
BAL_SUBOBJECT_SELECT Read subobject table record
BP_EVENT_RAISE Trigger an event from ABAP/4 program
BP_JOBLOG_READ Fetch job log executions
CHANGEDOCUMENT_READ_HEADERS Get the change document header for a sales document, and put the results in an internal table.

Example:
CALL FUNCTION ‘CHANGEDOCUMENT_READ_HEADERS’

EXPORTING

objectclass = ‘EINKBELEG’

objectid = l_objectid

username = space

TABLES

i_cdhdr = lt_cdhdr.

LOOP AT lt_cdhdr WHERE udate IN s_aedat.

CALL FUNCTION ‘CHANGEDOCUMENT_READ_POSITIONS’

EXPORTING

changenumber = lt_cdhdr-changenr

TABLES

editpos = lt_editpos.

LOOP AT lt_editpos WHERE fname = ‘LOEKZ’

AND f_new = ‘L’.

p_desc = text-r01. ” Cancel Contract

ENDLOOP.

ENDLOOP. |

CHANGEDOCUMENT_READ_POSITIONS
Get the details of a change document, and store them in an internal table. This will tell you whether a field was changed, deleted, or updated.

Example:
CALL FUNCTION ‘CHANGEDOCUMENT_READ_HEADERS’

EXPORTING

objectclass = ‘EINKBELEG’

objectid = l_objectid

username = space

TABLES

i_cdhdr = lt_cdhdr.

LOOP AT lt_cdhdr WHERE udate IN s_aedat.

CALL FUNCTION ‘CHANGEDOCUMENT_READ_POSITIONS’

EXPORTING

changenumber = lt_cdhdr-changenr

TABLES

editpos = lt_editpos.

LOOP AT lt_editpos WHERE fname = ‘LOEKZ’

AND f_new = ‘L’.

p_desc = text-r01. ” Cancel Contract

ENDLOOP.

ENDLOOP. |

 

CLAF_CLASSIFICATION_OF_OBJECTS Return all of the characteristics for a material
CLOI_PUT_SIGN_IN_FRONT Move the negative sign from the left hand side of a number, to the right hand side of the number. Note that The result will be left justified (like all character fields), not right justifed as numbers normally are.
CLPB_EXPORT Export a text table to the clipboard (on presentation server)
CLPB_IMPORT Import a Text Table from the Clipboard (on presentation server)
COMMIT_TEXT To load long text into SAP
CONVERSION_EXIT_ALPHA_INPUT converts any number into a string fill with zeroes, with the number at the extreme right
Example:
input = 123

output = 0000000000000…000000000000123 |

CONVERSION_EXIT_ALPHA_OUTPUT
converts any number with zeroes right into a simple integer

Example:
input = 00000000000123

 

CONVERT_ABAPSPOOLJOB_2_PDF convert abap spool output to PDF
CONVERT_OTF Convert SAP documents (SAPScript) to other types.

Example:
CALL FUNCTION “CONVERT_OTF”

EXPORTING FORMAT = “PDF”

IMPORTING BIN_FILESIZE = FILE_LEN

TABLES OTF = OTFDATA

LINES = PDFDATA

EXCEPTIONS ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

OTHERS = 4. |

CONVERT_OTFSPOOLJOB_2_PDF converts a OTF spool to PDF (i.e. Sapscript document)
CONVERT_TO_FOREIGN_CURRENCY Convert local currency to foreign currency.
CONVERT_TO_LOCAL_CURRENCY Convert from foreign currency to local currency
DATE_CHECK_PLAUSIBILITY Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.
DATE_COMPUTE_DAY Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
DATE_GET_WEEK will return the week that a date is in.
DATE_IN_FUTURE Calculate a date N days in the future.
DAY_ATTRIBUTES_GET Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuedsay), whether the day is a holiday, and more.(provided by Francois Henrotte)
DOWNLOAD download a file to the presentation server (PC)
DYNP_VALUES_READ Read the values from a dynpro. This function can be used to read the values from a report’s selection screen too (Another example).
DYNP_VALUES_UPDATE Similar to DYNP_VALUES_READ, this function will allow the updating of fields on a dynpro. Very useful when you want to change a field based on the value entered for another field.
ENQUE_SLEEP Wait a specified period of time before continuing processing.
ENQUEUE_ESFUNCTION Lock an abap program so that it cannot be executed.

List of ABAP-transaction codes related to SAP security

S. No. Transaction Code Purpose
1 SU01 To create and maintain the users.
2 SU01D To Display Users
3 SU10 For mass maintenance.
4 SU02 For Manual creation of profiles.
5 SU03 For Manual creation of authorization.
6 SU3 For setting Address and default parameters.
7 PFCG For maintaining role using profile generator.
8 PFUD For Comparing User master in Dialog.
9 SUPC For generation of Mass profile.
10 SU24 For Maintaining Check Indicators and for Maintaining templates.
11 SU25 For initial Customer table fill.
12 SU20 Lists down the authorization fields.
13 SU21 Lists the Object classes and authorization objects.
14 SM01 For locking the transaction from execution.
15 SM19 Security audit – configuration.
16 SM20 Security audit – reporting.
17 SM30 For creation of table authorization groups and for maintaining assignments to tables
18 SCCL For Local Client Copy on same system between different clients.
19 SCC9 For data exchange over the network and remote client copy between clients in different systems.
20 SCC8 Data exhange happens at operating system level, it supports Client transport.
21 STMS Transport Management System
22 RZ10 Profile configuration
23 RZ11 Maintain profile parameters
24 SU53 To display last authority check that failed
25 SU56 Display User buffer
26 SE84 Information System for SAP R/3 Authorizations
27 SECR Audit Information System
28 SE43 Maintain and display Area Menus
29 ST01 System Trace
30 SUGR Maintain User groups
31 SUIM User Information System
32 SU05 Maintain Internet Users
33 SMLG Maintain Logon Group
34 ST02 Setups/Tune Buffers
35 SM02 System Messages
36 SM04 User Overview
37 SM12 Display and Delete Locks
38 SM13 Display Update Records
39 SM21 System Log
40 SM50 Work Process Overview
41 SM51 List of SAP Servers
42 SM59 Display/Maintain RFC Destinations
43 ST11 Display Developer Traces and error log files
44 ST22 ABAP/4 Runtime Error Analysis
45 SM35 Batch Input Monitoring
46 ST05 Performance trace

 

List of slis_fieldcat_alv

row_pos        like sy-curow, ” output in row
col_pos        like sy-cucol, ” position of the column
fieldname      type slis_fieldname,
tabname        type slis_tabname,
currency(5)    type c,
cfieldname     type slis_fieldname, ” field with currency unit
ctabname       type slis_tabname,   ” and table
ifieldname     type slis_fieldname, ” initial column
quantity(3)    type c,
qfieldname     type slis_fieldname, ” field with quantity unit
qtabname       type slis_tabname,   ” and table
round          type i,        ” round in write statement
exponent(3)       type c,     ” exponent for floats
key(1)         type c,        ” column with key-color
icon(1)        type c,        ” as icon
symbol(1)      type c,        ” as symbol
checkbox(1)    type c,        ” as checkbox
just(1)        type c,        ” (R)ight (L)eft (C)ent.
lzero(1)       type c,        ” leading zero
no_sign(1)     type c,        ” write no-sign
no_zero(1)     type c,        ” write no-zero
no_convext(1)  type c,
edit_mask      type slis_edit_mask,                ”
emphasize(4)   type c,        ” emphasize
fix_column(1)   type c,       ” Spalte fixieren
do_sum(1)      type c,        ” sum up
no_out(1)      type c,        ” (O)blig.(X)no out
tech(1)        type c,        ” technical field
outputlen      like dd03p-outputlen,
offset         type dd03p-outputlen,     ” offset
seltext_l      like dd03p-scrtext_l, ” long key word
seltext_m      like dd03p-scrtext_m, ” middle key word
seltext_s      like dd03p-scrtext_s, ” short key word
ddictxt(1)     type c,        ” (S)hort (M)iddle (L)ong
rollname       like dd03p-rollname,
datatype       like dd03p-datatype,
inttype        like dd03p-inttype,
intlen         like dd03p-intlen,
lowercase      like dd03p-lowercase,

ABAP List Viewer

ABAP List Viewer

This is an escort for creating ABAP List Viewer (ALV) report. In creating ALV, first you must do are :

  1. Add line“type-pools : slis” in your program.
  2. Create functional ALV procedures which is :
    1. Category Fields

This functions for registry which fields will be display on the report.

  1. Layout

Configuring layout properties of ALV reports.

  1. Color

Configuring color layout in ALV report.

  1. Event

before call procedure Comment, call this function first.

  1. Sort and Subtotal

Configuring ALV Sort and Subtotal Function

  1. Group
  1. Comment

Configuring header and Footer ALV report.

  1. Filter

Configuring ALV filter.

  1. Print

Configuring for ALV Report Printing

  1. Call function “REUSE_ALV_LIST_DISPLAY” in background mode (outside of Start-Of-Selection), this function for execute the ALV report program.  Fill the parameter :
    1. I_CALLBACK_PROGRAM with Program ID (Sy-REPID)
    2. I_STRUCTURE_NAME with internal table name or structure table name
    3. IS_LAYOUT with data which has been set in procedure Layout
    4. IT_FIELDCAT with table which has been set in procedure Category Fields.
    5. IT_FILTER with Filter Data
    6. IT_SPECIAL_GROUPS with Groups data
    7. IT_EVENTS with Event data
    8. IT_SORT with Sort Data
    9. IS_PRINT with Print Data
    10. Tables T_OUTTAB with your

C a t e g o r y  F i e l d s

Category Fields are fields which will be display on ALV Report. You must create variable with type slis_t_fieldcat_alv. Then make procedure which set property of that variable.

Here is the structure of Structure slis_t_fieldcat_alv.

TYPES: BEGIN OF SLIS_FIELDCAT_MAIN,

ROW_POS        LIKE SY-CUROW, ” output in row

COL_POS        LIKE SY-CUCOL, ” position of the column

FIELDNAME      TYPE SLIS_FIELDNAME,

TABNAME        TYPE SLIS_TABNAME,

REF_FIELDNAME  LIKE DD03P-FIELDNAME,

REF_TABNAME    LIKE DD03P-TABNAME,

CFIELDNAME     TYPE SLIS_FIELDNAME, ” field with currency unit

CTABNAME       TYPE SLIS_TABNAME,   ” and table

QFIELDNAME     TYPE SLIS_FIELDNAME, ” field with quantity unit

QTABNAME       TYPE SLIS_TABNAME,   ” and table

ROUNDFIELDNAME TYPE SLIS_FIELDNAME,

ROUNDTABNAME   TYPE SLIS_TABNAME,

ROUND          TYPE I,        ” round in write statement

DECIMALSFIELDNAME TYPE SLIS_FIELDNAME,

DECIMALSTABNAME   TYPE SLIS_TABNAME,

DECIMALS_OUT(6)   TYPE C,   ” decimals in write statement

EXPONENT(3)       TYPE C,   ” exponent for floats

KEY(1)         TYPE C,        ” column with key-color

ICON(1)        TYPE C,        ” as icon

SYMBOL(1)      TYPE C,        ” as symbol

CHECKBOX(1)    TYPE C,        ” as checkbox

JUST(1)        TYPE C,        ” (R)ight (L)eft (C)ent.

LZERO(1)       TYPE C,        ” leading zero

NO_SIGN(1)     TYPE C,        ” write no-sign

NO_ZERO(1)     TYPE C,        ” write no-zero

EDIT_MASK      TYPE SLIS_EDIT_MASK, ”

EMPHASIZE(4)   TYPE C,        ” emphasize

FIX_COLUMN(1)   TYPE C,       ” Spalte fixieren

DO_SUM(1)      TYPE C,        ” sum up

NO_OUT(1)      TYPE C,        ” (O)blig.(X)no out

TECH(1)        TYPE C,        ” technical field

OUTPUTLEN      LIKE DD03P-OUTPUTLEN,

SELTEXT_L      LIKE DD03P-SCRTEXT_L, ” long key word

SELTEXT_M      LIKE DD03P-SCRTEXT_M, ” middle key word

SELTEXT_S      LIKE DD03P-SCRTEXT_S, ” short key word

REPTEXT_DDIC   LIKE DD03P-REPTEXT,   ” heading (ddic)

DDICTXT(1)     TYPE C,        ” (S)hort (M)iddle (L)ong

ROLLNAME       LIKE DD03P-ROLLNAME,

*        domname        like dd03p-domname,     “Domname für Checkbox

DATATYPE       LIKE DD03P-DATATYPE,

DDIC_OUTPUTLEN LIKE DD03P-OUTPUTLEN,

INTLEN         LIKE DD03P-INTLEN,

END OF SLIS_FIELDCAT_MAIN.

 

TYPES: BEGIN OF SLIS_FIELDCAT_ALV_SPEC,

KEY_SEL(1)     TYPE C,        ” field not obligatory

NO_SUM(1)      TYPE C,        ” do not sum up

SP_GROUP(1)    TYPE C,        ” group specification

REPREP(1)      TYPE C,        ” selection for rep/rep

INPUT(1)       TYPE C,        ” input

HOTSPOT(1)     TYPE C,        ” hotspot

END OF SLIS_FIELDCAT_ALV_SPEC.

 

TYPES: BEGIN OF SLIS_FIELDCAT_ALV.

INCLUDE TYPE SLIS_FIELDCAT_MAIN.

INCLUDE TYPE SLIS_FIELDCAT_ALV_SPEC.

TYPES: END OF SLIS_FIELDCAT_ALV.

TYPES: SLIS_T_FIELDCAT_ALV TYPE SLIS_FIELDCAT_ALV OCCURS 1.

After you set the properties, it will be use in executing ALV reports.

Take a look at this example :

 

FORM FIELDCAT_INIT.

DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.

CLEAR FIELDCAT_IN.

*– add matnr –

CLEAR FIELDCAT_IN.

FIELDCAT_IN-FIELDNAME = ‘MATNR’.

FIELDCAT_IN-REF_FIELDNAME = ‘MATNR’.

FIELDCAT_IN-REF_TABNAME = ‘MARA’.

FIELDCAT_IN-OUTPUTLEN = 20.

APPEND FIELDCAT_IN TO GT_FIELDCAT.

*– add matkl –

CLEAR FIELDCAT_IN.

FIELDCAT_IN-FIELDNAME = ‘MATKL’.

FIELDCAT_IN-REF_FIELDNAME = ‘MATKL’.

FIELDCAT_IN-REF_TABNAME = ‘MARA’.

FIELDCAT_IN-OUTPUTLEN = 20.

FIELDCAT_IN-HOTSPOT = ‘X’.

FIELDCAT_IN-SELTEXT_L = ‘Material Type (MATKL)’.

FIELDCAT_IN-EMPHASIZE = ‘C700′.

APPEND FIELDCAT_IN TO GT_FIELDCAT.

*– add mtart –

CLEAR FIELDCAT_IN.

FIELDCAT_IN-FIELDNAME = ‘MTART’.

FIELDCAT_IN-REF_FIELDNAME = ‘MTART’.

FIELDCAT_IN-REF_TABNAME = ‘MARA’.

FIELDCAT_IN-NO_OUT = ”.

FIELDCAT_IN-OUTPUTLEN = 20.

APPEND FIELDCAT_IN TO GT_FIELDCAT.

ENDFORM.

 

Of course we can see that if you want to show more than one field Use it like you use internal table.

L a y o u t

This properties gives you, you can configure what you want about the layout of ALV report. Here is the structure of Layout properties plus brief explanation.

 

TYPES: BEGIN OF SLIS_LAYOUT_MAIN,

DUMMY,

END OF SLIS_LAYOUT_MAIN.

 

TYPES: BEGIN OF SLIS_LAYOUT_ALV_SPEC,

*        Display options

COLWIDTH_OPTIMIZE(1) TYPE C,

NO_COLHEAD(1) TYPE C,         ” no headings

NO_HOTSPOT(1) TYPE C,         ” headings not as hotspot

ZEBRA(1) TYPE C,              ” striped pattern

NO_VLINE(1) TYPE C,           ” columns separated by space

NO_MIN_LINESIZE(1) TYPE C,    ” line size = width of the list

MIN_LINESIZE LIKE SY-LINSZ,   ” if initial min_linesize = 80

MAX_LINESIZE LIKE SY-LINSZ,   ” Default 250

WINDOW_TITLEBAR LIKE RSMPE-TITTEXT,

*      Exceptions

LIGHTS_FIELDNAME TYPE SLIS_FIELDNAME,” fieldname for exception

LIGHTS_TABNAME TYPE SLIS_TABNAME, ” fieldname for exception

LIGHTS_ROLLNAME LIKE DFIES-ROLLNAME,” rollname f. exceptiondocu

LIGHTS_CONDENSE(1) TYPE C,    ” fieldname for exception

*        Sums

NO_SUMCHOICE(1) TYPE C,       ” no choice for summing up

NO_TOTALLINE(1) TYPE C,       ” no total line

NO_SUBCHOICE(1) TYPE C,       ” no choice for subtotals

NO_SUBTOTALS(1) TYPE C,       ” no subtotals possible

NUMC_SUM(1)     TYPE C,       ” totals for NUMC-Fields possib.

TOTALS_ONLY(1) TYPE C,        ” show only totals

TOTALS_TEXT(60) TYPE C,       ” text for 1st col. in total line

SUBTOTALS_TEXT(60) TYPE C,    ” text for 1st col. in subtotals

*      Interaction

BOX_FIELDNAME TYPE SLIS_FIELDNAME, ” fieldname for checkbox

BOX_TABNAME TYPE SLIS_TABNAME,” tabname for checkbox

EXPAND_FIELDNAME TYPE SLIS_FIELDNAME, ” fieldname flag ‘expand’

HOTSPOT_FIELDNAME TYPE SLIS_FIELDNAME, ” fieldname flag hotspot

NO_INPUT(1) TYPE C,           ” only display fields

F2CODE LIKE SY-UCOMM,       ”

CONFIRMATION_PROMPT,          ” confirm. prompt when leaving

KEY_HOTSPOT(1) TYPE C,        ” keys as hotspot ” K_KEYHOT

REPREP(1) TYPE C,             ” report report interface active

GROUP_BUTTONS(1) TYPE C,      ” buttons for COL1 – COL5

NO_KEYFIX(1) TYPE C,          ” do not fix keycolumns

GET_SELINFOS(1) TYPE C,       ” read selection screen

GROUP_CHANGE_EDIT(1) TYPE C,  ” Settings by user for new group

NO_SCROLLING(1) TYPE C,        ” no scrolling

*        Detailed screen

DETAIL_POPUP(1) TYPE C,       ” show detail in popup

DETAIL_INITIAL_LINES(1) TYPE C, ” show also initial lines

DETAIL_TITLEBAR(30) TYPE C,   ” Titlebar for detail

*        Display variants

HEADER_TEXT(20) TYPE C,       ” Text for header button

ITEM_TEXT(20) TYPE C,         ” Text for item button

DEFAULT_ITEM(1) TYPE C,       ” Items as default

*       colour

INFO_FIELDNAME TYPE SLIS_FIELDNAME, ” infofield for listoutput

COLTAB_FIELDNAME TYPE SLIS_FIELDNAME, ” colors

*        others

LIST_APPEND(1) TYPE C,        ” no call screen

END OF SLIS_LAYOUT_ALV_SPEC.

 

TYPES: BEGIN OF SLIS_LAYOUT_ALV.

INCLUDE TYPE SLIS_LAYOUT_MAIN.

INCLUDE TYPE SLIS_LAYOUT_ALV_SPEC.

TYPES: END OF SLIS_LAYOUT_ALV.

 

C o l o r

Below is structure for Color in ALV Report.

 

TYPES: BEGIN OF SLIS_COLOR,

COL TYPE I,

INT TYPE I,

INV TYPE I,

END OF SLIS_COLOR.

 

TYPES: BEGIN OF SLIS_COLTYPES,

HEACOLFIR      TYPE SLIS_COLOR, ” heading_cols_first

HEACOLNEX      TYPE SLIS_COLOR, ” heading_cols_nex

HEAROWFIR      TYPE SLIS_COLOR, ” heading_rows_first

HEAROWNEX      TYPE SLIS_COLOR, ” heading_rows_next

LISBODFIR      TYPE SLIS_COLOR, ” list_body_first

LISBODNEX      TYPE SLIS_COLOR, ” list_body_next

LISBOD         TYPE SLIS_COLOR, ” list_body

HIGCOLKEY      TYPE SLIS_COLOR, ” highlight_col_key

HIGCOL         TYPE SLIS_COLOR, ” highlight_col

HIGROW         TYPE SLIS_COLOR, ” highlight_row

HIGSUM         TYPE SLIS_COLOR, ” highlight_sum

HIGSUMHIG      TYPE SLIS_COLOR, ” highlight_sum_high

HIGSUMLOW      TYPE SLIS_COLOR, ” highlight_sum_low

HIGINS         TYPE SLIS_COLOR, ” highlight_inserted

HIGPOS         TYPE SLIS_COLOR, ” highlight_positive

HIGNEG         TYPE SLIS_COLOR, ” highlight_negative

HIG            TYPE SLIS_COLOR, ” highlight

HEAHIE         TYPE SLIS_COLOR, ” heading_hier

LISBODHIE      TYPE SLIS_COLOR, ” list_body_hierinfo

END OF SLIS_COLTYPES.

You can give touch of color for your report by setting this properties.

Examples of using.

E v e n t

With this function we can handle event. The way to handle is

first you must call function “REUSE_ALV_EVENTS_GET” with input parameter  of I_LIST_TYPE with value :

  1. 0 : Simple List (default)
  2. 1 : Hierarchy – sequential List
  3. 2 : Simple Block List
  4. 3 : Hierarchy – sequential block list

NB: I still don’t know what the differences for each type

and Output parameter of ET_EVENTS with table which has type SLIS_T_EVENT.

Here is the constants for Event Constants.

CONSTANTS:

* Events

SLIS_EV_ITEM_DATA_EXPAND   TYPE SLIS_FORMNAME VALUE ‘ITEM_DATA_EXPAND’,

SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE ‘CALLER_EXIT’,

SLIS_EV_USER_COMMAND       TYPE SLIS_FORMNAME VALUE ‘USER_COMMAND’,

SLIS_EV_TOP_OF_PAGE        TYPE SLIS_FORMNAME VALUE ‘TOP_OF_PAGE’,

SLIS_EV_TOP_OF_COVERPAGE   TYPE SLIS_FORMNAME VALUE ‘TOP_OF_COVERPAGE’,

SLIS_EV_END_OF_COVERPAGE   TYPE SLIS_FORMNAME VALUE ‘END_OF_COVERPAGE’,

SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME

VALUE ‘FOREIGN_TOP_OF_PAGE’,

SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME

VALUE ‘FOREIGN_END_OF_PAGE’,

SLIS_EV_PF_STATUS_SET      TYPE SLIS_FORMNAME VALUE ‘PF_STATUS_SET’,

SLIS_EV_LIST_MODIFY        TYPE SLIS_FORMNAME VALUE ‘LIST_MODIFY’,

SLIS_EV_TOP_OF_LIST        TYPE SLIS_FORMNAME VALUE ‘TOP_OF_LIST’,

SLIS_EV_END_OF_PAGE        TYPE SLIS_FORMNAME VALUE ‘END_OF_PAGE’,

SLIS_EV_END_OF_LIST        TYPE SLIS_FORMNAME VALUE ‘END_OF_LIST’,

SLIS_EV_AFTER_LINE_OUTPUT  TYPE SLIS_FORMNAME VALUE ‘AFTER_LINE_OUTPUT’,

SLIS_EV_BEFORE_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE                                                 ‘BEFORE_LINE_OUTPUT’.

 

Below is Structure of SLIS_T_EVENT.

 

*— Structure for event handling

TYPES: BEGIN OF SLIS_ALV_EVENT,

NAME(30),

FORM(30),

END OF SLIS_ALV_EVENT.

TYPES: SLIS_T_EVENT TYPE SLIS_ALV_EVENT OCCURS 0.

 

Then you can check what events has occured. by Check the SLIS_ALV_EVENT-NAME with event – constants. Check the code below.

 

FORM EVENTTAB_BUILD.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION ‘REUSE_ALV_EVENTS_GET’

EXPORTING

I_LIST_TYPE     = 0

IMPORTING

ET_EVENTS       = GT_EVENTS

EXCEPTIONS

LIST_TYPE_WRONG = 1

OTHERS          = 2.

 

*  check what event has occured.

READ TABLE GT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

*  if event occured.

IF SY-SUBRC = 0.

MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO GT_EVENTS.

ENDIF.

ENDFORM.

Note: You must call this function before creating call function COMMENT.

 

S o r t   a n d    S u b t o t a l

Below is Structure Sort (SLIS_T_SORTINFO_ALV).

* information for sort and subtotals

TYPES: BEGIN OF SLIS_SORTINFO_ALV,

SPOS LIKE ALVDYNP-SORTPOS,

FIELDNAME TYPE SLIS_FIELDNAME,

TABNAME TYPE SLIS_FIELDNAME,

UP LIKE ALVDYNP-SORTUP,                 “Ascending

DOWN LIKE ALVDYNP-SORTDOWN,       “Descending

GROUP LIKE ALVDYNP-GROUPLEVEL,   “Grouping

SUBTOT LIKE ALVDYNP-SUBTOTALS,    “Field Subtotal

COMP(1) TYPE C,

EXPA(1) TYPE C,

END OF SLIS_SORTINFO_ALV.

TYPES: SLIS_T_SORTINFO_ALV TYPE SLIS_SORTINFO_ALV OCCURS 1.

Every field to be configured is added to SLIS_T_SORTINFO_ALV. This table will be use as input parameter of function “REUSE_ALV_LIST_DISPLAY”.
G r o u p

not yet studied.

C o m m e n t

This function use for creating header and footer ALV report. This is the structure for use Comment.

 

* Header table for top of page

TYPES: BEGIN OF SLIS_LISTHEADER,

TYP(1) TYPE C,   ” H = Header, S = Selection, A = Action

KEY(20) TYPE C,

INFO TYPE SLIS_ENTRY,

END OF SLIS_LISTHEADER.

TYPES: SLIS_T_LISTHEADER TYPE SLIS_LISTHEADER OCCURS 1.

Take a look code below.

Data GT_LIST_TOP_PAGE type slis_t_listheader.

FORM COMMENT_BUILD.

DATA: GS_LINE TYPE SLIS_LISTHEADER, TEXT(60) TYPE C.

GS_LINE-TYP = ‘H’.

GS_LINE-INFO = ‘Hello Header’.

APPEND GS_LINE TO GT_LIST_TOP_PAGE.

ENDFORM.

 

It will pring ‘Hello Header’ in top-of-page ALV report.
F i l t e r

 

P r i n t

This standard Type in SLIS type-groups.

 

TYPES: SLIS_LIST_TYPE(1) TYPE N,

SLIS_CHAR_1(1) TYPE C,

SLIS_TEXT40(40) TYPE C.

TYPES: SLIS_TABNAME(30) TYPE C,

SLIS_FIELDNAME(30) TYPE C,

SLIS_FORMNAME(30) TYPE C,

SLIS_ENTRY(60) TYPE C,

SLIS_EDIT_MASK(60) TYPE C,

SLIS_COLDESC(4) TYPE C.

author by Sandi Wijaya

INFORMATION