2008 Apr 08 6:54 AM
Hi,
Kindly please help me to develop a report in Goods reciept.
I know the tables ekko,ekbeln..
Then how shud i proceed
Hi,
Kindly please help me to develop a report in Goods reciept.
I know the tables ekko,ekbeln..
Then how shud i proceed
2008 Apr 08 6:58 AM
here is a sample code
plz reward if useful
&----
*& Report Z9D_PO_GOODSRECEIPT
*&
&----
*&
*&
&----
report z9d_po_goodsreceipt
message-id z9d_po
no standard page heading line-size 200 line-count 200.
types : begin of type_ekkoekpo,
ebeln type ebeln, "Purchasing Document Number
ebelp type ebelp, "Item Number of Purchasing Document
lifnr type elifn, "Vendor's account number
bedat type ebdat, "Purchasing Document Date
menge type bstmg, "Purchase order quantity
end of type_ekkoekpo.
types : begin of type_ekbe,
ebeln type ebeln, "Purchasing Document Number
ebelp type ebelp, "Item Number of Purchasing Document
zekkn type dzekkn, "Sequential number of account assignment
vgabe type vgabe, "Transaction/event type, purchase order history
gjahr type mjahr, "Material Document Year
belnr type mblnr, "Number of Material Document
buzei type mblpo, "Item in Material Document
budat type budat, "Posting Date in the Document
menge type menge_d, "Quantity
end of type_ekbe.
types : begin of type_lfa1,
lifnr type lifnr, "Account Number of Vendor or Creditor
name1 type name1_gp, "Name 1
end of type_lfa1.
types : type_t_ekkoekpo type type_ekkoekpo,
type_t_ekbe type type_ekbe,
type_t_lfa1 type type_lfa1.
*&---internal tables
data : it_ekbe type standard table of type_t_ekbe,
it_ekkoekpo type standard table of type_t_ekkoekpo,
it_lfa1 type standard table of type_t_lfa1.
*&----work areas
data : wa_ekbe type type_ekbe,
wa_ekkoekpo type type_ekkoekpo,
wa_lfa1 type type_t_lfa1.
*&---data for selection-screen
data : v_lifnr type lifnr,
v_name1 type name1,
v_ebeln type ebeln,
v_ebelp type ebelp,
v_bedat type bedat.
*&-----field symbol for the ekbe
field-symbols: <fekbe> type type_ekbe.
*&---data declaration
data : lvsum type menge_d value 0,
lvleft type menge_d value 0,
name1_low type name1,
name1_high type name1.
*&----
constants
constants : c_bw type i value '101'.
*&---initialization.
initialization.
clear wa_ekkoekpo.
clear wa_ekbe.
clear wa_lfa1.
refresh it_ekkoekpo.
refresh it_ekbe.
refresh it_lfa1.
*&----
defining the selection-screen
selection-screen begin of block bl1 with frame title text001.
select-options : s_lifnr for v_lifnr obligatory.
select-options : s_name1 for v_name1.
select-options : s_ebeln for v_ebeln.
select-options : s_ebelp for v_ebelp.
select-options : s_bedat for v_bedat.
selection-screen end of block bl1.
*&----
validation for selection-screen
at selection-screen on s_lifnr.
if s_lifnr[] is initial.
set cursor field 's_lifnr-low'.
message e001.
else.
select lifnr into v_lifnr
from lfa1
up to 1 rows
where lifnr in s_lifnr.
endselect.
if sy-subrc <> 0.
set cursor field 's_lifnr-low'.
message e001.
endif.
endif.
at selection-screen on s_name1.
select name1 into v_name1
from lfa1
up to 1 rows
where name1 in s_name1.
endselect.
if sy-subrc <> 0.
set cursor field 's_name1-low'.
message e002.
endif.
at selection-screen on s_ebeln.
select ebeln into v_ebeln
from ekko
up to 1 rows
where ebeln in s_ebeln.
endselect.
if sy-subrc <> 0.
set cursor field 's_ebeln-low'.
message e003.
endif.
at selection-screen on s_ebelp.
select ebelp into v_ebelp
from ekpo
up to 1 rows
where ebelp in s_ebelp.
endselect.
if sy-subrc <> 0.
set cursor field 's_ebelp-low'.
message e004.
endif.
*&---main logic
start-of-selection.
*&--populate the data from ekko & ekpo
select a~ebeln "Purchasing Document Number
b~ebelp "Item Number of Purchasing Document
a~lifnr "Vendor's account number
a~bedat "Purchasing Document Date
b~menge "Purchase order quantity
into table it_ekkoekpo
from ekko as a inner join ekpo as b
on aebeln = bebeln
where a~lifnr in s_lifnr and
a~ebeln in s_ebeln and
b~ebelp in s_ebelp and
a~bedat in s_bedat.
*&--populate the data from ekbe
if it_ekkoekpo[] is not initial.
select ebeln "Purchasing Document Number
ebelp "Item Number of Purchasing Document
zekkn "Sequential number of account assignment
vgabe "Transaction/event type, purchase order history
gjahr "Material Document Year
belnr "Number of Material Document
buzei "Item in Material Document
budat "Posting Date in the Document
menge "Quantity
into table it_ekbe
from ekbe
for all entries in it_ekkoekpo
where ebeln = it_ekkoekpo-ebeln and
ebelp = it_ekkoekpo-ebelp.
endif.
*&---populate the data from lfa1
if it_lfa1[] is not initial.
endif.
*&----
printing on the output clasical report
format color 5 on.
write:/2 'vendor name' , 16 'vendor name' , 54 'po no' , 64 'po item no' , 80 'po qty' , 101 'qty received' , 126 'qty pending'.
format color 5 off.
format color 7 on.
write:/2 'gr no' , 16 'gr item no ' , 34 'gr qty' , 45 'gr date'.
format color 7 off.
uline.
*&-----populate the data from lfa1
loop at it_ekkoekpo into wa_ekkoekpo.
format color 5 on.
read table it_lfa1 into wa_lfa1 with key lifnr = wa_ekkoekpo-lifnr.
if sy-subrc <> 0.
select single lifnr
name1
into wa_lfa1
from lfa1
FOR ALL ENTRIES IN it_lfa1
where lifnr = wa_lfa1-lifnr.
if sy-subrc = 0.
append wa_lfa1 to it_lfa1.
write:/2 wa_lfa1-lifnr , sy-vline ,
16 wa_lfa1-name1 , sy-vline ,
54 wa_ekkoekpo-ebeln , sy-vline ,
64 wa_ekkoekpo-ebelp , sy-vline ,
80 wa_ekkoekpo-menge , sy-vline .
endif.
else.
write:/2 wa_lfa1-lifnr , sy-vline ,
16 wa_lfa1-name1 , sy-vline ,
54 wa_ekkoekpo-ebeln , sy-vline ,
64 wa_ekkoekpo-ebelp , sy-vline ,
80 wa_ekkoekpo-menge , sy-vline .
endif.
endloop.
*&----caluculate the (qty received)
loop at it_ekbe into wa_ekbe .
lvsum = lvsum + wa_ekbe-menge.
endloop.
*&-----caluculate the qty pending
lvleft = wa_ekkoekpo-menge - lvsum.
write:101 lvsum , 126 lvleft.
clear : lvsum , lvleft.
uline.
format color 5 off.
loop at it_ekbe into wa_ekbe where ebeln = wa_ekkoekpo-ebeln and
ebelp = wa_ekkoekpo-ebelp.
format color 7 on.
write: sy-vline.
write:2 wa_ekbe-belnr , sy-vline ,
16 wa_ekbe-buzei , sy-vline ,
34 wa_ekbe-menge , sy-vline ,
45 wa_ekbe-budat , sy-vline , 138 sy-vline.
format color 7 off.
uline.
endloop.
2008 Apr 08 10:22 AM
Hi Vivek,
Pls expl;ain me from the portion that i mentioned before
Will reward
2008 Apr 08 6:59 AM
Hi Lathe,
What search criteria and output u want?
Mention Tables, Fields & condition.
Regards
AK
2008 Apr 08 7:16 AM
2008 Apr 08 7:01 AM
Hi,
take a look to this:
SELECT ebeln INTO CORRESPONDING FIELDS OF TABLE po_table1
FROM ekko WHERE lifnr IN lifnr.
READ TABLE po_table1 INDEX 1.
IF sy-subrc = 0.
Preread the PO's with movements with reason
PERFORM progress USING text-101.
SELECT ebeln ebelp
INTO CORRESPONDING FIELDS OF TABLE po_table2
FROM ekbe
FOR ALL ENTRIES IN po_table1
WHERE ebeln = po_table1-ebeln AND
ebeln IN ebeln AND
ebelp IN ebelp AND
werks IN werks AND
budat IN budat AND
grund IN grund AND
grund <> space AND
bwart IN bwart AND
vgabe = '1'.
READ TABLE po_table2 INDEX 1.
IF sy-subrc = 0.
Read EKBE for all PO's involved in such histories
SELECT ebeln ebelp gjahr belnr buzei menge wesbs dmbtr hswae
INTO CORRESPONDING FIELDS OF TABLE iekbe
FROM ekbe
FOR ALL ENTRIES IN po_table2
WHERE ebeln = po_table2-ebeln AND
ebelp = po_table2-ebelp AND
ebeln IN ebeln AND
ebelp IN ebelp AND
budat IN budat AND
vgabe = '1'.
READ TABLE iekbe INDEX 1.
IF sy-subrc = 0.
Read the material documents
PERFORM progress USING text-102.
SELECT mkpfmblnr mkpfmjahr zeile bwart matnr werks lgort
charg sobkz
lifnr shkzg menge meins ebeln ebelp grund dmbtr waers
kzbew "494211
INTO CORRESPONDING FIELDS OF TABLE imseg
FROM mkpf INNER JOIN mseg
ON mkpfmblnr = msegmblnr AND
mkpfmjahr = msegmjahr
FOR ALL entries IN iekbe
WHERE mseg~mblnr = iekbe-belnr AND
mseg~mjahr = iekbe-gjahr AND
mseg~zeile = iekbe-buzei AND
mseg~matnr IN matnr AND
vgart IN vgart.
ENDIF.
ENDIF.
endif.
2008 Apr 08 7:06 AM
Hi
Please be specific on what you want to know
Genrally for such kind of reports we follow following steps
1) Design the selection screen (where user will input ).
2) Based on inputs from the selection screen we select data from the tables.
3) Then if required write logic to prepare a final table which will be displayed (It must be specified on ur FS ).
4) Display the report .
Now tell us where u have problem ?
Regards
Bikas
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |