如何为 ABAP 中的现有记录修改数据库 table 中的数据?

How to Modify the data inside database table for existing record in ABAP?

我创建了数据库 table ZSP_EMP_DET,我在其中通过屏幕提供值来执行 CRUD 操作。

所以我试图查找记录是否已存在于 table 中,如果发现通过屏幕更新值但值未在 DB table.

中修改
    DATA zsp_emp_det TYPE zsp_emp_det.
    DATA gwa_emp type table of zsp_emp_det.

    gwa_emp-empid = zsp_emp_det-empid.     "it is a name given to input fields on screen

    SELECT * from ZSP_EMP_DET
        where empid = gwa_emp-empid.

    IF sy-subrc = 0.
        gwa_emp-fname = zsp_emp_det-fname.
        gwa_emp-lname = zsp_emp_det-lname.
        gwa_emp-loc = zsp_emp_det-loc.
        gwa_emp-designation = zsp_emp_det-designation.
        gwa_emp-bdate = zsp_emp_det-bdate.
        gwa_emp-doj = zsp_emp_det-doj.
    
        MODIFY zsp_emp_det FROM gwa_emp.
    
    
        MESSAGE 'Data Modified Successfully' TYPE 'S'.
    
    ELSE.
        MESSAGE 'Data is not Modified' TYPE 'E'.
    ENDIF.

您需要填写结构中的主要字段。我不确定 table 结构。您可以使用相应的移动来填充您的结构,或者您可以 select 进入如下结构。

 SELECT * 
   FROM ZSP_EMP_DET
   INTO gwa_emp
        where empid = gwa_emp-empid.