*& *
*&---------------------------------------------------------------------*
*& Program demonstrates the BAPI call to create Purchase Order *
*& Minimum required parameters are used are as per the current *
*& system configuration *
*&---------------------------------------------------------------------*
REPORT ZBAPI_CREATE_PO .
*&---------------------------------------------------------------------*
*DATA DECLARATION
CONSTANTS : C_X VALUE 'X'.
*Structures to hold PO header data
DATA : HEADER LIKE BAPIMEPOHEADER ,
HEADERX LIKE BAPIMEPOHEADERX .
*Structures to hold PO account data
DATA : ACCOUNT LIKE BAPIMEPOACCOUNT OCCURS 0 WITH HEADER LINE ,
ACCOUNTX LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE .
*Structures to hold PO schedule data
DATA : ITEMSCHEDULE LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE ,
ITEMSCHEDULEX LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE .
*Structures to hold PO (distrib.imputac.lín.servicios) data
DATA : POSRVACCESSVALUES LIKE BAPIESKLC OCCURS 0 WITH HEADER LINE .
*Structures to hold PO services data
DATA : SERVICES LIKE BAPIESLLC OCCURS 0 WITH HEADER LINE .
*Internal Tables to hold PO ITEM DATA
DATA : ITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
ITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
*Internal table to hold messages from BAPI call
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
*Internal table to hold messages from BAPI call
POCONTRACTLIMITS LIKE BAPIESUCC OCCURS 0 WITH HEADER LINE.
data : w_header(40) value 'PO Header',
PURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER,
DELIVERY_DATE LIKE BAPIMEPOSCHEDULE-DELIVERY_DATE.
data : ws_langu like sy-langu.
*text-001 = 'PO Header' - define as text element
selection-screen begin of block b1 with frame title text-001.
parameters : company like header-comp_code default '1000' ,
doctyp like HEADER-DOC_TYPE default 'PM' ,
cdate like HEADER-CREAT_DATE default sy-datum ,
vendor like HEADER-VENDOR default '100006' ,
pur_org like HEADER-PURCH_ORG default '1000' ,
pur_grp like HEADER-PUR_GROUP default '850' ,
sociedad like HEADER-COMP_CODE default '1000' ,
vendedor like HEADER-SALES_PERS default 'Wilda Messina'.
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters : item_num like ITEM-PO_ITEM default '00010',
material like ITEM-MATERIAL default 'CRANE' ,
tipo_imp like ITEM-ACCTASSCAT default 'K' ,
pos_doc like ITEM-ITEM_CAT default 'F' ,
shorttxt like ITEM-SHORT_TEXT default 'PRUEBA BAPI' ,
grup_art like ITEM-MATL_GROUP default '350001' ,
plant like ITEM-PLANT default '1000' ,
mpe like ITEM-TRACKINGNO default '9999' ,
contrato like ITEM-AGREEMENT default '4904000003' ,
quantity like ITEM-QUANTITY default 1 .
* po_unit like ITEM-PO_UNIT default 'UP'.
selection-screen end of block b2.
* Parámnetros para los servicios
selection-screen begin of block b3 with frame title text-003.
parameters : paquete like SERVICES-PCKG_NO default '956',
numlinin like SERVICES-LINE_NO default '9' ,
numlinea like SERVICES-EXT_LINE default '80',
service like SERVICES-SERVICE default '8010',
srv_cant like SERVICES-quantity default '5' ,
precio like SERVICES-GR_PRICE default '300' ,
impuesto like SERVICES-TAX_CODE default 'I2' .
selection-screen end of block b3.
* Parámnetros de imputación
selection-screen begin of block b4 with frame title text-004.
parameters : centro like ACCOUNT-COSTCENTER default '120100',
cuenta like ACCOUNT-GL_ACCOUNT default '6501002000' ,
num_pos like ACCOUNT-PO_ITEM default '10' ,
serial like ACCOUNT-SERIAL_NO default '01' ,
ind_imp like ACCOUNT-TAX_CODE default 'I2' .
*&---------------------------------------------------------------------*
*Confirm the document creation by calling database COMMIT
*&---------------------------------------------------------------------*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
..
end-of-selection.
*&---------------------------------------------------------------------*
*Output the messages returned from BAPI call
*&---------------------------------------------------------------------*
LOOP AT RETURN.
WRITE / RETURN-MESSAGE.
ENDLOOP.
Code:
REPORT ZTEST26 . " ME_PO_CREATE
DATA : L_PO_HEADER LIKE BAPIMEPOHEADER.
DATA : L_PO_HEADERX LIKE BAPIMEPOHEADERX.
DATA : L_PURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER.
*DATA : L_HEADER LIKE BAPIMEPOHEADER STRUCTURE BAPIMEPOHEADER.
DATA : BEGIN OF T_PO_ITEMS OCCURS 0.
INCLUDE STRUCTURE BAPIMEPOITEM.
DATA : END OF T_PO_ITEMS.
DATA : BEGIN OF T_PO_ITEMSX OCCURS 0.
INCLUDE STRUCTURE BAPIMEPOITEMX.
DATA : END OF T_PO_ITEMSX.
DATA : BEGIN OF T_RETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA : END OF T_RETURN.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.