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

wrong select statement

Former Member
0 Likes
935

Hello,

the following code is a part of a function module. My problem is that the field language is still empty, although there is an according value.

What is wrong with this code? Please hlep me!

Regards

Philipp

DATA: language TYPE sylangu,

cv_language TYPE sylangu,

ls_orderadm_h TYPE crmt_orderadm_h_wrkt.

tables: STXH, CRMD_ORDERADM_H.

SELECT a~tdspras INTO language

FROM STXH as a

INNER JOIN CRMD_ORDERADM_H as b

ON atdname = bguid

WHERE b~object_id EQ ls_orderadm_h-object_id.

ENDSELECT.

IF language IS NOT INITIAL.

cv_language = language.

ELSE.

cv_language = sy-langu.

ENDIF.

10 REPLIES 10
Read only

Former Member
0 Likes
908

hi,

do this way ..

if not ls_orderadm_h[] is initial.

SELECT a~tdspras INTO language

FROM STXH as a

INNER JOIN CRMD_ORDERADM_H as b

ON atdname = bguid

for all entries in ls_orderadm_h

WHERE b~object_id EQ ls_orderadm_h-object_id.

ENDSELECT.

endif.

Read only

0 Likes
908

Hello Santosh,

your code don´t work.

The field language is still empty.

Regards

Philipp

Read only

Former Member
0 Likes
908

Try seperating the selections, The join statement disterb you.

2 possible solutions:

1.Select all records from first table and than loop

at this internal table and select from second

table.

2. Use left outer join if it's OK with your

functionality.

Please reward if helpfull..

Rebeka.

Read only

Former Member
0 Likes
908

Hi Philipp,

anyways u r not processing selected value inside select / endselect...

Also , u r not using all key fields from both table...so language field can not be single...

it is better to use...select...into table it_lang...it'll definitely improve the performance also...

this code may help u...

*===========================================

types : begin of ty_lang,

language TYPE sy-langu,

end of ty_lang.

data : it_lang type table of ty_lang,

wa_lang type ty_lang.

SELECT a~tdspras INTO it_lang

FROM STXH as a

INNER JOIN CRMD_ORDERADM_H as b

ON atdname = bguid

WHERE b~object_id EQ ls_orderadm_h-object_id.

read table it_lang into wa_lang where language is not initial.

IF sy-subrc = 0.

cv_language = wa_lang-language.

ELSE.

cv_language = sy-langu.

endif.

*============================================

Reward points if useful...

Sachin

Read only

0 Likes
908

Hello Sachin,

it_lang is an internal table and is not allowed.

Regards

Philipp

Read only

Former Member
0 Likes
908

have you checked whether there is any suitable record in the table satisfying the select condition ....

Regards,

Santosh

Read only

0 Likes
908

Hello Santosh,

yes there exists an according value.

Regards

Philipp

Read only

Former Member
0 Likes
908

hi Philip,

Remove join and use for all entries statement then.

Regards,

Santosh

Read only

Former Member
0 Likes
908

Just check both the tables for the record u r looking for.

also use SELECT SINGLE instead of SELECT-ENDSELECT.

Reward if useful.

S@meer

Read only

Former Member
0 Likes
908

Try this,

SELECT single a~tdspras INTO language

FROM STXH as a

INNER JOIN CRMD_ORDERADM_H as b

ON atdname = bguid

WHERE b~object_id EQ ls_orderadm_h-object_id.

IF language IS NOT INITIAL.

cv_language = language.

ELSE.

cv_language = sy-langu.

ENDIF.

OR

SELECT a~tdspras INTO language

FROM STXH as a

INNER JOIN CRMD_ORDERADM_H as b

ON atdname = bguid

WHERE b~object_id EQ ls_orderadm_h-object_id.

IF language IS NOT INITIAL.

cv_language = language.

ELSE.

cv_language = sy-langu.

ENDIF.

ENDSELECT.