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.