Application Development and Automation 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: 
Read only

update ALV grid

Former Member
0 Likes
516

Hi All,

I have displayed one ALV grid on container.

1. while displaying time it is always initial.

2. using the edit buttons user can enter the data in ALV

3. based on the user hit on application tool bar button need to save this data in database table.

my Issue is........

when user hit the application tool bar button... that output table is not updating with user entered data in ALV. How I will get this data into out put table.

I used the Refresh table display method ... but this is not workout for this

I register the event modify cell data .... in this case I got the data except last cell data.

please help me on this issue.

thanks.

Hi All,

I have displayed one ALV grid on container.

1. while displaying time it is always initial.

2. using the edit buttons user can enter the data in ALV

3. based on the user hit on application tool bar button need to save this data in database table.

my Issue is........

when user hit the application tool bar button... that output table is not updating with user entered data in ALV. How I will get this data into out put table.

I used the Refresh table display method ... but this is not workout for this

I register the event modify cell data .... in this case I got the data except last cell data.

please help me on this issue.

thanks.

2 REPLIES 2
Read only

Former Member
0 Likes
458

hi

modify data in alv output and it can save it to ztable

In itab declaration, include field to be selection indicator.

Ex: DATA: BEGIN OF ITAB OCCURS 0 WITH HEADER LINE,

SELECT.

INCLUDE STRUCTURE EKKO.

DATA: END OF ITAB.

In fieldcat declaration, make your desired field attribute editable.

Ex: FIELDCAT-EDIT = 'X'.

In layout declaration, declare your selection indicator from the ITAB.

Ex: p_layouts-sel_mode = 'A'.

p_layouts-box_fname = 'SELECT'.

In user-command form, declare the following codes to check if there's a change in ALV.

data it_grid TYPE REF TO cl_gui_alv_grid.

data p_valid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_repid = sy-repid

e_grid = it_grid.

CALL METHOD it_grid->check_changed_data

IMPORTING

e_valid = p_valid.

if P_VALID = 'X'. Your ALV has been changed and may proceed to your next logic.....

Read only

Former Member
0 Likes
458

Hi,

Please find below scenario which fulfill your requirement.

To change entry in ALV display

WHEN 'CHANGE'.

CLEAR sy-ucomm.

IF index_number = 0.

MESSAGE e004(08) WITH text-s80.

CLEAR sy-ucomm.

ELSE.

PERFORM locktable.

flag = 2.

CALL SCREEN 0300.

ENDIF.

CLEAR sy-ucomm.

CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'

EXPORTING

defaultoption = 'Y'

textline1 = message1

titel = text-024

cancel_display = ' '

IMPORTING

answer = wg_confirm_ind.

CASE wg_confirm_ind.

WHEN 'J'.

PERFORM move_values.

PERFORM change_dbase.

flag = 0.

LEAVE TO SCREEN 150.

WHEN 'N'.

LEAVE TO SCREEN 150.

ENDCASE.

ENDCASE.

  • Then use REFRESH command for updating values from ALV grid to cutom table and on ALV display.

WHEN 'REFRESH'.

CLEAR sy-ucomm.

DATA: lo_repid LIKE sy-repid,

lo_seltab LIKE rsparams OCCURS 0 WITH HEADER LINE.

lo_repid = sy-repid.

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

EXPORTING

curr_report = lo_repid

TABLES

selection_table = lo_seltab

EXCEPTIONS

not_found = 1

no_report = 2

OTHERS = 3.

SUBMIT (sy-repid)

WITH SELECTION-TABLE lo_seltab.

&----


*& Form locktable

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM locktable.

CASE sy-subrc.

WHEN 0.

  • MESSAGE i888 WITH 'Enqueue successful'(001).

MESSAGE s004(08) WITH 'Enqueue sucessfuly'.

  • WHEN 1.

  • DATA : text type c.

  • text = sy-msgv1.

  • MESSAGE e004(08) WITH 'Record already'(002) 'locked by'(003)

  • text.

  • CALL TRANSACTION 'SM12'.

  • WHEN 2 OR 3.

  • MESSAGE e004(08) WITH 'Error in enqueue!'(004)

  • 'SY-SUBRC:' sy-subrc.

ENDCASE.

ENDFORM. " locktable

&----


*& Form move_values

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM move_values.

MOVE i_z23_tblassign12_line-namefirst TO z23_tblassign12-namefirst.

MOVE i_z23_tblassign12_line-namelast TO z23_tblassign12-namelast.

MOVE i_z23_tblassign12_line-dob TO z23_tblassign12-dob.

MOVE i_z23_tblassign12_line-phone TO z23_tblassign12-phone.

MOVE i_z23_tblassign12_line-address TO z23_tblassign12-address.

MOVE i_z23_tblassign12_line-title TO z23_tblassign12-title.

MOVE i_z23_tblassign12_line-plantno TO z23_tblassign12-plantno.

MOVE i_z23_tblassign12_line-department TO z23_tblassign12-department

.

MOVE i_z23_tblassign12_line-experience TO z23_tblassign12-experience

.

MOVE i_z23_tblassign12_line-salary TO z23_tblassign12-salary.

MOVE i_z23_tblassign12_line-grade TO z23_tblassign12-grade.

CLEAR : index_number.

ENDFORM. " move_values

&----


*& Form change_dbase

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM change_dbase.

CASE flag.

WHEN 1.

INSERT INTO z23_tblassign12 VALUES i_z23_tblassign12_line.

COMMIT WORK.

WHEN 2.

PERFORM locktable.

MODIFY z23_tblassign12 FROM i_z23_tblassign12_line.

PERFORM unlocktable.

COMMIT WORK.

WHEN 3.

INSERT INTO z23_tblassign12 VALUES i_z23_tblassign12_line.

COMMIT WORK.

ENDCASE.

IF sy-subrc = 0.

MESSAGE s004(08) WITH 'Entered sucessfuly'.

ELSE.

MESSAGE w005(08) WITH 'Not entered'.

ENDIF.

ENDFORM. " change_dbase

hope you will get some idea from above code.