Purchase order structure
Hi,
I have a task which has a very small touchpoint to EBS purchasing so I am trying to learn a bit more about PO's, their structure etc.
I'm fine with the concept of the PO Header and PO Lines, however what I don't really understand is "Distributions", ""Shipments" and "Releases".
Firstly, what do they represent? Ie, what is a PO Distribution? I believe releases are for receiving against? What about shipments? Are these created when a supplier ships items, when it's received etc???
Sorry for being vague but I haven't had any experience in this business area before.
Thanks
Hello,
Shipments:
This will specify the receiving Inventory Organization,their Location, required quantity and need by date for receiving the Purchased Items against this PO.
Distributions:
This is primarily used for accounting purpose.
Also you can find the destination type(Shop floor or Expense or Inventory) requester and the receving sub-inventory.If PO is auto-created from requisition then you can find the requisition number.If you use any Oracle Projects you can find the project number and Task number against this PO.
Basically, you can find more information in these shipments and distributions.
Releases:
Blanket Agreement and Planned PO's are agreement documents.
you specify only agreed amounts and other required parametres.
you receive the actual items in their respective releases.
All the information in PO Headers,PO Lines,Shipments,Distributions form a complete PO.
Please go thru the Purchasing User/Implementation manual or even Oracle Help for more information.
Thanks
-Arif.
Similar Messages
-
Report for Planned vs Purchase Order(Qty and rate)
Hi
I have the following issue. My client is raising Purchasing requisition and Purchase Orders in Me51N and ME21n respectively. The Project Structure is used only to plan the quantities and rates whereas no PR is released from it. But the components are attached. Now if i make use of the code CN52N, i am getting the planned quantity and unit rate for the planned value whereas no Purchase requisition number or purchase order number is updated in it.
My requirement is that both planned quantity, rate along with Purchase order quantity and rate should be available in a report.
1. Is there any setting that we can make so that the details are updated in cn52N (or)
2. is there any other report with those details (or)
3. Should that be achived only through ABAP.
Please suggest.
RaghavThere are a few reports that you can use to display STO requisitions and orders, by supplying plant, material, or MD04 like was mentioned.
The only thing that you don't have in a report is the link to the production order. In SAP in a MTS situation there's no fixed link (pegging) between the requirement (STO) and the supply (prod Ord).
You can view the pegging dynamically, for example in MD04.
Edited by: Mario Adler on Oct 27, 2011 12:13 PM -
Error in Bapi_GoodsMvt_Create using Purchase order
Hi Friends,
I am using Bapi_goodsmvt_create for Goods Receipts against Purchase order.
The below code i have given for Goods receipts
It shows the error like
ID : 8J
Err No.:182
Message : Entry 4500000344 00040 0000 not valid; correct entry
Please help me to correct this error.
Thanks
Shankar
===================================
Heading Structure
st_gm_code-gm_code = '01'.
st_gm_header-pstng_date = '20070930'.
st_gm_header-doc_date = '20070930'.
st_gm_header-gr_gi_slip_no = '970015'.
st_gm_header-bill_of_lading = '527213'.
st_gm_header-header_txt = 'AIR'.
st_gm_header-ref_doc_no = '4500000344'.
Tables - ITEM CREATE.
itab_afs_gm_itemx-plant = '2000'.
itab_afs_gm_itemx-deliv_numb = '80100121'.
itab_afs_gm_itemx-stge_loc = '2110'.
itab_afs_gm_itemx-move_stloc = '2110'.
itab_afs_gm_itemx-po_number = '4500000344'.
itab_afs_gm_itemx-po_item = '00040'.
itab_afs_gm_itemx-vendor = '0000650003'.
itab_afs_gm_itemx-vendrbatch = 'ABC123'.
itab_afs_gm_itemx-move_type = '101'.
itab_afs_gm_itemx-mvt_ind = 'B'.
itab_afs_gm_itemx-material = '000000000030000227'.
itab_afs_gm_itemx-entry_qnt = 10.
APPEND itab_afs_gm_itemx .
****&& Grid values
gr_afs-matdoc_itm = '0001'.
gr_afs-grid_value = '205'.
gr_afs-withdrawn_sku = 'X'. "Final issue at sku level
gr_afs-stock_cat = '0000000001000366'.
APPEND gr_afs.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = st_gm_header
goodsmvt_code = st_gm_code
TESTRUN = ' '
IMPORTING
goodsmvt_headret = st_gm_headret
materialdocument = mat_doc
matdocumentyear = doc_year
TABLES
goodsmvt_item = itab_afs_gm_itemx
afs_goodsmvt_sku = gr_afs
return = bapi_return.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
CLEAR itab_afs_gm_itemx.
REFRESH itab_afs_gm_itemx.
CLEAR gr_afs.
REFRESH gr_afs.Hi,
Here is some sample code from one of my programs, which does a 551 movement type. This should get you started. Just check the RETURN table for messages, they should tell you what you are missing.
code
Structures for BAPI
data: gm_header type bapi2017_gm_head_01.
data: gm_code type bapi2017_gm_code.
data: gm_headret type bapi2017_gm_head_ret.
data: gm_item type table of
bapi2017_gm_item_create with header line.
data: gm_return type bapiret2 occurs 0.
data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.
clear: gm_return, gm_retmtd. refresh gm_return.
Setup BAPI header data.
gm_header-pstng_date = sy-datum.
gm_header-doc_date = sy-datum.
gm_code-gm_code = '06'. " MB11
Write 551 movement to table
clear gm_item.
move '551' to gm_item-move_type .
move '000000000040001234' to gm_item-material.
move '1' to gm_item-entry_qnt.
move 'EA' to gm_item-entry_uom.
move '0004' to gm_item-plant.
move '4000' to gm_item-stge_loc.
move '201' to gm_item-move_reas.
Determine cost center per plant
case xresb-werks.
when '0004'.
move '0000041430' to gm_item-costcenter.
when '0006'.
move '0000041630' to gm_item-costcenter.
when '0007'.
move '0000041731' to gm_item-costcenter.
when '0008'.
move '0000041830' to gm_item-costcenter.
endcase.
append gm_item.
Call goods movement BAPI
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gm_header
goodsmvt_code = gm_code
importing
goodsmvt_headret = gm_headret
materialdocument = gm_retmtd
tables
goodsmvt_item = gm_item
return = gm_return.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
[/code]
Welcome to SDN! Please remember to award points for helpful answers and mark you post as solved when solved completely. Thanks.
REgards,
Raj. -
KEY FIGURE: Effective purchase order value & K.F "No. of Purch.Orders"
Yo my fellow Gurus,
Got a problem, when executing listcube on the Info-Cube 0PUR_C01 - I see the data/amounts in the column for "Effective purchase order value" / 0ORDER_VAL. But when running the query with the Key Figure I just get "0"
I tried the option of adding the Process Keys not allocated in the Routine list of keys, yet still nothing has popped in the query, and heres the routine after additonal keys added:
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: ...
INCLUDE RS_BCT_MM_UPDATE_RULES.
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS2LIS_02_SCL
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BI0/V0PUR_C04T-ORDER_VAL
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
IF ( COMM_STRUCTURE-PROCESSKEY = '001' or "Bestellung
COMM_STRUCTURE-PROCESSKEY = '011' or
*change of keys
COMM_STRUCTURE-PROCESSKEY = '015' or
COMM_STRUCTURE-PROCESSKEY = '005' or
COMM_STRUCTURE-PROCESSKEY = '025' or
COMM_STRUCTURE-PROCESSKEY = '041' or
COMM_STRUCTURE-PROCESSKEY = '051' or
COMM_STRUCTURE-PROCESSKEY = '061' or
*change of keys
COMM_STRUCTURE-PROCESSKEY = '021' or
COMM_STRUCTURE-PROCESSKEY = '004' or "LP
COMM_STRUCTURE-PROCESSKEY = '014' or
COMM_STRUCTURE-PROCESSKEY = '024' )
AND COMM_STRUCTURE-BWAPPLNM EQ 'MM'
AND COMM_STRUCTURE-ORDER_VAL <> 0.
perFORM LOC_CURR_CONVERT
USING COMM_STRUCTURE-ORDER_VAL
COMM_STRUCTURE-DOC_DATE
COMM_STRUCTURE-ORDER_CURR
COMM_STRUCTURE-LOC_CURRCY
COMM_STRUCTURE-EXCHG_RATE
CHANGING RESULT.
if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
else.
RETURNCODE = 4.
endif.
if abort is not equal zero, the update process will be canceled
This seems to be also the issue with my other Key Figure "No. of Purch. Orders" except here it the just comes up blank / 0 . This is to some the number of pos per plant for the month. So it's not storing anything but running via an interface and then with the aid of the routine loading the count into the cube:
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: ...
DATA: ...
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS2LIS_02_HDR
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BI0/V0PUR_C04T-NO_PUR_ORD
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
if COMM_STRUCTURE-HDRPROCESS = '01' "Bestellung
AND COMM_STRUCTURE-no_hdr <> 0.
result value of the routine
RESULT = COMM_STRUCTURE-no_hdr.
if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
else.
RETURNCODE = 4.
endif.
if abort is not equal zero, the update process will be canceled
ABORT = 0.
$$ end of routine - insert your code only before this line -
ENDFORM.
Please advise the way forward.
Thanks,
Ishaamwhat do u want?
-
BAPI for PURCHASE ORDER with OPEN QUANTITY field
Hi All,
I wanted to use the BAPI_PO_GETDETAIL to get the Purchase Order details upon triggering from Warehouse management system,
But the details required contains a field called OPEN QUANTITY...which is not used in this BAPI.
I request to let me know if any BAPI exits for PO details having the structure for this field:Open Quantity.
Am using SAP version 4.0B.
If not exists please advise how to customize the existing BAPI to meet the requirement.
thanks
mahiHi,
Open quantity is a calculated field. I guess the BAPI gives the details of the delivery, so take the ordered qty and substract the delivered qty from that.
Delivery data is EKET table.
Regards,
Ravi -
ISSUE WITH SERVICE PURCHASE ORDER STATUS
Hi
There is an issue with a Service PO.When I created a service p.o the
p.o value was 1,543,695.60 USD . I created service entry sheet and GR
for 1,029,130.40 USD.
The still to be delivered amount should be 1,543,695.60-1,029,130.40 =514565.20 USD
But the Amount Still to be delivered in p.o STATUS HEADER DATA screen shows 191,761.60 USD.
Actually the system should show the delivered status as 514565.20 USD.
What should be the cause for this???
I checked the invoice also.Invoicing is done for 1,029,130.40 USD.
Apperciate ur immediate feedback on this.Hi
S012 is updated by the Purchase Order creation date, not the Goods Receipt date. e.g. a Purchase Order is created in January and good receipt is in February and March, S012 will shows the values in period January.
try Transaction MC26
Info structure S012 Update group (stats) SAP
Double click on Goods received qty
In the section Date field for period determination
check regarding date or change accordingly
hope it helps. -
Table for purchase order status
Hello friends,
There's a tab STATUS in purchase order (tcoe ME21N).
I can't find a table which contains theses statuses.
Anybody knows what's the table for purchase orders status ??
Regards,
BahiaHi
PO status is stored in Structure not in the table.
Please use the List displays to get the information like ME2N,ME2L, ME2M, ME2K etc
You can also get the information from the table EKKO, EKPO, EKET,EKBE
Hope it helps
thanks/karthik -
Hi all,
i have two doubts related to the purchase order.
1. How to know the Status of the purchase order
ex: Open , Closed
2. How to get the Purchasing Quantity (KOMV-KAWRT)
Please Advice me..
Many thanks for all of your help.
Regards,
Lakshma.Hi
Here is the code to find out the open purchase order.
List of open purchase orders for a given plant/delivery period *
A purchase order is open when the delivery completed indicator = ' '*(field elikz.ekpo = space)
Tables
TABLES: EKKO, "Purchase order - header"
EKPO, "Purchase order - lines"
EKET, "Purchase order - delivery date"
EKBE, "Purchase order - history
LFA1, "Supplier - general info"
STXH, "Text table - header info"
T001W, "Plant description table
MARA, "Material master
MAKT, "Material description table
T163X.
DATA: BEGIN OF TXTF_HEADER. "Purchase order header texts
INCLUDE STRUCTURE THEAD.
DATA: END OF TXTF_HEADER.
DATA: BEGIN OF TXTF_LINES OCCURS 2. "Purchase order header texts
INCLUDE STRUCTURE TLINE.
DATA: END OF TXTF_LINES.
DATA: WNAME(70),
WLPEIN(1),
WEINDT(10),
WMENGE LIKE EKET-MENGE,
WBISMT LIKE MARA-BISMT,
W_HISTORY(1).
SELECT-OPTIONS : S-EINDT FOR EKET-EINDT.
SELECT-OPTIONS : S-WAERS FOR EKKO-WAERS.
FIELD-GROUPS : HEADER, GROUP1.
INSERT EKPO-WERKS
EKET-LPEIN
EKET-EINDT
EKPO-EBELN
EKPO-EBELP
EKPO-MATNR
EKKO-WAERS
EKKO-WKURS
EKKO-KUFIX
EKKO-BEDAT INTO HEADER.
INSERT EKKO-SPRAS
EKKO-EKGRP
T163X-EPSTP
EKPO-TXZ01
EKPO-KONNR
EKPO-KTPNR
EKET-MENGE
EKPO-MEINS
EKPO-LGORT
EKET-WEMNG
EKPO-NETPR
EKPO-PEINH
EKPO-BPRME
EKPO-NETWR
EKKO-LIFNR
W_HISTORY INTO GROUP1.
General data
INITIALIZATION.
EM_SELKB = 'X'.
EM_SELKK = ' '.
EM_SELKL = ' '.
EM_SELKA = ' '.
Start of program
START-OF-SELECTION.
Read purchase order items for this plant with delivery completed
indicator = space
GET EKPO.
SELECT * FROM T163X WHERE SPRAS EQ SY-LANGU
AND PSTYP EQ EKPO-PSTYP.
EXIT.
ENDSELECT.
IF SY-SUBRC NE 0.
T163X-EPSTP = EKPO-PSTYP.
ENDIF.
CHECK S-WAERS.
GET EKET.
CHECK S-EINDT.
IF EKPO-ELIKZ = ' ' AND EKPO-LOEKZ = ' '.
if eket-wemng = 0 and eket-wamng = 0.
CLEAR : W_HISTORY.
SELECT * FROM EKBE WHERE EBELN = EKPO-EBELN
AND EBELP = EKPO-EBELP.
EXIT.
ENDSELECT.
IF SY-SUBRC = 0.
MOVE '*' TO W_HISTORY.
ENDIF.
EXTRACT GROUP1.
endif.
ENDIF.
END-OF-SELECTION.
Sort by plant - delivery date
SORT.
FORMAT INTENSIFIED OFF. "PPL26041995
LOOP.
read vendor
SELECT SINGLE * FROM LFA1
WHERE LIFNR = EKKO-LIFNR.
IF SY-SUBRC <> 0.
MOVE '???' TO LFA1-NAME1.
ENDIF.
search old materialnumber if needed
SELECT SINGLE * FROM MARA
WHERE MATNR = EKPO-MATNR.
IF SY-SUBRC <> 0.
MOVE '???' TO WBISMT.
ELSE.
MOVE MARA-BISMT TO WBISMT.
ENDIF.
read purchase order header text - first 2 lines of delivery text
CLEAR TXTF_LINES.
CLEAR TXTF_HEADER.
REFRESH TXTF_LINES.
MOVE EKPO-EBELN TO WNAME.
MOVE EKPO-EBELP TO WNAME+10.
SELECT SINGLE * FROM STXH
WHERE TDID = 'F04' AND
TDOBJECT = 'EKPO' AND
TDNAME = WNAME AND
TDSPRAS = EKKO-SPRAS.
IF SY-SUBRC = 0.
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = 'F04 '
LANGUAGE = EKKO-SPRAS
OBJECT = 'EKPO '
NAME = WNAME
IMPORTING
HEADER = TXTF_HEADER
TABLES
LINES = TXTF_LINES
EXCEPTIONS
ID = 01
LANGUAGE = 02
NAME = 03
NOT_FOUND = 04
OBJECT = 05
REFERENCE_CHECK = 06.
ENDIF.
READ TABLE TXTF_LINES INDEX 1.
print list
RESERVE 3 LINES.
AT NEW EKPO-WERKS.
SELECT SINGLE * FROM T001W WHERE WERKS = EKPO-WERKS.
IF SY-SUBRC NE 0. CLEAR T001W. ENDIF.
NEW-PAGE.
ENDAT.
CLEAR WEINDT.
CLEAR WLPEIN.
AT NEW EKET-EINDT.
CALL FUNCTION 'PERIOD_AND_DATE_CONVERT_OUTPUT'
EXPORTING
INTERNAL_DATE = EKET-EINDT
INTERNAL_PERIOD = EKET-LPEIN
IMPORTING
EXTERNAL_DATE = WEINDT
EXTERNAL_PERIOD = WLPEIN.
ENDAT.
WRITE: / WLPEIN,
3 WEINDT,
13 SY-VLINE(1),
14 EKPO-EBELN,
25 EKPO-EBELP+3(2),
28 T163X-EPSTP,
31 EKPO-MATNR,
add old material number
52 wbismt,
62 EKET-MENGE,
80 EKPO-MEINS,
85 EKKO-LIFNR,
116 SY-VLINE(1),
127 txtf_lines-tdline(40),
118 EKKO-WAERS,
122 EKPO-NETPR,
142 EKPO-PEINH,
152 EKPO-BPRME,
157 EKPO-NETWR,
177 EKKO-WKURS,
190 EKKO-KUFIX,
193 EKKO-BEDAT,
206 EKKO-EKGRP,
211 SY-VLINE,
216 W_HISTORY.
add storage location
171 sy-vline, ekpo-lgort,
178 sy-vline.
READ TABLE TXTF_LINES INDEX 2.
SELECT SINGLE * FROM MAKT WHERE MATNR = EKPO-MATNR
AND SPRAS = SY-LANGU.
IF SY-SUBRC NE 0.
MOVE EKPO-TXZ01 TO MAKT-MAKTX.
ENDIF.
WMENGE = EKET-MENGE - EKET-WEMNG.
IF EKPO-KONNR = SPACE.
WRITE:/13 SY-VLINE(1),
MAKT-MAKTX(30) UNDER EKPO-MATNR,
WMENGE UNDER EKET-MENGE,
LFA1-NAME1 UNDER EKKO-LIFNR,
126 sy-vline(1),
txtf_lines-tdline(40) under txtf_lines-tdline,
116 SY-VLINE(1),
171 sy-vline(1),
211 SY-VLINE(1).
ELSE.
WRITE:/13 SY-VLINE(1),
ekpo-konnr under ekpo-ebeln,
ekpo-ktpnr+3(2) under ekpo-ebelp,
MAKT-MAKTX(30) UNDER EKPO-MATNR,
WMENGE UNDER EKET-MENGE,
LFA1-NAME1 UNDER EKKO-LIFNR,
126 sy-vline(1),
txtf_lines-tdline(40) under txtf_lines-tdline,
167 sy-vline(1),
116 SY-VLINE(1),
211 SY-VLINE(1).
ENDIF.
ULINE /13(207).
AT END OF EKET-EINDT.
ULINE 1(12).
ENDAT.
ENDLOOP.
print delivery date with first line.
TOP-OF-PAGE.
CALL FUNCTION 'PERIOD_AND_DATE_CONVERT_OUTPUT'
EXPORTING
INTERNAL_DATE = EKET-EINDT
INTERNAL_PERIOD = EKET-LPEIN
IMPORTING
EXTERNAL_DATE = WEINDT
EXTERNAL_PERIOD = WLPEIN.
CALL FUNCTION 'Z_PRINT_TITEL' "PPL24041995
EXPORTING PROGNAME = 'ZMCH0089' "PPL24041995
TEXTTYPE = 'T' "PPL24041995
ORG_PROGNAME = ' '
PARAM_1 = EKPO-WERKS "PPL24041995
PARAM_2 = T001W-NAME2 "PPL24041995
PARAM_3 = ' ' "PPL24041995
PARAM_4 = ' ' "PPL24041995
PARAM_5 = ' '. "PPL24041995
Reward if helpful.
Chandralekha -
Hai,
how to upload the purchase order when one PO has three line items,
another has 100 line items, and so on.
can i use BAPI_PO_Create FM for this ?
if it possible ,how to use ?
Thanks & regards,
ManikandanCheck the following ex:
Data Declaration for BAPI *****************
data: begin of pohead occurs 10.
include structure BAPIMEPOHEADER.
data: end of pohead.
data: begin of poheadx occurs 10.
include structure BAPIMEPOHEADERX.
data: end of poheadx.
*EXPPURCHASEORDER
data: BEGIN OF ponum.
include structure BAPIMEPOHEADER.
data: end of ponum.
data: begin of poitem occurs 100.
include structure BAPIMEPOITEM.
data: end of poitem.
data: begin of poitemx occurs 100.
include structure BAPIMEPOITEMX.
data: end of poitemx.
data: begin of errmsg occurs 10.
include structure bapiret2.
data: end of errmsg.
data : errflag.
START-OF-SELECTION.
PERFORM UPLOAD_DATA.
*& Form UPLOAD_DATA
text
--> p1 text
<-- p2 text
FORM UPLOAD_DATA .
data: p_fdir(200) type c .
p_fdir = gfile.
data: begin of it_filedir occurs 10.
include structure salfldir.
data: end of it_filedir.
Get Current Directory Listing for OUT Dir
call function 'RZL_READ_DIR_LOCAL'
EXPORTING
name = p_fdir
TABLES
file_tbl = it_filedir.
data: it_filedir1 like it_filedir occurs 0 with header line.
loop at it_filedir.
if it_filedir-name(4) = 'CPOR' or it_filedir-name(4) = 'cpor'.
move it_filedir-name to it_filedir1-name.
append it_filedir1.
endif.
endloop.
IF IT_FILEDIR1[] IS INITIAL.
STOP.
ENDIF.
REFRESH I_MSG1.
CLEAR I_MSG1.
loop at it_filedir1.
REFRESH I_TAB.
REFRESH I_TAB2.
REFRESH I_TAB1.
data: g_file(100) type c .
name = it_filedir1-name.
concatenate: gfile '\' name into g_file.
data : i_tab1(200).
OPEN DATASET g_file FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
DO.
READ DATASET g_file INTO i_tab1.
if sy-subrc = 0.
split i_tab1 at ',' into i_tab-verkf i_tab-verkf1 i_tab-lifnr
i_tab-ebelp1 i_tab-werks
i_tab-matnr i_tab-idnlf
i_tab-menge i_tab-bprme i_tab-lewed i_tab-netpr.
else.
exit.
endif.
APPEND i_tab.
clear i_tab.
ENDDO.
ENDIF.
*************** error testing*******************
LOOP AT i_tab.
MOVE-CORRESPONDING i_tab TO etab1.
append etab1.
clear etab1.
ENDLOOP.
*************** end error testing*******************
DELETE DATASET g_file.
CLOSE DATASET g_file.
concatenate:
hfile '\' date1 '\' name into h_file.
OPEN DATASET h_file FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
LOOP AT I_TAB.
CONCATENATE I_TAB-VERKF ',' I_TAB-VERKF1 ',' I_TAB-LIFNR ','
I_TAB-EBELP1 ',' I_TAB-WERKS ',' I_TAB-MATNR ','
I_TAB-IDNLF ',' I_TAB-MENGE ',' I_TAB-BPRME ','
I_TAB-LEWED ',' I_TAB-NETPR INTO I_TAB2.
TRANSFER i_tab2 TO h_file.
ENDLOOP.
ENDIF.
CLOSE DATASET h_file.
MOVE I_TAB[] TO I_TAB3[].
DELETE ADJACENT DUPLICATES FROM I_TAB COMPARING VERKF.
loop at i_tab.
refresh pohead.
refresh poheadx.
refresh poitem.
refresh poitemX.
pohead-DOC_TYPE = i_tab-bsart.
pohead-VENDOR = i_tab-lifnr.
pohead-PURCH_ORG = c_ekorg.
pohead-CREAT_DATE = i_tab-verkf1.
pohead-PUR_GROUP = c_ekgrp.
pohead-COMP_CODE = c_bukrs.
pohead-SALES_PERS = I_TAB-VERKF2.
pohead-doc_date = sy-datum.
pohead-langu = sy-langu.
append pohead.
poheadx-DOC_TYPE = c_x.
poheadx-VENDOR = c_x.
poheadx-PURCH_ORG = c_x.
poheadx-PUR_GROUP = c_x.
poheadx-COMP_CODE = c_x.
poheadx-SALES_PERS = c_x.
poheadx-doc_date = c_x.
poheadx-langu = c_x.
append poheadx.
loop at i_tab3 WHERE VERKF = I_TAB-VERKF.
poitem-PO_ITEM = i_tab3-ebelp1.
poitem-MATERIAL = i_tab3-MATNR.
poitem-QUANTITY = i_tab3-MENGE.
poitem-PO_UNIT = i_tab3-BPRME.
poitem-NET_PRICE = i_tab3-NETPR.
poitem-PLANT = i_tab3-WERKS.
poitem-GR_TO_DATE = i_tab3-LEWED.
poitem-tax_code = c_x.
poitem-item_cat = c_x.
POITEM-ACCTASSCAT = c_x.
poitem-AGREEMENT = i_tab3-ebeln.
poitem-AGMT_ITEM = i_tab3-ebelp1.
poitem-VEND_MAT = i_tab3-IDNLF.
append poitem.
poitemx-PO_ITEM = i_tab3-ebelp1.
poitemx-MATERIAL = c_x.
poitemx-QUANTITY = c_x.
poitemx-PO_UNIT = c_x.
poitemx-NET_PRICE = c_x.
poitemx-PLANT = c_x.
poitemx-GR_TO_DATE = c_x.
poitemx-tax_code = c_x.
poitemx-item_cat = c_x.
POITEMx-ACCTASSCAT = c_x.
poitemx-AGREEMENT = 'X'.
poitemx-AGMT_ITEM = 'X'.
poitemx-VEND_MAT = c_x.
append poitemx.
endloop.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = pohead
POHEADERX = poheadx
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
NO_AUTHORITY =
NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER = ponum
EXPPOEXPIMPHEADER =
TABLES
RETURN = errmsg
POITEM = poitem
POITEMX = poitemx
POADDRDELIVERY =
POSCHEDULE =
POSCHEDULEX =
POACCOUNT =
POACCOUNTPROFITSEGMENT =
POACCOUNTX =
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
endloop.
if errflag is initial.
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
else.
write:/ ponum-PO_NUMBER, ponum-comp_code.
endif.
endif.
endloop.
ENDFORM. " UPLOAD_DATA -
Error while creation of PUrchase order by using BAPI.
Hi All,
We are creating a purchase order thru BAPI ("BAPI_POEC_CREATE") and we are passing the following parameters ( I_PO_HEADER , I_PO_ITEMS , I_PO_ACCASS , I_PO_PARTNER and I_PO_ORGDATA) to the bapi and after processing we are getting the following error and Abend messages.
Messages:
1) Enter at least one item or one limit ( we have added line items in I_PO_ITEMS structure).
2) Incorrect interface data for set 78 in method C.
3) Interface data contains errors.
Can anyone help me in fixing these errors inorder to proceed further.
Regards
DharmarajuHi there,
Did you manage to sort this problem ?
If not let me know
I am using the same and know how to overcome
Thanks
Turlock
T -
Need help! in purchase order report..
Hai,
I need to write a report
"<b>Interactive report</b> to display all the Purchase Orders for the Purchasing Organization and display the total, and individual values of all the Purchase Orders."
what are the tables to use for the above report ?
which field is used for Line-selection( for interactive report)
thanks in advanceHi,
Use the tables EKKO, EKPO and fetch the data and display.
On the basic list display the only EKKO data of the Purchase orgn
and in the second list Interactive use the EKPO details and do the totals.
Sort based on EKORG field and do the sums for Amount fields.
see the sample code and do accordingly:
REPORT ZMM_PO_REPORT message-Id yb
NO STANDARD PAGE HEADING
LINE-COUNT 60(1)
LINE-SIZE 230.
D A T A B A S E T A B L E S D E C L A R A T I O N
TABLES: lfa1, " Vendor Master
t161, " PO Doc Types
t024, " Purchase Groups
ekko. " PO Header
T Y P E S D E C L A R A T I O N S
Purchase Orders Main Structure
TYPES: BEGIN OF s_po,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
bukrs TYPE bukrs, " Company Code
bsart TYPE bbsrt, " PO Type
lifnr TYPE lifnr, " Vendor No
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
END OF s_po.
Purchase Orders History Structure
TYPES: BEGIN OF s_account,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
gjahr TYPE mjahr, " Fiscal Year
belnr TYPE mblnr, " PO Invoice No
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Local Currency
dmbtr TYPE dmbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
shkzg TYPE shkzg, " Dr/Cr Indicator
END OF s_account.
Purchase Orders History Structure(Item Sum)
TYPES: BEGIN OF s_inv_sum,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
END OF s_inv_sum.
Purchase Orders Main Structure
TYPES: BEGIN OF s_rep,
lifnr TYPE lifnr, " Vendor No
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
bsart TYPE bbsrt, " PO Type
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
name1 TYPE name1, " Plant
orewr TYPE netpr, " To be Invoiced Price
curr TYPE waers, " Inv Doc Currency
END OF s_rep.
D A T A D E C L A R A T I O N S
DATA: gv_title1 TYPE sylisel, " Report title
gv_dial. " Color flag
C O N S T A N T S D E C L A R A T I O N S
CONSTANTS: c_x VALUE 'X', " Flag X
c_h VALUE 'H', " Debit
c_vgabe TYPE vgabe VALUE '2'. " Transaction Type
I N T E R N A L T A B L E S D E C L A R A T I O N S
DATA: i_po TYPE STANDARD TABLE OF s_po WITH HEADER LINE,
" Purchase Order
i_inv TYPE STANDARD TABLE OF s_inv_sum WITH HEADER LINE,
" PO Invoice Values
i_rep TYPE STANDARD TABLE OF s_rep WITH HEADER LINE,
" PO Invoice Values
i_ekbe TYPE STANDARD TABLE OF s_account WITH HEADER LINE.
" PO Invoice Values
S E L E C T I O N S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr MATCHCODE OBJECT kred,
s_ebeln FOR ekko-ebeln MATCHCODE OBJECT mekk,
s_bsart FOR t161-bsart,
s_ekgrp FOR t024-ekgrp,
s_bedat FOR ekko-bedat.
SELECTION-SCREEN END OF BLOCK b1.
I N I T I A L I Z A T I O N *
INITIALIZATION.
A T S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN.
Validate the screen fields
PERFORM validate_screen.
S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Fetch main data
PERFORM fetch_data.
T O P - O F - P A G E *
TOP-OF-PAGE.
Header of the List
PERFORM header.
E N D - O F - P A G E *
Footer
END-OF-PAGE.
ULINE.
E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
Display the Report Output data
PERFORM display_data.
At Line-Selection
AT LINE-SELECTION.
When double clicked on EBELN display the details of Purchase Doc
PERFORM line_sel.
*& Form validate_screen
Validation of Selection Screen fields
FORM validate_screen .
Validation of Vendor Number
CLEAR lfa1-lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT lifnr UP TO 1 ROWS
INTO lfa1-lifnr
FROM lfa1
WHERE lifnr IN s_lifnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Vendor'(002).
ENDIF.
ENDIF.
Validation of PO Number
CLEAR ekko-ebeln.
IF NOT s_ebeln[] IS INITIAL.
SELECT ebeln UP TO 1 ROWS
INTO ekko-ebeln
FROM ekko
WHERE ebeln IN s_ebeln.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Document Number'(003).
ENDIF.
ENDIF.
Validation of PO Document Type
CLEAR t161-bsart.
IF NOT s_bsart[] IS INITIAL.
SELECT bsart UP TO 1 ROWS
INTO t161-bsart
FROM t161
WHERE bsart IN s_bsart.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchase Document Type'(004).
ENDIF.
ENDIF.
Validation of Purchasing Group
CLEAR t024-ekgrp.
IF NOT s_ekgrp[] IS INITIAL.
SELECT ekgrp UP TO 1 ROWS
INTO t024-ekgrp
FROM t024
WHERE ekgrp IN s_ekgrp.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Group'(005).
ENDIF.
ENDIF.
ENDFORM. " validate_screen
*& Form fetch_data
Fetching the PO related data from Database Tables
FORM fetch_data .
CLEAR i_po.
REFRESH i_po.
SELECT a~ebeln " PO No.
b~ebelp " PO Item
a~bstyp " PO Category
a~bukrs " Company Code
a~bsart " PO Type
a~lifnr " Vendor No
a~ekgrp " Purchase Group
a~waers " Currency
a~bedat " PO Date
b~txz01 " Material Text
b~werks " Plant
b~lgort " Storage Location
b~matkl " Material Group
b~menge " PR Quantity
b~meins " UOM
b~bprme " Price Unit
b~netpr " Net price
b~peinh " Price Unit UOM
b~pstyp " Item Category
b~knttp " Account Assignment Category
INTO TABLE i_po
FROM ekko AS a JOIN ekpo AS b
ON a~ebeln = b~ebeln
WHERE a~ebeln IN s_ebeln AND
a~lifnr IN s_lifnr AND
a~ekgrp IN s_ekgrp AND
a~bsart IN s_bsart AND
a~bedat IN s_bedat.
SORT i_po BY ebeln ebelp.
break-point.
IF NOT i_po[] IS INITIAL.
Fetch the PO History/Invoice Details from EKBE Table
CLEAR i_ekbe.
REFRESH i_ekbe.
SELECT ebeln " PO No.
ebelp " PO Item
gjahr " Fiscal Year
belnr " PO Invoice No
menge " PR Quantity
wrbtr " Price in Local Currency
dmbtr " Price in Foreign Currency
waers " Currency
shkzg " Dr/Cr Indicator
INTO TABLE i_ekbe
FROM ekbe
FOR ALL ENTRIES IN i_po
WHERE ebeln = i_po-ebeln AND
ebelp = i_po-ebelp AND
vgabe = c_vgabe.
break-point.
IF sy-subrc = 0.
SORT i_ekbe BY ebeln ebelp.
LOOP AT i_ekbe.
IF i_ekbe-shkzg = c_h.
i_ekbe-wrbtr = i_ekbe-wrbtr * -1.
ENDIF.
MODIFY i_ekbe.
ENDLOOP.
break-point.
Sum up the Item wise Invoice totals
LOOP AT i_ekbe.
AT END OF ebelp.
READ TABLE i_ekbe INDEX sy-tabix.
SUM.
MOVE-CORRESPONDING i_ekbe TO i_inv.
APPEND i_inv.
ENDAT.
CLEAR i_inv.
ENDLOOP.
SORT i_inv BY ebeln ebelp.
break-point.
ENDIF.
ENDIF.
Move the Vendor Name and Invoice Values to I_rep Internal Table
LOOP AT i_po.
MOVE-CORRESPONDING i_po TO i_rep.
CLEAR i_inv.
READ TABLE i_inv WITH KEY ebeln = i_po-ebeln
ebelp = i_po-ebelp.
IF sy-subrc = 0.
i_rep-orewr = ( i_po-menge - i_inv-menge ) * i_po-netpr.
i_rep-curr = i_inv-waers.
ELSE.
i_rep-orewr = i_po-menge * i_po-netpr.
i_rep-curr = i_po-waers.
ENDIF.
break-point.
Get the Vendor Name
CLEAR lfa1-name1.
SELECT SINGLE name1 FROM lfa1 INTO lfa1-name1
WHERE lifnr = i_po-lifnr.
IF sy-subrc = 0.
i_rep-name1 = lfa1-name1.
ENDIF.
APPEND i_rep.
CLEAR i_rep.
break-point.
ENDLOOP.
SORT i_rep BY lifnr ebeln ebelp.
DELETE i_rep WHERE orewr LE 0.
break-point.
ENDFORM. " fetch_data
*& Form display_data
Display the Report Output data
FORM display_data .
DATA: lv_flag, " New Flag
lv_rec TYPE i. " No of Records
CLEAR lv_rec.
IF i_rep[] IS INITIAL.
MESSAGE e000 WITH 'No Data found'(022).
ELSE.
LOOP AT i_rep.
Toggle Color
PERFORM toggle_color.
IF lv_flag <> space.
NEW-LINE.
ENDIF.
At New Purchase Document
AT NEW ebeln.
WRITE:/1 sy-vline, 2(10) i_rep-ebeln INTENSIFIED OFF.
lv_flag = c_x.
lv_rec = lv_rec + 1.
ENDAT.
WRITE: 1 sy-vline,
12 sy-vline,13(4) i_rep-bsart,
17 sy-vline,18(10) i_rep-lifnr,
28 sy-vline,29(35) i_rep-name1,
64 sy-vline,65(4) i_rep-ekgrp,
69 sy-vline,70(10) i_rep-bedat,
80 sy-vline,81(5) i_rep-ebelp,
86 sy-vline,87(40) i_rep-txz01,
127 sy-vline,128(9) i_rep-matkl,
137 sy-vline,138(1) i_rep-pstyp,
139 sy-vline,140(1) i_rep-knttp,
141 sy-vline,142(4) i_rep-werks,
146 sy-vline,147(4) i_rep-lgort,
151 sy-vline,152(13) i_rep-menge UNIT i_rep-meins,
165 sy-vline,166(3) i_rep-meins,
169 sy-vline,170(15) i_rep-netpr CURRENCY i_rep-waers,
185 sy-vline,186(4) i_rep-waers,
190 sy-vline,191(5) i_rep-peinh,
196 sy-vline,197(4) i_rep-bprme,
201 sy-vline,202(15) i_rep-orewr CURRENCY i_rep-curr,
217 sy-vline,218(4) i_rep-curr,
222 sy-vline,223(7) i_rep-bstyp centered,
230 sy-vline.
NEW-LINE.
hide: i_rep-ebeln.
ENDLOOP.
ULINE.
FORMAT COLOR OFF.
WRITE : /2 'Total Number of Purchasing Documents:'(025) COLOR 3,
lv_rec COLOR 3.
ENDIF.
ENDFORM. " display_data
*& Form header
Write the Report Header
FORM header .
FORMAT RESET.
header
WRITE:/1(230) 'LIST OF PURCHASE DOCUMENTS PER VENDOR'(006) CENTERED.
SKIP.
FORMAT COLOR COL_HEADING.
ULINE.
WRITE:/1 sy-vline,2(10) 'Pur.Doc.No'(006) CENTERED,
12 sy-vline,13(4) 'Type'(007),
17 sy-vline,18(10) 'Vendor'(008) CENTERED,
28 sy-vline,29(35) 'Name'(009) CENTERED,
64 sy-vline,65(4) 'PGrp'(010) CENTERED,
69 sy-vline,70(10) 'Doc.Date'(012) CENTERED,
80 sy-vline,81(5) 'Item'(011),
86 sy-vline,87(40) 'Material Short Text'(024) CENTERED,
127 sy-vline,128(9) 'Mat.Group'(013),
137 sy-vline,138(1) 'I',
139 sy-vline,140(1) 'A',
141 sy-vline,142(4) 'Plnt'(014),
146 sy-vline,147(4) 'SLoc'(015),
151 sy-vline,152(13) 'Quantity'(016) CENTERED,
165 sy-vline,166(3) 'UoM'(017),
169 sy-vline,170(15) 'Net Value'(018) CENTERED,
185 sy-vline,186(4) 'Curr'(019),
190 sy-vline,191(5) 'Per'(020),
196 sy-vline,197(4) 'Unit'(021),
201 sy-vline,202(15) 'To be Invoiced'(023) CENTERED,
217 sy-vline,218(4) 'Curr'(019),
222 sy-vline,223(7) 'Doc.Cat'(026),
230 sy-vline.
ULINE.
ENDFORM. " header
*& Form toggle_color
This routine alters the color of the records in the list
FORM toggle_color.
IF gv_dial = space.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
gv_dial = c_x.
ELSE.
FORMAT COLOR 1 INTENSIFIED OFF.
CLEAR gv_dial.
ENDIF.
ENDFORM. " toggle_color
*& Form LINE_SEL
*When double clicked on EBELN field display the details of Purchase Doc
FORM line_sel.
CASE sy-lsind.
WHEN '1'.
DATA: lv_field(20),
lv_value(10),
lv_bstyp like i_rep-bstyp.
clear: lv_bstyp,lv_value, lv_field.
GET CURSOR FIELD lv_field VALUE lv_value.
IF lv_field = 'I_REP-EBELN'.
IF NOT lv_value IS INITIAL.
READ LINE sy-index FIELD VALUE i_rep-bstyp
INTO lv_bstyp.
READ CURRENT LINE FIELD VALUE i_rep-bstyp INTO lv_bstyp.
if lv_bstyp = 'F'.
SET PARAMETER ID 'BES' FIELD lv_value.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
elseif ( lv_bstyp = 'K' or lv_bstyp = 'L' ).
SET PARAMETER ID 'VRT' FIELD lv_value.
CALL TRANSACTION 'ME33' AND SKIP FIRST SCREEN.
elseif lv_bstyp = 'A'.
SET PARAMETER ID 'ANF' FIELD lv_value.
CALL TRANSACTION 'ME43' AND SKIP FIRST SCREEN.
endif.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " line_sel
reward if useful
regards,
ANJI
Message was edited by:
Anji Reddy Vangala -
Purchase order output message disappear at approval
Gurus,
Anyone encountered the problem of output type disappearing when purchase orders approval is carried out ?
PO does not appear anymore in ME9F and vendors are calling as they haven t received the order. No problem when PO amount is below fisrt approval range or until PO is getting approved.
Thanks for your help
OlivierA specific field "Plant on header level 2" was added to structure KOMKBEA and the field for this value is lost on PO change mode.
The problem is not linked to any SAP standard related issue. Am therefore closing this thread. -
Standard report on purchase order and bank details
Respected all
I need a standard report in which i could get purchase order number , internal order number , vendor name , invoice number , cheque number , cheque amount and cheque date .
Is there any standard report available? your replies are highly appriciated.
thanking you
abhaytry MC.A
Please search before asking, even in your menu structure.
There are binocluar icons in your SAP Easy access screen to search in the menu.
Or enter SEARCH_SAP_MENU in the ok-field and search for transactions. -
Urgent :Doubt on open Purchase orders
Hi friends,
i will be more help full if anybody can help me on below issue how to find open PO and partially open PO.
Only open purchase orders will be extracted for conversion into Destination Server. An open purchase order is defined as any unshipped, non-cancelled with open quantities. In regards to, partially open purchase orders, we will only convert open units (i.e. Original ordered qty was 300; 70 have shipped, 230 remain open Target Server sales order will have an original order qty of 230).
also where to find that Sub Contracting orders and Sample orders.
Orders not considered for migration because they will have either shipped in full or deleted prior to data migration as a part of data clean-up: ALL subcontracting orders; sample orders
please help me on the above two issues.
thanks and Regards,
Gokul.Hi
First take the ALL Po's from EKKO and EKPO tables and check for the different GR's and GI's qty's from MKPF and MSEG tables and you have to compare the PO qty with the total GR/GI qty's and to find the OPEN po's
see the sample report
*& Report ZMM_PO_REPORT
REPORT ZMM_PO_REPORT message-Id yb
NO STANDARD PAGE HEADING
LINE-COUNT 60(1)
LINE-SIZE 230.
D A T A B A S E T A B L E S D E C L A R A T I O N
TABLES: lfa1, " Vendor Master
t161, " PO Doc Types
t024, " Purchase Groups
ekko. " PO Header
T Y P E S D E C L A R A T I O N S
Purchase Orders Main Structure
TYPES: BEGIN OF s_po,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
bukrs TYPE bukrs, " Company Code
bsart TYPE bbsrt, " PO Type
lifnr TYPE lifnr, " Vendor No
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
END OF s_po.
Purchase Orders History Structure
TYPES: BEGIN OF s_account,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
gjahr TYPE mjahr, " Fiscal Year
belnr TYPE mblnr, " PO Invoice No
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Local Currency
dmbtr TYPE dmbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
shkzg TYPE shkzg, " Dr/Cr Indicator
END OF s_account.
Purchase Orders History Structure(Item Sum)
TYPES: BEGIN OF s_inv_sum,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
END OF s_inv_sum.
Purchase Orders Main Structure
TYPES: BEGIN OF s_rep,
lifnr TYPE lifnr, " Vendor No
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
bsart TYPE bbsrt, " PO Type
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
name1 TYPE name1, " Plant
orewr TYPE netpr, " To be Invoiced Price
curr TYPE waers, " Inv Doc Currency
END OF s_rep.
D A T A D E C L A R A T I O N S
DATA: gv_title1 TYPE sylisel, " Report title
gv_dial. " Color flag
C O N S T A N T S D E C L A R A T I O N S
CONSTANTS: c_x VALUE 'X', " Flag X
c_h VALUE 'H', " Debit
c_vgabe TYPE vgabe VALUE '2'. " Transaction Type
I N T E R N A L T A B L E S D E C L A R A T I O N S
DATA: i_po TYPE STANDARD TABLE OF s_po WITH HEADER LINE,
" Purchase Order
i_inv TYPE STANDARD TABLE OF s_inv_sum WITH HEADER LINE,
" PO Invoice Values
i_rep TYPE STANDARD TABLE OF s_rep WITH HEADER LINE,
" PO Invoice Values
i_ekbe TYPE STANDARD TABLE OF s_account WITH HEADER LINE.
" PO Invoice Values
S E L E C T I O N S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr MATCHCODE OBJECT kred,
s_ebeln FOR ekko-ebeln MATCHCODE OBJECT mekk,
s_bsart FOR t161-bsart,
s_ekgrp FOR t024-ekgrp,
s_bedat FOR ekko-bedat.
SELECTION-SCREEN END OF BLOCK b1.
I N I T I A L I Z A T I O N *
INITIALIZATION.
A T S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN.
Validate the screen fields
PERFORM validate_screen.
S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Fetch main data
PERFORM fetch_data.
T O P - O F - P A G E *
TOP-OF-PAGE.
Header of the List
PERFORM header.
E N D - O F - P A G E *
Footer
END-OF-PAGE.
ULINE.
E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
Display the Report Output data
PERFORM display_data.
At Line-Selection
AT LINE-SELECTION.
When double clicked on EBELN display the details of Purchase Doc
PERFORM line_sel.
*& Form validate_screen
Validation of Selection Screen fields
FORM validate_screen .
Validation of Vendor Number
CLEAR lfa1-lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT lifnr UP TO 1 ROWS
INTO lfa1-lifnr
FROM lfa1
WHERE lifnr IN s_lifnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Vendor'(002).
ENDIF.
ENDIF.
Validation of PO Number
CLEAR ekko-ebeln.
IF NOT s_ebeln[] IS INITIAL.
SELECT ebeln UP TO 1 ROWS
INTO ekko-ebeln
FROM ekko
WHERE ebeln IN s_ebeln.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Document Number'(003).
ENDIF.
ENDIF.
Validation of PO Document Type
CLEAR t161-bsart.
IF NOT s_bsart[] IS INITIAL.
SELECT bsart UP TO 1 ROWS
INTO t161-bsart
FROM t161
WHERE bsart IN s_bsart.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchase Document Type'(004).
ENDIF.
ENDIF.
Validation of Purchasing Group
CLEAR t024-ekgrp.
IF NOT s_ekgrp[] IS INITIAL.
SELECT ekgrp UP TO 1 ROWS
INTO t024-ekgrp
FROM t024
WHERE ekgrp IN s_ekgrp.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Group'(005).
ENDIF.
ENDIF.
ENDFORM. " validate_screen
*& Form fetch_data
Fetching the PO related data from Database Tables
FORM fetch_data .
CLEAR i_po.
REFRESH i_po.
SELECT a~ebeln " PO No.
b~ebelp " PO Item
a~bstyp " PO Category
a~bukrs " Company Code
a~bsart " PO Type
a~lifnr " Vendor No
a~ekgrp " Purchase Group
a~waers " Currency
a~bedat " PO Date
b~txz01 " Material Text
b~werks " Plant
b~lgort " Storage Location
b~matkl " Material Group
b~menge " PR Quantity
b~meins " UOM
b~bprme " Price Unit
b~netpr " Net price
b~peinh " Price Unit UOM
b~pstyp " Item Category
b~knttp " Account Assignment Category
INTO TABLE i_po
FROM ekko AS a JOIN ekpo AS b
ON a~ebeln = b~ebeln
WHERE a~ebeln IN s_ebeln AND
a~lifnr IN s_lifnr AND
a~ekgrp IN s_ekgrp AND
a~bsart IN s_bsart AND
a~bedat IN s_bedat.
SORT i_po BY ebeln ebelp.
break-point.
IF NOT i_po[] IS INITIAL.
Fetch the PO History/Invoice Details from EKBE Table
CLEAR i_ekbe.
REFRESH i_ekbe.
SELECT ebeln " PO No.
ebelp " PO Item
gjahr " Fiscal Year
belnr " PO Invoice No
menge " PR Quantity
wrbtr " Price in Local Currency
dmbtr " Price in Foreign Currency
waers " Currency
shkzg " Dr/Cr Indicator
INTO TABLE i_ekbe
FROM ekbe
FOR ALL ENTRIES IN i_po
WHERE ebeln = i_po-ebeln AND
ebelp = i_po-ebelp AND
vgabe = c_vgabe.
break-point.
IF sy-subrc = 0.
SORT i_ekbe BY ebeln ebelp.
LOOP AT i_ekbe.
IF i_ekbe-shkzg = c_h.
i_ekbe-wrbtr = i_ekbe-wrbtr * -1.
ENDIF.
MODIFY i_ekbe.
ENDLOOP.
break-point.
Sum up the Item wise Invoice totals
LOOP AT i_ekbe.
AT END OF ebelp.
READ TABLE i_ekbe INDEX sy-tabix.
SUM.
MOVE-CORRESPONDING i_ekbe TO i_inv.
APPEND i_inv.
ENDAT.
CLEAR i_inv.
ENDLOOP.
SORT i_inv BY ebeln ebelp.
break-point.
ENDIF.
ENDIF.
Move the Vendor Name and Invoice Values to I_rep Internal Table
LOOP AT i_po.
MOVE-CORRESPONDING i_po TO i_rep.
CLEAR i_inv.
READ TABLE i_inv WITH KEY ebeln = i_po-ebeln
ebelp = i_po-ebelp.
IF sy-subrc = 0.
i_rep-orewr = ( i_po-menge - i_inv-menge ) * i_po-netpr.
i_rep-curr = i_inv-waers.
ELSE.
i_rep-orewr = i_po-menge * i_po-netpr.
i_rep-curr = i_po-waers.
ENDIF.
break-point.
Get the Vendor Name
CLEAR lfa1-name1.
SELECT SINGLE name1 FROM lfa1 INTO lfa1-name1
WHERE lifnr = i_po-lifnr.
IF sy-subrc = 0.
i_rep-name1 = lfa1-name1.
ENDIF.
APPEND i_rep.
CLEAR i_rep.
break-point.
ENDLOOP.
SORT i_rep BY lifnr ebeln ebelp.
DELETE i_rep WHERE orewr LE 0.
break-point.
ENDFORM. " fetch_data
*& Form display_data
Display the Report Output data
FORM display_data .
DATA: lv_flag, " New Flag
lv_rec TYPE i. " No of Records
CLEAR lv_rec.
IF i_rep[] IS INITIAL.
MESSAGE e000 WITH 'No Data found'(022).
ELSE.
LOOP AT i_rep.
Toggle Color
PERFORM toggle_color.
IF lv_flag <> space.
NEW-LINE.
ENDIF.
At New Purchase Document
AT NEW ebeln.
WRITE:/1 sy-vline, 2(10) i_rep-ebeln INTENSIFIED OFF.
lv_flag = c_x.
lv_rec = lv_rec + 1.
ENDAT.
WRITE: 1 sy-vline,
12 sy-vline,13(4) i_rep-bsart,
17 sy-vline,18(10) i_rep-lifnr,
28 sy-vline,29(35) i_rep-name1,
64 sy-vline,65(4) i_rep-ekgrp,
69 sy-vline,70(10) i_rep-bedat,
80 sy-vline,81(5) i_rep-ebelp,
86 sy-vline,87(40) i_rep-txz01,
127 sy-vline,128(9) i_rep-matkl,
137 sy-vline,138(1) i_rep-pstyp,
139 sy-vline,140(1) i_rep-knttp,
141 sy-vline,142(4) i_rep-werks,
146 sy-vline,147(4) i_rep-lgort,
151 sy-vline,152(13) i_rep-menge UNIT i_rep-meins,
165 sy-vline,166(3) i_rep-meins,
169 sy-vline,170(15) i_rep-netpr CURRENCY i_rep-waers,
185 sy-vline,186(4) i_rep-waers,
190 sy-vline,191(5) i_rep-peinh,
196 sy-vline,197(4) i_rep-bprme,
201 sy-vline,202(15) i_rep-orewr CURRENCY i_rep-curr,
217 sy-vline,218(4) i_rep-curr,
222 sy-vline,223(7) i_rep-bstyp centered,
230 sy-vline.
NEW-LINE.
hide: i_rep-ebeln.
ENDLOOP.
ULINE.
FORMAT COLOR OFF.
WRITE : /2 'Total Number of Purchasing Documents:'(025) COLOR 3,
lv_rec COLOR 3.
ENDIF.
ENDFORM. " display_data
*& Form header
Write the Report Header
FORM header .
FORMAT RESET.
header
WRITE:/1(230) 'LIST OF PURCHASE DOCUMENTS PER VENDOR'(006) CENTERED.
SKIP.
FORMAT COLOR COL_HEADING.
ULINE.
WRITE:/1 sy-vline,2(10) 'Pur.Doc.No'(006) CENTERED,
12 sy-vline,13(4) 'Type'(007),
17 sy-vline,18(10) 'Vendor'(008) CENTERED,
28 sy-vline,29(35) 'Name'(009) CENTERED,
64 sy-vline,65(4) 'PGrp'(010) CENTERED,
69 sy-vline,70(10) 'Doc.Date'(012) CENTERED,
80 sy-vline,81(5) 'Item'(011),
86 sy-vline,87(40) 'Material Short Text'(024) CENTERED,
127 sy-vline,128(9) 'Mat.Group'(013),
137 sy-vline,138(1) 'I',
139 sy-vline,140(1) 'A',
141 sy-vline,142(4) 'Plnt'(014),
146 sy-vline,147(4) 'SLoc'(015),
151 sy-vline,152(13) 'Quantity'(016) CENTERED,
165 sy-vline,166(3) 'UoM'(017),
169 sy-vline,170(15) 'Net Value'(018) CENTERED,
185 sy-vline,186(4) 'Curr'(019),
190 sy-vline,191(5) 'Per'(020),
196 sy-vline,197(4) 'Unit'(021),
201 sy-vline,202(15) 'To be Invoiced'(023) CENTERED,
217 sy-vline,218(4) 'Curr'(019),
222 sy-vline,223(7) 'Doc.Cat'(026),
230 sy-vline.
ULINE.
ENDFORM. " header
*& Form toggle_color
This routine alters the color of the records in the list
FORM toggle_color.
IF gv_dial = space.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
gv_dial = c_x.
ELSE.
FORMAT COLOR 1 INTENSIFIED OFF.
CLEAR gv_dial.
ENDIF.
ENDFORM. " toggle_color
*& Form LINE_SEL
*When double clicked on EBELN field display the details of Purchase Doc
FORM line_sel.
CASE sy-lsind.
WHEN '1'.
DATA: lv_field(20),
lv_value(10),
lv_bstyp like i_rep-bstyp.
clear: lv_bstyp,lv_value, lv_field.
GET CURSOR FIELD lv_field VALUE lv_value.
IF lv_field = 'I_REP-EBELN'.
IF NOT lv_value IS INITIAL.
READ LINE sy-index FIELD VALUE i_rep-bstyp
INTO lv_bstyp.
READ CURRENT LINE FIELD VALUE i_rep-bstyp INTO lv_bstyp.
if lv_bstyp = 'F'.
SET PARAMETER ID 'BES' FIELD lv_value.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
elseif ( lv_bstyp = 'K' or lv_bstyp = 'L' ).
SET PARAMETER ID 'VRT' FIELD lv_value.
CALL TRANSACTION 'ME33' AND SKIP FIRST SCREEN.
elseif lv_bstyp = 'A'.
SET PARAMETER ID 'ANF' FIELD lv_value.
CALL TRANSACTION 'ME43' AND SKIP FIRST SCREEN.
endif.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " line_sel
<b>Reward points for useful Answers</b>
Regards
Anji -
report to list the purchase order quantity for statistical delivery date which gives the cumulative totals for the plants, material group, factory which were entered in the selection criteria.
*& Report ZMM_PO_REPORT
REPORT ZMM_PO_REPORT message-Id yb
NO STANDARD PAGE HEADING
LINE-COUNT 60(1)
LINE-SIZE 256.
D A T A B A S E T A B L E S D E C L A R A T I O N
TABLES: lfa1, " Vendor Master
t161, " PO Doc Types
t024, " Purchase Groups
ekko. " PO Header
T Y P E S D E C L A R A T I O N S
Purchase Orders Main Structure
TYPES: BEGIN OF s_po,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
ihrez TYPE ihrez, " Your reference
unsez TYPE unsez, " Our Reference
bukrs TYPE bukrs, " Company Code
bsart TYPE bbsrt, " PO Type
lifnr TYPE lifnr, " Vendor No
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
END OF s_po.
Purchase Orders History Structure
TYPES: BEGIN OF s_account,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
gjahr TYPE mjahr, " Fiscal Year
belnr TYPE mblnr, " PO Invoice No
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Local Currency
dmbtr TYPE dmbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
shkzg TYPE shkzg, " Dr/Cr Indicator
END OF s_account.
Purchase Orders History Structure(Item Sum)
TYPES: BEGIN OF s_inv_sum,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
END OF s_inv_sum.
Purchase Orders Main Structure
TYPES: BEGIN OF s_rep,
lifnr TYPE lifnr, " Vendor No
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
ihrez TYPE ihrez, " Your Reference
unsez TYPE unsez, " Our Reference
bsart TYPE bbsrt, " PO Type
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
name1 TYPE name1, " Plant
orewr TYPE netpr, " To be Invoiced Price
curr TYPE waers, " Inv Doc Currency
END OF s_rep.
D A T A D E C L A R A T I O N S
DATA: gv_title1 TYPE sylisel, " Report title
gv_dial. " Color flag
C O N S T A N T S D E C L A R A T I O N S
CONSTANTS: c_x VALUE 'X', " Flag X
c_h VALUE 'H', " Debit
c_vgabe TYPE vgabe VALUE '2'. " Transaction Type
I N T E R N A L T A B L E S D E C L A R A T I O N S
DATA: i_po TYPE STANDARD TABLE OF s_po WITH HEADER LINE,
" Purchase Order
i_inv TYPE STANDARD TABLE OF s_inv_sum WITH HEADER LINE,
" PO Invoice Values
i_rep TYPE STANDARD TABLE OF s_rep WITH HEADER LINE,
" PO Invoice Values
i_ekbe TYPE STANDARD TABLE OF s_account WITH HEADER LINE.
" PO Invoice Values
S E L E C T I O N S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr MATCHCODE OBJECT kred,
s_ebeln FOR ekko-ebeln MATCHCODE OBJECT mekk,
s_bsart FOR t161-bsart,
s_ekgrp FOR t024-ekgrp,
s_bedat FOR ekko-bedat.
SELECTION-SCREEN END OF BLOCK b1.
I N I T I A L I Z A T I O N *
INITIALIZATION.
A T S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN.
Validate the screen fields
PERFORM validate_screen.
S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Fetch main data
PERFORM fetch_data.
T O P - O F - P A G E *
TOP-OF-PAGE.
Header of the List
PERFORM header.
E N D - O F - P A G E *
Footer
END-OF-PAGE.
ULINE.
E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
Display the Report Output data
PERFORM display_data.
At Line-Selection
AT LINE-SELECTION.
When double clicked on EBELN display the details of Purchase Doc
PERFORM line_sel.
*& Form validate_screen
Validation of Selection Screen fields
FORM validate_screen .
Validation of Vendor Number
CLEAR lfa1-lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT lifnr UP TO 1 ROWS
INTO lfa1-lifnr
FROM lfa1
WHERE lifnr IN s_lifnr.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Vendor'(002).
ENDIF.
ENDIF.
Validation of PO Number
CLEAR ekko-ebeln.
IF NOT s_ebeln[] IS INITIAL.
SELECT ebeln UP TO 1 ROWS
INTO ekko-ebeln
FROM ekko
WHERE ebeln IN s_ebeln.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Document Number'(003).
ENDIF.
ENDIF.
Validation of PO Document Type
CLEAR t161-bsart.
IF NOT s_bsart[] IS INITIAL.
SELECT bsart UP TO 1 ROWS
INTO t161-bsart
FROM t161
WHERE bsart IN s_bsart.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Purchase Document Type'(004).
ENDIF.
ENDIF.
Validation of Purchasing Group
CLEAR t024-ekgrp.
IF NOT s_ekgrp[] IS INITIAL.
SELECT ekgrp UP TO 1 ROWS
INTO t024-ekgrp
FROM t024
WHERE ekgrp IN s_ekgrp.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Purchasing Group'(005).
ENDIF.
ENDIF.
ENDFORM. " validate_screen
*& Form fetch_data
Fetching the PO related data from Database Tables
FORM fetch_data .
CLEAR i_po.
REFRESH i_po.
SELECT a~ebeln " PO No.
b~ebelp " PO Item
a~bstyp " PO Category
a~ihrez " Your Reference
a~unsez " Our Reference
a~bukrs " Company Code
a~bsart " PO Type
a~lifnr " Vendor No
a~ekgrp " Purchase Group
a~waers " Currency
a~bedat " PO Date
b~txz01 " Material Text
b~werks " Plant
b~lgort " Storage Location
b~matkl " Material Group
b~menge " PR Quantity
b~meins " UOM
b~bprme " Price Unit
b~netpr " Net price
b~peinh " Price Unit UOM
b~pstyp " Item Category
b~knttp " Account Assignment Category
INTO TABLE i_po
FROM ekko AS a JOIN ekpo AS b
ON a~ebeln = b~ebeln
WHERE a~ebeln IN s_ebeln AND
a~lifnr IN s_lifnr AND
a~ekgrp IN s_ekgrp AND
a~bsart IN s_bsart AND
a~bedat IN s_bedat.
SORT i_po BY ebeln ebelp.
IF NOT i_po[] IS INITIAL.
Fetch the PO History/Invoice Details from EKBE Table
CLEAR i_ekbe.
REFRESH i_ekbe.
SELECT ebeln " PO No.
ebelp " PO Item
gjahr " Fiscal Year
belnr " PO Invoice No
menge " PR Quantity
wrbtr " Price in Local Currency
dmbtr " Price in Foreign Currency
waers " Currency
shkzg " Dr/Cr Indicator
INTO TABLE i_ekbe
FROM ekbe
FOR ALL ENTRIES IN i_po
WHERE ebeln = i_po-ebeln AND
ebelp = i_po-ebelp AND
vgabe = c_vgabe.
IF sy-subrc = 0.
SORT i_ekbe BY ebeln ebelp.
LOOP AT i_ekbe.
IF i_ekbe-shkzg = c_h.
i_ekbe-wrbtr = i_ekbe-wrbtr * -1.
ENDIF.
MODIFY i_ekbe.
ENDLOOP.
Sum up the Item wise Invoice totals
LOOP AT i_ekbe.
AT END OF ebelp.
READ TABLE i_ekbe INDEX sy-tabix.
SUM.
MOVE-CORRESPONDING i_ekbe TO i_inv.
APPEND i_inv.
ENDAT.
CLEAR i_inv.
ENDLOOP.
SORT i_inv BY ebeln ebelp.
ENDIF.
ENDIF.
Move the Vendor Name and Invoice Values to I_rep Internal Table
LOOP AT i_po.
MOVE-CORRESPONDING i_po TO i_rep.
CLEAR i_inv.
READ TABLE i_inv WITH KEY ebeln = i_po-ebeln
ebelp = i_po-ebelp.
IF sy-subrc = 0.
i_rep-orewr = ( i_po-menge - i_inv-menge ) * i_po-netpr.
i_rep-curr = i_inv-waers.
ELSE.
i_rep-orewr = i_po-menge * i_po-netpr.
i_rep-curr = i_po-waers.
ENDIF.
Get the Vendor Name
CLEAR lfa1-name1.
SELECT SINGLE name1 FROM lfa1 INTO lfa1-name1
WHERE lifnr = i_po-lifnr.
IF sy-subrc = 0.
i_rep-name1 = lfa1-name1.
ENDIF.
APPEND i_rep.
CLEAR i_rep.
ENDLOOP.
SORT i_rep BY lifnr ebeln ebelp.
DELETE i_rep WHERE orewr LE 0.
ENDFORM. " fetch_data
*& Form display_data
Display the Report Output data
FORM display_data .
DATA: lv_flag, " New Flag
lv_rec TYPE i. " No of Records
CLEAR lv_rec.
IF i_rep[] IS INITIAL.
MESSAGE e000 WITH 'No Data found'(022).
ELSE.
LOOP AT i_rep.
Toggle Color
PERFORM toggle_color.
IF lv_flag space.
NEW-LINE.
ENDIF.
At New Purchase Document
AT NEW ebeln.
WRITE:/1 sy-vline, 2(10) i_rep-ebeln INTENSIFIED OFF.
lv_flag = c_x.
lv_rec = lv_rec + 1.
ENDAT.
WRITE: 1 sy-vline,
12 sy-vline,13(4) i_rep-bsart,
17 sy-vline,18(10) i_rep-lifnr,
28 sy-vline,29(35) i_rep-name1,
64 sy-vline,65(4) i_rep-ekgrp,
69 sy-vline,70(10) i_rep-bedat,
80 sy-vline,81(5) i_rep-ebelp,
86 sy-vline,87(40) i_rep-txz01,
127 sy-vline,128(9) i_rep-matkl,
137 sy-vline,138(1) i_rep-pstyp,
139 sy-vline,140(1) i_rep-knttp,
141 sy-vline,142(4) i_rep-werks,
146 sy-vline,147(4) i_rep-lgort,
151 sy-vline,152(13) i_rep-menge UNIT i_rep-meins,
165 sy-vline,166(3) i_rep-meins,
169 sy-vline,170(15) i_rep-netpr CURRENCY i_rep-waers,
185 sy-vline,186(4) i_rep-waers,
190 sy-vline,191(5) i_rep-peinh,
196 sy-vline,197(4) i_rep-bprme,
201 sy-vline,202(15) i_rep-orewr CURRENCY i_rep-curr,
217 sy-vline,218(4) i_rep-curr,
222 sy-vline,223(7) i_rep-bstyp centered,
230 sy-vline,231(12) i_rep-ihrez,
243 sy-vline,244(12) i_rep-unsez,
256 sy-vline.
NEW-LINE.
hide: i_rep-ebeln.
ENDLOOP.
ULINE.
FORMAT COLOR OFF.
WRITE : /2 'Total Number of Purchasing Documents:'(025) COLOR 3,
lv_rec COLOR 3.
ENDIF.
ENDFORM. " display_data
*& Form header
Write the Report Header
FORM header .
FORMAT RESET.
header
WRITE:/1(230) 'LIST OF PURCHASE DOCUMENTS PER VENDOR'(006) CENTERED.
SKIP.
FORMAT COLOR COL_HEADING.
ULINE.
WRITE:/1 sy-vline,2(10) 'Pur.Doc.No'(006) CENTERED,
12 sy-vline,13(4) 'Type'(007),
17 sy-vline,18(10) 'Vendor'(008) CENTERED,
28 sy-vline,29(35) 'Name'(009) CENTERED,
64 sy-vline,65(4) 'PGrp'(010) CENTERED,
69 sy-vline,70(10) 'Doc.Date'(012) CENTERED,
80 sy-vline,81(5) 'Item'(011),
86 sy-vline,87(40) 'Material Short Text'(024) CENTERED,
127 sy-vline,128(9) 'Mat.Group'(013),
137 sy-vline,138(1) 'I',
139 sy-vline,140(1) 'A',
141 sy-vline,142(4) 'Plnt'(014),
146 sy-vline,147(4) 'SLoc'(015),
151 sy-vline,152(13) 'Quantity'(016) CENTERED,
165 sy-vline,166(3) 'UoM'(017),
169 sy-vline,170(15) 'Net Value'(018) CENTERED,
185 sy-vline,186(4) 'Curr'(019),
190 sy-vline,191(5) 'Per'(020),
196 sy-vline,197(4) 'Unit'(021),
201 sy-vline,202(15) 'To be Invoiced'(023) CENTERED,
217 sy-vline,218(4) 'Curr'(019),
222 sy-vline,223(7) 'Doc.Cat'(026),
230 sy-vline,231(12) 'Your Ref'(012),
243 sy-vline,244(12)'Our Ref'(012),
256 sy-vline.
ULINE.
ENDFORM. " header
*& Form toggle_color
This routine alters the color of the records in the list
FORM toggle_color.
IF gv_dial = space.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
gv_dial = c_x.
ELSE.
FORMAT COLOR 1 INTENSIFIED OFF.
CLEAR gv_dial.
ENDIF.
ENDFORM. " toggle_color
*& Form LINE_SEL
*When double clicked on EBELN field display the details of Purchase Doc
FORM line_sel.
CASE sy-lsind.
WHEN '1'.
DATA: lv_field(20),
lv_value(10),
lv_bstyp like i_rep-bstyp.
clear: lv_bstyp,lv_value, lv_field.
GET CURSOR FIELD lv_field VALUE lv_value.
IF lv_field = 'I_REP-EBELN'.
IF NOT lv_value IS INITIAL.
READ LINE sy-index FIELD VALUE i_rep-bstyp
INTO lv_bstyp.
READ CURRENT LINE FIELD VALUE i_rep-bstyp INTO lv_bstyp.
if lv_bstyp = 'F'.
SET PARAMETER ID 'BES' FIELD lv_value.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
elseif ( lv_bstyp = 'K' or lv_bstyp = 'L' ).
SET PARAMETER ID 'VRT' FIELD lv_value.
CALL TRANSACTION 'ME33' AND SKIP FIRST SCREEN.
elseif lv_bstyp = 'A'.
SET PARAMETER ID 'ANF' FIELD lv_value.
CALL TRANSACTION 'ME43' AND SKIP FIRST SCREEN.
endif.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " line_sel
Reward Points if useful.
Maybe you are looking for
-
Please help me with the problem of validator in struts
sorry for my poor English i have a question which i can't deal with. i have a jsp page in which some client imformation can be modified. The modify page accepts the parameters from the previous page in the form of href="/xxx/xxx.jsp?xxx=mobilephone "
-
Master Detail form in APEX 3.1
Hi, I am a bit new to the wonders of APEX (Only 1 project behind me). On my current project I need to make a Master-Detail so I used the APEX template for that. However I have trouble setting my foreign key value in the detail table. Table setup is l
-
Indesign CS6 very slow with vectors. please Help!
We updated to CS6 from CS5.5 to a Mac Pro running OS 10.6. Processors are 2 x 2.8 GHz Quad-Core Intel Xeon. Ram is 10 GB 800 MHz DDR2. Video card is ATI Radeon HD 2600 256 MB. One Cinema Display and a smaller Samsung monitor. The performance of InDes
-
I need the cable for my air to the tv?
where i can buy
-
G12: XMP not opened after raw edit
Hi all, yesterday I got my new Canon G12. I only work in RAW and I edited the G12 CR2 files as usual and save the settings in xmp files. The xmp files are written to disk as usual BUT: I do not get the little icons in Bridge indicating that there are