Application Development 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: 

Passing SELECT-OPTIONS value to Function Module

Former Member
0 Kudos

Hi,

I need to pass select-options value to a function module.

Code is like the following:



SELECT-OPTIONS seltab FOR object-type.

CALL FUNCTION 'Z_MY_FM'
      EXPORTING
        sel_tab         = seltab
     IMPORTING
        result_tab     = it_result

I have found a similar problem in the SDN forum:

However, that could not help me much in solving my problem.

So far I have tried to created a structure in DDIC with the following components for the select-options:

SIGN - BAPISIGN

OPTION - BAPIOPTION

LOW - ZBWOBJECTTYPE (my type)

HIGH - ZBWOBJECTTYPE (my type)

and subsequently a table type for this structure which is specified in the "Import" tab of my function module.

Unfortunately, when I ran the program a runtime exception occured (CALL_FUNCTION_CONFLICT_TYPE).

Could anyone please help me on this issue?

Thanks in advance.

Regards,

Joon Meng

1 ACCEPTED SOLUTION

former_member555112
Active Contributor
0 Kudos

Hi,

Declare an internal table in your program of the same dictionary table type which you created and then append the entries on the select-option to this table.

Pass this internal table to your Function Module.

Regards,

Ankur Parab

11 REPLIES 11

former_member555112
Active Contributor
0 Kudos

Hi,

Declare an internal table in your program of the same dictionary table type which you created and then append the entries on the select-option to this table.

Pass this internal table to your Function Module.

Regards,

Ankur Parab

Former Member
0 Kudos

Define a new type in a type-pool.

types: mytype type range of obect-type.

Then you can define the parameter of your Function module with the new type.

You can pass SELTAB[] to the parameter of the FM and it should work.

Best Regards

Rafa

0 Kudos

Hi Rafa,

what is the meaning of the square bracket in "SELTAB[]"?

Thanks,

Joon Meng

0 Kudos

Hello Joon,


CALL FUNCTION 'Z_MY_FM'
      EXPORTING
        sel_tab         = seltab
     IMPORTING
        result_tab     = it_result

You have defined SELTAB as a SELECT-OPTION.

So when you pass only SELTAB, the header line is transferred to the FM. When you pass SELTAB[] the whole table(range) is passed.

It is similar to the concept of an internal table with header line.

Hope i am clear.

Anyways how have you defined result_tab and sel_tab ?

BR,

Suhas

0 Kudos

Hi,

@Ankur: Thanks for your tip. It works now! I have shown my appreciation with the points 😃

@Suhas: Thanks for the information too. I am clear about the use of the squared bracket in ignoring the header line.

Thanks everyone.

Regards,

Joon Meng

0 Kudos

Hi Joon.

The select-option is an internal table with header line. You should pass the content of it, not the header. So you refer to the content of the select option (the content of the table) using brackets.

Hope it helps.

Regards

Rafa

0 Kudos

Hi Rafa,

thanks for the explanation.

Regards,

Joon Meng

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Did you tried using tables parameter in function module?

Former Member
0 Kudos

Hi Joon ,

You have to change the FM parameter and make it a table or you have to loop at the select - option and then call the FM.

Hope it solves your issue.

Former Member
0 Kudos

You can pass a table without structure and copy it to an internal table type range

0 Kudos

CALL FUNCTION 'Z_MY_FM'

      EXPORTING

        sel_tab         = seltab

     IMPORTING

        result_tab     = it_result

here pass seltab[] instead of seltab.