Wednesday, 31 May 2017

How Classify The Classes based on Percentage in SAP HANA

In this blog I am classifying the Student classes based on there percentage. If Student get above 60 percentage then they will get “FIRST CLASS” or If Student get between 60 to 50 percentage then they will get “SECOND CLASS” or If Student get below 50 percentage they will get “THIRD CLASS”.

For Implementing this scenario I took two calculated columns one for calculating Percentage other one for Specifying Class.

Below are the steps to implement “How Classify The Classes based on Percentage in SAP HANA”.

Step 1: Create one Table with the name “STUDENT_DETAILS” in our schema with following structure

All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Insert Below Values into our Table

All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Step 2: Create Calculation view in our package with the name “STUDENT_CLASS”

All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Select STUDENT_DETAILS table in projection and Select the all columns.

All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Create One calculated column for Calculating Percentage.

All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Create another calculated column for calculated for class classification.

All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Use the following logic to classifying the classes.

if(“MARKS_PERCENTAGE”>=60,‘FIRST CLASS’,if(“MARKS_PERCENTAGE”>=50 and “MARKS_PERCENTAGE”<60,‘SECOND CLASS’,if(“MARKS_PERCENTAGE”<50,‘THIRD CLASS’,‘FAIL’)))

Add projection to aggregation and select the calculated columns MARKS_PERCENTAGE and CLASS.

All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Save and Activate the View.

select the data preview.

Output:


All SAP Modules, SAP Tutorials and Materials, SAP HANA Studio, HANA Calculation View, SAP HANA Modeling

Above output we can see the CLASSES Classification in last column.

Tuesday, 30 May 2017

Quick Test Data Generation in SAP BW

During development in BW, I’m sure many have come across the situation where we are lacking of test data for testing especially if it’s the source that provide the test data is a new development as well. To save time while waiting for the actual test data to be generated, there’s a program in SAP BW that can generate random test data directly into the underlying InfoCube(s) that is feeding your report or logic.

Following are 3 simple steps for quick test data generation so that you can test on the functionality (like variables, key figures, formula and etc) of your report while waiting for the actual test date.

Program Name: CUBE_SAMPLE_CREATE


Step 1: Go to SE38 and execute the above program


SAP Guides, SAP Module, SAP Tutorials and Materials, SAP All Certificaions

Step 2: Execute the program with the below info


InfoCube Entry
  • InfoCube Name: Technical name of your InfoCube, if it’s a SPO, remember to enter the technical of the underlying InfoCube and not the SPO Name (for example, SPO: ZABC01, the underlying InfoCube will be ZABC01XX)
  • Number of Data Records to be Generated: Provides the number of Test Data to be generated
  • Fiscal Variant: If you have Fiscal Period to be generated
SAP Guides, SAP Module, SAP Tutorials and Materials, SAP All Certificaions

Input Mode:
  • Generated Values: The program will Immediately generate and display the Test Data
  • Vals from Master Data Table: The program will generate and display the Test Data based on Master Data
  • Read-For-Input ALV: Personally I would recommend this approach as the program will generate the test data based on your preference
    • You can change the value of the table before hitting the save button to generate the test data into the target InfoCube
    • Tip: You can export this structure to excel, manually change all the test data, then copy and paste the values back to the ALV table
SAP Guides, SAP Module, SAP Tutorials and Materials, SAP All Certificaions

SAP Guides, SAP Module, SAP Tutorials and Materials, SAP All Certificaions

SAP Guides, SAP Module, SAP Tutorials and Materials, SAP All Certificaions

Step 3: Check the Target InfoCube


Result

Every time the Test Data Generation is executed, you will see a new request being created at your targeted InfoCube. You can always remove this request after your testing.

SAP Guides, SAP Module, SAP Tutorials and Materials, SAP All Certificaions

Saturday, 20 May 2017

SAP OTC Process: BAPI Quotation Create Extension - Part 1

SAP OTC (Order-to-Cash) process is the core process of SAP Sales and distribution module. SAP OTC process involves various steps. The first process is ‘ENQUIRY’ from the customers, then ‘QUOTATION’, next is the ‘SALES ORDER’ followed by ‘STANDARD ORDER’ , ‘SHIPPING’, ‘DELIVERY’ , ‘PICKING’ etc.

SAP BAPI (Business Application Programming Interfaces) are widely in SAP Environment for creating, updating and deleting business documents along with reading from the backend database as well. BAPIs are the API methods of SAP business object types, and stored in Business Objects Repository (BOR).

This blog discusses Extension for BAPIs which are part of OTC process. This document is part 1 of the SAP OTC Process extensions serious. Part 2 discusses Sales Order extension.

In Current blog , I am discussing Quotation extension scenario for BAPI_QUOTATION_CREATEFROMDATA2. As discussed earlier, QUOTATION is response to customer Inquiry.

Before we move on to the coding side. There are tables and structures, that must extended with the custom fields.

1) The first step is to add custom fields in the VBAP (Sales document Item level) . I am taking date and time fields, as part of the custom data as show in the below screen capture.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

2) The next step is adjusting the following structures :

Adjust the following structures for customer enhancements to table VBAP:
  1. VBAPKOZ
  2. VBAPKOZX
  3. BAPE_VBAP
  4. BAPE_VBAPX
  5. VBAPKOM
  6. VBAPKOMX
SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

Here , I have demonstrated adding custom fields in 3 out of 6 structures. Adjusting all structures are mandatory.

3) After adjusting required structures I move on to the coding part of BAPI API_QUOTATION_CREATEFROMDATA2 for the BAPI extension process.

(a) First we need to declare extension container to hold custom data as show below

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

This container needs to be filled and, then supplied at the ‘extensionin’ table for the BAPI_QUOTATION_CREATEFROMDATA2.

4) Now lets fill up some data using function module ‘BAPISDORDER_GETDETAILEDLIST‘ based on inquiry.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

5) Schedule lines needs to be adjust for example transport planning date, Goods issue date ,scheduling lines date etc as show below.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

6) For updating custom fields and creating quotations, i am using times and dates fields from table ‘AFVV‘ these fields need to be updating along with quotation creation as part of custom fields data. I am reading date and time fields and putting them in the internal table .

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

7) Next step is updating the extension container

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

8) Now we are ready to call the BAPI_QUOTATION_CREATEFROMDATA2 

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

9) I executed the program and check extension container.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

extension container is ready ,

10) Now I have to check if I have the new quotation number in variable lv_new_sales_document_type

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

As you can see in the above screen capture, the BAPI returns the new quotation number indicating the successful execution of BAPI.

11) Finally I check the new quotation number in VBAP TABLE and check if custom fields are updated.

SAP Tutorials and Materials, SAP Certifications, SAP Modules, SAP Guides, SAP Learning, SAP SD

All the Custom fields are updated for the newly created Quotation.

Monday, 24 April 2017

SAP OTC Process: BAPI Sales Order Create Extension - Part 2

In Part 1 of SAP OTC Process, I discussed a demonstration for Creating Quotations with Extensions. In this part I am going to create Sales orders with customer extensions.

The process which i used is the same as in the Part 1, however there are certain considerations and customization which need to be considered for creating sales order based on customer requirements. In a usual process Sales Orders are created in response to a quotation.

Step 1:

Same structures are adjusted for the custom fields as i did in Part 1 and they are:
  • VBAPKOZ
  • VBAPKOZX
  • BAPE_VBAP
  • BAPE_VBAPX
  • VBAPKOM
  • VBAPKOMX
SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 2:

After adding custom fields , next we need to fill up the required tables using the function module BAPISDORDER_GETDETAILEDLIST/

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 3: 

Next is again filling up the extension Container as discussed previously.

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 4:

Now the function module Call for creating the sales order is will be done:

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Step 5: 

Check if we get values in lv_new_sales_document_type and in ext_cont for the custom fields.

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

The function module has returned new Sales Order number as mentioned above, and ext container is filled with the custom field values .

STEP 6: 

Now we check the VBAP table with new created sales order number to check if custom fields are updated.

SD (Sales and Distribution), SAP All Module, Tutorial and Certification, SAP Live, SAP Material

Saturday, 8 April 2017

SAP UI5 Table row color change based on status

I am going to write about an interesting topic in SAP UI5. Changing the entire row color of a sap.m.Table based on Status. Generally we keep a text in Status field and change the color of the text according to the Status. But, nowadays customers are asking about this requirement for better user experience.

SAPUI5, All SAP Modules, SAP Certifications

I am going describe you step by step to achieve this goal.

Step 1: Mock oData to display on the table

I am defining a method where I had created a mock data and take in a Name-model.

fnGetLeaveHistoryData:function(){
var oData={
LeaveHistory : [ {
"leaveFrom" : "8 Oct, 2016",
"leaveTo" : "11 Oct, 2016",
"leaveSubject" : "Casual Leave",
"Remarks" : "Casual Leave taken",
"status":"Pending"
},
{
"leaveFrom" : "1 Dec, 2016",
"leaveTo" : "2 Apr, 2016",
"leaveSubject" : "Sick Leave",
"Remarks" : "Sick Leave taken",
"status":"Approved"
},
{
"leaveFrom" : "12 Feb, 2017",
"leaveTo" : "14 Feb, 2017",
"leaveSubject" : "Casual Leave",
"Remarks" : "Casual Leave taken",
"status":"Rejected"
},
{
"leaveFrom" : "7 March, 2017",
"leaveTo" : "10 March, 2017",
"leaveSubject" : "LWP Leave",
"Remarks" : "LWP Leave taken",
"status":"Approved"
},
{
"leaveFrom" : "16 Apr, 2017",
"leaveTo" : "18 Apr, 2017",
"leaveSubject" : "Annual Leave",
"Remarks" : "Annual Leave taken",
"status":"Pending"
}]
};
var oLeaveHistoryJsonModel = new JSONModel(oData);
this.getView().setModel(oLeaveHistoryJsonModel,"LeaveModel");
},

Now the above data I am going to bind with sap.m.Table. I am gone a change the color of the row based on the status. If status is Pending, row color should be Orange, if Rejected, row color should be Red, & if Approved, row color should be Green.

Step 2: sap.m.Table data binding

<Table id="LeaveDetailsTable" showSeparators="All" class="sapUiSizeCompact"     items="path:'LeaveModel>/LeaveHistory'}"> <columns>
 <Column width="7em" minScreenWidth="Tablet" demandPopin="true" hAlign="Center"  >
   <Text text="Leave From" />
 </Column>
 <Column width="7em" minScreenWidth="Tablet" demandPopin="true" hAlign="Center">
  <Text text="Leave Up To" />
 </Column>
 <Column width="8em" minScreenWidth="Tablet" demandPopin="true" hAlign="Center">
  <Text text="Leave Type"/>   
 </Column>
 <Column width="12em" minScreenWidth="Tablet" demandPopin="true" hAlign="Center">
  <Text text="Description"/>
 </Column>
 <Column width="7em" minScreenWidth="Tablet" demandPopin="true" hAlign="Center">
  <Text text="Status"/>
 </Column>
</columns>
<ColumnListItem id="clm" >
   <customData>
     <core:CustomData key="mydata" value="{LeaveModel>status}" writeToDom="true"></core:CustomData>
   </customData>
   <cells >
<Text text="{LeaveModel>leaveFrom}"  />
<Text text="{LeaveModel>leaveTo}" />
<Text text="{LeaveModel>leaveSubject}"/>
<Text text="{LeaveModel>Remarks}" />
<Text text="{LeaveModel>status}"/>
  </cells>
</ColumnListItem>
</Table>

Here i have done the data binding. Inside ColumnListItem I had taken a Custom Data and bind the Status as value. So, on run time for each row one customdata will generate. I am attaching the screen shot bellow. Inside data-mydata  will have the Status of that particular row.

SAPUI5, All SAP Modules, SAP Certifications

Then we need to write the css according to that to assign color.

Step 3: Need to add CSS to put color according to the status

tr[data-mydata="Pending"]{
  backgr
ound:   #ff9933!important;
}
tr[data-mydata="Rejected"]{
  background: #ff3333!important;
}

tr[data-mydata="Approved"]{
  background:  #33cc33!important;
}

Now all set.. here is the output:

SAPUI5, All SAP Modules, SAP Certifications

Thursday, 16 February 2017

SRM UI5 Add-on : SC Creation Important classes to remember

I am going to share some helpful information for SRM UI5 Add-on developers ( with ABAP knowledge ) about important classes that you need to remember while debugging any issues related to SC creation and also how these classes communicate with each other and their purpose in overcall SC creation.

SAP Supplier Relationship Management, SAPUI5, All SAP Modules

There are five important class involved.

/SRMNXP/CL_BO_DA_SHOPPING_CART:  this class is runtime class for SRMSHOPPING_CART OData service (responsible for entity types ShoppingcartItemCollection and ShoppingcarCollection) that is responsible for SC creation. So everything starts and end in this class. Data entered on the UI5 screen is passed to this class and also data that is to be displayed finally in the screen is passed back to this class. Inside most of the methods of the class the actual work is delegated to /SRMNXP/CL_TEMPORARY_CART and /SRMNXP/CL_INTL_PDO_SC.

/SRMNXP/CL_BO_DA_PDO_CART:  This class has same purpose as above class but is responsible for entity types SRMShoppingcartItemCollection and SRMShoppingcarCollection. This class comes into picture, if you are adding item to a SC which was already saved in database or when you click on item details or any other tab in the item details.

/SRMNXP/CL_TEMPORARY_CART:  This class manages the temporary cart until it is completely ordered or SAVE&CLOSE button is clicked or entire minicart is deleted. This class communicates with class /SRMNXP/CL_BO_DA_SHOPPING_CART and /SRMNXP/CL_INTL_PDO_SC.

/SRMNXP/CL_INTL_PDO_SC: This class acts as an intermediate layer (I assume that is the reason for INTL in its name) between /SRMNXP/CL_TEMPORARY_CART and /SAPSRM/CL_PDO_BO_SC_ADV.

/SAPSRM/CL_PDO_BO_SC_ADV:  This is our old PDO friend that is responsible for creation of SC in SRM (this class existed since golden era of webdynpro in SRM 7.0).

SAP Supplier Relationship Management, SAPUI5, All SAP Modules

Saturday, 11 February 2017

MRP and Safety Stock in SAP PP

The SAP ERP system offers two types of safety stocks: absolute safety stock and safety days’ supply. The absolute safety stock enables the system to subtract it from material availability calculations (net requirements calculations). The safety stock must always be available to cover for unforeseen material shortages or unexpected high demand.

For days’ supply/safety time, the system plans the goods receipt in advance by the period specified as safety time. Thus, planned days’ supply of the stock, in fact, corresponds to the number of days specified as safety time. The system shifts backs the date of the receipts by the number of working days and also takes the factory calendar into account.

You make the relevant entries in the MRP 2 view of the material master. The system refers to the planning of a safety days’ supply as safety time. To consider the safety time, you need to set the Safety time ind. to “1” (for independent requirements) or “2” (for all requirements), and then also give the Safety time/act.cov. in days. Further, you can define deviations from the constant safety time using a safety time period profile (STime period profile field).

MAN Production Planning (PP), SAP PP, All SAP Modules

Let’s take a look at how the safety stock availability can be used in net requirements calculations and also the selection method that the system uses for receipts.

1. Safety Stock Availability


To avoid the unnecessary creation of planned orders for a smaller quantity, which can otherwise be covered by the safety stock, you can define the percentage (share) of safety stock that the system can use in such business scenarios. For example, during the MRP run, the system assesses a shortage of 2 PC of a material. You have, however, maintained a safety stock of 40 PC for this material, which the system doesn’t consider in the MRP run. If you define that a 10% safety stock can be used to account for smaller shortages, which for this example means that 4 PC come from safety stock, then the system can cater to this small requirement or shortage of 2 PC from the 4 PC available from safety stock and no longer creates a procurement proposal.

To define the safety stock parameters, use configuration (Transaction SPRO) menu path, Logistics > Production > Material Requirements Planning > Planning > MRP Calculation > Stocks > Define Safety Stock Availability. For this example, the system can consider 10% of the safety stock for Plnt 3000 and MRP group 0010 for net requirements calculation (see below). You eventually assign the MRP group in the MRP 1 view of the material master.

MAN Production Planning (PP), SAP PP, All SAP Modules

2. Master Data Selection


For material that’s produced in-house, you also create a BOM and routing (or master recipe). There might be several alternatives available for a BOM or a routing, so you can control the selection of alternatives. This ensures that the system is able to assign the relevant BOM and routing to the created planned orders, and it enables you to perform functions such as availability checks, and so on.

With the right control in place, the system automatically assigns the correct selection or alternate in the planned orders created from the planning run. This is accessed and managed in the MRP 4 view of the material master (Transaction MM02) as shown below.

MAN Production Planning (PP), SAP PP, All SAP Modules