2011 Feb 25 9:34 AM
Hi,
I have to take Invoice only for 1 & 2 Series Vendors. i.e. Lifnr = 01********** & 02**********.
I try it with diff codes - As -->
SELECT belnr gjahr budat lifnr lifnr(2) FROM rbkp
INTO (it_final-belnr, it_final-gjahr, it_final-budat, it_final-lifnr, v_lifnr)
WHERE budat IN so_budat
AND tcode = 'MIRO'
AND stblg = ''
AND lifnr(2) IN ('01','02').
" Syntax error
But not getting the correct Syntax. Is it possible to work like it?
Itwill give major diff on Performance if I can filter it in SELECT Statement.
Edited by: Priya.ABAP on Feb 25, 2011 10:34 AM
2011 Feb 25 10:16 AM
Hi Priya,
The code should be :
lifnr like '01%'.....
For your referenece see the below example..
data : it_lfa1 type TABLE OF lfa1.
select *
from lfa1
into TABLE it_lfa1
WHERE LIFNR LIKE '00003%'.
I have tested it.
It will select the vendors correponding to '00003...'
Hope it helps you.
Thanks
Arbind
2011 Feb 25 9:40 AM
i think you can use option of % in the where clause
where lifnr = '01 %'
try this option ..
Edited by: sniper on Feb 25, 2011 3:10 PM
2011 Feb 25 10:10 AM
Thanks.
I already try this options.
@Sniper
where lifnr = '01 %'
It's giving me Initial ITAB (sy-subrc = 4).
@Anilbhai
Yes, I have to compare first two Char Only.
lifnr + 0(2) in ( '01', '02') is also giving syntax error.
" Field lifnr+0(2) is unknown.
2011 Feb 25 9:52 AM
Hi,
Do you want to compare exactily first two characters of lifnr ?
then try using lifnr + 0(2) in ( '01', '02').
Thanks & Regards,
Anil Bhai
2011 Feb 25 10:16 AM
Hi Priya,
The code should be :
lifnr like '01%'.....
For your referenece see the below example..
data : it_lfa1 type TABLE OF lfa1.
select *
from lfa1
into TABLE it_lfa1
WHERE LIFNR LIKE '00003%'.
I have tested it.
It will select the vendors correponding to '00003...'
Hope it helps you.
Thanks
Arbind
2011 Feb 25 10:32 AM
Thanks Arbind.
I did it with LIKE statement only - But it works only for One Option and Not if I go for Three.
Like -->
SELECT belnr gjahr budat lifnr FROM rbkp
INTO (it_final-belnr, it_final-gjahr, it_final-budat, it_final-lifnr)
WHERE budat IN so_budat
AND tcode = 'MIRO'
AND stblg = ''
AND lifnr LIKE '01%'.
*This works Fine - and give me all Invoices for 1 Series Vendor - No issues"
But My Requirement is for Multiple - Like 1, 2 & 3 Series
And when I try it as -
SELECT belnr gjahr budat lifnr FROM rbkp
INTO (it_final-belnr, it_final-gjahr, it_final-budat, it_final-lifnr)
WHERE budat IN so_budat
AND tcode = 'MIRO'
AND stblg = ''
AND lifnr LIKE '01%' OR lifnr LIKE '02%' OR lifnr LIKE '03%'.
*In this Case it's giving me sy-subrc = 4. (Records are there in RBKP)
2011 Feb 25 10:35 AM
Try this:
SELECT belnr gjahr budat lifnr FROM rbkp
INTO (it_final-belnr, it_final-gjahr, it_final-budat, it_final-lifnr)
WHERE budat IN so_budat
AND tcode = 'MIRO'
AND stblg = ''
AND ( lifnr LIKE '01%' OR lifnr LIKE '02%' OR lifnr LIKE '03%' ).
2011 Feb 25 10:39 AM
Hi,
It should be like...
WHERE budat = '1'
AND tcode = 'MIRO'
AND stblg = ''
AND ( lifnr LIKE '01%' OR lifnr LIKE '02%' OR lifnr LIKE '03%' ).
Try it out.
It will work.
Thanks
Arbind
2011 Feb 25 10:17 AM
Hi Priya,
You have to use 'Like' statement to get the exact linked Vendors.
Thanks
Arbind
Edited by: Arbind Prasad on Feb 25, 2011 3:50 PM
2011 Feb 25 10:33 AM
Pls try this way. don't know whether it is useful for you
DATA : it_lfa1 TYPE TABLE OF lfa1,
wa_lfa1 like LINE OF it_lfa1.
SELECT *
FROM lfa1
INTO TABLE it_lfa1.
LOOP AT it_lfa1 INTO wa_lfa1
WHERE ( lifnr0(2) = '01' OR lifnr0(2) = '02').
********do your coding here***
ENDLOOP.
Regds,
AnilBhai