‎2011 Apr 07 9:02 PM
Hi,
I have a abap report using ALV-Editable to update a Z-table. Data are reading into internal table and the user does modfications in alv-grid; then user confirms these changes and the report call Open-SQL statement UPDATE.
This are the steps:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = c_user_command
is_layout_lvc = gd_layout
it_fieldcat_lvc = t_fieldcat
i_save = 'X'
TABLES
t_outtab = it_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
if sy-subrc = 0.
perform save_data.
endif.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Then user does modifications in this alv-grid and the report call the following subroutine:
&----
*& Form save_data
&----
text
----
form save_data.
perform update_database.
message s000(0k) with text-s01.
endform. "save_data
&----
*& Form update_database
&----
text
----
form update_database.
data: lt_instab type table of zsdpob.
zsdpob-zfrecepok = wa_zsdpob-zfrecepok.
zsdpob-zfrecnofi = wa_zsdpob-zfrecnofi.
zsdpob-zproblema = wa_zsdpob-zproblema.
zsdpob-zmensajero = wa_zsdpob-zmensajero.
zsdpob-zfentregafv = wa_zsdpob-zfentregafv.
zsdpob-zfrecepfv = wa_zsdpob-zfrecepfv.
zsdpob-znroguiad = wa_zsdpob-znroguiad.
zsdpob-znroguiar = wa_zsdpob-znroguiar.
zsdpob-zsobreporte = wa_zsdpob-zsobreporte.
zsdpob-zobserv1 = wa_zsdpob-zobserv1.
zsdpob-zobserv2 = wa_zsdpob-zobserv2.
zsdpob-zobserv3 = wa_zsdpob-zobserv3.
zsdpob-zobserv4 = wa_zsdpob-zobserv4.
zsdpob-zusercflag = sy-uname.
zsdpob-zfechachange = sy-datum.
zsdpob-zhorachange = sy-uzeit.
update zsdpob set zfrecepok = wa_zsdpob-zfrecepok
zfrecnofi = wa_zsdpob-zfrecnofi
zproblema = wa_zsdpob-zproblema
zmensajero = wa_zsdpob-zmensajero
zfentregafv = wa_zsdpob-zfentregafv
zfrecepfv = wa_zsdpob-zfrecepfv
znroguiad = wa_zsdpob-znroguiad
znroguiar = wa_zsdpob-znroguiar
zsobreporte = wa_zsdpob-zsobreporte
zobserv1 = wa_zsdpob-zobserv1
zobserv2 = wa_zsdpob-zobserv2
zobserv3 = wa_zsdpob-zobserv3
zobserv4 = wa_zsdpob-zobserv4
zusercflag = sy-uname
zfechachange = sy-datum
zhorachange = sy-uzeit
where zvbeln = wa_zsdpob-vbeln
and zbukrs = wa_zsdpob-bukrs
and zfkdat = wa_zsdpob-fkdat
and zfkart = wa_zsdpob-fkart
and zwerks = wa_zsdpob-werks
and zfksto = wa_zsdpob-fksto.
if sy-subrc = 0.
message '!!!Update OK!!!!' type 'I'.
else.
message '!!!Update Error!!!!' type 'I'.
endif.
update zsdpob from table lt_instab.
endform. "update_database
But nothing is record in the table. What's section in my code is wrong? Can any guy help me?
Thanks.
‎2011 Apr 07 9:13 PM
‎2011 Apr 07 9:13 PM
‎2011 Apr 08 12:49 PM
Thanks Sebastian,
Although I inserted this instruction in my code, however nothing is done.
‎2011 Apr 08 2:32 PM
From your ALV, have you actually obtained anything to update (e.g., your data fields are not initial going into the update command)? You have run in debug to watch what is happening? There's a huge gap here that you're not showing....from ALV to update step....what are you doing in the middle to get the data the user changed?
With update, you are CHANGING an existing record....is that what you're trying to do? If not, use MODIFY or do a SELECT from the db table for the key values and choose to update or insert, based on your zero or non-zero return code for the SELECT. MODIFY will result in the correct decision (update or insert) for you, but is more expensive from an efficiency viewpoint. What is your sy-dbcnt after the update command?
Edited by: BreakPoint on Apr 8, 2011 3:32 PM