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 Edit

kesavadas_thekkillath
Active Contributor
0 Kudos

How to Modify the values in ALV and upload it ot DB.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Mohammed,

1.In Fieldcat structure say EDIT = 'X'.

2. Refresh the ALV to get the new result & then do your process..

If the hint is useful… Say thanks by reward….

Regards,

Prabhu Rajesh

Message was edited by:

PrabhuRajesh Janardanan

4 REPLIES 4

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check this link.I am explaining the same concept in OOPS alv here.

Editing and Saving OOPS ALV

https://wiki.sdn.sap.com/wiki/pages/pointstab/viewpageversion.action?pageId=37472&version=3

Former Member
0 Kudos

Hi Mohammed,

1.In Fieldcat structure say EDIT = 'X'.

2. Refresh the ALV to get the new result & then do your process..

If the hint is useful… Say thanks by reward….

Regards,

Prabhu Rajesh

Message was edited by:

PrabhuRajesh Janardanan

Former Member
0 Kudos

hi,

<b>this is a sample program , copy this & exxcute..

in this, click on the NAMES, then after that dril;l down , u can edit & save...</b>

REPORT ZSBN_10_OCT .

&----


*& Report ZTEST_ALV_EDIT *

*& *

&----


*& FOR EDITING ALV *

*& *

&----


----


  • Part 1 - External Tables (DDIC) *

----


TYPE-POOLS: slis.

----


  • PART 2 - USER DEFINED DATA TYPES

----


TYPES : BEGIN OF st_detls,

edit(1) TYPE c, "THIS FIELD HAS TO BE MARKED IF RECORD HAS

*TO BE EDITED

name(20) TYPE c,

company(20) TYPE c,

END OF st_detls.

----


  • PART 3 - INTERNAL TABLES AND WORK AREAS

----


DATA : it_detls_edit TYPE TABLE OF st_detls.

DATA : it_detls TYPE TABLE OF st_detls.

DATA : wa_detls TYPE st_detls.

DATA : wrk_index TYPE i.

*---TABLES USED FOR ALV

DATA : it_fcat TYPE slis_t_fieldcat_alv.

DATA : wa_fcat LIKE LINE OF it_fcat.

DATA : i_layout TYPE slis_layout_alv.

START-OF-SELECTION.

--GET THE DATA--


PERFORM f_get_data.

--SET THE FIELD CATALOGUE--


PERFORM f_set_field_catlogue.

---CALL ALV--


PERFORM f_call_alv.

&----


*& Form f_get_data

&----


  • GET THE DATA

----


FORM f_get_data .

CLEAR wa_detls.

wa_detls-edit = ' '. "THE RECORD WHICH HAS TO BE EDITED HAS

  • TO BE MARKED X.

wa_detls-name = 'BAIJU'.

wa_detls-company = 'WIPRO'.

APPEND wa_detls TO it_detls.

CLEAR wa_detls.

wa_detls-edit = ' '.

wa_detls-name = 'ANUJ'.

wa_detls-company = 'WIPRO'.

APPEND wa_detls TO it_detls.

CLEAR wa_detls.

wa_detls-edit = ' '.

wa_detls-name = 'SHREE'.

wa_detls-company = 'WIPRO'.

APPEND wa_detls TO it_detls.

CLEAR wa_detls.

wa_detls-edit = 'X'.

wa_detls-name = 'DON'.

wa_detls-company = 'IVL'.

APPEND wa_detls TO it_detls.

CLEAR wa_detls.

wa_detls-edit = 'X'.

wa_detls-name = 'SAJITH'.

wa_detls-company = 'IVL'.

APPEND wa_detls TO it_detls.

CLEAR wa_detls.

wa_detls-edit = ' '.

wa_detls-name = 'SABIN'.

wa_detls-company = 'CAP GEMINI'.

APPEND wa_detls TO it_detls.

CLEAR wa_detls.

wa_detls-edit = 'X'.

wa_detls-name = 'BINOY'.

wa_detls-company = 'CAP GEMINI'.

APPEND wa_detls TO it_detls.

ENDFORM. " f_get_data

&----


*& Form f_set_field_catlogue

&----


  • SET FIELD CATLOGUE

----


FORM f_set_field_catlogue .

CLEAR it_fcat[].

CLEAR wa_fcat.

wa_fcat-fieldname = 'NAME'.

wa_fcat-tabname = 'IT_DETLS'.

wa_fcat-seltext_m = 'NAME'.

wa_fcat-hotspot = 'X'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

wa_fcat-fieldname = 'COMPANY'.

wa_fcat-tabname = 'IT_DETLS'.

wa_fcat-seltext_m = 'COMPANY'.

APPEND wa_fcat TO it_fcat.

ENDFORM. " f_set_field_catlogue

&----


*& Form f_call_alv

&----


  • CALL ALV

----


FORM f_call_alv .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'F_USERCOMMAND_ALV'

it_fieldcat = it_fcat

TABLES

t_outtab = it_detls.

ENDFORM. " f_call_alv

&----


*& Form F_WRITE_ITAB

&----


  • WRITE ITAB

----


FORM f_write_itab .

CLEAR wa_detls.

LOOP AT it_detls INTO wa_detls.

WRITE : /, wa_detls-edit, wa_detls-name, wa_detls-company.

CLEAR wa_detls.

ENDLOOP.

ENDFORM. " F_WRITE_ITAB

.

&----


*& Form f_set_field_catlogue_sec

&----


  • SET FIELD CATLOGUE FOR SECONDARY

----


FORM f_set_field_catlogue_sec .

CLEAR it_fcat[].

CLEAR wa_fcat.

wa_fcat-fieldname = 'NAME'.

wa_fcat-tabname = 'IT_DETLS'.

wa_fcat-seltext_m = 'NAME'.

APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

wa_fcat-fieldname = 'COMPANY'.

wa_fcat-tabname = 'IT_DETLS'.

wa_fcat-seltext_m = 'COMPANY'.

APPEND wa_fcat TO it_fcat.

ENDFORM. "f_set_field_catlogue_SEC

&----


*& Form F_USERCOMMAND_ALV

&----


  • USER COMMAND FOR ALV

----


FORM f_usercommand_alv USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield."#EC *

CASE r_ucomm.

WHEN '&IC1'.

CLEAR it_detls_edit.

CLEAR wa_detls.

CLEAR wrk_index.

*--store the line number of the record in the orginal internal table.

wrk_index = rs_selfield-tabindex.

*--read that record

READ TABLE it_detls INTO wa_detls INDEX wrk_index.

*--check whether is allowed to be edited

IF wa_detls-edit = 'X'.

*--if thius is editable then put that work area to an internal tbale

*--and then call a new using the new internal table

APPEND wa_detls TO it_detls_edit.

*--set the new field catalgue and also call new alv.

SET SCREEN 0.

PERFORM f_set_field_catlogue_sec.

PERFORM f_call_alv_sec.

ENDIF.

ENDCASE.

ENDFORM. "F_USERCOMMAND_ALV

&----


*& Form F_USERCOMMAND_ALV

&----


  • USER COMMAND FOR ALV

----


FORM f_usercommand_alv_sec USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield."#EC *

CASE r_ucomm.

*--when the user pressses the save button the orginal internal table is

*modified wiht

*--the current record.

*--for that we are usign the index of the orginal one which the user has

  • previously selected,

*---FOR SAVING

WHEN '&DATA_SAVE'.

*--Reads the current change made

CLEAR wa_detls.

READ TABLE it_detls_edit INTO wa_detls INDEX 1.

*--Mdify the record in the orginal internal table

MODIFY it_detls FROM wa_detls INDEX wrk_index.

*--Set the field caltalogue and call ALV once more..

*--here the field cataouge is called because the same set of code is

*used both, this can be optiinzed

SET SCREEN 0.

PERFORM f_set_field_catlogue.

PERFORM f_call_alv.

ENDCASE.

ENDFORM. "F_USERCOMMAND_ALV

&----


*& Form f_call_alv_sec

&----


  • CALL ALV

----


FORM f_call_alv_sec.

i_layout-edit = 'X'.

i_layout-no_hotspot = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'F_USERCOMMAND_ALV_SEC'

is_layout = i_layout

it_fieldcat = it_fcat

TABLES

t_outtab = it_detls_edit.

ENDFORM. " f_call_alv_sec

<b>after SAVE, modify ur DB Table by looping ur itab</b>

reply back..

With Rgds,

S.Barani

Former Member
0 Kudos

The field which u want 2 modify..cahnge its field catalog as

Add

<tabmname>-edit = 'X'.

Reward if helpful