Using the SAP Locking Facility
Definition of an SAP lock
The description of an SAP lock to a table is made via the lock condition
and the lock mode.
The lock condition is a logical condition for the lines of the table to
be locked. It describes the area of the table which the lock is to
protect from competitive access. To avoid the administration of the lock
becoming complicated, the lock condition can not be formulated as freely
as the WHERE clauses: only fully qualified key fields related by AND
may appear in the condition.
Via the lock mode you define which operations on the table are to be
protected by the lock. The lock modes available are:
o Read lock (shared lock)
protects read access to an object. The read lock allows other
transactions read access but not write access to the locked area of
the table.
o Write lock (exclusive lock)
protects write access to an object. The write lock allows other
transactions neither read nor write access to the locked area of the
table.
o Enhanced write lock (exclusive lock without cumulation)
works like a write lock except that the enhanced write lock also
protects from further accesses from the same transaction.
In order to be able to define SAP locks for a table, you must first
create a lock object for the table via Development->Dictionary.
If the data for an application object is distributed among several
database tables, it is often necessary to be able to lock these tables
simultaneously. It is therefore possible to include several tables in a
lock object, althought they must be related via appropriate foreign key
relationships. The tables involved in a lock object are also known as
its base tables.
Requesting an SAP lock
When a lock object obj is activated, two function modules (see CALL
FUNCTION) with the names ENQUEUE_obj and DEQUEUE_obj are generated.
These lock modules are used to explicitly request or release SAP locks
in an ABAP program. The SAP lock concept thus assumes a cooperative
behavior by all the programs involved. This means that access from
programs that do not call the specified modules are not protected.
The lock conditions and lock modes for the requested locks are defined
by the IMPORT parameters of the lock modules.
The lock conditions are defined by the lock parameters of the lock
object. If the lock object has only one base table, each primary key
field of the table corresponds to exactly one lock parameter. Apart from
this, a lock parameter corresponds to a group of primary key fields that
are identified by the join conditions. For each lock parameter par, the
lock modules have two IMPORT parameters with the names par and X_par.
The lock condition is defined by these parameters. If a parameter par is
not defined or if it is defined with the initial value, this means that
the corresponding key fields should be locked generically. If you really
want to lock the key field with the initial value, you must also define
the parameter X_par with the value 'X'.
To define the lock modes, the lock modules have an IMPORT parameter
MODE_tab for each base table tab, with which the lock mode for this
table can be defined. A default value must already be set for this
parameter in the definition of the lock object.
You cannot set an SAP lock by finding all the lines of the table which
satisfy the lock condition and marking them as locked. Rather, the lock
condition and lock mode for a table are entered in a special lock table.
Collision of SAP locks
Before a requested SAP lock is entered in the lock table, a check is
made on whether it collides with a lock already entered in the lock
table. Two locks on the same table collide if their lock conditions
overlap and their lock modes are incompatible.
The overlapping of two lock conditions on one table is a purely logical
attribute. It occurs if a row of the table which meets both conditions
could exist. It is therefore irrelevant for the overlap whether or not
such a row really exists in the table.
The following rules apply for the compatability of locks: An enhanced
write lock is incompatible with all other locks, a write lock is
incompatible with all locks requested by other transactions, and a read
lock is compatible with all other read locks.
If locks are requested with the help of a lock object that has several
base tables, all locks requested are regarded as colliding as soon as a
collision is recognized for just one of the base tables involved.
Behaviour in a collision
An SAP lock that collides with an existing lock cannot be granted and is
therefore not entered in the lock table.
With the help of the IMPORT parameter _WAIT, you can determine how the
ENQUEUE module should behave if the lock it requests collides with an
existing lock. If this parameter has the value ' ', the exception
FOREIGN_LOCK is triggered. The system field SY-MSGV1 is supplied with
the user set by the the colliding lock.
If the parameter has the value 'X', the lock request is repeated at set
intervals until either the lock can be granted or an internal system
time limit is exceeded. In the second case the exception FOREIGN_LOCK is
also triggered.
Duration of an SAP lock
At the end of a transaction, this automatically releases all the SAP
locks it holds. Note, however, that if an update routine is called by
the transaction, locks can be transferred from the ordering transaction
to the update routine. In the same way, these locks are automatically
released at the end of the update routine. Via the IMPORT parameter _SCOPE of the ENQUEUE module, you can determine
whether a lock should be transferred to the update routine if one is
called.
If _SCOPE has the value '1', the lock remains with the the ordering
transaction. If _SCOPE has the value '2', the lock can pass to the
update routine. Finally, if the parameter has the value '3', two locks
of the same kind will be generated, one of which passes to an update
routine when one is called.
By calling the DEQUEUE module, a transaction can explicitly release a
lock which it holds. The lock parameter and lock mode must be supplied
with the same value as for calling the ENQUEUE module. If the parameter
_SCOPE has the value '1', only one lock is released which cannot pass to
an update routine. If the parameter has the value '2', only one lock is
released which can pass to the update program. Finally, if the parameter
has the value '3', both locks can be released. Note however that a
transaction can release neither a lock which has already been
transferred to the update program, nor a lock which is held by another
transaction.
Via the IMPORT parameter _SYNCHRON you can control whether the release
of the lock should be synchronous or asynchronous. If this parameter has
the value 'X', the module waits until the lock has really been removed
from the lock table. If the parameter has the value ' ', a requst for
deletion of the lock from the lock table is sent to the application server which manages the lock table, and then the execution of the
program is immediately continued.
Monitoring of SAP locks
The transaction Display and delete locks monitors the SAP locks.
LOCK PARAMETERS
Definition of the lock parameters of a lock object:
The lock parameters of a lock object are used when the relevant lock
modules are called to allocate the values to the lock arguments of the
lock object.
For each parameter field of the lock object (at most) one lock parameter
can be defined.
The name of the lock parameter generally corresponds to the name of the
relevant parameter field. The name can however be freely chosen as long
as it adheres to the name conventions for lock parameters.
For each parameter of the lock objects the relevant lock modules
receive IMPORT parameters and X_. The parameter
possesses the relevant parameter field as reference field. If the IMPORT
parameter is filled with a value in a call, all the lock fields
equivalent to the parameter field in the corresponding lock arguments
are filled with that value. If the parameter remains initial, generic
locking takes place on these lock fields. If however the flag X_ is
set, initial also means that the corresponding lock field should
be locked at initial value.
NAMING CONVENTIONS OF LOCK OBJECTS
When naming the lock parameters of a lock object, the following
conventions apply:
1. No lock parameter may appear twice in a lock object.
2. Each lock parameter name must adhere to the name conventions for
table fields.
3. No lock parameter name may begin with the prefix 'X_'.
4. No lock parameter name may begin with the prefix 'MODE_'.
5. No lock parameter name may correspond to the name of a Basis table.
6. The names 'DDENQ_LIKE' and 'DD26E' are not allowed for lock
parameters.
LOCK FIELDS
Definition of the lock fields of a lock object:
The lock fields of a lock object are the key fields of the base tables
of the lock object for which a lock mode is defined.
The only exception to this rule is when the lock object only has one
base table and this base table is a structure without key fields. In
this case the lock fields of lock object are precisely those parameter
fields of the lock object for which a lock parameter is defined. (Here
too a lock mode must be defined for this base table.)
The lock argument for a table is now constructed from the lock fields
within this table. By virtue of the join conditions which were used to
construct the lock object, each lock field is equivalent to one
parameter field. If a lock parameter is defined for this parameter
field, the content of the lock field in the lock argument is controlled
via this lock parameter. Otherwise only generic locking is possible for
this lock field.
LOCK MODES
Definition of the lock modes of a lock object:
In the definition of a lock object one of the three lock modes
'S'(shared lock), 'E'(exclusive lock) or 'X'(exclusive lock without
accumulation) can be specified for each Basis table.
For each Basis table , for which a lock mode was specified, the
lock modules belonging to the lock object receive an IMPORT parameter
MODE_. This has the specified value as default. In a call this can
be changed to one of the other two values. This value is then entered in
the lock granule for the table. Basis tables for which no lock mode is
defined cannot be locked with the lock object.
LOCK GRANULE
Definition of the lock granule of a lock object:
For each base table of a lock object for which a lock mode is defined, a
lock granule is formed which consists of the name of the table, the
current lock mode and the lock argument for this base table. These lock
granules are the information which is transmitted to the lock server
when a lock module for a lock object is called.
DATABASE LOCKING
Database Locking
Any database permitting simultaneous access by several users requires a
locking mechanism to manage and synchronize access. The tasks of this
mechanism are to:
- protect data objects which a transaction is currently changing
or reading from being changed by other transactions at the same
time.
- protect a transaction against reading data objects which have
not yet been fully written back by another transaction.
How is locking achieved?
Database systems do not usually provide commands for explicitly setting
or releasing locks. Therefore, prior to executing the database
operation, database locks are set implicitly when one of the Open SQL
statements SELECT SINGLE FOR UPDATE, INSERT, UPDATE, MODIFY, DELETE is
called (or when the corresponding Native SQL statement is called).
What is locked?
Database systems set physical locks on all lines affected by a database
call. In the case of SELECT, these are the selected entries. In the case
of UPDATE, DELETE, INSERT and MODIFY, they are the entries to be
changed, deleted, etc.
It is not always the table line which is locked. Tables, data pages and
index pages can also be locked. The units to be locked depend on the
database system you are using and the access being performed.
Lock mode
In principle, one type of lock is enough to control conflicting data
accesses. However, to achieve a greater degree of parallel running among
transactions, database systems use several types of locks. These can
vary from system to system, but the following two are sufficient to gain
an understanding of how locking works:
o Read lock (shared lock)
Read locks permit the setting of further read locks, but prevent
other transactions from setting write locks for the objects in
question.
o Write lock (exclusive lock)
Write locks do not allow other transactions to set any locks for the
objects in question.
How are locks set?
You set write locks with the Open SQL statements SELECT SINGLE FOR
UPDATE, INSERT, UPDATE, MODIFY and DELETE (or with the appropriate
Native SQL statements).
The decision as to whether the Open SQL command SELECT or the
appropriate Native SQL command sets the lock or not depends on the
isolation level of the transaction. Two possible levels are
distinguished:
o Uncommitted read (or dirty read)
A program using an "uncommitted read" to read data does not set
locks on data objects and does not obey them. For this reason,
programmers must bear in mind that their programs might read data
which has not yet been finally written to the database with a database commit and could thus still be deleted from the database by
a database rollback. "Uncommitted read" is the default setting in
the R/3 system for the isolation level.
o Committed read
A program using a "committed read" to read data obeys the locks on
data objects. This means that programmers can be sure that their
programs will read only data which has been finally written to the
database with a database commit. You can set the isolation level in
the R/3 system to "committed read" by calling the function module
DB_SET_ISOLATION_LEVEL. The next database commit or rollback will
reset the isolation level to its default setting, as will calling
the function module DB_RESET_ISOLATION_TO_DEFAULT.
Many database systems employ additional isolation levels (e.g. "cursor
stability" and "repeatable read"). These work like "committed read", but
the read lock is retained until the next data object is read or until
the database cursor is closed. Since these isolation levels are not
sufficiently standardized, they are not currently used in the R/3
System.
If a transaction cannot lock an object because it is already locked by another transaction, it waits until the other transaction has released
the lock. This can result in a deadlock. A deadlock occurs, for example,
when two transactions are waiting for a lock held by the other.
How long is a lock retained?
In database locking, all locks are released no later than the next database commit or rollback (see Logical Unit of Work (LUW)). Read locks
are usually retained for a shorter period. Sometimes, this causes
problems for transactions which cover several dialog steps:
In the above example, further dialog steps follow the selection of a
flight with free seats to enter additional data for the reservation.
Here, the adding of the flight reservation occurs in a different LUW
than the original selection of the flight. Database locking does not
prevent another transaction from booking this flight in the meantime.
This means that the scheduled booking may have to be canceled after all.
From the user's point of view, this solution is very inconvenient. To
avoid this scenario, a flight reservation system must use the SAP
locking mechanism (see SAP Locking) to lock the flight for the entire
duration of the transaction.
MESSAGES
MESSAGE Syntax Diagram
Variants:
1. MESSAGE xnnn.
2. MESSAGE ID id TYPE mtype NUMBER n.
3. MESSAGE xnnn(mid).
Effect Sends a message. Messages are stored in table T100, and can be
maintained using Transaction SE91. They are fully integrated
in the forward navigation of the ABAP Workbench.
The ABAP runtime environment handles messages according to the
message type specified in the MESSAGE statement and the
context in which the message is sent. There are six kinds of
message type:
A (Abend) Termination
E (Error) Error
I (Info) Information
S (Status) Status message
W (Warning) Warning
X (Exit) Termination with short dump
Messages are used primarily to handle user input on screens.
There is an Example program for messages that displays how
messages behave in various contexts.
Variant 1 MESSAGE xnnn.
Additions:
1. ... WITH f1 ... f4
2. ... RAISING exception
3. ... INTO f
Effect Sends the message nnn from message class i with type x. You
can specify the message class i in the MESSAGE-ID addition to
the REPORT, PROGRAM or other introductory statement.
Example
MESSAGE I001.
- If you want to use a different message class, you can
specify one in parentheses after the message number:
MESSAGE I001(SU).
- When the statement is executed, the following system
variables are set:
* SY-MSGID (Message class)
* SY-MSGTY (Message type)
* SY-MSGNO (Message number)
Note Runtime errors:
- MESSAGE_TYPE_UNKNOWN: Message type unknown
- MESSAGE_TYPE_X: Deliberate program termination with short
dump
TRANSATIONS
1.SCREEN NUMBERS
The screen number identifies a screen within a program (module pool,
report).
Screen numbers can be up to 4 characters long, all of which must be
digits. Screen numbers from 9000 are reserved for customer-specific
screens.
The use of screen numbers is namespace-dependent. For screens in
programs in the SAP namespace, numbers less than 9000 are reserved for
SAP screens, numbers between 9000 and 9500 are reserved for SAP
partners, and numbers greater than 9500 are for customers.
BADI, BAPI'S, BDC, HR, Interview Questions, Programming, Reports, RFC, TCodes, ABAP-Java, ALE, IDOCs, ALV's, BSP, BTE, Data Dictionary, Dialog Programming, FICO, SD, MM, Function Modules, Interactive Reports, Internal Tables, Locking, Logical Database, OOPS,PM,PP,QM,R/3,BW,SCRIPTS,SMART FORMS
Showing posts with label ABAP ALV REPORTS SAMPLE CODES.. Show all posts
Showing posts with label ABAP ALV REPORTS SAMPLE CODES.. Show all posts
Tuesday, June 10, 2008
REPLACE COMMENTARY IN ALV
1 Introduction
The ALV provides Events, which allows users to add information to the List at different rendering time points.
Goals of the ALV Form:
• UI independent information for rendering
• The information is displayed in agreement with the SAP agronomical guideline
The base Element of the ALV Form is the abstract class CL_SALV_FORM_ELEMENT.
This base Element (CL_SALV_FORM_ELEMENT) describes the information to be displayed. There are two major Element types:
• Layout Element (CL_SALV_FORM_ELEMENT_LAYOUT): the base layout element for describing a table or a flow of information
• Textual Element (CL_SALV_FORM_ELEMENT_TEXTUAL): the base element for text elements. Text Elements supported are:
o Label (CL_SALV_FORM_LABEL)
o Text (CL_SALV_FORM_TEXT)
o Header information (CL_SALV_FORM_HEADER_INFO)
o Action information (CL_SALV_FORM_ACTION_INFO)
2 Step-by-Step Description how to Replace
1) Have a look at the original output and ensure you that the converted output has the same lines and texts arrangements
2) Identify used ‘REUSE_ALV_COMMENTARY_WRITE’ calls within your programs, especially in the subroutines TOP_OF_PAGE (Grid) and TOP_OF_LIST (Simple List)
3) Comment the ‘REUSE_ALV_COMMENTARY_WRITE’
4) Search and comment all the used variables, subroutine / function module calls, text-elements and internal tables, which are used exclusively for the ‘REUSE_ALV_COMMENTARY_WRITE’ output.
5) Please insert the necessary coding and data-elements for “ALV Form”. This is done within the TOP_OF_PAGE subroutine for ALV GRID and in the TOP_OF_LIST subroutine for Simple List
6) Delete all unused (commented) variables, calls and tables (step 3&4).
7) ! Ensure that you have inserted all newly created text-elements for this process in your report documentation
8) Test the output and compare with the original one
3 Coding and Functionality of “ALV Form” (easy)
CREATE OBJECT lr_grid.
lr_label = lr_grid->create_label(
row = 1
column = 1
text = constant1).
lr_text = lr_grid->create_text(
row = 1
column = 2
text = variable1).
*... set label for text
lr_label->set_label_for( lr_text ).
lr_label = lr_grid->create_label(
row = 2
column = 1
text = text-003).
lr_text = lr_grid->create_text(
row = 2
column = 2
text = variable2).
*... set label for text
lr_label->set_label_for( lr_text ).
CALL METHOD cl_salv_form_content=>set
EXPORTING
value = lr_grid.
To 1: Declare the necessary type with reference to the used class locally (within FORM top_of_page or top_of_list).
To 2: Create the object which will be filled in part 3.
To 3: In this section, you need to define the exact data to be displayed and the layout / formatting of the same. The coding in BLACK is fixed – do not alter this code. The code in BLUE is variable and your action is needed here.
The „ lr_grid->create_label“ statement creates the label – usually at the beginning left of each line
The „lr_grid->create_text“ statement creates the text, which usually stand right to the label and specifies the label by a value
You can combine both as it is needed and as it’s making sense.
In „row“ and „column“ you enter the exact position of label or text. Attention: Elements will automatically aligned!
Example, 1st line: Label row 1, column 1 / Text row 1, column 2
Label and text will be automatically aligned by system. Please see label „abc“ and text „21“.
For „text“ please insert the formerly used data elements. They could be
- text element
- variable/constant
- internal table value ...
Do not use hard coded statements!
To 4: If your row contains label and text data, which belong together, please add this statement to link them.
To 5: If all your formatting is done, call the necessary method (cl_salv_form_content=>set ) with exactly the same coding as in the section 4.
Addition to 3: If an empty line is needed please use following statement:
*... create empty line.
lr_grid->add_row( ).
4 Coding and Functionality of “ALV Form” with header line / action item
If you need a header line and/or an action item, please cf. the example coding below:
DATA: lr_content TYPE REF TO cl_salv_form_element,
lr_outer_grid TYPE REF TO cl_salv_form_layout_grid,
lr_inner_grid TYPE REF TO cl_salv_form_layout_grid,
lr_flow TYPE REF TO cl_salv_form_layout_flow,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
lr_header TYPE REF TO cl_salv_form_header_info,
lr_action TYPE REF TO cl_salv_form_action_info.
*********************************************************************
* create OUTER_GRID as top_of_page object
*********************************************************************
CREATE OBJECT lr_outer_grid.
*********************************************************************
**... in the cell [1,1] of outer_grid a flow information is set
*********************************************************************
lr_flow = lr_outer_grid->create_flow(
row = 1
column = 1 ).
*.. create header information
lr_header = lr_flow->create_header_information(
text ='This a a long header line as flow information').
*********************************************************************
*... in the cell [2,1] of outer_grid grid information is set
*********************************************************************
lr_inner_grid = lr_outer_grid->create_grid(
row = 2
column = 1 ).
*... create empty line in inner_grid_
lr_inner_grid->add_row( ).
*... create lable information in inner_grid
lr_label = lr_inner_grid->create_label(
row = 2
column = 1
text = 'LABLE' ).
*... create text information in inner_grid
lr_text = lr_inner_grid->create_text(
row = 2
column = 2
text = 'Herr Mayer' ).
*... set label for text
lr_label->set_label_for( lr_text ).
*... create empty line in innner_grid
lr_inner_grid->add_row( ).
*********************************************************************
*... in the cell [3,1] of outer_grid low information is set
*********************************************************************
lr_flow = lr_outer_grid->create_flow(
row = 3
column = 1 ).
*... create action information
lr_action = lr_flow->create_action_information(
text ='Action in cell [3,1]').
*********************************************************************
*.. set content
*********************************************************************
lr_content = lr_outer_grid.
cl_salv_form_content=>set( lr_content ).
ENDFORM. "TOP_OF_PAGE
"
The ALV provides Events, which allows users to add information to the List at different rendering time points.
Goals of the ALV Form:
• UI independent information for rendering
• The information is displayed in agreement with the SAP agronomical guideline
The base Element of the ALV Form is the abstract class CL_SALV_FORM_ELEMENT.
This base Element (CL_SALV_FORM_ELEMENT) describes the information to be displayed. There are two major Element types:
• Layout Element (CL_SALV_FORM_ELEMENT_LAYOUT): the base layout element for describing a table or a flow of information
• Textual Element (CL_SALV_FORM_ELEMENT_TEXTUAL): the base element for text elements. Text Elements supported are:
o Label (CL_SALV_FORM_LABEL)
o Text (CL_SALV_FORM_TEXT)
o Header information (CL_SALV_FORM_HEADER_INFO)
o Action information (CL_SALV_FORM_ACTION_INFO)
2 Step-by-Step Description how to Replace
1) Have a look at the original output and ensure you that the converted output has the same lines and texts arrangements
2) Identify used ‘REUSE_ALV_COMMENTARY_WRITE’ calls within your programs, especially in the subroutines TOP_OF_PAGE (Grid) and TOP_OF_LIST (Simple List)
3) Comment the ‘REUSE_ALV_COMMENTARY_WRITE’
4) Search and comment all the used variables, subroutine / function module calls, text-elements and internal tables, which are used exclusively for the ‘REUSE_ALV_COMMENTARY_WRITE’ output.
5) Please insert the necessary coding and data-elements for “ALV Form”. This is done within the TOP_OF_PAGE subroutine for ALV GRID and in the TOP_OF_LIST subroutine for Simple List
6) Delete all unused (commented) variables, calls and tables (step 3&4).
7) ! Ensure that you have inserted all newly created text-elements for this process in your report documentation
8) Test the output and compare with the original one
3 Coding and Functionality of “ALV Form” (easy)
CREATE OBJECT lr_grid.
lr_label = lr_grid->create_label(
row = 1
column = 1
text = constant1).
lr_text = lr_grid->create_text(
row = 1
column = 2
text = variable1).
*... set label for text
lr_label->set_label_for( lr_text ).
lr_label = lr_grid->create_label(
row = 2
column = 1
text = text-003).
lr_text = lr_grid->create_text(
row = 2
column = 2
text = variable2).
*... set label for text
lr_label->set_label_for( lr_text ).
CALL METHOD cl_salv_form_content=>set
EXPORTING
value = lr_grid.
To 1: Declare the necessary type with reference to the used class locally (within FORM top_of_page or top_of_list).
To 2: Create the object which will be filled in part 3.
To 3: In this section, you need to define the exact data to be displayed and the layout / formatting of the same. The coding in BLACK is fixed – do not alter this code. The code in BLUE is variable and your action is needed here.
The „ lr_grid->create_label“ statement creates the label – usually at the beginning left of each line
The „lr_grid->create_text“ statement creates the text, which usually stand right to the label and specifies the label by a value
You can combine both as it is needed and as it’s making sense.
In „row“ and „column“ you enter the exact position of label or text. Attention: Elements will automatically aligned!
Example, 1st line: Label row 1, column 1 / Text row 1, column 2
Label and text will be automatically aligned by system. Please see label „abc“ and text „21“.
For „text“ please insert the formerly used data elements. They could be
- text element
- variable/constant
- internal table value ...
Do not use hard coded statements!
To 4: If your row contains label and text data, which belong together, please add this statement to link them.
To 5: If all your formatting is done, call the necessary method (cl_salv_form_content=>set ) with exactly the same coding as in the section 4.
Addition to 3: If an empty line is needed please use following statement:
*... create empty line.
lr_grid->add_row( ).
4 Coding and Functionality of “ALV Form” with header line / action item
If you need a header line and/or an action item, please cf. the example coding below:
DATA: lr_content TYPE REF TO cl_salv_form_element,
lr_outer_grid TYPE REF TO cl_salv_form_layout_grid,
lr_inner_grid TYPE REF TO cl_salv_form_layout_grid,
lr_flow TYPE REF TO cl_salv_form_layout_flow,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
lr_header TYPE REF TO cl_salv_form_header_info,
lr_action TYPE REF TO cl_salv_form_action_info.
*********************************************************************
* create OUTER_GRID as top_of_page object
*********************************************************************
CREATE OBJECT lr_outer_grid.
*********************************************************************
**... in the cell [1,1] of outer_grid a flow information is set
*********************************************************************
lr_flow = lr_outer_grid->create_flow(
row = 1
column = 1 ).
*.. create header information
lr_header = lr_flow->create_header_information(
text ='This a a long header line as flow information').
*********************************************************************
*... in the cell [2,1] of outer_grid grid information is set
*********************************************************************
lr_inner_grid = lr_outer_grid->create_grid(
row = 2
column = 1 ).
*... create empty line in inner_grid_
lr_inner_grid->add_row( ).
*... create lable information in inner_grid
lr_label = lr_inner_grid->create_label(
row = 2
column = 1
text = 'LABLE' ).
*... create text information in inner_grid
lr_text = lr_inner_grid->create_text(
row = 2
column = 2
text = 'Herr Mayer' ).
*... set label for text
lr_label->set_label_for( lr_text ).
*... create empty line in innner_grid
lr_inner_grid->add_row( ).
*********************************************************************
*... in the cell [3,1] of outer_grid low information is set
*********************************************************************
lr_flow = lr_outer_grid->create_flow(
row = 3
column = 1 ).
*... create action information
lr_action = lr_flow->create_action_information(
text ='Action in cell [3,1]').
*********************************************************************
*.. set content
*********************************************************************
lr_content = lr_outer_grid.
cl_salv_form_content=>set( lr_content ).
ENDFORM. "TOP_OF_PAGE
"
ALV WITH POV SAMPLE CODE
****EXECUTABLE PROGRAM ON ALV****
REPORT Y_MALVPOV .
****TABLE WORK AREA
TABLES:KNA1,VBAK.
***SELECTION SCREEN***
PARAMETERS:P_KUNNR LIKE KNA1-KUNNR DEFAULT 1001.
SELECT-OPTIONS:S_VBELN FOR VBAK-VBELN.
****DEFINE INTERNAL TABLE***
DATA:BEGIN OF IT_ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
END OF IT_ITAB.
***DEFINE INTERNAL TABLE WITH HEADER LINE****
DATA:IT_JTAB LIKE VBAK OCCURS 0 WITH HEADER LINE.
****PROVIDE TYPE GROUP***
TYPE-POOLS:SLIS.
***MAINTAIN REPORT ID***
DATA:REPID LIKE SY-REPID,
****DEFINE COLUMN HEADING****
VBAK_B TYPE SLIS_T_FIELDCAT_ALV,
****EVENT***
EVENTS_B TYPE SLIS_T_EVENT.
****VARIABLE FOR STORING VALUE***
DATA:IDEX TYPE I.
***FUNCTION MODULE COLUMN HEADINGS****
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'VBAK'
CHANGING
Ct_fieldcat = VBAK_B.
****REPORT ID SYSTEM VARIABLE****
REPID = SY-REPID.
****AT SELECTION SCREEN ****
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_VBELN-LOW.
*****FUNCTION MODULE FOR ADDING ZEROS AND DELETING THE ZEROS***
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = P_KUNNR
IMPORTING
OUTPUT = P_KUNNR.
****SELECT STATEMENT FOR OUTPUT DISPLAY***
SELECT VBELN FROM VBAK INTO TABLE IT_ITAB.
****FUNCTION MODULE FOR OUPUT DISPLAY***
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
endpos_col = 30
endpos_row = 30
startpos_col = 10
startpos_row = 10
titletext = 'SALES DETAILS'
IMPORTING
CHOISE = IDEX
tables
valuetab = IT_ITAB.
READ TABLE IT_ITAB INDEX IDEX.
S_VBELN-LOW = IT_ITAB-VBELN.
IF SY-SUBRC <> 0.
LEAVE.
ENDIF.
****START-OF-SELECTION EVENT***
START-OF-SELECTION.
SELECT * FROM VBAK INTO TABLE IT_JTAB WHERE VBELN = S_VBELN-LOW.
****FUNCTION MODULE OUTPUT DISPLAY***
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
IT_FIELDCAT = VBAK_B
IT_EVENTS = EVENTS_B
TABLES
t_outtab = IT_JTAB.
****END OF PROGRAM**
REPORT Y_MALVPOV .
****TABLE WORK AREA
TABLES:KNA1,VBAK.
***SELECTION SCREEN***
PARAMETERS:P_KUNNR LIKE KNA1-KUNNR DEFAULT 1001.
SELECT-OPTIONS:S_VBELN FOR VBAK-VBELN.
****DEFINE INTERNAL TABLE***
DATA:BEGIN OF IT_ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
END OF IT_ITAB.
***DEFINE INTERNAL TABLE WITH HEADER LINE****
DATA:IT_JTAB LIKE VBAK OCCURS 0 WITH HEADER LINE.
****PROVIDE TYPE GROUP***
TYPE-POOLS:SLIS.
***MAINTAIN REPORT ID***
DATA:REPID LIKE SY-REPID,
****DEFINE COLUMN HEADING****
VBAK_B TYPE SLIS_T_FIELDCAT_ALV,
****EVENT***
EVENTS_B TYPE SLIS_T_EVENT.
****VARIABLE FOR STORING VALUE***
DATA:IDEX TYPE I.
***FUNCTION MODULE COLUMN HEADINGS****
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'VBAK'
CHANGING
Ct_fieldcat = VBAK_B.
****REPORT ID SYSTEM VARIABLE****
REPID = SY-REPID.
****AT SELECTION SCREEN ****
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_VBELN-LOW.
*****FUNCTION MODULE FOR ADDING ZEROS AND DELETING THE ZEROS***
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = P_KUNNR
IMPORTING
OUTPUT = P_KUNNR.
****SELECT STATEMENT FOR OUTPUT DISPLAY***
SELECT VBELN FROM VBAK INTO TABLE IT_ITAB.
****FUNCTION MODULE FOR OUPUT DISPLAY***
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
endpos_col = 30
endpos_row = 30
startpos_col = 10
startpos_row = 10
titletext = 'SALES DETAILS'
IMPORTING
CHOISE = IDEX
tables
valuetab = IT_ITAB.
READ TABLE IT_ITAB INDEX IDEX.
S_VBELN-LOW = IT_ITAB-VBELN.
IF SY-SUBRC <> 0.
LEAVE.
ENDIF.
****START-OF-SELECTION EVENT***
START-OF-SELECTION.
SELECT * FROM VBAK INTO TABLE IT_JTAB WHERE VBELN = S_VBELN-LOW.
****FUNCTION MODULE OUTPUT DISPLAY***
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
IT_FIELDCAT = VBAK_B
IT_EVENTS = EVENTS_B
TABLES
t_outtab = IT_JTAB.
****END OF PROGRAM**
ALV HIRACHICAL REPORT SAMPLE CODE
TYPE-POOLS: slis.
TABLES : ekko, ekpo.
DATA : BEGIN OF i_ekko OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
var1,
END OF i_ekko.
DATA : BEGIN OF i_ekpo OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
var2,
END OF i_ekpo.
DATA : BEGIN OF i_final OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
END OF i_final.
SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN.
DATA : fcat TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
* fcat1 TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
cat TYPE slis_fieldcat_alv. "FIELDCATALOG(WORK AREA)
DATA : LAYOUT1 TYPE SLIS_LAYOUT_ALV, "LAYOUT 1
* LAYOUT2 TYPE SLIS_LAYOUT_ALV, "LAYOUT 2
KEY TYPE SLIS_KEYINFO_ALV , "KEY INFORMATION
GT_EVENT1 TYPE SLIS_T_EVENT.
START-OF-SELECTION.
PERFORM GETTING_DATA.
PERFORM append_field.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT = LAYOUT1
IT_FIELDCAT = FCAT
* IT_EVENTS = GT_EVENT1
i_tabname_header = 'I_EKKO'
i_tabname_item = 'I_EKPO'
is_keyinfo = KEY
tables
t_outtab_header = I_EKKO
t_outtab_item = I_EKPO.
*&---------------------------------------------------------------------
*
*& Form GETTING_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM GETTING_DATA . SELECT EBELN BSART ERNAM UP TO 100 ROWS INTO CORRESPONDING FIELDS OF TABLE I_EKKO FROM EKKO WHERE EBELN IN S_EBELN. SELECT EBELN EBELP MATNR AEDAT INTO CORRESPONDING FIELDS OF TABLE I_EKPO FROM EKPO FOR ALL ENTRIES IN I_EKKO WHERE EBELN = I_EKKO-EBELN . SORT I_EKKO BY EBELN. LOOP AT I_EKKO. READ TABLE I_EKPO WITH KEY EBELN = I_EKKO-EBELN. IF SY-SUBRC EQ 0. MOVE: I_EKKO-EBELN TO I_FINAL-EBELN, I_EKKO-BSART TO I_FINAL-BSART, I_EKKO-ERNAM TO I_FINAL-ERNAM, I_EKPO-EBELP TO I_FINAL-EBELP, I_EKPO-MATNR TO I_FINAL-MATNR, I_EKPO-AEDAT TO I_FINAL-AEDAT. APPEND I_FINAL. ENDIF. ENDLOOP. ENDFORM. " GETTING_DATA *&---------------------------------------------------------------------* *& Form APPEND_FIELD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM append_field . CLEAR cat. cat-col_pos = 1. cat-fieldname = 'EBELN'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'EBELN'. cat-ref_tabname = 'EKKO'. cat-key = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 2. cat-fieldname = 'BSART'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'BSART'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 3. cat-fieldname = 'ERNAM'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'ERNAM'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 4. cat-fieldname = 'EBELP'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'EBELP'. cat-ref_tabname = 'EKPO'. cat-key = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 5. cat-fieldname = 'MATNR'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'MATNR'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 6. cat-fieldname = 'AEDAT'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'AEDAT'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat. CLEAR cat. layout1-expand_fieldname = 'VAR1'. layout1-lights_fieldname = '3'. layout1-lights_tabname = 'I_EKPO'. key-header01 = 'EBELN'. key-item01 = 'EBELN'. ENDFORM. " APPEND_FIELD
TABLES : ekko, ekpo.
DATA : BEGIN OF i_ekko OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
var1,
END OF i_ekko.
DATA : BEGIN OF i_ekpo OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
var2,
END OF i_ekpo.
DATA : BEGIN OF i_final OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
END OF i_final.
SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN.
DATA : fcat TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
* fcat1 TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
cat TYPE slis_fieldcat_alv. "FIELDCATALOG(WORK AREA)
DATA : LAYOUT1 TYPE SLIS_LAYOUT_ALV, "LAYOUT 1
* LAYOUT2 TYPE SLIS_LAYOUT_ALV, "LAYOUT 2
KEY TYPE SLIS_KEYINFO_ALV , "KEY INFORMATION
GT_EVENT1 TYPE SLIS_T_EVENT.
START-OF-SELECTION.
PERFORM GETTING_DATA.
PERFORM append_field.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT = LAYOUT1
IT_FIELDCAT = FCAT
* IT_EVENTS = GT_EVENT1
i_tabname_header = 'I_EKKO'
i_tabname_item = 'I_EKPO'
is_keyinfo = KEY
tables
t_outtab_header = I_EKKO
t_outtab_item = I_EKPO.
*&---------------------------------------------------------------------
*
*& Form GETTING_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM GETTING_DATA . SELECT EBELN BSART ERNAM UP TO 100 ROWS INTO CORRESPONDING FIELDS OF TABLE I_EKKO FROM EKKO WHERE EBELN IN S_EBELN. SELECT EBELN EBELP MATNR AEDAT INTO CORRESPONDING FIELDS OF TABLE I_EKPO FROM EKPO FOR ALL ENTRIES IN I_EKKO WHERE EBELN = I_EKKO-EBELN . SORT I_EKKO BY EBELN. LOOP AT I_EKKO. READ TABLE I_EKPO WITH KEY EBELN = I_EKKO-EBELN. IF SY-SUBRC EQ 0. MOVE: I_EKKO-EBELN TO I_FINAL-EBELN, I_EKKO-BSART TO I_FINAL-BSART, I_EKKO-ERNAM TO I_FINAL-ERNAM, I_EKPO-EBELP TO I_FINAL-EBELP, I_EKPO-MATNR TO I_FINAL-MATNR, I_EKPO-AEDAT TO I_FINAL-AEDAT. APPEND I_FINAL. ENDIF. ENDLOOP. ENDFORM. " GETTING_DATA *&---------------------------------------------------------------------* *& Form APPEND_FIELD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM append_field . CLEAR cat. cat-col_pos = 1. cat-fieldname = 'EBELN'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'EBELN'. cat-ref_tabname = 'EKKO'. cat-key = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 2. cat-fieldname = 'BSART'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'BSART'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 3. cat-fieldname = 'ERNAM'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'ERNAM'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 4. cat-fieldname = 'EBELP'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'EBELP'. cat-ref_tabname = 'EKPO'. cat-key = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 5. cat-fieldname = 'MATNR'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'MATNR'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 6. cat-fieldname = 'AEDAT'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'AEDAT'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat. CLEAR cat. layout1-expand_fieldname = 'VAR1'. layout1-lights_fieldname = '3'. layout1-lights_tabname = 'I_EKPO'. key-header01 = 'EBELN'. key-item01 = 'EBELN'. ENDFORM. " APPEND_FIELD
ALV LIST DISPLAY SAMPLE CODE
TYPE-POOLS:SLIS.
TABLES:EKKO.
SELECT-OPTIONS:SO_EBELN FOR EKKO-EBELN.
DATA:BEGIN OF IT_EKKO OCCURS 0,
EBELN LIKE EKKO-EBELN, "PURCHASE DOCUMENT NUMBER
BUKRS LIKE EKKO-BUKRS, "COMPANY CODE
BSTYP LIKE EKKO-BSTYP, "PURCHASE DOCUMENT CATEGORY
BSART LIKE EKKO-BSART, "PUCHASE DOCUMENT TYPE
END OF IT_EKKO.
*FIELD CATALOG TABLE DECLARATION.
DATA:I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
* I_EVENTCAT TYPE SLIS_T_EVENT WITH HEADER LINE.
START-OF-SELECTION.
*INTERNAL TABLE POPULATION
SELECT EBELN
BUKRS
BSTYP
BSART
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN SO_EBELN.
*POPULATING FIELD CATALOG USING FIELDS IN FIELDCATALOG
*I_FIELDCAT-COL_POS = 1.
*I_FIELDCAT-FIELDNAME = 'EBELN'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'EBELN'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'PURCHAGE DOCUMENT NUMBER'.
*I_FIELDCAT-OUTPUTLEN = 20.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = 'X'.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 2.
*I_FIELDCAT-FIELDNAME = 'BUKRS'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BUKRS'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C610'.
*I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = ''.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 3.
*I_FIELDCAT-FIELDNAME = 'BSTYP'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BSTYP'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'DOCUMENT CATEGORY'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 4.
*I_FIELDCAT-FIELDNAME = 'BSART'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BSART'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'DOCUMENT TYPE'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*
*
*POPULATING FIELD CATALOG BY USING FUNCTION MODULE
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-CPROG
I_INTERNAL_TABNAME = 'IT_EKKO'
I_INCLNAME = SY-CPROG
CHANGING
ct_fieldcat = I_FIELDCAT[].
*DISPLAYING REPORT AS ALV LIST
*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
* EXPORTING
* I_CALLBACK_PROGRAM = SY-CPROG
* IT_FIELDCAT = I_FIELDCAT[]
* TABLES
* t_outtab = IT_EKKO.
**
*DISPLAYING REPORT AS ALV GRID
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = I_FIELDCAT[]
TABLES
t_outtab = IT_EKKO
TABLES:EKKO.
SELECT-OPTIONS:SO_EBELN FOR EKKO-EBELN.
DATA:BEGIN OF IT_EKKO OCCURS 0,
EBELN LIKE EKKO-EBELN, "PURCHASE DOCUMENT NUMBER
BUKRS LIKE EKKO-BUKRS, "COMPANY CODE
BSTYP LIKE EKKO-BSTYP, "PURCHASE DOCUMENT CATEGORY
BSART LIKE EKKO-BSART, "PUCHASE DOCUMENT TYPE
END OF IT_EKKO.
*FIELD CATALOG TABLE DECLARATION.
DATA:I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
* I_EVENTCAT TYPE SLIS_T_EVENT WITH HEADER LINE.
START-OF-SELECTION.
*INTERNAL TABLE POPULATION
SELECT EBELN
BUKRS
BSTYP
BSART
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN SO_EBELN.
*POPULATING FIELD CATALOG USING FIELDS IN FIELDCATALOG
*I_FIELDCAT-COL_POS = 1.
*I_FIELDCAT-FIELDNAME = 'EBELN'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'EBELN'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'PURCHAGE DOCUMENT NUMBER'.
*I_FIELDCAT-OUTPUTLEN = 20.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = 'X'.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 2.
*I_FIELDCAT-FIELDNAME = 'BUKRS'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BUKRS'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C610'.
*I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = ''.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 3.
*I_FIELDCAT-FIELDNAME = 'BSTYP'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BSTYP'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'DOCUMENT CATEGORY'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 4.
*I_FIELDCAT-FIELDNAME = 'BSART'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BSART'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'DOCUMENT TYPE'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*
*
*POPULATING FIELD CATALOG BY USING FUNCTION MODULE
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-CPROG
I_INTERNAL_TABNAME = 'IT_EKKO'
I_INCLNAME = SY-CPROG
CHANGING
ct_fieldcat = I_FIELDCAT[].
*DISPLAYING REPORT AS ALV LIST
*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
* EXPORTING
* I_CALLBACK_PROGRAM = SY-CPROG
* IT_FIELDCAT = I_FIELDCAT[]
* TABLES
* t_outtab = IT_EKKO.
**
*DISPLAYING REPORT AS ALV GRID
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = I_FIELDCAT[]
TABLES
t_outtab = IT_EKKO
ALV LAYOUT DISPLAY SAMPLE CODE
TYPE-POOLS:slis.
TABLES:ekko.
SELECT-OPTIONS:so_ebeln FOR ekko-ebeln.
PARAMETERS: VARIANT LIKE DISVARIANT-VARIANT.
DATA:BEGIN OF it_ekko OCCURS 0,
ebeln LIKE ekko-ebeln, "PURCHASE DOCUMENT NUMBER
bukrs LIKE ekko-bukrs, "COMPANY CODE
bstyp LIKE ekko-bstyp, "PURCHASE DOCUMENT CATEGORY
bsart LIKE ekko-bsart, "PUCHASE DOCUMENT TYPE
END OF it_ekko.
*FIELD CATALOG AND EVENT CATALOG TABLE DECLARATION.
DATA:i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_eventcat TYPE slis_t_event WITH HEADER LINE,
I_LAYOUT TYPE SLIS_LAYOUT_ALV .
* ZDLAYOUT1 TYPE SLIS_LAYOUT_ALV .
DATA:W_VARIANT LIKE DISVARIANT,
W_VARIANT1 LIKE DISVARIANT.
INITIALIZATION.
MOVE: SY-REPID TO W_VARIANT-REPORT,
SY-REPID TO W_VARIANT1-REPORT.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = 'A'
CHANGING
cs_variant = W_VARIANT.
MOVE W_VARIANT-VARIANT TO w_VARIANT1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR VARIANT.
DATA: L_EXIT.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = W_VARIANT1
* I_TABNAME_HEADER =
* I_TABNAME_ITEM =
* IT_DEFAULT_FIELDCAT =
* I_SAVE = 'A'
* I_DISPLAY_VIA_GRID = ' '
IMPORTING
E_EXIT = L_EXIT
ES_VARIANT = W_VARIANT.
START-OF-SELECTION.
*INTERNAL TABLE POPULATION
SELECT ebeln
bukrs
bstyp
bsart
FROM ekko
INTO TABLE it_ekko
WHERE ebeln IN so_ebeln.
*POPULATING FIELD CATALOG BY USING FUNCTION MODULE
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-cprog
i_internal_tabname = 'IT_EKKO'
i_inclname = sy-cprog
CHANGING
ct_fieldcat = i_fieldcat[].
*DISPLAYING ALV GRID WITH MULTIPLE LAYOUTSETS
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT = 'ZDLAYOUT1'
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A' "'U' "'X'
* IS_VARIANT = VARIANT
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = IT_EKKO.
TABLES:ekko.
SELECT-OPTIONS:so_ebeln FOR ekko-ebeln.
PARAMETERS: VARIANT LIKE DISVARIANT-VARIANT.
DATA:BEGIN OF it_ekko OCCURS 0,
ebeln LIKE ekko-ebeln, "PURCHASE DOCUMENT NUMBER
bukrs LIKE ekko-bukrs, "COMPANY CODE
bstyp LIKE ekko-bstyp, "PURCHASE DOCUMENT CATEGORY
bsart LIKE ekko-bsart, "PUCHASE DOCUMENT TYPE
END OF it_ekko.
*FIELD CATALOG AND EVENT CATALOG TABLE DECLARATION.
DATA:i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_eventcat TYPE slis_t_event WITH HEADER LINE,
I_LAYOUT TYPE SLIS_LAYOUT_ALV .
* ZDLAYOUT1 TYPE SLIS_LAYOUT_ALV .
DATA:W_VARIANT LIKE DISVARIANT,
W_VARIANT1 LIKE DISVARIANT.
INITIALIZATION.
MOVE: SY-REPID TO W_VARIANT-REPORT,
SY-REPID TO W_VARIANT1-REPORT.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = 'A'
CHANGING
cs_variant = W_VARIANT.
MOVE W_VARIANT-VARIANT TO w_VARIANT1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR VARIANT.
DATA: L_EXIT.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = W_VARIANT1
* I_TABNAME_HEADER =
* I_TABNAME_ITEM =
* IT_DEFAULT_FIELDCAT =
* I_SAVE = 'A'
* I_DISPLAY_VIA_GRID = ' '
IMPORTING
E_EXIT = L_EXIT
ES_VARIANT = W_VARIANT.
START-OF-SELECTION.
*INTERNAL TABLE POPULATION
SELECT ebeln
bukrs
bstyp
bsart
FROM ekko
INTO TABLE it_ekko
WHERE ebeln IN so_ebeln.
*POPULATING FIELD CATALOG BY USING FUNCTION MODULE
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-cprog
i_internal_tabname = 'IT_EKKO'
i_inclname = sy-cprog
CHANGING
ct_fieldcat = i_fieldcat[].
*DISPLAYING ALV GRID WITH MULTIPLE LAYOUTSETS
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT = 'ZDLAYOUT1'
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A' "'U' "'X'
* IS_VARIANT = VARIANT
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = IT_EKKO.
ALV BLOCK SAMPLE REPORT
TYPE-POOLS: slis.
TABLES : ekko, ekpo.
DATA : BEGIN OF i_ekko OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
var1,
END OF i_ekko.
DATA : BEGIN OF i_ekpo OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
var2,
END OF i_ekpo.
DATA : BEGIN OF i_final OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
END OF i_final.
SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN.
DATA : fcat TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
fcat1 TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
cat TYPE slis_fieldcat_alv. "FIELDCATALOG(WORK AREA)
DATA : LAYOUT1 TYPE SLIS_LAYOUT_ALV, "LAYOUT 1
LAYOUT2 TYPE SLIS_LAYOUT_ALV, "LAYOUT 2
KEY TYPE SLIS_KEYINFO_ALV , "KEY INFORMATION
GT_EVENT1 TYPE SLIS_T_EVENT.
PERFORM GETTING_DATA.
PERFORM append_field.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = 'ZD_ALV_BLOCK_DISPLAY'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT1
IT_FIELDCAT = FCAT
I_TABNAME = 'I_EKKO'
IT_EVENTS = GT_EVENT1
I_TEXT = 'HEADER BLOCK'
TABLES
T_OUTTAB = I_EKKO.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT2
IT_FIELDCAT = FCAT1
I_TABNAME = 'I_EKPO'
IT_EVENTS = GT_EVENT1
I_TEXT = 'ITEMS BLOCK'
TABLES
T_OUTTAB = I_EKPO.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
*&---------------------------------------------------------------------
*
*& Form GETTING_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM GETTING_DATA . SELECT EBELN BSART ERNAM UP TO 100 ROWS INTO CORRESPONDING FIELDS OF TABLE I_EKKO FROM EKKO WHERE EBELN IN S_EBELN. SELECT EBELN EBELP MATNR AEDAT INTO CORRESPONDING FIELDS OF TABLE I_EKPO FROM EKPO FOR ALL ENTRIES IN I_EKKO WHERE EBELN = I_EKKO-EBELN . SORT I_EKKO BY EBELN. LOOP AT I_EKKO. READ TABLE I_EKPO WITH KEY EBELN = I_EKKO-EBELN. IF SY-SUBRC EQ 0. MOVE: I_EKKO-EBELN TO I_FINAL-EBELN, I_EKKO-BSART TO I_FINAL-BSART, I_EKKO-ERNAM TO I_FINAL-ERNAM, I_EKPO-EBELP TO I_FINAL-EBELP, I_EKPO-MATNR TO I_FINAL-MATNR, I_EKPO-AEDAT TO I_FINAL-AEDAT. APPEND I_FINAL. ENDIF. ENDLOOP. ENDFORM. " GETTING_DATA *&---------------------------------------------------------------------* *& Form APPEND_FIELD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM append_field . CLEAR cat. cat-col_pos = 1. cat-fieldname = 'EBELN'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'EBELN'. cat-ref_tabname = 'EKKO'. cat-key = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 2. cat-fieldname = 'BSART'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'BSART'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 3. cat-fieldname = 'ERNAM'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'ERNAM'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 4. cat-fieldname = 'EBELP'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'EBELP'. cat-ref_tabname = 'EKPO'. cat-key_SEL = 'X'. "define field as key APPEND cat TO fcat1. CLEAR cat. cat-col_pos = 5. cat-fieldname = 'MATNR'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'MATNR'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat1. CLEAR cat. cat-col_pos = 6. cat-fieldname = 'AEDAT'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'AEDAT'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat1. CLEAR cat. ENDFORM. " APPEND_FIELD
TABLES : ekko, ekpo.
DATA : BEGIN OF i_ekko OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
var1,
END OF i_ekko.
DATA : BEGIN OF i_ekpo OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
var2,
END OF i_ekpo.
DATA : BEGIN OF i_final OCCURS 0,
ebeln LIKE ekko-ebeln,
ernam LIKE ekko-ernam,
bsart LIKE ekko-bsart,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
aedat LIKE ekpo-aedat,
END OF i_final.
SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN.
DATA : fcat TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
fcat1 TYPE slis_t_fieldcat_alv, "FIELDCATALOG(TABLE)
cat TYPE slis_fieldcat_alv. "FIELDCATALOG(WORK AREA)
DATA : LAYOUT1 TYPE SLIS_LAYOUT_ALV, "LAYOUT 1
LAYOUT2 TYPE SLIS_LAYOUT_ALV, "LAYOUT 2
KEY TYPE SLIS_KEYINFO_ALV , "KEY INFORMATION
GT_EVENT1 TYPE SLIS_T_EVENT.
PERFORM GETTING_DATA.
PERFORM append_field.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = 'ZD_ALV_BLOCK_DISPLAY'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT1
IT_FIELDCAT = FCAT
I_TABNAME = 'I_EKKO'
IT_EVENTS = GT_EVENT1
I_TEXT = 'HEADER BLOCK'
TABLES
T_OUTTAB = I_EKKO.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = LAYOUT2
IT_FIELDCAT = FCAT1
I_TABNAME = 'I_EKPO'
IT_EVENTS = GT_EVENT1
I_TEXT = 'ITEMS BLOCK'
TABLES
T_OUTTAB = I_EKPO.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
*&---------------------------------------------------------------------
*
*& Form GETTING_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM GETTING_DATA . SELECT EBELN BSART ERNAM UP TO 100 ROWS INTO CORRESPONDING FIELDS OF TABLE I_EKKO FROM EKKO WHERE EBELN IN S_EBELN. SELECT EBELN EBELP MATNR AEDAT INTO CORRESPONDING FIELDS OF TABLE I_EKPO FROM EKPO FOR ALL ENTRIES IN I_EKKO WHERE EBELN = I_EKKO-EBELN . SORT I_EKKO BY EBELN. LOOP AT I_EKKO. READ TABLE I_EKPO WITH KEY EBELN = I_EKKO-EBELN. IF SY-SUBRC EQ 0. MOVE: I_EKKO-EBELN TO I_FINAL-EBELN, I_EKKO-BSART TO I_FINAL-BSART, I_EKKO-ERNAM TO I_FINAL-ERNAM, I_EKPO-EBELP TO I_FINAL-EBELP, I_EKPO-MATNR TO I_FINAL-MATNR, I_EKPO-AEDAT TO I_FINAL-AEDAT. APPEND I_FINAL. ENDIF. ENDLOOP. ENDFORM. " GETTING_DATA *&---------------------------------------------------------------------* *& Form APPEND_FIELD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM append_field . CLEAR cat. cat-col_pos = 1. cat-fieldname = 'EBELN'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'EBELN'. cat-ref_tabname = 'EKKO'. cat-key = 'X'. "define field as key APPEND cat TO fcat. CLEAR cat. cat-col_pos = 2. cat-fieldname = 'BSART'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'BSART'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 3. cat-fieldname = 'ERNAM'. cat-tabname = 'I_EKKO'. cat-ref_fieldname = 'ERNAM'. cat-ref_tabname = 'EKKO'. APPEND cat TO fcat. CLEAR cat. cat-col_pos = 4. cat-fieldname = 'EBELP'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'EBELP'. cat-ref_tabname = 'EKPO'. cat-key_SEL = 'X'. "define field as key APPEND cat TO fcat1. CLEAR cat. cat-col_pos = 5. cat-fieldname = 'MATNR'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'MATNR'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat1. CLEAR cat. cat-col_pos = 6. cat-fieldname = 'AEDAT'. cat-tabname = 'I_EKPO'. cat-ref_fieldname = 'AEDAT'. cat-ref_tabname = 'EKPO'. APPEND cat TO fcat1. CLEAR cat. ENDFORM. " APPEND_FIELD
ALV CHECK BOXES SAMPLE CODE
REPORT zalv5 NO STANDARD PAGE HEADING.
*Description-----------------------------------------------------------*
* TOPICS INTRODUCED:
* 1. Learn about the ‘Standard’ PF-Status that comes as default.
* 2. Exclude function codes from ‘Standard’ PF-Status and customize it.
*----------------------------------------------------------------------*
TYPE-POOLS: slis.
DATA: BEGIN OF i_data OCCURS 0,
qmnum LIKE qmel-qmnum,
qmart LIKE qmel-qmart,
qmtxt LIKE qmel-qmtxt,
ws_row TYPE i,
ws_char(5) TYPE c,
chk,
END OF i_data.
DATA: report_id LIKE sy-repid.
DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
DATA: i_layout TYPE slis_layout_alv.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: i_events TYPE slis_t_event.
DATA: i_header TYPE slis_t_listheader.
DATA: i_extab TYPE slis_t_extab.
SELECT qmnum
qmart
qmtxt
INTO TABLE i_data
FROM qmel
WHERE qmnum <= '00030000010'. LOOP AT i_data. i_data-ws_row = sy-tabix. i_data-ws_char = 'AAAAA'. MODIFY i_data. ENDLOOP. report_id = sy-repid. PERFORM f1000_layout_init CHANGING i_layout. PERFORM f2000_fieldcat_init CHANGING i_fieldcat. PERFORM f3000_build_header CHANGING i_header. PERFORM f4000_events_init CHANGING i_events. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * i_structure_name = ' ' * I_BACKGROUND_ID = ' ' i_grid_title = ws_title * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = it_events = i_events * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_data 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 F1000_Layout_Init
*&---------------------------------------------------------------------*
FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
CLEAR i_layout.
i_layout-colwidth_optimize = 'X'.
i_layout-edit = 'X'.
ENDFORM. " F1000_Layout_Init
*&---------------------------------------------------------------------*
*& Form f2000_fieldcat_init
*&---------------------------------------------------------------------*
FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: line_fieldcat TYPE slis_fieldcat_alv.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMNUM'. " The field name and the table
line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
line_fieldcat-seltext_m = 'Notification No.'. " Column Header
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMART'.
line_fieldcat-ref_tabname = 'I_DATA'.
line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
line_fieldcat-seltext_m = 'Notif Type'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMTXT'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Description'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_ROW'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Row Number'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_CHAR'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Test Character Field'.
line_fieldcat-datatype = 'CHAR'.
line_fieldcat-outputlen = '15'. " You can specify the width of a
APPEND line_fieldcat TO i_fieldcat. " column.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'CHK'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Checkbox'.
line_fieldcat-checkbox = 'X'. " Display this field as a checkbox
line_fieldcat-edit = 'X'. " This option ensures that you can
" edit the checkbox. Else it will
" be protected.
APPEND line_fieldcat TO i_fieldcat.
ENDFORM. " f2000_fieldcat_init
*&---------------------------------------------------------------------*
*& Form f3000_build_header
*&---------------------------------------------------------------------*
FORM f3000_build_header USING i_header TYPE slis_t_listheader.
DATA: gs_line TYPE slis_listheader.
CLEAR gs_line.
gs_line-typ = 'H'.
gs_line-info = 'This is line of type HEADER'.
APPEND gs_line TO i_header.
CLEAR gs_line.
gs_line-typ = 'S'.
gs_line-key = 'STATUS 1'.
gs_line-info = 'This is line of type STATUS'.
APPEND gs_line TO i_header.
gs_line-key = 'STATUS 2'.
gs_line-info = 'This is also line of type STATUS'.
APPEND gs_line TO i_header.
CLEAR gs_line.
gs_line-typ = 'A'.
gs_line-info = 'This is line of type ACTION'.
APPEND gs_line TO i_header.
ENDFORM. " f3000_build_header
*&---------------------------------------------------------------------*
*& Form f4000_events_init
*&---------------------------------------------------------------------*
FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
DATA: line_event TYPE slis_alv_event.
CLEAR line_event.
line_event-name = 'TOP_OF_PAGE'.
line_event-form = 'F4100_TOP_OF_PAGE'.
APPEND line_event TO i_events.
CLEAR line_event.
line_event-name = 'PF_STATUS_SET'.
line_event-form = 'F4200_PF_STATUS_SET'.
APPEND line_event TO i_events.
ENDFORM. " f3000_events_init
*---------------------------------------------------------------------*
* FORM F4100_TOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM f4100_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_header.
ENDFORM.
*---------------------------------------------------------------------*
* FORM F4200_PF_STATUS_SET *
*---------------------------------------------------------------------*
FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
REFRESH i_extab.
PERFORM f4210_exclude_fcodes CHANGING i_extab.
SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV' EXCLUDING i_extab.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form f4210_exclude_fcodes
*&---------------------------------------------------------------------*
FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
DATA: ws_fcode TYPE slis_extab.
CLEAR ws_fcode.
ws_fcode = '&EB9'. " Call up Report.
APPEND ws_fcode TO i_extab.
ws_fcode = '&ABC'. " ABC Analysis.
APPEND ws_fcode TO i_extab.
ws_fcode = '&NFO'. " Info Select.
APPEND ws_fcode TO i_extab.
ws_fcode = '&LFO'. " Information.
APPEND ws_fcode TO i_extab.
ENDFORM. " f4210_exclude_fcodes
*Description-----------------------------------------------------------*
* TOPICS INTRODUCED:
* 1. Learn about the ‘Standard’ PF-Status that comes as default.
* 2. Exclude function codes from ‘Standard’ PF-Status and customize it.
*----------------------------------------------------------------------*
TYPE-POOLS: slis.
DATA: BEGIN OF i_data OCCURS 0,
qmnum LIKE qmel-qmnum,
qmart LIKE qmel-qmart,
qmtxt LIKE qmel-qmtxt,
ws_row TYPE i,
ws_char(5) TYPE c,
chk,
END OF i_data.
DATA: report_id LIKE sy-repid.
DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
DATA: i_layout TYPE slis_layout_alv.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: i_events TYPE slis_t_event.
DATA: i_header TYPE slis_t_listheader.
DATA: i_extab TYPE slis_t_extab.
SELECT qmnum
qmart
qmtxt
INTO TABLE i_data
FROM qmel
WHERE qmnum <= '00030000010'. LOOP AT i_data. i_data-ws_row = sy-tabix. i_data-ws_char = 'AAAAA'. MODIFY i_data. ENDLOOP. report_id = sy-repid. PERFORM f1000_layout_init CHANGING i_layout. PERFORM f2000_fieldcat_init CHANGING i_fieldcat. PERFORM f3000_build_header CHANGING i_header. PERFORM f4000_events_init CHANGING i_events. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * i_structure_name = ' ' * I_BACKGROUND_ID = ' ' i_grid_title = ws_title * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = it_events = i_events * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_data 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 F1000_Layout_Init
*&---------------------------------------------------------------------*
FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
CLEAR i_layout.
i_layout-colwidth_optimize = 'X'.
i_layout-edit = 'X'.
ENDFORM. " F1000_Layout_Init
*&---------------------------------------------------------------------*
*& Form f2000_fieldcat_init
*&---------------------------------------------------------------------*
FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: line_fieldcat TYPE slis_fieldcat_alv.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMNUM'. " The field name and the table
line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
line_fieldcat-seltext_m = 'Notification No.'. " Column Header
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMART'.
line_fieldcat-ref_tabname = 'I_DATA'.
line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
line_fieldcat-seltext_m = 'Notif Type'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMTXT'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Description'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_ROW'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Row Number'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_CHAR'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Test Character Field'.
line_fieldcat-datatype = 'CHAR'.
line_fieldcat-outputlen = '15'. " You can specify the width of a
APPEND line_fieldcat TO i_fieldcat. " column.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'CHK'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Checkbox'.
line_fieldcat-checkbox = 'X'. " Display this field as a checkbox
line_fieldcat-edit = 'X'. " This option ensures that you can
" edit the checkbox. Else it will
" be protected.
APPEND line_fieldcat TO i_fieldcat.
ENDFORM. " f2000_fieldcat_init
*&---------------------------------------------------------------------*
*& Form f3000_build_header
*&---------------------------------------------------------------------*
FORM f3000_build_header USING i_header TYPE slis_t_listheader.
DATA: gs_line TYPE slis_listheader.
CLEAR gs_line.
gs_line-typ = 'H'.
gs_line-info = 'This is line of type HEADER'.
APPEND gs_line TO i_header.
CLEAR gs_line.
gs_line-typ = 'S'.
gs_line-key = 'STATUS 1'.
gs_line-info = 'This is line of type STATUS'.
APPEND gs_line TO i_header.
gs_line-key = 'STATUS 2'.
gs_line-info = 'This is also line of type STATUS'.
APPEND gs_line TO i_header.
CLEAR gs_line.
gs_line-typ = 'A'.
gs_line-info = 'This is line of type ACTION'.
APPEND gs_line TO i_header.
ENDFORM. " f3000_build_header
*&---------------------------------------------------------------------*
*& Form f4000_events_init
*&---------------------------------------------------------------------*
FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
DATA: line_event TYPE slis_alv_event.
CLEAR line_event.
line_event-name = 'TOP_OF_PAGE'.
line_event-form = 'F4100_TOP_OF_PAGE'.
APPEND line_event TO i_events.
CLEAR line_event.
line_event-name = 'PF_STATUS_SET'.
line_event-form = 'F4200_PF_STATUS_SET'.
APPEND line_event TO i_events.
ENDFORM. " f3000_events_init
*---------------------------------------------------------------------*
* FORM F4100_TOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM f4100_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_header.
ENDFORM.
*---------------------------------------------------------------------*
* FORM F4200_PF_STATUS_SET *
*---------------------------------------------------------------------*
FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
REFRESH i_extab.
PERFORM f4210_exclude_fcodes CHANGING i_extab.
SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV' EXCLUDING i_extab.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form f4210_exclude_fcodes
*&---------------------------------------------------------------------*
FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
DATA: ws_fcode TYPE slis_extab.
CLEAR ws_fcode.
ws_fcode = '&EB9'. " Call up Report.
APPEND ws_fcode TO i_extab.
ws_fcode = '&ABC'. " ABC Analysis.
APPEND ws_fcode TO i_extab.
ws_fcode = '&NFO'. " Info Select.
APPEND ws_fcode TO i_extab.
ws_fcode = '&LFO'. " Information.
APPEND ws_fcode TO i_extab.
ENDFORM. " f4210_exclude_fcodes
ALV INTERACTIVE REPORT SAMPLE CODE
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
* declaration for events table where user comand or set PF status will
* be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
* declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
* declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
* Fieldcatalog has all the field details from ekko
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
*& Form EVENT_CALL
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "EVENT_CALL
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form data_retrieval
*&--------------------------------------------------------------------*
* retreiving values from the database table ekko
*---------------------------------------------------------------------*
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*&--------------------------------------------------------------------*
*& Form bUild_listheader
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->I_LISTHEADEtext
*---------------------------------------------------------------------*
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*&--------------------------------------------------------------------*
*& Form display_alv_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
* I_GRID_SETTINGS =
* IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'ZLAY1'
I_SAVE = 'A'
* is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
* 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. "display_alv_report
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
*& Form event_call_ekpo
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "event_call_ekpo
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT =
I_SAVE = 'A'
* IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
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.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
* declaration for events table where user comand or set PF status will
* be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
* declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
* declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
* Fieldcatalog has all the field details from ekko
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
*& Form EVENT_CALL
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "EVENT_CALL
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form data_retrieval
*&--------------------------------------------------------------------*
* retreiving values from the database table ekko
*---------------------------------------------------------------------*
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*&--------------------------------------------------------------------*
*& Form bUild_listheader
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->I_LISTHEADEtext
*---------------------------------------------------------------------*
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*&--------------------------------------------------------------------*
*& Form display_alv_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
* I_GRID_SETTINGS =
* IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'ZLAY1'
I_SAVE = 'A'
* is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
* 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. "display_alv_report
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
*& Form event_call_ekpo
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "event_call_ekpo
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT =
I_SAVE = 'A'
* IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
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.
ALV DOUBLE CLICK SAMPLE CODE
REPORT ALVINTERSAMPLE NO STANDARD PAGE HEADING LINE-SIZE 650.
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
* declaration for events table where user comand or set PF status will
* be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
* declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
* declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
* Fieldcatalog has all the field details from ekko
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
*& Form EVENT_CALL
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "EVENT_CALL
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form data_retrieval
*&--------------------------------------------------------------------*
* retreiving values from the database table ekko
*---------------------------------------------------------------------*
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*&--------------------------------------------------------------------*
*& Form bUild_listheader
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->I_LISTHEADEtext
*---------------------------------------------------------------------*
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*&--------------------------------------------------------------------*
*& Form display_alv_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
* I_GRID_SETTINGS =
* IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'ZLAY1'
I_SAVE = 'A'
* is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
* 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. "display_alv_report
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
*& Form event_call_ekpo
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "event_call_ekpo
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT =
I_SAVE = 'A'
* IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
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.
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
* declaration for events table where user comand or set PF status will
* be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
* declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
* declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
* Fieldcatalog has all the field details from ekko
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
*& Form EVENT_CALL
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "EVENT_CALL
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form data_retrieval
*&--------------------------------------------------------------------*
* retreiving values from the database table ekko
*---------------------------------------------------------------------*
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*&--------------------------------------------------------------------*
*& Form bUild_listheader
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->I_LISTHEADEtext
*---------------------------------------------------------------------*
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*&--------------------------------------------------------------------*
*& Form display_alv_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
* I_GRID_SETTINGS =
* IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'ZLAY1'
I_SAVE = 'A'
* is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
* 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. "display_alv_report
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
*& Form event_call_ekpo
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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. "event_call_ekpo
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT =
I_SAVE = 'A'
* IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
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.
ALV SIMPLE SAMPLE CODE
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
*data definition
tables:
marav. "Table MARA and table MAKT
*---------------------------------------------------------------------*
* Data to be displayed in ALV
* Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
* matically determine the fieldstructure from this source program
Data:
begin of imat occurs 100,
matnr like marav-matnr, "Material number
maktx like marav-maktx, "Material short text
matkl like marav-matkl, "Material group (so you can test to make
" intermediate sums)
ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
"make sums)
gewei like marav-gewei, "weight unit (just to be complete)
end of imat.
*---------------------------------------------------------------------*
* Other data needed
* field to store report name
data i_repid like sy-repid.
* field to check table length
data i_lines like sy-tabix.
*---------------------------------------------------------------------*
* Data for ALV display
TYPE-POOLS: SLIS.
data int_fcat type SLIS_T_FIELDCAT_ALV.
*---------------------------------------------------------------------*
select-options:
s_matnr for marav-matnr matchcode object MAT1.
*---------------------------------------------------------------------*
start-of-selection.
* read data into table imat
select * from marav
into corresponding fields of table imat
where
matnr in s_matnr.
* Check if material was found
clear i_lines.
describe table imat lines i_lines.
if i_lines lt 1.
* Using hardcoded write here for easy upload
write: /
'No materials found.'.
exit.
endif.
end-of-selection.
*---------------------------------------------------------------------*
*
* Now, we start with ALV
*
*---------------------------------------------------------------------*
*
*
* To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
* The fieldcatalouge can be generated by FUNCTION
* 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
* report source, including this report.
* The only problem one might have is that the report and table names
* need to be in capital letters. (I had it :-( )
*
*
*---------------------------------------------------------------------*
* Store report name
i_repid = sy-repid.
* Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
I_INTERNAL_TABNAME = 'IMAT' "capital letters!
I_INCLNAME = i_repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
*explanations:
* I_PROGRAM_NAME is the program which calls this function
*
* I_INTERNAL_TABNAME is the name of the internal table which you want
* to display in ALV
*
* I_INCLNAME is the ABAP-source where the internal table is defined
* (DATA....)
* CT_FIELDCAT contains the Fieldcatalouge that we need later for
* ALV display
IF SY-SUBRC <> 0.
write: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
*This was the fieldcatlogue
*---------------------------------------------------------------------*
*
* And now, we are ready to display our list
* Call for ALV list display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
I_CALLBACK_PROGRAM = i_repid
IT_FIELDCAT = int_fcat
I_SAVE = 'A'
TABLES
T_OUTTAB = imat
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*
*explanations:
* I_CALLBACK_PROGRAM is the program which calls this function
*
* IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
* now the data definition needed for display
*
* I_SAVE allows the user to save his own layouts
*
* T_OUTTAB contains the data to be displayed in ALV
IF SY-SUBRC <> 0.
write: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
ENDIF.
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
*data definition
tables:
marav. "Table MARA and table MAKT
*---------------------------------------------------------------------*
* Data to be displayed in ALV
* Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
* matically determine the fieldstructure from this source program
Data:
begin of imat occurs 100,
matnr like marav-matnr, "Material number
maktx like marav-maktx, "Material short text
matkl like marav-matkl, "Material group (so you can test to make
" intermediate sums)
ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
"make sums)
gewei like marav-gewei, "weight unit (just to be complete)
end of imat.
*---------------------------------------------------------------------*
* Other data needed
* field to store report name
data i_repid like sy-repid.
* field to check table length
data i_lines like sy-tabix.
*---------------------------------------------------------------------*
* Data for ALV display
TYPE-POOLS: SLIS.
data int_fcat type SLIS_T_FIELDCAT_ALV.
*---------------------------------------------------------------------*
select-options:
s_matnr for marav-matnr matchcode object MAT1.
*---------------------------------------------------------------------*
start-of-selection.
* read data into table imat
select * from marav
into corresponding fields of table imat
where
matnr in s_matnr.
* Check if material was found
clear i_lines.
describe table imat lines i_lines.
if i_lines lt 1.
* Using hardcoded write here for easy upload
write: /
'No materials found.'.
exit.
endif.
end-of-selection.
*---------------------------------------------------------------------*
*
* Now, we start with ALV
*
*---------------------------------------------------------------------*
*
*
* To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
* The fieldcatalouge can be generated by FUNCTION
* 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
* report source, including this report.
* The only problem one might have is that the report and table names
* need to be in capital letters. (I had it :-( )
*
*
*---------------------------------------------------------------------*
* Store report name
i_repid = sy-repid.
* Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
I_INTERNAL_TABNAME = 'IMAT' "capital letters!
I_INCLNAME = i_repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
*explanations:
* I_PROGRAM_NAME is the program which calls this function
*
* I_INTERNAL_TABNAME is the name of the internal table which you want
* to display in ALV
*
* I_INCLNAME is the ABAP-source where the internal table is defined
* (DATA....)
* CT_FIELDCAT contains the Fieldcatalouge that we need later for
* ALV display
IF SY-SUBRC <> 0.
write: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
*This was the fieldcatlogue
*---------------------------------------------------------------------*
*
* And now, we are ready to display our list
* Call for ALV list display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
I_CALLBACK_PROGRAM = i_repid
IT_FIELDCAT = int_fcat
I_SAVE = 'A'
TABLES
T_OUTTAB = imat
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*
*explanations:
* I_CALLBACK_PROGRAM is the program which calls this function
*
* IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
* now the data definition needed for display
*
* I_SAVE allows the user to save his own layouts
*
* T_OUTTAB contains the data to be displayed in ALV
IF SY-SUBRC <> 0.
write: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
ENDIF.
ALV COLURING SAMPLE CODE
REPORT zalv.
*****************************************************************
* Use of colours in ALV grid (cell, line and column) *
*****************************************************************
* Table
TABLES : mara.
* Type
TYPES : BEGIN OF ty_mara,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
counter(4) TYPE n,
free_text(15) TYPE c,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
END OF ty_mara.
* Structures
DATA : wa_mara TYPE ty_mara,
wa_fieldcat TYPE lvc_s_fcat,
is_layout TYPE lvc_s_layo,
wa_color TYPE lvc_s_scol.
* Internal table
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
it_color TYPE TABLE OF lvc_s_scol.
* Variables
DATA : okcode LIKE sy-ucomm,
w_alv_grid TYPE REF TO cl_gui_alv_grid,
w_docking_container TYPE REF TO cl_gui_docking_container.
PARAMETERS : p_column AS CHECKBOX,
p_line AS CHECKBOX,
p_cell AS CHECKBOX.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM fill_catalog.
PERFORM fill_layout.
CALL SCREEN 2000.
*&--------------------------------------------------------------*
*& Module status_2000 OUTPUT
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
MODULE status_2000 OUTPUT.
SET PF-STATUS '2000'.
ENDMODULE. " status_2000 OUTPUT
*&---------------------------------------------------------------*
*& Module user_command_2000 INPUT
*&---------------------------------------------------------------*
* text
*----------------------------------------------------------------*
MODULE user_command_2000 INPUT.
DATA : w_okcode LIKE sy-ucomm.
MOVE okcode TO w_okcode.
CLEAR okcode.
CASE w_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " user_command_2000 INPUT
*&--------------------------------------------------------------*
*& Module alv_grid OUTPUT
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
MODULE alv_grid OUTPUT.
IF w_docking_container IS INITIAL.
PERFORM create_objects.
PERFORM display_alv_grid.
ENDIF.
ENDMODULE. " alv_grid OUTPUT
*&--------------------------------------------------------------*
*& Form create_objects
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
* --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM create_objects. * Ratio must be included in [5..95] CREATE OBJECT w_docking_container EXPORTING ratio = 95 EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5 others = 6. CREATE OBJECT w_alv_grid EXPORTING i_parent = w_docking_container. ENDFORM. " create_objects *&--------------------------------------------------------------* *& Form display_alv_grid *&--------------------------------------------------------------* * text *---------------------------------------------------------------* * --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM display_alv_grid. CALL METHOD w_alv_grid->set_table_for_first_display
EXPORTING
is_layout = is_layout
CHANGING
it_outtab = it_mara
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " display_alv_grid
*&--------------------------------------------------------------*
*& Form get_data
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
* --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM get_data. SELECT * FROM mara UP TO 5 ROWS. CLEAR : wa_mara-color_line, wa_mara-color_cell. MOVE-CORRESPONDING mara TO wa_mara. ADD 1 TO wa_mara-counter. MOVE 'Blabla' TO wa_mara-free_text. IF wa_mara-counter = '0002' AND p_line = 'X'. * Color line MOVE 'C410' TO wa_mara-color_line. ELSEIF wa_mara-counter = '0004' AND p_cell = 'X'. * Color cell MOVE 'FREE_TEXT' TO wa_color-fname. MOVE '5' TO wa_color-color-col. MOVE '1' TO wa_color-color-int. MOVE '1' TO wa_color-color-inv. APPEND wa_color TO it_color. wa_mara-color_cell[] = it_color[]. ENDIF. APPEND wa_mara TO it_mara. ENDSELECT. ENDFORM. " get_data *&--------------------------------------------------------------* *& Form fill_catalog *&--------------------------------------------------------------* * text *---------------------------------------------------------------* * --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM fill_catalog. ***************************************************************** * Colour code : * * Colour is a 4-char field where : * * - 1st char = C (color property) * * - 2nd char = color code (from 0 to 7) * * 0 = background color * * 1 = blue * * 2 = gray * * 3 = yellow * * 4 = blue/gray * * 5 = green * * 6 = red * * 7 = orange * * - 3rd char = intensified (0=off, 1=on) * * - 4th char = inverse display (0=off, 1=on) * * * * Colour overwriting priority : * * 1. Line * * 2. Cell * * 3. Column * ***************************************************************** DATA : w_position TYPE i VALUE '1'. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'MATNR' TO wa_fieldcat-fieldname. MOVE 'MARA' TO wa_fieldcat-ref_table. MOVE 'MATNR' TO wa_fieldcat-ref_field. APPEND wa_fieldcat TO it_fieldcat. ADD 1 TO w_position. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'MATKL' TO wa_fieldcat-fieldname. MOVE 'MARA' TO wa_fieldcat-ref_table. MOVE 'MATKL' TO wa_fieldcat-ref_field. * Color column IF p_column = 'X'. MOVE 'C610' TO wa_fieldcat-emphasize. ENDIF. APPEND wa_fieldcat TO it_fieldcat. ADD 1 TO w_position. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'COUNTER' TO wa_fieldcat-fieldname. MOVE 'N' TO wa_fieldcat-inttype. MOVE '4' TO wa_fieldcat-intlen. MOVE 'Counter' TO wa_fieldcat-coltext. APPEND wa_fieldcat TO it_fieldcat. ADD 1 TO w_position. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname. MOVE 'C' TO wa_fieldcat-inttype. MOVE '20' TO wa_fieldcat-intlen. MOVE 'Text' TO wa_fieldcat-coltext. APPEND wa_fieldcat TO it_fieldcat. ENDFORM. " fill_catalog *&--------------------------------------------------------------* *& Form fill_layout *&--------------------------------------------------------------* * text *---------------------------------------------------------------* * --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM fill_layout. * Field that identify color line in internal table MOVE 'COLOR_LINE' TO is_layout-info_fname. * Field that identify cell color in inetrnal table MOVE 'COLOR_CELL' TO is_layout-ctab_fname. ENDFORM. " fill_layout Flow logic code Code: PROCESS BEFORE OUTPUT. MODULE status_2000. MODULE alv_grid. PROCESS AFTER INPUT. MODULE user_command_2000.
*****************************************************************
* Use of colours in ALV grid (cell, line and column) *
*****************************************************************
* Table
TABLES : mara.
* Type
TYPES : BEGIN OF ty_mara,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
counter(4) TYPE n,
free_text(15) TYPE c,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
END OF ty_mara.
* Structures
DATA : wa_mara TYPE ty_mara,
wa_fieldcat TYPE lvc_s_fcat,
is_layout TYPE lvc_s_layo,
wa_color TYPE lvc_s_scol.
* Internal table
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
it_color TYPE TABLE OF lvc_s_scol.
* Variables
DATA : okcode LIKE sy-ucomm,
w_alv_grid TYPE REF TO cl_gui_alv_grid,
w_docking_container TYPE REF TO cl_gui_docking_container.
PARAMETERS : p_column AS CHECKBOX,
p_line AS CHECKBOX,
p_cell AS CHECKBOX.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM fill_catalog.
PERFORM fill_layout.
CALL SCREEN 2000.
*&--------------------------------------------------------------*
*& Module status_2000 OUTPUT
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
MODULE status_2000 OUTPUT.
SET PF-STATUS '2000'.
ENDMODULE. " status_2000 OUTPUT
*&---------------------------------------------------------------*
*& Module user_command_2000 INPUT
*&---------------------------------------------------------------*
* text
*----------------------------------------------------------------*
MODULE user_command_2000 INPUT.
DATA : w_okcode LIKE sy-ucomm.
MOVE okcode TO w_okcode.
CLEAR okcode.
CASE w_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " user_command_2000 INPUT
*&--------------------------------------------------------------*
*& Module alv_grid OUTPUT
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
MODULE alv_grid OUTPUT.
IF w_docking_container IS INITIAL.
PERFORM create_objects.
PERFORM display_alv_grid.
ENDIF.
ENDMODULE. " alv_grid OUTPUT
*&--------------------------------------------------------------*
*& Form create_objects
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
* --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM create_objects. * Ratio must be included in [5..95] CREATE OBJECT w_docking_container EXPORTING ratio = 95 EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5 others = 6. CREATE OBJECT w_alv_grid EXPORTING i_parent = w_docking_container. ENDFORM. " create_objects *&--------------------------------------------------------------* *& Form display_alv_grid *&--------------------------------------------------------------* * text *---------------------------------------------------------------* * --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM display_alv_grid. CALL METHOD w_alv_grid->set_table_for_first_display
EXPORTING
is_layout = is_layout
CHANGING
it_outtab = it_mara
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " display_alv_grid
*&--------------------------------------------------------------*
*& Form get_data
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
* --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM get_data. SELECT * FROM mara UP TO 5 ROWS. CLEAR : wa_mara-color_line, wa_mara-color_cell. MOVE-CORRESPONDING mara TO wa_mara. ADD 1 TO wa_mara-counter. MOVE 'Blabla' TO wa_mara-free_text. IF wa_mara-counter = '0002' AND p_line = 'X'. * Color line MOVE 'C410' TO wa_mara-color_line. ELSEIF wa_mara-counter = '0004' AND p_cell = 'X'. * Color cell MOVE 'FREE_TEXT' TO wa_color-fname. MOVE '5' TO wa_color-color-col. MOVE '1' TO wa_color-color-int. MOVE '1' TO wa_color-color-inv. APPEND wa_color TO it_color. wa_mara-color_cell[] = it_color[]. ENDIF. APPEND wa_mara TO it_mara. ENDSELECT. ENDFORM. " get_data *&--------------------------------------------------------------* *& Form fill_catalog *&--------------------------------------------------------------* * text *---------------------------------------------------------------* * --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM fill_catalog. ***************************************************************** * Colour code : * * Colour is a 4-char field where : * * - 1st char = C (color property) * * - 2nd char = color code (from 0 to 7) * * 0 = background color * * 1 = blue * * 2 = gray * * 3 = yellow * * 4 = blue/gray * * 5 = green * * 6 = red * * 7 = orange * * - 3rd char = intensified (0=off, 1=on) * * - 4th char = inverse display (0=off, 1=on) * * * * Colour overwriting priority : * * 1. Line * * 2. Cell * * 3. Column * ***************************************************************** DATA : w_position TYPE i VALUE '1'. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'MATNR' TO wa_fieldcat-fieldname. MOVE 'MARA' TO wa_fieldcat-ref_table. MOVE 'MATNR' TO wa_fieldcat-ref_field. APPEND wa_fieldcat TO it_fieldcat. ADD 1 TO w_position. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'MATKL' TO wa_fieldcat-fieldname. MOVE 'MARA' TO wa_fieldcat-ref_table. MOVE 'MATKL' TO wa_fieldcat-ref_field. * Color column IF p_column = 'X'. MOVE 'C610' TO wa_fieldcat-emphasize. ENDIF. APPEND wa_fieldcat TO it_fieldcat. ADD 1 TO w_position. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'COUNTER' TO wa_fieldcat-fieldname. MOVE 'N' TO wa_fieldcat-inttype. MOVE '4' TO wa_fieldcat-intlen. MOVE 'Counter' TO wa_fieldcat-coltext. APPEND wa_fieldcat TO it_fieldcat. ADD 1 TO w_position. CLEAR wa_fieldcat. MOVE w_position TO wa_fieldcat-col_pos. MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname. MOVE 'C' TO wa_fieldcat-inttype. MOVE '20' TO wa_fieldcat-intlen. MOVE 'Text' TO wa_fieldcat-coltext. APPEND wa_fieldcat TO it_fieldcat. ENDFORM. " fill_catalog *&--------------------------------------------------------------* *& Form fill_layout *&--------------------------------------------------------------* * text *---------------------------------------------------------------* * --> p1 text
* <-- p2 text *---------------------------------------------------------------* FORM fill_layout. * Field that identify color line in internal table MOVE 'COLOR_LINE' TO is_layout-info_fname. * Field that identify cell color in inetrnal table MOVE 'COLOR_CELL' TO is_layout-ctab_fname. ENDFORM. " fill_layout Flow logic code Code: PROCESS BEFORE OUTPUT. MODULE status_2000. MODULE alv_grid. PROCESS AFTER INPUT. MODULE user_command_2000.
Monday, May 19, 2008
ALV LIST USING OO STYLE SAMPLE CODE
1. Create a Control (for Custom and Split Containers only)
2. Instantiate a Container Object (in case of Custom and Split Containers, specify the control which is created by us in Screen painter) CREATE OBJECT
3. Instantiate an Object of the kind of report that has to be displayed (List, Grid or Tree). CREATE OBJECT . Here we need to specify the Parent Container as the so that it sits in that container.
4. Call appropriate methods to display the report on the screen. CALL METHOD ->
Example:
DATA : g_dock TYPE REF TO cl_gui_docking_container,
g_split TYPE REF TO cl_gui_easy_splitter_container,
g_cont1 TYPE REF TO cl_gui_container,
g_cont2 TYPE REF TO cl_gui_container,
g_grid1 TYPE REF TO cl_gui_alv_grid,
g_grid2 TYPE REF TO cl_gui_alv_grid.
* i_mara is an internal table of structure MARA
SELECT * FROM mara INTO TABLE i_mara.
* i_kna1 is an internal table of structure KNA1
SELECT * FROM kna1 INTO TABLE i_kna1.
* To create an Object of type Docking Container
CREATE OBJECT g_dock
EXPORTING
side = cl_gui_docking_container=>dock_at_top
extension = 200 .
* To Create an Object of Type Split Container. Here we can see that the Docking *Container Created above has been used as a parent .
CREATE OBJECT g_split
EXPORTING
parent = g_dock
orientation = 1 .
* Easy Split container splits one Control into 2 manageable controls, each of them is used * to handle one GUI Container each
g_cont1 = g_split->top_left_container.
g_cont2 = g_split->bottom_right_container.
* To Create an Object of type Grid . Here we can see that the Left Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid1
EXPORTING
i_parent = g_cont1 .
* To Create an Object of type Grid . Here we can see that the Right Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid2
EXPORTING
i_parent = g_cont2 .
* The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MARA'
CHANGING
it_outtab = i_mara[] .
* The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNA1'
CHANGING
it_outtab = i_kna1[] .
2. Instantiate a Container Object (in case of Custom and Split Containers, specify the control which is created by us in Screen painter) CREATE OBJECT
3. Instantiate an Object of the kind of report that has to be displayed (List, Grid or Tree). CREATE OBJECT . Here we need to specify the Parent Container as the so that it sits in that container.
4. Call appropriate methods to display the report on the screen. CALL METHOD ->
Example:
DATA : g_dock TYPE REF TO cl_gui_docking_container,
g_split TYPE REF TO cl_gui_easy_splitter_container,
g_cont1 TYPE REF TO cl_gui_container,
g_cont2 TYPE REF TO cl_gui_container,
g_grid1 TYPE REF TO cl_gui_alv_grid,
g_grid2 TYPE REF TO cl_gui_alv_grid.
* i_mara is an internal table of structure MARA
SELECT * FROM mara INTO TABLE i_mara.
* i_kna1 is an internal table of structure KNA1
SELECT * FROM kna1 INTO TABLE i_kna1.
* To create an Object of type Docking Container
CREATE OBJECT g_dock
EXPORTING
side = cl_gui_docking_container=>dock_at_top
extension = 200 .
* To Create an Object of Type Split Container. Here we can see that the Docking *Container Created above has been used as a parent .
CREATE OBJECT g_split
EXPORTING
parent = g_dock
orientation = 1 .
* Easy Split container splits one Control into 2 manageable controls, each of them is used * to handle one GUI Container each
g_cont1 = g_split->top_left_container.
g_cont2 = g_split->bottom_right_container.
* To Create an Object of type Grid . Here we can see that the Left Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid1
EXPORTING
i_parent = g_cont1 .
* To Create an Object of type Grid . Here we can see that the Right Split Container * Created above has been used as a parent .
CREATE OBJECT g_grid2
EXPORTING
i_parent = g_cont2 .
* The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MARA'
CHANGING
it_outtab = i_mara[] .
* The method of Grid Control Object is used to display the Data.
CALL METHOD g_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNA1'
CHANGING
it_outtab = i_kna1[] .
Subscribe to:
Posts (Atom)
Archives
-
▼
2008
(112)
-
▼
July
(54)
- The R/3 Basis System: Overview
- Position of the Basis System Within the R/3 System
- Application Servers in SAP
- Work Processes in SAP ABAP
- Overview of the Components of Application Programs...
- Structure of an Application Program in SAP ABAP
- Screens in SAP ABAP
- Structure of ABAP Programs
- Processing Blocks in ABAP Programs
- ABAP Statements in SAP ABAP
- Logical Databases and Contexts in SAP ABAP
- Memory Structures of an ABAP Program
- Creating and Changing ABAP Programs in SAP ABAP
- Opening a Program from the Repository Browser in S...
- Opening Programs in the ABAP Editor
- Opening Programs Using Forward Navigation in SAP ABAP
- Maintaining Program Attributes in SAP ABAP
- Editing Programs in SAP ABAP
- ABAP Syntax
- Processing Data in SAP ABAP
- LESSON 25 CALLING PROGRAM AND PASSING DATA
- LESSON 26 TECHNIQUES FOR LIST CREATION AND SAP QUARY
- LESSON 29 SELECTION SCREENS ABAP REPORT
- ABAP Interview Questions -SQL , Tables , Basic
- Dialog Programming Interview Questions(FAQ's)
- Performance Tuning Faqs in abap
- SAP BASIS LAYER Interview Questions
- SAP ABAPDATA DICTIONARY Interview Questions
- SAP ABAP LOGICAL DATABASE Interview Questions
- SAP ABAP Dialog Programming FAQ
- More than 100 ABAP Interview Faq's
- SAP Workflow Items Sent To Everyone If Agent Not D...
- How to delete an editor lock in sap?
- How can I insert my company logo in the sap abap s...
- sap abap program for Issuing an Unix Command from ...
- Difference for Stock Transfer and Transfer Posting...
- Add a Field To New Condition Table in Pricing in SAP
- Unified Access to All SAP ABAP HR Infotypes
- SAP HR ABAP Logical Database
- Processing Payroll infotypes/Cluster in SAP HR ABAP
- FAQ ON SCRIPTS 1
- FAQ ON SCRIPTS 2
- FAQ ON SCRIPTS 3
- General - Reporting Tree in ABAP
- List Box in ABAP Report
- Example Code For Drill Down Report in SAP ABAP
- TABStrips in ABAP
- A demo program to create subscreen in your ABAP Pr...
- Tree type report in ABAP
- Recursion with Loop Checking in SAP
- ABAP Clipboard Utilities for Beautiful Commented Code
- Create Push Buttons in Application Tool Bar IN SAP...
- Single Bit Processing in Hexadecimal Fields in SAP...
- Showing posts with label ABAP Enhancement. Show al...
-
▼
July
(54)