SAP ABAP Training By DILBAG SINGH Send Adobe Form as Email Attachment 1 What is ERP ? ERP Enterprises Resource Planning. Organization Man Machine Material Method Money Optimum utilization of Recourses. • ERP software helps to integrate various business functions and processes, allowing for more efficient and effective management and utilization of resources. • It provides a centralized database that can be accessed by different departments, enabling them to share information and collaborate on tasks. • ERP software also provides real-time data analysis and reporting, which helps managers make better decisions. • • • • • • • • SAP ERP Oracle ERP Microsoft Dynamics 365 Infor ERP NetSuite ERP Epicor ERP JD Edwards EnterpriseOne Acumatica ERP 2 What is SAP ? SAP System Application Product • SAP ERP is a business software solution developed by SAP SE, a leading provider of enterprise software. • SAP ERP is a comprehensive and integrated solution that allows businesses to manage and streamline their key business processes, including finance, human resources, procurement, logistics, manufacturing, and other areas. • SAP ERP provides a centralized platform for managing business processes and data across an organization, enabling businesses to standardize their processes and gain better visibility and control over their operations. • SAP ERP is designed to be highly scalable and customizable, allowing businesses to tailor the software to their specific needs. 3 WHY SAP ? • Industry-specific functionality: SAP ERP offers industry-specific functionality that enables organizations to manage their business operations more efficiently. SAP ERP is available in different versions that are designed to meet the needs of specific industries such as manufacturing, retail, healthcare, and financial services. • Scalability: SAP ERP is highly scalable and can be customized to meet the specific needs of an organization. It can handle the needs of small and medium-sized businesses as well as large enterprises. • Integration: SAP ERP is designed to integrate with other software and systems that an organization may use, such as customer relationship management (CRM), supply chain management (SCM), and business intelligence (BI) tools. • Analytics: SAP ERP includes powerful analytics and reporting tools that enable organizations to gain insights into their business operations and make data-driven decisions. • Mobile support: SAP ERP supports mobile devices, allowing employees to access critical business information from anywhere, at any time. • User-friendly interface: SAP ERP has a user-friendly interface that is easy to navigate and use, which makes it easier for employees to learn and use the system. 4 What is ABAP ? TECHNICAL • ABAP (Advanced Business Application Programming) is a high-level programming language developed by SAP for building business applications on top of its ERP system. • ABAP is used to develop and modify SAP applications and is the primary language used for customization and extension of SAP systems. ABAP MM & SD SAP FUNCTIONAL • All the Functional Modules are developed using ABAP Language. PP, PM & QM HCM & FICO ADMIN Administration 5 SAP Evolution 6 R/3 Architecture Presentation Layer: The presentation layer is responsible for providing a user interface to the SAP system. This includes the various screens, forms, and reports that are used to interact with the system. The presentation layer allows users to interact with the SAP system by entering data, viewing reports, and executing transactions. Application Layer: The application layer is responsible for performing the business logic, processing the data and Updating the data back to the database layer. Database Layer: The database layer is responsible for storing and managing the data used by the SAP system. This includes data related to customers, vendors, inventory, financial transactions, and other business-related data. 7 ABAP consultants Responsibilities Before-Development: Requirement Gathering: Solution design: Estimation and planning: During Development : Programming: Integration: Testing: Documentation: After Development : Deployment: Maintenance and support: Training: Enhancement and development: 8 RICEF OBJECTS These are the five types of objects commonly used in SAP ABAP programming to customize and extend the functionality of SAP systems. R - Reports • Reports are used to extract and display data from SAP systems in a customized format. Data can be retrieved using Select Statements.. Eg. Classic Reports & ALV Reports. I - Interface • Interfaces are used to connect SAP systems with other systems or applications. Interfaces can be built using various technologies such as IDocs, BAPIs, and RFCs. C - conversions • Conversions are used to convert data from one format to another. For example, data may need to be converted from a legacy system format to a format that can be used in SAP systems. Eg. BDC & LSMW. E- Enhancements • Enhancements are used to add new functionality to existing SAP systems. Enhancements can be implemented using various techniques such as user exits, BAdIs, and Enhancement spots. F - Forms • Forms are used to generate customized documents such as invoices, purchase orders, and shipping documents. Forms can be generated using Scripts or using the SAP Smart Forms or SAP Interactive Forms by Adobe tools. 9 Real time system landscape Development System: • All Business Objects Development. • Enhancements. • Testing By ABAP Consultant. Quality System: • Testing of Objects with Huge amount of data (Kind of Real Data). • Need to Make Sure the objects are stable and bug free. Production System: • Objects will be accessed by End User with Real Business data. • Any Downtime or bug can have the impact on the Business. 10 Integer vs Numeric • The "INTEGER" data type is used to represent whole numbers that do not have a decimal component. • It can be used to represent values from -2,147,483,648 to 2,147,483,647. 5 Standard Rules to follow in CORE ABAP Every statement will end with dot/period ( . ). ABAP statement and keywords are not case sensitive. e.g. SELECT , select, SeLeCT. ABAP is space sensitive. e.g. A=B-C. (invalid) A = B – C. (valid) Strings will be enclosed in single quote only. E.g. ‘HELLO ROHIT SINGH’ Star symbol ( * ) (ctrl + < or ctrl + >) or double quote ( “ ) will be used for commenting. 6 ABAP Statements Operation C C++ ABAP OUTPUT Printf Cout Write INPUT Scanf Cin Parameters CONSTANTS Const Const Constants VARIABLE DECLARATION Int A; float B; char C; Int A; float B; char C; Data A type i. Data B type f. Data C type c. 7 ABAP System Fields System Field Purpose SY-DATUM For server date SY-UZEIT Current Time SY-REPID Current Program Name SY-UNAME Logged in user Name SY-PAGNO Current Page no 8 Variables Operation C C++ ABAP OUTPUT Printf Cout Write INPUT Scanf Cin Parameters CONSTANTS Const Const Constants VARIABLE DECLARATION Int A; float B; char C; Int A; float B; char C; Data A type i. Data B type f. Data C type c. Data Keyword for declaring the variable Type :- to specify which type of data we want to store Data A type i A = any variable name we can propose here Type of data:I for integer f for float c for character 9 Requirement for Parameters ABAP Report ---------------------------- Selection Screen to read input from user in run-time First No Second No List processing Screen Sum Result is : 10 Conditional Statements ABAP Report ---------------------------- Selection Screen to read input from user in run-time First No Second No Operation 1/2/3/4 1 for Sum 2 for Subtraction 3 for multiplication 4 for division List processing Screen Result is : 11 Looping Statements A loop statement allows us to execute a statement or group of statements multiple times. e.g. While-endwhile, do-enddo, loop-endloop. Conditional loops using the WHILE statement. Unconditional loops using the DO statement. 12 Looping Statements ABAP Report ---------------------------- Selection Screen to read input from user in run-time Enter any Number 8 List processing Screen 8 8 8 8 8 8 8 8 8 8 * 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 = = = = = = = = = = 8 16 24 32 40 48 56 64 72 80 12 Code Inspector, ATC, EPC Code Inspector is a static analysis tool that checks ABAP programs for potential errors and inconsistencies. It can be used to identify potential problems before they cause errors in production. It analyzes the code without executing it. ABAP Test Cockpit is a dynamic analysis tool that executes ABAP programs and checks their results. It can be used to verify that programs are working as expected and to identify potential performance problems. Extended Program Check is a set of checks that can be run on ABAP programs to identify potential security vulnerabilities. Feature Code Inspector ABAP Test Cockpit Extended Program Check Type of analysis Static Dynamic Static Purpose Find potential errors and inconsistencies Verify that programs are working as expected and identify potential performance problems Identify potential security vulnerabilities When to use Before deploying a program to During development and testing Before deploying a program to 12 Parallel Cursor ABAP Report Selection Screen to Read Sales doc No Range ---------------------------------------------- Sales doc to Requirement 1 Write code in Traditional Approach. Requirement 2 Write code using Parallel Cursor. List processing Screen Kunnr VBELN NETWR 13 Radio Button ABAP Report ---------------------------- Selection Screen to read input from user in run-time List processing Screen First No Second No Sum Subtraction Product Division None of the above Appropriate result :- 14 Check Boxes ABAP Report ---------------------------- Selection Screen to read input from user in run-time List processing Screen First No Second No √ Sum Subtraction √ Product Division Appropriate result :- 15 Selection screen blocks & push buttons ABAP Report ---------------------------- Selection Screen with blocks and push buttons First No Second No Enter options 1/2/3/4 Result Exit 16 Selection Screen Events ABAP Report Selection screen Initialization At selectionscreen output Result EXIT At selectionscreen Once user click on any push button, Sap triggers at selection-screen event, and capture the assigned function code of that clicked push button in the system field sy-ucomm 17 Tab Buttons on Selection Screen ABAP Report Selection Screen (1000) with Tab Buttons TAB1 TAB2 Welcome to SAP Core ABAP Training Subscreen 1 (100) Subscreen 2 (200) 18 At Selection-screen ON ABAP Report Selection Screen First Number Second Number Addition On pressing the enter, we need to display the addition of above 2 number in 3rd field 19 Submit Statement Source Program Target Program 2 Statement 1 Submit target program Statement 1 Statement 2 Control goes to TP Statement 2 LPS for Source Program 1 Statement 1 3 LPS for Target Program Statement 1 Statement 2 20 Submit Statement 1st Program 1 Read 2 input values from user & export the data. 2nd Program 2 Import the data from1st program And And 4 import the calculated data from 2nd program and display 3 Do the calculation & export the data. 21 Submit Statement ABAP memory E2 E1 R1 1st Program 1 Read 2 input values from user & export the data. 2nd Program 2 Import the data from1st program And And 4 import the calculated data from 2nd program and display 3 Do the calculation & export the data. 22 Condense, concatenate, split Statements Condense: The Condense statement is used to remove the leading and trailing spaces from a string. The condensed string is then stored in the same field or variable. This statement is useful for removing any unnecessary spaces in a string to make it easier to process or display. Concatenate: The Concatenate statement is used to combine two or more strings into a single string. The concatenated string can be stored in a new variable or in one of the existing variables. Split: The Split statement is used to separate a string into smaller substrings based on a separator character. The substrings are stored in an internal table or individual variables. This statement is useful when a large string needs to be processed in smaller pieces. STRLEN statement is used to determine the length of a string. It returns the number of characters in a string. 23 FIND, REPLACE & SHIFT FIND Statement: The FIND statement in SAP ABAP is used to find the position of a substring within a larger string. REPLACE Statement: The REPLACE statement in SAP ABAP is used to replace all occurrences of a substring in a larger string with a different substring. SHIFT Statement: The SHIFT statement in SAP ABAP is used to shift a part of a string a specified number of characters to the left or right or circular. 1 Scripts • Scripts are used for Designing the Template of Business Document. And these are client Dependent. • Tools used for it Form Painter Tool SE71. • Scripts supports only the Static Form, Runtime Interaction is not possible. • Step to be followed in Form Painter Tool SE71. I. Create Paragraph Format and Associate FONT Settings.. II. Associate the Static Text as part of main window. III. Set the Default Paragraph. IV. Activate the SAP Scripts. • In the Executable Program (Driver Program), we need to call 3 FMs. (open_form, write_form, close_form). • System symbols Stored in TTXSY DB Table. • Standard Symbols Stored in TTDTG DB Table. • Program Symbols these are user defined Symbols passed from Driver Program. • Text Symbols Represented by Control Commands. 2 Scripts Customer Code : Customer Name : Customer Add : Customer City: Telephone no : LOGO Sales orders of the customer (table format) Prepared by Page 01 of 03 Approved By 3 Smart Forms • Smart Forms are used for Designing the Template of Business Document. • Smart Forms are client In-Dependent. • T-Code SMARTFORMS • On the Creation of Smart form, SAP itself generates a Function Module. • For calling the Smart Form, we need to call the auto generated FM. 4 Smart Forms • While calling the smart form function module, first we need to receive the content of the smart form in the OTF form. For this, set the field ‘GETOTF’ as ‘X’ as part of Importing parameters control parameters and receive the OTF format by considering the export parameter ‘JOB_OUTPUT_INFO’. • Prepare OTF internal table and convert the OTF format to PDF format by calling the function module ‘CONVERT_OTF’. • Download the PDF format to the local file using the function module ‘GUI_DOWNLOAD’ or to the application server by opening the file in the output/appending mode. 5 Scripts vs Smart Forms Scripts Smart Forms 1. T-code is SE71 T-code is SMARTFORMS. 2. Scripts are Client Dependent. 2. Smart Forms are client Independent. 3. Main Window is compulsory to have. 3. Main Window is not compulsory to have. 4. No FM generated. 4. SAP generates a FM on creation of Smart Form. 5. Scripts allows Black & white Text colors only. 5. Smart Forms allows colored texts also. Adobe Forms 6 • • • • Adobe Forms are used for Designing the Template of Business Document. It support static & Interactive Forms. T-code SFP Software Required ALD (Adobe LiveCycle Designer), ADS (Adobe Document Service). Procedure • Create the Adobe Interface. • Same SFP t-code will be used for created the ADOBE Interface. • As part for ADOBE interface, we can declare the Parameters, Global variables & we can write the select statements to retrieve the data from Database. • Based on the Adobe Interface, we will create the Adobe Form. • As part of Adobe form, we can map the Parameters, global variables & Adobe System Fields from Adobe Interface Context to Adobe Form Context. • We will design the Layout of the Adobe Form. • On the activation of Adobe Form, one FM will be Generated by SAP itself like Smartforms. • To call a Adobe Form from Driver Program, we need to call a FM FP_JOB_OPEN • To get the Generated FM DYNAMICALLY , we need to call another FM FP_FUNCTION_MODULE_NAME • Then we need to call the FM considering the Parameters of Adobe Form. • In last we need to close the Job by calling a FM FP_JOB_CLOSE. 7 Adobe Interface 3 Types of Adobe Interface. • ABAP Dictionary Based Interface for Static Adobe Forms. • Smartform Compatible Interface used when smartform is migrated to adobe form. • Xml schema based Interface for Interactive Adobe Forms. 8 Adobe Form Requirement Selection Screen Customer no Country City Customer no KUNNR Customer Master Data Sales Doc Header Data None VBELN ERDAT AUART NETWR 9 Adobe Form Requirement SALES DOCUMENT DETAILS Selection Screen Sales Doc No ERDAT ERNAM Sales Doc No Sales Doc Item Data POSNR MATNR MATKL NETWR 10 Send Adobe Form as Email Attachment Steps to be Followed 1 Get the Adobe Form PDF content by calling generated FM – Exporting parameter /1BCDWP/FORMOUTPUT 2 Convert it to Binary format from RAWSTRING Format by calling SCMS_XSTRING_TO_BINARY FM 3 Create Send Request. by calling CREATE_PERSISTENT method from CL_BCS class. 4 Create the Recipient. by calling CREATE method from CL_SAPUSER_BCS class. (INTERNAL) by calling CREATE_INTERNET_ADDRESS method CL_CAM_ADDRESS_BCS (EXTERNAL) 5 Add the Recipient by calling ADD_RECIPIENT method from CL_BCS class. 6 Create the Document. by calling CREATE_DOCUMENT method from CL_DOCUMENT_BCS class. 7 Add the Binary Format as Attachment by calling ADD_ATTACHEMENT method from CL_DOCUMENT_BCS class. 8 Set the Document by calling SET_DOCUMENT method from CL_BCS class. 9 Immediate Sending by calling SET_SEND_IMMEDIATELY method from CL_BCS class. 10 Send the Email by calling SEND method from CL_BCS class. 11 Commit by statement COMMIT WORK. (in case of external Recipient). 1 LSMW LSMW (Legacy System Migration Workbench) a tool that supports data migration from legacy systems (non-SAP systems) to SAP systems. T-code LSMW. This Tool can be used in 4 different Ways. 1. LSMW using Batch Input Recording. 2. LSMW using Direct Input. 3. LSMW using IDOC. 4. LSMW using BAPI. 2 LSMW using Batch Input Recording 1. Maintain Object Attributes Record the Required Screen & capture the respective data elements. 2. Maintain Source Structure Create the Structure. 3. Maintain Source Fields As part of structure, Create the Required Legacy Fields with respective data types.. 4. Maintain Structure Relations Map the Recording with the Respective Structure. 5. Maintain Field Mapping and Conversion Rules Map the Fields of the Recording with the fields of the structure and define the conversion rule as per requirement.. 6. Maintain Fixed Values, Translations, User-Defined Routines Implement the Rules defined in the last step. 7. Specify Files Upload the file containing data in the LSMW system. 8. Assign Files Assign the uploaded file to the structure. 9. Read File Tools is going to read the uploaded file and the data available in the file will be copied to a file named as ‘LSMW.READ’. 10. Display Read Data SAP will display the data which it read in LSMW.READ file. Just verify it. 11. Convert Data SAP will execute the rules we defined as part of 5th step. And converted data will be stored in LSMW.CONV file. 12. Display Converted Data converted data will be displayed. 13. Create Batch Input Session Converted data will be mapped to the Object which we created in 1st step. 14. Run Batch Input Session Run the Batch Input Sessions either in Background or Foreground. 3 LSMW using Direct Input 1. Maintain Object Attributes Select the Appropriate Business Object, based on the selected Business Object, Method and Program name will be provided by SAP 2. Maintain Source Structure Create the Structure. 3. Maintain Source Fields As part of structure, Create the Required Legacy Fields with respective data types.. 4. Maintain Structure Relations Map the source structure with respective standard structures provided by SAP.. 5. Maintain Field Mapping and Conversion Rules Map the Fields of the standard structures with the fields of the source structure, select the T-Code field and provide appropriate T-Code and define the conversion rule as per requirement.. 6. Maintain Fixed Values, Translations, User-Defined Routines Implement the Rules defined in the last step. 7. Specify Files Upload the file containing data in the LSMW system. 8. Assign Files Assign the uploaded file to the structure. 9. Read File Tools is going to read the uploaded file and the data available in the file will be copied to a file named as ‘LSMW.READ’. 10. Display Read Data SAP will display the data which it read in LSMW.READ file. Just verify it. 11. Convert Data SAP will execute the rules we defined as part of 5th step. And converted data will be stored in LSMW.CONV file. 12. Display Converted Data converted data will be displayed. 13. Start Direct Input Program Start with program or Tcode for data Migration. 4 LSMW using IDoc 1. Identify the Field’s name from the local file records. 2. Identify the Segments based on Local Records’ fields which we need to Migrate. 3. List down the Data types for the Identified fields from Respective Segments. 4. Create the Idoc objects for Receiver only as sender is Local system from where we need to pick text file. a. Create the Logical System. SALE b. Assign Logical System to the Client. SALE c. Create File Port. WE21 d. Create Partner Profile. WE20 e. Assign Inbound Parameters. WE20 5 LSMW using IDoc 1. Maintain Object Attributes Provide the appropriate Message Type and Idoc type. 2. Maintain Source Structure Create the Structure/s depends on the no of local files.. 3. Maintain Source Fields As part of structure, Create the Required Legacy Fields with respective data types.. 4. Maintain Structure Relations Map the source structure with respective standard segments of Idoc type. 5. Maintain Field Mapping and Conversion Rules Map the Fields of the standard segments with the fields of the source structure, and define the conversion rule as per requirement. 6. Maintain Fixed Values, Translations, User-Defined Routines Implement the Rules defined in the last step. 7. Specify Files Upload the file containing data in the LSMW system. 8. Assign Files Assign the uploaded file to the structure/s. 9. Read File Tools is going to read the uploaded file and the data available in the file will be copied to a file named as ‘LSMW.READ’. 10. Display Read Data SAP will display the data which it read in LSMW.READ file. Just verify it. 11. Convert Data SAP will execute the rules we defined as part of 5th step. And converted data will be stored in LSMW.CONV file. 12. Display Converted Data converted data will be displayed. 13. Start Idoc Generation based on records available in LSMW.CONV file, it will generate the Idoc. 14. Start Idoc Processing Generated Idoc will be processed. 15. Create Idoc Overview Generated Idoc will be displayed. 16. Start Idoc Follow-up if any error, analyze it, correct it, and re-process the Idoc. 6 LSMW using BAPI 1. Identify the Field’s name from the local file records. 2. Identify the Appropriate Business object BAPI Note Every BAPI cannot be used in LSMW, only BAPI which are associated with the ALE Message Type, can be used in LSMW. 3. Identify Business Object type, API METHOD, BAPI FM, ALE MESSAGE BAPI 4. Identify the associated Idoc Type with Message Type WE82 5. Identify the Segments based on Local Records’ fields which we need to Migrate. WE30 6. List down the Data types for the Identified fields from Respective Segments. SE11 or WE30 7. Create the Idoc objects for Receiver only as sender is Local system from where we need to pick text file. a. Create the Logical System. SALE b. Assign Logical System to the Client. SALE c. Create File Port. WE21 d. Create Partner Profile. WE20 e. Assign Inbound Parameters. WE20 BDC 6 • BDC Stands For Batch Data Communication. • BDC Technique is used for migrating the Data from Non-SAP System to SAP System. • There are multiple BDC Techniques are DIRECT INPUT, CALL TRANSACTION, SESSION METHOD, TABLE CONTROL. • Before starting the migration the Local Data to SAP system, we need to do the Data Analysis with Functional Consultant. • • • • • Separator How many fields data One Record contains Identify the Type of Data customer data, supplier, plant , machine, instruments, material. Identify the Target DB Table where Data has to Migrate. Identify the Target Fields in the DB Table. 1 Selection Screen 1. To Generate A selection Screen with one Input Fields, we go for PARAMETERS. 2. To declare multiple Parameters variables, we should go for Chain Operator. 3. To provide a meaningful Text in the Label, we need to go for Selection Text. 4. To make any field as mandatory, we need to use one Keyword OBLIGATORY. 5. To provide some default value in the input field, we need to use one keyword DEFAULT. 6. To comment a line, we need to prefix < * > symbol with that line. 7. To comment multiple lines at once, we need to select those lines and press CTRL + < 8. To uncomment multiple lines at once, we need to select those lines and press CTRL + > 9. To go for in-line comment, we need to go for < “ > symbol. 10. To print the value on LPS, we need to go for WRITE statement. 11. To print the Value in an Dialog Box, we need to go for MESSAGE statement. 12. Debugging It is a process of analyzing the source code execution line-by-line or section-bysection. 13. For Debugging of the Program, we need to set the Break Point from where we want to start Debugging. 14. Break point can be set in an Active Program only and can be set on executable Source lines only (not on declarations). 2 Conditional Statements if endif • IF statement contains one or more logical expressions/Conditions followed by one or more statements. IF statement followed by ELSE contains another set of statements. • The statements available as part of IF block will be executed only when the IF condition satisfied. Otherwise statements available in ELSE block will be executed. 3 Conditional Statements case endcase • So when to go for if endif • When to go for case endcase. IF ENDIF • Using this conditional statement, SAP Matches each and every condition. • Poor performance if there are multiple condition to be matched. Case Endcase • Using this conditional statement, control directly jumps to the matched condition in stead of matching each condition.. • Better Performance. 4 Do enddo & While Endwhile • These both are examples of Loop statements. • Loop statements executes the associated statement multiple times. DO enddo • It is a non-conditional loop statement. While Endwhile • It is a conditional loop statement. Till the time associated condition will be satisfied, statements will keep executing Syntax Syntax Do <n> times. While <condition> <Executable_statement> <Executable_statement> Enddo. Endwhile. 5 Push Button on selection Screen First Name Middle Name Report Program Last Name FULL NAME CLEAR EXIT SELECTION SCREEN 6 Interact with DB Tables • Data Available in Internal Tables is Temporary Data. • Data Available in DB Tables is Permanent Data. • Standard DB Tables KNA1, VBAK, VBAP, VBRK, VBRP, EKKO, EKPO, SPFLI, SFLIGHT, MARA, MAKT, MARD, MARC, LFA1 ………….. etc. • To Retrieve a single Record from DB Table, use Select Single Statement • To Retrieve Multiple Records from DB Table, use Select Statement • A single Record can be retrieved in Either Local variable or in Work Area. • Multiple Records can be retrieved in an Internal Table. • While retrieving the data from DB tables, Always refer either Data Element or Field name to the Local variable or fields of Types structure instead of referring the Data Type. 6 Dynamic Selection Screen USE KUNNR USE VBELN Enter Cust No Enter Sales Doc No 7 Joins A join is a way to combine data from two or more tables into a single result set. This result set can be used for various purposes, such as reporting, data analysis. Inner Join: This join returns only the rows that have matching values in both tables. Left Outer Join: This join returns all the rows from the left table and matching rows from the right table. If there is no match in the right table, the result set will contain NULL values. Right Outer Join: This join returns all the rows from the right table and matching rows from the left table. If there is no match in the left table, the result set will contain NULL values. Full Outer Join: This join returns all the rows from both tables, regardless of whether there is a match or not. Inner Join: Left Outer Join: Right Outer Join: Full Outer Join: 8 Classical Interactive Reporting A join is a way to combine data from two or more tables into a single result set. This result set can be used for various purposes, such as reporting, data analysis. 1 MPP • MPP – Module Pool Programming. Also called as Dialog Programming. • SE38 ABAP EDITOR or SE80 OBJECT NAVIGATOR Executable/Report Program Module Pool/Dialog Program 1. Executable program can be run via SE38/SE80. Reports are standalone programs. 1. Module pool program cannot be executed directly, it must be run from a Transaction Code or using Call Screen. 2. Reports are collection of processing blocks, controlled by 2. Dialog programs are controlled by Screen flow logic. System calls depending on events. 3. Events in Executable programs are Start-of-selection, at selection-screen etc. 3. Events in Executable programs are PBO, PAI etc. 4. We go for Report Programs to read Database Tables & represent results in Lists. 4. We use Dialog Programs to read & Change Database Tables. 5. In report programming, input will be provided within the program or on a screen and output will be list. 5. In the case of Dialog programming input will be screen and output will be screen 2 MPP TAB-1 TAB-2 3 MPP Enter Customer Range Get Data Exit Display required Data from KNA1 Table in Table Control 3 MPP Customer No. Display Data KNA1 VBAK EXIT 1 Structure • Structure is a collection of fields. • The fields declared as part of a structure can have different – different Data Types. • Based on a Structure, we can declare the Work Areas and Internal Table. 2 Internal Table 1. It is a Temporary Table where we can store the retrieved data from DB Tables. 2. In an Internal Table, we can process the retrieved Data. 3. The Memory allocated to the Internal Table is sustained up to the current program only. 4. Once we close the current program, memory allocated to the Internal table will be collapsed. 5. And the Data available in the Internal table will also be erased once the program is closed. 6. So the Data available in an Internal table is Temporary Data. 7. In Internal Tables, data gets stored in form of Rows and columns. Row is also called as Line and column is called as Field. 8. And the Data available in Database tables is the Permanent Data which stored in the Database server.. 9. An internal Table will be declared on top of a Structure. 10. An Internal Table can be declared either with Header or without header. 11. In Internal Table with Header, Header line or Work area will be created itself. 12. In Internal Table without Header, Header line or Work area will not be created itself. We our self has to declare the work area based on same types structure to fill the Internal table. 13. There are 3 types of Internal Tables, STANDARD INTERNAL TABLE, SORTED INTERNAL TABLE & HASHED INTERNAL TABLE. 3 Internal Table 1. INTERNAL TABLE WITH HEADER LINE. 2. INTERNAL TABLE WITHOUT HEADER LINE. 3. DISPLAY THE DATA FROM INTERNAL TABLE USING LOOP ENDLOOP. 4. GET THE NO OF COUNT OF RECORDS IN INTERNAL TABLE - DESCRIBE TABLE AND SY-TFILL. 5. ASSIGNMENT OPERATOR TO ASSIGN THE DATA FROM ONE INTERNAL TABLE TO ANOTHER. 6. APPEND LINE OF - STATEMENT. 7. HOW TO REFRESH AND CLEAR THE INTERNAL TABLE. 8. APPEND LINE OF - FROM N TO N - STATEMENT. 9. FREE STATEMENT IN INTERNAL TABLE. 10. How to sort Internal Tables - Ascending & Descending. 11. Internal Table with key field. 12. Insert statement vs append statement. 13. Read Statement with index in Internal Table. 14. Read statement with KEY field in internal table. 15. Read statement with Transporting in internal table. 16. Loop endloop with WHERE condition. 17. Process the data in internal table (Modify and Delete) 18. STANDARD INTERNAL TABLE 19. SORTED INTERNAL TABLE 20. HASHED INTERNAL TABLE. 1 Modularization Techniques • In SAP ABAP, Modularization is a process which is used for dividing the complex code into smaller, manageable blocks. • This approach makes the code more organized, easier to maintain and test, and reduces the risk of errors. • The Blocks can be grouped into classes, functions, include programs, methods, and subroutines, which can be reused across multiple programs. • Modularization also enhances code security by encapsulating data and logic. • Classes and methods are object oriented concepts. Here we are going to discuss about the Sub-Routines, Include Programs and Function Modules. 2 Modularization Techniques • Subroutines: Subroutines are small units of code within a larger program. They can be called multiple times from within the same program, and they help to break down the complexity of the program into smaller, more manageable units. Sub-routine will always be defined at the end of the Program. We can define it using FORM <sub-routine_name> ENDFORM. And we can call a subroutine using PERFORM <subroutine_name> statement. • Include Programs: Include programs are self-contained units of code that can be reused in multiple programs. An include program is stored in a separate file and can be called from any other program using an "include" statement. • Function Modules: Function modules are reusable blocks of code that can be called from multiple programs. Function modules can be used to perform specific tasks and can accept input parameters and return values. Function modules are stored in the SAP function library and can be easily reused in other programs. 3 Modularization Techniques Subroutines: Advantages: • Subroutines help to reduce the complexity of a program by breaking it down into smaller, more manageable units. • Subroutines can be reused multiple times within a program, reducing the amount of duplicated code. • Subroutines make the code easier to read and maintain. Maintenance Cost Decreased. Subroutines: Disadvantages: • Subroutines cannot be reused outside of the program in which they are defined. • Subroutines may increase the number of source code lines, making the program more difficult to navigate. 4 Modularization Techniques Include Programs: Advantages: • Include programs can be reused in multiple programs, reducing the amount of duplicated code. • Include programs can be stored in a separate file, making it easier to manage the code and to perform version control. • Include programs can be tested and debugged separately from the main program. Include Programs: Disadvantages: • Include programs can increase the number of source code lines in a program, making it more difficult to navigate. • Include programs may require additional maintenance when changes are made to the code. • Include programs cannot be executed independently, they must be called from another program. 5 Modularization Techniques Function Modules: Advantages: • Function modules can be reused in multiple programs, reducing the amount of duplicated code. • Function modules are stored in the SAP function library, making it easy to reuse the code in other programs. • Function modules can be tested and debugged separately from the main program. • Function modules can accept input parameters and return values, making them more flexible than subroutines or include programs. Function Modules: Disadvantages: • Function modules may increase the complexity of a program if they are used excessively. • Function modules may require additional maintenance when changes are made to the code. 6 Modularization Techniques 1. INTERNAL SUB ROTUINE. 2. EXTERNAL SUB ROTUINE IN SUBROUTINE POOL.. 3. EXTERNAL SUB ROUTINE IN ANOTHER EXECUTABLE PROGRAM. 4. Formal & Actual Parameters to the Sub routines. 5. USING, CHANGING, TABLES keyword in sub routines. 5. Internal Table as parameter to the sub routine. 6. parameters pass by value & pass by reference in Sub routines. 7 Sub-Routine vs Function Module Sub-Routines Function Modules Can be Defined and called using ABAP Editor (SE38). Can be defined using Function Builder (SE37). Can be stored in Sub-Routine Pool (SE38) or in another executable program. Can be stored only in Function Group (SE80-Object Navigator). SR Types internal & external. FM Types: Custom FM and Standard FM. SR can be called in executable program only, these cannot be executed individually. FM can be executed individually. SR always defined at the end of the Program. FM can be called globally across the ABAP programs. We cannot handle exceptions while defining Sub routines. We can handle exceptions while defining FM. SR cannot be remote enabled. FM can be remote enabled. Object Transport Management System 1 • • • • • • As an Abap Consultant, we will be involved in the development of RICEF objects. R Reports I Interfaces C Conversions E Enhancements F Forms. • After the development of these objects, These objects has to be moved from Development system Landscape to Quality system landscape and then to the Production system landscape. • So to transport the objects and the changes from the development environment to the quality environment and then to the production environment, we need to store the objects inside a Transportable package, once objects are stored inside a transportable package, we will be able to assign the Transport Request. • The transport request movement from one SYSTEM to other is done by BASIS team. • Task are not self-transportable but part of transport request. Transport request can be released only once all the tasks inside transport request are completed, released or deleted. 2 Object Transport Management System Components of TMS • Package It is a logical container of Objects. • Transport Request / Change Request It is a collection of one or more tasks. Transport request is of two types. Workbench Request Workbench requests are cross-client. It will capture the changes done in the Repository objects (executable programs, include programs / subroutine pool) and dictionary objects (tables, data elements, type groups, views, search helps). Mostly it will be used by the ABAP consultants. Customizing Request Customizing requests are client specific. It will capture customization changes. Mostly It will be used by the Functional consultants. • Task Every user should create their own task/s under main request for storing their respective objects. Every task can be associated with one or more objects. Task are not self-transportable but part of transport request. Transport request can be released only once all the tasks inside transport request are completed, released or deleted. 3 Object Transport Management System Version Management • Version management in SAP ABAP refers to the ability to manage different versions of repository objects.. • This allows developers to maintain a history of changes made in the objects and also provides the ability to compare different versions. • SAP provides different tools for version management, such as the Transport Organizer and the Object Navigator. • These tools allow developers to create and manage different versions of programs, track changes, and move them between systems. 1 DDIC / Database objects DataBase Objects Repository Objects 1. Dictionary objects define the structure and characteristics of data. 1. Repository objects contain the actual code that manipulates that data. 2. Dictionary objects are created and maintained in the ABAP Dictionary and can be reused across the ABAP programs. 2. Repository objects are created and maintained in the ABAP Workbench. 3. DDIC objects are :- Tables, structures, Data Elements, Domains, Views, Table Types, Search Helps, Type Groups etc. 3. Repository Objects are :- Executable Programs, Include Programs, Sub-routines, Function Groups etc. 4. T-Code SE11 4. T-code SE80 or Individual T-codes. 2 Custom DB Table vs Standard DB Table Custom database tables in SAP ABAP are application-specific, created by developers, and used to store custom data. Standard database tables, on the other hand, are already present in the system, used to store system data, and maintained by SAP. Creation: Custom tables are created by developers, while standard tables are already present in the system. Fields: Custom tables can have fields that are specific to the application, whereas standard tables have fields that are common t all applications. Usage: Custom tables are used to store application-specific data, while standard tables are used to store system-related data. Maintenance: Custom tables are maintained by the developer, whereas standard tables are maintained by SAP. Authorization: Custom tables have authorization objects specific to the application, while standard tables have authorization objects that are predefined by SAP. Integration: Custom tables can be integrated with other application objects, while standard tables are already integrated with system objects. Naming conventions: Custom tables can have any naming convention, while standard tables have a predefined naming convention. 3 Client Dependent vs Client Independent Client Dependent Client In-Dependent 1. A client dependent table contains data that is specific to a particular client. 1. A client independent table contains data that is not specific to any particular client. 2. When a client dependent table is created, separate copies of the table are created for each client in the SAP system. 2. When a client independent table is created, only one copy of the table is created for the entire SAP system. 3. Data entered in one client is not visible or accessible to other clients. 3. Data entered in one client is visible and accessible to all clients in the SAP system. 4. Examples of client dependent tables include customer master data, vendor master data, and material master data. 4. Examples of client independent tables include company code data, plant data, and user master data. 4 Data Element & Domain • Data Element is a domain-based individual and reusable object that defines the properties and attributes of a particular data field. • Domain is a predefined set of values, which can be used to define the data type and length of a field. • Data Element provides a description of a data field, including the field's name, label, data type, length, and other characteristics. • Data Elements can also include documentation and search help. • Data Element can be created and maintained using the SAP Data Dictionary transaction (SE11) 5 Table Buffer • Table buffering is a performance optimization technique in SAP ABAP that involves storing frequently accessed table data temporarily in the memory of the application server. • Instead of fetching data directly from the database every time, the system retrieves it from the buffer, resulting in a substantial speedup. • Buffering significantly enhances query performance by storing frequently accessed data in memory, bypassing the time-consuming process of retrieving it from the database. This results in query speeds increasing by at least 10 times, leading to improved application responsiveness. • Only Transparent tables and Pooled tables can be buffered. Cluster tables cannot be buffered. Benefits of Table Buffering • Improved Performance: By reducing database accesses, table buffering significantly enhances application response time. • Reduced Database Load: As fewer data requests are sent to the database, it reduces the load on the database server. • Enhanced System Stability: Less database traffic can lead to improved system stability and reliability. 5 Table Buffer 3 Types of Buffering available 1. Single Record Buffering. Only the accessed record is loaded into the buffer. Useful for large tables where there are frequent single-record accesses (using SELECT SINGLE ... Comparing with key field). 2. Full Record Buffering. : All records of the table are loaded into the buffer when any record is accessed. For small tables where the access range is large. Recommended to implement on tables which are having Master Data. Only one database access is required to load such a table for full buffering. 3. Generic Area Buffering. A table should be buffered generically if only certain areas of the table are required. The individual generic areas are treated like independent tables that are fully buffered. Here we need to pass number of key Generic fields. The number of key generic fields for a generic area buffering is always less than the number of primary keys of the table. Useful for Generic area like Language Dependent DB Tables & client-specific DB tables. 5 Table Buffer Feature Single Record Buffering Full record Buffering Generic Record Buffering Description Only the accessed record is loaded into the buffer. All records of the table are loaded into the buffer when any record is accessed. A specific area of the table defined by a number range is loaded into the buffer. Buffer Size Smaller compared to other types. Larger compared to single record buffering, but can be excessive for large tables. Depends on the defined number range. Performance Good for large tables with infrequent access. Excellent for small tables with frequent access. Good for tables with frequently accessed data within a specific range. Database Accesses Multiple database accesses required for each record. Single database access for all records. Multiple database accesses within the defined number range. Suitable for Large tables with infrequent access, Small tables with frequent access, Tables with frequently accessed records around 100-200 KB. all records accessed frequently. data within a specific range. Considerations Higher administrative overhead due to multiple database accesses. Can consume significant buffer memory for large tables. Requires careful definition of the number range. 5 Foreign Key Relationship • Foreign Key Relationship is a way to link a field (or set of fields) in one database table to a field (or set of fields) in another table. • It helps to prevent the Data Inconsistencies. Data of One table will be dependent of another Table Data. • In both of the Tables, There must a field which is having the same technical Properties. • In one of the Table, One field must be declared as a Primary Key field to avoid the Duplicate data.. • There are 2 Tables involved In Foreign Key Relationship. Parent Table or check Table and Child Table or Foreign Key Table. • One Field need to be declared as a Primary Key field in Parent Table/ Check Table. • Foreign Key field will be declared in Child Table / Foreign Key Table. • After establishing the Foreign key relationship, we will be able to insert the Dependent data only in the Foreign Key Field of Child Table. 6 Type Group • Type Group is a Reusable Dictionary object which contains the Global Types and Global Constants. • The Component of Type Group are Types and Constants only. • The name of the components must be prefixed by the Type Group Name + <_>. • Local Types and Local Constants can be used in the parent Program only. • Type Group is Global. The Types and The constants declared as part of Type Group will be Global and these can be Used across the objects. 7 Table Type • The Table Type dictionary object is used to define the Global internal Table which will be based on a Global structure at ABAP Dictionary Level. • It defines the fields and their data types, the key fields, and other properties of the table, such as the size of the table and the number of rows that it can store. • <T> - identification. • <s> - line type - identification 8 View • View is a virtual table that provides a specific view of the data stored in one or more database tables. It is a Reusable dictionary Object. • It is defined in the ABAP Dictionary – SE11. • Advantage of Views • Simplify data access: A view can be used to simplify data access by presenting a simplified view of the data stored in one or more database tables. This can make it easier to access and manipulate the data, as the view can hide the underlying complexity of the data stored in the tables. • Enforce data security: A view can be used to enforce data security by restricting access to specific data stored in the underlying tables. For example, a view can be defined to only show data that is relevant to a specific user or role. • Improve performance: A view can be used to improve performance by pre-joining data from multiple tables, which can reduce the number of database accesses required to retrieve the data. 8 Types of Views Database View • A database view in SAP ABAP can be created either on a single table or multiple tables. It supports both projection and selection, where projection refers to the process of selecting only required fields, and selection refers to the process of imposing conditions on accessing the table data. • A database view created on a single table can either be "Read only" or "Read and Change," meaning that the changes made to the data at the view level will automatically reflect in the corresponding base table and vice versa. On the other hand, a database view created on multiple tables is always "Read only." • It is not possible to generate table maintenance for database views. When creating a database view based on multiple tables, one must provide the join conditions by comparing the logically related fields, otherwise, it will result in a Cartesian product. The resultant values are constructed based on an inner join. • The database view can be used in SELECT statements and provides a selective and simplified representation of the data from one or more tables in the database. 9 Types of Views Projection View • A projection view in SAP ABAP is created on top of a single table only. It supports only projection and does not support selection conditions. • When a projection view is needed, the complete data of the base table is shared but with limited fields. • The maintenance status for a projection view can either be "Read" or "Read and Change." • It is not possible to generate table maintenance for a projection view. 10 Types of Views Maintenance View • The purpose of a maintenance view is to provide a simplified interface for updating the database tables, taking into account the foreign key relationships between tables. • A maintenance view in SAP ABAP can be created on top of a single table or multiple tables. The join conditions are proposed by SAP based on the selected table's foreign key relationship. • Maintenance views support both selection and projection and can be used to generate table maintenance. However, it cannot be used in SELECT queries. 11 Types of Views Help View • The purpose of a help view is to provide additional information or support in a search operation. • A help view in SAP ABAP can be created on top of a single table or multiple tables. Table maintenance cannot be generated for help views. • Both selection and projection are supported, and the maintenance status is "Read only." • A help view can be viewed as a selection method in search help, and it follows a left outer join condition. It cannot be used as part of a SELECT statement. 11 Search Help • Search Help is a reusable Dictionary Object in SAP ABAP that can be used to populate custom F4 help for multiple objects such as data elements, selection screen input fields, and module pool screens. By attaching the Search Help to these objects, you can display the list of possible values for the user to choose from, ensuring consistent and accurate data entry. • Types of Search Help :1. Elementary Search Help. 2. Collective Search Help. An Elementary Search Help provides only one input path for F4 values, meaning that it provides a single list of values to choose from. A Collective Search Help, on the other hand, can provide multiple input paths for F4 values, meaning that it can provide multiple lists of values to choose from. This is useful in situations where you want to provide different sets of values for different input fields. 12 Lock Object • In SAP ABAP, a Lock Object is a mechanism used to prevent multiple users from accessing or modifying the same data simultaneously, which can lead to inconsistencies and data corruption. • When a user requests a lock on a particular piece of data, the system checks if the requested lock conflicts with any existing locks on that data. • If there is no conflict, the lock is granted, and the user can access the data. • If a conflict is detected, the system may block the user's request or place it in a queue until the conflicting lock is released. • Object Level Locking is done by SAP itself, Data level locking need to be done by Developer. 13 Lock Object • Mainly, there are three types of lock objects: • Shared Lock Object (S)- It allows multiple users to read the same data simultaneously. However, if any user wants to modify the data, the system will prevent them from doing so until all shared locks on that data have been released. Its also called as Read Lock. • Exclusive Lock Object (E)- It allows only one user to read or modify the data at any given time. If any user has an exclusive lock on the data, other users are prevented from accessing or modifying the data until the exclusive lock is released. Other User will be in the Queue. It is also called as WRITE Lock Object. • Exclusive but not cumulative Lock (X) – It is similar to Exclusive Lock, but other user’s request will not be stored in the queue, other users have to send the fresh request. • Lock objects can be defined and used in ABAP programs using the statement ENQUEUE for requesting a lock and DEQUEUE for releasing a lock. • Lock Object name must be start with EZ or EY. 1 Presentation Server, Application Server, Database Server Presentation Server Application Server Database Server 1 New ABAP Syntax in ABAP 7.40 & 7.51 LINE_INDEX Function is used to find the Index position of a row within an Internal Table. It returns the Index position of the first occurrence. If the condition in the Line_Index is not satisfied, no exception will be raised, The Return Index value will be ZERO. LINE_EXISTS Function is used to check whether a specific line exists in an internal table or not. LINE_EXISTS Function returns a Boolean value either TRUE or FALSE. 2 New ABAP Syntax in ABAP 7.40, 7.50 & 7.51 • LET expression is used to define local variables within an expression. • This can be useful when you want to define a variable that will only be used within a specific part of the code, without cluttering up the surrounding code with unnecessary declarations. • COND statement is used to perform simple conditional processing based on a single condition. • Operator will be used with each of the Condition. • SWITCH statement is used to perform more complex conditional processing based on multiple conditions. • Operator will be used only Once. 1 Debugging 1. Debugging is a process of finding and fixing errors in SAP ABAP programs. 2. To start the debugging, we need to set the Breakpoint at the line of code from where we want to start debugging process. 3. Programs should be in active state to start the debugging. 4. Break points needs to be set on executables statements only like SELECT, CALL FUNCTION. 5. Break point should not be set on declaration related statements like DATA, PARAMETERS, SELECT OPTION. 6. Debugging will start from the line where you set the Break Point. Earlier statements will be Executed. 7. Execution Keys in Debugging are F5 for step by step Execution, F6 for Line by line Execution, F7 for Return back to parent program, F8 for Execute completely. 8. System fields in Debugging SY-SUBRC, SY-TABIX. 9. Debugging can also be start by switching on the Debugging using T-code /h (here debugger will stop at the 1st executable line). 10. Desktop 3 is most preferable desktop to start debugging as we can check the variable values parallelly. 1 Misc. Concepts LDB - Logical Database. • A logical database is a special ABAP program which combines the contents of certain database tables. • We can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables. • LDB's Can be used only in Executable Program. • To access the LDB in Report Program, we use GET <LDB name > statement. • T-code SE36
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )