cancel
Showing results for 
Search instead for 
Did you mean: 

call function from FM

Former Member
0 Kudos

hi, how do i call a function from the function module and use it accordinly? i need call the EDITOR_SYNTAX_CHECK from the FM and use it in my program to check abap syntax that users entered.

pls provide codes.

thanks. will reward if useful.

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

its not solve yet because when i click on the save button, it gave me this error:

Runtime Errors: CALL_FUNCTION_CONFLICT_TYPE

Except.: CX_SY_DYN_CALL_ILLEGAL_TYPE

Short text: Type conflict when calling a function module.

What happened?: Error in the ABAP Applicaiton Program. The current ABAP program had to be terminated because it has come across a statement that unfortunately cannot be executed. A function module was called incorrectly.

Is it because of something wrong with my codes? The following is my codes when i click on the save button:

IF SY-UCOMM = 'SAVE'.

CALL FUNCTION 'EDITOR_SYNTAX_CHECK'

EXPORTING

I_PROGRAM = 'ZEVONNE'

IMPORTING

O_error_include = er_include

O_error_line = er_line

O_error_message = error_message

O_error_offset = er_off

O_error_subrc = er_subrc

TABLES

I_SOURCE = i_tline.

IF er_subrc = 0.

Er_line = er_line - 2.

WRITE: /1 'Error Line:' .

  • WRITE: /1 error_message-line1, error_message-line2,Error_message-line3.

STOP.

ENDIF.

  • MESSAGE S000(ZMSG02).

ENDIF.

Former Member
0 Kudos

Hi,

In the ABAP editor(SE38) .select pattern button on the screen, after clicking that it displays a screen there u select call function and mention the name of the function module over there and again click OK.

code for that function module is displayed in the screen.

mention all the respective import and export parameters u require there.

regards,

vasavi.

kindly reward if helpful.

Former Member
0 Kudos

ok thanks. then if my syntax is correct it will display a success message and if its wrong it will display an error message. how do i do it?

Former Member
0 Kudos

Hi Evonne,

The FM itself will not display any error or sucess message.

It will pass

O_ERROR_INCLUDE --- this is irrelevant to you O_ERROR_LINE --- line number where the error is

O_ERROR_MESSAGE --- the error message

O_ERROR_OFFSET -- leave this

O_ERROR_SUBRC -- leave this

if there is any error above parameters in exporting will get filled up.

After you call this FM

check for them & display message as per your requirement.

Regards,

Vaibhav.

Former Member
0 Kudos

Hi Evonne,

Is your issue resolved, if yes please mark this thread as answered.

**Never forget to reward useful replies.

Regards,

Vaibhav Modi.

Former Member
0 Kudos

hi,

go to ABAP editor click pattern

select call function-->EDITOR_SYNTAX_CHECK

click ok.

below one comes into ur report.

CALL FUNCTION 'EDITOR_SYNTAX_CHECK'

EXPORTING

  • I_GLOBAL_CHECK = ' '

  • I_GLOBAL_PROGRAM = ' '

i_program =

  • I_R2_CHECK = ' '

  • I_R2_DESTINATION = ' '

  • I_TRDIR = ' '

  • I_CORRWARN = ' '

  • ALL_ERRORS = ' '

  • IMPORTING

  • O_ERROR_INCLUDE =

  • O_ERROR_LINE =

  • O_ERROR_MESSAGE =

  • O_ERROR_OFFSET =

  • O_ERROR_SUBRC =

tables

i_source =

  • O_CORRECTION_TAB =

  • O_WARNINGS_TAB =

  • O_ERROR_TAB =

reward if its useful

Former Member
0 Kudos

I_SOURCE = ITAB // table in which all lines of code for syntax check should be there

what is itab? is it the internal table for my database table? or is it i need to create another table jus to store the codes for syntax check function?

Former Member
0 Kudos

Hi,

Itab is an internal table in which you have to pass the lines of code which your user has entered in Text editor.

regards,

Vaibhav Modi

Former Member
0 Kudos

thanks for all of ur replies.

I have a text editor that allows users to enter abap codes and when they clicked on the save button, the program will check the syntax they have entered and prompt them accordinly. how can i call the EDITOR_SYNTAX_CHECK fm and used it for my program?

below is my codes:

REPORT ZEVONNE_DYN.

TABLES: ZPROGRAM_TABLE.

DATA: ITAB_PROGRAM TYPE TABLE OF ZPROGRAM_TABLE WITH HEADER LINE.

DATA: CODE_EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

CODE_EDITOR TYPE REF TO CL_GUI_TEXTEDIT.

DATA: WA_PROGRAM LIKE LINE OF ITAB_PROGRAM,

g_ok_code LIKE sy-ucomm, " return code from screen

g_repid LIKE sy-repid.

DATA: st_head TYPE thead,

i_tline TYPE STANDARD TABLE OF ZPROGRAM_TABLE,

wa_tline TYPE ZPROGRAM_TABLE.

TYPES: BEGIN OF DYN_CODE,

LINE(255),

END OF DYN_CODE.

DATA: DYN_CODE_TABLE TYPE TABLE OF DYN_CODE,

wa_lv LIKE LINE OF DYN_CODE_TABLE.

CONSTANTS: CODE_EDITOR_LENGTH TYPE I VALUE 255.

DATA: BEGIN OF CODE_EDITOR_LINE OCCURS 0,

PROGRAM_CODE TYPE ZPROGRAM_TABLE-PROGRAM_CODE,

END OF CODE_EDITOR_LINE.

TYPES: BEGIN OF CODE_EDITOR_TABLE_LINE,

LINE(CODE_EDITOR_LENGTH) TYPE C,

END OF CODE_EDITOR_TABLE_LINE.

DATA: CODE_EDITOR_TABLE TYPE TABLE OF CODE_EDITOR_TABLE_LINE,

CODE_EDITOR_CONTENTS LIKE STANDARD TABLE OF LINE.

DATA: INSERT_COUNTER TYPE I, INSERT_VALUE(CODE_EDITOR_LENGTH) TYPE C,

GT_HEAD LIKE THEAD.

*ID

DATA l_number TYPE i.

DATA l_number2 TYPE i.

DATA: im_cpidentmax LIKE ZPROGRAM_TABLE-PROGRAM_ID.

*End ID

SELECT * INTO TABLE ITAB_PROGRAM FROM ZPROGRAM_TABLE.

START-OF-SELECTION.

CALL SCREEN 9000.

MODULE STATUS_9000 OUTPUT.

SET PF-STATUS 'SCREEN_9000'.

SET TITLEBAR 'TITLE_9000'.

IF CODE_EDITOR IS INITIAL.

CREATE OBJECT CODE_EDITOR_CONTAINER

EXPORTING

CONTAINER_NAME = 'GEN_CODE'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5.

CREATE OBJECT CODE_EDITOR

EXPORTING

PARENT = CODE_EDITOR_CONTAINER

WORDWRAP_MODE =

  • CL_GUI_TEXTEDIT=>WORDWRAP_OFF

CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION

  • CL_GUI_TEXTEDIT=>WORDWRAP_AT_WINDOWBORDER

WORDWRAP_POSITION = CODE_EDITOR_LENGTH

WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.

ENDIF.

ENDMODULE. "STATUS_9002 OUTPUT

----


  • MODULE USER_COMMAND_9002 INPUT

----


*

----


MODULE USER_COMMAND_9000 INPUT.

CASE SY-UCOMM.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'SAVE'.

MESSAGE S000(ZMSG02).

WHEN 'LOAD'.

  • send table to control

CALL METHOD CODE_EDITOR->set_text_as_r3table

EXPORTING

table = DYN_CODE_TABLE

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = g_repid

txt2 = space

txt1 = text-004.

ENDIF.

  • no flush here:

  • the automatic flush at the end of PBO does the job

ENDCASE.

ENDMODULE. "USER_COMMAND_9002 INPUT

Former Member
0 Kudos

Hi Evonne,

In MODULE USER_COMMAND_9002 INPUT

WHEN 'SAVE'.

CALL FUNCTION "EDITOR_SYNTAX_CHECK"

EXPORTING

I_PROGRAM = 'ZTEMP' // pass any dummy name its ok

TABLES

I_SOURCE = ITAB // table in which all lines of code for syntax check should be there

Use all the importing parameters to find if there is any error.

Hope this solves ur prob.

Reward if reply is useful.

Thanks,

Vaibhav Modi

Former Member
0 Kudos

Hi

In the ABAP editor, Click Pattern, after clicking that write a FM name over there and again click OK.

FM will come over in the screen.

pls reward if help.

Former Member
0 Kudos

Hi,

can u please eloborate what exactly is your prob.

You can call a Fm from another FM with the syntax,

CALL FUNCTION.

Regards,

Vaibhav.