Blog

  • $FILTER in SAP OData

    Preface – This post is part of the SAP ABAP OData Tutorial series.

    In this section, we will learn the concept of the $filter query in SAP OData and its usage.

    Supported System Version

    SAP NetWeaver Gateway Release 2.0 Support Package >=03

    Syntax

    http://<server>:<port>/sap/opu/odata/sap/<service_name>/EntitySet?$filter=ProductId eq ‘HP-101’

    Business Example

    The shopping site, say, Amazon is displaying all the products but you want some specific category to be displayed. So, you will apply filters (select category phones or laptops)  to display the data of your choice.

    Implementation

    In this section, we will implement $filter on our Product Entity Set.

    Step 1: After the creation of the OData service, right Click on Entity Set under Service Implementation, go to ABAP workbench.

    SAP OData Implementation

    Step 2:

    Adjust your code for $filter query.

    $FILTER in SAP OData

    The filter query option is available by accessing the parameter IT_FILTER_SELECT_OPTIONS.

    In the above code, we first retrieved the filter options passed from the frontend by reading IT_FILTER_SELECT_OPTIONS. And then passed the select-option range to BAPI to get the desired filtered output.

    Step 3:

    If we do not pass any filter option, we will get all the products from the system.

    Add $filter query in OData URL and execute the service. You can add one or more filter options.

    Service URL: /sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/ProductsSet?$filter=Name eq ‘Notebook Basic 15.

     

    Operators used with $filter

    Logical Operators

    Logical Operator Description Example
    eq Equal https://<API-Server>/odata/v2/User?$filter=gender eq ‘F’ .
    ne Not Equal hhttps://<API-Server>/odata/v2/User?$filter=place ne ‘’London’
    gt Greater than https://<API-Server>/odata/v2/PicklistLabel?$filter=amount gt 200
    ge Greater than or equal https://<API-Server>/odata/v2/PicklistLabel?$filter=amount ge 200
    lt Less than https://<API-Server>/odata/v2/PicklistLabel?$filter=amount lt 200
    le Less than or equal https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200
    and Logical and https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200 and amount ge 300
    or Logical or https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200 or amount ge 300
    not Logical not https://<API-Server>/odata/v2/PicklistLabel?$filter=amount le 200 not amount ge 300

     

    Arithmetic Operators

    Arithmetic Operator Description Example
    add Addition https://<API-Server>/odata/v2/PicklistLabel?$filter=amount add 5 gt 10
    sub Subtraction https://<API-Server>/odata/v2/PicklistLabel?$filter= amount sub 5 gt 10
    mul Multiplication https://<API-Server>/odata/v2/PicklistLabel?$filter= amount mul 5 gt 10
    div Division https://<API-Server>/odata/v2/PicklistLabel?$filter= amount div 5 gt 10
    mod Modulus https://<API-Server>/odata/v2/PicklistLabel?$filter= amount mod 5 gt 10

     

    Grouping Operators

    Grouping Operator Description Example
    ( ) Precedence grouping https://<API-Server>/odata/v2/PicklistLabel?$filter=(number sub 20) gt 30

     

  • Inquiry – Hands-on

    Preface – This post is part of the SAP SD series.

    Introduction

    In this section, we’re going to see how to create an inquiry in the system.

    Steps to create an Inquiry:

    • Go to transaction code VA11.
    • Give Inquiry Type and Organization Data details
    • Give Header details
    • Give Item details
    • Save

    Go to transaction VA11.

    This is the transaction code to create an inquiry. You can just hit, enter or click on this green checkmark.

    Transaction VA11

     

     

    If you don’t like to remember these funky codes, they can still do logistics, sales and distribution, sales, inquiry and create.

    Create Inquiry VA11

     

     

    So you can do this transaction, either way, use the transaction Code VA11 or you go to logistics, sales and distribution sales inquiry, then create.

    So you can use VA11 or use the menu path.

    Give Inquiry Type and Organization Data details

    Go inside by either double-clicking it, or typing in VA11 and hitting enter, you’ll be taken to the screen. This is the first screen.

    Inquiry Type

    When you create an inquiry, what do you have here? You have two main pieces of data.

     

    • Inquiry type, and when you go create a quotation, it’s going to say a quotation type. I don’t want to fully get into the concept of actually creating an inquiry type or configuring an inquiry type yet. But for now, I just want to understand that there are two pieces to start with.
      If you want to give me an example, you go to a subway and order some sandwiches, you’re going to start with some basic choices, like is it going to be a six-inches or a foot long? Right. You’re going to make some basic choices and then further move up from there.
      So similarly, this is the first choice that you’ve got to make. What is the inquiry type that you’re going to create? There can be multiple inquiries, inquiries for a certain group of products from another group of products.
      For example, a company like HP could be doing one inquiry type for all parts, any spare parts, another inquiry type for, say, capital goods? Another inquiry type for, say, routers. Because they might represent different lines of businesses and each inquiry is different for them, so they might want to do a different inquiry for each of them.
    • Similarly, there is something called ORG Data. This is more or less the areas or the geographical areas in which they are to business. That’s a very gross misrepresentation. But for now, just think of our data as your different geographies.
      Like, again, if you take the HP example, the ORG data for sales happening in the US is going to be US organization distribution channel, let’s say retail and division park sales. And if they are creating an inquiry into Singapore, it’s going to be sales of Singapore. It could be retail or wholesale distribution channel and say capital goods division. Now, I’m just taking too many examples here, but don’t worry, we’re going to talk about all these things in much greater detail at a later point.

     

    I just want to give you an idea of what’s an inquiry type and what’s your data and more importantly, why you’re seeing them here, because this is going to set the precedent for what you’re going to enter going forward.

    Let me give you one simple example. You don’t want to choose the ORG data for the US. And when you go inside this enter customer from the Singapore or Japanese region. Right. It’s just wrong.

    So you’re making a choice here and you’ll stick to those choices going forward as you enter customer data and material data.

     

    All right, so that’s a goal here, click on this dropdown and select an as your inquiry. As I said, you can create your own inquiry types, but we’re not there yet. For now, we’ll select a standard inquiry type provided by SAP and click OK, and over here, select your sales or distribution channel and division.

    Select Inquiry

    Enter Organizational Data

     

    Now, what are these Sales Organization 1000 represents the German sales org, Distribution Channel 10 represents the retail distribution channel and 00 represents a cross-division. But why is 1000 representing Germany? We will come to that when we come to enterprise structure. But until then, just select this level of details and hit enter.

    Enter Header data.

    Enter Header Data

     

    You need to fill in some data and the rest of the details are automatically be picked up by SAP based on the data that’s already available.

    For example, you want to pick a customer, right? In this case, Wal-Mart is our customer. We might not have created Wal-Mart yet in the system because we don’t know how to create a customer yet, but let’s just pick some customers for now.

    Say 1000, that’s a customer.

    Choose Sold to Party

     

    Now, again, why one thousand? I just picked up a number because I know it exists. If you don’t know a number, you can click on the button beside the Sold-To-Party field and it’ll pop up a search box where they can do a variety of searches by postal code by city.

    Search Ship to Party

     

    Let’s see if there’s anything like Wal-Mart. So I do a start which is a wild character and then to Wal-Mart and then star. So anything that has Wal-Mart in its name will be displayed.

    Search Ship to Party by Company Name

     

    So this is where you do your search and you select what kind of customer you want and so on.

     

    So now coming back to our step. We have entered our customer and now hit the green button. It’s giving me another pop up now.

    Partner Selection Screen

     

    It says this customer has multiple ship to parties.

     

    That means there are many ship to address that the customer could potentially ask us to ship. Which one do you want to select? You can either select the default one, which has a checkmark in there, or you can select the other one.

    Select Ship to Party

    Now you can just let it remain and click OK.

     

    Right, in this case, it has already pulled up the customer name, customer address and other details for the customer corresponding to the number 1000. So, what’s the name of the customer? It’s Becker Berlin and he stays at Calvin Strasse, some address and then Berlin. That’s the address.

    Verify Ship to Party

     

     

    Enter Line item data.

    Enter Line item data

    So here you will enter the line item details like desktops, laptops etc. Now, in this case, we don’t have desktops or laptops yet in the system. I know some materials, so I’m going to enter them here.

    Enter Material Details

     

    I entered material, quantity and hit enter. It will populate the material details with a description. You can enter more line items.

    populate the material details

     

    Now, we will enter the PO number and hit enter. As soon as you hit enter the system validates things. If there is an error, for example, say if you enter some wrong data, raw material, some random number that doesn’t exist. The system is going to look at the database behind the scenes and say, hey, this material is not defined.

     

    So now just click on the save button and look at the left bottom corner here, inquiry 10000006 have been saved.

    Inquiry successful creation

     

    This is called an inquiry number.

    And this is the number that we were referring to in our picture as inquiry number 10000006.

    Now this is what we’re going to give to Wal-Mart and say, you know what, this is the inquiry that we have created from SAP. Thank you very much for your inquiry.

    So this is how we create an Inquiry and an inquiry number is generated.

  • Invoice

    Preface – This post is part of the SAP SD series.

    Introduction

    After the sales have happened and after the logistics processes, which is physically delivering the goods, have happened and the truck has left the warehouse, you can start to invoice the customer.

    If you take a case of Amazon, you go select the product, you pay and then get the order number. This is typically the case with any B2C physical deliverables. You can take Wal-Mart retail sales. Anybody walks into Wal-Mart, buys a product, you give the product, the sales clerk scans it, generates a bill, you pay, you walk out.

    Now, this is B2B we are talking about, the sale between Wal-Mart and HP. Wal-Mart sends an order. HP takes the order, delivers the order, and then after the delivery, it bills Walmart. In the meanwhile, the delivery would have happened or it might be in between.

    That’s a difference in how billing happens between B2B and B2C scenarios.

     

    What is invoice or billing?

     

    Billing is as simple as how Walmart generates a bill for you. There are these products that you have asked for, some desktops, some laptops, what not quantities. However much has been delivered, we’re going to bill them. Let’s say we have only delivered 95 laptops and 15 desktops. So we are going to bill for 95 laptops and 15 desktops. And what do you do after billing, you generate a bill or an invoice which says customer Wal-Mart these are our products, these are the prices which will include taxes, freight discounts, etc. Then finally sent a copy to Wal-Mart saying, this is what we have delivered and this is what you need to pay us.

     

    So billing is an itemized selection of what has been shipped based on the customer’s order and how much the customer needs to pay. This is where the dollar value comes in.

     

    Now, in the next article, we’re going to create an invoice or billing for the delivery that we have just PGI.

  • Picking, Packing and PGI

    Preface – This post is part of the SAP SD series.

    Introduction

    We have learnt that pre-sales, sales and anything after sales is logistics. So logistics is where depending on the availability of goods you create the delivery.

    Delivery has three pieces to it or there are three sections to delivery.

    • Picking
    • Packing
    • PGI

    The first one is picking, the second is packing (this is optional), sometimes you do pack, sometimes you don’t need to do it for some materials. But picking is typically a process that’s followed for all physical deliverables, meaning physical goods, all tangible goods. And the last step is PGI, which is posting the issue of goods or post goods issue. The corresponding accounts are updated and the inventory is updated. This is the delivery.

     

    What is picking?

    Depending on what the customer needs, these products will be brought to a place called a staging area, where you can do all the packing and the processing. So you get all these goods in the staging area and the next step is to get these goods ready for packing.

     

    What is packing?

    Packing is just pulling those desktops, laptops, whatever the products are, into the proper packaging format requested by the customer, weighing them on your FedEx machine or EPS machine and keeping the box ready for the truck to come in. This is packing.

    After packing, when the truck comes in, the packed goods are loaded and the truck leaves. This is called picking.

     

    What is a post goods issue (PGI)?

    The goods that you have picked, packed and loaded are really no longer yours. They need to be accounted for in your inventory. All the details will be accounted for in your inventory.

    Meaning what is your inventory, in our case its desktop, what’s the total as of before the packing sets,  quantities, let’s say 2000. Now as part of this delivery, 500 has been reduced. So now it’s 1500. So, this process of reducing the inventory and making sure that the accounts are up to date is called the post goods issue.

     

    So, these are the three main steps that happen in the delivery.

    In the next article, we are going to actually create a delivery for the order that we have created previously and do the picking. And we’re not going to do the packing yet and we are just going to do the PGI and technically close that delivery.

  • Delivery

    Preface – This post is part of the SAP SD series.

    Introduction

    We have finished our pre-sales documents, inquiry, quotations and then Wal-Mart has placed an order, this is a sales document. So now we need to deliver the physical goods. This part is called logistics and this behaves differently than an order.

     

    What is the delivery?

    Most of the things in the delivery, again, are copied down from an order because we are trying to deliver the goods corresponding to the order that the customer has given us.

    Example

    In this case, the customer said he needs a desktop, quantity 100 and then there could be more line items. And each line item over here will have what is called a confirmed date.

    When creating the order, SAP has already done the availability check. An availability check confirms that these goods will be available or can be confirmed by this date, say, 14th of March or whatever. When you try to create this delivery, you should create it for that date, because if you try to create it before the system knows that the goods are not going to be it will not allow you to create a delivery. So make sure that the date you are trying to create the delivery, is the date the goods are confirmed. That’s called the delivery date.

    Once you get that, then you can create a delivery. Only the items that have that are to be delivered in the designed timeframe will be going to be delivered. Whenever the goods are available you can create a delivery document and all the goods that are confirmed by that date, the date when you’re creating the delivery will flow down from the order into the delivery.

     

    Pieces of Delivery

    Delivery essentially comprises three pieces.

    • Picking
    • Packing
    • PGI or post goods.

    There are other areas as well, but these are the main three key pieces or three key subprocesses in our delivery.

    We will understand picking, packing and PGI in our next article.

  • Sales Order

    Preface – This post is part of the SAP SD series.

    Introduction

    In the previous articles, we have learnt about an inquiry with an example. So we have Wal-Mart as our customer. We have a company, say, HP. Wal-Mart has inquired for some goods and an inquiry has been created in the system and sent out to Wal-Mart. Wal-Mart liked the inquiry and requested a formal call. This is a quote or an RFQ. A quotation was created in the system with reference to the inquiry.

    Up until this point, things are casual, meaning the customer is not promising to buy. The customer is just fooling around. Basically, it’s like you want to buy a car. You go to one dealer, another dealer, you go to five different dealers. You might just inquire for how long you want or you might get quotations from one, two, three, four different car sales guys or dealers. And you ultimately will end up buying from one. Typically, the quote that you like, you just confirm the quote and that’s when you go in and place an order for the car. But up until that point, it’s just called pre-sales term, because up until this point, there’s no sale.

    But after this, if the customer chooses to buy, then the customer will place what is called a purchase order.

    Steps to sales:

    • Inquiry
    • Quotation
    • Purchase order

     

    So from this point on, it becomes a sale. It’s almost exactly similar in terms of the data that it contains between an inquiry and a quotation. The customer does not change, nor does the quantities or the products that are desktops, laptops. So you can as well create it with reference and copy all the products and customers over to your subsequent document. In this case, the document is a sales order. And save it and generate a number for you, say 13409, and that is what you’re going to send as a purchase order, confirmation to the customer, Wal-Mart.

    Sales Order

    A sales order is a document generated in the system by the seller containing all the details related to the products or services requested by the customer. The details include prices, quantities, terms and conditions and much more information.

    Purchase order

    A purchase order is a fancy word for an order number generator in the system that confirms to the buyer that they have received the order. It is a document that a customer sends to the supplier that includes details like quantities, prices.

    It’s just like if you place an order at Amazon, you’ll get order confirmation. So here are the products you brought to get to know the prices, the total taxes and of course, you get additional details like when it’s going to ship by, and on what carrier, what tracking number and other information. That’s your purchase order number.

    Difference between purchase order and sales order

    When the customer is buying things, he’s actually purchasing things. Wal-Mart, the customer, calls it a purchase order. HP, on the other hand, is selling things. So it’s called the sales order, but both are the same in this case.

    And another point, just like the way quotation number and an inquiry number is generated, a purchase number is generated and sent to the customer, and that is called an order confirmation or a purchase order confirmation or sometimes it’s called sales order confirmation.

     

     

  • Quotation

    Preface – This post is part of the SAP SD series.

    Introduction

    Now that we have talked about the inquiry in the previous section, let’s start with the next step. We will continue with the example of Wal-Mart. Wal-Mart makes a decision that they like the inquiry, meaning that they like the prices or the product delivery date that HP has proposed. Or they don’t like it. If they like it, they like to continue their discussion further with HP in terms of how they would like to proceed further. The next step to an inquiry from a customer perspective needs to ask for a formal quote.

     

    What is a quote?

    The quotation process is going to look something like this: Wal-Mart is going to call or get in touch with HP and say, all right, with respect to our inquiry number 110120, we would like to continue further and want to ask you for a formal quote.

     

    A quote is very similar to an inquiry. But almost has the same set of details. From HP’s perspective, the quote is almost similar. So, we have the customer, Wal-Mart, and of course products, Desktop, laptop and the quantities, prices. That’s a quote.

    So why are they doing it again? If everything is similar between a quote and an inquiry, what’s the point in trying to do it again?  There are a couple of differences between the two.

     

    Inquiry and quotation

    An inquiry is very informal. Meaning, you go shopping at home for cars, you would go visit ten different dealerships. You’re not really sure which car you want. Maybe through the course of doing all these inquiries with different vendors, you find out that you might need a particular model of a car, say a Honda CRV. Now, you start to focus more on getting quotes from Honda CRV from different dealers that you’ve visited.

     

    Difference between Inquiry and Quotation

    The difference is, an inquiry is more informal. So HP does not need to stick to its stores or prizes, or variables. An inquiry has been made, we promised $500 per piece here, and if Walmart comes back 10 days from now and says I need the product, HP is not legally bound to deliver them at that price. But, a quotation on the other hand is more formal, which means the terms and conditions including prices, quantities, and deliverables need to be adhered to. Legally means, it’s more or less a formal legal quote, whereas inquiry is more informal, no terms, no promises.

     

    The clear difference is inquiry is more informal. So, it doesn’t have a set of days with which it’s valid. It’s informal anyway.

    The quotation, on the other hand, has a set of days within which it’s valid.

    Example of Inquiry and Quotation

    We can take an example, let’s continue the same car search.

    We’re searching for cars and you found a car, you’d like to get a quote on it. Let’s say the dealer has quoted $25,000. It’s not going to be valid forever, right? It’s going to be valid for, say, two weeks or a week at most. So this set of dates within which that quotation is valid is called validity dates. All quotations typically have a validity date. So the from date, and the to date is called the validity dates.

     

    You can grab some more differences between the inquiry and the quotation.

     

  • Order to Cash cycle- Inquiry

    Preface – This post is part of the SAP SD series.

    Introduction

    In this article, we will understand the sales order cycle. Every business will have a cycle. Let’s take an example of the finance business or the finance department. So, the finance department is responsible for looking at what the customer needs to pay and receiving the cash or receiving payments. That’s their business, they call it a report to record.

    Another example can be the procurement department. So, the procurement department is responsible for interacting with the vendors, getting the goods on time, so on. He is responsible for placing the purchase order with a vendor. For example, if Amul procurement department were to be taken as an example, they are responsible for dealing with the vendors that supply the goods. The procurement department will talk to all the different milk vendors. They’ll raise purchase orders, they’ll get the goods into the stock and they’ll pay the invoices, meaning pay the money to their vendors. This cycle is called procure to pay. So similarly, there are different business cycles followed by the different departments.

    Here, we will look into the sales department and different terms used in it. The sales department also follows a cycle, called the sales order cycle.

     

    What is Sales Order Cycle?

    The sales order cycle is a sequence of actions that a business follows to fulfil customer requirements.

     

    What is an RFI or an Inquiry?

    RFI is abbreviated as Request for Inquiry. It is a document requested by the company to gather information about the products and services from suppliers.

     

    What information’s are included in RFI?

    Every business can decide their own format for an RFI that they want to collect from the supplier. There is no particular way to write an RFI.

    Below are some details that can be included in an RFI.

    • Basic information about your company.
    • Request supplier to provide basic information about their organization
    • Confidentiality agreement to prevent the disclosure of information with a third party.
    • Statement for the reason of RFI.
    • Queries related to supplier experience in the relevant projects.

     

    Example

    The sales order cycle is best understood with an example. We will consider a B2B (business-to-business) scenario because SAP is built for more B2B scenarios.

    Let’s take two companies, one company say, a computer manufacturing company, HP or Dell. This is the company which is selling. So, we are looking at things from HP’s perspective. And there will be a buyer company.

    Let’s take the scenario of HP selling computers to the customer, Walmart. Wal-Mart is our customer. So, HP sells computers to Wal-Mart.

    How does the cycle start?

    Wal-Mart is looking for computers. It is inquiring about the different rates of HP, Dell and all the different computer manufacturers. Wal-Mart sends an RFI or Inquiry to HP. So, as soon as HP receive the request from Wal-Mart, they will capture the information in a document based on the customer’s RFI. This document is called an Inquiry.

    And as soon as this inquiry is saved in the system, you get an inquiry number. This inquiry number will be sent over to Walmart as a response to that inquiry.

     

  • Master Data

    Preface – This post is part of the SAP SD series.

    Introduction

    In this article, we are going to talk about master data. Master Data is everywhere. We see master data all around us. For example, if you go to Safeway, you go buy a bunch of products where you buy some soap and other stuff, and then you go to the billing counter, all your items are scanned and you’ll be asked if you have a reward card. So, this is a card that you’ll be given whereby your discounts will be cumulatively added and if you don’t have one, they’ll give one right away. What does the reward card have? A rewards card has your name, address and some of the personal details about you that they think are relevant for your purchase. This right here is Master Data. You can also call it customer master because you’re a customer in this case and Safeway is the company of the vendor which is selling you these products.

     

    What is Master data?

    Master Data is at its very fundamental level a collection of properties of an object. Objects could be customers, materials, vendors, assets, any of these. Typically, this kind of data is created only once, meaning you don’t create them again and again and again. For example, in the previous case when Best Buy was created as a customer, you don’t get BestBuy again and again and again. It’s created once, but it’s used again and again and again. And because it’s created once, you rarely change it. It’s changed occasionally. It is also the main source of data in transactions. You take any transaction sales order, delivery, billing, purchase, order, transfer order, posting to accounts, any kind of transaction typically has the bulk of the data coming in from the master data.

     

    Properties of Master data

    • Created once and used again and again.
    • Rarely changed.
    • Main Source of data in transactions.

     

    Types of master data

    Master Data in SAP

     

    Examples

    Let’s dig into some examples.

    Example 1

    Let’s say you go buy a piece of bread or buy a bottle of milk and then you go to the counter and these products are scanned. When they are scanned just one little scan can reveal a whole bunch of information about the product.

    What kind of information could that be? Some examples, of that information, could be:

    • Product name. For example, a particular model of bread is bread plain bread, milk break etc.
    • Product description
    • Price for that product and
    • Discounts they are given on that product
    • Cumulative discounts that are given on

     

    Here, Product Name and Product Description are master data. This is called data related to the material. And so it’s called material master data. Whereas, Price, Discounts and Cumulative discounts can be called pricing master data.

     

    Example 2

    Take another example of Amazon. You go to Amazon and you go log in, right? So, you have your username and password as soon as you log in. You can go to your account any time you want. So, when you go to your account you will have details like names, addresses. You can have multiple addresses like one address in Delhi, India one of those in Texas, US, you can store all your different addresses and you can store your credit cards or debit cards details and also different debit cards and credit cards. All of these are master data. And in this case, you are the customer, so you can call it customer master data. All these are common examples of master data that you typically see in a B2C environment all along.

     

    Example 3

    Say, HP is a company that is implementing SAP and a company buying from HP say Best Buy. Now, Best Buy places an order for, let’s say computers or whatever products that HP sells and HP creates an order. The order contains a header and has line items. Let’s say one, two, three, however many.

     

    On the header, what kind of information does it have?

    • Customer information: It has customer information of course and that’s Best Buy in this case,
    • Tax: The next thing is a tax classification
    • Corporate/Government: What kind of a customer is he, a corporate customer or is he a government customer or any other. In this case, he is a corporate customer or retail customer.
    • Ship: Can we ship all the goods together, yes or no? In this case, being a customer it’s an option that Best Buy gives, right?
    • Address: address to which we need to ship the goods.
    • Phone number: If there are issues which phone number to call to.
    • Payer: Who will be paying for this transaction.
    • Billing address: Where should the bill be sent?

    These are all the things that are captured, at the header level.

     

    Now, similarly, at the line-item level, what do we have?

    • Material: We have details like material that say it’s a computer model one on one
    • Weight: Say, 5 lbs
    • Volume
    • Plant: Which plant is it going to send the goods out of? Let’s say it’s sent out to the Bangalore plant.
    • Tax classification: Sometimes some goods, some materials are taxable and some materials are not.

    Looking back to header data, we have data related to customers and line-item data has data related to the material. So basically, master data in this case is a bunch of properties related to a customer or a material.

  • SAP EML (Entity Manipulation Language) in RAP: Guide

    SAP EML (Entity Manipulation Language) in RAP: Guide

    Preface – This post is part of the SAP ABAP RAP series.

    Introduction

    SAP Entity Manipulation Language (EML) is an ABAP language that is used to control the behavior of business objects in the context of the RESTful Application Programming model (also called SAP ABAP RAP). The business objects developed with the SAP ABAP RAP model can be consumed not only by OData protocol (Web API, Fiori UI) but also in ABAP using EML statements.

    There are two flavors of EML:

    • Standard API: Uses signature of business object entities
    • Generic API: Used for dynamic consumption of the business object

    The Generic API is used for the dynamic integration of business objects into other frameworks, such as the Cloud Data Migration Cockpit. Generic API is not in our scope. We will focus on Standard API’s.

    The Standard API’s are used when target business object is statically specified. It provides READ and MODIFY statements for the access of transactional scenarios of objects and COMMIT access for triggering save sequence. Using these syntaxes we will be able to perform the transactional behavior ( Create, Update, Delete, Actions, Read ) of business objects that are defined in Behaviour Definition.

    SAP EML Scenarios

    The following table gives you an overview of different SAP EML scenarios:

    Scenario Description Relevant EML statements
    Develop(BO with IN LOCAL MODE within its own behaviour pool) In EML develop scenario, when you provide the functionality for your own BO in its own behaviour pool, you use IN LOCAL MODE. It bypasses the access control, authorization control and feature instance control.  You can use it with CRUD and Actions. ·         READ/READ by ASSOCIATION

    ·         CREATE/CREATE BY ASSOCIATION

    ·         UPDATE/UPDATE BY ASSOCIATION

    ·         DELETE/DELETE BY ASSOCIATION

    ·         EXECUTE

    ·         AUGMENTING BY ASSOCIATION

    Consume (BO from other behaviour pool/ released objects) In consume scenario, you can use EML to consume other BO in or released BO’s. Here, you are not allowed to used IN LOCAL MODE. ·         READ/READ by ASSOCIATION

    ·         CREATE/CREATE BY ASSOCIATION

    ·         UPDATE/UPDATE BY ASSOCIATION

    ·         DELETE/DELETE BY ASSOCIATION

    ·         EXECUTE

    ·         GET PERMISSION

    ·         SET LOCK

    Test To test the BO outside of ABAP behaviour pool, you can use EML statements. Here, it is mandatory to add COMMIT statement to end RAP LUW. When in case of implementation inside behaviour pool, save it is done by the framework and we need not to write explicit COMMIT there. ·         READ/READ by ASSOCIATION

    ·         CREATE/CREATE BY ASSOCIATION

    ·         UPDATE/UPDATE BY ASSOCIATION

    ·         DELETE/DELETE BY ASSOCIATION

    ·         EXECUTE

    ·         GET PERMISSION

    ·         SET LOCK

    ·         COMMIT ENTITIES

    ·         ROLLBACK ENTITIES

     

    SAP EML Syntax

    SAP EML syntax has three major sections:

    • READ
    • MODIFY
    • COMMIT

     

    READ syntax

    READ is used to retrieve the data or you can say read the data of the entity. The syntax supports:

    • Read: Read the entity
    • Read by association: Read child entity using parent key

     

    Short syntax –

    READ ENTITY
    
     EntityName [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance
    
    RESULT et_result
    
    BY \association_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_rba
    
    RESULT et_result_rba
    
    LINK et_link_rba
    
    [FAILED ct_failed].
    
    where,
    
    EntityName: specifies the CDS view entity
    
    FIELDS: specifies the direct read for the given fields
    
    RESULT: used to store the retrieved data in variable
    
    LINK: used to store the key pair that is used for read by association operation
    
    Failed: used to store the response about failed retrieve (key-value, fail cause etc)

    Long syntax-

    READ ENTITIES OF RootEntityName
    
    ENTITY entity_1 " entity alias name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_1
    
    RESULT it_result
    
    BY \association1_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_rba
    
    RESULT et_result_rba
    
    LINK et_link_rba
    
    ENTITY entity_2_name " entity alias name [FIELDS ( ......
    
    ENTITY entity_3_name " entity alias name
    
           ... [FAILED ct_failed].

    The long syntax allows you to club READ operation of multiple entities of Business Object specified by RootEntity name at one go. Also, we can use alias names of entities defined in Behavior Definition.

    Example:

    READ ENTITIES OF /dmo/i_travel_m
    
    ENTITY travel
    
    FIELDS ( travel_id
    
      agency_id
    
                          customer_id
    
                          booking_fee
    
                          total_price
    
                          currency_code )
    
    WITH CORRESPONDING #( keys )
    
    RESULT DATA(ct_read_result)
    
    FAILED DATA(ct_failed)
    
    REPORTED DATA(ct_reported).

    MODIFY syntax

    MODIFY statement is used when we want to perform the change of data in entities. It includes:

    • Create
    • Create by association
    • Update
    • Delete
    • Execute (for Action)

    Short syntax-

    MODIFY ENTITY EntityName
    
    CREATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] it instance_crt
    
    CREATE BY \association_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_cba
    
    UPDATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance_upd
    
    DELETE FROM it_instance_del
    
    EXECUTE action_name FROM it_instance_act
    
    [RESULT et_result_a] [FAILED ct_failed] [MAPPED ct_mapped] [REPORTED ct_reported].

    Long syntax-

    MODIFY ENTITIES OF RootEntityName
    
    ENTITY entity1_name CREATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] it_instance1_crt
    
    CREATE BY \association_name [FIELDS ( field1 field2 ... ) WITH] | [FROM] itinstance1_cba
    
    UPDATE [FIELDS ( field1 field2 ... ) WITH] | [FROM] itinstance1_u
    
    DELETE FROM it_instance1_del
    
    EXECUTE action FROM it_instance1_act
    
    [RESULT et_result]
    
    
    
    
    ENTITY entity2_name
    
    CREATE FROM it_instance2_crt
    
    ...
    
    
    
    
    ENTITY entity3_name
    
    ... [FAILED ct_failed] [MAPPED ct_mapped] [REPORTED ct_reported].

    The long syntax allows clubbing multiple MODIFY operations of entities specified by RootEntity of the business object. We can specify alias names for entities if they are defined in behaviour definition.

    Example

    MODIFY ENTITIES OF /dmo/i_travel_m
    
    ENTITY travel
    
    CREATE FIELDS ( travel_id
    
       agency_id
    
       customer_id
    
       begin_date
    
       end_date
    
       booking_fee
    
       total_price
    
       currency_code
    
       description
    
       overall_status )
    
    WITH lt_create
    
    MAPPED ct_mapped
    
    FAILED ct_failed
    
    REPORTED ct_reported.

     

    COMMIT syntax

    The COMMIT syntax is used along with the MODIFY statement. As MODIFY statement does not change the data at database level, it is required to call COMMIT after MODIFY to persist the database changes.

    The modify statement set the data to transaction buffer and buffer data gets cleared after the ABAP session is closed. That means we need to trigger save sequence to save the data from the transactional buffer to the database. This trigger is called by executing the COMMIT statement. For save sequence methods you can refer to our previous articles.

     

    Simple syntax-

    COMMIT ENTITIES.

     

    Long syntax-

    COMMIT ENTITIES
    
       [RESPONSE OF rootentityname1
    
    [FAILED ct_failed]
    
     [REPORTED ct_reported]]
    
    [RESPONSE OF rootentityname2
    
    [FAILED ct_failed]
    
    [REPORTED ct_reported]].

    Using long syntax we can call COMMIT for multiple entities by explicitly specifying  RootEntity names. Whereas, the simple syntax COMMIT ENTITIES will also work for multiple entities in the same LUW. Here we need to specify the RootEntity name.