07-26-2010 3:15 PM
Hi,
S114010001
S118000001
S840100001
S168000001
S840100001
S128000001
S840100001
S128000001
I want to write a select queries where I need to pick the entries starting with S11* or S12*.
Similar way another query where it picks entries that will not start with S11* or S12*.
Example:
select single hkont into x_hkont from bseg where
belnr = vbrk-vbeln
and hkont like 'S11%'
or hkont like 'S12%'.
will the above query works? also I need other query where hkont is not equal to S11% or S12% that means it should select other than S11* or S12*.
Best Regards
MS
07-26-2010 3:28 PM
you must be carefule with: and / or
try:
select single hkont into x_hkont from bseg
where belnr = vbrk-vbeln
and ( hkont like 'S11%'
or hkont like 'S12%' ) .
(or better here : use select-options or ranges -> S_HKONT for BSEG-HKONT )
btw: this is a "bad" select-query becaus table bseg can rapid increase to 10.000.000++ documents
so be careful and try to use (here) tables bsis or bsas - otherwise use first table bkpf
-> and select bseg with key BUKRS,BELNR,GJAHR
grx
Andreas
Edited by: Andreas Mann on Jul 26, 2010 4:28 PM
07-26-2010 3:30 PM
This should work.
But I suggest do it in a better way. HKONT is not a key field & you are using only one key field in your select statement 'BELNR'. Instead of heaving two select statements, you rather TRY TO use your complete primary key BUKRS, BELNR, GJAHR & LINE ITEM.
After selecting the data, loop this itab and filter your data into two separate itabs and also perform any operations and calculation in the same loop. This way, you can avoid 2 selects and fetching data with flash card signs and non-key fields.
Hope this helps..
Thanks,
Kiran
07-26-2010 3:37 PM
Suresh..
definitely follow what kiran said.. but still if you just want your code to work..
you need to put the or condition in bracket..else it wont work.
it should be like..
select single hkont into x_hkont from bseg where
belnr = vbrk-vbeln and
( hkont like 'S11%' "===> i have added brackets..
or hkont like 'S12%' ).
07-26-2010 3:47 PM
Moderator message - Please do not ask or answer basic questions - thread locked Rob