2020 Oct 11 10:46 AM
hi ,
i have a requirement where i have to scan a report and check whether a update statement is used to update the keyfields of the DB table.
lv_stat will have each line of the report.
code:
IF lv_stat CS 'UPDATE'.
CHECK lv_stat+0(6) = 'UPDATE'.
SPLIT lv_stat AT space INTO lv_str_1 lv_str_2 lv_str_3.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING tabname = lv_str_2
TABLES dfies_tab = it_field.
next , i have to compare the fields in it_field with the field used in the update statement. But there are many ways of writing update statement ! . can anyone suggest how i can fetch the field names used.
Thanks,
2020 Oct 11 12:13 PM
Hello vijayashri
Have a look at class CL_ORA_ACTION_JSEL and its method PARSE_SQL_STATEMENT. It might help you (or give a hint) with parsing of the SQL statement.
You could also search for the key fields of the table in the UPDATE statement. If these are found then these are updated.
Kind regards,2020 Oct 11 2:19 PM
Definitely use the output of parsed / tokenised code rather than the source code itself. it's MUCH easier.
See this blog https://blogs.sap.com/2019/04/22/how-to-scan-abap-code/
2020 Oct 11 1:59 PM
Of what I know, there is only one way to update the key fields (I guess from the primary key), other UPDATE variants can't update the key fields:
UPDATE tablename
SET keyfield1 = ..., keyfield2 = ..., other fields ...
WHERE ...
It seems pretty easy to parse. Can you explain what is your issue?
2020 Oct 12 8:51 AM
Hi Sandra ,
Thanks for the help. I was thinking if the key fields are updated through work area but it is not possible. The issue is resolved.
Regards,
Vijayashri.