SAP PO ME21N Exit The following list are the full list of ME21 exit for SAP Purchase Document / Order. So you can add custom processing or custom check for ME21 exit or SAP Purchase Order Check exit.
Explicit PO Number: This post will explain how to create a SAP PO ( Purchasing Order) with Explicit PO Number.
The first part will cover SAP PO Number Customizing and the second part will explain how to create explicit PO Number.
Bapi Po Create1 Manual Price. Bignovag.web.fc2.com › Bapi Po Create1 Manual Price. Oct 9, 2014 - When input data POITEM-POPRICE = '1' in BAPI, system will try to find an entry in the info record with the PO currency (for example, JPY) first. BAPIMEPOITEM is an SAP Structure so does not store data like a database table does but can be used to process 'Purchase Order Item' Information within sap ABAP programs. This is done by declaring abap internal tables, work areas or database tables based on this Structure. These can then be used to store and process the required data appropriately.
Customizing for Explicit PO Number
In order to allow External number to SAP PO ( Purchase Order ), customizing for PO Number range should be set to External.
So Define a SAP PO document Type then assign a number range for external numbers.
Create External Number Range for Purchasing Document
Launch the SAP Tcode OMH6 : Number Ranges for Purch. Documents
Check also, the following SAP Tcodes for Number Ranges
- OMH6 Number Ranges for Purch. Documents
- OMH7 Number Ranges for Purch. Requisition
- OMH8 Number Ranges for Service Package
- OMH9 Number Ranges for Entry Sheet
Assign External Number Range to Purchasing Document Type
To assign External Number Range to Purchasing Document Type, Navigate through SPRO to
Purchasing > Define Document Types
Set the following information
- Type for Document Types
- Item Number Interval
- No Range Internal
- No Range External
- …
Create SAP PO Explicit PO Number using BAPI
Once the Customizing for External Number Range for PO is done, you can move to ABAP report/Code.
In order to create a SAP Purchasing document with an External PO number use the standard BAPI BAPI_PO_CREATE1 (Create Purchase Order).
Check also List of Important SAP SD Tables (Sales and Distribution).
The main input parameters for PO Number are
- POHEADER : Header Data- type BAPIMEPOHEADER
- POHEADERX: Header Data (Change Parameter)- type BAPIMEPOHEADERX
Use field the POHEADER-PO_NUMBER (EBELN CHAR 10 0 Purchasing Document Number) for the External PO Number for the Purchase Document you want to create.
Set POHEADERX-PO_NUMBER = ‘X’
Call the BAPI BAPI_PO_CREATE1 will all the SAP Purchasing Order Details.
2 4 6 8 10 12 14 16 | DATA:LS_POHEADERTYPEBAPIMEPOHEADER. ' Set External PO ls_poheaderx-po_number=abap_true.' 'X' ' Call SAP PO Creation BAPI EXPORTING POHEADERX=LS_POHEADERX... |
Check more information about Purchasing Document and Most Useful SAP EDI Transactions (SAP Idocs Tcodes) & SAP EDI Tables
*&---------------------------------------------------------------------**& Report zan_pobapi
*&
*&---------------------------------------------------------------------*
*&
*& BAPI upload for Purchase Orders
*&
*&---------------------------------------------------------------------*
REPORT zan_pobapi.
*& Internal table containing data from input data file
DATA: BEGIN OF itab_po OCCURS 0,
rectype(1),
comp_code(4),
doc_type(2),
creat_date TYPE d,
vendor LIKE ekko-lifnr,
purch_org LIKE ekko-ekorg,
purch_group LIKE ekko-ekgrp,
po_item LIKE ekpo-ebelp,
material LIKE ekpo-matnr,
plant LIKE ekpo-werks,
quantity(15) ,'like ekpo-menge,
po_unit LIKE ekpo-meins,
net_price(15) ,'like ekpo-netwr,
plan_del(3) ,'like ekpo-plifz,
END OF itab_po.
DATA: lexists TYPE c,
chkfile(128) TYPE c,
idatstr TYPE string,
ponum TYPE bapimepoheader-po_number.
*& Internal table to temporarily read the data in a string for splitting
DATA: BEGIN OF itabstr OCCURS 0,
str(120),
END OF itabstr.
* Declaration related to PO BAPI
DATA: lpoheader TYPE bapimepoheader,
lpoheaderx TYPE bapimepoheaderx.
DATA:lpoitem TYPE STANDARD TABLE OF bapimepoitem WITH HEADER LINE,
lpoitemx TYPE STANDARD TABLE OF bapimepoitemx WITH HEADER LINE,
lreturn TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
PARAMETERS idatfile(40) DEFAULT 'c:sapPOInputData.txt'.
chkfile = idatfile.
idatstr = idatfile.
DO.
'perform ChooseDataFile.
PERFORM datafileexists.
PERFORM readdatafile.
PERFORM populatedata.
* loop at itab_po.
* write:/ itab_po-rectype,
* itab_po-comp_code,
* itab_po-doc_type,
* itab_po-creat_date,
* itab_po-vendor,
* itab_po-purch_org,
* itab_po-purch_group ,
* itab_po-po_item,
* itab_po-material,
* itab_po-plant,
* itab_po-quantity,
* itab_po-po_unit,
* itab_po-net_price,
* itab_po-plan_del.
* endloop.
'PERFORM validate_data tables itab_po.
'editor-call for itab_po.
PERFORM data_fill.
EXIT.
ENDDO.
*&---------------------------------------------------------------------*
*& Form DataFileExists
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM datafileexists.
*This function will check to see whether the input data file exists
CALL FUNCTION 'DX_FILE_EXISTENCE_CHECK'
EXPORTING
filename = chkfile
pc = 'X'
* SERVER =
IMPORTING
file_exists = lexists
* EXCEPTIONS
* RFC_ERROR = 1
* FRONTEND_ERROR = 2
* NO_AUTHORITY = 3
* OTHERS = 4
.
IF NOT ( sy-subrc = 0 AND lexists = 'X').
MESSAGE 'Input Data File does not exist' TYPE 'E'.
ENDIF.
ENDFORM. 'DataFileExists
*& Call the function module to load the data into the internal table
FORM readdatafile.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = idatstr
filetype = 'ASC'
has_field_separator = '
'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = itabstr
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
ENDFORM. 'ReadDataFile
*&---------------------------------------------------------------------*
*& Form populatedata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM populatedata.
CLEAR itab_po.
LOOP AT itabstr.
SPLIT itabstr-str AT '
'
INTO
itab_po-rectype
itab_po-comp_code
itab_po-doc_type
itab_po-creat_date
itab_po-vendor
itab_po-purch_org
itab_po-purch_group
itab_po-po_item
itab_po-material
itab_po-plant
itab_po-quantity
itab_po-po_unit
itab_po-net_price
itab_po-plan_del.
APPEND itab_po.
CLEAR itab_po.
ENDLOOP.
ENDFORM. 'populatedata
*form validate_data tables ritab_po.
* loop at ritab_po.
* IF itab_po-rectype = 'H'.
*
*
* endloop.
*
*endform.
*&---------------------------------------------------------------------*
*& Form data_fill
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM data_fill.
LOOP AT itab_po.
IF itab_po-rectype = 'H'.
lpoheader-comp_code = itab_po-comp_code. 'BP01'.
lpoheader-doc_type = itab_po-doc_type. 'NB'.
lpoheader-creat_date = itab_po-creat_date. '22.04.2010'.
lpoheader-vendor = itab_po-vendor. 'C8000'.
lpoheader-purch_org = itab_po-purch_org. 'BP01'.
lpoheader-pur_group = itab_po-purch_group. '001'.
lpoheaderx-comp_code = 'X'.
lpoheaderx-doc_type = 'X'.
lpoheaderx-creat_date = 'X'.
lpoheaderx-vendor = 'X'.
lpoheaderx-purch_org = 'X'.
lpoheaderx-pur_group = 'X'.
ELSEIF itab_po-rectype = 'L'.
lpoitem-po_item = itab_po-po_item. '00010'.
lpoitem-material = itab_po-material. 'ZTC1'.
lpoitem-plant = itab_po-plant. 'BP01'.
lpoitem-quantity = itab_po-quantity. '10.
lpoitem-po_unit = itab_po-po_unit. 'M'.
lpoitem-net_price = itab_po-net_price. '10.
lpoitem-plan_del = itab_po-plan_del. '10.
APPEND lpoitem.
lpoitemx-po_item = itab_po-po_item.
lpoitemx-material = 'X'.
lpoitemx-plant = 'X'.
lpoitemx-quantity = 'X'.
lpoitemx-po_unit = 'X'.
lpoitemx-net_price = 'X'.
lpoitemx-plan_del = 'X'.
APPEND lpoitemx.
ELSEIF itab_po-rectype = 'X'.
PERFORM data_load.
PERFORM datacommit.
ELSE.
WRITE:/ 'Put in exception'.
ENDIF.
ENDLOOP.
ENDFORM. 'data_fill
*&---------------------------------------------------------------------*
*& Form data_load
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM data_load.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = lpoheader
poheaderx = lpoheaderx
* POADDRVENDOR =
* TESTRUN =
* MEMORY_UNCOMPLETE =
* MEMORY_COMPLETE =
* POEXPIMPHEADER =
* POEXPIMPHEADERX =
* VERSIONS =
* NO_MESSAGING =
* NO_MESSAGE_REQ =
* NO_AUTHORITY =
* NO_PRICE_FROM_PO =
IMPORTING
exppurchaseorder = ponum
Bapi Po Create1 Manual Price
* EXPHEADER =
* EXPPOEXPIMPHEADER =
TABLES
return = lreturn
poitem = lpoitem
poitemx = lpoitemx
* POADDRDELIVERY =
* POSCHEDULE =
* POSCHEDULEX =
* POACCOUNT =
Bapi Po Create1 Manual Priced
* POACCOUNTPROFITSEGMENT =* POACCOUNTX =
* POCONDHEADER =
* POCONDHEADERX =
* POCOND =
* POCONDX =
* POLIMITS =
* POCONTRACTLIMITS =
* POSERVICES =
* POSRVACCESSVALUES =
Bapi Po Create1 Manual Price In India
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
* POCOMPONENTS =
* POCOMPONENTSX =
* POSHIPPING =
* POSHIPPINGX =
* POSHIPPINGEXP =
.
ENDFORM. 'data_load
*&---------------------------------------------------------------------*
*& Form datacommit
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM datacommit.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = '2'
* IMPORTING
* RETURN =
.
WAIT UP TO 2 SECONDS.
WRITE: 'Generated PO:', ponum.
LOOP AT lreturn.
WRITE:/ lreturn-message, lreturn-message_v1.
ENDLOOP.
ENDFORM. 'datacommit
*LOOP AT lreturn.
* WRITE:/ lreturn-message, lreturn-message_v1.
*
*ENDLOOP.