You are on page 1of 9

How to make a row editable in alv based on

conditions Using FM.

White Paper
By
Vijay Agarwal

Abstract
To make single row editable in alv display based on certain condition using Function
Module Reuse_ALV_GRID_DISPLAY .

In many of the business scenarios User wants Reports in ALV display and in that they
want ALV row editable based on certain criteria.

About the Domain


SAP ABAP module can use this document. This will help out to modify ALV output
screen.

Abbreviations
Term
ERP
ABAP

Description
Enterprise Resource Planning
Advanced Business Application
Programming

Contents

Introduction...........................................................................................................................................................2
The Deployment Logic...........................................................................................................................................2
Steps involved........................................................................................................................................................2
Output....................................................................................................................................................................5
Conclusion.............................................................................................................................................................6
References..............................................................................................................................................................7

Introduction
This document will cover the basic steps that should be followed to get a editable field at the
output of ALV.

The Deployment Logic

Create your custom


program

Define Field Catalog,


Define Style table ,
Define Data Tab and
include style table in
this.

In fieldcatalog pass Edit


Parameter checked for
which column output
should editable.
Pass style into data table
and call Function
Module

On output you will find a


single row based on
condition editable.

Steps involved
The step that needs to be followed is as below.
1. Go to Se 37 , Create a Function module based on your naming convention .

Define in Top data .


DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.

Define : HANDLE_STYLE TYPE LVC_T_STYL, "FOR DISABLE


In your data tab.
e.g- it_vbap is data tab.where 2 fields for data vbeln,posnr .
so added handle_style into data tab.
e.g. DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
Flag,
HANDLE_STYLE TYPE LVC_T_STYL, "FOR DISABLE
END OF IT_VBAP.

2. In importing parameter Pass FLAG a mandatory Flag to and mention default value 1 for 167
infotype .
As shown blow.
LOOP AT IT_VBAP INTO LS_OUTTAB WHERE FLAG = 'X'.
V_INDEX = SY-TABIX.

LS_EDIT-FIELDNAME = 'VBELN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENAABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
LS_EDIT-FIELDNAME = 'POSNR'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY IT_VBAP INDEX V_INDEX FROM LS_OUTTAB

TRANSPORTING

HANDLE_STYLE .

ENDLOOP.

3. Go to Tables Define
While filling fieldcat pass following for the column you want to make as editable.
FIELDCAT-EDIT = 'X'.

Call Fm

--- CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'


EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT_LVC

= IT_FIELDCAT

TABLES
T_OUTTAB

= IT_VBAP[]

EXCEPTIONS
PROGRAM_ERROR

= 1

OTHERS

= 2.

Output

Conclusion
This code could be used to get a editable row in the ALV outupu screen.
Objective of this white paper is to
Standardize and automate the efforts of Architects in applying this solution
and Developers using the logic to maximum effect so as to reduce the
development cycle.Reusablity of efforts is key to deliver more in short time to
reduce the turn around time in Project management.

References

You might also like