Transferring Data from ABAP Internal Table to Excel Sheet
If you wish to transfer data from ABAP internal table to EXCEL you can use the following function module.
MS_EXCEL_OLE_STANDARD_DAT
This function module populates an existing excel sheet with the data from the ABAP internal table. Please find below code which shows hwo to declare and populate the import and important parameters. In the next section we will see in depth how this function module operates.
REPORT ZEX_DATATOEXCEL .
Parameters: P_file like RLGRAP-FILENAME.
data : begin of int_head occurs 0, Filed1(20) type c, " Header Data end of int_head.
data : begin of int_data occurs 0, Field1(20) type c, " Data Field2(20) type c, Field3(20) type c, Field4(20) type c, end of int_data.
If you wish to transfer Purchase Order related Data to SAP, you can do so by using the following BAPI.
BAPI_PO_CREATE
Many a times there is a requirement to transfer purchase order data from a third party to SAP, it can be done by the following methods.
1) BAPI 3) BDC 3) EDI
This this tutorial we will see how to create a Purchase Order using the above mentioned BAPI.
Please note that if you wish to create Real Time Purchase Orders from an external system into SAP R/3 then you need to use either the JCO connector, .NET connector or XI. The example below shows creation of a single purchase order, if you have data required to create purchase orders then you first need to upload it into an internal table and then pass the table to the BAPI.
Please find the code below to create a Purchase order using the BAPI BAPI_PO_CREATE
REPORT ZEX_POCREATE .
Data: int_pohead like BAPIEKKOC, int_poitem like BAPIEKPOC occurs 0 with header line, int_posched like BAPIEKET occurs 0 with header line, int_ret like BAPIRETURN occurs 0 with header line. Data: d_purchord like BAPIEKKOC-PO_NUMBER.
Move: 'NB' to int_pohead-DOC_TYPE, '1000' to int_pohead-PURCH_ORG, '001' to int_pohead-PUR_GROUP, '0000001234' to int_pohead-vendor,
'00010' to int_poitem-po_item, 'Material' to int_poitem-material, 'Material' to int_poitem-pur_mat, '1000' to int_poitem-plant,
'00010' to int_posched-PO_ITEM, '20080531' to int_posched-DELIV_DATE, '2' to int_posched-QUANTITY.
Always use Pretty Printer and Extended Program Check before releasing the code.
Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive.