Sample Programs

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 108

Single tender.

*&---------------------------------------------------------------------* *& Report ZMM_SINGLE_TENDER1 * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* report zmm_single_tender1 .

tables: ekko, ekpo, mkpf, mseg, eket, tbsgt. type-pools: slis. selection-screen : begin of block a with frame title text-000. select-options : s_date for sy-datum no-extension. select-options: s_bsart for ekko-bsart default 'NB' no-extension.

selection-screen: end of block a.

selection-screen: begin of block c with frame title text-002. parameters : po radiobutton group rad1 , st radiobutton group rad1, gr radiobutton group rad1. * mir RADIOBUTTON GROUP rad1. selection-screen: end of block c. types: begin of ty_po, ebeln like ekpo-ebeln, ebelp like ekpo-ebelp, bedat like ekko-bedat, matnr like ekpo-matnr, txz01 like ekpo-txz01, menge like ekpo-menge, meins like ekpo-meins, matkl like ekpo-matkl, * count type i, netwr like ekpo-netwr, netpr like ekpo-netpr, effwr like ekpo-effwr, waers like ekko-waers, lifnr like lfa1-lifnr, name1 like lfa1-name1, brsch like lfa1-brsch, brtxt like t016t-brtxt, ort01 like lfa1-ort01, regio like lfa1-regio, bstyp like ekpo-bstyp, bsart like ekko-bsart, bsgru like ekpo-bsgru, bezei like tbsgt-bezei, end of ty_po.

" " " " " " "

PO NUMBER PO SL NUMBER PO DATE MATERIAL NUMBER MATERIAL DESCRIPTION QUANTITY UoM

" " " " " " " " " " " " " "

NET ORDER VALUE NET PRICE EFFECTIVE VALUE CURRENCY UNIT VENDOR NUMBER VENDOR NAME VENDOR INDUSTRY TYPE (SSI STATUS INDICATOR) VENDOR INDUSTRY TYPE TEXT VENDOR CITY VENDOR REGION RFQ/PO DIFFERENTIATOR PO TYPE REASON FOR ORDERING REASON FOR ORDERING TEXT

types: begin of ty_gr, mblnr like bldat like zeile like lifnr like name1 like xblnr like budat like ebeln like ebelp like bedat like matnr like txz01 like erfmg like erfme like meins like lsmng like shkzg like dmbtr like waers like bwart like bsart like bsgru like bezei like end of ty_gr.

mseg-mblnr, mkpf-bldat, mseg-zeile, mseg-lifnr, lfa1-name1, mkpf-xblnr, mkpf-budat, ekpo-ebeln, ekpo-ebelp, ekko-bedat, ekpo-matnr, ekpo-txz01, mseg-erfmg, mseg-erfme, ekpo-meins, mseg-lsmng, mseg-shkzg , mseg-dmbtr, ekko-waers, mseg-bwart, ekko-bsart, ekpo-bsgru, tbsgt-bezei,

" " " " " " " " " " " " " " " " " " " " " " "

GR NUMBER GR DATE GR ITEM VENDOR CODE VENDOR NAME DC NUMBER DC DATE PO NUMBER PO SLNO PO DATE MATERIAL NUMBER MATERIAL DESCRIPTION QUANTITY IN PO UNIT OF MEASURE UNIT OF MEASURE QUANTITY DELIVERED DEBIT CREDIT INDICATOR TOTAL AMOUNT CURRENCY UNIT MOVEMENT TYPE PO TYPE REASON FOR ORDERING REASON FOR ORDERING TEXT

types: begin of ty_ekko, ebeln type ekko-ebeln, bstyp type ekko-bstyp, lifnr type ekko-lifnr, bedat type ekko-bedat, bsart type ekko-bsart, waers type ekko-waers, bsgru type ekpo-bsgru, end of ty_ekko. types: begin of ty_ekpo, ebeln type ekpo-ebeln, ebelp type ekpo-ebelp, matnr type ekpo-matnr, menge type ekpo-menge, meins type ekpo-meins, netwr type ekpo-netwr, effwr type ekpo-effwr, bsgru type ekpo-bsgru, netpr type ekpo-netpr, txz01 type ekpo-txz01, matkl type ekpo-matkl, end of ty_ekpo. types: begin of ty_tbsgt, bsgru type tbsgt-bsgru, bezei type tbsgt-bezei, count type i, effwr like ekpo-effwr,

" EFFECTIVE VALUE

end of ty_tbsgt

types: begin of ty_mkpf, mblnr type mkpf-mblnr, mjahr type mkpf-mjahr, budat type mkpf-budat, xblnr type mkpf-xblnr, end of ty_mkpf. types: begin of ty_mseg, mblnr type mseg-mblnr, mjahr type mseg-mjahr, zeile type mseg-zeile, matnr type mseg-matnr, lifnr type mseg-lifnr, ebeln type mseg-ebeln, ebelp type mseg-ebelp, erfmg type mseg-erfmg, erfme type mseg-erfme, meins type mseg-meins, shkzg type mseg-shkzg, dmbtr type mseg-dmbtr, lsmng type mseg-lsmng, bwart type mseg-bwart, waers type mseg-waers, end of ty_mseg.

types: begin of ty_lfa1, lifnr type lfa1-lifnr, name1 type lfa1-name1, end of ty_lfa1. types: begin of ty_ekbe, ebeln type ekbe-ebeln, ebelp type ekbe-ebelp, belnr type ekbe-belnr, gjahr type ekbe-gjahr, end of ty_ekbe. types: begin of ty_value, count type i, amount type ekpo-effwr, bsgru type ekpo-bsgru, bezei type tbsgt-bezei, grand_total type p, no_po type i, end of ty_value. types: begin of ty_value1, count type i, amount type ekpo-effwr, end of ty_value1. data: it_po type standard table of ty_po, wa_po type ty_po, it_gr type standard table of ty_gr, wa_gr type ty_gr,

it_ekbe type standard table of ty_ekbe, wa_ekbe type ty_ekbe, it_mkpf type standard table of ty_mkpf, wa_mkpf type ty_mkpf, it_mseg type standard table of ty_mseg, wa_mseg type ty_mseg, it_lfa1 type standard table of ty_lfa1, wa_lfa1 type ty_lfa1, it_ekko type standard table of ty_ekko, wa_ekko type ty_ekko, it_ekpo type standard table of ty_ekpo, wa_ekpo type ty_ekpo, it_tbsgt type standard table of ty_tbsgt, wa_tbsgt type ty_tbsgt, it_value type sorted table of ty_value with non-unique key bsgru bezei, wa_value type ty_value, it_value2 type standard table of ty_value1, wa_value2 type ty_value1, it_value1 type table of ty_value, wa_value1 type ty_value. data : i_fcat type slis_t_fieldcat_alv, i_fcat1 type slis_t_fieldcat_alv with header line, i_layou type slis_layout_alv, t_event type slis_t_event, t_event1 type slis_t_event with header line, t_list_commentary type slis_t_listheader, t_list_commentary1 type slis_t_listheader with header line.

data

: repid like sy-repid, lin type i, per_t type p decimals 2, per_a type p decimals 2, per_b type p decimals 4. repid = sy-repid.

at selection-screen.

if po eq 'X' or st eq 'X'. perform getdata. elseif gr eq 'X'. perform getdata1. * elseif mir EQ 'X'. * include zmir1. endif. * if mir EQ 'X'.

* *

include <zmir1>. endif.

start-of-selection. perform setdata. perform display. *&--------------------------------------------------------------------* *& Form getdata *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* form getdata. select ebeln bstyp lifnr bedat bsart waers from ekko into table it_ekko where bedat in s_date and bsart in s_bsart and bstyp = 'F'.

describe table it_ekko lines lin.

if it_ekko[] is not initial. select ebeln ebelp matnr menge meins netwr effwr bsgru netpr txz01 matkl from ekpo into table it_ekpo for all entries in it_ekko where ebeln = it_ekko-ebeln and loekz ne 'L'. * and * bsgru in (106 , 101 , 100 , 104 , 103 , 108 , 102 , 105 , 107 , 110 ,400 ,404, 407). endif.

if it_ekpo[] is not initial. select bsgru bezei from tbsgt into table it_tbsgt for all entries in it_ekpo where bsgru = it_ekpo-bsgru and spras = 'EN'. endif.

endform.

"getdata

*&--------------------------------------------------------------------* *& Form getdata1 *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* form getdata1. select ebeln bstyp lifnr bedat bsart waers from ekko into table it_ekko where bedat in s_date and bsart in s_bsart and bstyp = 'F'.

if it_ekko[] is not initial. select ebeln ebelp matnr menge meins netwr effwr bsgru netpr txz01 matkl from ekpo into table it_ekpo for all entries in it_ekko where ebeln = it_ekko-ebeln and loekz ne 'L'. endif. if it_ekpo[] is not initial. select ebeln ebelp belnr gjahr from ekbe into table it_ekbe for all entries in it_ekpo where ebeln = it_ekpo-ebeln and ebelp = it_ekpo-ebelp and bewtp = 'E'.

endif.

if it_ekbe[] is not initial. select mblnr mjahr

budat xblnr from mkpf into corresponding fields of table it_mkpf for all entries in it_ekbe where mblnr = it_ekbe-belnr and mjahr = it_ekbe-gjahr. * *endif. * *if it_mkpf[] is not initial. select mblnr mjahr zeile matnr lifnr ebeln ebelp erfmg erfme meins shkzg dmbtr lsmng bwart waers from mseg into table it_mseg for all entries in it_ekbe where mblnr = it_ekbe-belnr and mjahr = it_ekbe-gjahr and ebeln = it_ekbe-ebeln and ebelp = it_ekbe-ebelp and bwart in (101, 102, 105, 106).

endif. if it_ekko[] is not initial. select lifnr name1 from lfa1 into table it_lfa1 for all entries in it_ekko where lifnr = it_ekko-lifnr.

endif. if it_ekpo[] is not initial. select bsgru bezei from tbsgt into corresponding fields of table it_tbsgt for all entries in it_ekpo where bsgru = it_ekpo-bsgru and spras = 'EN'. endif.

endform.

"getdata1

*&--------------------------------------------------------------------* *& Form setdata *&--------------------------------------------------------------------* * text

*---------------------------------------------------------------------* form setdata. if po eq 'X'. perform podetails. elseif st eq 'X'. perform stanalysis. elseif gr eq 'X'. perform grdetails. * ELSEIF mir EQ 'X'. * PERFORM mir. endif. endform. "setdata *&---------------------------------------------------------------------* *& Form podetails *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form podetails . loop at it_ekpo into wa_ekpo. * * * * * READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln = wa_ekpo-ebeln. IF sy-subrc EQ 0. wa_po-ebeln = wa_ekpo-ebeln. wa_po-ebelp = wa_ekpo-ebelp. wa_po-matnr = wa_ekpo-matnr. wa_po-menge = wa_ekpo-menge. wa_po-meins = wa_ekpo-meins. wa_po-txz01 = wa_ekpo-txz01. wa_po-effwr = wa_ekpo-effwr. wa_po-matkl = wa_ekpo-matkl. ENDIF.

read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln. if wa_ekko-waers eq 'INR'. if sy-subrc eq 0. wa_po-lifnr = wa_ekko-lifnr. wa_po-bedat = wa_ekko-bedat. wa_po-waers = wa_ekko-waers. endif. read table it_tbsgt into wa_tbsgt with key bsgru = wa_ekpo-bsgru. if sy-subrc eq 0. wa_po-bsgru = wa_tbsgt-bsgru. wa_po-bezei = wa_tbsgt-bezei. endif.

endif.

append wa_po to it_po. endloop.

endform. " podetails *&---------------------------------------------------------------------* *& Form stanalysis *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form stanalysis . data: count type i value 0, amount type p value 0, count_t1 type i value 0, amount_t1 type p value 0, count_t2 type i value 0, amount_t2 type p value 0, count_t3 type i value 0, amount_t3 type p value 0, count_t4 type i value 0, amount_t4 type p value 0, count_t5 type i value 0, amount_t5 type p value 0, count_t6 type i value 0, amount_t6 type p value 0, count_t7 type i value 0, amount_t7 type p value 0, count_t8 type i value 0, amount_t8 type p value 0, count_t9 type i value 0, amount_t9 type p value 0, count_t10 type i value 0, amount_t10 type p value 0, count_t11 type i value 0, amount_t11 type p value 0, count_t12 type i value 0, amount_t12 type p value 0, count_t13 type i value 0, amount_t13 type p value 0, v_count type i value 0, v_amount type p value 0, v_count_t1 type i value 0, v_amount_t1 type p value 0, v_count_t2 type i value 0, v_amount_t2 type p value 0, t_count_po type i value 0, t_amount_po type p value 0.

loop at it_ekpo into wa_ekpo.

count = 1. amount = wa_ekpo-effwr. wa_value-count = count. wa_value-amount = amount.

wa_value-bsgru = wa_ekpo-bsgru.

read table it_tbsgt into wa_tbsgt with key bsgru = wa_ekpo-bsgru.

if sy-subrc eq 0. wa_value-bezei = wa_tbsgt-bezei. endif. collect wa_value into it_value. . endloop.

it_value1 = it_value[]. loop at it_ekpo into wa_ekpo. count = 1. amount = wa_ekpo-effwr. wa_value2-count = count. wa_value2-amount = amount.

collect wa_value2 into it_value2. endloop. loop at it_value2 into wa_value2. t_count_po = wa_value2-count. t_amount_po = wa_value2-amount. endloop.

loop at it_value1 into wa_value1. if wa_value1-bsgru = '106'. count_t1 = wa_value1-count. amount_t1 = wa_value1-amount. elseif wa_value1-bsgru = '101'. count_t2 = wa_value1-count. amount_t2 = wa_value1-amount. elseif wa_value1-bsgru = '100'. count_t3 = wa_value1-count. amount_t3 = wa_value1-amount. elseif wa_value1-bsgru = '104'. count_t4 = wa_value1-count. amount_t4 = wa_value1-amount. elseif wa_value1-bsgru = '103'. count_t5 = wa_value1-count. amount_t5 = wa_value1-amount. elseif wa_value1-bsgru = '108'. count_t6 = wa_value1-count. amount_t6 = wa_value1-amount. elseif wa_value1-bsgru = '102'. count_t7 = wa_value1-count. amount_t7 = wa_value1-amount. elseif wa_value1-bsgru = '105'. count_t8 = wa_value1-count.

amount_t8 = wa_value1-amount. elseif wa_value1-bsgru = '107'. count_t9 = wa_value1-count. amount_t9 = wa_value1-amount. elseif wa_value1-bsgru = '110'. count_t10 = wa_value1-count. amount_t10 = wa_value1-amount. elseif wa_value1-bsgru = '400'. count_t11 = wa_value1-count. amount_t11 = wa_value1-amount. elseif wa_value1-bsgru = '404'. count_t12 = wa_value1-count. amount_t12 = wa_value1-amount. elseif wa_value1-bsgru = '407'. count_t13 = wa_value1-count. amount_t13 = wa_value1-amount. endif. endloop. v_count = count_t12 + count_t11. v_amount = amount_t12 + amount_t11. v_count_t1 = count_t1 + count_t2 + count_t3 + count_t4 + count_t5 + count_t6 + count_t7 + count_t8 + count_t9 + count_t10. v_amount_t1 = amount_t1 + amount_t2 + amount_t3 + amount_t4 + amount_t5 + amount_t6 + amount_t7 + amount_t8 + amount_t9 + amount_t10. v_count_t2 = v_count_t1 + v_count + count_t13. v_amount_t2 = v_amount_t1 + v_amount + amount_t13. per_a = ( v_amount_t1 / t_amount_po ) * 100. per_b = ( v_amount / t_amount_po ) * 100. per_t = ( v_amount_t2 / t_amount_po ) * 100. write : /102 'NO', 120 'VALUE'. skip 1. uline 7(160). write: /7 sy-vline , 10 '(a)', 15 sy-vline, 17 'PROPRIETORY', 100 sy-vline, 101 count_t1, 113 sy-vline,120 amount_t1 , 150 sy-vline. uline /7(160). write: /7 sy-vline , 10 '(b)', 15 sy-vline, 17 'COLLABORATORS OR THEIR RECOMMENDED VENDOR', 100 sy-vline, 101 count_t2, 113 sy-vline,120 amount_t2, 150 sy-vline. uline /7(160). write: /7 sy-vline , 10 '(c)', 15 sy-vline, 17 'CUSTOMER CONTRACT REQUIREMENT',100 sy-vline, 101 count_t3, 113 sy-vline,120 amount_t3, 150 sy-vline. uline /7(160). write: /7 sy-vline , 10 '(d)', 15 sy-vline, 17 'URGENCY',100 sy-vline,101 count_t4, 113 syvline,120 amount_t4, 150 sy-vline. uline /7(160). write: /7 sy-vline , 10 '(e)', 15 sy-vline, 17 'SOURCE STANDARDISATION',100 sy-vline, 101 count_t5, 113 sy-vline,120 amount_t5, 150 sy-vline. uline /7(160).

write: /7 sy-vline , 10 '(f)', 15 sy-vline, 17 'EDUCATIONAL AND DEVELOPMENTAL ORDERS',100 syvline,101 count_t6, 113 sy-vline,120 amount_t6, 150 sy-vline. uline /7(160). write: /7 sy-vline , 10 '(g)', 15 sy-vline, 17 'AVALIABLITY OF PATTERN/ SPECIAL TOOLING, WITH SINGLE VENDOR', 100 sy-vline,101 count_t7, 113 sy-vline,120 amount_t7, 150 sy-vline. uline /7(160). write: /7 sy-vline , 10 '(h)', 15 sy-vline, 17 'VALUE LESS THAN Rs 20,000/-',100 sy-vline,101 count_t8, 113 sy-vline,120 amount_t8, 150 sy-vline. uline /7(160). write: /7 sy-vline , 10 '(i)', 15 sy-vline, 17 'SPARES FROM OEM',100 sy-vline, 101 count_t9, 113 sy-vline,120 amount_t9,150 sy-vline. uline /7(160). write: /7 sy-vline , 8 '(Last)', 15 sy-vline, 17 'SINGLE RESPONSE AGAINST OPEN TENDER',100 syvline, 113 sy-vline,150 sy-vline. uline /7(160). write: /7 sy-vline , 8 '(Last)', 15 sy-vline, 17 'SINGLE RESPONSE AGAINST LIMITED TENDER',100 sy-vline,101 count_t10,113 sy-vline,120 amount_t10, 150 sy-vline. uline /7(160). write: /7 sy-vline , 'TOTAL ',100 sy-vline,101 v_count_t1, 113 sy-vline,120 v_amount_t1, 150 sy-vline. uline /7(160). write: /7 sy-vline , 'AS % AGE OF TOTAL PO COMMITMENTS ',100 sy-vline,113 sy-vline, 120 per_a ,150 sy-vline. uline /7(160). write: /7 sy-vline , 17 'SISTER UNIT PURCHASE',100 sy-vline, 113 sy-vline,150 sy-vline. uline /7(160). *write: /7 sy-vline , 'AS % AGE OF TOTAL PO COMMITMENTS ',100 SY-VLINE,109 SY-VLINE,130 SYVLINE, 166 SY-VLINE. *ULINE /7(160). write: /7 sy-vline , 17 'PURCHASE AGAINST MOUs/ RATE CONTRACTS ENTERED BY CORP.OFFICE/ LEAD AGENCIES',100 sy-vline, 101 v_count, 113 sy-vline, 120 v_amount, 150 sy-vline. uline /7(160). write: /7 sy-vline , 'AS % AGE OF TOTAL PO COMMITMENTS ',100 sy-vline,113 sy-vline, 120 per_b , 150 sy-vline. *ULINE /7(160). write: /7 sy-vline , 17 'SINGLE VENDOR IN PMD/ APPROVED LIST',100 sy-vline, 113 sy-vline,150 sy-vline. uline /7(160). *write: /7 sy-vline , 'AS % AGE OF TOTAL PO COMMITMENTS ',100 SY-VLINE,109 SY-VLINE,130 SYVLINE, 166 SY-VLINE. *ULINE /7(160). write: /7 sy-vline , 17 'OTHERS WHICH IS NOT COVERED IN THE ABOVE',100 sy-vline,101 count_t13, 113 sy-vline,120 amount_t13, 150 sy-vline. uline /7(160). *write: /7 sy-vline , 'AS % AGE OF TOTAL PO COMMITMENTS ',100 SY-VLINE,109 SY-VLINE,130 SYVLINE, 166 SY-VLINE. *ULINE /7(160). write: /7 sy-vline , 'TOTAL ',100 sy-vline,101 v_count_t2 , 113 sy-vline,120 v_amount_t2, 150 sy-vline. uline /7(160). write: /7 sy-vline , 'AS % AGE OF TOTAL PO COMMITMENTS ',100 sy-vline,113 sy-vline,120 per_t, 166 sy-vline. uline /7(160). write: /7 sy-vline , 'TOTAL PO COMMITMENTS ',100 sy-vline,101 t_count_po, 113 sy-vline,120 t_amount_po, 150 sy-vline. uline /7(160). endform. " stanalysis " stanalysis

*&---------------------------------------------------------------------* *& Form grdetails *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form grdetails . loop at it_ekbe into wa_ekbe. wa_gr-ebeln = wa_ekbe-ebeln. wa_gr-ebelp = wa_ekbe-ebelp. wa_gr-mblnr = wa_ekbe-belnr.

read table it_mseg into wa_mseg with key mblnr = wa_ekbe-belnr mjahr = wa_ekbe-gjahr ebeln = wa_ekbe-ebeln ebelp = wa_ekbe-ebelp. *if sy-subrc eq wa_gr-zeile wa_gr-matnr wa_gr-lifnr wa_gr-erfmg wa_gr-erfme wa_gr-meins wa_gr-dmbtr wa_gr-bwart wa_gr-waers wa_gr-lsmng *endif. 0. = wa_mseg-zeile. = wa_mseg-matnr. = wa_mseg-lifnr. = wa_mseg-erfmg. = wa_mseg-erfme. = wa_mseg-meins. = wa_mseg-dmbtr. = wa_mseg-bwart. = wa_mseg-waers. = wa_mseg-lsmng.

read table it_mkpf into wa_mkpf with key mblnr = wa_mseg-mblnr mjahr = wa_mseg-mjahr. if sy-subrc eq 0. wa_gr-budat = wa_mkpf-budat. wa_gr-xblnr = wa_mkpf-xblnr. endif.

read table it_lfa1 into wa_lfa1 with key lifnr = wa_mseg-lifnr. if sy-subrc eq 0. wa_gr-name1 = wa_lfa1-name1. endif. read table it_ekpo into wa_ekpo with key ebeln = wa_ekbe-ebeln ebelp = wa_ekbe-ebelp. if sy-subrc eq 0. wa_gr-txz01 = wa_ekpo-txz01. wa_gr-bsgru = wa_ekpo-bsgru.

endif. read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln. if sy-subrc eq 0. wa_gr-bedat = wa_ekko-bedat. endif. read table it_tbsgt into wa_tbsgt with key bsgru = wa_ekpo-bsgru. if sy-subrc eq 0. wa_gr-bezei = wa_tbsgt-bezei. endif. append wa_gr to it_gr. clear: wa_gr. endloop. *delete it_gr where bsart ne s_bsart. delete it_gr where ebeln eq ' '. delete it_gr where mblnr cp '49*'. delete it_gr where ebeln cp '452*'. sort it_gr by budat mblnr zeile. endform. " grdetails

*&--------------------------------------------------------------------* *& Form mir *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* form mir. loop at it_ekpo wa_po-ebeln = wa_po-ebelp = wa_po-matnr = wa_po-menge = wa_po-meins = wa_po-txz01 = wa_po-effwr = wa_po-matkl = into wa_ekpo. wa_ekpo-ebeln. wa_ekpo-ebelp. wa_ekpo-matnr. wa_ekpo-menge. wa_ekpo-meins. wa_ekpo-txz01. wa_ekpo-effwr. wa_ekpo-matkl.

read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln. if wa_ekko-waers eq 'INR'. if sy-subrc eq 0. wa_po-lifnr = wa_ekko-lifnr. wa_po-bedat = wa_ekko-bedat. wa_po-waers = wa_ekko-waers. endif. read table it_tbsgt into wa_tbsgt with key bsgru = wa_ekpo-bsgru. if sy-subrc eq 0.

wa_po-bsgru = wa_tbsgt-bsgru. wa_po-bezei = wa_tbsgt-bezei. endif. elseif wa_ekko-waers ne 'INR'. if sy-subrc eq 0. wa_po-lifnr = wa_ekko-lifnr. wa_po-bedat = wa_ekko-bedat. wa_po-waers = wa_ekko-waers. endif. read table it_tbsgt into wa_tbsgt with key bsgru = wa_ekpo-bsgru. if sy-subrc eq 0. wa_po-bsgru = wa_tbsgt-bsgru. wa_po-bezei = wa_tbsgt-bezei. endif. endif. append wa_po to it_po.

endloop. delete it_po where matkl eq '26'. delete it_po where ebeln eq '451'. delete it_po where ebeln eq '4502'. * *loop at it_ekbe into wa_ekbe. * *wa_gr-ebeln = wa_ekbe-ebeln. *wa_gr-ebelp = wa_ekbe-ebelp. *wa_gr-mblnr = wa_ekbe-belnr. * * *read table it_mseg into wa_mseg * with key mblnr = wa_ekbe-belnr * mjahr = wa_ekbe-gjahr * ebeln = wa_ekbe-ebeln * ebelp = wa_ekbe-ebelp. * **if sy-subrc eq 0. *wa_gr-zeile = wa_mseg-zeile. *wa_gr-matnr = wa_mseg-matnr. *wa_gr-lifnr = wa_mseg-lifnr. *wa_gr-erfmg = wa_mseg-erfmg. *wa_gr-erfme = wa_mseg-erfme. *wa_gr-meins = wa_mseg-meins. *wa_gr-dmbtr = wa_mseg-dmbtr. *wa_gr-bwart = wa_mseg-bwart. *wa_gr-waers = wa_mseg-waers. *WA_GR-LSMNG = WA_MSEG-LSMNG. **endif. * * *read table it_mkpf into wa_mkpf * with key mblnr = wa_mseg-mblnr

* mjahr = wa_mseg-mjahr. * *if sy-subrc eq 0. *wa_gr-budat = wa_mkpf-budat. *wa_gr-xblnr = wa_mkpf-xblnr. *endif. * * *read table it_lfa1 into wa_lfa1 * with key lifnr = wa_mseg-lifnr. * *if sy-subrc eq 0. *wa_gr-name1 = wa_lfa1-name1. * *endif. * *READ TABLE IT_EKPO INTO WA_EKPO * WITH KEY EBELN = WA_EKBE-EBELN * EBELP = WA_EKBE-EBELP. * *IF SY-SUBRC EQ 0. *WA_GR-TXZ01 = WA_EKPO-TXZ01. *WA_GR-BSGRU = WA_EKPO-BSGRU. *ENDIF. * *READ TABLE IT_EKKO INTO WA_EKKO * WITH KEY EBELN = WA_EKPO-EBELN. * *IF SY-SUBRC EQ 0. *WA_GR-BEDAT = WA_EKKO-BEDAT. *ENDIF. * *read table it_tbsgt into wa_tbsgt * with key bsgru = WA_ekpo-bsgru. * *if sy-subrc eq 0. *WA_GR-BEZEI = WA_TBSGT-BEZEI. *endif. * APPEND wa_gr TO it_gr. * clear: wa_gr. * *endloop. **delete it_gr where bsart ne s_bsart. *delete it_gr where ebeln eq ' '. * delete it_gr where mblnr cp '49*'. * delete it_gr where ebeln cp '452*'. *sort it_gr by budat mblnr zeile. * endform. "mir

*&---------------------------------------------------------------------* *& Form display *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form display .

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

IF st EQ 'X'.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '2'. i_fcat1-fieldname = 'BSGRU'. i_fcat1-tabname = 'IT_VALUE1'. i_fcat1-reptext_ddic = 'OREDER '. APPEND i_fcat1 TO i_fcat1.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '1'. i_fcat1-fieldname = 'BEZEI'. i_fcat1-tabname = 'IT_VALUE1'. i_fcat1-reptext_ddic = 'REASON'. APPEND i_fcat1 TO i_fcat1.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '3'. i_fcat1-fieldname = 'COUNT'. i_fcat1-tabname = 'IT_VALUE1'. i_fcat1-reptext_ddic = 'NUMBER OF PO'. APPEND i_fcat1 TO i_fcat1. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '4'. i_fcat1-fieldname = 'AMOUNT'. i_fcat1-tabname = 'IT_VALUE1'. i_fcat1-reptext_ddic = 'AMOUNT'. APPEND i_fcat1 TO i_fcat1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = repid i_grid_title = 'SINGLE TENDER - ST + RA +RC ' it_fieldcat = i_fcat1[] i_default = 'X' it_events = t_event TABLES t_outtab = it_value1 EXCEPTIONS program_error = 1 OTHERS = 2.

if po eq 'X'. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '1'. i_fcat1-fieldname = 'EBELN'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'PO NUMBER'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '2'. i_fcat1-fieldname = 'EBELP'.

i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'PO SLNO'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '3'. i_fcat1-fieldname = 'BEDAT'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'PO DATE'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '4'. i_fcat1-fieldname = 'MATKL'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'MATERIAL GROUP'. append i_fcat1 to i_fcat. * i_fcat1-row_pos = '1'. i_fcat1-col_pos = '5'. i_fcat1-fieldname = 'MATNR'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'MATERIAL CODE'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '6'. i_fcat1-fieldname = 'EFFWR'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'AMOUNT'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '7'. i_fcat1-fieldname = 'WAERS'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'CURRENCY KEY'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '8'. i_fcat1-fieldname = 'LIFNR'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'VENDOR NUMBER'. append i_fcat1 to i_fcat.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '9'. i_fcat1-fieldname = 'BSGRU'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'REA. ORDERING'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '10'. i_fcat1-fieldname = 'BEZEI'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'REASON FOR ORDERING TEXT'. append i_fcat1 to i_fcat.

call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = repid i_grid_title = 'MONTHLY MIR REPORT - PO''s Details' it_fieldcat = i_fcat i_default = 'X' it_events = t_event tables t_outtab = it_po exceptions program_error = 1 others = 2. elseif gr eq 'X'.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '1'. i_fcat1-fieldname = 'EBELN'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'PO NUMBER'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '2'. i_fcat1-fieldname = 'EBELP'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'PO SLNO'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '3'. i_fcat1-fieldname = 'BEDAT'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'PO DATE'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '4'. i_fcat1-fieldname = 'MBLNR'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'GR NUMBER'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '5'. i_fcat1-fieldname = 'ZEILE'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'GR SLNO'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '6'. i_fcat1-fieldname = 'BUDAT'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'GR DATE'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'.

i_fcat1-col_pos = '7'. i_fcat1-fieldname = 'MATNR'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'MATERIAL CODE'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '8'. i_fcat1-fieldname = 'TXZ01'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'MATERIAL DESCRIPTION'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '9'. i_fcat1-fieldname = 'ERFMG'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'QUANTITY ORDERED'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '10'. i_fcat1-fieldname = 'ERFME'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'UoM'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '11'. i_fcat1-fieldname = 'LSMNG'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'QUANTITY RECEIVED'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '12'. i_fcat1-fieldname = 'MEINS'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'UoM'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '13'. i_fcat1-fieldname = 'DMBTR'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'AMOUNT'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '14'. i_fcat1-fieldname = 'WAERS'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'AMOUNT'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '15'. i_fcat1-fieldname = 'XBLNR'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'DC NUMBER & DATE'. append i_fcat1 to i_fcat.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '16'. i_fcat1-fieldname = 'BSGRU'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'REA. ORDERING'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '17'. i_fcat1-fieldname = 'BEZEI'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'REASON FOR ORDERING TEXT'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '18'. i_fcat1-fieldname = 'BWART'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'MOVEMENT TYPE'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '19'. i_fcat1-fieldname = 'LIFNR'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'VENDOR NUMBER'. append i_fcat1 to i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '20'. i_fcat1-fieldname = 'NAME1'. i_fcat1-tabname = 'IT_GR'. i_fcat1-reptext_ddic = 'VENDOR NAME'. append i_fcat1 to i_fcat.

call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = repid i_grid_title = 'MONTHLY MIR REPORT - GR Details' it_fieldcat = i_fcat i_default = 'X' it_events = t_event tables t_outtab = it_gr exceptions program_error = 1 others = 2. * * * * * * * * * * * ELSEIF mir EQ 'X'.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '1'. i_fcat1-fieldname = 'EBELN'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'PO NUMBER'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

i_fcat1-col_pos = '2'. i_fcat1-fieldname = 'EBELP'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'PO SLNO'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '3'. i_fcat1-fieldname = 'BEDAT'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'PO DATE'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '4'. i_fcat1-fieldname = 'MATKL'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'MATERIAL GROUP'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '5'. i_fcat1-fieldname = 'MATNR'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'MATERIAL CODE'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '6'. i_fcat1-fieldname = 'EFFWR'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'AMOUNT'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '7'. i_fcat1-fieldname = 'WAERS'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'CURRENCY KEY'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '8'. i_fcat1-fieldname = 'LIFNR'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'VENDOR NUMBER'. APPEND i_fcat1 TO i_fcat.

i_fcat1-row_pos = '1'. i_fcat1-col_pos = '9'. i_fcat1-fieldname = 'BSGRU'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'REA. ORDERING'. APPEND i_fcat1 TO i_fcat. i_fcat1-row_pos = '1'. i_fcat1-col_pos = '10'. i_fcat1-fieldname = 'BEZEI'. i_fcat1-tabname = 'IT_PO'. i_fcat1-reptext_ddic = 'REASON FOR ORDERING TEXT'.

* * * * * * * * * * * * * * * * * *

APPEND i_fcat1 TO i_fcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = repid i_grid_title = 'MONTHLY MIR REPORT - PO''s Details' it_fieldcat = i_fcat i_default = 'X' it_events = t_event TABLES t_outtab = it_po EXCEPTIONS program_error = 1 OTHERS = 2.

endif. endform.

" display

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Vender rating


*&---------------------------------------------------------------------* *& Report ZMM_VENDOR_RAT2 * *& TITLE : VENDOR RATING REPOR *& * *&---------------------------------------------------------------------* *& REQUEST NO : DEVK907310 * *& DEVELOPED BY : MOHAN *&---------------------------------------------------------------------* report zmm_vendor_rat2 no standard page heading line-size 520.

tables: ekko, ekpo, lfa1,eket,mseg,qals,qave, t023t. type-pools slis. selection-screen : begin of block a with frame title text-000 . select-options : s_ekorg for ekko-ekorg no-extension obligatory, s_lifnr for ekko-lifnr no-extension obligatory no intervals. parameters:p_date like sy-datum default sy-datum.

selection-screen: end of block a. selection-screen : begin of block b with frame title text-001. select-options : s_matnr for ekpo-matnr no-extension modif id man, s_matkl for ekpo-matkl no-extension obligatory modif id mal. parameters: p_matnr radiobutton group sel default 'X' user-command b, p_matkl radiobutton group sel. selection-screen : end of block b. types: begin of ty_ekko, ebeln type ekko-ebeln,

bukrs type ekko-bukrs, bedat type ekko-bedat, lifnr type ekko-lifnr, ekorg type ekko-ekorg, ekgrp type ekko-ekgrp, end of ty_ekko.

types: begin of ty_ekpo, ebeln type ekpo-ebeln, ebelp type ekpo-ebelp, matnr type ekpo-matnr, txz01 type ekpo-txz01, werks type ekpo-werks, matkl type ekpo-matkl, menge type ekpo-menge, meins type ekpo-meins, ktmng type ekpo-ktmng, aedat type ekpo-aedat, end of ty_ekpo. types: begin of ty_lfa1, lifnr type lfa1-lifnr, name1 type lfa1-name1, end of ty_lfa1. types: begin of ty_ekbe, ebeln type ekbe-ebeln, ebelp type ekbe-ebelp, belnr type ekbe-belnr, gjahr type ekbe-gjahr, buzei type ekbe-buzei, bpmng type ekbe-bpmng, menge type ekbe-menge, end of ty_ekbe.

types: begin of ty_op, lifnr type lfa1-lifnr, name1 type lfa1-name1, matnr type ekpo-matnr, txz01 type ekpo-txz01, matkl type ekpo-matkl, wgbez type t023t-wgbez, lmengeist type qals-lmengeist, lmenge01 type qals-lmenge01, qratg type p decimals 3, sratg type p decimals 3, spr type p decimals 3, grade(2) type c, end of ty_op. types: begin ebeln ebelp etenr eindt bedat lpein menge of ty_eket, type eket-ebeln, type eket-ebelp, type eket-etenr, type eket-eindt, type eket-bedat, type eket-lpein, type eket-menge,

wemng mng02 dat01 wadat

type type type type

eket-wemng, eket-mng02, eket-dat01, eket-wadat,

end of ty_eket.

types: begin of ty_mseg, mblnr type mseg-mblnr, mjahr type mseg-mjahr, ebeln type mseg-ebeln, ebelp type mseg-ebelp, zeile type mseg-zeile, bwart type mseg-bwart, matnr type mseg-matnr, werks type mseg-werks, shkzg type mseg-shkzg, erfmg type mseg-erfmg, erfme type mseg-erfme, bpmng type mseg-bpmng, bprme type mseg-bprme, bstmg type mseg-bstmg, end of ty_mseg. types: begin of ty_mkpf, mblnr type mkpf-mblnr, mjahr type mkpf-mjahr, budat type mkpf-budat, end of ty_mkpf.

types: begin of ty_qals, prueflos type qals-prueflos, zeile type qals-zeile, werk type qals-werk, matnr type qals-matnr, ebeln type qals-ebeln, ebelp type qals-ebelp, etenr type qals-etenr, mblnr type qals-mblnr, mjahr type qals-mjahr, lmengeist type qals-lmengeist, lmenge01 type qals-lmenge01, lmengepr type qals-lmengepr, vcode type qave-vcode, vbewertung type qave-vbewertung, end of ty_qals. types: begin of ty_t023t, matkl type t023t-matkl, wgbez type t023t-wgbez, spras type t023t-spras, end of ty_t023t.

types : begin matkl matnr mblnr

of ty_gr1, type ekpo-matkl, type ekpo-matnr, type mseg-mblnr,

mjahr type mseg-mjahr, bwart type mseg-bwart, zeile type mseg-zeile, budat type mkpf-budat, erfmg type mseg-erfmg, erfme type mseg-erfme, ebeln type ekpo-ebeln, ebelp type ekpo-ebelp, bedat type ekko-bedat, lmenge01 type qals-lmenge01, lmengeist type qals-lmengeist, lmengepr type qals-lmengepr, dr type p decimals 3, qr type p decimals 3,

end of ty_gr1.

types: begin of ty_po1, ebeln type eket-ebeln, ebelp type eket-ebelp, etenr type eket-etenr, matnr type ekpo-matnr, txz01 type ekpo-txz01, matkl type ekpo-matkl, wgbez type t023t-wgbez, eindt type eket-eindt, menge type eket-menge, meins type ekpo-meins, bedat type eket-bedat, name1 type lfa1-name1, lifnr type ekko-lifnr,

end of ty_po1. types: begin of ty_disp, lifnr type ekko-lifnr, name1 type lfa1-name1, matnr type ekpo-matnr, matkl type ekpo-matkl, wgbez type t023t-wgbez, txz01 type ekpo-txz01, dr type p decimals 2, qr type p decimals 2, sr type p decimals 2, spr type p decimals 2, grade(2) type c, end of ty_disp. ************************ data: it_disp_temp type standard table of ty_disp, wa_disp_temp type ty_disp. types: begin of temp12, lifnr type lifnr, matkl type matkl, dr type p decimals 2, qr type p decimals 2, sr type p decimals 2, spr type p decimals 2, end of temp12.

data: it_disp_temp1 type sorted table of temp12 with non-unique key lifnr matkl, wa_disp_temp1 type temp12, occ type i, it_disp_grp type table of ty_disp," WITH NON-UNIQUE KEY matnr txz01, wa_disp_grp type ty_disp. data: it_disp_temp2 type table of temp12, wa_disp_temp2 type temp12. ***********************

data: * * *

it_opt type standard table of ty_opt, wa_opt type ty_opt, it_disp type table of ty_disp," wa_disp type ty_disp, WITH NON-UNIQUE KEY matnr txz01,

it_dis type sorted table of ty_disp with unique key matnr, wa_dis type ty_disp, it_gr1 type standard table of ty_gr1, wa_gr1 type ty_gr1,

it_op1 type table of ty_op, wa_op1 type ty_op, it_po1 type standard table of ty_po1, wa_po1 type ty_po1, it_ekko type standard table of ty_ekko, wa_ekko type ty_ekko, it_ekpo type standard table of ty_ekpo, wa_ekpo type ty_ekpo, it_lfa1 type standard table of ty_lfa1, wa_lfa1 type ty_lfa1, it_ekbe type standard table of ty_ekbe, wa_ekbe type ty_ekbe, it_eket type standard table of ty_eket, wa_eket type ty_eket, it_mseg type standard table of ty_mseg, wa_mseg type ty_mseg, it_mkpf type standard table of ty_mkpf, wa_mkpf type ty_mkpf, it_t023t type standard table of ty_t023t, wa_t023t type ty_t023t, it_disp1 type standard table of ty_disp, wa_disp1 type ty_disp,

it_qals type standard table of ty_qals, wa_qals type ty_qals.

data: fieldcat type slis_t_fieldcat_alv with header line. data: c_index type sy-index. at selection-screen output. if p_matkl eq 'X'. refresh s_matnr. loop at screen. check screen-group1 = 'MAN'. screen-input = '0'. modify screen. endloop.

endif. if p_matnr eq 'X'. refresh s_matkl. loop at screen. check screen-group1 = 'MAL'. screen-input = '0'. modify screen. endloop. endif.

start-of-selection. perform getdata. perform setdata. perform qr_rating. perform dr_rating. perform display.

*&--------------------------------------------------------------------* *& Form getdata *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* form getdata. data: year(4) type c, month(2) type c, day(2) type c, date type d, count type i value '1', c_tfill type sy-tfill, l_date type d, lin type i, n type i. year = p_date+0(4). month = p_date+4(2).

day = p_date+6(2). if month <= 3. day = '01'. month = '04'. year = year - 2. concatenate year month day into l_date. elseif month > 3. day = '01'. month = '04'. year = year - 1. concatenate year month day into l_date. endif. c_tfill = sy-tfill.

select ebeln bukrs bedat lifnr ekorg ekgrp bstyp from ekko into corresponding fields of table it_ekko l_date and p_date and lifnr in s_lifnr and ekorg in s_ekorg and bstyp = 'F '.

where bedat between

describe table it_ekko lines lin. if lin < 3. n = 3. n = n - lin. select ebeln bukrs bedat lifnr ekorg ekgrp bstyp from ekko into corresponding fields of table it_ekko up to n rows where lifnr in s_lifnr and ekorg in s_ekorg and bstyp = 'F' and bedat le sy-datum order by bedat descending.

endif. if p_matnr eq 'X'.

if it_ekko[] is not initial.

select ebeln

ebelp etenr eindt bedat menge wemng from eket into corresponding fields of table it_eket for all entries in it_ekko where ebeln = it_ekko-ebeln. select ebeln ebelp matnr txz01 matkl werks menge meins ktmng from ekpo into corresponding fields of table it_ekpo for all entries in it_eket where ebeln = it_eket-ebeln and ebelp = it_eket-ebelp and matnr in s_matnr.

endif. else. if it_ekko[] is not initial. select ebeln ebelp etenr eindt bedat menge wemng from eket into corresponding fields of table it_eket for all entries in it_ekko where ebeln = it_ekko-ebeln. select ebeln ebelp matnr txz01 matkl werks menge meins ktmng from ekpo into corresponding fields of table it_ekpo for all entries in it_eket where ebeln = it_eket-ebeln and ebelp = it_eket-ebelp and matkl in s_matkl.

endif. endif. if it_ekpo[] is not initial. select lifnr name1 from lfa1 into corresponding fields of table it_lfa1

for all entries in it_ekko where lifnr = it_ekko-lifnr. endif. if sy-subrc eq 0.

select matkl wgbez spras from t023t into corresponding fields of table it_t023t for all entries in it_ekpo where matkl = it_ekpo-matkl and spras = 'EN'. endif. if sy-subrc = 0. select ebeln ebelp belnr gjahr buzei matnr from ekbe into corresponding fields of table it_ekbe for all entries in it_ekpo where ebeln = it_ekpo-ebeln and ebelp = it_ekpo-ebelp and bewtp = 'E'. endif. if it_ekbe[] is not initial. select mblnr mjahr zeile erfmg erfme ebeln ebelp matnr werks bwart from mseg into corresponding fields of table it_mseg for all entries in it_ekbe where mblnr = it_ekbe-belnr and mjahr = it_ekbe-gjahr and ebeln = it_ekbe-ebeln and ebelp = it_ekbe-ebelp and mblnr like '5%' and ( bwart = '101' or bwart = '102'). endif. if sy-subrc eq 0. select mblnr mjahr budat from mkpf into corresponding fields of table it_mkpf for all entries in it_mseg where mblnr = it_mseg-mblnr and mjahr = it_mseg-mjahr. endif.

if it_mseg[] is not initial. select ebeln ebelp etenr zeile prueflos mblnr mjahr matnr werk bwart lmengeist lmenge01 lmengepr from qals into corresponding fields of table it_qals for all entries in it_mseg where mblnr = it_mseg-mblnr and mjahr = it_mseg-mjahr and bwart = '101'. endif. endform. "getdata

*&--------------------------------------------------------------------* *& Form setdata *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* form setdata. data: pre_dat like sy-datum, curr_dat like sy-datum. loop at it_mseg into wa_mseg.

wa_gr1-mblnr = wa_gr1-mjahr = wa_gr1-zeile = wa_gr1-bwart = wa_gr1-ebeln = wa_gr1-ebelp = wa_gr1-erfmg = wa_gr1-erfme = clear wa_mkpf.

wa_mseg-mblnr. wa_mseg-mjahr. wa_mseg-zeile. wa_mseg-bwart. wa_mseg-ebeln. wa_mseg-ebelp. wa_mseg-erfmg. wa_mseg-erfme.

if wa_gr1-bwart = '102'. wa_gr1-erfmg = wa_gr1-erfmg * ( -1 ). endif. read table it_mkpf into wa_mkpf with key mblnr = wa_mseg-mblnr mjahr = wa_mseg-mjahr. if sy-subrc eq 0.

wa_gr1-budat = wa_mkpf-budat. endif.

clear wa_qals. read table it_qals into wa_qals with key ebeln = wa_gr1-ebeln ebelp = wa_gr1-ebelp mblnr = wa_gr1-mblnr mjahr = wa_gr1-mjahr zeile = wa_gr1-zeile. if sy-subrc eq 0. move: wa_qals-prueflos to wa_gr1-prueflos, wa_qals-matnr to wa_gr1-matnr, wa_qals-lmengeist to wa_gr1-lmengeist, wa_qals-lmenge01 to wa_gr1-lmenge01. endif. read table it_ekpo into wa_ekpo with key ebeln = wa_gr1-ebeln ebelp = wa_gr1-ebelp. if sy-subrc eq 0. wa_-matnr = wa_ekpo-matnr. wa_opt-txz01 = wa_ekpo-txz01. wa_gr1-matkl = wa_ekpo-matkl. wa_opt-menge = wa_ekpo-menge. wa_opt-meins = wa_ekpo-meins. endif. read table it_ekko into wa_ekko with key ebeln = wa_gr1-ebeln.

* * * *

if sy-subrc eq 0. wa_gr1-bedat = wa_ekko-bedat. endif. append wa_gr1 to it_gr1. endloop. .

loop at it_eket into wa_eket. wa_po1-ebeln = wa_eket-ebeln. wa_po1-ebelp = wa_eket-ebelp. wa_po1-etenr = wa_eket-etenr. wa_po1-bedat = wa_eket-bedat. wa_po1-eindt = wa_eket-eindt. wa_po1-menge = wa_eket-menge. read table it_ekpo into wa_ekpo with key ebeln = wa_po1-ebeln ebelp = wa_po1-ebelp. if sy-subrc eq 0.

* *

wa_po1-matnr = wa_ekpo-matnr. wa_po1-txz01 = wa_ekpo-txz01. wa_po1-matkl = wa_ekpo-matkl. wa_po1-menge = wa_ekpo-menge. wa_po1-meins = wa_ekpo-meins. endif. read table it_t023t into wa_t023t with key matkl = wa_ekpo-matkl. if sy-subrc eq 0. wa_po1-wgbez = wa_t023t-wgbez. endif. read table it_ekko into wa_ekko with key ebeln = wa_eket-ebeln. if sy-subrc eq 0. wa_po1-lifnr = wa_ekko-lifnr. wa_po1-bedat = wa_ekko-bedat.

endif.

read table it_lfa1 into wa_lfa1 with key lifnr = wa_po1-lifnr. if sy-subrc eq 0. wa_po1-name1 = wa_lfa1-name1. endif. append wa_po1 to it_po1. endloop.

endform.

"setdata

*&--------------------------------------------------------------------* *& Form dr_rating *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* form dr_rating. data: del_qty like ekpo-menge, del_dt like eket-bedat, dely_days type i, sch_days type i, dr_var type p decimals 3, qr_var type p decimals 3, dr_va1 type p decimals 3, qr_va1 type p decimals 3, dr_sum type p decimals 3, qty_sum type p decimals 3, qr type p decimals 3, qr_sum type p decimals 3,

spr type p decimals 3, grade(2) type c.

loop at it_po1 into wa_po1.

" WHERE matnr in s_matnr OR matkl IN s_matkl.

** * * * * * **

loop at it_po1 into wa_po1 where ebeln = wa_po1-ebeln. at end of ebeln. del_dt = wa_po1-bedat. endat. endloop.

* ************************ del_qty = 0. if wa_po1-etenr = 1. * if wa_po1-etenr = wa_po1-etenr. del_dt = wa_po1-bedat. endif. ***************************** *clear wa_gr1. loop at it_gr1 into wa_gr1 where ebeln = wa_po1-ebeln and ebelp = wa_po1-ebelp and budat >= del_dt. del_qty = del_qty + wa_gr1-erfmg. if del_qty >= wa_po1-menge. del_dt = wa_gr1-budat. dely_days = del_dt - wa_po1-eindt. sch_days = wa_po1-eindt - wa_gr1-bedat. * if dely_days > sch_days. wa_gr1-dr = 1. else. if sch_days <= 0. sch_days = 0. wa_gr1-dr = 0. endif. if dely_days <= 0. dely_days = 0. wa_gr1-dr = 0. endif. if sch_days <> 0 and dely_days <> 0. wa_gr1-dr = dely_days / sch_days. endif. endif.

modify it_gr1 from wa_gr1.

exit. endif. endloop. endloop. delete it_gr1 where bwart = '102'. data: it_temp type table of ty_gr1 wa_temp type ty_gr1. it_temp[] = it_gr1[]. ,

sort it_gr1 by matnr budat descending . clear wa_gr1. read table it_gr1 into wa_gr1 index 1. dr_var = wa_gr1-dr.

data: temp type p decimals 3. loop at it_gr1 into wa_gr1. * IF p_matnr EQ 'X'. on change of wa_gr1-matnr. if wa_gr1-dr is initial. wa_gr1-dr = '0.00'. temp = wa_gr1-dr. modify it_gr1 from wa_gr1 transporting dr. else. dr_var = wa_gr1-dr. wa_gr1-dr = dr_var. temp = wa_gr1-dr. modify it_gr1 from wa_gr1 transporting dr. endif. endon. if wa_gr1-dr is initial. dr_var = wa_gr1-dr. wa_gr1-dr = temp. temp = wa_gr1-dr. modify it_gr1 from wa_gr1 transporting dr. else. dr_var = wa_gr1-dr. wa_gr1-dr = dr_var. temp = wa_gr1-dr. modify it_gr1 from wa_gr1 transporting dr. endif. * * * * ELSE.

* * * * * * * * * * * *

IF wa_gr1-dr IS INITIAL. wa_gr1-dr = dr_var. ELSE. dr_var = wa_gr1-dr. ENDIF.

wa_gr1-dr = dr_var. MODIFY it_gr1 FROM wa_gr1 TRANSPORTING dr. ENDIF. endloop.

if p_matnr eq 'X' or p_matkl eq 'X'. sort it_gr1 by matnr.

loop at it_gr1 into wa_gr1. dr_sum = wa_gr1-erfmg * wa_gr1-dr + dr_sum. qty_sum = wa_gr1-erfmg + qty_sum. qr_sum = wa_gr1-erfmg * wa_gr1-qr + qr_sum. read table it_po1 into wa_po1 with key ebeln = wa_gr1-ebeln ebelp = wa_gr1-ebelp.

if sy-subrc eq 0. wa_disp-lifnr = wa_disp-name1 = wa_disp-matnr = wa_disp-matkl = wa_disp-txz01 = wa_disp-wgbez =

wa_po1-lifnr. wa_po1-name1. wa_po1-matnr. wa_po1-matkl. wa_po1-txz01. wa_po1-wgbez.

endif.

at end of matnr . dr_var = dr_sum / qty_sum. qr_var = qr_sum / qty_sum. if dr_var <= 0. dr_var = 1. endif. dr_va1 = ( 1 - dr_var ) * 30. if dr_va1 > 0. wa_disp-dr = dr_va1. else. wa_disp-dr = 0. endif. qr_va1 = qr_var * 60. wa_disp-qr = qr_va1. wa_disp-sr = 10.

spr = wa_disp-qr + wa_disp-dr + wa_disp-sr. move spr to wa_disp-spr.

if wa_disp-spr > 95. grade = 'A1'. move grade to wa_disp-grade. elseif wa_disp-spr <= 95 and wa_disp-spr > 90. grade = 'A'. move grade to wa_disp-grade. elseif wa_disp-spr <= 90 and wa_disp-spr > 75. grade = 'B'. move grade to wa_disp-grade. elseif wa_disp-spr <= 75 and wa_disp-spr >= 60. grade = 'C'. move grade to wa_disp-grade. elseif wa_disp-spr < 60. grade = 'D'. move grade to wa_disp-grade. endif. append wa_disp to it_disp. dr_sum = 0. qty_sum = 0. qr_sum = 0. clear: wa_disp, wa_gr1. endat. endloop.

else. * loop at it_gr1 into wa_gr1 where matkl = s_matkl. sort it_gr1 by matkl. clear :dr_sum , qty_sum .

endif. it_disp1[] = it_disp[].

if p_matkl = 'X'. it_disp_temp[] = it_disp1[]. sort it_disp_temp by matkl. delete adjacent duplicates from it_disp_temp comparing matkl.

loop at it_disp_temp into wa_disp_temp.

loop at it_disp1 into wa_disp1 where matkl = wa_disp_temp-matkl. wa_disp_temp1-lifnr = wa_disp1-lifnr. wa_disp_temp1-matkl = wa_disp1-matkl. wa_disp_temp1-dr = wa_disp1-dr. wa_disp_temp1-qr = wa_disp1-qr.

wa_disp_temp1-sr = wa_disp1-sr. wa_disp_temp1-spr = wa_disp1-spr. append wa_disp_temp2 to it_disp_temp2. collect wa_disp_temp1 into it_disp_temp1. endloop. describe table it_disp_temp2 lines occ. read table it_disp_temp1 into wa_disp_temp1 index 1. wa_disp_grp-lifnr = wa_disp_temp1-lifnr. wa_disp_grp-matkl = wa_disp_temp1-matkl. wa_disp_grp-dr = wa_disp_temp1-dr / occ. wa_disp_grp-qr = wa_disp_temp1-qr / occ. wa_disp_grp-sr = wa_disp_temp1-sr / occ. wa_disp_grp-spr = wa_disp_temp1-spr / occ. read table it_disp1 into wa_disp1 with key lifnr = wa_disp_grp-lifnr matkl = wa_disp_grp-matkl. wa_disp_grp-name1 = wa_disp1-name1. wa_disp_grp-wgbez = wa_disp1-wgbez. append wa_disp_grp to it_disp_grp. clear: wa_disp_grp,wa_disp_temp1,occ,wa_disp1. refresh: it_disp_temp2,it_disp_temp1. endloop.

loop at it_disp_grp into wa_disp_grp. if wa_disp_grp-spr > 95. grade = 'A1'. move grade to wa_disp_grp-grade. elseif wa_disp_grp-spr <= 95 and wa_disp_grp-spr > 90. grade = 'A'. move grade to wa_disp_grp-grade. elseif wa_disp_grp-spr <= 90 and wa_disp_grp-spr > 75. grade = 'B'. move grade to wa_disp_grp-grade. elseif wa_disp_grp-spr <= 75 and wa_disp_grp-spr >= 60. grade = 'C'. move grade to wa_disp_grp-grade. elseif wa_disp_grp-spr < 60. grade = 'D'. move grade to wa_disp_grp-grade. endif. modify it_disp_grp from wa_disp_grp. endloop. endif.

*endif. endform.

"dr_rating

*&--------------------------------------------------------------------* *& Form qr_rating *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* form qr_rating.

data: qr type p decimals 3, spr type i, grade(2) type c.

data: acc_qua type p value 0, insp_qua type p value 0.

if p_matnr eq 'X'. loop at it_gr1 into wa_gr1. acc_qua = wa_gr1-lmenge01. insp_qua = wa_gr1-lmengeist. qr = acc_qua / insp_qua. wa_gr1-qr = qr. modify it_gr1 from wa_gr1 transporting qr. endloop. else.

loop at it_gr1 into wa_gr1. "where matkl in s_matkl. acc_qua = wa_gr1-lmenge01. insp_qua = wa_gr1-lmengeist. qr = acc_qua / insp_qua. wa_gr1-qr = qr. modify it_gr1 from wa_gr1 transporting qr. endloop.

endif. sort it_gr1 by endform. ebeln budat. "qr_rating

*---------------------------------------------------------------------* form display.

if p_matnr eq 'X'. fieldcat-col_pos = 1. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'LIFNR'. fieldcat-seltext_l = 'VENDOR CODE'. append fieldcat. fieldcat-col_pos = 2. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'NAME1'. fieldcat-seltext_l = 'VENDOR NAME'. append fieldcat.

fieldcat-col_pos = 3. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'MATNR'. fieldcat-seltext_l = 'MATERIAL CODE'. append fieldcat.

fieldcat-col_pos = 4. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'TXZ01'. fieldcat-seltext_l = 'MATERIAL DESCRIPTION'. append fieldcat. fieldcat-col_pos = 5. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'QR'. fieldcat-seltext_l = 'QUALITY RATING'. append fieldcat.

fieldcat-col_pos = 6. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'DR'. fieldcat-seltext_l = 'DELIVERY RATING'. append fieldcat. fieldcat-col_pos = 7. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'SR'. fieldcat-seltext_l = 'SERVICE RATING'. append fieldcat.

fieldcat-col_pos = 8. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'SPR'. fieldcat-seltext_l = 'SPR'. append fieldcat.

fieldcat-col_pos = 9. fieldcat-tabname = 'IT_DISP1'. fieldcat-fieldname = 'GRADE'.

fieldcat-seltext_l = 'GRADE'. append fieldcat.

call function 'REUSE_ALV_GRID_DISPLAY' exporting it_fieldcat = fieldcat[] tables t_outtab = it_disp1[].

elseif p_matkl eq 'X'. * IT_DISP_GR1[] = IT_DISP_GRP[]. fieldcat-col_pos = 1. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'LIFNR'. fieldcat-seltext_l = 'VENDOR CODE'. append fieldcat. fieldcat-col_pos = 2. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'NAME1'. fieldcat-seltext_l = 'VENDOR NAME'. append fieldcat.

fieldcat-col_pos = 3. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'MATKL'. fieldcat-seltext_l = 'MATERIAL GROUP'. append fieldcat.

fieldcat-col_pos = 4. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'WGBEZ'. fieldcat-seltext_l = 'MATERIAL GROUP DESCRIPTION'. append fieldcat. fieldcat-col_pos = 5. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'QR'. fieldcat-seltext_l = 'QUALITY RATING'. append fieldcat.

fieldcat-col_pos = 6. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'DR'. fieldcat-seltext_l = 'DELIVERY RATING'. append fieldcat. fieldcat-col_pos = 7. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'SR'.

fieldcat-seltext_l = 'SERVICE RATING'. append fieldcat.

fieldcat-col_pos = 8. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'SPR'. fieldcat-seltext_l = 'SPR'. append fieldcat.

fieldcat-col_pos = 9. fieldcat-tabname = 'IT_DISP_GRP'. fieldcat-fieldname = 'GRADE'. fieldcat-seltext_l = 'GRADE'. append fieldcat.

call function 'REUSE_ALV_GRID_DISPLAY' exporting it_fieldcat = fieldcat[] tables t_outtab = it_disp_grp. endif. endform.

"display

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Contract conclude


*&---------------------------------------------------------------------* *& Report ZCONTRACT *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* report zcontract.

type-pools: slis. data : it_fieldcat type slis_t_fieldcat_alv, wa_fieldcat type slis_fieldcat_alv. types: begin of typ_eket, ebeln type ebeln, ebelp type ebelp, banfn type banfn, bnfpo type bnfpo, bedat type bedat, eindt type eindt,

end of typ_eket. types: begin of typ_temp_eket, ebeln type ebeln, ebelp type ebelp, bedat type bedat, banfn type banfn, bnfpo type bnfpo, eindt type bedat, end of typ_temp_eket. types: begin of typ_ekko, ebeln type ebeln, lifnr type lifnr, bedat type bedat, angdt type angdt, end of typ_ekko. types: begin of typ_ekpo, ebeln type ebeln, ebelp type ebelp, txz01 type txz01, end of typ_ekpo. types: begin of typ_ekpo_t, ebeln type ebeln, ebelp type ebelp, bsgru type bsgru, netwr type netwr, txz01 type txz01, end of typ_ekpo_t. types: begin of typ_lfa1, lifnr type lifnr, name1 type name1, end of typ_lfa1. types: begin of typ_lfa11, lifnr type lifnr, name1 type name1, end of typ_lfa11.

types: begin of typ_tbsgt, bsgru type bsgru, bezei type bezei40, end of typ_tbsgt. types: begin of typ_temp, ebeln(20) type c, ebelp type ebelp, banfn type banfn, bnfpo type bnfpo, count type i, end of typ_temp. types: begin of typ_vendor, ebeln type ebeln, lifnr type lifnr, end of typ_vendor.

types: begin of typ_price, ebeln type ebeln, ebelp type ebelp, netwr type netwr, agmem type agmem, end of typ_price. types: begin of typ_rfq, ebeln type ebeln, ebelp type ebelp, bedat type bedat, banfn type banfn, bnfpo type bnfpo, netwr type netwr, angdt type angdt, eindt type eindt, lifnr type lifnr, name1 type name1, agmem type agmem, end of typ_rfq. types: begin of typ_status, ebeln type c length 20, ebelp type ebelp, banfn type banfn, bnfpo type bnfpo, angdt type angdt, eindt type eindt, bedat type bedat, accept type c length 300, reject type c length 300, count type i, end of typ_status. types: begin of typ_po, ebeln type ebeln, ebelp type ebelp, lifnr type lifnr, name1 type name1, netwr type netwr, angdt type angdt, bedat type bedat, bsgru type c length 3, txz01 type txz01, banfn type banfn, bnfpo type bnfpo, agmem type agmem, eindt type eindt, end of typ_po. types: begin of typ_output, rfqno(20) type c, txz01 type txz01, ebeln type ebeln, lifnr type lifnr, name1 type name1, accept type c length 300, reject type c length 300, angdt type angdt, bedat type bedat, eindt type eindt,

reason(3) type c, rfqdt type bedat, netwr type netwr, least(3) type c, count type i, end of typ_output.

data: it_eket type table of typ_eket, it_temp_eket type table of typ_temp_eket, it_ekko type table of typ_ekko, it_ekpo type table of typ_ekpo, it_lfa1 type table of typ_lfa1, it_lfa11 type table of typ_lfa11, it_tbsgt type table of typ_tbsgt, it_ekpo_t type table of typ_ekpo_t, it_temp type table of typ_temp, it_price type table of typ_price, it_rfq type table of typ_rfq, it_status type table of typ_status, it_output type table of typ_output, it_vendor type table of typ_vendor, it_po type table of typ_po, wa_vendor type typ_vendor, wa_po type typ_po, wa_output type typ_output, wa_status type typ_status, wa_rfq type typ_rfq, wa_price type typ_price, wa_temp type typ_temp, wa_ekpo_t type typ_ekpo_t, wa_eket type typ_eket, wa_temp_eket type typ_temp_eket, wa_ekko type typ_ekko, wa_ekpo type typ_ekpo, wa_lfa1 type typ_lfa1, wa_lfa11 type typ_lfa11, wa_tbsgt type typ_tbsgt, temp(10) type n, temp1(10) type n, tebeln type ebeln, tebeln1 type ebeln, tebelp type ebelp, tbanfn type banfn, tbnfpo type bnfpo.

select-options: sbedat for sy-datum no-extension obligatory.

start-of-selection. perform perform perform perform perform perform get_data. set_data. set_data1. rfq_join. final_fill. alv_fill.

*&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form get_data . select ebeln ebelp bedat banfn bnfpo eindt from eket into table it_temp_eket where bedat in sbedat and ebeln like '4%'. if sy-subrc = 0. select ebeln lifnr from ekko into table it_vendor for all entries in it_temp_eket where ebeln = it_temp_eket-ebeln. if sy-subrc = 0. select lifnr name1 from lfa1 into table it_lfa11 for all entries in it_vendor where lifnr = it_vendor-lifnr. endif.

select ebeln ebelp bsgru netwr txz01 from ekpo into table it_ekpo_t for all entries in it_temp_eket where ebeln = it_temp_eket-ebeln and ebelp = it_temp_eket-ebelp.

if sy-subrc = 0. select bsgru bezei from tbsgt into table it_tbsgt for all entries in it_ekpo_t where bsgru = it_ekpo_t-bsgru. endif. *********** select ebeln ebelp banfn bnfpo bedat eindt from eket into table it_eket for all entries in it_temp_eket where banfn = it_temp_eket-banfn and bnfpo = it_temp_eket-bnfpo and ebeln like '6%' . if sy-subrc = 0. select ebeln ebelp brtwr agmem from ekpo into table it_price for all entries in it_eket where ebeln = it_eket-ebeln and ebelp = it_eket-ebelp. select ebeln lifnr bedat angdt from ekko into table it_ekko for all entries in it_eket

where ebeln = it_eket-ebeln. if sy-subrc = 0. select lifnr name1 from lfa1 into table it_lfa1 for all entries in it_ekko where lifnr = it_ekko-lifnr. endif.

endif. endif. endform. " get_data

*&---------------------------------------------------------------------* *& Form SET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form set_data . data count type i. loop at it_temp_eket into wa_temp_eket. select ebeln ebelp banfn bnfpo from eket into (tebeln, tebelp, tbanfn, tbnfpo) where banfn = wa_temp_eket-banfn and bnfpo = wa_temp_eket-bnfpo and ebeln like '6%' order by ebeln descending. endselect. select ebeln ebelp banfn bnfpo from eket into (tebeln1, tebelp, tbanfn, tbnfpo) where banfn = wa_temp_eket-banfn and bnfpo = wa_temp_eket-bnfpo and ebeln like '6%' order by ebeln ascending. endselect. temp = tebeln. temp1 = tebeln1. count = temp1 - temp.

if count = 0. count = 1. else. count = count + 1.

endif. replace all occurrences of temp(7) in temp1 with ' '.

concatenate temp ' - ' temp1 into wa_temp-ebeln. wa_temp-ebelp wa_temp-banfn wa_temp-bnfpo wa_temp-count = = = = tebelp. tbanfn. tbnfpo. count.

append wa_temp to it_temp. clear:tebeln,tebeln1,tebelp,tbanfn,tbnfpo,wa_temp,wa_temp_eket,count.

endloop.

endform.

" SET_DATA

*&---------------------------------------------------------------------* *& Form SET_DATA1 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form set_data1 . loop at it_temp_eket into wa_temp_eket. read table it_vendor into wa_vendor with key ebeln = wa_temp_eket-ebeln. if sy-subrc = 0. wa_po-lifnr = wa_vendor-lifnr. endif. read table it_lfa11 into wa_lfa11 with key lifnr = wa_po-lifnr. if sy-subrc = 0. wa_po-name1 = wa_lfa11-name1. else. read table it_lfa1 into wa_lfa1 with key lifnr = wa_po-lifnr. if sy-subrc = 0. wa_po-name1 = wa_lfa1-name1. endif. endif. read table it_ekpo_t into wa_ekpo_t with key ebeln = wa_temp_eket-ebeln ebelp = wa_temp_eket-ebelp. if sy-subrc = 0. wa_po-bsgru = wa_ekpo_t-bsgru. wa_po-netwr = wa_ekpo_t-netwr. wa_po-txz01 = wa_ekpo_t-txz01. endif.

wa_po-banfn wa_po-bnfpo wa_po-ebeln wa_po-ebelp wa_po-bedat wa_po-eindt

= = = = = =

wa_temp_eket-banfn. wa_temp_eket-bnfpo. wa_temp_eket-ebeln. wa_temp_eket-ebelp. wa_temp_eket-bedat. wa_temp_eket-eindt.

if wa_po-bsgru >= 100 wa_po-bsgru = 'ST'. elseif wa_po-bsgru >= wa_po-bsgru = 'LT'. elseif wa_po-bsgru >= wa_po-bsgru = 'OT'. elseif wa_po-bsgru >= wa_po-bsgru = 'OT'. endif.

and wa_po-bsgru <= 199. 200 and wa_po-bsgru <= 299. 300 and wa_po-bsgru <= 399. 400 and wa_po-bsgru <= 499.

append wa_po to it_po. clear: wa_po,wa_ekpo_t,wa_lfa1,wa_vendor,wa_temp_eket. endloop.

endform.

" SET_DATA1

*&---------------------------------------------------------------------* *& Form rfq_join *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form rfq_join . loop at it_eket into wa_eket. read table it_price into wa_price with key ebeln = wa_eket-ebeln ebelp = wa_eket-ebelp. if sy-subrc = 0. wa_rfq-netwr = wa_price-netwr. wa_rfq-ebeln = wa_price-ebeln. wa_rfq-ebelp = wa_price-ebelp. wa_rfq-agmem = wa_price-agmem. endif. read table it_ekko into wa_ekko with key ebeln = wa_eket-ebeln. if sy-subrc = 0. wa_rfq-lifnr = wa_ekko-lifnr. wa_rfq-bedat = wa_ekko-bedat. wa_rfq-angdt = wa_ekko-angdt. endif.

read table it_lfa1 into wa_lfa1 with key lifnr = wa_rfq-lifnr. if sy-subrc = 0.

wa_rfq-name1 = wa_lfa1-name1. endif. wa_rfq-banfn = wa_eket-banfn. wa_rfq-bnfpo = wa_eket-bnfpo. wa_rfq-eindt = wa_eket-eindt. append wa_rfq to it_rfq. clear: wa_rfq,wa_lfa1,wa_ekko,wa_price,wa_eket.

endloop. data: ltemp type c length 300, ltemp1 type c length 300. sort it_temp_eket by banfn bnfpo descending. sort it_rfq by banfn bnfpo eindt descending. sort it_temp by banfn bnfpo. loop at it_temp_eket into wa_temp_eket where banfn ne space. clear wa_rfq. loop at it_rfq into wa_rfq where banfn = wa_temp_eket-banfn and bnfpo = wa_temp_eket-bnfpo. if wa_rfq-agmem = 000. concatenate ltemp ',' wa_rfq-name1 into ltemp. else. concatenate temp1 ',' wa_rfq-name1 into ltemp1. endif. endloop.

replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace

first first first first first first first first first first first first first first first first first first first first first first first first

occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence occurrence

of of of of of of of of of of of of of of of of of of of of of of of of

',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','

in in in in in in in in in in in in in in in in in in in in in in in in

ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp ltemp

with with with with with with with with with with with with with with with with with with with with with with with with

'1)'. '2)'. '3)'. '4)'. '5)'. '6)'. '7)'. '8)'. '9)'. '10)'. '11)'. '12)'. '13)'. '14)'. '15)'. '16)'. '17)'. '18)'. '19)'. '20)'. '21)'. '22)'. '23)'. '24)'.

*********************************************************** replace first occurrence of ',' in ltemp1 with '1)'. replace first occurrence of ',' in ltemp1 with '2)'. replace first occurrence of ',' in ltemp1 with '3)'. replace first occurrence of ',' in ltemp1 with '4)'. replace first occurrence of ',' in ltemp1 with '5)'. replace first occurrence of ',' in ltemp1 with '6)'. replace first occurrence of ',' in ltemp1 with '7)'. replace first occurrence of ',' in ltemp1 with '8)'. replace first occurrence of ',' in ltemp1 with '9)'. replace first occurrence of ',' in ltemp1 with '10)'. replace first occurrence of ',' in ltemp1 with '11)'. replace first occurrence of ',' in ltemp1 with '12)'. replace first occurrence of ',' in ltemp1 with '13)'. replace first occurrence of ',' in ltemp1 with '14)'. replace first occurrence of ',' in ltemp1 with '15)'. replace first occurrence of ',' in ltemp1 with '16)'. replace first occurrence of ',' in ltemp1 with '17)'. replace first occurrence of ',' in ltemp1 with '18)'. replace first occurrence of ',' in ltemp1 with '19)'. replace first occurrence of ',' in ltemp1 with '20)'. replace first occurrence of ',' in ltemp1 with '21)'. replace first occurrence of ',' in ltemp1 with '22)'. replace first occurrence of ',' in ltemp1 with '23)'. replace first occurrence of ',' in ltemp1 with '24)'.

read table it_temp into wa_temp with key banfn = wa_temp_eket-banfn bnfpo = wa_temp_eket-bnfpo. if sy-subrc = 0. wa_status-ebelp = wa_temp-ebelp. wa_status-ebeln = wa_temp-ebeln. wa_status-banfn = wa_temp-banfn. wa_status-bnfpo = wa_temp-bnfpo. wa_status-count = wa_temp-count. endif. wa_status-accept = ltemp. wa_status-reject = ltemp1. wa_status-angdt = wa_rfq-angdt. wa_status-eindt = wa_rfq-eindt. wa_status-bedat = wa_rfq-bedat.

append wa_status to it_status. clear: wa_status,ltemp,ltemp1,wa_rfq,wa_temp_eket,wa_temp. endloop.

endform.

" rfq_join

*&---------------------------------------------------------------------* *& Form final_fill *&---------------------------------------------------------------------* * text

*----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form final_fill .

sort it_po by banfn bnfpo. sort it_status by banfn bnfpo. loop at it_po into wa_po. read table it_status into wa_status with key banfn = wa_po-banfn bnfpo = wa_po-bnfpo. if sy-subrc = 0. wa_output-rfqno = wa_status-ebeln. wa_output-accept = wa_status-accept. wa_output-reject = wa_status-reject. wa_output-angdt = wa_status-angdt. wa_output-eindt = wa_status-eindt. wa_output-rfqdt = wa_status-bedat. wa_output-least = 'YES'. wa_output-count = wa_status-count. endif. wa_output-ebeln = wa_po-ebeln. wa_output-lifnr = wa_po-lifnr. wa_output-name1 = wa_po-name1. wa_output-bedat = wa_po-bedat. wa_output-reason = wa_po-bsgru. wa_output-bedat = wa_po-bedat. wa_output-txz01 = wa_po-txz01. wa_output-netwr = wa_po-netwr. wa_output-eindt = wa_po-eindt. append wa_output to it_output. clear: wa_output,wa_status,wa_po. endloop.

sort it_output by bedat.

endform.

" final_fill

*&---------------------------------------------------------------------* *& Form alv_fill *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form alv_fill . perform buildfields using '1' 'RFQNO' 'IT_OUTPUT' 'TENDER NUMBER' '16' . perform buildfields using '2' 'TXZ01' 'IT_OUTPUT' 'ITEM/NATURE OF WORK' '25' . perform buildfields using '3' 'REASON' 'IT_OUTPUT' 'MODE OF TENDER ENQUITY' '5' . perform buildfields using '4' 'RFQDT' 'IT_OUTPUT' 'DATE OF PUBLICATION OF NIT' '10' . perform buildfields using '5' 'ANGDT' 'IT_OUTPUT' 'LAST DATE OF RECEIPT OF TENDER' '10' .

perform perform perform '300' . perform perform perform TENDERER' perform perform perform perform SUPPLIES'

buildfields using '6' buildfields using '7' buildfields using '8' buildfields buildfields buildfields '10' . buildfields buildfields buildfields buildfields '10' .

'COUNT' 'ACCEPT' 'REJECT'

'IT_OUTPUT' 'NO OF TENDERS RECEIVED' '5' . 'IT_OUTPUT' 'VENDORS QUALIFIED TECHNICALLY' '300' . 'IT_OUTPUT' 'VENDORS NOT QUALIFIED TECHNICALLY' 'IT_OUTPUT' 'CONTRACT NUMBER' '12' . 'IT_OUTPUT' 'CONTRACT DATE' '10' . 'IT_OUTPUT' 'WHETHER CONTRACT IS AWARDED TO L1 'IT_OUTPUT' 'IT_OUTPUT' 'IT_OUTPUT' 'IT_OUTPUT' 'VENDOR' '10' . 'NAME OF THE CONTRACTOR' '25' . 'VALUE OF CONTRACT' '18' . 'SCHEDULED DATE OF COMPLETION OF

using '9' 'EBELN' using '10' 'BEDAT' using '11' 'LEAST' using using using using '12' '13' '14' '15' 'LIFNR' 'NAME1' 'NETWR' 'EINDT'

call function 'REUSE_ALV_GRID_DISPLAY' exporting it_fieldcat = it_fieldcat tables t_outtab = it_output[].

endform. " alv_fill *&---------------------------------------------------------------------* *& Form buildfields *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_1246 text * -->P_1247 text * -->P_1248 text * -->P_1249 text * -->P_1250 text *----------------------------------------------------------------------* form buildfields using value(p_col_pos) type sy-cucol value(p_fldname) type slis_fieldname value(p_tabname) type slis_tabname value(p_seltext) type dd03p-reptext value(p_length) type i.

wa_fieldcat-fieldname = p_fldname. wa_fieldcat-seltext_l = p_seltext. wa_fieldcat-tabname = p_tabname. wa_fieldcat-col_pos = p_col_pos. wa_fieldcat-outputlen = p_length. append wa_fieldcat to it_fieldcat. clear wa_fieldcat. endform. " buildfields

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Pr to invoice
*&---------------------------------------------------------------------* *& Report ZPRTOINVOICE *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* report zprtoinvoice.

tables: eban,ekko,ekpo,mseg,lfa1,qals,mkpf,ekbe,t007s,ebkn. type-pools:slis.

types: begin of typ_pr, banfn type banfn, bnfpo type bnfpo, matnr type matnr, badat type badat, matkl type matkl, ekgrp type ekgrp, bednr type bednr, end of typ_pr. types: begin of typ_pr1, banfn type banfn, bnfpo type bnfpo, kostl type kostl, end of typ_pr1. types: begin of typ_po, ebeln type ebeln, ebelp type ebelp, matnr type matnr, txz01 type txz01, menge type bstmg, meins type bstme, banfn type banfn, bnfpo type bnfpo, anfnr type anfnr, anfps type anfps, bsgru type bsgru, netpr type bprei, brtwr type bbwert, netwr type bwert, mwskz type mwskz, end of typ_po. types: begin of typ_po1, ebeln type ebeln, lifnr type lifnr, aedat type aedat, end of typ_po1. types: begin of typ_ekko, ebeln type ebeln, lponr type lponr, angdt type angdt,

aedat type aedat, end of typ_ekko.

types: begin of typ_gr_t, ebeln type ebeln, ebelp type ebelp, end of typ_gr_t. types: begin of typ_gr_t1, mblnr type mblnr, mjahr type mjahr, end of typ_gr_t1. types: begin of typ_res, bsgru type bsgru, bezei type bezei, end of typ_res. types: begin of typ_tax, mwskz type mwskz, text1 type text1_007s, end of typ_tax. types: begin lifnr name1 end of of typ_ven, type lifnr, type name1_gp, typ_ven.

types: begin of typ_eket, ebeln type ebeln, ebelp type ebelp, banfn type banfn, bnfpo type bnfpo, end of typ_eket. types: begin of typ_temp_ekko, ebeln type ebeln, angdt type angdt, aedat type aedat, end of typ_temp_ekko. types: begin of typ_gr, ebeln type ebeln, ebelp type ebelp, mblnr type mblnr, mjahr type mjahr, bwart type bwart, erfmg type erfmg, erfme type erfme, dmbtr type dmbtr, matnr type matnr, end of typ_gr. types: begin of typ_gr1, mblnr type mblnr, mjahr type mjahr, bldat type bldat, end of typ_gr1.

types: begin of typ_qi, ebeln type ebeln, ebelp type ebelp, mblnr type mblnr, mjahr type mjahr, prueflos type qplos, pastrterm type qprstart, paendterm type qprende, losmenge type qlosmenge, end of typ_qi.

types: begin of typ_ekbe, ebeln type ebeln, ebelp type ebelp, belnr type mblnr, gjahr type mjahr, budat type budat, dmbtr type dmbtr, bldat type bldat, waers type waers, end of typ_ekbe. types: begin of typ_output, banfn type banfn, bnfpo type bnfpo, matnr type matnr, badat type badat, angdt type angdt, matkl type matkl, kostl type kostl, bednr type bednr, netpr type bprei, brtwr type bbwert, netwr type bwert, ekgrp type ekgrp, anfnr type anfnr, anfps type anfps, ebeln type ebeln, ebelp type ebelp, aedat type aedat, aedat1 type aedat, txz01 type txz01, lifnr type lifnr, name1 type name1_gp, menge type bstmg, meins type bstme, bsgru type bsgru, bezei type bezei, mwskz type mwskz, text1 type text1_007s, mblnr type mblnr, mjahr type mjahr, bldat type bldat, bwart type bwart, grund type mb_grbew, erfmg type erfmg, erfme type erfme, prueflos type qplos, pastrterm type qprstart,

paendterm type qprende, losmenge type qlosmenge, belnr type mblnr, gjahr type mjahr, budat type budat, dmbtr type dmbtr, waers type waers, end of typ_output. data: it_pr type table of typ_pr, it_pr1 type table of typ_pr1, it_po type table of typ_po, it_po1 type table of typ_po1, it_ekko type table of typ_ekko, it_gr_t type table of typ_gr_t, it_gr_t1 type table of typ_gr_t1, it_ven type table of typ_ven, it_res type table of typ_res, it_tax type table of typ_tax, it_gr type table of typ_gr, it_gr1 type table of typ_gr1, it_qi type table of typ_qi, it_ekbe type table of typ_ekbe, it_output type table of typ_output, fieldcat type slis_t_fieldcat_alv with header line, it_eket type table of typ_eket, it_temp_ekko type table of typ_temp_ekko, wa_eket type typ_eket, wa_temp_ekko type typ_temp_ekko, wa_pr type typ_pr, wa_pr1 type typ_pr1, wa_po type typ_po, wa_po1 type typ_po1, wa_ekko type typ_ekko, wa_gr_t type typ_gr_t, wa_gr_t1 type typ_gr_t1, wa_ven type typ_ven, wa_res type typ_res, wa_tax type typ_tax, wa_gr type typ_gr, wa_gr1 type typ_gr1, wa_qi type typ_qi, wa_ekbe type typ_ekbe, wa_output type typ_output. selection-screen: begin of block t with frame title text-009. selection-screen: begin of block a with frame title text-001. select-options: s_banfn for eban-banfn s_badat for eban-badat s_kostl for ebkn-kostl s_ekgrp for eban-ekgrp s_bednr for eban-bednr selection-screen: end of block a. no-extension, no-extension, no-extension, no-extension, no-extension.

selection-screen: begin of block b with frame title text-002. select-options: s_anfnr for ekpo-anfnr no-extension, s_aedat1 for ekko-aedat no-extension,

s_lifnr2 for ekko-lifnr no-extension. selection-screen: end of block b.

selection-screen: begin of block c with frame title text-003. select-options: s_ebeln for ekko-ebeln no-extension, s_aedat for ekko-aedat no-extension, s_bsgru for ekpo-bsgru no-extension, s_lifnr1 for ekko-lifnr no-extension. selection-screen: end of block c.

selection-screen: begin of block d with frame title text-004. select-options: s_mblnr for mseg-mblnr no-extension, s_mjahr for mseg-mjahr no-extension, s_bldat for mkpf-bldat no-extension.

selection-screen: end of block d. selection-screen: begin of block e with frame title text-005. select-options: s_belnr for ekbe-belnr no-extension, s_gjahr for ekbe-gjahr no-extension. selection-screen: end of block e.

selection-screen: begin of block f with frame title text-006. select-options: s_matnr for eban-matnr no-extension, s_matkl for eban-matkl no-extension. selection-screen: end of block f. selection-screen: end of block t.

start-of-selection. perform get_data. perform set_data. perform fill_output. perform alv_fill. perform alv_display.

*&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form get_data . if s_banfn is not initial or s_badat is not initial or s_ekgrp is not initial or s_bednr is not initial. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr where banfn in s_banfn and badat in s_badat and ekgrp in s_ekgrp and bednr in s_bednr. if sy-subrc = 0. sort it_pr by banfn bnfpo. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_pr where banfn = it_pr-banfn and bnfpo = it_pr-bnfpo.

if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln.

endif. endif.

elseif s_kostl is not initial. select banfn bnfpo kostl from ebkn into table it_pr1 where kostl in s_kostl and banfn in s_banfn. if sy-subrc = 0. sort it_pr1 by banfn bnfpo. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_pr1 where banfn = it_pr1-banfn and bnfpo = it_pr1-bnfpo.

select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_pr where banfn = it_pr-banfn and bnfpo = it_pr-bnfpo.

if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln.

endif. endif.

********************************************************************* elseif not s_anfnr is initial. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po where anfnr in s_anfnr.

if sy-subrc = 0.

sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln.

select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo. endif.

elseif not s_aedat1 is initial. select ebeln lponr angdt aedat from ekko into table it_ekko where aedat in s_aedat1 and lifnr in s_lifnr1 and bstyp = 'A' and bsart = 'AN'. if sy-subrc = 0. sort it_ekko by ebeln. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_ekko where anfnr = it_ekko-ebeln and anfps = it_ekko-lponr and aedat = it_ekko-aedat. if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln.

select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo.

endif. endif. elseif not s_lifnr2 is initial . select ebeln lifnr aedat from ekko into table it_po1 where lifnr in s_lifnr2 and ebeln in s_anfnr and aedat in s_aedat1.

if sy-subrc = 0. sort it_po1 by ebeln. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_po1 where ebeln = it_po1-ebeln. if sy-subrc = 0. sort it_po by ebeln ebelp. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo.

endif. endif. ********************************************************************* elseif not s_ebeln is initial. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po where ebeln in s_ebeln and matnr in s_matnr and matkl in s_matkl and bsgru in s_bsgru and aedat in s_aedat. if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko

into table it_po1 for all entries in it_po where ebeln = it_po-ebeln.

select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo. endif.

elseif not s_aedat is initial. select ebeln lifnr aedat from ekko into table it_po1 where aedat in s_aedat and ebeln in s_ebeln and lifnr in s_lifnr1. if sy-subrc = 0. sort it_po1 by ebeln. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_po1 where ebeln = it_po1-ebeln and bsgru in s_bsgru. if sy-subrc = 0. sort it_po by ebeln ebelp. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo.

endif. endif.

elseif not s_bsgru is initial. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po where bsgru in s_bsgru and ebeln in s_ebeln and matnr in s_matnr and aedat in s_aedat.

if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat angdt from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln.

select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo. endif. elseif not s_lifnr1 is initial . select ebeln lifnr aedat from ekko into table it_po1 where lifnr in s_lifnr1 and ebeln in s_ebeln and aedat in s_aedat.

if sy-subrc = 0. sort it_po1 by ebeln. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_po1 where ebeln = it_po1-ebeln. if sy-subrc = 0. sort it_po by ebeln ebelp. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo.

endif. endif.

************************************************************************ elseif s_mblnr is not initial and s_mjahr is not initial.

select ebeln ebelp from mseg into table it_gr_t where mblnr in s_mblnr and mjahr in s_mjahr.

if sy-subrc = 0. sort it_gr_t by ebeln ebelp. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_gr_t where ebeln = it_gr_t-ebeln and ebelp = it_gr_t-ebelp. if sy-subrc = 0. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo.

endif. endif.

elseif s_bldat is not initial. select mblnr mjahr from mkpf into table it_gr_t1 where bldat in s_bldat and mblnr like '5%'. if sy-subrc = 0. sort it_gr_t1 by mblnr mjahr. select ebeln ebelp from mseg into table it_gr_t for all entries in it_gr_t1 where mblnr = it_gr_t1-mblnr and mjahr = it_gr_t1-mjahr. if sy-subrc = 0. sort it_gr_t by ebeln ebelp.

select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_gr_t where ebeln = it_gr_t-ebeln and ebelp = it_gr_t-ebelp. if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln. if sy-subrc = 0. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo. endif. endif. endif. endif. *********************************************************************** elseif s_belnr is not initial and s_gjahr is not initial. select ebeln ebelp from ekbe into table it_gr_t where belnr in s_belnr and gjahr in s_gjahr.

if sy-subrc = 0. sort it_gr_t by ebeln ebelp. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_gr_t where ebeln = it_gr_t-ebeln and ebelp = it_gr_t-ebelp. if sy-subrc = 0. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po

where ebeln = it_po-ebeln. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr for all entries in it_po where banfn = it_po-banfn and bnfpo = it_po-bnfpo.

endif. endif. *********************************************************************** elseif s_matnr is not initial. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr where matnr in s_matnr. if sy-subrc = 0. sort it_pr by banfn bnfpo. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_pr where banfn = it_pr-banfn and bnfpo = it_pr-bnfpo. if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln. endif. endif. elseif s_matkl is not initial. select banfn bnfpo matnr badat matkl ekgrp bednr from eban into table it_pr where matkl in s_matkl. if sy-subrc = 0. sort it_pr by banfn bnfpo. select ebeln ebelp matnr txz01 menge meins banfn bnfpo anfnr anfps bsgru netpr brtwr netwr mwskz from ekpo into table it_po for all entries in it_pr

where banfn = it_pr-banfn and bnfpo = it_pr-bnfpo and matnr = it_pr-matnr.

if sy-subrc = 0. sort it_po by ebeln ebelp. select ebeln lifnr aedat from ekko into table it_po1 for all entries in it_po where ebeln = it_po-ebeln. endif. endif.

endif. endform. " get_data

*&---------------------------------------------------------------------* *& Form set_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form set_data . if it_pr is not initial. select banfn bnfpo kostl from ebkn into table it_pr1 for all entries in it_pr where banfn = it_pr-banfn and bnfpo = it_pr-bnfpo and kostl in s_kostl.

select ebeln ebelp banfn bnfpo from eket into table it_eket for all entries in it_pr where banfn = it_pr-banfn and bnfpo = it_pr-bnfpo and ebeln like '6%'. if sy-subrc = 0. select ebeln angdt aedat from ekko into table it_temp_ekko for all entries in it_eket where ebeln = it_eket-ebeln. endif. endif. if not it_po1[] is initial. sort it_po1 by ebeln. select lifnr name1 from lfa1 into table it_ven for all entries in it_po1 where lifnr = it_po1-lifnr. endif.

if not it_po[] is initial. select mwskz text1 from t007s into table it_tax for all entries in it_po where mwskz = it_po-mwskz.

select bsgru bezei from tbsgt into table it_res for all entries in it_po where bsgru = it_po-bsgru. select ebeln ebelp mblnr mjahr bwart erfmg erfme dmbtr matnr from mseg into table it_gr for all entries in it_po where ebeln = it_po-ebeln and ebelp = it_po-ebelp and matnr = it_po-matnr. and mblnr like '5%'.

* *

if sy-subrc = 0. sort it_gr by mblnr mjahr.

select mblnr mjahr bldat from mkpf into table it_gr1 for all entries in it_gr where mblnr = it_gr-mblnr and mjahr = it_gr-mjahr. endif. endif. if not it_gr[] is initial. select ebeln ebelp mblnr mjahr prueflos pastrterm paendterm losmenge from qals into table it_qi for all entries in it_gr where mblnr = it_gr-mblnr and mjahr = it_gr-mjahr and ebeln = it_gr-ebeln and ebelp = it_gr-ebelp.

select ebeln ebelp belnr gjahr budat dmbtr bldat waers from ekbe into table it_ekbe for all entries in it_gr where ebeln = it_gr-ebeln and ebelp = it_gr-ebelp and bewtp = 'Q'. endif. endform. " set_data

*&---------------------------------------------------------------------* *& Form fill_output *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form fill_output .

loop at it_pr into wa_pr. wa_output-badat wa_output-ekgrp wa_output-matkl wa_output-bednr wa_output-banfn wa_output-bnfpo wa_output-matnr = = = = = = = wa_pr-badat. wa_pr-ekgrp. wa_pr-matkl. wa_pr-bednr. wa_pr-banfn. wa_pr-bnfpo. wa_pr-matnr.

read table it_pr1 into wa_pr1 with key banfn = wa_pr-banfn bnfpo = wa_pr-bnfpo. if sy-subrc = 0.

wa_output-kostl = wa_pr1-kostl. endif. if it_po[] is not initial. loop at it_po into wa_po where banfn = wa_pr-banfn and bnfpo = wa_pr-bnfpo. wa_output-ebeln wa_output-ebelp wa_output-txz01 wa_output-menge wa_output-meins wa_output-anfnr wa_output-anfps wa_output-bsgru wa_output-netpr wa_output-brtwr wa_output-netwr wa_output-mwskz = = = = = = = = = = = = wa_po-ebeln. wa_po-ebelp. wa_po-txz01. wa_po-menge. wa_po-meins. wa_po-anfnr. wa_po-anfps. wa_po-bsgru. wa_po-netpr. wa_po-brtwr. wa_po-netwr. wa_po-mwskz.

read table it_po1 into wa_po1 with key ebeln = wa_output-ebeln. if sy-subrc = 0. wa_output-lifnr = wa_po1-lifnr. wa_output-aedat = wa_po1-aedat. endif. read table it_temp_ekko into wa_temp_ekko with key ebeln = wa_output-anfnr.

if sy-subrc = 0. wa_output-aedat1 = wa_temp_ekko-aedat. wa_output-angdt = wa_temp_ekko-angdt. endif. read table it_tax into wa_tax with key mwskz = wa_output-mwskz. if sy-subrc = 0. wa_output-text1 = wa_tax-text1. endif. read table it_res into wa_res with key bsgru = wa_output-bsgru. if sy-subrc = 0. wa_output-bezei = wa_res-bezei. endif.

read table it_ven into wa_ven with key lifnr = wa_output-lifnr. if sy-subrc = 0. wa_output-name1 = wa_ven-name1. endif. loop at it_gr into wa_gr where ebeln = wa_output-ebeln and ebelp = wa_output-ebelp. wa_output-mblnr = wa_gr-mblnr. wa_output-mjahr = wa_gr-mjahr. wa_output-erfmg = wa_gr-erfmg.

wa_output-erfme = wa_gr-erfme. wa_output-bwart = wa_gr-bwart. read table it_gr1 into wa_gr1 with key if sy-subrc = 0. wa_output-bldat = wa_gr1-bldat. endif. read table it_qi into wa_qi with key mblnr mjahr ebeln ebelp = = = = wa_output-mblnr wa_output-mjahr wa_output-ebeln wa_output-ebelp. mblnr = wa_output-mblnr.

if sy-subrc = 0. wa_output-prueflos = wa_qi-prueflos. wa_output-pastrterm = wa_qi-pastrterm. wa_output-paendterm = wa_qi-paendterm. wa_output-losmenge = wa_qi-losmenge. endif. if wa_output-bwart = '101'. read table it_ekbe into wa_ekbe with key ebeln = wa_output-ebeln ebelp = wa_output-ebelp.

if sy-subrc = 0. wa_output-belnr wa_output-gjahr wa_output-budat wa_output-dmbtr wa_output-waers endif.

= = = = =

wa_ekbe-belnr. wa_ekbe-gjahr. wa_ekbe-budat. wa_ekbe-dmbtr. wa_ekbe-waers.

endif. append wa_output to it_output. clear: wa_temp_ekko. endloop. append wa_output to it_output. endloop. else. append wa_output to it_output. endif. clear: wa_output. endloop. sort it_output by banfn bnfpo ebeln ebelp mblnr gjahr. delete adjacent duplicates from it_output comparing banfn bnfpo ebeln ebelp mblnr gjahr.

endform.

" fill_output

*&---------------------------------------------------------------------* *& Form ALv_FILL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------*

form alv_fill . fieldcat-col_pos = 1. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BANFN'. fieldcat-seltext_l = 'PR NUMBER'. append fieldcat. fieldcat-col_pos = 2. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BNFPO'. fieldcat-seltext_l = 'PR ITEM NO'. append fieldcat. fieldcat-col_pos = 3. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BADAT'. fieldcat-seltext_l = 'PR DATE'. append fieldcat. fieldcat-col_pos = 4. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BEDNR'. fieldcat-seltext_l = 'BUDGET NUMBER'. append fieldcat. fieldcat-col_pos = 5. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'EKGRP'. fieldcat-seltext_l = 'PURCHASING GROUP'. append fieldcat. fieldcat-col_pos = 6. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'ANFNR'. fieldcat-seltext_l = 'RFQ NUMBER'. append fieldcat. fieldcat-col_pos = 7. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'ANFPS'. fieldcat-seltext_l = 'RFQ ITEM'. append fieldcat. fieldcat-col_pos = 8. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'AEDAT1'. fieldcat-seltext_l = 'ENQUIRY DATE'. append fieldcat.

fieldcat-col_pos = 9. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'ANGDT'. fieldcat-seltext_l = 'DEAD LINE FOR QUATION'. append fieldcat. fieldcat-col_pos = 10. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'EBELN'. fieldcat-seltext_l = 'PO NUMBER'. append fieldcat. fieldcat-col_pos = 11. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'EBELP'. fieldcat-seltext_l = 'PO ITEM'. append fieldcat. fieldcat-col_pos = 12. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'AEDAT'. fieldcat-seltext_l = 'PO DATE'. append fieldcat. fieldcat-col_pos = 13. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'LIFNR'. fieldcat-seltext_l = 'VENDOR CODE'. append fieldcat. fieldcat-col_pos = 14. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'NAME1'. fieldcat-seltext_l = 'VENDOR NAME'. append fieldcat. fieldcat-col_pos = 15. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'MATNR'. fieldcat-seltext_l = 'MATERIAL NUMBER'. append fieldcat. fieldcat-col_pos = 16. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'TXZ01'. fieldcat-seltext_l = 'MATERIAL DESCRIPTION'. append fieldcat. fieldcat-col_pos = 17. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'MATKL'. fieldcat-seltext_l = 'MATERIAL GROUP'. append fieldcat. fieldcat-col_pos = 18. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'MEINS'. fieldcat-seltext_l = 'UNIT OF MEASURE'. append fieldcat.

fieldcat-col_pos = 19. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'MENGE'. fieldcat-seltext_l = 'PO QUANTITY'. append fieldcat. fieldcat-col_pos = 20. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'NETPR'. fieldcat-seltext_l = 'UNIT PRICE'. append fieldcat. fieldcat-col_pos = 21. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BRTWR'. fieldcat-seltext_l = 'TOTAL UNIT PRICE'. append fieldcat. fieldcat-col_pos = 22. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'NETWR'. fieldcat-seltext_l = 'TOTAL PO VALUE'. append fieldcat. fieldcat-col_pos = 23. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'WAERS'. fieldcat-seltext_l = 'CURRENCY'. append fieldcat. fieldcat-col_pos = 24. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'KOSTL'. fieldcat-seltext_l = 'COST CENTER'. append fieldcat. fieldcat-col_pos = 25. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'MWSKZ'. fieldcat-seltext_l = 'TAX CODE'. append fieldcat. fieldcat-col_pos = 26. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'TEXT1'. fieldcat-seltext_l = 'DESCRIPTION'. append fieldcat. fieldcat-col_pos = 27. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BSGRU'. fieldcat-seltext_l = 'REASON FOR ORDERING'. append fieldcat. fieldcat-col_pos = 28. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BEZEI'. fieldcat-seltext_l = 'DESCRIPTION'. append fieldcat. fieldcat-col_pos = 29.

fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'MBLNR'. fieldcat-seltext_l = 'GR NUMBER'. append fieldcat. fieldcat-col_pos = 30. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'MJAHR'. fieldcat-seltext_l = 'DOC YEAR'. append fieldcat. fieldcat-col_pos = 31. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BLDAT'. fieldcat-seltext_l = 'GR DATE'. append fieldcat. fieldcat-col_pos = 32. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BWART'. fieldcat-seltext_l = 'MOVEMENT TYPE'. append fieldcat. fieldcat-col_pos = 33. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'ERFMG'. fieldcat-seltext_l = 'GR QUANTITY'. append fieldcat. fieldcat-col_pos = 34. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'ERFME'. fieldcat-seltext_l = 'UNIT OF MEASURE'. append fieldcat. fieldcat-col_pos = 35. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'PRUEFLOS'. fieldcat-seltext_l = 'INSPECTION LOT NUMBER'. append fieldcat. fieldcat-col_pos = 36. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'PASTRTERM'. fieldcat-seltext_l = 'START DATE'. append fieldcat. fieldcat-col_pos = 37. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'PAENDTERM'. fieldcat-seltext_l = 'END DATE'. append fieldcat.

fieldcat-col_pos = 38. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'LOSMENGE'. fieldcat-seltext_l = 'INSPECTION QUANTITY'. append fieldcat.

fieldcat-col_pos = 39. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BELNR'. fieldcat-seltext_l = 'INVOICE NUMBER'. append fieldcat. fieldcat-col_pos = 40. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'GJAHR'. fieldcat-seltext_l = 'DOC YEAR'. append fieldcat. fieldcat-col_pos = 41. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'BUDAT'. fieldcat-seltext_l = 'INVOICE DATE'. append fieldcat. fieldcat-col_pos = 42. fieldcat-tabname = 'IT_OUTPUT'. fieldcat-fieldname = 'DMBTR'. fieldcat-seltext_l = 'INVOICE AMOUNT'. append fieldcat.

endform.

" ALv_FILL

*&---------------------------------------------------------------------* *& Form ALV_DISPLAY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------*

form alv_display . call function 'REUSE_ALV_GRID_DISPLAY' exporting it_fieldcat = fieldcat[] tables t_outtab = it_output[].

endform.

" ALV_DISPLAY

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, price comparative statement

*&---------------------------------------------------------------------* *& Report ZMMRFQCOM3 * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------*

report

zmmrfqcom2 line-size 192 line-count 33 message-id zmessage1.

tables: ekko,ekpo,lfa1,konv,a003,t052u. types: begin of typ_ekko, ebeln type ebeln, lifnr type lifnr, ekorg type ekorg, bedat type bedat, zterm type dzterm, zbd1t type dzbdet, inco1 type inco1, kalsm type kalsm_d, bnddt type aedat, angnr type angnr, ihran type ihran, inco2 type inco2, waers type waers, end of typ_ekko. " to hold rfq header

types: begin of typ_lfa1, " to hold vendor details lifnr type lifnr, name1 type name1, land1 type land1_gp, ort01 type ort01_gp, end of typ_lfa1. types: begin of typ_ekpo, ebeln type ebeln, ebelp type ebelp, matnr type matnr, txz01 type txz01, ktmng type ktmng, meins type bstme, netpr type netpr, mwskz type mwskz, agmem type agmem, banfn type banfn, end of typ_ekpo. types: begin of typ_t052u, zterm type dzterm, text1 type text1_052, end of typ_t052u. types: begin of typ_ekpo1, ebeln type ebeln, ebelp type ebelp, matnr type matnr, txz01 type txz01, ktmng type ktmng, " to hold rfq rejected details " to hold rfq accepted details

meins type bstme, netpr type netpr, mwskz type mwskz, agmem type agmem, end of typ_ekpo1. types: begin of typ_reject, ebeln type ebeln, ebelp type ebelp, matnr type matnr, lifnr type lifnr, end of typ_reject. types: begin of typ_a003, kschl type kschl, mwskz type mwskz, aland type aland, knumh type knumh, end of typ_a003. types: begin of typ_konp, knumh type knumh, kschl type kschl, kbetr type kbetr, mwsk1 type mwskz, end of typ_konp. types: begin of typ_konh, ebeln type ebeln, ebelp type ebelp, vakey type vakey, end of typ_konh. types: begin of typ_konh1, knumh type knumh, vakey type vakey, end of typ_konh1. " to fetch tax conditions record number

"

to hod tax individual values

" to fetch vakey for con rec numb

" to hold cond rec numb for other charges

types: begin of typ_konp1, knumh type knumh, kopos type kopos, kschl type kschl, krech type krech, kbetr type kbetr, kpein type kpein, end of typ_konp1. types: begin of typ_tax, " to save tax individual values for calc mwskz type mwskz, ed type p length 4 decimals 3, vat type p length 4 decimals 3, edc type p length 4 decimals 3, vatc type p length 4 decimals 3, cst type p length 4 decimals 3, end of typ_tax.

types: begin of typ_rfq, ebeln type ebeln,

" combining rfq head,item,ven.

ebelp type ebelp, lifnr type lifnr, name1 type name1, land1 type land1_gp, ekorg type ekorg, bedat type bedat, zterm type dzterm, zbd1t type dzbdet, inco1 type inco1, kalsm type kalsm_d, matnr type matnr, txz01 type txz01, ktmng type ktmng, meins type bstme, netpr type netpr, mwskz type mwskz, agmem type agmem, knumh type knumh, bnddt type aedat, banfn type banfn, angnr type angnr, ort01 type ort01_gp, inco2 type inco2, text1 type text1_052, ihran type ihran, waers type waers, end of typ_rfq. types: begin of typ_calculation, ebeln type ebeln, ebelp type ebelp, lifnr type lifnr, name1 type name1, land1 type land1_gp, zterm type dzterm, zbd1t type dzbdet, inco1 type inco1, matnr type matnr, txz01 type txz01, ktmng type ktmng, meins type bstme, netpr type netpr, mwskz type mwskz, agmem type agmem, knumh type knumh, waers type waers, subtotal1 type bprei, others1 type bprei, subtotal2 type bprei, ed type bprei, subtotal3 type bprei, others2 type bprei, subtotal5 type bprei, vat type bprei, cst type bprei, subtotal4 type bprei, cenvat type bprei, modvat type bprei, grand type bprei, payment type bprei, transport type bprei,

others3 type bprei, landcost type bprei, landper type bprei, lastpo type ebeln, netpr1 type netpr, aedat1 type aedat, lifnr1 type lifnr, discount type bprei, end of typ_calculation. types: begin of typ_print_item, ebeln type c length 15, ebelp type c length 15, lifnr type c length 15, name1 type c length 15, matnr type c length 18, netpr type c length 15, mwskz type c length 15, waers type c length 15, subtotal1 type c length others1 type c length subtotal2 type c length ed type c length subtotal3 type c length others2 type c length subtotal5 type c length vat type c length cst type c length subtotal4 type c length cenvat type c length modvat type c length grand type c length payment type c length transport type c length others3 type c length landcost type c length landper type c length lastpo type ebeln, netpr1 type netpr, aedat1 type aedat, lifnr1 type lifnr, discount type c length rank(15) type c, end of typ_print_item. types: begin of typ_print_over, ebeln(15), ebelp(15), lifnr(15), landcost(15), matnr(18), end of typ_print_over.

15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,

15,

types: begin of typ_indiv, ebeln type ebeln, ebelp type ebelp, matnr type matnr, landper type bprei, end of typ_indiv.

types: begin of typ_over, ebeln type ebeln, landcost type bprei, end of typ_over. types: begin of typ_indiv1, ebeln type ebeln, ebelp type ebelp, matnr type matnr, landper type bprei, rank(3) type c, end of typ_indiv1. types: begin of typ_over1, ebeln type ebeln, landcost type bprei, rank(3) type c, end of typ_over1. types: begin of typ_over2, ebeln(15), landcost(15), rank(15), end of typ_over2.

data: it_ekko type table of typ_ekko, it_ekpo type table of typ_ekpo, it_ekpo1 type table of typ_ekpo1, it_lfa1 type table of typ_lfa1, it_t052u type table of typ_t052u, it_a003 type table of typ_a003, it_rfq type table of typ_rfq, it_rfqt type table of typ_rfq, it_konp type table of typ_konp, it_konh type table of typ_konh, it_konh1 type table of typ_konh1, it_konp1 type table of typ_konp1, it_tax type sorted table of typ_tax with non-unique key mwskz, it_final type table of typ_calculation, it_indiv type table of typ_indiv, it_indiv1 type table of typ_indiv1, it_over1 type table of typ_over1, it_over2 type table of typ_over2, it_over type sorted table of typ_over with non-unique key ebeln, it_output1 type table of typ_print_item, it_output_temp type table of typ_print_item, it_output2 type table of typ_print_over, it_reject type table of typ_reject, wa_reject type typ_reject, wa_output1 type typ_print_item, wa_output_temp type typ_print_item, wa_output2 type typ_print_over, wa_rfq type typ_rfq, wa_rfqt type typ_rfq, wa_konp type typ_konp, wa_konh type typ_konh, wa_konh1 type typ_konh1, wa_konp1 type typ_konp1, wa_lfa1 type typ_lfa1, wa_ekko type typ_ekko,

wa_ekpo type typ_ekpo, wa_t052u type typ_t052u, wa_ekpo1 type typ_ekpo1, wa_tax type typ_tax, wa_final type typ_calculation, wa_indiv type typ_indiv, wa_over type typ_over, wa_indiv1 type typ_indiv1, wa_over1 type typ_over1, wa_over2 type typ_over2, wa_a003 type typ_a003, purno type ebeln.

selection-screen: begin of block a with frame. select-options: s_ebeln for ekko-ebeln obligatory. *parameters: pebeln type ekko-ebeln obligatory. selection-screen: end of block a. selection-screen: begin of block b with frame. parameter: rad1 radiobutton group radi, rad2 radiobutton group radi. selection-screen: end of block b.

start-of-selection. purno = s_ebeln-low. perform get_data. perform calculate. credit details perform calculation1. perform split. " all details from db " get tax details from table and calculate ed,vat,cst,ed credit,vat

" full calculation of sub total etc.. " spliting contents for calculating ranks

perform individual_rank. " calculation of individual ranking per item perform overall. perform fill_output. " over all ranking " filling output based on radio button at selection screen.

end-of-selection. if rad1 = 'X'. perform header. perform print_quotaion_summary. perform print_itemwise_l1_list. perform print_items. else.

perform header. perform print_quotaion_summary. * PERFORM print_overall_l1_list. perform disply_all. endif.

*&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form get_data . select ebeln lifnr ekorg bedat zterm zbd1t inco1 kalsm bnddt angnr ihran inco2 waers from ekko into table it_ekko where ebeln in s_ebeln and bstyp = 'A'. if sy-subrc = 0. select lifnr name1 land1 ort01 from lfa1 into table it_lfa1 for all entries in it_ekko where lifnr = it_ekko-lifnr. select zterm text1 from t052u into table it_t052u for all entries in it_ekko where zterm = it_ekko-zterm.

select ebeln ebelp matnr txz01 ktmng meins netpr mwskz agmem banfn from ekpo into table it_ekpo for all entries in it_ekko where ebeln = it_ekko-ebeln. if sy-subrc = 0. sort it_ekpo by ebeln ebelp. loop at it_ekpo into wa_ekpo. concatenate wa_ekpo-ebeln wa_ekpo-ebelp into wa_konh-vakey. wa_konh-ebeln = wa_ekpo-ebeln. wa_konh-ebelp = wa_ekpo-ebelp. append wa_konh to it_konh. endloop. endif. if it_konh[] is not initial. select knumh vakey from konh into table it_konh1 for all entries in it_konh where vakey = it_konh-vakey. endif. if it_konh1[] is not initial. select knumh kopos kschl krech kbetr kpein from konp into table it_konp1 for all entries in it_konh1 where knumh = it_konh1-knumh. endif. loop at it_ekpo into wa_ekpo. read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln. if sy-subrc = 0. wa_rfq-ebeln = wa_ekko-ebeln. wa_rfq-lifnr = wa_ekko-lifnr. wa_rfq-ekorg = wa_ekko-ekorg. wa_rfq-bedat = wa_ekko-bedat. wa_rfq-zterm = wa_ekko-zterm. wa_rfq-zbd1t = wa_ekko-zbd1t. wa_rfq-inco1 = wa_ekko-inco1. wa_rfq-kalsm = wa_ekko-kalsm. wa_rfq-bnddt = wa_ekko-bnddt. wa_rfq-angnr = wa_ekko-angnr. wa_rfq-inco2 = wa_ekko-inco2. wa_rfq-ihran = wa_ekko-ihran. wa_rfq-waers = wa_ekko-waers. endif. read table it_t052u into wa_t052u with key zterm if sy-subrc = 0. wa_rfq-text1 = wa_t052u-text1. endif. = wa_ekko-zterm.

read table it_lfa1 into wa_lfa1 with key lifnr = wa_rfq-lifnr. if sy-subrc = 0. wa_rfq-name1 = wa_lfa1-name1. wa_rfq-land1 = wa_lfa1-land1. wa_rfq-ort01 = wa_lfa1-ort01. endif.

read table it_konh into wa_konh with key ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp.

if sy-subrc = 0. read table it_konh1 into wa_konh1 with key vakey = wa_konh-vakey. if sy-subrc = 0. wa_rfq-knumh = wa_konh1-knumh. endif. wa_rfq-ebelp wa_rfq-matnr wa_rfq-txz01 wa_rfq-ktmng wa_rfq-meins wa_rfq-netpr wa_rfq-mwskz wa_rfq-agmem wa_rfq-banfn endif. append wa_rfq to it_rfq. clear: wa_rfq,wa_ekpo,wa_lfa1,wa_ekko. endloop. = = = = = = = = = wa_ekpo-ebelp. wa_ekpo-matnr. wa_ekpo-txz01. wa_ekpo-ktmng. wa_ekpo-meins. wa_ekpo-netpr. wa_ekpo-mwskz. wa_ekpo-agmem. wa_ekpo-banfn.

if it_rfq[] is not initial. select kschl mwskz aland knumh from a003 into table it_a003 for all entries in it_rfq where mwskz = it_rfq-mwskz and aland = it_rfq-land1. endif. if it_a003[] is not initial. select knumh kschl kbetr mwsk1 from konp into table it_konp for all entries in it_a003 where knumh = it_a003-knumh and kschl = it_a003-kschl and mwsk1 = it_a003-mwskz. endif. endif. endform. " get_data

*&---------------------------------------------------------------------* *& Form calculate *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form calculate . data: a type p length 4 decimals 3, b type p length 4 decimals 3,

c d e f g z

type type type type type type

p p p p p p

length length length length length length

4 4 4 4 4 4

decimals decimals decimals decimals decimals decimals

3, 3, 3, 3, 3, 3.

loop at it_konp into wa_konp. if wa_konp-kschl = 'JAO1'. a = wa_konp-kbetr. z = '1.00'. if a = '0.00'. z = '0.00'. endif. elseif wa_konp-kschl = 'JMO1'. z = '0.00'. elseif wa_konp-kschl = 'JEC1'. c = a + wa_konp-kbetr. d = c / 10000. elseif wa_konp-kschl = 'JIP1'. e = wa_konp-kbetr / 1000. elseif wa_konp-kschl = 'JIP2'. f = wa_konp-kbetr / 1000. if f = '0.00'. else. g = '0.7'. endif. elseif wa_konp-kschl = 'JIP5'. f = wa_konp-kbetr / 1000. g = '0.7'. elseif wa_konp-kschl = 'JIP6'. f = wa_konp-kbetr / 1000. g = '0.00'. endif. wa_tax-mwskz wa_tax-ed wa_tax-edc wa_tax-cst wa_tax-vat wa_tax-vatc = = = = = = wa_konp-mwsk1. d. z. e. f. g. " Ed alone and ed credit

" NO ED CREDIT " ED + cess

" CST cenvat

" VAT modvat

" VAT modvat

" VAT credit

collect wa_tax into it_tax. clear: z,d,e,f,g.

endloop. endform.

" calculate

*&---------------------------------------------------------------------* *& Form calculation1 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form calculation1 . data: a b c d e type type type type type p p p p p length length length length length 4 4 4 4 4 decimals decimals decimals decimals decimals 3, 3, 3, 3, 3.

data:

tpb00 tpbxx tr000 tr001 tr002 tzpf tjexc tjexs tnavs tzoth tzins tzhan tzfvl tzfrv tzfrt tzfrp tzent tzfrl

type type type type type type type type type type type type type type type type type type

kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr, kbetr.

data:

tsubtotal1 type bprei, tothers1 type bprei, tsubtotal2 type bprei, ted type bprei, tsubtotal3 type bprei, tothers2 type bprei, tvat type bprei, tcst type bprei, tsubtotal4 type bprei, tcenvat type bprei, tmodvat type bprei, tgrand type bprei, tpayment type bprei, ttransport type bprei, tothers3 type bprei, tlandcost type bprei, tlandper type bprei, tsubtotal11 type bprei, tsubtotal12 type bprei, tsubtotal13 type bprei, tsubtotal14 type bprei, tsubtotal15 type bprei, tsubtotal16 type bprei, temp_fri type bprei,

frieght type bprei, quan type bprei, quan1 type bprei, quan2 type bprei, quan3 type bprei.

loop at it_rfq into wa_rfq where mwskz = '' or netpr eq '0.00'. wa_reject-ebeln wa_reject-ebelp wa_reject-matnr wa_reject-lifnr = = = = wa_rfq-ebeln. wa_rfq-ebelp. wa_rfq-matnr. wa_rfq-lifnr.

append wa_reject to it_reject. endloop. delete it_rfq where mwskz = ''. DELETE IT_RFQ WHERE NETPR = '0.00'.

loop at it_rfq into wa_rfq. read table it_tax into wa_tax with key mwskz = wa_rfq-mwskz. if sy-subrc = 0. a = wa_tax-ed. b = wa_tax-edc. c = wa_tax-cst. d = wa_tax-vat. e = wa_tax-vatc. wa_final-mwskz = wa_tax-mwskz. endif.

loop at it_konp1 into wa_konp1 where knumh = wa_rfq-knumh. if wa_konp1-kschl = 'PB00'. tpb00 = wa_konp1-kbetr. elseif wa_konp1-kschl = 'PBXX'. tpbxx = wa_konp1-kbetr * wa_konp1-kpein. elseif wa_konp1-kschl = 'R001'. tr001 = wa_konp1-kbetr. quan1 = wa_konp1-kpein. tr001 = tr001 / quan1. tr001 = tr001 * wa_rfq-ktmng. elseif wa_konp1-kschl = 'R002'. tr002 = wa_konp1-kbetr. elseif wa_konp1-kschl = 'R000'. tr000 = wa_konp1-kbetr / 1000 . tr000 = tr000 * wa_rfq-ktmng. elseif wa_konp1-kschl = 'ZP&F'. tzpf = wa_konp1-kbetr / 1000. elseif wa_konp1-kschl = 'JEXC'. tjexc = wa_konp1-kbetr. elseif wa_konp1-kschl = 'JEXS'. tjexs = wa_konp1-kbetr. elseif wa_konp1-kschl = 'NAVS'. tnavs = wa_konp1-kbetr. elseif wa_konp1-kschl = 'ZOTH'.

tzoth = wa_konp1-kbetr. quan = wa_konp1-kpein. tzoth = tzoth / quan. tzoth = tzoth * wa_rfq-ktmng. elseif wa_konp1-kschl = 'ZINS'. tzins = wa_konp1-kbetr / 1000. elseif wa_konp1-kschl = 'ZHAN'. tzhan = wa_konp1-kbetr. elseif wa_konp1-kschl = 'ZFVL'. tzfvl = wa_konp1-kbetr. elseif wa_konp1-kschl = 'ZFRV'. tzfrv = wa_konp1-kbetr. elseif wa_konp1-kschl = 'ZFRT'. tzfrt = wa_konp1-kbetr. quan3 = wa_konp1-kpein. tzfrt = tzfrt / quan3. elseif wa_konp1-kschl = 'ZFRP'. tzfrp = wa_konp1-kbetr / 1000. elseif wa_konp1-kschl = 'ZENT'. tzent = wa_konp1-kbetr / 1000. elseif wa_konp1-kschl = 'ZFRL'. tzfrl = wa_konp1-kbetr. quan2 = wa_konp1-kpein. tzfrl = tzfrl / quan2. endif. endloop. *** ************ frieght = ( tzfrl * wa_rfq-ktmng ) + ( tzfrt * wa_rfq-ktmng ) + tzfvl.

**************** tsubtotal1 = wa_rfq-ktmng * tpb00. tsubtotal15 = tsubtotal1 * tzpf. tsubtotal2 = tsubtotal1 + tsubtotal15. " ed " pf

" subtotal1

" subtotal2

ted = tsubtotal2 * a. tsubtotal3 = ted + tsubtotal2. tvat = tsubtotal3 * d. tsubtotal11 = tsubtotal3 + tvat. tcst = tsubtotal11 * c. tsubtotal12 = tsubtotal11 + tcst. tsubtotal4 = tsubtotal12.

****************** tcenvat = ted * b. tsubtotal13 = tsubtotal4 - tcenvat. tmodvat = tvat * e. tsubtotal14 = tsubtotal13 - tmodvat. temp_fri = frieght. " frieght charges

tsubtotal16 = tsubtotal14 + temp_fri + tzoth.

tgrand

= tsubtotal16.

" grand total

wa_final-discount = tr001 + tr000.

wa_final-ebeln = wa_rfq-ebeln. wa_final-ebelp = wa_rfq-ebelp. wa_final-lifnr = wa_rfq-lifnr. wa_final-matnr = wa_rfq-matnr. wa_final-name1 = wa_rfq-name1. wa_final-land1 = wa_rfq-land1. wa_final-zterm = wa_rfq-zterm. wa_final-zbd1t = wa_rfq-zbd1t. wa_final-inco1 = wa_rfq-inco1. wa_final-txz01 = wa_rfq-txz01. wa_final-ktmng = wa_rfq-ktmng. wa_final-meins = wa_rfq-meins. wa_final-netpr = tpb00. wa_final-mwskz = wa_rfq-mwskz. wa_final-agmem = wa_rfq-agmem. wa_final-knumh = wa_rfq-knumh. wa_final-waers = wa_rfq-waers. ******** wa_final-subtotal1 = tsubtotal1 . wa_final-others1 = tsubtotal15. wa_final-subtotal2 = tsubtotal2. wa_final-ed = ted. wa_final-subtotal3 = tsubtotal3. * wa_final-others2 =. * wa_final-subtotal5 = wa_final-subtotal3 + wa_final-others2. wa_final-vat = tvat. wa_final-cst = tcst. wa_final-subtotal4 = tsubtotal4. wa_final-cenvat = tcenvat. wa_final-modvat = tmodvat. wa_final-grand = tsubtotal14. * wa_final-payment =. wa_final-transport = temp_fri. wa_final-others3 = tzoth. wa_final-subtotal5 = tsubtotal4 + temp_fri + tzoth. wa_final-landcost = tgrand + wa_final-discount. wa_final-landper = wa_final-landcost / wa_rfq-ktmng.

select ebeln netpr aedat from ekpo into (wa_final-lastpo, wa_final-netpr1, wa_finalaedat1) where matnr = wa_final-matnr and bstyp = 'F' and aedat < sy-datum order by aedat ascending. endselect. select single lifnr from ekko into (wa_final-lifnr1) where ebeln = wa_final-lastpo.

append wa_final to it_final. clear: frieght,tzfrl,tzoth,tzfrt,quan,quan1,tr001,tzpf,quan2,quan3,tr000,tpb00. endloop. endform. " calculation1

*&---------------------------------------------------------------------* *& Form split *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form split . loop at it_final into wa_final. wa_indiv-ebeln = wa_final-ebeln. wa_indiv-ebelp = wa_final-ebelp. wa_indiv-matnr = wa_final-matnr. wa_indiv-landper = wa_final-landper. append wa_indiv to it_indiv. wa_over-ebeln = wa_final-ebeln. wa_over-landcost = wa_final-landcost. collect wa_over into it_over. clear: wa_final. endloop. move it_indiv[] to it_indiv1[]. move it_over[] to it_over1[]. endform. " split

*&---------------------------------------------------------------------* *& Form individual_rank *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form individual_rank . data: temp_lc type bwert, temp_r(3) type c, count(2) type n value 1, count1(2) type n value 1, count2(2) type n value 1, i(2) type n value 0, x(3) type c.

delete it_indiv1 where landper = ''. sort it_ekpo by matnr. sort it_indiv1 by matnr landper. delete adjacent duplicates from it_ekpo comparing matnr.

loop at it_ekpo into wa_ekpo.

loop at it_indiv1 into wa_indiv1 where matnr = wa_ekpo-matnr. on change of wa_ekpo-matnr. wa_indiv1-rank = 'L1'. temp_lc = wa_indiv1-landper. temp_r = 'L1'. modify it_indiv1 from wa_indiv1 transporting rank. count = 1. endon. if wa_indiv1-rank eq ''. if wa_indiv1-landper = temp_lc. wa_indiv1-rank = temp_r. temp_r = wa_indiv1-rank. temp_lc = wa_indiv1-landper. else. count = count + 1. concatenate 'L' count into x. wa_indiv1-rank = x. temp_r = wa_indiv1-rank. temp_lc = wa_indiv1-landper. endif. modify it_indiv1 from wa_indiv1 transporting rank. endif. at last. clear:count. endat. endloop. clear: temp_r,temp_lc,wa_indiv1. endloop.

loop at it_indiv1 into wa_indiv1. if wa_indiv1-rank = 'L02'. wa_indiv1-rank = 'L2'. elseif wa_indiv1-rank = 'L03'. wa_indiv1-rank = 'L3'. elseif wa_indiv1-rank = 'L04'. wa_indiv1-rank = 'L4'. elseif wa_indiv1-rank = 'L05'. wa_indiv1-rank = 'L5'. elseif wa_indiv1-rank = 'L06'. wa_indiv1-rank = 'L6'. elseif wa_indiv1-rank = 'L07'. wa_indiv1-rank = 'L7'.

elseif wa_indiv1-rank = 'L08'. wa_indiv1-rank = 'L8'. elseif wa_indiv1-rank = 'L09'. wa_indiv1-rank = 'L9'. endif. modify it_indiv1 from wa_indiv1. endloop. endform. " individual_rank

*&---------------------------------------------------------------------* *& Form overall *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form overall .

data:

temp_lc type bwert, temp_r(3) type c, count(2) type n value 1, x(3) type c.

delete it_over1 where landcost = ''. sort it_over1 by landcost. loop at it_over1 into wa_over1 where rank eq ' '. if wa_over1-landcost ne ''. at first. wa_over1-rank = 'L1'. temp_lc = wa_over1-landcost. temp_r = 'L1'. modify it_over1 from wa_over1 transporting rank. endat.

if sy-tabix = 1. read table it_over1 into wa_over1 index 1. temp_lc = wa_over1-landcost. endif. if wa_over1-rank eq ''. if wa_over1-landcost = temp_lc. wa_over1-rank = temp_r. temp_r = wa_over1-rank. temp_lc = wa_over1-landcost. else. count = count + 1. concatenate 'L' count into x. wa_over1-rank = x. temp_r = wa_over1-rank. temp_lc = wa_over1-landcost. endif. modify it_over1 from wa_over1 transporting rank. endif.

endif. endloop.

************************************************************** loop at it_over1 into wa_over1. if wa_over1-rank = 'L02'. wa_over1-rank = 'L2'. elseif wa_over1-rank = 'L03'. wa_over1-rank = 'L3'. elseif wa_over1-rank = 'L04'. wa_over1-rank = 'L4'. elseif wa_over1-rank = 'L05'. wa_over1-rank = 'L5'. elseif wa_over1-rank = 'L06'. wa_over1-rank = 'L6'. elseif wa_over1-rank = 'L07'. wa_over1-rank = 'L7'. elseif wa_over1-rank = 'L08'. wa_over1-rank = 'L8'. elseif wa_over1-rank = 'L09'. wa_over1-rank = 'L9'. endif. modify it_over1 from wa_over1. endloop. *************************************************************** endform. " overall

*&---------------------------------------------------------------------* *& Form FILL_OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form fill_output . loop at it_final into wa_final. wa_output1-ebeln = wa_final-ebeln . wa_output1-ebelp = wa_final-ebelp. wa_output1-lifnr = wa_final-lifnr . wa_output1-name1 = wa_final-name1. wa_output1-matnr = wa_final-matnr. wa_output1-netpr = wa_final-netpr. wa_output1-mwskz = wa_final-mwskz. wa_output1-subtotal1 = wa_final-subtotal1. wa_output1-others1 = wa_final-others1. wa_output1-subtotal2 = wa_final-subtotal2. wa_output1-ed = wa_final-ed. wa_output1-subtotal3 = wa_final-subtotal3 . wa_output1-others2 = wa_final-others2. wa_output1-subtotal5 = wa_final-subtotal5 . wa_output1-vat = wa_final-vat. wa_output1-cst = wa_final-cst.

wa_output1-subtotal4 = wa_final-subtotal4 . wa_output1-cenvat = wa_final-cenvat. wa_output1-modvat = wa_final-modvat. wa_output1-grand = wa_final-grand. wa_output1-payment = wa_final-payment. wa_output1-transport = wa_final-transport. wa_output1-others3 = wa_final-others3. wa_output1-landcost = wa_final-landcost. wa_output1-landper = wa_final-landper . wa_output1-lastpo = wa_final-lastpo. wa_output1-netpr1 = wa_final-netpr1. wa_output1-aedat1 = wa_final-aedat1. wa_output1-lifnr1 = wa_final-lifnr1. wa_output1-discount = wa_final-discount. read table it_indiv1 into wa_indiv1 with key ebeln = wa_final-ebeln ebelp = wa_final-ebelp. if sy-subrc = 0. wa_output1-rank = wa_indiv1-rank. endif. append wa_output1 to it_output1. endloop.

loop at it_final into wa_final. wa_output2-ebeln = wa_final-ebeln. wa_output2-ebelp = wa_final-ebelp. wa_output2-matnr = wa_final-matnr. wa_output2-lifnr = wa_final-lifnr. wa_output2-landcost = wa_final-landcost. append wa_output2 to it_output2. endloop. endform. " FILL_OUTPUT

*&---------------------------------------------------------------------* *& Form header *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form header .

read table it_ekpo into wa_ekpo index 1. write : /7 'BHEL-EPD BANGALORE', 60 'COMPARATIVE STATEMENT', 82 'DATED', 88 sy-datum ,

99 'FOR PR' , 106 wa_ekpo-banfn. skip 1. endform. " header

*&---------------------------------------------------------------------* *& Form print_quotaion_summary *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form print_quotaion_summary .

write : /7'QUOTATION DETAILS'. it_rfqt[] = it_rfq[]. sort it_rfq by lifnr. delete adjacent duplicates from it_rfq comparing lifnr.

loop at it_rfq into wa_rfq. at first. write : /7 sy-vline. uline 7(168). write : 175 sy-vline. write : /7 sy-vline, 10 'VENDOR', 21 'VENDOR NAME', 57 'PLACE', 73 'QUOTATION', 84 'QUOTATION', 95 'PAYMENT TERMS', 139 'INCO TERMS', 164 'BINDING', 175 sy-vline. write : /7 sy-vline, 73 'NUMBER', 84 'DATE', 164 'DATE', 175 sy-vline. write : /7 sy-vline. uline 7(168). write : 175 sy-vline. endat. write : /7 sy-vline, 10 wa_rfq-lifnr, 21 wa_rfq-name1+0(30), 57 wa_rfq-ort01+0(15), 73 wa_rfq-angnr, 84 wa_rfq-ihran, 95 wa_rfq-zterm, 100 wa_rfq-text1+0(38), 139 wa_rfq-inco1, 143 wa_rfq-inco2+0(20),

164 wa_rfq-bnddt, 175 sy-vline. if wa_rfq-ort01+15(20) <> '' or wa_rfq-text1+38(12) <> '' or wa_rfq-inco2+20(8) <> ''. write : /7 sy-vline, 57 wa_rfq-ort01+15(20), 100 wa_rfq-text1+38(12), 143 wa_rfq-inco2+20(8), 175 sy-vline. endif. at last. write : /7 sy-vline. uline 7(168). write : 175 sy-vline. endat. endloop. endform. " print_quotaion_summary

*&---------------------------------------------------------------------* *& Form PRINT_ITEMWISE_L1_LIST *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form print_itemwise_l1_list .

skip 1. write : /7 'LIST OF ITEMS WITH ITEMWISE L1 RATES & RFQ NUMBER'. write: /7 'ITEM', 15 'MATERIAL', 36 'DESCRIPTION', 86 'QUANTITY', 100 'UNITS', 115 'PRICE' , 125 'CURRENCY', 140 'RFQ NUMBER'. sort it_indiv1 by ebeln ebelp. loop at it_indiv1 into wa_indiv1 where rank = 'L1'. loop at it_rfqt into wa_rfqt where matnr = wa_indiv1-matnr and ebeln = wa_indiv1-ebeln and ebelp = wa_indiv1-ebelp. write : /7 15 36 77 100 110 125 140 endloop. endloop. wa_indiv1-ebelp, wa_indiv1-matnr, wa_rfqt-txz01, wa_rfqt-ktmng , wa_rfqt-meins , wa_indiv1-landper, wa_rfqt-waers, wa_indiv1-ebeln.

endform.

" PRINT_ITEMWISE_L1_LIST

*&---------------------------------------------------------------------* *& Form PRINT_ITEMS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form print_items . skip 2. write:/7 'PRICE SUMMARY:'. skip. it_output_temp[] = it_output1[]. sort it_output_temp by ebelp. delete adjacent duplicates from it_output_temp comparing ebelp.

loop at it_output1 into wa_output1. if wa_output1-netpr = 0. wa_output1-rank = ''. modify it_output1 from wa_output1. endif.

endloop.

loop at it_output_temp into wa_output_temp. new-page. on change of wa_output_temp-ebelp. skip 1. endon.

write:/9 'RFQ NUMBER

:'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write:wa_output1-ebeln,sy-vline. endloop. write:/9 'ITEM :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write:wa_output1-ebelp,sy-vline. endloop. write:/9 'MATERIAL :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. shift wa_output1-matnr left deleting leading '0'. write:wa_output1-matnr(15),sy-vline. endloop.

write:/9 'VENDOR

:'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. shift wa_output1-lifnr left deleting leading '0'. write:wa_output1-lifnr(15),sy-vline. endloop. write:/9 'NAME :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-name1,sy-vline. endloop. write:/9 'BASIC PRICE :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write:wa_output1-netpr,sy-vline. endloop.

write:/9 'SUBTOTAL 1

:'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-subtotal1,sy-vline. endloop. write:/9 'OTHERS 1 :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-others1,sy-vline. endloop. write:/9 'SUBTOTAL 2 :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-subtotal2,sy-vline. endloop. write:/9 'EXCISE DUTY :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-ed,sy-vline. endloop. * * * * * * * * write:/9 'SUBTOTAL 3 :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-subtotal3,sy-vline. endloop. write:/9 'OTHERS 2 :'.

* * *

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-others2,sy-vline. endloop. write:/9 'SUBTOTAL 3 :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-subtotal3,sy-vline. endloop.

write:/9 'VAT

:'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-vat,sy-vline. endloop. write:/9 'CST :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-cst,sy-vline. endloop. write:/9 'SUBTOTAL 4 :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-subtotal4,sy-vline. endloop.

* * * * *

write:/9 'GRAND

:'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-grand,sy-vline. endloop. write:/9 'PAY TERM LOAD:'. loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-payment,sy-vline. endloop. write:/9 'TRANSPORT :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-transport,sy-vline. endloop. write:/9 'OTHERS3 :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-others3,sy-vline. endloop.

write:/9 'SUBTOTAL 5

:'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-subtotal5,sy-vline. endloop.

write:/9 'MODVAT

(-) :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-cenvat,sy-vline. endloop. write:/9 'CENVAT (-) :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-modvat,sy-vline. endloop. write:/9 'DISCOUNT (-) :'. loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write:wa_output1-discount,sy-vline. endloop. write:/9 'LANDING COST :'. loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-landcost,sy-vline. endloop. write:/9 'LC PER UNIT :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-landper,sy-vline. endloop. write:/9 'RANK :'.

loop at it_output1 into wa_output1 where ebelp = wa_output_temp-ebelp. write: wa_output1-rank,sy-vline. clear: wa_output1-rank. endloop. skip 2. shift wa_output_temp-matnr left deleting leading '0'. write:/7 'LAST PLACED PO FOR MATERIAL:',wa_output_temp-matnr. write:/9 'PO NO-',wa_output_temp-lastpo,'PRICE-',wa_output_temp-netpr1, 'ON VENDOR',wa_output_temp-lifnr1,'DATED',wa_output_temp-aedat1.

on change of sy-pagno. write:/ sy-uline. endon. endloop.

endform.

" PRINT_ITEMS

*&---------------------------------------------------------------------* *& Form PRINT_OVERALL_L1_LIST *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form print_overall_l1_list . skip 1. write : /7 'LIST OF OVERALL L1 RATES & RFQ NUMBER'. skip 1. write: /7 'RFQ NUMBER', 35 'NETPRICE'. loop at it_over1 into wa_over1 where rank = 'L1'. write:/7 wa_over1-ebeln, 30 wa_over1-landcost.

endloop. endform. " PRINT_OVERALL_L1_LIST

*&---------------------------------------------------------------------* *& Form DISPLY_ALL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form disply_all .

skip 2. write:/7 'RFQ OVER ALL DETAILS'. skip 1. write:/7 'VENDOR NUMBER data: temp_material(18), temp_item(15). * sort it_output2 descending by landcost. loop at it_output2 into wa_output2. shift wa_output2-lifnr left deleting leading '0'. on change of wa_output2-lifnr. write: wa_output2-lifnr. endon. endloop. '.

uline. skip 1. write:/7 'ITEM ',25 'MATERIAL'.

read table it_output2 into wa_output2 with key ebelp = '00010'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost.

endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00020'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00030'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00040'.

if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00050'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00060'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00070'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and

matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00080'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00090'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. read table it_output2 into wa_output2 with key ebelp = '00100'. if sy-subrc = 0. temp_material = wa_output2-matnr. temp_item = wa_output2-ebelp. shift wa_output2-ebelp left deleting leading '0'. shift wa_output2-matnr left deleting leading '0'.

write:/7 wa_output2-ebelp,'-'. write: wa_output2-matnr. loop at it_output2 into wa_output2 where ebelp = temp_item and matnr = temp_material. write: wa_output2-landcost. endloop. endif. write:/ sy-uline. write:/ '

OVER ALL LANDING COST

'.

loop at it_over1 into wa_over1. wa_over2-ebeln = wa_over1-ebeln. wa_over2-landcost = wa_over1-landcost. wa_over2-rank = wa_over1-rank. append wa_over2 to it_over2. endloop.

sort it_over2 by ebeln. loop at it_over2 into wa_over2. write: wa_over2-landcost. endloop. write:/ sy-uline. write:/ ' '. skip 3. write:/3 'MATERIAL DESCRIPTIONS '. skip 1. loop at it_final into wa_final where ebeln = purno. write:/ ' '. write: wa_final-matnr,wa_final-txz01. endloop.

* skip 6. * uline. * write :/7 'PAGE',12 sy-pagno,30 'PREPARED BY', 55 'APPROVED BY', 80 'ENDORSED BY', 105 'PRINTED ON:',113 sy-datum.

endform.

" DISPLY_ALL

You might also like