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: 

How to pass dynamic logical expression to function module

Former Member
0 Kudos

Hi,

I'm using FM META_READ_TABLE as below:

As mentioned above im using META_READ_TABLE FM to get company codes from CSKS table of ECC. Below is the code im using:

   DATA:i_opt type STANDARD TABLE OF RFC_DB_OPT, i_fld type STANDARD TABLE OF RFC_DB_FLD,
       i_res type STANDARD TABLE OF TAB512.

Constants:   c_expr(72) TYPE c VALUE 'KOSTL EQ COST_CTR', c_fld(5) TYPE c VALUE 'BUKRS'.

  w_opt-text = c_expr.
w_fld-FIELDNAME = c_fld.
append: w_opt to i_opt,
        w_fld to i_fld.
data i_control type STANDARD TABLE OF BBP_CONTROL_RECORD.
**&&--Get Co code from ECC (CSKS table)
CALL FUNCTION 'META_READ_TABLE'
  EXPORTING
    QUERY_TABLE          = c_table
*   DELIMITER            = ' '
*   NO_DATA              = ' '
*   ROWSKIPS             = '0'
*   ROWCOUNT             = '0'
    LOGICAL_SYSTEM       = v1_logsys
  TABLES
    OPTIONS              = i_opt
    FIELDS               = i_fld
    DATA                 = i_res
    CONTROL_RECORD       = i_control.

however it is giving me 'Communication Error' while executing this piece of code. I guess the problem here is with passing query to i_opt table. obviously the way im doing this is wrong and it has to be dynamic. Could anybody please give me idea how to execute fm with dynamic query i.e., 'KOSTL EQ COST_CTR' where COST_CTR is cost center and an importing parameter to this.please advise.

Rgds

1 ACCEPTED SOLUTION

Former Member
0 Kudos

The "communication error" would seem more likely to be a problem with an RFC call - does 'META_READ_TABLE" call another function in the remote system?

We don't have that function module here (is it SRM?) but you should be able to construct your dynamic "where" something like this (p_kostl is the variable in this example):

  data:

    l_where     type text72.

  concatenate

    'KOSTL EQ_'

    ''''  

    p_kostl      "variable

    ''''  

    into l_where.

  translate l_where using '_ '.  "replace underscore with space

Jonathan

2 REPLIES 2

Former Member
0 Kudos

The "communication error" would seem more likely to be a problem with an RFC call - does 'META_READ_TABLE" call another function in the remote system?

We don't have that function module here (is it SRM?) but you should be able to construct your dynamic "where" something like this (p_kostl is the variable in this example):

  data:

    l_where     type text72.

  concatenate

    'KOSTL EQ_'

    ''''  

    p_kostl      "variable

    ''''  

    into l_where.

  translate l_where using '_ '.  "replace underscore with space

Jonathan

0 Kudos

Hello Jonathan,

This works perfectly and nomore 'communication error' now. Thank you for your time!

Rgds