‎2008 Feb 01 3:00 PM
I have an sap table lfa1
I have to extract the vendor records
Which were created from sy-datum-1 to sy-datum.
Now I created a function module
My import parameters will be sy-datum and sy-datum-1.
How can I do this
‎2008 Feb 01 3:04 PM
instead of using sy-datum1 and sy-datum as parameters take them in two separate varibales who has type same as sy-datum
then pass these variables you will get desired output for sure
<REMOVED BY MODERATOR>
keep rockin
vivek
Edited by: Alvaro Tejada Galindo on Feb 1, 2008 12:52 PM
‎2008 Feb 01 3:08 PM
Hi,
goto se37
give Zname to your FM.
Import PARAmeters are sy-datum & sy-datum1
in tables give a table to store vendor information.
in source code write select stmt. to populate that table...
RAISE exception for error condition....
Some thing like this..
types: begin of t_po,
ebeln type ebeln,
ebelp type ebelp,
etenr type eeten,
aedat type erdat,
VERKF type EVERK,
TELF1 type TELF0,
lifnr type ELIFN,
NAME1 type NAME1_GP,
ORT01 type ORT01_GP,
regio type regio,
bukrs type bukrs,
ORT01_c type ORT01, "address of the company
LFDAT type LFDAT_V,
matnr type matnr,
menge type bstmg,
meins type meins,
netpr type bprei,
netwr type bwert,
maktx type maktx,
menge_d type etmen,
eindt type eindt,
end of t_po.
data: wa_po_final type t_po.
*data: it_po type t_po.
types: begin of t_po_details ,
ebeln type ebeln,
ebelp type ebelp,
matnr type matnr,
menge type bstmg,
meins type meins,
netpr type bprei,
netwr type bwert,
maktx type maktx,
etenr type eeten,
menge_d type etmen,
eindt type eindt,
end of t_po_details.
data: wa_po_details type t_po_details.
data: po_details type t_po_details occurs 0.
**data: it_eket like eket.
types: begin of t_deliv_details,
ebelp type ebelp,
ebeln type ebeln,
etenr type eeten,
menge_d type etmen,
eindt type eindt,
end of t_deliv_details.
data: wa_delivery type t_deliv_details.
data: it_delivery type t_deliv_details occurs 0.
data: y type i.
types: begin of t_po_header,
ebeln type ebeln,
aedat type erdat,
VERKF type EVERK,
TELF1 type TELF0,
lifnr type ELIFN,
NAME1 type NAME1_GP,
ORT01 type ORT01_GP,
regio type regio,
bukrs type bukrs,
ORT01_c type ORT01, "address of the company
LFDAT type LFDAT_V,
end of t_po_header.
*select * into table po_header from ekko where ebeln in po_range.
data: wa_po_header type t_po_header.
data: po_header type standard table of t_po_header.
data: wa_details1 type t_po_details.
data: po_details1 type standard table of t_po_details.
*data: po_header type standard table of t_po_header.
*
select ebeln aedat verkf telf1 bukrs lifnr into corresponding fields of wa_po_header from ekko where ebeln in PO_RANGE.
append wa_po_header to po_header.
endselect.
if sy-subrc <> 0.
else.
select ebeln ebelp matnr menge meins netpr netwr into corresponding fields of wa_po_details from ekpo
where
ebeln in po_range.
select single matnr maktx into (wa_po_details-matnr,
wa_po_details-maktx)
from makt where matnr = wa_po_details-matnr and spras = sy-langu.
append wa_po_details to po_details.
endselect.
endif.
loop at po_details into wa_po_details.
select ebeln ebelp etenr eindt menge into (wa_delivery-ebeln,
wa_delivery-ebelp,
wa_delivery-etenr,
wa_delivery-eindt,
wa_delivery-menge_d) from eket
where ebeln = wa_po_details-ebeln and ebelp = wa_po_details-ebelp.
append wa_delivery to it_delivery.
endselect.
endloop.
loop at po_header into wa_po_header.
*clear wa_po_header-lifnr.
clear wa_po_header-name1.
clear wa_po_header-ort01.
clear wa_po_header-regio.
*clear wa_po_header-bukrs.
clear wa_po_header-ort01_c.
select single lifnr name1 ort01 regio into (wa_po_header-lifnr,
wa_po_header-name1,
wa_po_header-ort01,
wa_po_header-regio)
from lfa1 where lifnr = wa_po_header-lifnr.
select single bukrs ort01 into (wa_po_header-bukrs,
wa_po_header-ort01_c)
from t001
where bukrs = wa_po_header-bukrs.
modify po_header from wa_po_header.
endloop.
sort po_details by ebeln ebelp.
sort it_delivery by ebeln ebelp etenr.
append lines of po_details to po_details1.
refresh po_details.
loop at po_details1 into wa_po_details.
loop at it_delivery into wa_delivery where ebeln = wa_po_details-ebeln and ebelp =
wa_po_details-ebelp.
wa_po_details-etenr = wa_delivery-etenr.
wa_po_details-eindt = wa_delivery-eindt.
wa_po_details-menge_d = wa_delivery-menge_d.
append wa_po_details to po_details.
endloop.
endloop.
sort po_details by ebeln ebelp.
loop at po_details into wa_po_details.
at new ebeln.
read table po_header into wa_po_header with key ebeln = wa_po_details-ebeln binary search.
read table po_header into wa_po_header with key ebeln = wa_po_details-ebeln transporting all fields.
wa_po_final-ebeln = wa_po_header-ebeln.
wa_po_final-aedat = wa_po_header-aedat.
wa_po_final-VERKF = wa_po_header-verkf.
wa_po_final-TELF1 = wa_po_header-telf1.
wa_po_final-lifnr = wa_po_header-lifnr.
wa_po_final-NAME1 = wa_po_header-name1.
wa_po_final-ORT01 = wa_po_header-ort01.
wa_po_final-regio = wa_po_header-regio.
wa_po_final-bukrs = wa_po_header-bukrs.
wa_po_final-ORT01_c = wa_po_header-ort01_c.
wa_po_final-LFDAT = wa_po_header-lfdat.
endat.
wa_po_final-ebelp = wa_po_details-ebelp.
wa_po_final-matnr = wa_po_details-matnr.
wa_po_final-menge = wa_po_details-menge.
wa_po_final-meins = wa_po_details-meins.
wa_po_final-netpr = wa_po_details-netpr.
wa_po_final-netwr = wa_po_details-netwr.
wa_po_final-maktx = wa_po_details-maktx.
wa_po_final-etenr = wa_po_details-etenr.
wa_po_final-menge_d = wa_po_details-menge_d.
wa_po_final-eindt = wa_po_details-eindt.
append wa_po_final to po_final.
endloop.
ENDFUNCTION.
REGARDS,
GAURAVJ.
‎2008 Feb 01 3:12 PM
Hi,
Declare 2 variables of same type as sy-datum.
move these fields to a range field.
data: r_datum like line of sy-datum. (work around this)
r_datum-low - v_date1.
r_datum-high-v_date2.
select * from lfa1 into it_lfa1 where datum in r_datum.
<REMOVED BY MODERATOR>
regards,
Nageswar
Edited by: Alvaro Tejada Galindo on Feb 1, 2008 12:53 PM
‎2008 Feb 01 3:13 PM
What exactly do you mean by "created from sy-datum-1 to sy-datum"? Is it created between yesterday and today or created between 2 different dates?
If you mean yesterday and today there is no necessity to ask the user for iunput, you can always calculate it, using the system variable sydatum.
today = sy-datum.
yesterday = sy-datum-1.
But if you mean 2 dates, then goto import parameters of the FM and create 2 parameters FROM_DATE and TO_DATE, both with type sy-datum. Then you can use these two dates in your logic accordingly.
Its better to create a range as follows.
RANGE : r_date for lfa1-erdat.
r_date-sign = 'I'.
r_date-option = 'EQ'.
r_date-low = from_date.
r_date-high = to_date.
append r_Date.
in your select query you can write
select *
from lfa1
into table t_lfa1
where erdat in r_date.
‎2008 Feb 01 3:16 PM
Import Parameters:
erdat1 type sy-datum
erdat2 type sy-datum
tables:
t_lfa1 like lfa1
code in fm
tables: lfa1.
ranges: r_erdat for lfa1-erdat.
r_erdat-sign = 'I'.
r_erdat-option = 'BT'.
r_erdat-low = erdat1.
r_erdat-high = erdat2.
select * from lfa1 into table t_lfa1 where erdat in r_erdat.
i think this is the function module u need
<REMOVED BY MODERATOR>
Regards,
Raghu
Edited by: Alvaro Tejada Galindo on Feb 1, 2008 12:53 PM