‎2008 Mar 20 7:59 AM
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.
‎2008 Mar 20 8:03 AM
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.
‎2008 Mar 20 8:23 AM
Hello Santosh,
your code don´t work.
The field language is still empty.
Regards
Philipp
‎2008 Mar 20 8:08 AM
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.
‎2008 Mar 20 8:27 AM
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
‎2008 Mar 20 8:33 AM
Hello Sachin,
it_lang is an internal table and is not allowed.
Regards
Philipp
‎2008 Mar 20 8:27 AM
have you checked whether there is any suitable record in the table satisfying the select condition ....
Regards,
Santosh
‎2008 Mar 20 8:35 AM
Hello Santosh,
yes there exists an according value.
Regards
Philipp
‎2008 Mar 20 8:50 AM
hi Philip,
Remove join and use for all entries statement then.
Regards,
Santosh
‎2008 Mar 20 8:55 AM
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
‎2008 Mar 20 9:00 AM
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.