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

SELECT OPTIONS IN A FUNCTION

Former Member
0 Likes
759

Hello,

I need to use a select options in a Function module and then i have to send the values to a Report program.

How can I do it?

Thanks.

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
726

This is how I have done in past...

In a type-group define types like this


TYPES : zmb52_tr_matnr TYPE RANGE OF mara-matnr ,
        zmb52_tr_werks TYPE RANGE OF marc-werks ,
        zmb52_tr_lgort TYPE RANGE OF mard-lgort ,
        zmb52_tr_charg TYPE RANGE OF mchb-charg ,
        zmb52_tr_mtart TYPE RANGE OF mara-mtart ,
        zmb52_tr_matkl TYPE RANGE OF mara-matkl ,
        zmb52_tr_ekgrp TYPE RANGE OF marc-ekgrp ,
        zmb52_tr_sobkz TYPE RANGE OF mkol-sobkz ,

and use it in FM like this


FUNCTION zgetstock.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_SPMON) TYPE  SPMON
*"     VALUE(I_MATNR) TYPE  ZMB52_TR_MATNR OPTIONAL
*"     VALUE(I_WERKS) TYPE  ZMB52_TR_WERKS OPTIONAL
*"     VALUE(I_LGORT) TYPE  ZMB52_TR_LGORT OPTIONAL
*"     VALUE(I_CHARG) TYPE  ZMB52_TR_CHARG OPTIONAL
*"     VALUE(I_MTART) TYPE  ZMB52_TR_MTART OPTIONAL
*"     VALUE(I_MATKL) TYPE  ZMB52_TR_MATKL OPTIONAL
*"     VALUE(I_EKGRP) TYPE  ZMB52_TR_CHARG OPTIONAL

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
726

You can use the RANGE statement, it is just like SELECT-OPTIONS, but you do not get the screen fields.

Regards,

Rich Heilman

Read only

0 Likes
726

Hello,

But, I need to use the select options as import parameter in the function module.

Thanks

Read only

0 Likes
726

Hi,

Refer to this function :

RS_REFRESH_FROM_SELECTOPTIONS , the tables parameter SELECTION_TABLE refers to structure RSPARAMS, you can define it in the same way.

Later you can fill the ranges in your program from this table.

Hope this helps.

regards,

Advait

Read only

0 Likes
726

Ok, so then you need to use a table type. What is the actual field type that you want to pass as a range, is it a date? If not, is is a character field? what is the length? You may be able to use an existing table table. Otherwise, you will need to create your own "Z" table type, which will use a custom structure as well. The structure should include the four fields.

SIGN

OPTION

LOW

HIGH

SIGN should be a char 1 field, and the OPTION field should be character 2, the LOW and HIGH fields depends on what you are trying to pass. Create this "Z" structure, then create the table type using this "Z" structure. Then use this table type as an IMPORTING parameter of your function module(you could also use the TABLES parameter, and simply use the structure instead, but it is better to use a table type and the IMPORTING parameter).

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
726

So for example, here you fill the range, just like it would be for a select-option, and then you may pass this range to the select-option of the submited program, here S_DATUM is a select-option in the ZREPORT report program.

ranges: r_datum for sy-datum.

r_datum-sign = 'I'.
r_datum-option = 'EQ'.
r_datum-low = sy-datum.
r_datum-high = sy-datum + 7.
append r_datum.

submit zreport 
     with s_datum in r_datum
             and return.

Regards,

Rich Heilman

Read only

Pawan_Kesari
Active Contributor
0 Likes
727

This is how I have done in past...

In a type-group define types like this


TYPES : zmb52_tr_matnr TYPE RANGE OF mara-matnr ,
        zmb52_tr_werks TYPE RANGE OF marc-werks ,
        zmb52_tr_lgort TYPE RANGE OF mard-lgort ,
        zmb52_tr_charg TYPE RANGE OF mchb-charg ,
        zmb52_tr_mtart TYPE RANGE OF mara-mtart ,
        zmb52_tr_matkl TYPE RANGE OF mara-matkl ,
        zmb52_tr_ekgrp TYPE RANGE OF marc-ekgrp ,
        zmb52_tr_sobkz TYPE RANGE OF mkol-sobkz ,

and use it in FM like this


FUNCTION zgetstock.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_SPMON) TYPE  SPMON
*"     VALUE(I_MATNR) TYPE  ZMB52_TR_MATNR OPTIONAL
*"     VALUE(I_WERKS) TYPE  ZMB52_TR_WERKS OPTIONAL
*"     VALUE(I_LGORT) TYPE  ZMB52_TR_LGORT OPTIONAL
*"     VALUE(I_CHARG) TYPE  ZMB52_TR_CHARG OPTIONAL
*"     VALUE(I_MTART) TYPE  ZMB52_TR_MTART OPTIONAL
*"     VALUE(I_MATKL) TYPE  ZMB52_TR_MATKL OPTIONAL
*"     VALUE(I_EKGRP) TYPE  ZMB52_TR_CHARG OPTIONAL