Go on link..

link us with ...

Thursday, December 30, 2010

Purchase and Brokerage report in MM

*&---------------------------------------------------------------------*
*& Report ZVVF_MMRO_PURCHASE_COND_REPORT *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
*=====================================================================*
* Report : Purchase and Brokerage report
* Purpose : User gives in a date range. Report is generated showing PO
* no, Date, Item, Material, Net Price and quantity.
*======================================================================*

REPORT ZVVF_MMRO_PURCHASE_COND_REPORT
no standard page heading
line-size 1023.

tables: ekko, " Purchasing Document Header
ekpo, " Purchasing Document Item
ekbe, "#EC * " History per Purchasing Document
konv, "#EC * " Conditions (Transaction Data)c
makt, "#EC * " Material Descriptions
lfa1, "#EC * " Vendor Master (General Section)
t685t, "#EC * " Conditions: Types: Texts
cdhdr, "#EC * " Change document header
t001w. "#EC * " Plants/Branches

*========================= DATA DECLARATION ===========================*
*-----------
* Main Table
*-----------
data: begin of ttemp occurs 0,
ebeln like ekpo-ebeln, " Purchasing document number
kposn like konv-kposn, " Condition item number
kschl like konv-kschl, " Condition type
kwert like konv-kwert, " Condition value
kbetr like konv-kbetr, " Rate (condition amount or %)
ebelp like ekpo-ebelp, " Item number of purchasing doc
bedat like ekko-bedat, " Purchasing document date
matnr like ekpo-matnr, " Material number
netpr like ekpo-netpr, " Net price in purchasing doc
netpr2 like ekpo-netpr, " Net price in purchasing doc
menge like ekpo-menge, " Purchase order quantity
reswk like ekko-reswk, " Supplying plant in case of STO
knumv like ekko-knumv, " Number of the doc condition
lifnr like ekko-lifnr, " Vendor's account number
maktx like makt-maktx, " Material description
name1 like lfa1-name1, " Vendor Name 1
ernam like ekko-ernam, " Person who Created Object
meins like ekpo-meins, " Order unit
netwr like ekpo-netwr, " Net order value in PO currency
bprme like ekpo-bprme, " Order price unit (purchasing)
peinh like ekpo-peinh, " Price unit
txz01 like ekpo-txz01, " Short text
bpumz like ekpo-bpumz, " Conversion Numerator
bpumn like ekpo-bpumn, " Conversion Denominator
username like cdhdr-username, " User responsible in change doc
werks like ekpo-werks, " Plant
name2 like t001w-name1, " Plant Name
ekorg like ekko-ekorg, " Purchasing organization
ekotx like t024e-ekotx, " Description of purch orgn
ekgrp like ekko-ekgrp, " Purchasing group
eknam like t024-eknam, " Description of purch group
bsart like ekko-bsart, " Purchasing document type
batxt like t161t-batxt, " Description of purch doc type
matkl like ekpo-matkl, " Material group
wgbez like t023t-wgbez, " Description of material group
mwskz like ekpo-mwskz, " Tax code
text1 like t007s-text1, " Tax Code Des
end of ttemp.
data: temp like ttemp occurs 0 with header line, " Final list display
temp_line like line of temp. " Temporary storing

*-----------------------------------------------
* Gets conditions, etc from cluster table 'konv'
*-----------------------------------------------
data: begin of temp_konv occurs 0,
kwert like konv-kwert, " Condition value
knumv like konv-knumv, " Number of the doc condition
kbetr like konv-kbetr, " Rate (condition amount or %)
kschl like konv-kschl, " Condition type
kposn like konv-kposn, " Condition item number
lifnr like konv-lifnr, " Account number of vendor/creditor
end of temp_konv.

*---------------------------------------
* For the person who last changed the PO
*---------------------------------------
data: begin of cdhdr_tab occurs 0,
objectid like cdhdr-objectid, " Object value
ernam like ekko-ernam, " Person who Created the Object
end of cdhdr_tab.
data: begin of cdhdr2_tab occurs 0,
objectid like cdhdr-objectid, " Object value
* udate LIKE cdhdr-udate, " Creation date of change doc
* utime LIKE cdhdr-utime, " Time changed
changenr like cdhdr-changenr, " Document change number
username like cdhdr-username, " Person resp in change doc
end of cdhdr2_tab.

*---------------------
* Plant and plant name
*---------------------
data: begin of werks_tab occurs 0,
werks like ekpo-werks, " Plant
name2 like t001w-name1, " Plant Name
end of werks_tab.

*-----------------------
* Vendor and vendor name
*-----------------------
data: begin of lifnr_tab occurs 0,
lifnr like ekko-lifnr, " Vendor's account number
name1 like lfa1-name1, " Name
end of lifnr_tab.

*-------------------------------
* Material types and description
*-------------------------------
data: mat_type like t023t occurs 0 with header line.

*-------------------------------
* Tax Code and description
*-------------------------------
data: tax_code like t007s occurs 0 with header line.

*------------------------------------------------
* PO Groups, Type, Organisations with their names
*------------------------------------------------
data: po_group like t024 occurs 0 with header line,
po_orgns like t024e occurs 0 with header line,
po_types like t161t occurs 0 with header line.

*----------------------------------------------
* Contains unique conditions (kschl) for matrix
*----------------------------------------------
data: begin of head_temp occurs 0, " Tables for list manipulation
kschl like konv-kschl, " Condition type
vtext like t685t-vtext, " Condition Name
end of head_temp.

*-----------------------------------------------------------
* Each Condition and their values w.r.t different docu types
*-----------------------------------------------------------
data: begin of temp_head occurs 0,
kschl like konv-kschl, " Condition type
kwert like konv-kwert, " Condition value
end of temp_head.

*------------------------------------------
* Table for storing Goods Receipts Quantity
*------------------------------------------
data: begin of i_gr_qty occurs 0,
ebeln like ekbe-ebeln, " Purchasing document number
ebelp like ekbe-ebelp, " Item number of purchasing document
menge like ekbe-menge, " Quantity (GR)
shkzg like ekbe-shkzg, " Debit/credit indicator
end of i_gr_qty.

data: w_spacing type i value 20. " For kschl-list generation

*------------------
* Counter variables
*------------------
data: w_toggle type i value 1,
w_tempc type i value 0,
w_count type i value 0,
w_here type i value 0,
w_last type i value 0,
w_newline type i value 0. "#EC *

*-------------------------------------------
* Entries found in different internal tables
*-------------------------------------------
data: w_entries_t type i value 0,
w_entries_ht type i value 0,
w_entries_tt type i value 0,
w_entries_tk type i value 0.

*----------------------------------------------
* kschl temporary storing - For SUM calculation
*----------------------------------------------
data: w_tkwert type p decimals 2 value 0,
grmenge like ekpo-menge,
w_tot_kwert type p decimals 2 value 0,
w_tmp_kwert type p decimals 2 value 0,
w_finalsum type p decimals 2 value 0, "#EC *
w_finalrate type p decimals 4 value 0. "#EC *

*----------------------------------------
* Columns for list-matrix dynamic spacing
*----------------------------------------
data: w_cols type p decimals 2 value 0,
w_v type c value '|'.

*------------------------------------------
* Gives positions on items in a typical row
*------------------------------------------
data: begin of lr occurs 1, "#EC *
ebeln type i value 2, "10
kposn type i value 13, "6
netpr type i value 20, "12
meins type i value 33, "5
menge type i value 39, "13
grmenge type i value 53, "13

bedat type i value 67, "10
knumv type i value 78, "10
ernam type i value 89, "12
username type i value 102, "12

werks type i value 115, "5
name2 type i value 121, "30
matnr type i value 152, "8
txz01 type i value 161, "40
lifnr type i value 202, "6
name1 type i value 209, "35

ekorg type i value 245, "5
ekotx type i value 251, "20
ekgrp type i value 272, "5
eknam type i value 278, "20
bsart type i value 299, "5
batxt type i value 305, "20

matkl type i value 326, "9
wgbez type i value 336, "20
mwskz type i value 357, "4
d_mwskz type i value 362, "10
w_start type i value 373, "5

* maktx TYPE i VALUE 1, "40
* netpr2 type i value 1, "12
* reswk type i value 1,
* netwr type i value 1,
* bprme type i value 1,
* peinh type i value 1,
* bpumz type i value 1,
* bpumn type i value 1,
* kschl type i value 1,
* kwert type i value 1,
* kbetr type i value 1,
* ebelp type i value 1,
end of lr.

*-----------------------------------------
* Position on vertical lines in a list row
*-----------------------------------------
data: begin of v_lines occurs 1, "#EC *
ebeln type i value 1, "10
kposn type i value 12, "6
netpr type i value 19, "12
meins type i value 32, "5
menge type i value 38, "13
grmenge type i value 52, "13

bedat type i value 66, "10
knumv type i value 77, "10
ernam type i value 88, "12
username type i value 101, "12

werks type i value 114, "5
name2 type i value 120, "30
matnr type i value 151, "8
txz01 type i value 160, "40
lifnr type i value 201, "6
name1 type i value 208, "35

ekorg type i value 244, "5
ekotx type i value 250, "20
ekgrp type i value 271, "5
eknam type i value 277, "20
bsart type i value 298, "5
batxt type i value 304, "20

matkl type i value 325, "9
wgbez type i value 335, "20
mwskz type i value 356, "4
d_mwskz type i value 361, "10

w_start type i value 372, "5

* maktx TYPE i VALUE 1, "40
* netpr2 type i value 1, "12
* reswk type i value 1,
* netwr type i value 1,
* bprme type i value 1,
* peinh type i value 1,
* bpumz type i value 1,
* bpumn type i value 1,
* kschl type i value 1,
* kwert type i value 1,
* kbetr type i value 1,
* ebelp type i value 1,
end of v_lines.

ranges: r_loekz for ekko-loekz. " Deletion Indicator
* r_elikz FOR ekpo-elikz. " "Delivery completed" indicator

*========================= SELECTION SCREEN ===========================*
selection-screen: skip 1,
comment 35(35) text-000,
begin of block b1 with frame title text-001.
parameter : p_bukrs like ekko-bukrs obligatory.
select-options: s_bedat for ekko-bedat obligatory ,
s_ebeln for ekko-ebeln,
s_kschl for konv-kschl,
s_matnr for ekpo-matnr,
s_lifnr for ekko-lifnr,
s_mwskz for ekpo-mwskz,
s_werks for ekpo-werks.
selection-screen skip 1.
select-options: s_matkl for ekpo-matkl.

selection-screen: skip 1,
begin of block b2 with frame title text-002.
select-options: s_ekorg for ekko-ekorg,
s_ekgrp for ekko-ekgrp.
selection-screen: end of block b2,
skip 1.
parameters: p_value as checkbox default 'X',
p_change as checkbox.
*--- Deleted/UnDeleted/All Purchase Orders
selection-screen: skip,
begin of line,
comment (15) text-003.
parameters: p_all radiobutton group del.
selection-screen comment 25(9) for field p_all.
parameters: p_del radiobutton group del.
selection-screen comment 45(12) for field p_del.
parameters: p_undel radiobutton group del default 'X'.
selection-screen comment 65(14) for field p_undel.
selection-screen end of line.
selection-screen end of block b1.

*============================== # MAIN # ==============================*
top-of-page.
perform header. " Writes the header on the list.
perform po_header. " Dynamic header using all kschl.

start-of-selection.
perform initialize.
perform pop_ttemp. " Populates ttemp Internal Table.
perform pop_other_tabs.
perform pop_temp_konv. " Populates temp_konv.
perform gr_quantity.

end-of-selection.
perform merge. " Merges ttemp and temp_konv data.
if p_value = 'X'.
delete temp where kwert = 0.
endif.
describe table temp lines w_entries_t. " Gives no. of lines in temp.
perform list.
perform footer.
set left scroll-boundary column 53.

*=============================== FORMS ================================*
*--------------
form pop_ttemp.
*--------------
select *
into corresponding fields of table ttemp
from ekpo as a
inner join ekko as b on a~ebeln = b~ebeln
where b~bedat in s_bedat and
b~ebeln in s_ebeln and
b~lifnr in s_lifnr and
a~matnr in s_matnr and
a~werks in s_werks and
a~bukrs eq p_bukrs and
a~matkl in s_matkl and
b~ekorg in s_ekorg and
b~ekgrp in s_ekgrp and
a~mwskz in s_mwskz and
a~loekz in r_loekz and
*--- Meaning that PO is released
( b~frgke = 'Z' or b~frgrl <> 'X' ).
describe table ttemp lines w_entries_tt.
if w_entries_tt = 0.
perform quit.
endif.
loop at ttemp.
ttemp-kposn = ttemp-ebelp.
if ttemp-lifnr eq space.
werks_tab-werks = ttemp-reswk. append werks_tab to werks_tab.
else.
lifnr_tab-lifnr = ttemp-lifnr. append lifnr_tab to lifnr_tab.
endif.
werks_tab-werks = ttemp-werks. append werks_tab to werks_tab.
cdhdr_tab-objectid = ttemp-ebeln. cdhdr_tab-ernam = ttemp-ernam.
append cdhdr_tab to cdhdr_tab.
modify ttemp. clear ttemp.
endloop.
endform.

*----------------
form gr_quantity.
*----------------
select ebeln ebelp menge shkzg
from ekbe
into corresponding fields of table i_gr_qty
for all entries in ttemp
where ebeln = ttemp-ebeln and
ebelp = ttemp-ebelp and
vgabe = 1.
*--- Negate where Debit/credit indicator(shkzg) is 'H' - Credit
loop at i_gr_qty where shkzg = 'H'.
i_gr_qty-menge = i_gr_qty-menge * -1.
modify: i_gr_qty.
endloop.
endform.

*------------------
form pop_temp_konv.
*------------------
select knumv kwert kbetr kschl kposn lifnr
into corresponding fields of table temp_konv
from konv
for all entries in ttemp
where kschl in s_kschl and
knumv = ttemp-knumv and
kposn = ttemp-kposn.
describe table temp_konv lines w_entries_tk.
if w_entries_tk = 0.
perform quit.
endif.
endform.

*----------
form merge.
*----------
*--- It gives a fast merge instead of just simple 'loop'. If it doesn't
*--- find an entry intemp_konv, it deletes the entry.
sort ttemp by knumv kposn.
sort temp_konv by knumv kposn.
delete ttemp where knumv = 0.
loop at ttemp.
loop at temp_konv.
if temp_konv-knumv = ttemp-knumv and temp_konv-kposn = ttemp-kposn.
ttemp-kwert = temp_konv-kwert.
ttemp-kbetr = temp_konv-kbetr.
ttemp-kschl = temp_konv-kschl.
append ttemp to temp.
delete temp_konv.
else.
if ttemp-knumv > temp_konv-knumv. "#EC PORTABLE
delete temp_konv.
else.
exit.
endif.
endif.
endloop.
endloop.
*--- TEMP
sort temp by ebeln kposn kschl.
loop at temp.
if temp-lifnr eq space.
read table werks_tab with key werks = temp-reswk.
temp-name1 = werks_tab-name2.
temp-lifnr = temp-reswk.
else.
read table lifnr_tab with key lifnr = temp-lifnr.
temp-name1 = lifnr_tab-name1.
endif.

read table werks_tab with key werks = temp-werks.
temp-name2 = werks_tab-name2.
temp-netpr2 = ( temp-netpr / temp-peinh ) *
( temp-bpumz / temp-bpumn ).

read table cdhdr2_tab with key objectid = temp-ebeln.
if sy-subrc = 0.
temp-username = cdhdr2_tab-username.
endif.

read table po_group with key ekgrp = temp-ekgrp.
if sy-subrc = 0.
temp-eknam = po_group-eknam.
endif.

read table po_types with key bsart = temp-bsart.
if sy-subrc = 0.
temp-batxt = po_types-batxt.
endif.

read table po_orgns with key ekorg = temp-ekorg.
if sy-subrc = 0.
temp-ekotx = po_orgns-ekotx.
endif.

read table mat_type with key matkl = temp-matkl.
if sy-subrc = 0.
temp-wgbez = mat_type-wgbez.
endif.

read table tax_code with key mwskz = temp-mwskz.
if sy-subrc = 0.
temp-text1 = tax_code-text1.
endif.

modify temp. clear temp.
endloop.
endform.

*-------------------
form pop_other_tabs.
*-------------------
sort cdhdr_tab by objectid.
delete adjacent duplicates from cdhdr_tab comparing objectid.
if p_change = 'X'.
*--- Get The Change History
loop at cdhdr_tab.
select single objectid max( changenr ) username "#EC *
into (cdhdr2_tab-objectid, cdhdr2_tab-changenr,
cdhdr2_tab-username)
from cdhdr
where objectclas eq 'EINKBELEG' and
objectid eq cdhdr_tab-objectid
group by objectid changenr username.
append cdhdr2_tab.
endloop.
*--- Sort
sort cdhdr2_tab by objectid changenr descending.
delete adjacent duplicates from cdhdr2_tab comparing objectid.
endif.
*--- Plant
sort werks_tab by werks.
delete adjacent duplicates from werks_tab comparing werks.
loop at werks_tab.
select single name1
into (werks_tab-name2)
from t001w
where werks = werks_tab-werks.
modify werks_tab. clear werks_tab.
endloop.
*--- Vendor
sort lifnr_tab by lifnr.
delete adjacent duplicates from lifnr_tab comparing lifnr.
loop at lifnr_tab.
select single name1
into (lifnr_tab-name1)
from lfa1
where lifnr = lifnr_tab-lifnr.
modify lifnr_tab. clear lifnr_tab.
endloop.
*--- PO Group
select *
from t024
into corresponding fields of table po_group.
*--- PO Organisation
select *
from t024e
into corresponding fields of table po_orgns.
*--- PO Types
select *
from t161t
into corresponding fields of table po_types
where spras = 'E'.
*--- Material Types
select *
from t023t
into corresponding fields of table mat_type
where spras = 'E'.
*--- Tax Code and Des
select *
from t007s
into corresponding fields of table tax_code
where spras = 'E'.

endform.

*---------------
form initialize.
*---------------
clear: r_loekz.
refresh: r_loekz.
*--- Deleted PO's only
if p_del = 'X'.
r_loekz-sign = 'I'.
r_loekz-option = 'EQ'.
r_loekz-low = 'L'.
append r_loekz.
endif.
*--- UnDeleted PO's only
if p_undel = 'X'.
r_loekz-sign = 'E'.
r_loekz-option = 'EQ'.
r_loekz-low = 'L'.
append r_loekz.
endif.
endform.

*---------
form list.
*---------
perform generate_head_temp. " Temporary table for kschl header.
loop at temp.
clear: grmenge.
temp_line = temp.
format color col_normal.
* AT NEW ebeln.
* SELECT username
* INTO (temp-username)
* FROM cdhdr
* WHERE objectid = temp-ebeln.
* ENDSELECT.
* MODIFY temp. CLEAR temp.
* ENDAT.
at new kposn.
loop at i_gr_qty where ebeln = temp_line-ebeln and
ebelp = temp_line-ebelp.
grmenge = grmenge + i_gr_qty-menge.
endloop.
* SELECT SUM( menge )
* FROM ekbe
* INTO grmenge
* WHERE ebeln = temp_line-ebeln AND
* ebelp = temp_line-kposn AND
* vgabe = 1
* GROUP by ebeln ebelp.
* ENDSELECT.
write:/1 w_v.

write: at lr-ebeln(10) temp_line-ebeln,
at lr-kposn(6) temp_line-kposn,
at lr-netpr(12) temp_line-netpr2, "#EC UOM_IN_MES
at lr-meins(5) temp_line-meins,
at lr-menge(13) temp_line-menge, "#EC UOM_IN_MES
at lr-grmenge(13) grmenge, "#EC UOM_IN_MES
at lr-bedat(10) temp_line-bedat,
at lr-knumv(10) temp_line-knumv,
at lr-ernam(12) temp_line-ernam,
at lr-username(12) temp_line-username,
at lr-werks(5) temp_line-werks,
at lr-name2(30) temp_line-name2,
at lr-matnr(8) temp_line-matnr,
at lr-txz01(40) temp_line-txz01,
at lr-lifnr(6) temp_line-lifnr,
at lr-name1(35) temp_line-name1,
at lr-ekorg(5) temp_line-ekorg,
at lr-ekotx(20) temp_line-ekotx,
at lr-ekgrp(5) temp_line-ekgrp,
at lr-eknam(20) temp_line-eknam,
at lr-bsart(5) temp_line-bsart,
at lr-batxt(20) temp_line-batxt,
at lr-ekorg(5) temp_line-ekorg,
at lr-matkl(9) temp_line-matkl,
at lr-wgbez(9) temp_line-wgbez,
at lr-mwskz(2) temp_line-mwskz,
at lr-d_mwskz(10) temp_line-text1.

clear grmenge.
w_count = v_lines-w_start.
do w_entries_ht times. "entries is number of unique kschl's
w_count = w_count + w_spacing.
write at w_count w_v.
enddo.
endat.

w_tkwert = temp_line-kwert.
at new kschl.
w_tmp_kwert = w_tmp_kwert + w_tkwert.
read table head_temp with key kschl = temp_line-kschl.
w_count = v_lines-w_start + 1 - w_spacing +
( sy-tabix * w_spacing ).
w_tempc = w_spacing - 1.
write at w_count(w_tempc) w_tkwert.
endat.
at end of kposn.
if w_toggle = 0.
format intensified on. w_toggle = 1.
else.
format intensified off. w_toggle = 0.
endif.
w_tempc = w_last - ( 2 * w_spacing ).
format color col_total.
write: at w_tempc(w_spacing) w_tmp_kwert right-justified.
w_tot_kwert = w_tot_kwert + w_tmp_kwert.
if temp_line-menge <> 0.
w_finalrate = w_tmp_kwert / temp_line-menge.
* w_finalrate = w_finalrate * temp_line-peinh.
endif.
w_tempc = w_last - w_spacing.
format color col_normal.
write: at w_tempc(w_spacing) w_finalrate, temp_line-meins.
clear w_tmp_kwert.
perform vert_lines.
endat.
* Temporary Internal Table for LIST manipulation.
temp_head-kschl = temp_line-kschl.
temp_head-kwert = temp_line-kwert.
append temp_head.
endloop.
w_tempc = w_last + 5.
*******Begin of modification For Upgrade by Ajay(AP10092004)**********
write at /1(w_tempc) sy-uline . "+
* write :/1(w_tempc) sy-uline . "-
********End of modification For Upgrade by Ajay(AP10092004)***********

format reset. write:/1' '. w_count = v_lines-w_start.
sort temp_head by kschl kwert.
loop at temp_head.
at new kschl.
write at w_count sy-vline.
w_count = w_count + w_spacing.
endat.
at end of kschl.
sum.
w_tkwert = temp_head-kwert.
read table head_temp with key kschl = temp_head-kschl.
w_here = v_lines-w_start + 1 - w_spacing +
( sy-tabix * w_spacing ).
format color col_total intensified on.
w_tempc = w_spacing - 1.
write: at w_here(w_tempc) temp_head-kwert. "#EC UOM_IN_MES
format reset.
endat.
w_tempc = w_last - ( 2 * w_spacing ).
at last.
format color col_total intensified on.
write at w_tempc w_tot_kwert left-justified.
format reset.
endat.
endloop.
if sy-subrc = 0. "For the ULINE under the sum's.
w_tempc = w_tempc - 1.
write: at w_count sy-vline, at w_tempc sy-vline.
w_tempc = w_last - ( 2 * w_spacing ) - v_lines-w_start.
*******Begin of modification For Upgrade by Ajay(AP10092004)**********
write at /v_lines-w_start(w_tempc) sy-uline. "+
* write:/v_lines-w_start(w_tempc) sy-uline. "-
********End of modification For Upgrade by Ajay(AP10092004)***********

endif.
endform.

*-----------------------
form generate_head_temp.
*-----------------------
loop at temp.
head_temp-kschl = temp-kschl.
append head_temp.
endloop.
sort head_temp by kschl.
delete adjacent duplicates from head_temp.
loop at head_temp.
select single vtext "#EC *
into (head_temp-vtext)
from t685t
where kschl = head_temp-kschl and spras = 'E'.
modify head_temp. clear head_temp.
endloop.

describe table head_temp lines w_entries_ht.
w_cols = w_entries_ht * w_spacing.
if w_cols > 600.
w_cols = 600 / w_entries_ht.
w_spacing = floor( w_cols ).
endif.
endform.

*--------------
form po_header.
*--------------
if w_entries_t = 0.
perform quit.
endif.
format color col_heading.
w_last = w_entries_ht * w_spacing + v_lines-w_start + 1 +
( 2 * w_spacing ).
w_tempc = w_last + 5.
*******Begin of modification For Upgrade by Ajay(AP10092004)**********
write at 1(w_tempc) sy-uline. "+
* write:/1(w_tempc) sy-uline. "-
********End of modification For Upgrade by Ajay(AP10092004)***********
write:/1 sy-vline.
write:
at lr-ebeln 'Purchase',
at lr-kposn 'Line',
at lr-netpr 'Basic',
at lr-meins 'Unit',
at lr-menge 'Purchase',
at lr-grmenge 'GR',
at lr-bedat 'PO',
at lr-knumv 'Document',
at lr-ernam 'User',
at lr-username 'Changed',
at lr-werks 'Plant',
at lr-name2 'Plant',
at lr-matnr 'Material',
at lr-txz01 'Material',
at lr-lifnr 'Vendor',
at lr-name1 'Vendor',
at lr-ekorg 'PO',
at lr-ekotx 'PO Organisation',
at lr-ekgrp 'PO',
at lr-eknam 'PO Group',
at lr-bsart 'PO',
at lr-batxt 'PO Type',
at lr-wgbez 'Material Group',
at lr-matkl 'Material',
at lr-mwskz 'Tax',
at lr-d_mwskz 'Tax Code'.

perform vert_lines.
w_count = v_lines-w_start + 1.
loop at head_temp.
w_tempc = w_spacing - 1. "In between two vertical lines.
write: at w_count(w_tempc) head_temp-kschl.
w_count = w_count + w_spacing.
w_tempc = w_count - 1.
write at w_tempc sy-vline.
endloop.

w_tempc = w_last - ( 2 * w_spacing ).
write: at w_tempc 'SUM'.
w_tempc = w_tempc + w_spacing + 1.
write at w_tempc 'Price'.
w_tempc = w_tempc + w_spacing.
write at w_tempc 'Unit'.

write:/1 sy-vline.
write:
at lr-ebeln 'Order No.',
at lr-kposn 'Item',
at lr-netpr 'Price',
at lr-meins 'per',
at lr-menge 'Quantity',
at lr-grmenge 'Quantity',
at lr-bedat 'Date',
at lr-knumv 'Condition',
at lr-ernam 'Name',
at lr-username 'Last By',
at lr-werks 'Code',
at lr-name2 'Name',
at lr-matnr 'Code',
at lr-txz01 'Description',
at lr-lifnr 'Code',
at lr-name1 'Name',
at lr-ekorg 'Orgn.',
at lr-ekotx 'Description',
at lr-ekgrp 'Group',
at lr-eknam 'Description',
at lr-bsart 'Type',
at lr-batxt 'Description',
at lr-wgbez 'Description',
at lr-matkl 'Group',
at lr-mwskz 'Code',
at lr-d_mwskz 'Description'.

perform vert_lines.
w_count = v_lines-w_start + 1.
loop at head_temp.
w_tempc = w_spacing - 1. "In between two vertical lines.
write: at w_count(w_tempc) head_temp-vtext.
w_count = w_count + w_spacing.
w_tempc = w_count - 1.
write at w_tempc sy-vline.
endloop.
w_tempc = w_last + 5.
*******Begin of modification For Upgrade by Ajay(AP10092004)**********
write at 1(w_tempc) sy-uline."+
* write:/1(w_tempc) sy-uline. "-
********End of modification For Upgrade by Ajay(AP10092004)***********

format reset.
endform.

*---------
form quit.
*---------
write:/1(121) sy-uline, /1 sy-vline.
write:30 'No matching records found. Please try a better criteria.'.
write: at 121 sy-vline, /1(121) sy-uline.
stop.
endform.

*---------------
form vert_lines.
*---------------
write:
at v_lines-ebeln w_v,
at v_lines-kposn w_v,
at v_lines-netpr w_v,
at v_lines-meins w_v,
at v_lines-menge w_v,
at v_lines-grmenge w_v,
at v_lines-bedat w_v,
at v_lines-knumv w_v,
at v_lines-ernam w_v,
at v_lines-username w_v,
at v_lines-werks w_v,
at v_lines-name2 w_v,
at v_lines-matnr w_v,
at v_lines-txz01 w_v,
at v_lines-lifnr w_v,
at v_lines-name1 w_v,
at v_lines-ekorg w_v,
at v_lines-ekotx w_v,
at v_lines-ekgrp w_v,
at v_lines-eknam w_v,
at v_lines-bsart w_v,
at v_lines-batxt w_v,
at v_lines-matkl w_v,
at v_lines-wgbez w_v,
at v_lines-mwskz w_v,
at v_lines-d_mwskz w_v,
at v_lines-w_start w_v.

w_tempc = w_last - w_spacing.
write at w_tempc w_v.
write at w_last w_v.
w_tempc = w_last + 5.
write at w_tempc w_v.
endform.

*-----------
form header.
*-----------
format color col_background.
new-line no-scrolling.
write:/1(121) sy-uline.
new-line no-scrolling.
write:/1 sy-vline. write:3 'User:'. write: 10(10) sy-uname.
write:21 sy-vline. write:25 'Date :'.
write: 40(10) sy-datum.
write:72 sy-vline.
write:75 'Number of entries found:', w_entries_t.
write:121 sy-vline.
new-line no-scrolling.
write:/1(121) sy-uline.
new-line no-scrolling.
write:/1 sy-vline. write:21 sy-vline.
write:25 'For dates :', 40 s_bedat-low, 55'TO ', 60 s_bedat-high.
write:75 'For PO nos :', 90 s_ebeln-low, 105'TO ', 110 s_ebeln-high.
write:72 sy-vline. write:121 sy-vline.
new-line no-scrolling.
write:/1 sy-vline. write:21 sy-vline.
write:25 'For Brokers :', 40 s_kschl-low, 55 'TO ', 60 s_kschl-high.
write:75 'For Vendors :', 90 s_lifnr-low, 105 'TO ', 110 s_lifnr-high.
write:72 sy-vline. write:121 sy-vline.
new-line no-scrolling.
write:/1 sy-vline. write:21 sy-vline.
write:25 'For Material:', 40 s_matnr-low, 55'TO ', 60 s_matnr-high.
write:72 sy-vline. write:121 sy-vline.
new-line no-scrolling.
write:/1(121) sy-uline.
format reset.
endform.

*-----------
form footer.
*-----------
write:/1(21) sy-uline.
write:/1 sy-vline. write:5 'End of report'. write:21 sy-vline.
write:/1(21) sy-uline.
endform.

* IF p_change = 'X'.
**--- Get The Change History
* LOOP AT cdhdr_tab.
* SELECT objectid username udate utime
* INTO (cdhdr2_tab-objectid, cdhdr2_tab-username,
* cdhdr2_tab-udate, cdhdr2_tab-utime)
* FROM cdhdr
** FOR ALL ENTRIES IN cdhdr_tab
* WHERE objectid = cdhdr_tab-objectid
* ORDER BY udate DESCENDING utime DESCENDING.
* APPEND cdhdr2_tab.
* EXIT.
* ENDSELECT.
* ENDLOOP.
**--- Sort
* SORT cdhdr2_tab BY objectid DESCENDING
* udate DESCENDING
* utime DESCENDING.
* DELETE ADJACENT DUPLICATES FROM cdhdr2_tab COMPARING objectid.
* ENDIF.

* LOOP AT cdhdr_tab.
* SELECT SINGLE username objectid MAX( changenr )
* INTO (cdhdr2_tab-username, cdhdr2_tab-objectid,
* cdhdr2_tab-changenr)
* FROM cdhdr
* WHERE objectclas EQ 'EINKBELEG' AND
* objectid EQ cdhdr_tab-objectid
* GROUP by username objectid changenr.
* APPEND cdhdr2_tab.
* ENDLOOP.

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)