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

Passing import parameter in RFC as optional

deepak_dhamat
Active Contributor
0 Likes
1,841

Dear Expert ,

I want to pass four parameter to the select queery in RFC which are optional and

i want to execute that query like we execute query in report for example

SELECT a~matnr

a~bismt

INTO CORRESPONDING FIELDS OF TABLE it_mara

FROM mara AS a INNER JOIN marc AS b ON amatnr = bmatnr

WHERE b~werks in p_werks

AND a~bismt IN p_bismt

AND a~matnr in p_matnr .

where if only p_bismt= '02470' is passed it should give result for all matnr of bismt ='02470 '

Regards

Deepak

Dear Expert ,

I want to pass four parameter to the select queery in RFC which are optional and

i want to execute that query like we execute query in report for example

SELECT a~matnr

a~bismt

INTO CORRESPONDING FIELDS OF TABLE it_mara

FROM mara AS a INNER JOIN marc AS b ON amatnr = bmatnr

WHERE b~werks in p_werks

AND a~bismt IN p_bismt

AND a~matnr in p_matnr .

where if only p_bismt= '02470' is passed it should give result for all matnr of bismt ='02470 '

Regards

Deepak

4 REPLIES 4
Read only

Clemenss
Active Contributor
0 Likes
1,077

Hi Deepak,

and what is the question?

Create an RFC-usable function module, create import parameters for the ranges (must be type table or certain tabletype) and then it's OK.

It is not nice to use a name like p_werks for a range (used with IN ).

Regards,

Clemens

Read only

bettinasilveira
Participant
0 Likes
1,077

The problem with the optional parameters is that if none on the parameters have values you are retrieving the whole table.

You should check that, at least, one of the four parameters are completed.

Here you have a quick solution for your problem:

ranges: r_bismt for mara-bismt.

ranges: r_matnr for mara-matnr.

ranges: r_werks for marc-werks.

if not i_bismt is initial.

move 'I' to r_bismt-sign.

move 'EQ' to r_bismt-option.

move i_bismt to r_bismt-low.

append r_bismt.

endif.

if not i_matnr is initial.

move 'I' to r_matnr-sign.

move 'EQ' to r_matnr-option.

move i_matnr to r_matnr-low.

append r_matnr.

endif.

if not i_werks is initial.

move 'I' to r_werks-sign.

move 'EQ' to r_werks-option.

move i_werks to r_werks-low.

append r_werks.

endif.

SELECT a~matnr

a~bismt

INTO CORRESPONDING FIELDS OF TABLE it_mara

FROM mara AS a INNER JOIN marc AS b ON amatnr = bmatnr

WHERE b~werks in r_werks

AND a~bismt IN r_bismt

AND a~matnr in r_matnr .

Read only

0 Likes
1,077

YEs

Bettina ,

Your answer is helpful, but what if all fields are passed blank

Regards

Deepak

Read only

0 Likes
1,077

In that case you have to decide how the FM will behave.

You can check that at least one parameter have a value, if not, you can return an error.

You can retrieve all the data (like happens with the select options). With my previous code, if all the fields are blank the select will retrieve the whole table.

Regards

Bettina