2019 Dec 08 5:48 AM
I need to increase ID users everytime when i will write into database but i dont know how to do it.
2019 Dec 08 6:01 AM
Hi,
Best is to use snro .
If you are not interested in snro then fetch latest userid from DB table and then increment by one and save the next record.
2019 Dec 08 6:57 AM
Hi,
In your code, you are increasing the counter after appending the value to LT_USER. Move 'gv_a = gv_a + 1' code line to 2 lines above, before you assign gv_a to ls_user-user_id.
Else, get the latest record from DB and increment and then put it to DB as suggested by Prasanna above.
GK
2019 Dec 08 8:09 AM
Hello Floso Klim,
You Can follow the below Code:
ls_user-first_name = meno.
ls_user-last_name = priez.
ls_user-school = school.
SELECT MAX( user_id )
INTO @DATA(ls_latest_user)
FROM z04_users.
IF sy-subrc EQ 0.
ls_user-user_id = ls_latest_user + 1.
ELSE.
ls_user-user_id = 1.
ENDIF.
APPEND ls_user TO lt_user.
MODIFY z04_users FROM lt_user.