Skip to Content
author's profile photo Former Member
Former Member

call function from FM

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2008 at 07:29 AM

    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?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2008 at 06:46 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2008 at 06:49 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2008 at 07:04 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2008 at 08:24 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2008 at 08:24 AM

    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?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 04:36 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 07:13 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.