Skip to Content
0
Former Member
Mar 10, 2009 at 12:42 PM

where condition problem

18 Views

Hi experts

My sel SCr has

(all are select option)

Customer number - KUNNR

region - REGIO

date -BLDAT

company code -BUKRS

for (EG) if i have customer 00001 in Region AP .

According to my input even i give TN its fetching the output

leaving my customer name(kna1-name1) blank

can you pls help me out saying where i have gone wrong???

MY CODE

======

select bukrs gjahr belnr blart bldat budat xblnr bktxt xreversal from bkpf

into corresponding fields of table it_bkpf

where bukrs = pr_bukrs

  • and gjahr = wa_bkpf-gjahr

  • and belnr = wa_bkpf-belnr

and blart = 'DH' and

budat in so_budat

and xreversal = ' '.

If it_bkpf[] is not initial.

**Selection item details based on distributor

Select bukrs belnr gjahr buzei kunnr dmbtr zuonr from bseg

into corresponding fields of table it_bseg

for all entries in it_bkpf

where bukrs = it_bkpf-bukrs and

gjahr = it_bkpf-gjahr and

belnr = it_bkpf-belnr and

kunnr in so_kunnr.

Endif.

If it_bseg[] is not initial.

**Selection region for distributor

Select kunnr regio name1 from kna1

into corresponding fields of table it_kna1

for all entries in it_bseg

where kunnr = it_bseg-kunnr

and regio in so_regio.

Endif.

Loop at it_bseg into wa_bseg.

if wa_bseg-kunnr <> ' ' .

wa_final-belnr = wa_bseg-belnr.

wa_final-dmbtr = wa_bseg-dmbtr.

wa_final-zuonr = wa_bseg-zuonr.

wa_final-kunnr = wa_bseg-kunnr.

Endif.

read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.

wa_final-bldat = wa_bkpf-bldat.

wa_final-budat = wa_bkpf-budat.

wa_final-xblnr = wa_bkpf-xblnr.

wa_final-bktxt = wa_bkpf-bktxt.

ead table it_kna1 into wa_kna1 with key kunnr = wa_bseg-kunnr.

if sy-subrc = 0.

wa_final-name1 = wa_kna1-name1.

Endif.

append wa_final to it_final.

clear wa_final.

Endloop.