2007 Aug 08 6:25 PM
I tried out the below program but did not get the output. Is there any mistake in the program. Please correct me.
In the purchasing (MM module) you can process the purchase requisitions. The purchase requisitions define primarily the need for a material/service. List the first 100 purchase requisitions at the plant 'PL01' (table EBAN). Then make it possible to change the purchase requisition itself from the list by clicking twice on the row or by using a push-button.
ADDITIONAL REQUIREMENTS TO THE LIST:
1. CONTENT: PURCHASE REQUISITION NUMBER, ITEM NUMBER, DOCUMENT TYPE, MATERIAL, QUANTITY, UNIT OF MEASURE
2. LAYOUT: MAIN HEADER SHOULD INCLUDE
PROGRAM NAME, COMPANY NAME, PLANT, PURCHASE GROUP, CREATION DATE, PAGE NUMBER
3. ONE PAGE SHOULD HAVE 50 LINE ITEM
________________________________________
report zmjud001 no standard page heading line-size 85 line-count 50.
DATA /TABLES DECLARATION*
tables: eban.
data: prog_nam(8).
data: begin of pur_req occurs 100,
ekgrp like eban-ekgrp,
werks like eban-werks,
banfn like eban-banfn,
bnfpo like eban-bnfpo,
bsart like eban-bsart,
estkz like eban-estkz,
matnr like eban-matnr,
menge like eban-menge,
meins like eban-meins,
numb(3) type n.
data: end of pur_req.
THE REPORT HEADER
prog_nam = sy-repid.
top-of-page.
perform header_write.
SELECTION
start-of-selection.
pur_req-numb = 1.
SELECT ONLY THOSE FIELDS THAT WILL BE USED FROM THE TABLE EBAN, AND ONLY
*THE FIRST100 RECORDS OF THE THE PLANT 'PL01'
select banfn bnfpo bsart ekgrp matnr werks menge meins frgdt estkz
into corresponding fields of eban from eban up to 100 rows
where bsart = 'NB' "document type 'NB' = purchase requisition
and werks = 'PL01'
and statu = 'N' "processing status
and loekz = ' '. "deletion indicator
THE SELECTED RECORDS SHOULD BE APPENDED TO INTERNAL TABLE 'PUR_REQ'
pur_req-banfn = eban-banfn.
pur_req-matnr = eban-matnr.
pur_req-werks = eban-werks.
pur_req-ekgrp = eban-ekgrp.
pur_req-bnfpo = eban-bnfpo.
pur_req-bsart = eban-bsart.
pur_req-menge = eban-menge.
pur_req-meins = eban-meins.
pur_req-estkz = eban-estkz.
append pur_req.
pur_req-numb = pur_req-numb + 1.
endselect.
CHECK WHETHER THE TABLE EBAN CONTAINS ANY PURCHASE REQUISITIONS
if sy-subrc ne 0.
write: / 'No Purchase Requisition found.'.
endif.
PROCESS THE INTERNAL TABLE; WRITE OUT THE REQUIRED FIELDS AND HIDE THE
*FIELDS YOU ARE GOING TO USE LATER
loop at pur_req.
write: /1 pur_req-numb, 9 pur_req-banfn, 21 pur_req-bnfpo, 31 pur_req-bsart, 41 pur_req-matnr,
61 pur_req-menge unit pur_req-meins, 82 pur_req-meins.
hide: pur_req-matnr, pur_req-werks, pur_req-banfn.
endloop.
clear pur_req-banfn. clear pur_req-matnr. clear pur_req-werks.
IN THE MENU PAINTER (SE41) CREATE A STATUS TO YOUR PROGRAM. HERE YOU CAN
*DEFINE THE PUSH-BUTTON
set pf-status 'basic'.
CHOOSE A REQUISITION (WITH DOUBLE CLICKING OR PUSH-BUTTON) IN THE LIST! THE
*PURCHASE REQUISITION IS GOING TO COME UP
at line-selection.
if pur_req-banfn <> space.
set parameter id 'BAN' field pur_req-banfn. " parameter id for pruchase req. number
call transaction 'ME52' and skip first screen. "trans. code 'ME52': Change Purchase Requis.
clear pur_req-banfn. clear pur_req-matnr.
clear pur_req-werks.
endif.
FORM THE HEADER
form header_write.
write: / prog_nam, 32 'FUN-FACTORY',
/ 'Purch.Gr.:', pur_req-ekgrp, 26 'Purchase Requisition List',
61 'As Of Date:', 75 sy-datum,
/ 'Plant:', pur_req-werks, 61 'Page:', 75 sy-pagno.
uline.
write: / text-001,
/ text-002.
uline.
endform.
I just got the below output :
ZMJUD001 FUN-FACTORY
Purch. Gr.: 001 Purchase Requisition List As Of Date: 05/09/1997
Plant: D031 Page: 1
-
Numb. Requisition Item Document Material Quantity Unit of
Number Num Type Measure
-
2007 Aug 08 10:58 PM
> where bsart = 'NB'
Check the conditions on your select.
I am able to get output from this code by reducing the WHERE clause to the quoted portion above.
You appear to be excluding everything from your select with the combination of conditions you are using.
Verify that all of the expressions in the WHERE clause on your SELECT are necessary and correct, and not mis-typed. For example, should it be PLO1 or PL01 (O or zero?)
Verify that data exists that meets those conditions by using SE16 over the file EBAN.
You could also simplify this program greatly by directly loading into your internal table.
Good luck.
Brian
2007 Aug 09 2:16 PM
Hi sudha,
please recode the program first bec it may not suggestable code for perforamnce.
- First u need to use the into itab instead of select . And endselect .( select banfn bnfpo bsart ekgrp matnr werks menge meins frgdt estkz
into table pur_req from eban up to 100 rows).
- Directly you could fetch the data into in to pur_req instead of eban.
- And check the data presence in the data base table by se16n by giving the input values what you have give in the where condition
- If data is occur in data base table then go and check it out in debug mode whether data is populating into internal table properly or not if not make necessary changes to code.
If these above pints are really helpful reward with points.
Regards,
Vijay