Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

abap query to select a line item # from bseg on basis of following pattern:

Former Member
0 Kudos

Hello,

I want to retrieve the line item # from bseg which has the following pattern,

account type = S

AND

gl account starting from 135***** , 136***** , 137*****

, 138***** , 139*****

hope i am comprehendable. How do i go on writing the query,

Thanks..

Shehryar

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

Hello,

Select * from bseg into itab

where koart = 'S'

and ( hkont like '000135%' or hkont like '000136%' )

Reagrds,

Naimesh

9 REPLIES 9

naimesh_patel
Active Contributor
0 Kudos

Hello,

Select * from bseg into itab

where koart = 'S'

and ( hkont like '000135%' or hkont like '000136%' )

Reagrds,

Naimesh

Former Member
0 Kudos

simplest of all would be use ranges statement

populate ina range as low eq 13500000 ( 0 for a * )

and high as 1399999(high is 9 for a *)

use ranges

r_range-low = 13500000

r_range-high = 1399999

r_range-sign = BT

r_range-option = I

Regards,

Harish

Former Member
0 Kudos

Hi ,

put like this

ranges : r_hkont for bseg-hkont.

r_hkont-sigh = 'I'.

r_hkont-option = 'BT'

r_hkont-low = '000000000135000'.

r_hkont-high = '000000000139999'.

append r_hkont.

clear r_hkont.

if r_hknot is not initial.

select * from bseg into corresponding fields of ibseg

where bukrs in s_bukrs

and gjahr in s_gjahr

and HKONT in R_hkont.

endif.

Regards

Prabhu

0 Kudos

Hello and thanks..

Prabhu, ibseg will have the type of bseg ..rite ?

0 Kudos

Prabhu,

i get 000 in ibseg when i run yur query..

0 Kudos

Hi Dahar ,

just check the internal length of the Hkont then pass.

otherwise post ur code

Regards

Prabhu

Former Member
0 Kudos

Hello,

Built a range table like the field u have mentioned.

Then fill the Table like.

s_glacc-sign = 'I'.

s_glacc-option = 'CP'

s_glacc-low = '135*'.

append g_glacc.

s_glacc-sign = 'I'.

s_glacc-option = 'CP'

s_glacc-low = '136*'.

append g_glacc.

so on...

In the query where glacc in s_glacc.

If useful reward points.

Vasanth

andreas_mann3
Active Contributor
0 Kudos

hi,

you'll get performance problems with your select

-> try to fill some key-fields too:

bukrs, gjahr and perhaps the nr. range to fill the field belnr

- you can preselect your accounts with table glt0: if here are no movements - you can exclude the account from select of bseg

Andreas

Former Member
0 Kudos

Hi Shehryar,

This will fetch records with GL A/C starting with <b>13</b> only , if you want 14 and others also write sepearate conditions using <b>LIKE</b> statements.


REPORT zztest.

DATA : itab TYPE STANDARD TABLE OF bseg WITH HEADER LINE.

SELECT * FROM bseg INTO TABLE itab WHERE <b>koart = 'S'

AND

hkont LIKE '13%'</b>.

This will take a lot of DB time for fetching the records, try to include Key Fields(BUKRS and GJAHR .. if possible others).

Regards,

Arun Sambargi.

Regards