Friday, June 19, 2015

SP ABAP : Performance Tuning

What tools can be used to help with performance tuning?

  1. ST05 : this is used to trace performance of the program. it trace SQL performance and mainly used to trace the performance of the select statements used in the program.
  2. SAT : used to measure the application performance. it analyse the runtime performance of the program.
  3. ST12 : this is combination of ST05 and SAT transactions.
  4. EPC (Tcode SLIN) and CI (Tcode SCI ) tools.

What are the steps to optimize the ABAP Code?

http://wiki.scn.sap.com/wiki/display/ABAP/ABAP+Performance+and+Tuning
  1. DATABASE
    1. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.  Very important !!
    2. Design your Query to Use as much index fields as possible in your WHERE statement
    3. Use INNER (or OUTER under some circumstances) JOIN in your SELECT statement to retrieve the matching records at one shot
    4. Avoid using nested SELECT statement and SELECT within LOOPs, better use JOINs or FOR ALL ENTRIES. Use FOR ALL ENTRIES when  the internal table is already there or the end of some processing. Try JOINs if the SELECT are right behind each other
    5. Avoid using INTO CORRESPONDING FIELDS OF TABLE during buffered access. Otherwise use the most appropriate for the program.
    6. Avoid using SELECT * and Select only the required fields from the table.
    7. Avoid using ORDER BY in SELECT statements if it differs from used index  (instead, sort the resulting internal table), because this may add additional work to the database system which is unique, while there may be many ABAP servers
    8. INDEX: Creation of Index for improving performance should not be taken without thought. Index speeds up the performance but at the same time adds two overheads namely; memory and insert/append performance. When INDEX is created, memory is used up for storing the index and index sizes can be quite big on large transaction tables! When inserting new entry in the table, all the index's are updated. More index more time. More the amount of data, bigger the indices, larger the time for updating all the indices
    9. Avoid Executing an identical Select (same SELECT, same parameter) multiple times in the program. Buffer in your abap code.
    10. Avoid using join statements if adequate standard views exist no performance impact
  2. TABLE BUFFER:
    1. Defining a table as buffered (SE11) can help in improving the performance but this has to be used with caution. Buffering of tables leads to data being read from the buffer rather than from table. Buffer sync with table happens periodically, only if something changes which is happen rarely. If this table is a transaction table chances are that the data is changing for a particular selection criteria, therefore application tables are usually not suited for table bufferung. Using table buffering in such cases is not recommended. Use Table Buffering for configuration data and sometimes for Master Data.. 
    2. Avoid using complex Selects on buffered tables-, because SAP may not be able to interpret this request, and may transmit the request to the database- The code inspector tells which commands bypass the buffer
  3. Internal tables
    1. Use HASHED tables where-ever possible. Otherwise SORTED tables. STANDARD tables should be the last choice.
    2. Use assign instead of into in LOOPs for table types with large work areas, if the data is being modified.
    3. When in doubt call transaction SE30/SAT and check your code.
    4. If you must use a STANDARD table and you are using a READ, sort the table appropriately and use the addition BINARY SEARCH to speed up the search. 

  4. http://wiki.scn.sap.com/wiki/display/ABAP/ABAP+Performance+and+Tuning
  5. Use SLIN and code inspector tools.











Thursday, June 18, 2015

SAP ABAP : SD Brief

SD Flow:

INQUIRY->QUOTATION->SALE ORDER->Delivery->SHIPPING->BILLING-

  1. Customer's Inquiry 
  2. Customer request a quotation - created referring inquiry 
  3. Sales Order creation - created referring quotation.(  when customer placed an order )
  4. Shipping - Ship the goods to customer
  5. delivery
  6. Billing/Invoicing
  7. Post goods Issue
Transaction Codes:
  1. Inquiry : VA11/VA12/VA13
  2. Quotation : VA21/VA22/VA23
  3. Sales Order : VA01/VA02/VA03 - VBAP VBAK
  4. Delivery : VL01N/VL02N/Vl03N - LIKP LIPS
  5. Shippment :  VT01/VT02/VT03 - VTTK VTTP
  6. Billing  : VF01/VF02/VF03 : VBRK VBRP
  7. Invoice : VF21 : VBRK VBRP
SD Master Data : 
  1. Condition Master data 
    • Pricing data
    • Rebate data
    • output master data
  2. Customer master data XO01/XO02/XO03
  3. Material master data  
  4. CUST/MAT Info record  VD51
    •  mapping of customer name of material to sap name of material.
  5. Output master master data (Optional) 

========================================================================

Below is the standard sales and distribution(SD) document flow in SAP .
VBFA is the document flow table

INQUIRY

VA11 is the T-code for inquiry and related tables are VBAK, VBAP.Once inquiry is done customer requests quotation.

QUOTATION

T-code for quotation in VA21, tables are VBAK, VBAP.After quotation flow goes for purchase order.

PURCHASE ORDER

Purchase order t-code is ME21N, related tables are EKKO, EKPO.Based on purchase order sales order will be created.

SALES ORDER

Sales order t-code is VA01, related tables are VBAK, VBAP. Once sales order is created, delivery will be done.

DELIVERY

T-code for delivery order is VL01N, tables are LIKP, LIPS. Next the goods should be dlivered through shipping

SHIPPING

Shipping t-code is VT01, related tables are VTTK, VTTP.Once goods are shipped, go for billing.

BILLING

Billing t-code is VF01, tables are VBRK,VBRP. Every bill has invoice...next provide invoice.

INVOICE

Invoice t-code is VF21, related tables are VBRK, VBRP.Invoice end of sales flow.
=================================================================================

Enhancement Scenario:
  • Addition of tab , Item Level : VF01 SD Invoice
    • http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=235803375
    • Step 1 : Got to SE11 table VBRP
    • Step 2 : Add a Z structure to this table with one field Zadd for example.
    • Step 3 : Create a Z program and write code to that program.
    • Step 4 : add layout in the screen of this Z program. use structure field.
    • Step 5 : Go to SE80 and give th eprogram name of the VF01 Transaction. (SAPMV60A)
    • Step 6 : Find enhancement point and implement it with following logic:
      • Implement CUST_ITEM_ACTIVATE 
=================================================================================
VOFM : 
  • VOFM routines are ABAP code written in Forms.
  • VOFM provides the user with the benefit of choosing from one of the standard delivered by SAP or writing their own.
  • VOFM basically is for the implementation team and not for the end user.
  • Copying Requirements : This is provided by SAP to support SD and logistics requirements.
  • In each area of VOFM, SAP delivers routines using the name space from 1 to 599.
  • SAP customers can create their own VOFM routines using the name space from 600 to 999.
  • New VOFM routines created at a customer site are not overwritten by a software upgrade.
  •  http://www.newtosap.info/2014/01/vofm-routinesa-short-guide.html
  • VOFM routines can be used to propose/alter the business process and it can be triggered for particular condition. Ex: Pricing condition ZCIL which will trigger the routine whenever it’s used.
  • There are various categories in VOFM like Data Transfer, Requirements, Formulae’s etc. Depending upon the category, the routine or exit will be called. Ex: any routine done in Formula’s category will be triggered during the computation of formula of a particular pricing condition. One has to choose the correct category and create a new routine.
  • V/08 for assigning routine number to the required pricing procedure.
  • http://www.saptechsolutions.com/pdf/InsideVOFM.pdf
=====================================================================


Condition Record: 
  • The following new transactions are offered:
    • Create conditions (transaction VK31)
    • Create conditions with reference (transaction VK34)
    • Change conditions (VK32)
    • Display conditions (VK33)
========================================================================Enterprise structure in SD : 
  1. Client  - TATA
  2. Company Code - TCS  
  3. Sales Area :
    • Sales Organisation (Delhi) 
    • Distribution channel (online, retail store)
    • Division 
  4. Plant
  5. Shipping Point 
  6. Loading Point 

Element of SD Org Structure:

    • Sales Organization
    • Distribution Channel
    • Division
    • Sales Office
    • Sales Group
  • Internal structure: 
    • Sales Office
    • Sales Group
    • Sales Person 
========================================================================

Shipment Process in SAP SD : ( http://scn.sap.com/docs/DOC-45032 )

1. Creation of Sales Order - VA01
2. Creation of Outbound Delivery - VL01N

Shipment process will start form here
 3. Creation of Condition Record for Forwarding Agent, : VK11
  • Give condition type (we can create them by copy standard)
  • Give the service agent and Tf zone point of dep.
  • give the Amount unit and save it .
Service Agent used to calculate net amount in the Shipment cost doc.

 4. Creation of Shipment Document : VT01N
(Note- Shipment document we can create with reference to outbound delivery before PGI or after PGI)
  • A shipment document will be created against one or more delivery.
 5. Creation of Shipment Cost Document VI01
   A) PO and service entry sheet will be created automatically by the system.
 6. Enter Vendor’s Invoice (Invoice receipt and verification). MIRO
======================================================================== 






Saturday, June 13, 2015

SAP ABAP MACRO

Syntax : 

define Macro1.
....&1... &2...
end-of-definition.

Only used in local program.
Mainly abbreviation for some line of codes in a program.
we cannot debug so we should avoid using macros.

Friday, June 5, 2015

SAP ABAP : Control break events

These events are used inside the loops in ABAP program. There are 5 such events available in ABAP:

  1. AT FIRST - ENDAT
    • Will trigger at the first run of the loop.
  2. AT NEW - ENDAT
    • Will Trigger when new value for the applied field.
  3. AT END OF - ENDAT
    • will trigger for the last occurrence of the same value in the applied field.
  4. AT LAST - ENDAT
    • Will Trigger withe the last run of the loop,
  5. ON CHANGE OF
    • Trigger every time change in the value of applied filed. can also be used outside loop.
We must use a temporary workarea to display values in the 3 (2,3,5) control events. otherwise we get values like ***.


SAP ABAP : ENHANCEMENT

https://sites.google.com/site/programminginterviewquestions/enhancements

http://sapignite.com/sap-abap-interview-questions-and-answers/


1. What are the different ways in which you can make changes to SAP standard software ?

Customizing

Enhancements to the SAP Standard

Modifications to the SAP Standard

Customer Development

1. Source code enhancements (plug-ins)
2. Function group enhancements
3. Class Enhancements
4. Kernel-BADI enhancements

New BADI/KERNEL BADI : GET BADI/CALL BADI
Classic BADi : CAll cl_exithandller->get_instance

===========================================================

Enhancement :

    • Whenever we need to enhance any standard SAP delivered functionality by introducing new code. there are several ways to achieve this:
      • Code Modification : This required access key. not recommended. 



      • User Exits : there are some routines in the standard code start with USEREXIT_*. These subroutines are delivered by SAP but you can add code to them. this is manageable because they are in a single include.
        • To find user exits in SD :
          • Got to SE80
          • Select package VMOD
          • we have all the includes for user exits
        • In user Exit MV45AFZ1 we have subroutine userexit_save_document_prepare this can be used to add checks before a document saved. (VL02 ).
        • In user exit MV45AFZZ (sales order exit ), USEREXIT_MOVE_FIELD_TO_VBKD
      • Customer Exits : Function module not delivered by SAP. we can implement our code.  customer exits are nothing but a include in customer name space will be provided in the function module which starts with CALL CUSTOMER.
        • SAP creates customer exits for special programs, screens, menus within standard applications.
        • Type of customer exit
          • Screen exit : Call Customer Sub ScR
          • function module exit : Call Customer Function
          • menu exit : +US00 
      • BADI (Business add ins):
        • are based on oops concept.
        • multiple implementation.
        • Filter Badi.
  • Enhancement Point and enhancement section
      • Enhancement point does not offer any default code implementation whereas Section offers a default logic between ENHANCEMENT SECTION and END ENHANCEMENT SECTION. whenever you implement enhancement section standard automatically insert this logic to your code, you may keep it or may not.
      • ENHANCEMENT-POINT is the empty placeholder for the code where as ENHANCEMENT-SECTION is the placeholder with default code.
      • Enhancement point are provided on some specific place whereas the enhancement section is there to replace some special lines of code.
  • Implicit Enhancement Vs Explicit Enhancement
      • Implicit Enhancement are provided by SAP at the beginning and End of code blocks like subroutines, type definitions etc.
      • Explicit enhancements you can implement anywhere in the code.
      • Here is both of the options mean:
        • Declaration – When you choose this type, the implementation would be created and treated as Static implementation. Means, it would be always available in all the clients.
        • Code– When you choose this option, the implementation would be Dynamic implementation. It would be only called based on switch’s status if the switch is assigned.
===========================================================

Classic BADI : ME_PROCESS_PO_CUST /DOCUMENT_AUTH02
New BADI : DOCUMENT_STATUS02 / DOCUMENT_STATUS





SAP ABAP Web Services

Internal Session - call transaction / call screen / call dialog - export /import - ABAP Memory
External Session - new session within SAP - SPA?GPA - SAP Memory


SOAP - Simple Object Access Protocol
XML - eXtensible mark up language
WSDL - Web Service Definition Language
UDDI - Universal Description , Discovery and Integration 


What is Web Service ?

  • The web service is a system of communication using SOAP protocol over the web.
  • Web service is based on :
    • SOAP protocol to exchange data
    • WSDL to declare description
    • UDDI to reference the service 
WS Provider:
  • This is a service provided by the SAP to the outside world.
Security level in the WEB service configuration in SAP ABAP
  • This level of security is a incident in SOAMANAGER configuration. the level determine the minimum authentication required for a web service.
    • High - HTTPS with heavy authentication 
    • Medium - Basic authentication (user/pwd) with SSL (SSL is a technique for encryption)
    • Low - Basic authentication (user/pwd) without SSL
    • No - No Authentication is required
Customize the Web Service
  • Go to SOAMANAGER and create binding for the web service.
  • generate WSDL for the binding.
  • then we can use binding URL for the use of this web service.
  • Other service can use this WSDL to access this provider web service.
WS Consumer:
  • Create Consumer from SE80.
  • Create Port using SOAMANAGER
  • Execute consumer from SE80