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

Generate Function But Can't Call It? --Reload

Former Member
0 Likes
1,368

hi all,

I have program like below, but the SAP system tell me "Call Function NOT FOUND" when lv_idx = 2.

How to make it work?


*&---------------------------------------------------------------------*
*& Report  Z_TEST_DYN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  z_test_dyn.


DATA fname TYPE rs38l-name.
DATA:
      lt_code TYPE TABLE OF rssource,
      lv_idx TYPE n LENGTH 3 VALUE 0.

APPEND 'write: /''test''.' TO lt_code.

DO 10 TIMES.
  ADD 1 TO lv_idx.
  CONCATENATE 'Z_TEST_' lv_idx INTO fname.
  CALL FUNCTION 'RS_FUNCTIONMODULE_INSERT'
    EXPORTING
      funcname                      = fname
      function_pool                 = 'ZIF_FGDYN'
*     INTERFACE_GLOBAL              = ' '
*     REMOTE_CALL                   = ' '
      short_text                    = 'TEST'
*     SUPPRESS_CORR_CHECK           = 'X'
*     UPDATE_TASK                   = ' '
*     CORRNUM                       = ' '
*     NAMESPACE                     = ' '
*     SUPPRESS_LANGUAGE_CHECK       = 'X'
*     AUTHORITY_CHECK               = 'X'
*     SAVE_ACTIVE                   = 'X'
*     NEW_SOURCE                    =
*     EXCEPTION_CLASS               = ' '
*     SUPPRESS_UPGRADE_CHECK        = ' '
*   IMPORTING
*     FUNCTION_INCLUDE              =
*     CORRNUM_E                     =
   TABLES
*     IMPORT_PARAMETER              =
*     EXPORT_PARAMETER              =
*     TABLES_PARAMETER              =
*     CHANGING_PARAMETER            =
*     EXCEPTION_LIST                =
*     PARAMETER_DOCU                =
     SOURCE                        = lt_code
   EXCEPTIONS
     double_task                   = 1
     error_message                 = 2
     function_already_exists       = 3
     invalid_function_pool         = 4
     invalid_name                  = 5
     too_many_functions            = 6
     no_modify_permission          = 7
     no_show_permission            = 8
     enqueue_system_failure        = 9
     canceled_in_corr              = 10
     OTHERS                        = 11
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  CALL FUNCTION 'FUNCTION_EXISTS'
    EXPORTING
      funcname                 = fname
*   IMPORTING
*     GROUP                    =
*     INCLUDE                  =
*     NAMESPACE                =
*     STR_AREA                 =
   EXCEPTIONS
     function_not_exist       = 1
     OTHERS                   = 2
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  CALL FUNCTION 'SBUF_SYNCHRONIZE'
    EXCEPTIONS
      c_func_error = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'FUNCTION_EXISTS'
    EXPORTING
      funcname                 = fname
*   IMPORTING
*     GROUP                    =
*     INCLUDE                  =
*     NAMESPACE                =
*     STR_AREA                 =
   EXCEPTIONS
     function_not_exist       = 1
     OTHERS                   = 2
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION fname      <<<<<<<<<< Error when twice here
    TABLES
      et_table = lt_a.

ENDDO.

regards,

jkchen

Edited by: jkchen on Nov 26, 2010 7:13 AM

Edited by: jkchen on Nov 26, 2010 7:15 AM

hi all,

I have program like below, but the SAP system tell me "Call Function NOT FOUND" when lv_idx = 2.

How to make it work?


*&---------------------------------------------------------------------*
*& Report  Z_TEST_DYN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  z_test_dyn.


DATA fname TYPE rs38l-name.
DATA:
      lt_code TYPE TABLE OF rssource,
      lv_idx TYPE n LENGTH 3 VALUE 0.

APPEND 'write: /''test''.' TO lt_code.

DO 10 TIMES.
  ADD 1 TO lv_idx.
  CONCATENATE 'Z_TEST_' lv_idx INTO fname.
  CALL FUNCTION 'RS_FUNCTIONMODULE_INSERT'
    EXPORTING
      funcname                      = fname
      function_pool                 = 'ZIF_FGDYN'
*     INTERFACE_GLOBAL              = ' '
*     REMOTE_CALL                   = ' '
      short_text                    = 'TEST'
*     SUPPRESS_CORR_CHECK           = 'X'
*     UPDATE_TASK                   = ' '
*     CORRNUM                       = ' '
*     NAMESPACE                     = ' '
*     SUPPRESS_LANGUAGE_CHECK       = 'X'
*     AUTHORITY_CHECK               = 'X'
*     SAVE_ACTIVE                   = 'X'
*     NEW_SOURCE                    =
*     EXCEPTION_CLASS               = ' '
*     SUPPRESS_UPGRADE_CHECK        = ' '
*   IMPORTING
*     FUNCTION_INCLUDE              =
*     CORRNUM_E                     =
   TABLES
*     IMPORT_PARAMETER              =
*     EXPORT_PARAMETER              =
*     TABLES_PARAMETER              =
*     CHANGING_PARAMETER            =
*     EXCEPTION_LIST                =
*     PARAMETER_DOCU                =
     SOURCE                        = lt_code
   EXCEPTIONS
     double_task                   = 1
     error_message                 = 2
     function_already_exists       = 3
     invalid_function_pool         = 4
     invalid_name                  = 5
     too_many_functions            = 6
     no_modify_permission          = 7
     no_show_permission            = 8
     enqueue_system_failure        = 9
     canceled_in_corr              = 10
     OTHERS                        = 11
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  CALL FUNCTION 'FUNCTION_EXISTS'
    EXPORTING
      funcname                 = fname
*   IMPORTING
*     GROUP                    =
*     INCLUDE                  =
*     NAMESPACE                =
*     STR_AREA                 =
   EXCEPTIONS
     function_not_exist       = 1
     OTHERS                   = 2
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  CALL FUNCTION 'SBUF_SYNCHRONIZE'
    EXCEPTIONS
      c_func_error = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'FUNCTION_EXISTS'
    EXPORTING
      funcname                 = fname
*   IMPORTING
*     GROUP                    =
*     INCLUDE                  =
*     NAMESPACE                =
*     STR_AREA                 =
   EXCEPTIONS
     function_not_exist       = 1
     OTHERS                   = 2
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION fname      <<<<<<<<<< Error when twice here
    TABLES
      et_table = lt_a.

ENDDO.

regards,

jkchen

Edited by: jkchen on Nov 26, 2010 7:13 AM

Edited by: jkchen on Nov 26, 2010 7:15 AM

9 REPLIES 9
Read only

Former Member
0 Likes
1,314

Need help, wait online.

regards.

jkchen

Read only

0 Likes
1,314

hi Jkchen ,

Can you please check if the FM are created when you execute the program .

Please execute the program debugging it and see if FM is created.

Regards,

Arun

Read only

0 Likes
1,314

hi Arun,

I'm sure the FM is created successful, and I can see them in SE80 when i debugging. But system still throw exception...

Read only

Former Member
0 Likes
1,314

Hi,

check the value from fname after

CONCATENATE 'Z_TEST_' lv_idx INTO fname.

It could be better to go on with the last fuba, only if the fuba before is succesfully.

CALL FUNCTION 'FUNCTION_EXISTS'

EXPORTING

funcname = fname

  • IMPORTING

  • GROUP =

  • INCLUDE =

  • NAMESPACE =

  • STR_AREA =

EXCEPTIONS

function_not_exist = 1

OTHERS = 2

.

IF sy-subrc 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

if sy-subrc eq 0.

CALL FUNCTION fname <<<<<<<<<< Error when twice here

TABLES

et_table = lt_a.

Read only

0 Likes
1,314

hi Nicole,

I'm sure the value of sy-subrc is zero after every call function 'FUNCTION_EXISTS'.

Read only

0 Likes
1,314

Hi Jkchen ,

I tested your code in my system and the FM are created , i have a doubt in the last starement when you are callinf the FM why are you using the paramater

TABLES

et_table = lt_a.

When i look at the FM created it does not have any interface parameters. This might be causing the error.

Regards

Arun

Read only

0 Likes
1,314

hi Arun,

that's a mistake...I forget to delete the parameter...

Read only

0 Likes
1,314

Hi jkchen,

I am not sure what is the issue , as if i call the Fm after exiting the do- enddo loop then it works fine.

This is a bit strange as the FM is existing in the system.

Regards,

Arun

Read only

0 Likes
1,314

hi Arun,

Thanks a lot. maybe this is a bug.

regards