Hello Every one,
I want to extract clearing doc's for the same accounting doc's posted in bkpf bseg and bset.
This is my query, i want just check it if it's right coded or not to extract Clearing documents from BSAK and BSAD.
*for accounting docs
select bukrs belnr gjahr budat bldat blart cpudt waers awtyp awkey reindat vatdate wwert xblnr bktxt from bkpf into corresponding fields of table it_bkpf
where bukrs = p_bukrs
and belnr in p_belnr
and budat in p_budat
and cpudt in p_cpudt
and gjahr in p_gjahr
and monat in p_monat
and blart in p_blart
and cpudt in p_cpudt.
if sy-subrc = 0.
*for accounting docs
select bukrs belnr gjahr mwskz hwbas fwbas lwbas hwste fwste lwste stceg shkzg from bset
into corresponding fields of table it_bset
for all entries in it_bkpf
where bukrs = it_bkpf-bukrs
and belnr = it_bkpf-belnr
and gjahr = it_bkpf-gjahr
and mwskz ne empty_str.
sy-subrc = 0.
*for accounting docs
select bukrs belnr gjahr koart lifnr kunnr stceg saknr pswbt pswsl mwskz sgtxt shkzg from bseg
into corresponding fields of table it_bseg
for all entries in it_bset
where bukrs = it_bset-bukrs
and belnr = it_bset-belnr
and gjahr = it_bset-gjahr
and ( lifnr ne empty_str or kunnr ne empty_str ).
* get clearing data for vendor
select bukrs lifnr belnr gjahr bldat augdt augbl zlsch from bsak into corresponding fields of table it_bsak
for all entries in it_bset
where bukrs = it_bset-bukrs
and belnr = it_bset-belnr
and gjahr = it_bset-gjahr.
* get clearing data for customer
select bukrs kunnr belnr gjahr bldat augdt augbl zlsch from bsad into corresponding fields of table it_bsad
for all entries in it_bset
where bukrs = it_bset-bukrs
and belnr = it_bset-belnr
and gjahr = it_bset-gjahr.
And to fill in my data for Vendor i do this following condition:
if wa_bsak-augbl is not initial.
write customer clearing data......
if wa_bsad-augbl is not initial.
write vendor clearing data......
is this query right ????
Thank u for replaying.