BAPI Functionality

Hi Everyone,

I need to create a sales order in SAP using BAPI Activity. Have downloaded from Marketplace.

Could you please guide on where to pass input parameter & do SO creation.

Thanks in advance

Hi @nithya

You can try this approach

Use this BAPI

BAPI_SALESORDER_CREATEFROMDAT

Fill these inputs inside the BAPI activity:

Import Parameter

  • ORDER_HEADER_IN → DOC_TYPE, SALES_ORG, DISTR_CHAN, DIVISIO

Tables

  • ORDER_PARTNERS → AG (Sold-to party)

  • ORDER_ITEMS_IN → Material, Qty

  • ORDER_SCHEDULES_IN → Item No, Req Qty

After this, call BAPI_TRANSACTION_COMMIT → WAIT = “X”

Output SALES_DOCUMENT → Sales Order Number

Hi @nithya

Install UiPath SAP BAPI package from Marketplace.

Add SAP BAPI Scope → enter SAP connection details (same as SAP GUI).

Add Invoke BAPI activity → select BAPI_SALESORDER_CREATEFROMDAT2.

Pass inputs in:

IMPORT section → Header details (DOC_TYPE, SALES_ORG, etc.)

TABLES section → Items, Partners, Schedule Lines, Prices

Prepare variables such as:

ORDER_HEADER_IN (structure)

ORDER_ITEMS_IN (list of items)

ORDER_PARTNERS (list of partner roles)

After calling the BAPI, run BAPI_TRANSACTION_COMMIT to save the order.

Read RETURN table to check success or errors.

Output SALESDOCUMENT = created Sales Order number.

Automating SAP BAPIs with UiPath Studio

Hello Everyone,

I am also facing a similar challenge. I need to pass the Ship-To Party, Sold-To Party, Item, Material, and Order Quantity, but I am confused about where to pass these input parameters. If possible, could you please provide a sample input Excel file? There are multiple BAPIs like BAPI_SALESORDER_CREATEFROMDAT, BAPI_SALESORDER_CREATEFROMDAT1, and BAPI_SALESORDER_CREATEFROMDAT2— which one should I use.

Hi @MADINENI_UDAYA

You should use BAPI_SALESORDER_CREATEFROMDAT2 because it’s most stable BAPI for creating sales orders.

You can pass the input in this form
Sold-To / Ship-To → ORDER_PARTNERS

Read this Excel and map each column to the respective BAPI tables. This will create the sales order correctly
If you found this solution work plz mark as solved
Cheers

Its throws the error.How to resolve this

Thanks

Can you pls provide the sample excel file where the parameter values are passed.

Here is the attched excel file I used. Can you please check anything needs to be modified
SalesOrderInputf.xlsx (10.2 KB)

@StefanSchnell - Please guide on this issue

Sure will check and update you

Hi @nishiijain2000 @MohammedShabbir- Now it’s not showing any error, but it did not create a sales order as well. I printed the message; it says to enter the ship-to or sold-to party. But I have entered value in excel sheet Attached excel file for reference


Sales Order template.xlsx (13.3 KB)

Can you use write line/ log message and print these values before calling BAPI.

Also for SoldTo field, see how its coming..

Also form where are you reading soldTo, exactly which column.. May be some wrong mapping


AG & WE are the ship to & sold to value.

@nithya
SAP shows “Enter sold-to/ship-to” because the value from Excel is coming as blank or wrong column.
Please try this

  1. Print both values:
    Log Message: row(“PARTN_NUMB”).ToString.Trim
  2. Map correctly:
    SoldTo / ShipTo must come from PARTN_NUMB, not PARTN_ROLE.
  3. Pad zeros (if needed):
    value.PadLeft(10,"0"c)
  4. Add both roles in PARTNERS table:
  • AG → Sold-to
  • WE → Ship-to

Usually the issue is wrong column mapping or Excel giving empty value.
Please try this solution
Cheers

Now I am able to pass the value.

Now its says No customer master record exist for sold to party.

This looks fine, then the way you are mapping, there something is going wrong.

are you using for each and assigning it.. Also trim the fields when you pass values.

Hi @nithya

Your value is correct The SAP error means customer 644386 is not created or not extended to the Sales Area, so SAP cannot create a sales order.

Ask your SAP SD team to check XD03/BP and extend the customer.

Cheers

Hi @nithya,
Use the Marketplace BAPI activity to call the SAP function (eg BAPI_SALESORDER_CREATEFROMDAT2). In the activity set the FunctionName to that BAPI and supply the connection. Pass input data into the BAPI’s import structures and table parameters: populate ORDER_HEADER_IN (DOC_TYPE, SALES_ORG, DIST_CHAN, DIVISION), fill ORDER_ITEMS_IN table rows (ITM_NUMBER, MATERIAL, TARGET_QTY, SCHED_TYP, etc), add ORDER_PARTNERS table rows (PARVW and PARTN for sold-to/ship-to), and any schedule lines or conditions tables as needed. Most Marketplace BAPI activities accept import structures as dictionaries/objects and tables as DataTable or list-of-dictionaries — map your sheet/variables into those inputs before calling.

After executing the BAPI read the RETURN table to check for errors or the created sales order number (in RETURN or the output parameter like SALES_DOCUMENT). If the call is successful you must call BAPI_TRANSACTION_COMMIT (another BAPI call) to commit the change. If there are errors, log RETURN messages and do not commit.

It says error in sales item Item.

Material # is not defined .

@nithya
The error means the material is not extended for the Sales Org (2100) and Distribution Channel (30) in SAP.

Ask the SAP team to check MM02 → Sales Org Data and extend the material for that sales area.

That’s why your BAPI returns “Error in SALES_ITEM_IN 000010”.

You can follow this links
https://forum.uipath.com/search?q=BAPI%20sales%20order

Cheers

Thanks Everyone for the support.

Its working.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.