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: 

In ALV Report ,a field to allow the user EDIT/CHANGE

Former Member
0 Kudos

Hi Guys,

My requirement is

in the ALV Grid display iam having 10 fields.5th field should be allow the user EDIT/CHANGE mode.

what ever he enters the value the same should be updated to an custom table.

EX.

o/p:

0001 0002 0003 0004 0005 0006 0007 0008 0009 0010

Now the user changed the value 0005 to 0011.

0001 0002 0003 0004 0011 0006 0007 0008 0009 0010

now 0011 should be updated in custom table.

to do this process please suggest a best way for coding.

thanks in advance.

Sunil.

6 REPLIES 6

Former Member
0 Kudos

hi



*&---------------------------------------------------------------------*
*& Report  ZTESTDEMO_INTERACTIVE_LIST_2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZTESTDEMO_INTERACTIVE_LIST_2.

TABLES: MARA,MARC,MARD.


* internal table itab_mara 3 fields matnr, ernam,mtart
DATA: BEGIN OF ITAB_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,  " material number
ERNAM LIKE MARA-ERNAM,  " name of person who create
MTART LIKE MARA-MTART,  " Material Type
END OF ITAB_MARA.

* internal table itab_marc 3 fields matnr, werks,lvorm

DATA: BEGIN OF ITAB_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,  " Plant
LVORM LIKE MARC-LVORM,  " Flag Material for Deletion at Plant Level
END OF ITAB_MARC.

* internal table itab_mard 2 fields

DATA: BEGIN OF ITAB_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT,  " Storage Location
END OF ITAB_MARD.

SELECT-OPTIONS: S_MTART FOR MARA-MTART.

INITIALIZATION.

S_MTART-LOW = 'HALB'.
S_MTART-HIGH = 'HAWA'.
S_MTART-OPTION = 'BT'.
APPEND S_MTART.

START-OF-SELECTION.

SELECT MATNR ERNAM MTART FROM MARA INTO TABLE ITAB_MARA WHERE MTART IN
S_MTART.

PERFORM DISPLAY.


TOP-OF-PAGE.
WRITE:/2(15) 'MATERIAL NO',20(20) 'CREATED BY',45(15) 'MATERIAL TYPE'.


FORM DISPLAY.

LOOP AT ITAB_MARA.
WRITE:/ ITAB_MARA-MATNR UNDER 'MATERIAL NO' HOTSPOT ON,ITAB_MARA-ERNAM
UNDER 'CREATED BY',ITAB_MARA-MTART UNDER 'MATERIAL TYPE'.
HIDE: ITAB_MARA-MATNR.
ENDLOOP.

ENDFORM.

AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.

SELECT MATNR WERKS LVORM FROM MARC INTO TABLE ITAB_MARC WHERE MATNR =
ITAB_MARA-MATNR.
PERFORM DISPLAY1.

WHEN 2.

SELECT MATNR LGORT FROM MARD INTO TABLE ITAB_MARD WHERE MATNR =
ITAB_MARC-MATNR.
PERFORM DISPLAY2.

when 3.
sy-lsind = 0.
ENDCASE.

FORM DISPLAY1.
LOOP AT ITAB_MARC.
WRITE:/ ITAB_MARC-MATNR HOTSPOT ON, ITAB_MARC-WERKS,ITAB_MARC-LVORM.
HIDE: ITAB_MARC-MATNR.
ENDLOOP.

WRITE:/ SY-LSIND.
ENDFORM.

FORM DISPLAY2.
LOOP AT ITAB_MARD.
WRITE:/ ITAB_MARD-MATNR, ITAB_MARD-LGORT.
ENDLOOP.
WRITE:/ SY-LSIND.

ENDFORM.

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Pawan_Kesari
Active Contributor
0 Kudos

in fieldcatelog set fields EDIT and INPUT to 'X'

Former Member
0 Kudos

Check out this related thread

Former Member
0 Kudos

Hi Sunil,

There is a layout specification in type pool SLIS as below

slis_layout_alv_spec0.

Check the options given below, you can use for editing the particular column records.

edit(1) type c, " for grid only

edit_mode(1) type c, " for grid only

Try this out.

Best Regards,

Ram

Former Member
0 Kudos

Hi Guys,

its a bit urgent.

still my clarification was not cleared.

if the user enters in the field manually then the value should get updated in the custom table.

please tell me the process.

0 Kudos

1. in the fieldcatalog for that field , use

wa_fieldcat-fieldname = 'FIELD5'.

wa_fieldcat-edit = 'X'.

2. in the user command subroutine

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = <b>'USER_COMMAND'</b>

FORM <b>USER_COMMAND</b> USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

CASE P_UCOMM.

Data ref1 type ref to cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = ref1.

call method ref1->check_changed_data.

WHEN 'SAVE'.

modify ZTABLE from table itab.

ENDCASE.

ENDFORM.