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: 
Read only

fm syntax check

Former Member
0 Likes
1,882

Hi all.

i need to have a fm to check for syntax error when user key in some sql statement into my input field. What is the FM for checking syntax for sql statement? thks

17 REPLIES 17
Read only

Former Member
0 Likes
1,843

Hi Gary,

Use RS_SYNTAX_CHECK

pass your code in I_SOURCE

Regards,

Atish

Read only

0 Likes
1,843

I got doubt in the FM part. I had declare the ' value' to store my sql statement. This sql statement had error. i need the 'RS_SYNTAX_CHECK' to make a check on my sql. I also expect a error message. How can i do it? Pls change my code if there any mistake. thankS!

data: value(30) type c.

value = 'Select * from student where'

CALL FUNCTION 'RS_SYNTAX_CHECK'

EXPORTING

  • I_GLOBAL_CHECK = ' '

  • I_GLOBAL_PROGRAM = ' '

I_PROGRAM =

  • I_WITH_DIALOG = ' '

  • IMPORTING

  • O_ERROR_INCLUDE =

  • O_ERROR_LINE =

  • O_ERROR_MESSAGE =

  • O_ERROR_OFFSET =

  • O_ERROR_SUBRC =

  • O_NAVIGATE =

  • CANCEL =

TABLES

I_SOURCE = <b>value</b>

.

Read only

0 Likes
1,843

Hi Gary,

I_SOURCE is a table.

You need to define a internal table in your code. In the same way you defined in your earlier program using TYPES...

Just have a field of type string and then append your SQL to that table and pass that table to this FM

regards,

Atish

Read only

0 Likes
1,843

Hello,

You need to pass the program name since this is mandatory!

Which also means that you cannot just pass a source code having just the query .

You'll have to put that query in a program . Convert that program source code into an internal table and pass that internal table here.

Hope this helps you.

Regards

Nishant

Read only

0 Likes
1,843

okie i go try. thank

Read only

0 Likes
1,843

i try but i gt syntax error when activate. Below is my problem code

I got this syntax error: The field "TABLES" is unknown, but there is a field with the similar name "<TABLE>". "<TABLE>".

CONSTANTS: line_length TYPE i VALUE 255.

TYPES:

BEGIN OF t_texttable,

line(line_length) TYPE c,

END OF t_texttable.

DATA

i_texttable TYPE TABLE OF t_texttable.

data: value(30) type c.

Start-Of-Selection.

APPEND value TO i_texttable.

CALL FUNCTION 'RS_SYNTAX_CHECK'

EXPORTING

  • I_GLOBAL_CHECK = ' '

  • I_GLOBAL_PROGRAM = ' '

I_PROGRAM =

  • I_WITH_DIALOG = ' '

  • IMPORTING

  • O_ERROR_INCLUDE =

  • O_ERROR_LINE =

  • O_ERROR_MESSAGE =

  • O_ERROR_OFFSET =

  • O_ERROR_SUBRC =

  • O_NAVIGATE =

  • CANCEL =

TABLES

I_SOURCE = i_texttable

.

Read only

0 Likes
1,843

Hi Gary,

Change it to

CONSTANTS: line_length TYPE i VALUE 255.

TYPES:

BEGIN OF t_texttable,

line(line_length) TYPE c,

END OF t_texttable.

DATA

i_texttable TYPE TABLE OF t_texttable.

DATA wa_texttable TYPE t_texttable.

data: value(30) type c.

Start-Of-Selection.

MOVE value TO wa_texttable-line.

APPEND wa_texttable TO t_texttable.

CALL FUNCTION 'RS_SYNTAX_CHECK'

EXPORTING

  • I_GLOBAL_CHECK = ' '

  • I_GLOBAL_PROGRAM = ' '

I_PROGRAM =

  • I_WITH_DIALOG = ' '

  • IMPORTING

  • O_ERROR_INCLUDE =

  • O_ERROR_LINE =

  • O_ERROR_MESSAGE =

  • O_ERROR_OFFSET =

  • O_ERROR_SUBRC =

  • O_NAVIGATE =

  • CANCEL =

TABLES

I_SOURCE = i_texttable

Regards,

Atish

Read only

0 Likes
1,843

i cut and copy the code but i still hav syntax error:

The field "T_TEXTTABLE" is unknown, but there are the following fields

with similar names: "I_TEXTTABLE" and "WA_TEXTTABLE".

Read only

0 Likes
1,843

Hi

Sorry for that

just change

t_texttable to i_ texttable

Regards,

Atish

Read only

0 Likes
1,843

i gt another error again:

Field "TABLES" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement. "DATA" statement.

The word in bold is the error.

below is my code.

CONSTANTS: line_length TYPE i VALUE 255.

TYPES:

BEGIN OF t_texttable,

line(line_length) TYPE c,

END OF t_texttable.

DATA

i_texttable TYPE TABLE OF t_texttable.

DATA wa_texttable TYPE t_texttable.

data: value(50) type c.

START-OF-SELECTION.

MOVE value TO wa_texttable-line.

APPEND wa_texttable TO i_texttable.

CALL FUNCTION 'RS_SYNTAX_CHECK'

EXPORTING

  • I_GLOBAL_CHECK = ' '

  • I_GLOBAL_PROGRAM = ' '

I_PROGRAM =

  • I_WITH_DIALOG = ' '

  • IMPORTING

  • O_ERROR_INCLUDE =

  • O_ERROR_LINE =

  • O_ERROR_MESSAGE =

  • O_ERROR_OFFSET =

  • O_ERROR_SUBRC =

  • O_NAVIGATE =

  • CANCEL =

<b>TABLES</b>

I_SOURCE = i_texttable.

Read only

0 Likes
1,843

Hi Gary,

CALL FUNCTION 'RS_SYNTAX_CHECK'

EXPORTING

I_PROGRAM = sy-repid

  • I_WITH_DIALOG = ' '

  • IMPORTING

  • O_ERROR_INCLUDE =

  • O_ERROR_LINE =

  • O_ERROR_MESSAGE =

  • O_ERROR_OFFSET =

  • O_ERROR_SUBRC =

  • O_NAVIGATE =

  • CANCEL =

TABLES

I_SOURCE = i_texttable.

Regards,

Atish

Read only

0 Likes
1,843

Also Gary to get the errors record you need to fill get the importing parameters

  • IMPORTING

  • O_ERROR_INCLUDE =

  • O_ERROR_LINE =

  • O_ERROR_MESSAGE =

  • O_ERROR_OFFSET =

  • O_ERROR_SUBRC =

  • O_NAVIGATE =

  • CANCEL =

regards,

Atish

Read only

0 Likes
1,843

now i have no error text. i tested. There's no response or error check on my sql statement. How to perform the check which i can implement this FM in my program?

Read only

0 Likes
1,843

You need to get that using defining all the IMPORTING table.

Just do where used list on this FM and you can get an idea.

Regards,

Atish

Read only

0 Likes
1,843

gary please specify the program name for i_program the error will be removed.

give the program name in '' and in capital

Read only

0 Likes
1,843

do u hav ready code to demo? Cos i dont know hw to set the paramater

Read only

Former Member
0 Likes
1,843

I think if you'll just pass the SQL statement which is having no data declaration, syntax check will give errors so pass the data declaration also of the variables that are being used.

Regards

Nishant