Extraction
of Open Purchase orders
Open Purchase Orders data retrieved from
tables EKKO, EKPO, EKET, ESLL, EKKN and KONV, which includes the following
Field | Description |
EKKO-BSART | Purchasing Document Type |
EKKO-EBELN | Purchasing Document Number |
EKKO-LIFNR | Account Number of the Vendor |
EKKO-BEDAT | Purchasing Document Date |
EKKO-BUKRS | Company Code |
EKKO-EKGRP | Purchasing group |
EKKO-EKORG | Purchasing Organization |
EKKO-ZTERM | Terms of payment key |
EKKO-INCO1 | Incoterms (part 1) |
EKKO-INCO2 | Incoterms (part 2) |
EKKO-WAERS | Currency Key |
EKKO-WKURS | Exchange rate |
EKKO-VERKF | Responsible salesperson at vendor's office |
EKKO-TELF1 | Vendor's telephone number |
EKKO-IHREZ | Customer's or vendor's internal reference |
EKKO-UNSEZ | Our reference |
EKKO-ANGNR | Quotation number |
EKKO-IHRAN | Quotation submission date |
EKKO-SUBMI | Collective number |
EKKO-KNUMV | Number of the document condition |
EKKO-KALSM | Procedure (pricing, output control, acct. det., |
EKKO-KDATB | Start of validity period |
EKKO-KDATE | End of validity period |
EKPO-EBELP | Item Number of Purchasing Document |
EKPO-KNTTP | Account assignment category |
EKPO-PSTYP | Item category in purchasing document |
EKPO-MATNR | Material Number |
EKPO-TXZ01 | Short text |
EKPO-MENGE | Purchase order quantity |
EKPO-MEINS | Order unit |
EKPO-NETPR | Net price in purchasing document (in document |
EKPO-PEINH | Price unit |
EKPO-WERKS | Plant |
EKPO-LGORT | Storage Location |
EKPO-BEDNR | Requirement Tracking Number |
EKPO-MATKL | Material Group |
EKPO-AFNAM | Name of requisitioner/requester |
EKPO-INFNR | Number of purchasing info record |
EKPO-BPRME | Order Price Unit (Purchasing) |
EKPO-WEUNB | Goods Receipt, Non-Valuated |
EKPO-EVERS | Shipping instructions |
EKPO-INSMK | Stock type |
EKPO-INCO1 | Incoterms (part 1) |
EKPO-INCO2 | Incoterms (part 2) |
EKPO-MWSKZ | Tax on sales/purchases code |
EKPO-TXJCD | Jurisdiction for Tax Calculation - Tax |
EKPO-BSTAE | Confirmation control key |
EKPO-LABNR | Order acknowledgment number |
EKPO-KZABS | Order acknowledgment requirement |
EKPO-IDNLF | Material Number used by Vendor |
EKPO-KUNNR | Customer |
EKPO-EMLIF | Vendor to be supplied/who is to receive delivery |
EKPO-LBLKZ | Subcontracting vendor |
EKPO-ELIKZ | "Delivery Completed" Indicator |
EKPO-LOEKZ | Deletion indicator in purchasing document |
KONV-STUNR | Step number |
KONV-KSCHL | Condition type |
KONV-KRECH | Calculation type for condition |
KONV-KAWRT | Condition base value |
KONV-KBETR | Rate (condition amount or percentage) |
KONV-WAERS | Currency Key |
KONV-KPEIN | Condition pricing unit |
KONV-KMEIN | Condition unit in the document |
KONV-LIFNR | Account Number of Vendor or Creditor |
KONV-KWERT | Condition value |
EKET-ETENR | Delivery Schedule Line Counter |
EKET-LPEIN | Category of delivery date |
EKET-EINDT | Item delivery date |
EKET-MENGE | Scheduled quantity |
EKET-SLFDT | Statistics-relevant delivery date |
ESLL-PACKNO | Package number |
ESLL-INTROW | Line number |
ESLL-EXTROW | Line number |
ESLL-KTEXT1 | Short text |
ESLL-MENGE | Quantity with or without plus/minus sign |
ESLL-MEINS | Base Unit of Measure |
ESLL-BRTWR | Gross price |
ESLL-NETWR | Net Value of the Item |
ESLL-TBTWR | Gross price |
EKKN-ZEKKN | Sequential number of account assignment |
EKKN-KOSTL | Cost Center |
EKKN-SAKTO | G/L Account |
EKKN-AUFNR | Order Number |
EKKN-KOKRS | Controlling |
EKKN-MENGE | Quantity |
EKKN-VPROZ | Distribution |
- Provide the Selection Screen with Purchasing
Document Date, Purchasing Document Type and Plant.
- Fetch the Header Data for Open Purchase Order into
an Internal Table by selecting All Header details from EKKO table by Passing BSTYP
= ‘F’ , Purchasing Document Date(BEDAT) = Selection Screen Date , BUKRS(Company
Code) = ‘XXX’ and Purchasing Document Type (BSART) = Selection Screen Purchasing
Document Type.
- For the header data, fetch the relevant item details
into an internal table from EKPO table by passing LOEKZ = ‘ ’, ELIKZ = ‘ ’ and
Plant (WERKS) = Selection Screen Plant.
- Loop the item data and read the header data, to move
all the header and item details into a single internal table.
- For the header and item details, fetch the relevant
Schedule line details into an internal table from EKET Table.
- For the schedule line details, fetch the relevant History
per Purchasing Document into an internal table from EKBE Table.
- Delete the values in the History per Purchasing
Document internal table by BEWTP (PO history category) EQ ‘Q’.
- Fetch the Service Entry Sheet Header Data, for all History
per Purchasing Document values from ESSR Table by passing Entry sheet number (LBLNI)
from ESSR = Document No. of a Reference Document(LFBNR) from EKBE table.
- Loop the Schedule line internal table and read the History
per Purchasing Document.
- By passing certain condition move the Schedule line
details, History per Purchasing Document details into a single internal table.
- State the condition EKBE-BEWTP EQ ‘E’ , then loop
the History per Purchasing Document internal table using key field of PO number
and item number.
- Create an internal table with PO number, PO item, Number
of Material Document (BELNR), Item in Material Document (BUZEI).
- Read that newly created internal table for BELNR,
With the Key of EBELN, EBELP, BELNR, and BUZEI.
- Check for the BELNR Equal is initial, Check for the
Condition where Movement type (BWART) EQ ‘101’ and PO number and PO item number
EQ to History per Purchasing Document PO number and PO item number.
- Else if check for the movement type ‘102’ and ‘122’
and EBELN and EBELP, if BWART (Movement type) = 122 add the Quantity for the
new internal for Schedule line = new internal for Schedule line + History per
Purchasing Document quantity (MENGE), and move the same for quantity1 as well
else move the Quantity for the new internal for Schedule line = new internal
for Schedule line + History per Purchasing Document quantity (MENGE).Check for
the Quantity for movement type 103 is not initial, for movement type 122 clear
the Quantity and Set a flag = ‘Y’, else if movement type 101 initial Clear
quantity1 and Set a flag = ‘X’.
- Else if check for the movement type ‘103’ and EBELN
and EBELP, Quantity 103 = quantity 103 + EKBE-BAMNG.
- Else if check for the movement type ‘104’ , ‘122’ and
‘124’ and EBELN and EBELP, if BWART (Movement type) = 104 or 124 , add
quantity1 = quantity1 + EKBE-BAMNG Else add the Quantity for the new internal
for Schedule line = new internal for Schedule line + History per Purchasing
Document quantity (MENGE), and move the same for quantity1 as well. Check for
the Quantity for movement type 103 is not initial for movement type 122 clear
the Quantity and Set a flag = ‘Y’, else if movement type 101 initial Clear
quantity1 and Set a flag = ‘X’ else set flag = ‘Y’.
- Else if check for the movement type ‘101’ and EBELN
and EBELP is not initial, if flag = ‘Y’, finalquantity103 = quantity103 –
quantity1 and final value = menge value - finalquantity103 and quantity103 =
quantity103 + quantity1. Else if flag = ‘X’ then finalquantity101 = quantity101
– quantity and final value = menge value - finalquantity101 and quantity101 =
quantity101 + quantity. If final value not equal to ‘0’ , move EBELN, EBELP,
EINDT, SLFDT, LPEIN, ETENR, if flag = ‘X’ Move finalquantity101 to menge
else Move finalquantity103 to menge and
WEMNG and MENGE Value and append into EKET2 internal table and quantity101 =
quantity101 + EKBE-MENGE and Set flag = ‘X’.
- Else if check for the movement type ‘102’, ‘122’ and
EBELN and EBELP is not initial, if flag = ‘Y’, finalquantity103 = quantity103 –
quantity1 and final value = menge value - finalquantity103 and quantity103 =
quantity103 + quantity1. Else if flag = ‘X’ then finalquantity101 = quantity101
– quantity and final value = menge value - finalquantity101 and quantity101 =
quantity101 + quantity. If final value not equal to ‘0’, move EBELN, EBELP,
EINDT, SLFDT, LPEIN, ETENR, if flag = ‘X’ Move finalquantity101 to menge
else Move finalquantity103 to menge and
WEMNG and MENGE Value and append into EKET2 internal table and if movement type
= 122, quantity = quantity + EKBE-MENGE and quantity = quantity + EKBE-MENGE ,
check quantity103 is not initial Set flag = ‘Y’ and clear quantity else
quantity = quantity + EKBE-MENGE , check quantity101 is not initial Set flag =
‘X’ and clear quantity1 else set flag = ‘X’.
- Else if check for the movement type ‘103’ and EBELN
and EBELP is not initial, if flag = ‘Y’, finalquantity103 = quantity103 –
quantity1 and final value = menge value - finalquantity103 and quantity103 =
quantity103 + quantity1. Else if flag = ‘X’ then finalquantity101 = quantity101
– quantity and final value = menge value - finalquantity101 and quantity101 =
quantity101 + quantity. If final value not equal to ‘0’ , move EBELN, EBELP,
EINDT, SLFDT, LPEIN, ETENR, if flag = ‘X’ Move finalquantity101 to menge
else Move finalquantity103 to menge and WEMNG
and MENGE Value and append into EKET2 internal table and quantity103 =
quantity103 + EKBE-MENGE and Set flag = ‘Y’.
- Else if check for the movement type ‘104’, ‘122’,
‘124’ and EBELN and EBELP is not initial, if flag = ‘Y’, finalquantity103 =
quantity103 – quantity1 and final value = menge value - finalquantity103 and
quantity103 = quantity103 + quantity1. Else if flag = ‘X’ then finalquantity101
= quantity101 – quantity and final value = menge value - finalquantity101 and
quantity101 = quantity101 + quantity. If final value not equal to ‘0’, move
EBELN, EBELP, EINDT, SLFDT, LPEIN, ETENR, if flag = ‘X’ Move finalquantity101
to menge else Move finalquantity103 to
menge and WEMNG and MENGE Value and append into EKET2 internal table and if
movement type = ‘124’ or ‘104’, quantity1 = quantity + EKBE-MENGE, check
quantity103 is not initial Set flag = ‘Y’ and clear quantity else quantity1 =
quantity1 + EKBE-MENGE and quantity = quantity + EKBE-MENGE, check quantity101
is not initial Set flag = ‘X’ and clear quantity1 else set flag = ‘Y’.
- Else if check for the movement type ‘101’, if flag =
‘Y’, finalquantity103 = quantity103 – quantity1 and final value = menge value -
finalquantity103 and quantity103 = quantity103 + quantity1. Else if flag = ‘X’
then finalquantity101 = quantity101 – quantity and final value = menge value -
finalquantity101 and quantity101 = quantity101 + quantity. If final value not
equal to ‘0’ , move EBELN, EBELP, EINDT, SLFDT, LPEIN, ETENR, if flag = ‘X’
Move finalquantity101 to menge else Move
finalquantity103 to menge and WEMNG and MENGE Value and append into EKET2
internal table and quantity101 = quantity101 + EKBE-MENGE and Set flag = ‘X’.
- Else if check for the movement type ‘102’, ‘122’, if
flag = ‘Y’, finalquantity103 = quantity103 – quantity1 and final value = menge
value - finalquantity103 and quantity103 = quantity103 + quantity1. Else if
flag = ‘X’ then finalquantity101 = quantity101 – quantity and final value =
menge value - finalquantity101 and quantity101 = quantity101 + quantity. If
final value not equal to ‘0’, move EBELN, EBELP, EINDT, SLFDT, LPEIN, ETENR, if
flag = ‘X’ Move finalquantity101 to menge else
Move finalquantity103 to menge and WEMNG and MENGE Value and append into
EKET2 internal table and if movement type = 122, quantity = quantity +
EKBE-MENGE and quantity = quantity + EKBE-MENGE , check quantity103 is not
initial Set flag = ‘Y’ and clear quantity else quantity = quantity + EKBE-MENGE
, check quantity101 is not initial Set flag = ‘X’ and clear quantity1 else set
flag = ‘X’.
- Else if check for the movement type ‘103’, if flag =
‘Y’, finalquantity103 = quantity103 – quantity1 and final value = menge value -
finalquantity103 and quantity103 = quantity103 + quantity1. Else if flag = ‘X’
then finalquantity101 = quantity101 – quantity and final value = menge value -
finalquantity101 and quantity101 = quantity101 + quantity. If final value not
equal to ‘0’ , move EBELN, EBELP, EINDT, SLFDT, LPEIN, ETENR, if flag = ‘X’
Move finalquantity101 to menge else Move
finalquantity103 to menge and WEMNG and MENGE Value and append into EKET2
internal table and quantity103 = quantity103 + EKBE-MENGE and Set flag = ‘Y’.
- Else if check for the movement type ‘104’, ‘122’,
‘124’, if flag = ‘Y’, finalquantity103 = quantity103 – quantity1 and final
value = menge value - finalquantity103 and quantity103 = quantity103 +
quantity1. Else if flag = ‘X’ then finalquantity101 = quantity101 – quantity
and final value = menge value - finalquantity101 and quantity101 = quantity101
+ quantity. If final value not equal to ‘0’, move EBELN, EBELP, EINDT, SLFDT,
LPEIN, ETENR, if flag = ‘X’ Move finalquantity101 to menge else Move finalquantity103 to menge and WEMNG and
MENGE Value and append into EKET2 internal table and if movement type = ‘124’
or ‘104’, quantity1 = quantity + EKBE-MENGE, check quantity103 is not initial
Set flag = ‘Y’ and clear quantity else quantity1 = quantity1 + EKBE-MENGE and
quantity = quantity + EKBE-MENGE, check quantity101 is not initial Set flag =
‘X’ and clear quantity1 else set flag = ‘Y’.
- Move all the values to BELNR Internal Table and
append it and calculate menge value = menge value + EKET-MENGE and end if
Statement and end the Loop Statement.
- Else if Check for EKBE-BEWTP = ‘D’, Read the ESSR
Internal Table with key LBLNI = EKBE-LFBNR and LOKEZ = ‘X’. Check the if SY-SUBRC
EQ ‘0’ move all value from EKET to EKET1 and Append it, else read the EKBE1
Internal Table With Key LFBNR = EKBE-LFBNR BEWTP = ‘E’ BWART = ‘102’ . If EKBE1
is not an initial Move the values from EKET to EKET1 and append the EKET1
Internal Table.
- Else Move the values from EKET to EKET1 and append
the EKET1 Internal Table and end if statement.
- Else Move the values from EKET to EKET1 and append
the EKET1 Internal Table and end if Statement and end the Loop Statement.
- If quantity103 is not initial, finalquantity103 =
Quantity103 – Quantity1 and final value = Menge Value – Finalquantity103 and
Set flag = ‘Y’. Else if quantity101 is not initial, finalquantity101 =
Quantity101 – Quantity and final value = Menge Value – Finalquantity101 and Set
flag = ‘X’. If final value not equal to ‘0’, move EBELN, EBELP, EINDT, SLFDT,
LPEIN, ETENR, if flag = ‘X’ Move finalquantity101 to EKET2-menge else Move finalquantity103 to EKET2-menge and
WEMNG and MENGE Value and append into EKET2 internal table and end if
statement.
- Loop the EKET internal table, if EBELN = EKET-EBELN
and EBELP = EKET-EBELP, Move Menge Value = Menge value + EKET-MENGE and if
EBELN and EBELP is initial Move Menge Value = Menge value + EKET-MENGE and Move
EBELN, EBELP, Menge Value to BELNR and append the internal table and move the
values of EKET-EBELN to EBELN and EKET-EBELP to EBELP and end the loop
Statement.
- If menge value is not initial move EBELN, EBELP,
MENGE Value to BELNR internal table and append it and end if Statement.
- Again Loop the EKET internal table read the EKBE
internal Table with key BEWTP = ‘E’ EBELN EBELP, if EKBE is not initial Read
EKET2 internal table if SY-SUBRC = ‘0’ Read the BELNR internal table, Calculate
Menge Value = EKET2-MENGE – BELNR-MENGE.
If EKET2-MENGE = ‘0’, Move the EKBE and EKET Values to EKET1 and Append
the EKET2 internal table and move EBELN = EKBE-EBELN and EBELP = EKBE-EBELP.
- Else if EKET-MENGE > ‘0’ and EKET-EBELN = EBELN
and EKET-EBELP = EBELP and EKET2-MENGE = ‘0’, Move all the Values from EKBE,
EKET to EKET1 and Calculate MENGE1 = EKET-MENGE - EKET2-MENGE and EKET1-MENGE =
MENGE1, append the EKET1 internal table and assign EKET2-MENGE = ‘0’ Modify the
EKET2 internal table by transporting menge where EBELN and EBELP equal to EKBE
and move EBELN = EKBE-EBELN and EBELP = EKBE-EBELP.
- Else if EKET-MENGE > ‘0’ and EKET-MENGE >
EKET2-MENGE or EKET-MENGE = EKET2-MENGE, Move all the Values from EKBE and EKET
to EKET1 and Calculate MENGE1 = EKET-MENGE - EKET2-MENGE and EKET1-MENGE = MENGE1,
append the EKET1 internal table and assign EKET2-MENGE = ‘0’ Modify the EKET2
internal table by transporting menge where EBELN and EBELP equal to EKBE and
move EBELN = EKBE-EBELN and EBELP = EKBE-EBELP.
- Else if EKET-MENGE > ‘0’ and EKET-MENGE <
EKET2-MENGE and EKET2-MENGE = ‘0’, Move all the Values from EKBE and EKET to
EKET1 and EKET1-MENGE = ‘0’ and Calculate MENGE1 = EKET-MENGE - EKET2-MENGE and
append the EKET1 internal table and assign EKET2-MENGE = MENGE1 Modify the
EKET2 internal table by transporting menge where EBELN and EBELP equal to EKBE
and move EBELN = EKBE-EBELN and EBELP = EKBE-EBELP.
- Else if EKET-MENGE > ‘0’ and EKET-MENGE <
EKET2-MENGE and EKET2-MENGE not equal to ‘0’, Move all the Values from EKBE and
EKET to EKET1 and EKET1-MENGE = ‘0’ and Calculate MENGE1 = EKET-MENGE -
EKET2-MENGE and append the EKET1 internal table and assign EKET2-MENGE = MENGE1
Modify the EKET2 internal table by transporting menge where EBELN and EBELP
equal to EKBE and move EBELN = EKBE-EBELN and EBELP = EKBE-EBELP.
- Else if EKET-MENGE > ‘0’ and EKET-MENGE <
EKET2-MENGE and EKET2-MENGE equal to ‘0’ and EKET-EBELN = EBELN and EKET-EBELP
= EBELP, Move all the Values from EKBE and EKET to EKET1 and append the EKET1
internal table and move EBELN = EKBE-EBELN and EBELP = EKBE-EBELP.
- End if statement and end if statement and end the
loop statement.
- Sort the EKET1 internal table by EBELN EBELP.
- Delete adjacent duplicates EKET1 internal table by
comparing EBELN EBELP ETENR.
- For the header and item details, fetch the relevant Account
Assignment in Purchasing Document into an internal table EKKN from EKKN Table.
- For the header and item details, fetch the relevant Service
Line Item values into an internal table ESLL from ESLL Table.
- For the header and item details, fetch the relevant Item
Condition Type details into an internal table KONV from KONV Table.
- Loop the KONV internal table and Read the Header
item internal table (DATA) move the EBELN and EBELP and KONV details to KONVF
final internal table and append it.
- For the Service line item ESLL internal table , pass
the Pack no from ESLL internal table to ESLL Sub pack no and fetch all the
details into an internal table ESLLS from ESLL table.
- Loop the ESLLS internal table and read the ESLL
internal table with key sub pack no. = pack no.
Move the corresponding values into a final internal table ESLLFI and
move the both pack no into different field name.
- Loop the final internal table of ESLLFI and read the
header item internal table(DATA) , get the EBELN and EBELP with the Key pack no.
move all the values into an internal table ESLLFI1 and append it.
- Loop the header item internal table (DATA) and loop
the KONVF internal table and Loop EKET1 internal table and Loop EKKN internal
table and move all the values into a final internal table final. If DATA-PSTYP
EQ ‘9’ , Loop the ESLLFI1 internal table and move the values into an final
internal table and append it and end the loop statement else append the final
internal table and end if statement.
- If SY-SUBRC NE ‘0’, then perform move all the values
without EKET1 values into a final internal table and append it and end if
statement and end loop statement.
- If SY-SUBRC NE ‘0’, then perform move all the values
without KONVF values into a final internal table and append it and end if
statement and end loop statement.
- Then download the final internal table using
GUI_DOWNLOAD function module into an excel file, with header.
Changes & defects prevention
- Initially the
amount was calculated based on the formula- rate multiplied by qty.Later on;
the same program has been changed in such way that therate was
calculated based amount divided by qty as per business requirement.
- We found
excel format issue, once we downloaded the excel sheet.
For example if the material unit is inch, it’s
downloaded incorrectly as “” in excel sheet which results incorrect data
alingnment.This issue has been resolved by downloading excel using export
option in menu bar. There is no code change done for this case.