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 in RFC problem with WHERE statement

Former Member
0 Likes
2,628

Hello Experts,

I am using a SELECT statement in the sourcecode part of a RFC. In this SELECT Statment I want to filter the results by one of the IMPORT variables. This won't work because the variable is interpretate as field in the "FROM table". It says can't be found in table.

I also tried to put the variable in a local variable like:

temp LIKE MATNR.
temp = MATNR.
...
WHERE OBJCT = temp.

But this works neither.

DO you know how to do this SELECT?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,502

In table AUSP you dont have any MATNR..it has OBJEK

so your select should be some thing like this

Select..

...

Where OBJEK = MATNR.

I am sure this should work.

santhosh

21 REPLIES 21
Read only

Former Member
0 Likes
2,502

Hi,

You can you use import parameters in where condition it will works fine I think you may facing problem not with import parameter something else.

Eg: below Eg:

import

MATNR LIKE MARA-MATNR

EXPORT

DESC LIKE MAKT-MATXT

SOURCECODE

select single matxt from makt into desc

where matnr = matnr and

SPRAS = 'EN'.

same eg test it once it will works

Thanks

Ganesh

Read only

0 Likes
2,502

Hi,

my Imports look different:

*"  IMPORTING
*"     VALUE(FNCODE) TYPE  SY-TCODE OPTIONAL
*"     VALUE(MATNR) TYPE  MARA-MATNR OPTIONAL
*"     VALUE(MAKTX) TYPE  MAKT-MAKTX OPTIONAL
*"     VALUE(UDATE) TYPE  RM01A-AFDAT OPTIONAL

...

My SELECT looks like:

SELECT
ausp~atwrt
ausp~ATINN
into corresponding fields of table itab
FROM ausp
WHERE MATNR = ausp~OBJEK.

I really don't know, what's the problem.

Read only

0 Likes
2,502

ausp~OBJEK should be one of the import parameters ...

SELECT

ausp~atwrt

ausp~ATINN

into corresponding fields of table itab

FROM ausp

WHERE MATNR = ausp~OBJEK.

Read only

0 Likes
2,502

You are selecting data from AUSP and you are also using this table in the WHERE statement. Sure this won't work.



SELECT
ausp~atwrt
ausp~ATINN
into corresponding fields of table itab
FROM ausp
WHERE MATNR = ausp~OBJEK.

You will have to do it like this:

SELECT

ausp~atwrt

ausp~ATINN

into corresponding fields of table itab

FROM ausp

WHERE MATNR = MATNR. This is your import variable.

Read only

0 Likes
2,502

No both hints won't work. What did you mean by MATNR = MATNR. The Key in ausp is called OBJEK. If you meant MATNR = OBJEK, it doesn't work either. It keeps saying MATNR is unknown.

@ Srinivas: Putting Objek into IMPORT won't solve the problem either.

Edited by: Daniel Gerne on Apr 28, 2008 3:08 PM

Read only

0 Likes
2,502

in table AUSP you have a field called OBJEK, correct.

IN select statement you will have to use this:

SELECT

atwrt

ATINN

into corresponding fields of table itab

FROM ausp

WHERE OBJEK = MATNR. This matnr is your impor variable.

BTW: I copied YOUR select statement in which is says WHERE MATNR = ???

But if you want to compare MATNR and OBJEK you have to make sure that you need leading zero's or....So again, my question is: Do you have a syntax error or don't you get any values back after selecting data???

Edited by: Micky Oestreich on Apr 28, 2008 3:13 PM

Read only

0 Likes
2,502

In AUSP there is no field called MATNR ..

SELECT

atwrt

ATINN

into corresponding fields of table itab

FROM ausp

WHERE OBJEK = MATNR. <-- declare this in import

parameters

Read only

0 Likes
2,502

I get a Syntax error saying: "The field MATNR is unknown."

But as I said before MATNR = OBJEK won't work. It's the same syntax error.

I just tried something new:

MATtemp TYPE MATNR.
MATtemp = MATNR.

* Put the requested values in temporary table
SELECT
ausp~atwrt
ausp~ATINN
into corresponding fields of table itab
FROM ausp
WHERE MATtemp = OBJEK.  <-------------------------------------

Doing it like that it still crushes at the <----


(saying: "The field MATtemp is unknown."). But above I used MATNR to write the value in the temp-Var (that worked). So it must be a problem that a SELECT can't access "non-table variables".

I'll have to think about a way around this problem. When you have one you are free to give me a hint

Edited by: Daniel Gerne on Apr 28, 2008 3:25 PM

Read only

0 Likes
2,502

@ Srinivas: THAT is exactly the problem. MATNR is not a field of ausp. It is the field I declared in IMPORT in order to compare it to another field which IS IN ausp. That's the initial situation.

Read only

0 Likes
2,502

Daniel, the syntax should be:

SELECT

atwrt

ATINN

into corresponding fields of table itab

FROM ausp

WHERE OBJEK = MATNR.

Do you get a syntax error in this case or not?

If so, please let me know the exact syntax error.

If the problem is that no value is returned from this select than this is most likely caused by the fact that you can not just compare OBJEK (CHAR 50) and MATNR (CHAR18).

We really want to help you, but we DO have to know the exact problem (syntax error, no values returned...??).

Read only

0 Likes
2,502

The field MATtemp should be in the table ... ausp ..

It gives the error as it is not present in the table ...

replace MATtemp with OBJEK and write the select as

  • Put the requested values in temporary table

SELECT

ausp~atwrt

ausp~ATINN

into corresponding fields of table itab

FROM ausp

WHERE OBJEK = MATNR.

Read only

0 Likes
2,502

I get a Syntax error saying: "The field MATNR is unknown."

Read only

0 Likes
2,502

field MATNR should be declared in IMPORT parameters

of the FM.

MATNR LIKE MARA-MATNR.

Read only

0 Likes
2,502

@Srinivas: MATNR is declared in IMPORT already.

When I add this code:

Data:
MATNR LIKE MARA-MATNR.

The Syntax error is "MATNR" is already declared. So it means it has been declared before (as I said).

From IMPORT:

*"     VALUE(MATNR) TYPE  MARA-MATNR OPTIONAL

Read only

0 Likes
2,502

Daniel,

are you sure about everything you are saying, because I did the same as you are saying and no syntax error at all:


*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(MATNR) TYPE  MATNR OPTIONAL
*"----------------------------------------------------------------------
  DATA: lt_ausp TYPE TABLE OF ausp.

  SELECT * FROM ausp
    INTO TABLE lt_ausp
    WHERE objek = matnr.

Read only

0 Likes
2,502

Now I got it working. I am sooo sorry I did not understand what you meant.

I didn't know that in a where-statement the tablefield must be LEFT from '='.

Sorry I was "slow on the uptake".

I'm sorry.

Read only

0 Likes
2,502

No problem, as long as it is solved now....which it is.

Read only

0 Likes
2,502

Try

SELECT * atinn atwrt FROM ausp INTO CORRESPONDING FIELDS of wa_itab
WHERE objek = matnr.
APPEND wa_itab TO itab.
ENDSELECT.

Read only

0 Likes
2,502

thanks for your patience with me.

Read only

Sm1tje
Active Contributor
0 Likes
2,502

But this works neither....what doesn't work. Don't you get any values returned, or do you get a syntax error?

How is the field objct defined in the table you want to select from? If the type is different then this could cause problems, or are you missing leading zero's or....

But first tell what you mean by: But this works neither....

Read only

Former Member
0 Likes
2,503

In table AUSP you dont have any MATNR..it has OBJEK

so your select should be some thing like this

Select..

...

Where OBJEK = MATNR.

I am sure this should work.

santhosh