简体   繁体   中英

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

I have created database table ZSP_EMP_DET inside which I am performing CRUD operations by providing values through screen.

So I have tried to find if record is already present in table or not and if found update values through screen but values are not getting modified inside 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.

You need to fill primary fields in your structure. I am not sure table structure. You can use move corresponding for filling your structure or you can select into structure like below.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM