Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ODate Sales Order Item List Price

0 Kudos
{   
    "ExternalReference": "{{SalesOrderExternalReference}}",
    "Name": "Lichung Test 001",
    "DataOriginTypeCode": "4",
    "SalesUnitParty":
        {   
            "PartyID": "{{SalesUnitID}}"
        },  
    "BuyerParty":
        {
            "PartyID": "{{CustomerID2}}"
        },
    "PricingTerms":
        {
            "CurrencyCode": "EUR",
            "GrossAmountIndicator": false
        },

    "Item":
        [
            {
                "ID": "10",
                "ProcessingTypeCode": "TAN",
                "Description":"Lichung test",
                "ItemProduct":
                    {
                        "ProductID": "SF-0000099"
                    },
                "ItemScheduleLine":
                    [
                        {
                            "Quantity": "2",
                            "unitCode": "XSX"
                        }
                    ],
                "ItemPriceAndTaxCalculation":
                    {
                        "ItemPriceComponent":
                        {
                            "Description":"Total Item Net Value",
                            "DecimalValue":"100",
                            "CurrencyCode":"EUR",
                            "BaseMeasureUnitCode":"XSX",
                            "BaseDecimalValue":"1"

                        }
                    }
                
            }
        ]
}       

I have problem when create sales oder from OData API.

I can't write the item list price.This is the json text I posted to "https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsalesorder/SalesOrderCollection".

And I got the error message:

{ "error": { "code": "", "message": { "lang": "en", "value": "Navigation property content for 'ItemPriceComponent' has wrong cardinality" } } } 
  • SAP Managed Tags:
7 REPLIES 7

palu
Employee
Employee
0 Kudos

Hi Hsu,

You are using a Deep Insert Method in the above payload. It looks, you are violating the Parent Child combination.

ItemPriceComponent is at 4th level in your Payload.

Kindly check the metadata of the Odata Service to check whether the collection is under ItemPriceAndTaxCalculation.

Also, there are no values given in ItemPriceAndTaxCalculation.

Regards,

Palani.

  • SAP Managed Tags:

0 Kudos

Hi Subramanian:

I check the metadata. I think ItemPriceComponent is under ItemPriceAndTaxCalculation.
Are there any document or example for reference?

  • SAP Managed Tags:

0 Kudos

Kindly check whether you can navigate from the parent to child. Then only it is possible to create data using Deep Insert.

Is the Payload working, if you remove the Price Component?

Regards,

Palani.

  • SAP Managed Tags:

YatseaLi
Product and Topic Expert
Product and Topic Expert

Hi Li,

If you are using the Odata sample from https://github.com/SAP-samples/byd-api-samples, then the association relationship betweenn ItemPriceAndTaxCalcuation to ItemPriceComponent is one to many.

<Association Name="ItemPriceAndTaxCalculation_ItemPriceComponent"><EndType="cust.ItemPriceComponent" Multiplicity="*" Role="ItemPriceComponent"/><End Type="cust.ItemPriceAndTaxCalculation" Multiplicity="1" Role="ItemPriceAndTaxCalculation"/></Association>
Therefore the right sample should be:

"ItemPriceAndTaxCalculation": {
                "ItemPriceComponent": [
                    {
                        "Description": "Total Item Net Value",
                        "DecimalValue": "100",
                        "CurrencyCode": "EUR",
                        "BaseMeasureUnitCode": "EA",
                        "BaseDecimalValue": "1"
                    }
                ]
            }

However, you will hit to another error about "ItemPriceAndTaxCalculationCollection is not allowed for creation. ", for it is not allowed created in OData metadata, which is only allowed for update operation. Please find the attached screenshot for detail.

Hence, you need to create the sales order with item first, then update it by updating the ItemPriceAndTaxCalculationCollection, please refer to the odata sample > Create Sales Order Node by Node > Update item schedule line.

Alternatively, you can you can achieve so in one shot through ManageSalesOrderIn web service. Here is a soap request sample:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global" xmlns:glob1="http://sap.com/xi/AP/Globalization">
   <soap:Header/>
   <soap:Body>
      <glob:SalesOrderBundleMaintainRequest_sync>
         <BasicMessageHeader>
         </BasicMessageHeader>
         <SalesOrder actionCode="01">     
             <ID>4023</ID>
             <ObjectNodeSenderTechnicalID>1000</ObjectNodeSenderTechnicalID>   
            <ReleaseAllItemsToExecution>true</ReleaseAllItemsToExecution>
            <Name>Updated via SOAP UI</Name>
            <ExternalReference>Demo for Training</ExternalReference>
            <PostingDate>2020-08-06T00:00:00Z</PostingDate>
            <!--Optional:-->
            <RequestedFulfillmentPeriodPeriodTerms actionCode="04">
               <!--Optional:-->
               <StartDateTime timeZoneCode='CET'>2020-08-06T12:00:00Z</StartDateTime>
            </RequestedFulfillmentPeriodPeriodTerms>
            <SalesUnitParty actionCode="04">
               <PartyID>P1110</PartyID>
            </SalesUnitParty>
            <AccountParty actionCode="04">
               <PartyID>CP100110</PartyID>
            </AccountParty>
            <PricingTerms actionCode="04">
               <CurrencyCode>USD</CurrencyCode>
               <GrossAmountIndicator>false</GrossAmountIndicator>
            </PricingTerms>        
            <Item actionCode="04">
               <ItemProduct actionCode="04">
                  <ProductInternalID>P100401</ProductInternalID>
               </ItemProduct>
               <ItemScheduleLine actionCode="04">
                  <ID>1</ID>
                  <TypeCode>1</TypeCode>
                  <Quantity unitCode="EA">2.0</Quantity>
               </ItemScheduleLine>
               <PriceAndTaxCalculationItem actionCode="04">
                  <ItemMainPrice actionCode="04">
                     <Rate>
                        <DecimalValue>200.0</DecimalValue>
                        <CurrencyCode>USD</CurrencyCode>
                        <BaseDecimalValue>1.0</BaseDecimalValue>
                        <BaseMeasureUnitCode>EA</BaseMeasureUnitCode>
                     </Rate>
                  </ItemMainPrice>
               </PriceAndTaxCalculationItem>               
            </Item>
         </SalesOrder>
      </glob:SalesOrderBundleMaintainRequest_sync>
   </soap:Body>
</soap:Envelope>

Kind Regards, Yatsea

  • SAP Managed Tags:

0 Kudos

Hi,Yatsea:

I see it can't create ItemTaxAndPriceCalculation.Is there any possible to send the OrderItem List Price to SAP from ODATA API?

The information in Sales Order and Sales Order Item are important.And I want reduce the error from user key in.

Kind Regards, Li Chung

  • SAP Managed Tags:

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Li-Chung,

Just verified myself and confirmed that Updating ItemPriceAndTaxCalculationCollection isn't working. Here you have my test steps below.

Therefore, the only way will be using web service ManageSalesOrderIn to create sales order with item price as mentioned in my last reply. BTW, please add the Tags of "SAP Business ByDesign" and "SAP Cloud Application Studio" on the question, as a result, it will be listed on under the approperiate tags, where a higher chance of receiving more answers from the ByD and CAS experts.

Step 1: Create a Sales Order without node ItemPriceAndTaxCalculationCollection.

{   
    "ExternalReference": "{{SalesOrderExternalReference}}",
    "Name": "Lichung Test 001",
    "DataOriginTypeCode": "4",
    "SalesUnitParty":
        {   
            "PartyID": "{{SalesUnitID}}"
        },  
    "BuyerParty":
        {
            "PartyID": "{{CustomerID2}}"
        },
    "PricingTerms":
        {
            "CurrencyCode": "EUR",
            "GrossAmountIndicator": false
        },

    "Item":
        [
            {
                "ID": "10",
                "ProcessingTypeCode": "TAN",
                "Description":"Lichung test",
                "ItemProduct":
                    {
                        "ProductID": "SF-0000099"
                    },
                "ItemScheduleLine":
                    [
                        {
                            "Quantity": "2",
                            "unitCode": "XSX"
                        }
                    ]
            }
        ]
}      

As a result, it will create the sales orders with the item with default price.

Step 2: Get the ObjectID of sub node ItemPriceAndTaxCalculationCollection with query as below:
GET

https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsalesorder/SalesOrderCollection?$format=json&$exp... eq '{{ID}}'

As a result, for each Item, it will has a sub node ItemPriceAndTaxCalculationCollection, for example, you may get the ObjectID of ItemPriceAndTaxCalculationCollection for the first item as '00163E71D7E21EDB8AAFB99CA7DE5DBC'

Certainly, your program need to loop item by item in resultset of step 2, and update the price as step 3

Step 3: Update the price for the target item by item.

Take the first item's ItemPriceAndTaxCalculationCollection

 PATCH https://my343094.sapbydesign.com/sap/byd/odata/cust/v1/khsalesorder/ItemPriceAndTaxCalculationCollection('00163E71D7E21EDB8AAFB99CA7DE5DBC')

Request Body:
{
    "ItemPriceComponent": [
        {
            "Description": "Total Item Net Value",
            "DecimalValue": "100",
            "CurrencyCode": "EUR",
            "BaseMeasureUnitCode": "EA",
            "BaseDecimalValue": "1"
        }
    ]
}

The request return OK(204). However the ItemPriceComponent doesn't really updated in the Sales Order.

Kind Regards, Yatsea

  • SAP Managed Tags:

0 Kudos

Hi,Yatsea:

We meet another problem.When we create a new order with SAP Bydesign Odata.And system ask us fill in orderitem list price.

Is that possible void this vailidation?

  • SAP Managed Tags: