‎2005 Nov 24 8:04 AM - last edited on ‎2024 Feb 04 1:17 AM by postmig_api_4
Hi friends ,
Please suggest most optimized code for the following scenerio , which fetches Billing Document , Company Code , and Address based on plant
There are two tables
1 . T001 (only 13 rows present in this) containing
a. Company Code - BUKRS
b. Address - ADRNR
2. BSEG (60000 rows present in this and 3000 rows per plant on avg. ) containing
a. Billing document - VBELN
b. Planning Date - FDTAG
c. Company Code - BUKRS
d. Plant - WERKS
‎2005 Nov 24 8:10 AM
Hi Yogesh,
TRy this code:
Select bukrs, adrnr into table i_tab1 from t001.
if sy-subrc = 0.
Select vbeln bukrs werks into table i_tab2 from bseg
for all entries in i_tab1 where bukrs = i_tab1-bukrs.
endif.
Use these two internal tables after proper sorting to get your required output.
Regards,
Raj
‎2005 Nov 24 8:16 AM
hi
secify the selection criteria
select bukrs werks adrnr from t001 into table itab_company
if sy-subrc is initial.
select bukrs belnr gjahr
into table itab
from bseg
for all entries in itab_company
where bukrs = itab_company-bukrs
and werks = itab_Company-werks
and.......anymore conditions
select name1 name2 from adrc into table itab_address
for all entries in itab_company
where adrnr = itab_company-adrnr
endif
‎2005 Nov 24 8:35 AM
Hi,
As far as possible avoid retrieving data from BSEG as this is a cluster table, instead you can use the following according to your requirement,
1. To get Vendor account details,
Use: BSAK(Cleared)
BSIK(Open) you may have to append both the table entries in one internal table, using appending statement
2.To get G/L account details,
Use: BSAS(Cleared)
BSIS(Open)
3.To get Customer account details
Use: BSAD(Cleared)
BSIS(Open)
Hope this helps,
Rgds,