Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to fetch the field names in update statement

0 Kudos
427

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,

4 REPLIES 4

MateuszAdamus
Active Contributor
328

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,
Mateusz

matt
Active Contributor
328

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/

Sandra_Rossi
Active Contributor
0 Kudos
328

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?

328

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.