10-03-2005 11:37 AM
I need to check whether SGTXT contains BELNR value.
SGTXT is a text field and It should be matched with BELNR
How to write select statement for this.
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT should have the given BELNR Value.
Plz note : Here I cannot give as SGTXT = BELNR as coz BELNR have only 10 digits.
10-03-2005 11:41 AM
You should be able to use CS (Contains operator). If you know that BELNR is going to be the starting or ending of the field SGTXT, then you can use a wild card like %BELNR, BELNR%.
Regards,
Ravi
Note : Please reward points if you think this was helpful.
10-03-2005 11:43 AM
Hi Sumi,
You can pass the value of Belnr to a variable of same length of SGTXT using <b>MOVE</b>.
For Example,
Data: W_BELNR like BSAD-SGTXT.
MOVE BELNR to W_BELNR.
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT = W_BELNR.
Regards,
Baburaj
Please Give the Reward points.
10-03-2005 11:45 AM
DATA WA_SGTXT LIKE BSAD-SGTXT.
MOVE BELNR TO WA_SGTXT.
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT eq WA_SGTXT
...
Cheers
10-03-2005 11:49 AM
Hi,
Try this.
data t_bsad type bsad.
select AUGBL AUGDT into (t_BSAD-AUGBL, t_BSAD-AUGDT)
from BSAD where SGTXT = BSAD~BELNR.
endselect.
Svetlin
10-03-2005 11:50 AM
data w_belnr like bsad-sgtxt.
concatenate 'belnr' '%' into w_belnr.
Select * from bsad where sgtxt like w_belnr.
Note: This SQL will be expensive
Ravi
10-03-2005 11:53 AM
u can't do a comparison in a select statement where both the fields on the left as well as on the right are from the database table. U probably have to go for one of these options...
1) compare with sgtxt that is previously determined in the program...this could be like retrieving in a separate internal table and then using 'FOR ALL ENTRIES' on it...like ....
select augbl augdt from bsad into table t_bsad
for all entries in t_bsad1
where belnr eq t_bsad1-sgtxt+0(10)...(followed by other conditions)
2) not recommended but u can try and go for a nested select.
rgds,
PJ
2)
10-03-2005 12:51 PM
hi,
try with this code,i am not sure about this but i think it could be helpful to you,
Data: duplicate_BELNR like BSAD-SGTXT.
WRITE BELNR to duplicate_BELNR.
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT = duplicate_BELNR.
10-03-2005 12:58 PM
Hi Sumi,
U can also create the another data type with type 'C' and length 50. Move belnr value into that.
Then in select use that field in where clause.
Reg,
Arpit
10-03-2005 1:17 PM
Hi,
data temp(12).
concatenate '%' belnr '%' into temp.
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT like temp.
If belnr is having multiple values,just create a internal table as follows.
types : begin of ty,
belnr....
temp(12),
end of ty.
data itab_ type standard table of ty.
data wa type ty.
loop at itab into wa.
concatenate '%' wa-belnr '%' into wa-temp.
modify itab from wa index sy-tabix transporting temp.
endloop.
Change your select statement accordingly.
Kindly reward poits if it helps.
10-03-2005 1:50 PM
Hi,
Just try this.
<b>concatenate '' belnr '' into temp.</b>
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT like temp.
10-03-2005 1:33 PM
1. Like is not working
2. I cannot use EQ. Coz SGTXT will have chars other than BELNR.
IF
BELNR = 123
SGTXT can be like this
TEST123TEST.
10-03-2005 1:43 PM
hi,
retieve all the records into interal table like
Select AUGBL AUGDT SGTXT into table t_xxxxx
from BSAD.
loop at t_xxxx
if t_xxx sgtxt ca belnr
else
delete t_xxxx
endif.
endloop
cheers,
sasi
10-03-2005 1:43 PM
Then use
CS (Contains String)
'ABCDE' CS 'CD' is true; SY-FDPOS = 2.
'ABCDE' CS 'XY' is false; SY-FDPOS = 5.
'ABC DEF' CS ' ' is true; but: SY-FDPOS = 0,
since ' ' is interpreted as a trailing blank and is thus
ignored.
10-03-2005 3:04 PM
Hi
You should create a string with tha value you want to check:
DATA SGTXT TYPE BSAD-SGTXT.
WRITE: '%' TO SGTXT(1),
BELNR TO SGTXT+1.
LEN = STRLEN( SGTXT ).
WRITE: '%' TO SGTXT+LEN(1).
SELECT * FROM BSAD WHERE SGTXT LIKE SGTXT
.....
Anyway I hope this isn't only condition you'd check, because it can take many time, it should be better you use the compnay code and vendor code.
Max