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

How can I change the parameter's type dynamically

Hello,everybody!

I'm creating a fuction modul or a class's method. But met a problem.I want to change the exporting parameter's type dynamically.

Here is what I want to do.

import data:

stru_name (structure name) dictionary table

indata (input data) string

output

outdata (output data)

The output data will be divided according to the structure of stru_name.

For example:

structure(a(3),b(3),c(3))

indata(123456789)

u2192outdata(123,456,789)

structure(a(2),b(3),c(4))

indata(123456789)

u2192outdata(12,345,6789)

Can anybody give me some advices?

I will appreciate your help.

Thanks.

Chen.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 22, 2008 at 10:01 PM

    Make the parameter type ANY. Then you can pass data of any structure.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2008 at 03:08 AM

    Hello Junhua,

    Don give any type for the parameters in the function module to make it generic.

    Regards

    Farzan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Sourav,Farzan

      Thanks for your reply.

      I have give any type for the output parameter .

      But at the end of my source ,how I move the data to the output parameter.

      Here is my source.

      FUNCTION z_divide_data_by_stru.

      *"----


      ""ローカルインタフェース:

      *" IMPORTING

      *" REFERENCE(STRU_NAME) TYPE STRUNAME

      *" REFERENCE(I_DATA) TYPE STRING

      *" EXPORTING

      *" REFERENCE(O_DATA) TYPE ANY

      *" EXCEPTIONS

      *" LENGTH_ERROR

      *" OTHER_ERROR

      *"----


      DATA:

      dy_stru TYPE REF TO data,

      res_dfies TYPE ddfields,

      res_header TYPE x030l,

      wl_dfies TYPE dfies.

      DATA:

      wa_offset TYPE doffset,

      wa_length TYPE ddleng.

      FIELD-SYMBOLS:

      <dyn_stru>,

      <dyn_field>.

      CREATE DATA dy_stru TYPE (stru_name).

      ASSIGN dy_stru->* TO <dyn_stru>.

      CALL FUNCTION 'TR_NAMETAB_GET'

      EXPORTING

      iv_tabname = stru_name

      iv_get_lengths_in_charmode = 'X'

      • IV_GET_TEXTS = ' '

      IMPORTING

      et_dfies = res_dfies

      es_header = res_header

      EXCEPTIONS

      not_found = 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.

      DO.

      ASSIGN COMPONENT sy-index

      OF STRUCTURE <dyn_stru> TO <dyn_field>.

      READ TABLE res_dfies INTO wl_dfies INDEX sy-index.

      wa_offset = wl_dfies-offset.

      wa_length = wl_dfies-leng.

      <dyn_field> = i_data+wa_offset(wa_length).

      IF sy-subrc <> 0.

      EXIT.

      ENDIF.

      ENDDO.

      WRITE <dyn_stru> TO o_data. -


      >Here is my problem....

      ENDFUNCTION.

      Can you give me some other advice?

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.