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: 

Data from BSEG table

Former Member
0 Kudos

Hi all,

I have written a select query to pull data from BSEG table for BSCHL (Posting key) values 31 or 22.

But currently its pulling only for 31 value and not for 22, if i am specifying only 22 in where condition then also I am facing the same problem.

How can I modify the below select query to pull data from bseg table for b oth the values of BSCHL field?

SELECT BUKRS BELNR GJAHR AUGDT BSCHL WRBTR WMWST LIFNR

APPENDING CORRESPONDING FIELDS OF TABLE I_BSEG PACKAGE SIZE 5000

FROM BSEG

WHERE BUKRS IN S_BUKRS

AND AUGDT IN S_AUGDT

AND BSCHL IN ('31','22')

AND KOART = 'K'

AND SHKZG = 'H'

AND LIFNR IN S_LIFNR.

Endselect.

Thanks in advance.

Selina

1 ACCEPTED SOLUTION

faisal_altaf2
Active Contributor
0 Kudos

Hi, Selk

Just comment out the following where condition.

"AND shkzg = 'H'

Same on my system there is no value in the table where SHKZG = 'H' and BSCHL = '22'.

Hope will help you to understand you problem,

Best Regards,

Faisal

6 REPLIES 6

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Selina,

First step will be to check in SE16 if you have data in BSEG for the given combination of selection params.

Please check & revert back.

BR,

Suhas

faisal_altaf2
Active Contributor
0 Kudos

Hi, Selk,

Please check for your other WHERE Conditions are they true for 22 as well ?

Regards,

Faisal

Former Member
0 Kudos

Hi,

SELECT bukrs belnr gjahr augdt bschl wrbtr wmwst lifnr

APPENDING CORRESPONDING FIELDS OF TABLE i_bseg PACKAGE SIZE 100

FROM bseg

WHERE bukrs IN s_bukrs

AND augdt IN s_augdt

AND ( bschl ='31'

OR bschl = '22' )

AND koart = 'K'

AND shkzg = 'H'

AND lifnr IN s_lifnr.

ENDSELECT.

This should work.. Only this what you need to keep in mind is there should be entries in BSEG for bschl 22 koart K and shkzg H.

Regards

Ansari

Former Member
0 Kudos

Hi,

I think with posting key 22 (Reverse invoice) you can not have SHKZG( Debit credit indicator ) as 'H' it will always be 'D' so you have to remove the where condition on SHKZG and that should resolve the issue.

Regards,

Himanshu

faisal_altaf2
Active Contributor
0 Kudos

Hi, Selk

Just comment out the following where condition.

"AND shkzg = 'H'

Same on my system there is no value in the table where SHKZG = 'H' and BSCHL = '22'.

Hope will help you to understand you problem,

Best Regards,

Faisal

0 Kudos

Hi,

Thank you all for the Quick reply.

My issue is solved.

Regards.

Selina.