2007 Oct 04 10:46 AM
Hi, everyone.
I have a problem in selecting records. In this case, I want to select records from database
LFA1,and the components of this table are LIFNR,ERDAT,LOEVM ,and so on.The type of LIFNR is char(10).There is a internal table:tab_cdhdr , the elements of tab_cdhdr are: objectid,udate and change_ind.The type of objectid is char(50).
And the select-rule is that: LIFNR = objectid. So I write like this:
select lifnr
erdat
loevm
form lfa1
into tab_lfa1
for all entries in tab_cdhdr
where lfa1 = tab_cdhdr-objectid+0(10).
But there is a warning: When using FOR ALL ENTRIES IN the specifyed length for "OBJECTID" is ignored in this condition.
Can you help me to solve this problem?
Thanks.
2007 Oct 04 11:29 AM
Hi ,
try like this..
take a field of type lifnr in the table tab_cdhdr..
Now u do like this
LOOP AT TAB_CDHDR.
TAB_CDHDR-LIFNR = tab_cdhdr-objectid+0(10).
MODIFY TAB_CDHDR.
ENDLOOP.
Now write ur query..
select lifnr
erdat
loevm
form lfa1
into tab_lfa1
for all entries in tab_cdhdr
where lfa1 = lifnr.
reward if helpful
Regards,
Nagaraj
Hi ,
try like this..
take a field of type lifnr in the table tab_cdhdr..
Now u do like this
LOOP AT TAB_CDHDR.
TAB_CDHDR-LIFNR = tab_cdhdr-objectid+0(10).
MODIFY TAB_CDHDR.
ENDLOOP.
Now write ur query..
select lifnr
erdat
loevm
form lfa1
into tab_lfa1
for all entries in tab_cdhdr
where lfa1 = lifnr.
reward if helpful
Regards,
Nagaraj
2007 Oct 04 10:52 AM
Hi Feng..
Just give like this:
select lifnr
erdat
loevm
form lfa1
into tab_lfa1
for all entries in tab_cdhdr
where lfa1 = tab_cdhdr-objectid(10). "It will compare only first 10 characters
REWARD IF HELPFUL.
2007 Oct 04 10:57 AM
> Hi Feng..
>
> Just give like this:
>
> select lifnr
> erdat
> loevm
> form lfa1
> into tab_lfa1
> for all entries in tab_cdhdr
> where lfa1 = tab_cdhdr-objectid(10). "It will
> compare only first 10 characters
>
> REWARD IF HELPFUL.
Thank you very much, Varma@infyTree . I think your code is the same as mine. And I chaned tab_cdhdr-objectid+0(10) to tab_cdhdr-objectid(10) , the result wasn't changed.
And I want to only compare the first 10 characters.
2007 Oct 04 11:24 AM
Do one thing - In our internal table <b>tab_cdhdr</b> add one more field-
LIFNR type LIFNR.
and while populating the Internal table - populate this lifnr with ur syntax <b>tab_cdhdr-objectid+0(10).</b>
and during the SELECT - FOR ALL ENTRIES use this lifnr field instead of objectid+0(10).
During FOR ALL ENTRIES SAP checks the data types - thats why u r having the problem. The above mentioned steps will solve ur problem.
2007 Oct 04 11:29 AM
Hi ,
try like this..
take a field of type lifnr in the table tab_cdhdr..
Now u do like this
LOOP AT TAB_CDHDR.
TAB_CDHDR-LIFNR = tab_cdhdr-objectid+0(10).
MODIFY TAB_CDHDR.
ENDLOOP.
Now write ur query..
select lifnr
erdat
loevm
form lfa1
into tab_lfa1
for all entries in tab_cdhdr
where lfa1 = lifnr.
reward if helpful
Regards,
Nagaraj
2007 Oct 04 11:32 AM
Thanks very much, SKC and nagaraj kumar nishtala .
But I don't want to change tab_cdhdr.
Is there any other methods to solve this problem?
2007 Oct 04 11:41 AM
Hi Feng..
If you dont want to change the Internal table TAB_CDHDR, Then declare another internal table (TEMPTAB_CDHDR.) with the same structure but Objectid with only 10 chars.
IF TAB_CDHDR[] IS NOT INITIAL.
LOOP AT TAB_CDHDR.
MOVE-CORRESPONDING TAB_CDHDR TO TEMPTAB_CDHDR.
APPEND TEMPTAB_CDHDR.
ENDLOOP.
select lifnr
erdat
loevm
form lfa1
into tab_lfa1
for all entries in tab_cdhdr
where lfa1 = TEMPtab_cdhdr-objectid.
ENDIF.
Sure ... this will work for u.....
REWARD IF HELPFUL.
2007 Oct 04 2:47 PM
the create a local copy of the internal table tab_cdhdr. say tab_cdhdr_copy.
In this internal table you can have the additional field LIFNR type LIFNR.
do this -
tab_cdhdr_copy[] = tab_cdhdr[]
then after doing a loop on tab_cdhdr_copy populate the vendor number. you can then do the SELECT on LAF1 performing the FOR ALL ENTRIES on this temporary table tab_cdhdr_copy[].
I guess this is the only way out if you are not interested in modifying tab_cdhdr.
2007 Oct 04 2:57 PM
Hi,
Try the below method.. it is the best one i feel.
ranges r_lifnr for lfa1-lifnr.
loop at tab_cdhdr.
r_lifnr-low = tab_cdhdr-objid(10)
r_lifnr-sign = 'I'.
r_lifnr-option = 'EQ'.
append r_lifnr.
clear r_lifnr.
endllop.
select lifnr
erdat
loevm
form lfa1
into tab_lfa1
where lfa1 IN r_lifnr.
2007 Oct 05 8:12 AM
Thanks very much, Sreejith Ramachandran .
But I can't understand your solution. Could you give me more examples about RANGES?
And I want to do like this:
LOOP AT TAB_CDHDR INTO WA_CDHDR.
SELECT LIFNR
ERDAT
LOEVM
FROM LFA1
APPENDING TABLE TAB_LFA1
WHERE LIFNR = WA_CDHDR-OBJECTID(10).
ENDLOOP.
Am I right?
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |