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: 

Why cant assign a string to a select-option

Former Member
0 Kudos

Hello friends,

I have the following code, but when I run it gives me the following error msg ""LV_LOCID" cannot be a table, a reference, a string, or contain any of these objects"

CODE:

Loop at lt_slpo into ls_slpo.

If ls_slpo-IOBJNM eq 'LOCNO'.

CALL FUNCTION '/SAPAPO/DM_LOCID_GET'

EXPORTING

I_LOCNO_RTAB = ls_slpo-LOW

IMPORTING

E_LOCID_TAB = lv_locid

EXCEPTIONS

NO_LOCATION = 1

NOT_QUALIFIED = 2

OTHERS = 3.

IF SY-SUBRC eq 0.

Select MATID LOCID from /SAPAPO/MATLOC

into corresponding fields of table lt_matloc

Where

locid = lv_locid.

ENDIF.

Any input would be appreiciate.

Many thanks

23 REPLIES 23

former_member181962
Active Contributor
0 Kudos

HI Shah,

Can you give us the declaration for lv_locid?

Regards,

ravi

0 Kudos

Hi,

Data:

lv_locid type /SAPAPO/LOCID_TAB.

Thanks

0 Kudos

Then, in the where condition,

you should pass only

lv_locid-<field for location id>

where locid = lv_locid-<field for location id>.

Regards,

Ravi

0 Kudos

hi Ravi,

can you a bit explain what, lv_locid-<field for location id> is ?

_Thanks

0 Kudos

then the issue is with the other parameter..

Pl change your function call as follows..



data: w_rtab type /SAPAPO/LOCNO_RSTR.
If ls_slpo-IOBJNM eq 'LOCNO'.
w_rtab-sign = 'I'.
w_rtab-option = 'EQ'.
w_rtab-low = ls_slpo-LOW.
append w_rtab.
CALL FUNCTION '/SAPAPO/DM_LOCID_GET'
EXPORTING
I_LOCNO_RTAB = w_rtab
IMPORTING
E_LOCID_TAB = lv_locid
EXCEPTIONS
NO_LOCATION = 1
NOT_QUALIFIED = 2
OTHERS = 3.

Regards,

Suresh Datti

0 Kudos

YOur lv_locid is declared as a table type.

This table has many fields in it.

So, when you pass this value in the where condition, the system is getting confused betwen the types of the left hand side and right hand side of the where clause.

i don't know the field name of the location id.

you should write your select statement as

select..

..

.

where

locid = lv_locid-locid.

Regards,

Ravi

0 Kudos

Hi,

I hope it will woek, will check now

Data:

lv_locid type /SAPAPO/LOCID, "/SAPAPO/LOCID_TAB,

Regards,

0 Kudos

Did you check the code I posted? Both the IMP/EXP parmeters of this function call should be Table Types ie in this case RANGES.

Regards,

Suresh Datti

0 Kudos

HI Shah,

It will not work. This time it will give the dump at the function call statement.

The variable which is collecting the exporting parameter type should have the same type as the function module parameter.

Regards,

ravi

0 Kudos

Hi Ravi,

Thanks for your explanation, but the thing is that

The table type /SAPAPO/LOCID_TAB contains only row-type /SAPAPO/LOCID, so I want to know all fields of table type /SAPAPO/LOCID_TAB, how I can see that ??

Thanks

0 Kudos

Hi Shah,

go to se11 transaction and give your /SAPAPO/LOCID_TAB as the table name and see for yourself.

Regards,

ravi

0 Kudos

Double click on /SAPAPO/LOCID and you can see it.

OR

In se11, type /SAPAPO/LOCID in the DATA TYPE field and display.

Regards,

Ravi

Note : Please mark all the helpful answers

0 Kudos

it is just a RANGES.. like any other select-option.. the fields will be SIGN,OPTION,LOW & HIGH..

Regards,

Suresh Datti

0 Kudos

Hi Ravi,

I tried, both of your ways, and it did not work ??

0 Kudos

it means suresh,

it should work then lv_locid-low ? or,

0 Kudos

Hi Shah,

Pl change your function call to what I have posted earlier & your SELECT statement as below.


Select MATID LOCID from /SAPAPO/MATLOC
into corresponding fields of table lt_matloc
Where
locid in lv_locid.

Regards,

Suresh Datti

0 Kudos

HI Shah,

I now under stand your problem.

Change your code as follows:

data: ;v_locid value type /sapapo/locid.

Loop at lt_slpo into ls_slpo.

If ls_slpo-IOBJNM eq 'LOCNO'.

CALL FUNCTION '/SAPAPO/DM_LOCID_GET'

EXPORTING

I_LOCNO_RTAB = ls_slpo-LOW

IMPORTING

E_LOCID_TAB = lv_locid

EXCEPTIONS

NO_LOCATION = 1

NOT_QUALIFIED = 2

OTHERS = 3.

IF SY-SUBRC eq 0.

read table lv_locid into lv_locid_value index 1.

Select MATID LOCID from /SAPAPO/MATLOC

into corresponding fields of table lt_matloc

Where

locid = lv_locid_value.

ENDIF.

Regards,

Ravi

0 Kudos

Hi Ravi,

Many thanks for your reply, for my better understanding can you pls expaint "locid = lv_locid_value.", from where you got _value ??

Hi Suresh, I tried your code sample, it gives me the same error as before.

Thanks for your inputs

RAVI , can yo pls re-sure me that

Data: lv_locid type /SAPAPO/LOCID, and not /SAPAPO/LOCID_TAB

Message was edited by: Shah H

0 Kudos

No Ravi it will not work.. I_LOCNO_RTAB is a RANGES. you will have to pass the table & not just the LOW value.

Regards,

Suresh DAtti

0 Kudos

Hi,

I dont understand what was the real problem, but now I am using the following FM

/SAPAPO/DM_LOCNO_GET_LOCID, I hope it will work fine,

Anyway, thanks for your inputs guys,

0 Kudos

HI Shah,

I think you have to change the design of you code slightly.

data: ls_locno type /SAPAPO/LOC_LOCNO_RSTR.

data: lt_locno type /SAPAPO/LOC_LOCNO_RTAB.

data: ls_locid type /SAPAPO/LOCID.

data: lt_locid type /SAPAPO/LOCID_TAB.

loop at lt_slpo into ls_slpo where IOBJNM eq 'LOCNO'.

move-corresponding ls_slpo into ls_locno.

append ls_locno to lt_locno.

clear ls_locno.

endloop.

CALL FUNCTION '/SAPAPO/DM_LOCID_GET'

EXPORTING

I_LOCNO_RTAB = lt_locno

IMPORTING

E_LOCID_TAB = lt_locid

EXCEPTIONS

NO_LOCATION = 1

NOT_QUALIFIED = 2

OTHERS = 3.

if sy-subrc = 0.

loop at lt_locid into ls_locid.

ls_locid_range-low = ls_locid.

ls_locid_range-sign = 'I'.

ls_locid_range-option = 'EQ'.

append ls_locid_range to lt_locid_range.

clear ls_locid_range.

endloop.

Select MATID LOCID from /SAPAPO/MATLOC

into corresponding fields of table lt_matloc

Where

locid in lt_locid_range.

endif.

Regards,

Ravi

suresh_datti
Active Contributor
0 Kudos

Hi Shah,

I think the issue may not be with the select option.. How did you declare <b>lv_locid</b> in your program? it should be as follows..

<b>data lv_lovis type /SAPAPO/LOCID_TAB.</b>

Regards,

Suresh Datti

Former Member
0 Kudos

Shah,

Looks like /SAPAPO/LOCID_TAB is table type (not a single variable) and that cannot be used as a part of the SELECT statement and that is why the error.

You will have pass only one variable to the SELECT statement. So, if /SAPAPO/LOCID_TAB is a strcuture then use lv_locid-fieldname else you will have to loop at lv_locid and fire that select statement for each row.

Regards,

Ravi

Note : Please mark all the helpful answers

Message was edited by: Ravikumar Allampallam