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

fetch value into internal table from bseg

Former Member
0 Likes
1,514

Hello

I am trying to fetch value of fields HKONT BSCHL from bseg into an internal table , but not able to do so, can any body tell how to do that, u help will be highly appreciated,

rgds

anupam

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,183

i am sure u have written a select query paste that here to see whats the wrong thing abt it

santhosh

Hello

I am trying to fetch value of fields HKONT BSCHL from bseg into an internal table , but not able to do so, can any body tell how to do that, u help will be highly appreciated,

rgds

anupam

8 REPLIES 8
Read only

Former Member
0 Likes
1,183

Hi,

Sample code for you.

DATA : begin of it_bseg occurs 0,

bukrs like bseg-bukrs,

hkont like bseg-hkont,

end of it_bseg.

data : v_line type i.

start-of-selection.

select bukrs

hkont

from bseg

into table it_bseg

where bukrs = '0001'.

describe table it_bseg LINES v_line.

write / v_line.

  • Reward if this helps

Read only

0 Likes
1,183

Hi

I have written the same query which u mentioned but it takes a hell lot of time to execute, can u suggest any thing else.

rgds

anup

Read only

Former Member
0 Likes
1,183

SELECT gjahr belnr buzei hkont bschl

into table itab

from bseg

where belnr eq ...

and gjahr eq ...

and buzei eq ...

Read only

Former Member
0 Likes
1,184

i am sure u have written a select query paste that here to see whats the wrong thing abt it

santhosh

Read only

Former Member
0 Likes
1,183

Hi,

That might be because of some error in ur code. Paste ur code here, lest its very hard 2 predict.

Read only

Former Member
0 Likes
1,183

Hi Anupam,

Since BSEG is a cluster table, it will have lots of entries. Try to put maximum key parameters in WHERE clause.

FYI. Key parameters are

BUKRS

BELNR

GJAHR

BUZEI

Read only

0 Likes
1,183

Hi Palak

Actually I have to generate a report using table BKPF and BSEG, i tried using join but that doesnt works as BSEG is a cluster table,

i need to display

bseg-hkont, bkpf-blart , bseg-bschl , count

where bseg-bukrs = bkpf-bukrs and bseg-gjahr = bkpf-gjahr

where count will count total records ,example

hkont blart bschl count

766000 AB 15

766000 AB 40 5

766000 AB 50 10

in count 5 + 10 comes out to be 15

Read only

0 Likes
1,183

It is good practice and performance enhancement never (means never ever!) to fetch data from BSEG directly.

Better first get the relevant headers from one of the secondary index tables as there are:

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 Item

BSEC : One-Time Account Data Document Segment

BSID : Accounting: Secondary Index for Customers

BSIK : Accounting: Secondary Index for Vendors

BSIS : Accounting: Secondary Index for G/L Accounts

Choose the appropriate table(s) for your requirement.

Define a 'header' table with only key fields for BKPF/BSEG.

Select from secondary index table(s) appending the header itab.

Then fetch only the fields you really need from BSEG and BKPF into corresponding fields of your results table for all entries in...

Hope you can do it!

Regards,

Clemens