sumedh patil
sumedh patil

Reputation: 59

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.

Upvotes: 0

Views: 4568

Answers (1)

mkysoft
mkysoft

Reputation: 5758

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.

Upvotes: 2

Related Questions