Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
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.
tions ia
output Abbrev
A LV
mo d if y to
wil l help out
is
o c u m ent. Th
s d
n. c a n u s e t hi
scree
A P m odule h e D o main
B t
SAP A About

Term Description
ERP Enterprise Resource Planning
Sábado, 17 de Septiembre del 2022
ABAP 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

O n output you will find a


single row based on
condition editable.

Steps involved
The step that needs to be followed is as below.
1. G o to Se 37 , Create a Function module based on your naming
convention .
Define in Top da ta .

DATA: LS_EDIT TYPE

LVC_S_STYL, LT_EDIT TYPE

LVC_T_S TYL.

Define : HANDLE_STYLE TYPE


LVC_T_S TYL, "FOR DISABLE
I n your data tab.

e.g- it_vbap is d a t a tab.where 2 fields for d a t a vbeln,posnr .


so a d de d handle_style into da t a tab.

e . g . DATA: BEGIN OF IT_VBAP OCCURS

0, VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POS NR,

Fl ag,

HANDLE_STYLE TYPE LVC_T_S TYL, "FOR DISABLE


END OF I T_VBAP.

2. In importing parameter Pass F L A G a mandatory Flag to and mention default value 1


for 167 infotype .
As shown blow.

LOOP AT I T_VBAP I NTO LS_OUTTAB WHERE FLAG = ' X' .

V_INDEX = S Y - TABI X.

LS_EDIT-FI ELDNAME = ' VBELN' .

LS_EDIT-STYLE =
CL_GUI _ALV_GRI D=>MC_STYLE_ENAABLED.
LS_EDIT-STYLE2 = S P A C E
.
LS_EDIT-STYLE3 = S P A C E
.
LS_EDIT-STYLE4 = S P A C E
.
LS_EDIT-MAXLEN = 8 .

INSERT LS_EDIT INTO TABLE LT_EDI T.

LS_EDIT-FI ELDNAME = ' POSNR' .

LS_EDIT-STYLE =
CL_GUI _ALV_GRI D=>MC_STYLE_ENABLED.
L S _ E D I T - STYLE2 = S P A C E
.
L S _ E D I T - STYLE3 = S P A C E
.
L S _ E D I T - STYLE4 = S P A C E
.
L S _ E D I T - MAXLEN = 8 .

I NS ERT LS _ EDI T I NTO TABLE LT_ EDI T.

I NS ERT LI NES OF LT_ EDI T I NTO TABLE LS _ OUTTAB- HANDLE_ S TYLE.

MODI F I T_ VBAP I NDEX V_ I NDEX FROM LS_OUTTAB TRANS P ORTI NG


Y
HANDLE_STYLE .

ENDLOOP .

3. G o to Tables Define
While filling fieldcat pass following for the column you want to make as editable.

F I ELDCAT- EDI T = ' X' .


Call Fm

--- CALL F UNCTI ON ' REUS E_ ALV_ GRI D_ DI S P LAY_ LVC'

EXP ORTI NG

I _ CALLBACK_ P ROGRAM = S Y- REP I D

I T_ F I ELDCAT_ LVC =

I T_ F I ELDCAT

TABLES
T_OUTTAB = IT_VBAP[
]
E XC E P T I O N S

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