1

How can I pass my select-options as a Function Module parameter?

I have a program, with some parameters, and need to pass the select-options parameter to a Z_FM to be used in a select statement.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Beto
  • 23
  • 1
  • 7
  • 2
    Is the same if the FM will work as RFC? – Beto Jan 24 '18 at 23:39
  • Function Modules are obsolete for the most part. You should probably avoid using them if possible. It may make more sense to use a class. – Brian Jan 26 '18 at 17:55

3 Answers3

1

In your Function Module definition, at the tables section, define a table LIKE RFG_RANGES.

Your FM will look like

  TABLES
      range_table STRUCTURE  EFG_RANGES

Then you can use it as if it were your original select-options parameter.

WHERE field IN range_table

This worked in a FM used as RFC Hope this helps

Rene MF
  • 157
  • 1
  • 12
  • I get an error:CALL_FUNCTION_CONFLICT_LENG. "P_DOCS" is the correct type, its length is incorrect. – Beto Jan 24 '18 at 23:43
1

Yes, it dumps an error for the length.

The solution is to use an auxiliary table.

DATA t_aux TYPE STANDARD TABLE OF efg_ranges.

t_aux[] = param_range[];

CALL FUNCTION 'Z_MYFM'
  TABLES
    range_param = t-aux.

This should work.

The problem is select-option sets the lengths of low and high depending on the table-filed used to define the select-options.

rfg_ranges have a fixed length of 45.

Rene MF
  • 157
  • 1
  • 12
1

Just to share the full solution.

Parameters:

SELECT-OPTIONS: p_docs FOR bkpf-belnr.

Call the FM.

DATA taux TYPE STANDARD TABLE OF efg_ranges.

taux[] = p_docs[].

CALL FUNCTION 'ZCRIP_GET_PG'
  EXPORTING
    soc           = p_bukrs
    fecha_ini     = fini
    fecha_fin     = ffin
  TABLES
    documentos    = taux.
Jagger
  • 10,350
  • 9
  • 51
  • 93
Beto
  • 23
  • 1
  • 7