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

Dynamic FM call using Structures and Tables

former_member213851
Active Contributor
0 Likes
1,039

Hi All,

I am trying to call dynamic FMs. I am getting null object reference dump although I am passing respective data references.

I referred below links but couldn't help me to fix the issue:

ABAP Keyword Documentation

I assume that either value or data_ref column will have object references based on kind.

Dump :

Runtime Errors    -    DATREF_NOT_ASSIGNED

Except.               -    CX_SY_DYN_CALL_PARAM_MISSING

Please see the attachment.

Code:

    lt_import[] = ls_details-import[].

     lt_export[] = ls_details-export[].

     lt_change[] = ls_details-change[].

     lt_tables[] = ls_details-tables[].

     lt_except[] = ls_details-except[].

     lt_paratx[] = ls_details-paramtext[].

* Import Parameters

     LOOP AT lt_import INTO ls_import WHERE optional = space.

       ls_ptab-name = ls_import-parameter.

       ls_ptab-kind = abap_func_importing.

       IF ls_import-structure IS NOT INITIAL .

         CREATE DATA lfs_dref TYPE (ls_import-structure).

         ls_ptab-value  = lfs_dref.     "set data type

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:lfs_dref,ls_ptab, ls_import.

     ENDLOOP.

* Export Parameters

     LOOP AT lt_export INTO ls_export WHERE optional = space  .

       ls_ptab-name = ls_export-parameter.

       ls_ptab-kind = abap_func_exporting.

       IF ls_export-structure IS NOT INITIAL.

         CREATE DATA lfs_dref TYPE (ls_export-structure).

         ls_ptab-value  = lfs_dref.     "set data type

         ls_ptab-tables_wa  = lfs_dref.

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:ls_ptab, ls_export.

     ENDLOOP.

* Changing Parameters

     LOOP AT lt_change INTO ls_change WHERE  optional = space..

       ls_ptab-name = ls_change-parameter.

       ls_ptab-kind = abap_func_changing.

       IF ls_change-structure IS NOT INITIAL.

         CREATE DATA lfs_dref TYPE (ls_change-structure).

         ls_ptab-value  = lfs_dref.     "set data type

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:ls_ptab, ls_change.

     ENDLOOP.

* Tables

     LOOP AT lt_tables INTO ls_tables WHERE  optional = space..

       ls_ptab-name = ls_tables-parameter.

       ls_ptab-kind = abap_func_tables.

       IF ls_tables-structure IS NOT INITIAL.

         CREATE DATA lfs_dref TYPE (ls_tables-structure).

         ls_ptab-tables_wa  = lfs_dref.

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:ls_ptab, ls_change.

     ENDLOOP.

* Exceptions

     LOOP AT lt_except INTO ls_except.

       ls_etab-name = ls_except-parameter.

       ls_etab-value = sy-tabix.

       INSERT ls_etab INTO TABLE lt_etab.

       CLEAR ls_etab..

     ENDLOOP.

* Call Dynamic FM name to chck for runtime exceptions

     CALL FUNCTION lv_fm_name

       PARAMETER-TABLE

       lt_ptab

       EXCEPTION-TABLE

       lt_etab.

     CLEAR ls_stxfadm.

   ENDLOOP.




1 ACCEPTED SOLUTION
Read only

former_member213851
Active Contributor
0 Likes
794

Issue resolved.

Signature of FM was fetched using class CL_FB_FUNCTION_UTILITY=>METH_GET_INTERFACE.

Here Importing parameters in FM definition  will act as Exporting parameters while passing signature to dynamic FM using    PARAMETER-TABLE and vice-versa.

So       ls_ptab-kind = abap_func_importing is changed to   ls_ptab-kind = abap_func_exporting in First loop.

and     ls_ptab-kind = abap_func_exporting is changed to   ls_ptab-kind = abap_func_importing  in second loop.

Hi All,

I am trying to call dynamic FMs. I am getting null object reference dump although I am passing respective data references.

I referred below links but couldn't help me to fix the issue:

ABAP Keyword Documentation

I assume that either value or data_ref column will have object references based on kind.

Dump :

Runtime Errors    -    DATREF_NOT_ASSIGNED

Except.               -    CX_SY_DYN_CALL_PARAM_MISSING

Please see the attachment.

Code:

    lt_import[] = ls_details-import[].

     lt_export[] = ls_details-export[].

     lt_change[] = ls_details-change[].

     lt_tables[] = ls_details-tables[].

     lt_except[] = ls_details-except[].

     lt_paratx[] = ls_details-paramtext[].

* Import Parameters

     LOOP AT lt_import INTO ls_import WHERE optional = space.

       ls_ptab-name = ls_import-parameter.

       ls_ptab-kind = abap_func_importing.

       IF ls_import-structure IS NOT INITIAL .

         CREATE DATA lfs_dref TYPE (ls_import-structure).

         ls_ptab-value  = lfs_dref.     "set data type

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:lfs_dref,ls_ptab, ls_import.

     ENDLOOP.

* Export Parameters

     LOOP AT lt_export INTO ls_export WHERE optional = space  .

       ls_ptab-name = ls_export-parameter.

       ls_ptab-kind = abap_func_exporting.

       IF ls_export-structure IS NOT INITIAL.

         CREATE DATA lfs_dref TYPE (ls_export-structure).

         ls_ptab-value  = lfs_dref.     "set data type

         ls_ptab-tables_wa  = lfs_dref.

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:ls_ptab, ls_export.

     ENDLOOP.

* Changing Parameters

     LOOP AT lt_change INTO ls_change WHERE  optional = space..

       ls_ptab-name = ls_change-parameter.

       ls_ptab-kind = abap_func_changing.

       IF ls_change-structure IS NOT INITIAL.

         CREATE DATA lfs_dref TYPE (ls_change-structure).

         ls_ptab-value  = lfs_dref.     "set data type

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:ls_ptab, ls_change.

     ENDLOOP.

* Tables

     LOOP AT lt_tables INTO ls_tables WHERE  optional = space..

       ls_ptab-name = ls_tables-parameter.

       ls_ptab-kind = abap_func_tables.

       IF ls_tables-structure IS NOT INITIAL.

         CREATE DATA lfs_dref TYPE (ls_tables-structure).

         ls_ptab-tables_wa  = lfs_dref.

       ENDIF.

       INSERT ls_ptab INTO TABLE lt_ptab.

       CLEAR:ls_ptab, ls_change.

     ENDLOOP.

* Exceptions

     LOOP AT lt_except INTO ls_except.

       ls_etab-name = ls_except-parameter.

       ls_etab-value = sy-tabix.

       INSERT ls_etab INTO TABLE lt_etab.

       CLEAR ls_etab..

     ENDLOOP.

* Call Dynamic FM name to chck for runtime exceptions

     CALL FUNCTION lv_fm_name

       PARAMETER-TABLE

       lt_ptab

       EXCEPTION-TABLE

       lt_etab.

     CLEAR ls_stxfadm.

   ENDLOOP.




1 REPLY 1
Read only

former_member213851
Active Contributor
0 Likes
795

Issue resolved.

Signature of FM was fetched using class CL_FB_FUNCTION_UTILITY=>METH_GET_INTERFACE.

Here Importing parameters in FM definition  will act as Exporting parameters while passing signature to dynamic FM using    PARAMETER-TABLE and vice-versa.

So       ls_ptab-kind = abap_func_importing is changed to   ls_ptab-kind = abap_func_exporting in First loop.

and     ls_ptab-kind = abap_func_exporting is changed to   ls_ptab-kind = abap_func_importing  in second loop.