Spend Management Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
JianZhu
Advisor
Advisor
378

Although SAP provides documentation for preparing requisition import files (like this one), the reality is often more complicated. Different environments come with different configurations—especially when custom fields are involved. Getting everything aligned can quickly become a headache.

What’s more frustrating? There’s no built-in way to export existing Purchase Requisitions (PRs) into CSV format. That means both customers and partners, and even SAP internal teams doing testing, often have to prepare sample files manually.

In this article, I’ll show you how to quickly generate ready-to-import CSV files without the hassle.

Although SAP Ariba doesn’t offer a direct CSV export interface, there is a convenient way to export requisition data to Excel through the UI. In the screenshot below, you’ll notice the “Excel Export” button—this will be our starting point.

JianZhu_0-1749184781437.png

Follow the steps below to quickly convert that Excel file into the CSV format required for PR import:

How to Convert Excel Export to PR Import-Ready CSV Files

  1. Export the Excel file from the Ariba UI using the Excel Export button.

  2. Open the downloaded file and make sure it's in Edit Mode.

  3. Press Alt + F11 to open the Visual Basic for Applications (VBA) editor.

  4. In the VBA Project pane (usually on the left), right-click your workbook.

  5. Choose Insert > Module.

    JianZhu_1-1749185029015.png

     

  6. Copy and paste the VBA code (provided below) into the new module.

Sub ExportSheetsToCSV_WithUTF8AndExtraColumn()
    Dim ws As Worksheet
    Dim savePath As String
    Dim fName As String
    Dim csvFullPath As String
    Dim lastRow As Long, lastCol As Long
    Dim tempWB As Workbook
    Dim tempWS As Worksheet
    Dim reqNumber As String
    Dim fileNum As Integer
    Dim rowNum As Long
    Dim rowValues As String
    Dim i As Long

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    ' Ask where to save the CSV files
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Select Folder to Save CSV Files"
        If .Show <> -1 Then
            MsgBox "No folder selected. Exiting.", vbExclamation
            Exit Sub
        End If
        savePath = .SelectedItems(1) & Application.PathSeparator
    End With

    ' Set the requisition number
    reqNumber = "PRXXXXX"

    ' Loop through each sheet in current workbook
    For Each ws In ThisWorkbook.Worksheets
        ' Copy sheet to temporary workbook
        ws.Copy
        Set tempWB = ActiveWorkbook
        Set tempWS = tempWB.Sheets(1)

        ' Determine last row and column
        With tempWS
            lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
            lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column

            ' Add Requisition_Number header
            .Cells(1, lastCol + 1).Value = "Requisition_Number"

            ' Fill in PRXXXXX
            For i = 2 To lastRow
                .Cells(i, lastCol + 1).Value = reqNumber
            Next i
        End With

        ' Build filename (remove spaces from sheet name)
        fName = Replace(ws.Name, " ", "") & ".csv"
        csvFullPath = savePath & fName

        ' Write UTF-8 + CSV to file manually
        fileNum = FreeFile
        Open csvFullPath For Output As #fileNum
        Print #fileNum, "UTF-8" ' first line

        For rowNum = 1 To lastRow
            rowValues = ""
            For i = 1 To lastCol + 1
                rowValues = rowValues & """" & Replace(tempWS.Cells(rowNum, i).Text, """", """""") & ""","
            Next i
            rowValues = Left(rowValues, Len(rowValues) - 1) ' remove trailing comma
            Print #fileNum, rowValues
        Next rowNum

        Close #fileNum
        tempWB.Close SaveChanges:=False
    Next ws

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

    MsgBox "All CSV files exported successfully with UTF-8 and Requisition_Number.", vbInformation
End Sub

JianZhu_17-1749186567351.png

  • Press F5 to run the macro, or click Run, select ExportSheetsToCSV_WithUTF8AndExtraColumn, and run it.

    JianZhu_4-1749185355182.png
  • You'll be prompted to choose a folder to save the CSV files—select a location and click OK.

    JianZhu_6-1749185448989.pngJianZhu_7-1749185468065.png
  • The macro will generate three clean CSV files, fully formatted and ready for PR import.

    JianZhu_8-1749185511958.pngJianZhu_9-1749185543208.png
    You can open the files and make any necessary adjustments.
  • Head to Core Administration > Data Import/Export, upload the generated CSV files, and start the import.

    JianZhu_10-1749185731881.png
    JianZhu_11-1749185814394.pngJianZhu_12-1749185858717.pngJianZhu_13-1749185906989.png 
  • Once the import completes, go back to the Home page and check My Documents.

    JianZhu_15-1749185965204.png
  • Open the latest document—you should see the newly generated requisition ready to go.

    JianZhu_16-1749186022788.png

Why This Matters

Manually preparing CSV files—especially when custom fields and multiple environments are involved—can be time-consuming, error-prone, and frustrating. With this automated approach, what used to take hours of manual editing and guesswork now takes just a few minutes.

Whether you're a partner building test cases, a customer staging data, or an SAP consultant troubleshooting integration scenarios—this tool empowers you to move faster, reduce mistakes, and focus on solving real business problems instead of wrestling with formatting.

I hope this guide saves you time, reduces friction, and makes your daily work just a little easier. If this was helpful, leave a comment and let me know—I'd love to hear how you’re using it!

SAP Ariba Procurement SAP Ariba Buying and Invoicing SAP Ariba solution integration for SAP Business Suite  SAP Ariba Central Procurement