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

help me to solve this. select statement!

Shahid
Product and Topic Expert
Product and Topic Expert
0 Likes
1,051

hello alll

is there any functional module which gives me the BELNR(of bseg) by passing the vbeln.

yeah ...we can do tht by passing bseg table ,,,,but its taking loads of time to give me the output as its not a primary key or secondary key.....

when i m using this condition in the prog i cannot use inner join as its a cluster table . if i m writing a condition it is effecting my prog performance

this statement is really taking long time to process.

in bseg table as vbeln is not primary key or seconday key, i guess thz the reason it is taking so much time ,,,

can anyone help me to sort this out... ??

any fun mod to get the data of bseg cluster table by giving vbeln?/

or any other conditions to reduce the processing time?

clear t_vbrkvbrp.

sort t_vbrkvbrp by vbeln.

loop at t_vbrkvbrp.

at new vbeln.

select bukrs belnr vbeln

from bseg

into corresponding fields of table t_temp

where bukrs = t_vbrkvbrp-bukrs

and vbeln = t_vbrkvbrp-vbeln.

endat.

endloop.

SELECT bukrs belnr buzid koart shkzg dmbtr vbeln hkont kunnr werks

FROM bseg

INTO TABLE t_bseg

for all entries in t_temp

WHERE hkont IN s_hkont

AND bukrs = t_temp-bukrs

AND belnr = t_temp-belnr

AND buzid = ' '

AND koart = 'S'

AND shkzg = 'H'.

i need to get the g/l account number and belnr from bseg for the above condition type so i have to use bseg table

as there is no apporpriate index it is scanning the full table ,,,, so can anyone tell me how to create a index or like wise to get the data faster??

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,000

Don't use BSEG, use BKPF and fields AWTYP, AWREF which link a financial document to the application and document that generated it. (The "original document" under transaction like FB03)

<i>Example: "RMRP" + invoice number for purchase invoice</i>

In some case you need an intermediate table

<i>Example: from EKPO, EKBE, you get the MKPF records and from them the BKPF/BSEG</i>

For a list of "referenced procedures" Look at TTYP (text table is TTYPT), you will get the code, structure used to build the key (if more than one field) and a function module used to display the origin

<i>Example : MKPF "Material document" structure MKPF_AWKEY function module MB_DOCUMENT_SENDER_MKPF</i>

You can also look at your accounting documents found with the "slow" BSEG version of your program and establish a list of AWTYP used in you company/customer.

An other way, used in some companies, is to append a structure with EBELN field to BSIS and BSAS table, these table are filled via a MOVE-CORRESPONDING statement, so the nesw records will be filled (You may write a program to update past records) then create an index on EBELN on these fields.

Regards

PS: BSEG is a cluster table, so the only real criteria are the primary keys, if you select via EBELN, the program read the whole table, may be correct in Development, but not in Production and there it will be more and more resources consuming. So NEVER select from BSEG vithout the primary keys, use the secondary tables : BSIS/BSAS, BSIM, etc.

Don't use BSEG, use BKPF and fields AWTYP, AWREF which link a financial document to the application and document that generated it. (The "original document" under transaction like FB03)

<i>Example: "RMRP" + invoice number for purchase invoice</i>

In some case you need an intermediate table

<i>Example: from EKPO, EKBE, you get the MKPF records and from them the BKPF/BSEG</i>

For a list of "referenced procedures" Look at TTYP (text table is TTYPT), you will get the code, structure used to build the key (if more than one field) and a function module used to display the origin

<i>Example : MKPF "Material document" structure MKPF_AWKEY function module MB_DOCUMENT_SENDER_MKPF</i>

You can also look at your accounting documents found with the "slow" BSEG version of your program and establish a list of AWTYP used in you company/customer.

An other way, used in some companies, is to append a structure with EBELN field to BSIS and BSAS table, these table are filled via a MOVE-CORRESPONDING statement, so the nesw records will be filled (You may write a program to update past records) then create an index on EBELN on these fields.

Regards

PS: BSEG is a cluster table, so the only real criteria are the primary keys, if you select via EBELN, the program read the whole table, may be correct in Development, but not in Production and there it will be more and more resources consuming. So NEVER select from BSEG vithout the primary keys, use the secondary tables : BSIS/BSAS, BSIM, etc.

4 REPLIES 4
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,001

Don't use BSEG, use BKPF and fields AWTYP, AWREF which link a financial document to the application and document that generated it. (The "original document" under transaction like FB03)

<i>Example: "RMRP" + invoice number for purchase invoice</i>

In some case you need an intermediate table

<i>Example: from EKPO, EKBE, you get the MKPF records and from them the BKPF/BSEG</i>

For a list of "referenced procedures" Look at TTYP (text table is TTYPT), you will get the code, structure used to build the key (if more than one field) and a function module used to display the origin

<i>Example : MKPF "Material document" structure MKPF_AWKEY function module MB_DOCUMENT_SENDER_MKPF</i>

You can also look at your accounting documents found with the "slow" BSEG version of your program and establish a list of AWTYP used in you company/customer.

An other way, used in some companies, is to append a structure with EBELN field to BSIS and BSAS table, these table are filled via a MOVE-CORRESPONDING statement, so the nesw records will be filled (You may write a program to update past records) then create an index on EBELN on these fields.

Regards

PS: BSEG is a cluster table, so the only real criteria are the primary keys, if you select via EBELN, the program read the whole table, may be correct in Development, but not in Production and there it will be more and more resources consuming. So NEVER select from BSEG vithout the primary keys, use the secondary tables : BSIS/BSAS, BSIM, etc.

Read only

0 Likes
1,000

To get invoice financial document : Use AWTYP = 'VBRK' and AWKEY = invoice-number to read BKPF.

Regards

Read only

rodrigo_paisante3
Active Contributor
0 Likes
1,000

Hi shahid,

try to use select ... for all entries in this code:

clear t_vbrkvbrp.

sort t_vbrkvbrp by vbeln.

*loop at t_vbrkvbrp.

*at new vbeln.

select bukrs belnr vbeln

from bseg

into corresponding fields of table t_temp

<b>for all entries in t_vbrkvbrp[]</b>

where bukrs = t_vbrkvbrp-bukrs

and vbeln = t_vbrkvbrp-vbeln.

*endat.

*endloop.

You are using a select in a loop, this cause a long time, if this table is heavy, will take a lot.

Or you can use a other it to do what you want.

Regards.

Read only

varma_narayana
Active Contributor
0 Likes
1,000

Hi Shahid.

BSEG is a cluster table which gives performance problems and does not allow joins.

But the same data is also stored in tables

BSID - Closed items customer

BSAD - Open items customer.

You can see the field BSID-AUGBL that store the sales order no (VBAK-VBELN).

Hope this helps u.

<b>Reward if Helpful.</b>