‎2007 Oct 03 4:07 AM
Hi all,
I have a piece of code ,
zest_obj-zproject_id = s_pid.
zest_obj-zricef_id = s_rid.
zest_obj-zobject_type = s_obtyp.
zest_obj-zcomplex_id = v_id.
zest_obj-zcomplex_seqno = v_seqno.
CASE v_ucomm.
WHEN 'SAVED'.
v_mess = 'Saved as Draft Version'.
zest_obj-zversion = 'D'.
WHEN 'SAVEF'.
v_mess = 'Saved as Final Version'.
zest_obj-zversion = 'F'.
ENDCASE.
zest_obj-zmanhours = v_tot.
IF fg_change NE 'X'.
INSERT zest_obj from zest_obj.
ELSE.
MODIFY zest_obj FROM zest_obj.
ENDIF.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
MESSAGE v_mess TYPE 'S'.
ELSE.
MESSAGE 'Record Not saved' TYPE 'E'.
ENDIF.
while executing my Transaction i got an error "
An SQL error occurred when accessing a table"
<b></b>
‎2007 Oct 03 4:13 AM
Are you extracting all the keys for custom table correctly?
MODIFY statement works in both way - if record is not present in table, it creates one. If record is present in table, it updates. Can you just try with single MODIFY command, comment INSERT command.
‎2007 Oct 03 4:17 AM
I tried that too... still i'm getting the same error.... eventhough it is a new record...
‎2007 Oct 03 4:21 AM
Can you change the work area name to Z_***. I feel the name of table and work area is same, that might be causing the problem.
‎2007 Oct 03 4:23 AM
no i didnt create a separate work area...
i am using the DB Table as a work area to Insert.
‎2007 Oct 03 4:25 AM
‎2007 Oct 03 6:09 AM
Hi,
I think you are trying to insert records in customized database table.
In the following code i created a database table zpspnrdate with key field index.
here look into the code and you find that i am using the modify statement and directly updating the database table from internal table.
READ TABLE itab INDEX indx.
SELECT MAX( zindex ) INTO zindex FROM zpspnrdate.
zpspnrdate-zindex = zindex + 1.
zpspnrdate-pspnr = itab-pspnr.
zpspnrdate-zimi = itab-imi_date.
zpspnrdate-zdatetype ='IMI DATE'.
zpspnrdate-modfdate = sy-datum.
zpspnrdate-zuser = sy-uname.
zpspnrdate-zutime = sy-uzeit.
MODIFY zpspnrdate.
IF sy-subrc EQ '0'.
MESSAGE ' Record Updated Successfully!' TYPE 'S'.
ENDIF.
try in this way.
<i><b>regards
Debjani
Rewards point for all helpful answer</b></i>