10-16-2014 6:37 PM
Hi All,
I have a very small assignment in ABAP.
I have to make an ALV report from BSEG table of FI module. In the report there should be "Amount" column against "general ledger account", "cost center" , "profit center" and "business area".
I have found the Fields and data elements of Amount in LC (DMBTR), G/L Account (HKONT),Cost Center (KOSTL), Profit center(PRCTR), business area (GSBER) in BSEG table.
My question is while designing SELECT statement, which key fields would be required?
As BSEG is a cluster table, the only key fields allowed are those of the primary key[1]:
10-22-2014 7:47 AM
Hi Khurram,
You can actually select all of those as long as you set the where condition in your select statement right. These key fields may vary depending on your requirement. Example, if you are trying to reread the value of your select statement and compare to another table, say BSIS or BSAS, then you would definitely need key field BELNR(Document Number) to limit you comparison on the previous select statement coming from BSEG.
In your case, you can actually still use all if you have your parameters.
Best Regards,
Charlie
10-22-2014 8:07 AM
Cluster Tables:
- Should be accessed via primary key - very fast retrieval otherwise very slow
- No secondary indexes will be allowed
- 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.
As per the cluster definition RFBLG in which BSEG belongs to, below fields are highly enough to read the records for fast access...
BUKRS , BELNR, GJAHR
Please note that, you can write select query based on BUKRS or BUKRS, BELNR or BUKRS , BELNR, GJAHR (Totally, sequence of index fields will be left to right)... This is on the basis of performance view... Otherwise, it will be slow...
10-22-2014 8:42 AM
Actually the primary available keys are those common in BSEG and the actual database table RFBLG, so only [implicit MANDT], BUKRS, BELNR, GJAHR.
BUZEI as well as every other fields are only selected after actual read of database and decompression of raw data. also Joseph is right, every fields of BSEG are read in database, nevertheless better give a list of field in the SELECT to reduce size of data after each implicit or explicit package (each FETCH of data) is extracted.
As much as possible try to use "secondary indexes", for G/L those are BSIS and BSAS (depending on clearing status) You can also join BKPF with those tables. Only read BSEG as the last table, minimizing the size of the internal table referenced in the FOR ALL ENTRIES.
NB: You can also add an append structure to secondary indexes (with exact same fields in BS[I,A][S,K,D,M] table) as those are filled with MOVE-CORRESPONDING statements. (and build a small report to update added fields in legacy documents to be executed once out of peakside/workind days).
Regards,
Raymond