Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Help !!

Former Member
0 Kudos

I am using an ALV report using REUSE_ALV_GRID_DISPLAY,and my requirement is ...

Currently on execution of the report if in a particular colum if any records are coming then that cell alone should b shown in editable mode.

Eg :

Fld1 Fld2 Fld3 Fld4 Fld5

A1 A2 A4 A5

B1 B2 B3 B4 B5

in the above ex; in first record field 3 should b in editable mode

and all other fields should b in display mode.

plz send me a solution.

2 REPLIES 2

Former Member
0 Kudos

Hi ,

Use the logic for this program

BCALV_EDIT_03 though this is Object Oriented program the concept is the same to add in Function Module Method .

Rewards if useful.

Former Member
0 Kudos

hi,

You need to use field catalog for this.i am pating an example code for this.please see to it.

code:

report zalv_color_display_edit.

type-pools: slis.

tables : zcust_master2.

*----


  • INTERNAL TABLE DECLARATION

*----


types : begin of wi_zcust_master2,

zcustid like zcust_master2-zcustid,

zcustname like zcust_master2-zcustname,

zaddr like zcust_master2-zaddr,

zcity like zcust_master2-zcity,

zstate like zcust_master2-zstate,

zcountry like zcust_master2-zcountry,

zphone like zcust_master2-zphone,

zemail like zcust_master2-zemail,

zfax like zcust_master2-zfax,

zstat like zcust_master2-zstat,

field_style type lvc_t_styl,

end of wi_zcust_master2.

data: it_wi_zcust_master2 type standard table of wi_zcust_master2

initial size 0,

wa_zcust_master2 type wi_zcust_master2.

*----


*ALV data declarations

*----


data: fieldcatalog type slis_t_fieldcat_alv with header line.

data: it_fieldcat type lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER

line,

wa_fieldcat type lvc_s_fcat,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type lvc_s_layo, "slis_layout_alv,

gd_repid like sy-repid.

************************************************************************

start-of-selection.

perform data_retrieval.

perform set_specific_field_attributes.

perform build_fieldcatalog.

perform build_layout.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

wa_fieldcat-fieldname = 'ZCUSTID'.

wa_fieldcat-scrtext_m = 'CUSTOMER ID'.

wa_fieldcat-col_pos = 0.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZCUSTNAME'.

wa_fieldcat-scrtext_m = 'CUSTOMER NAME'.

wa_fieldcat-col_pos = 1.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZADDR'.

wa_fieldcat-scrtext_m = 'ADDRESS'.

wa_fieldcat-col_pos = 2.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZCITY'.

wa_fieldcat-scrtext_m = 'CITY'.

wa_fieldcat-col_pos = 3.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZSTATE'.

wa_fieldcat-scrtext_m = 'STATE'.

wa_fieldcat-col_pos = 4.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZCOUNTRY'.

wa_fieldcat-scrtext_m = 'COUNTRY'.

wa_fieldcat-col_pos = 5.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZPHONE'.

wa_fieldcat-scrtext_m = 'PHONE NUMBER'.

wa_fieldcat-col_pos = 6.

  • wa_fieldcat-edit = 'X'. "sets whole column to be editable

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZEMAIL'.

wa_fieldcat-scrtext_m = 'EMAIL'.

wa_fieldcat-edit = 'X'. "sets whole column to be editable

wa_fieldcat-col_pos = 7.

wa_fieldcat-outputlen = 15.

wa_fieldcat-datatype = 'CURR'.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZFAX'.

wa_fieldcat-scrtext_m = 'FAX'.

wa_fieldcat-col_pos = 8.

wa_fieldcat-edit = 'X'. "sets whole column to be editable

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ZSTAT'.

wa_fieldcat-scrtext_m = 'STATUS'.

wa_fieldcat-col_pos = 9.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

  • Set layout field for field attributes(i.e. input/output)

gd_layout-stylefname = 'FIELD_STYLE'.

gd_layout-zebra = 'X'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

*----


  • call function 'REUSE_ALV_GRID_DISPLAY'

*----


call function 'REUSE_ALV_GRID_DISPLAY_LVC'

exporting

i_callback_program = gd_repid

is_layout_lvc = gd_layout

it_fieldcat_lvc = it_fieldcat

i_save = 'X'

tables

t_outtab = it_wi_zcust_master2

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 DATA_RETRIEVAL

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form data_retrieval .

data: ld_color(1) type c.

select zcustid zcustname zaddr zcity zstate zcountry zphone zemail

zfax zstat up to 10 rows from zcust_master2 into corresponding fields of

table it_wi_zcust_master2.

endform. "data_retrieval

Hope this helps u.

Regards,

Arunsri