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

Reading data from BSEG

Former Member
0 Likes
2,634

Hi,

I never read data from Cluster table like BSEG, is there any precautions to be taken while reading data from it? as it contains voluminous data

please suggest.

regards,

Pra

Hi,

I never read data from Cluster table like BSEG, is there any precautions to be taken while reading data from it? as it contains voluminous data

please suggest.

regards,

Pra

5 REPLIES 5
Read only

amit_khare
Active Contributor
0 Likes
1,172

Hi,

the most important thing try to avoid using cluster table specially like BSEG, normally you can extract same data from transparent tables like BKPF too, your business person will be able to tell you better.

If nothing is there then try to provide all the key fields to read data from it.

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
1,172

hi Praneet,

1. Include all the key fields in the where conditon . Try making use of Indexes .

2. Never put these statements in loop and endloop .

3. Avoid using select .. endselect statement ..

Regards,

Santosh

Read only

Former Member
0 Likes
1,172

<b>Cluster Tables (BSEG,BSEC)</b>

  • Should be accessed via primary key - very fast retrieval otherwise very slow

  • No secondary indexes

  • Select * is Ok because all columns retrieved anyway. Performing an operation on multiple rows is more efficient than single row operations. Therefore you still want to select into an internal table. If many rows are being selected into the internal table, you might still like to retrieve specific columns to cut down on the memory required.

  • Statistical SQL functions (SUM, AVG, MIN, MAX, etc) not supported

  • Can not be buffered

SELECT bukrs belnr gjahr blart budat monat

tcode bvorg waers kursf hwaer

FROM bkpf

INTO TABLE it_bkpf

WHERE bukrs IN s_bukrs

AND gjahr IN s_gjahr

AND monat IN s_monat

AND tcode IN ('CO88', 'KO88', 'KK87')

AND awtyp EQ c_ref_pro. "'AUAK'

  • Pick up the corresponding line items from BSEG

SELECT bukrs belnr gjahr dmbtr wrbtr ktosl

zuonr hkont matnr werks menge

FROM bseg

INTO TABLE it_bseg

FOR ALL ENTRIES IN it_bkpf

WHERE bukrs = it_bkpf-bukrs

AND belnr = it_bkpf-belnr

AND gjahr = it_bkpf-gjahr

AND werks IN s_werks

AND ktosl = c_tr_key. "'PRD'

<b>BSEG Access</b>

BSAD Accounting: Secondary index for customers (cleared items)

BSAK Accounting: Secondary index for vendors (cleared items)

BSAS Accounting: Secondary index for G/L accounts (cleared items)

BSID Accounting: Secondary index for customers

BSIK Accounting: Secondary index for vendors

BSIM Secondary Index, Documents for Material

BSIS Accounting: Secondary index for G/L accounts

Read only

Former Member
0 Likes
1,172

Hello,

Instead of BSEG make use of the fillowing tables:

BSEC One-Time Account Data Document Segment

BSED Bill of Exchange Fields Document Segment

BSEG Accounting Document Segment

BSES Document Control Data

BSET Tax Data Document Segment

There are also index tables like BSIS, BSAS, BSID, BSAD BSIK and BSAK. You may be able to use one or two of them

Vasanth

Read only

Former Member
0 Likes
1,172

Hi,

Since BSEG is a cluster table field in where clause of the select shall contain only the primary keys. Any further filtering of the data shall be done after selection has been done.

Clear: I_BSEG/

Select BUKRS BELNR GJAHR BUZEI KOART SHKZG MENGE MEINS EBELN EBELP INTO TABLE I_BSEG FOR ALL ENTRIES IN I_BSIK WHERE BUKRS EQ I_BSIK-BUKRS

BELNR EQ I_BSIK-BELNR

GJAHR EQ I_BSIK-GJAHR.

If sy-subrc eq 0.

sort i_bseg by bukrs gjahr belnr.

endif.

Regards

Kannaiah