Skip to Content
0
Former Member
Feb 22, 2008 at 07:19 PM

select..!

17 Views

Hi ALLL,

Hope all are doing great!!!

Enclosed routine cosists of select....endselect query....i have changed the code as select..into table itab.. without using select..endselect ..but its taking more processing time to get the ouput...

So my question is ..can u pls help me out in changing the select.......endselect as select into table itab at appropriate places of select .....endselect ....

without changing the existing functionality in the routine...

<REMOVED BY MODERATOR>

Form demo.
Data: lv_tax_exists(1)   type c,
       Lv_abs    type   bseg-wrbtr,
     Lv_kunnr   type   knb1-kunnr,
     Ls_t000   type   t000,
     Lv_belnr_prefix(2)   type   c.

Types: begin of ty_lst_kna1,
Erdat type kna1-erdat,
Anred type kna1-anred,
.
* some more fields from kna1 table
.
.
.
land1 type kna1-land1,
pst12 type kna1-pst12,
end of ty_lst_kna1.

Types :	begin of ty_lst_bsid,
	Bukrs type bsid-bukrs,
gjahr	type bsid-gjahr,
.
.
* some more fields from bsid table
.
filkd type bsid-filkd,
end of ty_lst_bsid.

Types: begin of ty_lst_bkpf,
Belnr type bkpf-belnr,
Gjahr type bkpf-gjahr,
Bukrs type bkpf-bukrs,
.
.
*some more fields from bkpf table
Budat type bkpf-budat,
End of ty_lst_bkpf.

Types: begin of ty_lst_bseg,
Belnr type bseg-belnr,
Gjahr type bseg-gjahr,
Bukrs type bseg-bukrs,
.
.
*some more fields from bkpf table
Budat type bseg-budat,
End of ty_lst_bseg.

Data: lt_bsid type standard table of ty_lst_bsid,
	ls_kna1 type ty_lst_kna1,
	ls_bsid type ty_lst_bsid,
	ls_bkpf type ty_lst_bkpf,
ls_bseg  type ty_lst_bseg.

Select  pmvalue_low
Into lv_belnr_prefix
Up to 1 rows
From zgd_prog_consts
Where repid = sy- repid
And pmname = ‘belnr_prefix’.
Endselect.

Select single * from t000
Into ls_t000
Where mandt eq sy-mandt.

Select bukrs waers 
From t001 
Into table gt_t001
Where bukrs in s_bukrs
Order by bukrs.

Select bukrs belnr gjahr ……..from bkpf 
Into ls_bkpf 
Where < condition>.

Check ls_bkpf-blart in s_blart.

Check ls_bkpf-belnr(2) ne lv_belnr_prefix.

Select bukrs belnr gjahr……from bseg
Into ls_bseg
Where <condition>.

Check ls_bseg-koart eq ‘D’.

Check ls_bseg-kunnr in s_kunnr
Or ( ls_bseg-filkd in s_kunnr   and not ls_bseg-filkd is initial).

Perform check_tax using ls_bkpf-bukrs
			     Ls_bkpf-belnr
			     Ls_bkpf-gjahr
		Changing lv_tax_exists.

Check lv_tax_exists is initial.

If ls_bkpf-blart in s_blar2.
Check bseg-shkzg eq ‘S’.
Endif.

Clear: gs_alv.
Gs_alv-bukrs = ls_bkpf-bukrs.
If not bseg-filkd is initial.
Gs_alv-kunnr = ls_bseg-filkd.
Else.
Gs_alv-kunnr = ls_bseg-kunnr.
Endif.
Gs_alv-belnr  = ls_bseg-belnr.
Gs_alv-blart = ls_bkpf-blart.
…
…
………
…
…
…
….
…
gs_alv-wrbtr = ls_bseg-wrbtr.
Gs_alv-dmbtr = ls_bseg-dmbtr.
…
..
..
append gs_alv to gt_alv.

Endselect.
Endselect.

Sort gt_alv.


Loop at gt_alv into gs_alv.

at new kunnr.


*read data from bsid and bsad when using fiscal period.

If not p_rb_new is initial.

 If not gs_alv-knrze is initial.
Lv_kunnr = gs_alv-knrze.
Else.
Lv_kunnr = gs_alv-kunnr.
Endif.

Clear : lt_bsid[].

Select bukrs gjahr belnr budat blart………..
From bsid
Into ls_bsid
Where <condition>.

If lv_kunnr eq gs_alv-knrze.
Check ls_bsid-filkd eq gs_alv-kunnr.
Endif.

Check ls_bsid-blart in s_blart.

Check ls_bsid-belnr(2) ne lv_belnr_prefix.

If ls_bsid-blart in s_blar2.
Check ls_bsid-shkzg eq ‘S’.
Endif.
Append ls_bsid to lt_bsid.
Exit.
Endselect.


Select bukrs gjahr belnr budat blart………..
From bsad
Into ls_bsid
Where <condition>.

If lv_kunnr eq gs_alv-knrze.
Check ls_bsid-filkd eq gs_alv-kunnr.
Endif.

Check ls_bsid-blart in s_blart.

Check ls_bsid-belnr(2) ne lv_belnr_prefix.

If ls_bsid-blart in s_blar2.
Check ls_bsid-shkzg eq ‘S’.
Endif.
Append ls_bsid to lt_bsid.
Exit.
Endselect.

Sort lt_bsid by budat descending.

Read table lt_bsid into ls_bsid index 1.

If sy-subrc is initial.

Perform check_tax using……..Changing lv_tax_exists.

If lv_tax_exists is initial.
Delete gt_alv where bukrs eq gs_alv-bukrs
			And kunnr eq gs_alv-kunnr.
Continue.
Endif.
Endif.	


Endif.
Endat.


Case ‘x’.
…..
……
..
…
...
Endcase.

If lv_abs  lt   p_wrbtr.
Delete gt_alv.
Continue.
Endif.

Move-corresponding ls_kna1 to gs_alv.
Move gs_t001-waers to gs_alv-hwaer.

Modify gt_alv from gs_alv.
Endloop.

Endform.

regards

jack

Edited by: Alvaro Tejada Galindo on Feb 22, 2008 2:25 PM