Dear All,
I need to display all customers as per selected Salesperson field(pernr) . i am getting single salesperson perfectly but in select-options if i am selecting multiple selection it is giving long list
it is mixing all customers of diffent sales persons.
so plz help me out in this regards i need to display what ever salesmen i am selecting under that i need to display that customers ony like this.
Salesmen A.
1
2
3
Salesmen B
1
2
3
4
5
slaesmen c
1
2
3
like this i need to display plz help me.
&----
*& Report ZSTMTCUST
*&
&----
*&
*&
&----
REPORT ZSTMTCUST NO STANDARD PAGE HEADING
LINE-SIZE 90.
TABLES : knvp,kna1,BSID.
TYPES : BEGIN OF TY_knvp,
PERNR TYPE knvp-PERNR,
KUNNR TYPE knvp-KUNNR,
END OF TY_knvp.
types : begin of ty_kna1,
kunnr type kna1-kunnr,
name1 type kna1-name1,
end of ty_kna1.
TYPES : BEGIN OF TY_BSID,
KUNNR TYPE BSID-KUNNR,
BELNR TYPE BSID-BELNR,
SHKZG TYPE BSID-SHKZG,
DMBTR TYPE BSID-DMBTR,
END OF TY_BSID.
TYPES : BEGIN OF TY_BSID1,
KUNNR TYPE BSID-KUNNR,
BELNR1 TYPE BSID-BELNR,
SHKZG TYPE BSID-SHKZG,
DMBTR TYPE BSID-DMBTR,
END OF TY_BSID1.
DATA :T_BSID1 TYPE STANDARD TABLE OF TY_BSID1 INITIAL SIZE 1,
W_BSID1 TYPE TY_BSID1.
TYPES :BEGIN OF TY_FINAL,
PERNR TYPE knvp-PERNR,
KUNNR TYPE BSID-KUNNR,
name1 type kna1-name1,
BELNR TYPE BSID-BELNR,
SHKZG TYPE BSID-SHKZG,
DBB TYPE BSID-DMBTR,
CRR TYPE ty_bsid1-dmbtr,
END OF TY_FINAL.
DATA :T_knvp TYPE STANDARD TABLE OF TY_knvp INITIAL SIZE 1,
W_knvp TYPE TY_knvp.
DATA :T_kna1 TYPE STANDARD TABLE OF TY_kna1 INITIAL SIZE 1,
W_kna1 TYPE TY_kna1.
DATA :T_BSID TYPE STANDARD TABLE OF TY_BSID INITIAL SIZE 1,
W_BSID TYPE TY_BSID.
DATA :T_FINAL TYPE STANDARD TABLE OF TY_FINAL INITIAL SIZE 1,
W_FINAL TYPE TY_FINAL.
data : DB type p decimals 2,
DB1 TYPE P DECIMALS 2,
CR TYPE P DECIMALS 2,
CR1 TYPE P DECIMALS 2,
total TYPE P DECIMALS 2,
gtotal type p decimals 2.
DB = 0.
DB1 = 0.
CR = 0.
CR1 = 0.
total = 0.
gtotal = 0.
data : gtabix type i.
*PARAMETERS : SMEN TYPE knvp-PERNR.
select-options : smen for knvp-pernr.
SELECT PERNR
KUNNR
FROM
knvp
INTO TABLE T_knvp
WHERE PERNR in SMEN.
check t_knvp is not initial.
select kunnr
name1
from kna1
into table t_kna1
for all entries in t_knvp
where kunnr = t_knvp-kunnr.
check t_knvp is not initial.
SELECT KUNNR
BELNR
SHKZG
DMBTR
FROM
BSID
INTO TABLE T_BSID
FOR ALL ENTRIES IN T_knvp
WHERE KUNNR = T_knvp-KUNNR
and bukrs = '0002'
and gjahr = '2009'
and ( shkzg = 'S' OR SHKZG = 'H' ). "Debit and Credit
check t_knvp is not initial.
loop at t_bsid into w_bsid.
read table t_knvp into w_knvp with key kunnr = w_bsid-kunnr.
read table t_kna1 into w_kna1 with key kunnr = w_knvp-kunnr.
if sy-subrc eq 0.
if w_bsid-shkzg = 'H'. "when credit
cr1 = cr1 + w_bsid-dmbtr.
cr = cr1 / 1000.
else. "when debit
db1 = db1 + w_bsid-dmbtr.
db = db1 / 1000. " This is Debit...
endif.
Move : w_knvp-pernr to w_final-pernr,
w_kna1-name1 to w_final-name1,
w_bsid-kunnr to w_final-kunnr,
w_bsid-belnr to w_final-belnr,
w_bsid-shkzg to w_final-shkzg,
db to w_final-dbb, "contains Debit
cr to w_final-crr. "contains credit
append w_final to t_final.
endif.
clear : w_bsid,
w_knvp,
db1,
cr1,
db,
cr,
w_final.
endloop.
loop at t_final into w_final.
*at new pernr.
*gtabix = sy-tabix.
*read table t_final into w_final index gtabix.
at end of kunnr.
sum.
total = w_final-dbb - w_final-crr.
gtabix = sy-tabix.
read table t_final into w_final index gtabix.
WRITE :/01 sy-vline,
05 w_final-kunnr,
25 w_final-name1,
60 total,90 sy-vline.
gtotal = gtotal + total.
endat.
*endat.
at last.
uline." :/65(15).
write :/49 'Grand Total', 60 gtotal color col_total.
uline :/65(15).
endat.
endloop.
clear total.
clear gtotal.
top-of-page.
write :/30 'CUSTOMER STATEMETS - BY SALESMEN' color col_heading.
ULINE :/30(34).
write :/05 'Salesmen-number', w_final-pernr,70 'Page No:',sy-pagno .
uline.
format color 5.
write :/01 sy-vline,
05 'Customer Number',
25 'Cusotmer Name',
65 'Total Amount', 90 sy-vline.
uline.
format color off.