Application Development and Automation 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: 
Read only

select query

Former Member
0 Likes
787

hi all,

in the report i need to fetch data based on BELNR, BUKRS, GJAHR and ZUONR

the problem is for paricular BELNR,BUKRS AND GJAHR they are alot of ZUONRS

FOR EG:

for a particular

BELNR BUKRS GJAHR ZUONR

1001 0010 2008 23456

1001 0010 2008 98567

1001 0010 2008 TMI234

1001 0010 2008 CA5673

1001 0010 2008 TK0000

1001 0010 2008 6736

Suppose i have the data as above in BSEG Table

i need to fetch only the following data based on ZUONR which contains first 2 letters alphabets

how can i fetch the following data

BELNR BUKRS GJAHR ZUONR

1001 0010 2008 TMI234

1001 0010 2008 CA5673

1001 0010 2008 TK0000

please see my select query , please help to fetch the data

SELECT BUKRS

BELNR

GJAHR

DMBTR

WRBTR

PSWSL

ZUONR

HKONT

FROM BSEG

INTO TABLE GT_BSEG

FOR ALL ENTRIES IN GT_BKPF

WHERE BUKRS EQ LT_BKPF-BUKRS

AND BELNR EQ LT_BKPF-BELNR

AND GJAHR EQ LT_BKPF-GJAHR

AND ZUONR EQ . "what do i need to put here.

PLEASE HELP

7 REPLIES 7
Read only

Former Member
0 Likes
759
SELECT BUKRS
BELNR
GJAHR
DMBTR
WRBTR
PSWSL
ZUONR
HKONT
FROM BSEG
INTO TABLE GT_BSEG
FOR ALL ENTRIES IN GT_BKPF
WHERE BUKRS EQ LT_BKPF-BUKRS
AND BELNR EQ LT_BKPF-BELNR
AND GJAHR EQ LT_BKPF-GJAHR.

Loop at GT_BSEG into <Workarea>.
If <workarea>-ZUONR+0(2) CN SY-ABCDE.          " If first two does not conatins characters delete.
DELETE GT_BSEG.
Endif.
ENDLOOP.

This will solve the issue.

Regards,

Gurpreet

Read only

Former Member
0 Likes
759

One way of achieving this:

SELECT BUKRS

BELNR

GJAHR

DMBTR

WRBTR

PSWSL

ZUONR

HKONT

FROM BSEG

INTO TABLE GT_BSEG

FOR ALL ENTRIES IN GT_BKPF

WHERE BUKRS EQ LT_BKPF-BUKRS

AND BELNR EQ LT_BKPF-BELNR

AND GJAHR EQ LT_BKPF-GJAHR.

loop at gt_bseg.

if gt_bseg-ZUONR+0(2) ca '0123456789'.

delete gt_bseg index sy-tabix.

endif.

endloop.

Regards,

Ravi kanth Talagana

Read only

Former Member
0 Likes
759

Hi,

You can use '%' symbol as we use '*' in select query.

use like this....

AND ( ZUONR LIKE 'T%' or ZUNOR LIKE 'C%' )but there should be some condition to filter.

Regards,

Naresh.

Read only

Former Member
0 Likes
759

my tip would be select em all and do your condition afterwards, when looping over it.

I dont think you can get something like "where first 2 characters is numeric" in your select query.

Read only

Former Member
0 Likes
759

hi ,

try using OFFSET on the first two characters of this field.

EX.

If OFFSET(0) CA '0123456789'

AND OFFSET(1) CA '0123456789'.

then the fields you want need not b fetched.

Hope it helps.

Edited by: srishti singh on Apr 15, 2009 12:41 PM

Read only

Former Member
0 Likes
759
Read only

Former Member
0 Likes
759

SELECT BUKRS

BELNR

GJAHR

DMBTR

WRBTR

PSWSL

ZUONR

HKONT

FROM BSEG

INTO TABLE GT_BSEG

FOR ALL ENTRIES IN GT_BKPF

WHERE BUKRS EQ LT_BKPF-BUKRS

AND BELNR EQ LT_BKPF-BELNR

AND GJAHR EQ LT_BKPF-GJAHR.

you need to fetch all values here and then you have see for your condition and delete your records.

loop at gt_bseg.

if gt_bseg-ZUONR+0(2) cn sy-abcde.

delete gt_bseg.

endif.

endloop.

Regards,

Lalit Mohan Gupta.