nice book with good examample and cover all interview question and answer...
SAP-ABAP
1
INDEX 1 2 3 4 5 6 7 8 9 10 11 12
Introduction to ERP Introduction to SAP R/3 SAP R/3 Services Introduction to ABAP/4 & ABAP Work Bench Tools ABAP Data types ABAP Programming Structures Steps to Write & Create SAP Program Tips for Writing a Program in Real Time Internal Table & difference between database table & internal table Reading Data from Body to Work Area (or) Header Line (1. LOOP….ENDLOOP, 2. READ) Selection Screen (1. Select-options, 2. Ranges, 3. Parameters ) Other SELECT-OPTIONS keywords (1. Obligatory, 2. No Intervals, 3. No-Extension, 4. No-Display)
Rohini kumar
5 6 8 10 12 14 16 19 20 22 26 28
SAP-ABAP
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Other Important Keywords for Internal Table (1. Append, 2. Sort, 3. Delete Adjacent Duplicates, 4. Collect 5. Modify ) 6. Deleting Data from Internal Table by (1. Fresh, 2. Refresh, 3. Clear, 4. Delete ) 7. Describe Keyword 8. Coping data b/w work areas (1. Move, 2. Move-Correspondig) 9. Coping data b/w internal tables (1. Loop…….Endloop, 2. Append Lines) Control Break Statements (1. At First, 2. At Last, 3. At New, 4. At Change, 5. At End ) Insert keyword & Syntaxes for Internal Tables System Fields for Internal Table DML Operations on Database Table (insert, update, delete, modify keywords) Types of Internal Tables Data Dictionary (9 objects) 1. Database Table 2. Structure (.include & Append Structure) 3. View(Database view, Projection view) 4. Search Help (Elementary search help, Collective search help) Table Maintenance Generator (TMG) (TCode, Default values, Check boxes) Text Table Some Important Steps for Working with Standard Tables Types of Tables (Transparent, Cluster, Pooled Tables) Open SQL Statements & Native SQL Statements Buffering (Single Record, Generic, Full Buffering) MODULES(1. MM Module) Inner Joins Table Fields & Links (1. LFA1, 2. EKKO, 3. EKPO) Message Handling Modularization Techniques (5) 1. Subroutines (Internal Subroutine, External Subroutine) Break Point (1. Static Break Point 2. Dynamic Break Point) Pass by Value & Pass by Reference Table Fields & Links (1. MKPF, 2. MSEG) Function Module (1. Normal, 2. Remote Enabled, 3. ALv) Include Program Field Symbol FOR ALL ENTRIES Table Fields & Links (1. MARA, 2. MAKT, 3. TSPAT) 2. SD Module String Operations (shift, translate, replace, strlen, offset functionality, split, concatenate, condense) Looping Statements (1. Conditional, 2. Unconditional)
Rohini kumar
2
31 36 37 38 39 41 45 46 48 50 51 55 58 60 63 70 72 73 74 75 76 79 84 86 88 90 91 94 96 100 101 103 108 109 111 115
SAP-ABAP
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
3
CONTINUE, CHECK, EXIT keywords Mathematical Operations (1. Frac, 2. Ceil 3. Floor, 4. Abs, 5. Rem, 6. Mod, 7. Sign, 8. Trunc, 9. Div ) SAP Memory & ABAP Memory Support Project System Landscape Version Management Sub Objects in ABAP Editor (1. Source Code, 2. Variants, 3. Attributes, 4. Documentation, 5. Text Elements) Interview Questions ABAP Editor Interview Questions Internal Tables Interview Questions Data Dictionary LFA1 Table EKKO Table EKPO Table MKPF Table MSEG Table MARA Table MAKT & TSPAT Tables
Rohini kumar
118 120 122 125 126 130 131 133 136 143 161 162 163 164 165 166 167
SAP-ABAP
4
ERP ERP: Enterprise Resource Planning ERP is a package under which all the business resources are integrated in one system Enterprise-------organization Resource--------FICO, HR, MM, PP, SD, CRM Types of ERP: 1. High End ERP 2. Mid Range ERP 1. High End ERP: These ERPs are implemented in large scale industries In these ERPs all the tables, programs & applications are predefined Example: Rohini kumar
SAP-ABAP
5
1. SAP R/3 (60000+ applications, 400000+ tables, 55+ modules) 2. Oracle Apps (for Finance) 2.1. Oracle Finance 2.2. Oracle Manufactures 2.3. Oracle HRMS 3. SIEBEL (for CRM) 4. People Soft (for HR) 2. Mid Range ERP: These ERPs are implemented in small scale & medium scale industries Example: 1. Baan (for Finance) 2. JD Ed Wards (for logistics) 3. Ramco (for Cement) 4. Microsoft ERP (for Finance) Need for ERP: 1. Large Organization 2. Centralized Database 3. User Friendly 4. Speed 5. Security 6. Competitive Advantage 7. Reduced Errors
SAP R/3 SAP R/3: Systems, Applications, Products in data processing R/3------ Real time 3 tier architecture History: SAP AG---- developed by 5 IBM employees in 1973----in woldoff (Germany) SAP R/1(Finance)------1973 SAP R/2 (Mainframes)------1978 SAP R/3 (Client Server Technology)----1992 Systems: These are basic resources for implementing a project Examples: Servers, Hardware, Soft ware, Systems, Network, Database………etc Rohini kumar
SAP-ABAP
6
BASIS Consultant: Roles: 1. Installation 2. Maintenance 3. Configuration 4. Customization (or) Administration Applications: These are collection of Screens Each Screen is a collection of Fields Use---Applications are used by Clients (or) End Users Create---Applications are created by Abapars (or) Technical Consultant (or) ABAP Consultant Customized Data----Applications data customized by Functional Consultant Functional Consultant: Roles: 1. Customization of Data 2. Getting requirements from Clients 3. Preparing Functional Documents 4. Preparing End User Manuals (or) Snapshots 5. Providing end user Training
Products: These are called Objects These are created by Programming ABAP Consultant (or) Abapare (or) Technical Consultant: Roles: 1. Creates Technical Documents (brief logic) 2. Creates an Object from scratch implementation project 3. Modifies existing objects to support project 14-08-2014 Features of SAP: 1. Designed based on RDBMS 2. Designed based on R/3 Architecture 3. Database independent 4. Supports all types of industry specific solutions 5. International package available in 40 languages Rohini kumar
SAP-ABAP
7
6. It can be customized using ABAP language 7. Best ERP for FI, SD, MM, PP, HR, CR 8. Supports Client-Server Technology 9. Highly versatile (Operating System independent) 10.Supports web based application softwares SAP R/3 Architecture:
External Systems (Printer, Fax……etc)
Spool Service Programs, Applications, Objects…….etc
Objects are Executed, Compilation……etc
Dialog Service
Presentation Server
Maintains & Manages Database
Update Service
Application Server
Database Server
Services in R/3 Architecture: 1. Dialog Service: It provides interface between Presentation Server & Application Server 2. Update Service: It provides interface between Application Server & Database Server 3. Spool Service: It provides interface between SAP R/3 & External Systems (Printers, Fax….etc) 4. Background Service: It is for background scheduling Note: In real time once report is created, then it is scheduled in background by BASIS Consultants, they will set time & event related to it 5. En-queue Service: It maintains data integrity (locking mechanism) in SAP 6. Message Service: Rohini kumar
SAP-ABAP
8
It is for Error & Exception handling 7. Gateway Service: It is for distributed environment Note: The above 7 services are part of Application Server 8. SAP GUI Front End Service: It handles all SAP GUI Operations in SAP Presentation Server 9. Database Service: It Maintains & Manages data operations in Database Server Versions in SAP: Version Year 1.0 & 1.1 1991 2.0 & 2.1 1991 3.0 & 3.1 1992 4.0 1998 4.6A, 4.6B, 4.6C 2000 4.7EE 2003 ECC 5.0 2005 (ECC----Enterprise Core Component) ECC 6.0 2006 (Present Working) BI/BO 2008 (Business Independent) CRM, SCM, PLM 2009 (Customer Relationship Management, Product Lifecycle Management)
Soft wares in SAP: 1. Production Software 2. IDES Software (or) Training Software 1. Production Software: It is Real time Every company should purchase this software from SAP Here you will find only live data Clients (End Users) are works with Production Software 2. IDES Software: International Demonstration & Education System Software It is also known as Training Software Here you can find data for practice & examples for practice
Rohini kumar
SAP-ABAP
9
16-08-2014
ABAP/4 Advanced Business Application Programming 4th Generation Language All SAP applications are designed & developed using ABAP Language It is a high level language Features of ABAP: 1. It was designed based on ‘C’ language 2. It is a platform independent language 3. It is a case insensitive language 4. It is database independent 5. It is truly business oriented language 6. It is rich in data types 7. It was designed based on Object Oriented Programming 8. It is an event driven programming language 9. It is highly user friendly 10.It supports web based applications also ABAP Work Bench: In real time as a Technical Consultant have to work with ABAP Work Bench tools ABAP Work Bench Tools: 1. ABAP Dictionary: It works with Transaction Code (OR) T Code SE11 (System Engineering) Here we can create & store Tables (or) Data 2. ABAP Editor: It works with Transaction Code (OR) T Code SE38 (System Engineering) Here we can create & execute Programs 3. Screen Painter: It works with Transaction Code (OR) T Code SE51 (System Engineering) Here we can design Applications (OR) Screens 4. Class Builder: It works with Transaction Code (OR) T Code SE24 (System Engineering) It is for Object Oriented ABAP
5. Function Builder: Rohini kumar
SAP-ABAP
10
It works with Transaction Code (OR) T Code SE37 (System Engineering) Here we can work with Function Modules 6. Object Navigator: It works with Transaction Code (OR) T Code SE80 (System Engineering) Here we can create & modify the Objects & store the Objects Note: In Object Navigator you can develop all Objects in SAP It is also known as a True ABAP Development Work Bench Requirements for Installing SAP: 1. 4GB RAM 2. 500GB Hard Disk 3. Core 2 Duo Processor
Rohini kumar
SAP-ABAP
11
18-08-2014
ABAP Programming ABAP Data Types: ABAP data types are classified into 4 categories They are: 1. Numeric 2. Character 3. String 4. Hexadecimal 1. Numeric: These are classified into 3 categories They are: i) Integer (I) ii) bPacked Decimal (P) iii) Floating point (F) i) Integer (I): It holds integer values Ex: 102, 55, 74, ….. ii) Packed Decimal (P): It returns accurate values with decimal values It provides accuracy in ABAP programming Ex: 102.55, 56.235, ….. iii) Floating Point (F): It improves performance in ABAP programming by rounding of the value to nearest decimal Ex: 22.63-----23, 58.232-----58 2. Character: These are classified into 3 categories: They are: i) Character (C) ii) Date (D) iii) Time (T) i) Character (C): It holds character value provided in ‘ ’ (single quotes)
Rohini kumar
SAP-ABAP
12
Note: In ABAP programming the default data type is Character ii) Date: Use Date data type to store date values The default SAP format for date is YYYYMMDD iii) Time: Use Time data type to store time values The default SAP format for time is HHMMSS 3. String (String): A group of characters combined to form a String 4. Hexadecimal (HX): It is for SAP graphics management Note: QUAN, CURR, NUME are SAP provided business data types for storing Quantities, Currencies & other Numeric values Type Keyword: It specifies the type of data an Object (Variable) can hold Example: 1. Data ch type String --------hi, hello, how are you,……… 2. Data cnt type I ------54, 1025, 748,……. 3. Data count type P values 2 -------145.22, 52.69,…… 4. Data chr(10) type C ------ ‘a’, ‘h’,……… Data Keyword: Using Data keyword Objects are defined in ABAP programming Using Data keyword memory is allocated in buffer by system Note: Every Object (OR) Variable should be define using Data keyword
Rohini kumar
SAP-ABAP
13
Programming Structures: These are 2 types They are: 1. Pre defined Programming Structure 2. User defined Programming Structure Pre defined Programming Structure: It is given by SAP It contains Tables, Structures, Type groups,……….etc User defined Programming Structure: These are 2 types 1. Work Area 2. Internal Table 1. Work Area: Work Area is a Structure (group of fields with different data types) It holds only one single record during run time Syntax: Chain Operator Name of Work Area (any name) Data: Begin of wa_KNA1, { wa_table name (OR) w_table name is recommended } Customer(10) type C, Name(20) type C, City(20) type C, End of wa_KAN1. Period Symbol Field Name Note-1: With above syntax during run time a Work Area wa_KNA1 is created in Application Server Note-2: Work Area name can be any name In companies we have to follow Naming (Coding) standards while creating a program According to these standards Work Area should always begins with w_ (OR) wa_ followed by Table Name Note-3: Every Object (Work Area) should be define with Data keyword Note-4: Every Programming Structure should begins with Begin of & ends with End of followed by the Programming Structure name Rohini kumar
SAP-ABAP
14
Note-5: : is known as Chain Operator It provides the repetition of the Declarative Part Requirement: Transfer Customer Master Data from Database Server to Application Server & from Application Server to Presentation Server Solution: Select kunnr name1 ORT01 from KNA1 into wa_KNA1. ----- Data transfer from Database Server to Application Server (Work Area) Write:/10 wa_KNA1-Customer, 30 wa_KNA1-Name, data transfer from Work Area to Virtual Page then 60 wa_KNA1-City. Presentation Server Endselect. ----------- it repeats the Select statement until records completed Work Area 100 satya Hyderabad 200 ram Delhi 300 raj Bangalore
Presentation Server
100
satya Hyderabad
m 100 satya Hyderabad 200 ram Delhi 300 raj Bangalore
Application Server
kunnr 100 200 300
KNA1 name1 ORT01 satya Hyderabad ram Delhi raj Bangalore
Database Server Virtual Page
Rohini kumar
SAP-ABAP
15
20-08-2014 Steps to write & execute SAP program: Double click on SAP Logon on Desktop You will find a Logon Pad Double click on Development (121.241.50.175) Provide Client: 800 (only for practice purpose) User: user1 to user10 Password: Rgsabap You will find SAP Easy Access screen (Screen 0) On top of the screen you will find cursor blinking at Command Prompt (or) Command Field. Here you should type Transaction Codes (T Codes) in real time Next to Command Prompt you will find Standard Icons (Standard Application Tool Bar). Here you cannot add Customized Icons Under Standard Application Tool Bar you will find Text Area. It specifies documentation of current application Under Text Area you will find Customized Application Tool Bar when you can add your own icons apart from Standard ones Under Customize Application Tool Bar you will find Work Area where user performs his tasks (or) navigations Type SE38 in Command Prompt & press Enter Type program ZSD_Customer_Report Note: SAP is providing standard programs which starts with A,B,……………X. If you want to create ZPrograms (User Defined) start with Y (OR) Z Click on Create button Provide Title: Customer Details Report Provide Type: Executable Program Note: With Executable Program system will generate SAPGUI.EXE file Then press Enter you will find a pop-up here leave Package:___________ as blank Click on Local Object button Note-1: In real time Objects needs to be transported from Development client to Testing client & from Testing client to Production client. For that Objects should always be saved in a package. If an Object is saved in Local Object it cannot be transported between clients (Non Transportable Objects) Note-2: Local Object is meant for practicing Objects in real time Note-3: Rohini kumar
SAP-ABAP
16
All Executable Objects are Report Programs Note-4: On top of the program in Comment Section you should provide 1. Technical Consultant name 2. Functional Consultant name 3. Objective of the program 4. Transport Request number 5. Date of Creation (or) Change Writing Program: Report ZSD_Customer_Report -----------title of program Technical Consultant: Satya Function Consultant: Raja Objective: To display details of the Customer Transport Request Number: Not available because we not saved package Date of Creation: 20-08-2014
Comment Section
* provide Work Area --------- comment line DATA: BEGIN OF WA_KNA1, CUSTOMER(10) TYPE C, NAME(20) TYPE C, CITY(20) TYPE C, END OF WA_KNA1. * provide execution logic SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO WA_KNA1. * creating virtual page & printing WRITE:/10 WA_KNA1-CUSTOMER, 30 WA_KNA1-NAME, 60 WA_KNA1-CITY. * repeating SELECT statement ENDSELECT. Note: Once program is created 1. Check it for errors by pressing Ctrl+F2 2. Save it for backup by pressing Ctrl+S 3. Activate it for to store in Database Server by pressing Ctrl+F3 Activation of a Program: Rohini kumar
SAP-ABAP
17
Select Ctrl+F3 (or) Candle Icon to activate. You will find an Inactive Objects pop-up then press Enter With activation Objects are ultimately stored in Database Server With activation Objects can be integrated with each other in SAP Select F8 to execute a program 21-08-2014 Debugging:- Work Area Using debugging you can check (OR) test internal execution of a program It is an important tool for testing programs in real time Note: /H is T Code for debugging
Select Debugging button (shift+F5) By default you will find New Debugger Screen Select Debugger--switch to Classical Debugger Under Field Names: type wa_kna1-customer, wa_kna1-name, wa_kna1-city & press Enter Select F5 for single step debugging Select Display List option (ctrl+F12) to view Virtual page details. Select F3 again to switch from Virtual page view to Debugger Select F7 (or) F8 to execute
New Debugger: Currently in real time we are working with only New Debugger It is providing additional features compare to Old Debugger Working: Provide Program:_______ name Select Debugging button Select Desktop1 tab Under Variable: type wa_kna1-customer, wa_kna1-name, wa_kna1-city & press Enter Select F5 for single step debugging
Rohini kumar
SAP-ABAP
18
Tips for Writing a Program in Real Time: 1. Always start a program with Y (or) Z followed by Module name Ex-1: MM module ZMM_Material_Details Ex-2: SD module ZSD_Sales_Register Ex-3: HR module ZHR_Employee_Details 2. Provide Apt Title for a program 3. In real time always save the Object in a Package. But for practicing save Object in Local Object 4. Provide Comments in a program wherever require 5. Try to write your program as Neat as possible 6. Try to write your program in Capital letters 7. Always select Pretty Printer (shift+F1) option after writing a program 8. Always Activate your program once it is created Note: Only activated programs can be debugged Only activated programs can be integrated in SAP Only activated programs can be transported between clients 9. Always Debug your program once it is created for testing 10.Never delete section of a program always Comment it. For commenting select that section with mouse pointer & press Ctrl+< similarly to document select the same section with mouse pointer & press Ctrl+> 11.For Searching a specific keyword (or) ABAP statement select Find option in Standard Tool Bar then provide fine & press Enter 12.For Replacing ABAP keywords (or) statements select Ctrl+F you will find a pop-up Find What: KNA1 select Replace button provide Replace With: LFA1 select Replace All 13.To open new application by closing existing one type /NTCode Ex: /NSE38 14.To open sessions simultaneously type /OTCode Ex: /OSE11 in Command prompt Note: In SAP you can open maximum 6 sessions simultaneously 15.To logoff SAP type /NEX in Command prompt
Rohini kumar
SAP-ABAP
19
INTERNAL TABLES 2. Internal Table: Internal table is a temporary table created in RAM in Application Server It is created & filled with data during run time (execution time) Once execution is performed it is rolled out (or) discarded Note: Use Internal table for storing multiple records during run time Difference between Database table & Internal table: Database Table Internal Table 1. It is created in Database Server ------- 1. It is created in Application Server 2. It holds data permanently ------- 2. It holds data temporarily 3. It holds only specific type of data ----- 3. It holds data of different tables of at one place Que: What is exact purpose of Internal table. Do you think should be created in ABAP programming? Ans: In real time we are creating Internal table for storing different types of application data from different tables at one place Every Internal table is having 2 parts They are: 1. Internal Table Body 2. Header Line 1. Internal Table Body: The name Internal table itself specifies body of Internal table & it holds multiple records 2. Header Line: It is a default Work Area & holds single record Note: Header Line is system defined Work Area & Work Area is user defined Header Line Syntax: DATA: BEGIN OF it_kna1 OCCURS 0, customer(20) TYPE C, name(20) TYPE C, city(20) TYPE C, END OF it_kna1. Rohini kumar
SAP-ABAP
20
Note: 1. With above syntax an Internal table it_kna1 is crated in Application Server 2. You can provide any name. But in real time Internal table should always begins with it_ (or) i_ followed by table name 3. With BEGIN option Header Line is created & OCCURS option Body is created 4. 0, 1, 2, 3, …..9 is called Size Category 5. Both Header Line & Body name is same (it_kna1) Flow of Data in Internal Table: 1. Database Table ---- Body--- Header Line-- Virtual Page --- Presentation Server 2. Database Table --- Body--- Presentation Server
Rohini kumar
SAP-ABAP
22-08-2014 Reading Data from Body to Work Area (or) Header Line: 1. LOOP ……….. ENDLOOP 2. READ keywords 1. LOOP ……… ENDLOOP: It reads multiple records (record by record) from Body to Header Line (or) Work Area Syntax: LOOP AT it[INTO wa] [FROM m][TO n] [where codition]. ………… ………… ENDLOOP. LOOP AT it: Reads multiple records (record by record) from Body to Header Line Note: Internally system converts LOOP AT it as LOOP AT it INTO it. Working: Go to SE38 Program: ZSD_LOOPENDLOOP Select Create option Title; Internal Table Type: Executable Program Select Save option Leave Package:__________ blank Select Local Object option Pg)
REPORT ZSD_LOOPENDLOOP. * provide internal table DATA: BEGIN OF it_kna1 OCCURS 0, customer(20) TYPE C, name(20) TYPE C, city(20) TYPE C, END OF it_kna1. * provide extraction logic SELECT kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1. * Appling processing logic
Rohini kumar
21
SAP-ABAP
LOOP AT WRITE:/10 30 60 ENDLOOP.
22
it_kna1 INTO it_kna1. it_kna1-customer, it_kna1-name, it_kna1-city.
Note; Activate the program then select F8 to execute the program
Debugging: Internal Table Go to SE38 Program: ______ which you want to debug Select Debugging button Select Tables tab (starting from 6th option) Table: it_kna1 & press Enter
Note: You will find a Cap symbol which indicates Header Line (holds only single record) Select F5 for single step debugging Note: 1. Table keyword will transfer the data directly to Internal Table to Body 2. Always use Table keyword in select statement if you are working with Internal Tables 3. As long as you are in loop system will read next record in-line in an Internal Table. Once the loop is terminated again the loop starts reading from 1st line LOOP AT it INTO wa: Reads multiple records (record by record) from Body to Work Area Working: Go to SE38 Program: ZSD_INTERNAL_WORKAREA Select Create option Title: Internal Table & Work Area Type: Executable Program Select Save option Leave Package:__________ blank Select Local Object option
Rohini kumar
SAP-ABAP
Pg)
23
REPORT ZSD_ INTERNAL_WORKAREA. * provide internal table & work area TYPES: BEGIN OF ty_kna1, customer (20) TYPE C, name(20) TYPE C, city(20) TYPE C, END OF ty_kna1. DATA: wa_kna1 TYPE ty_kna1, it_kna1 TYPE TABLE OF ty_kna1. * provide extraction logic SELECT kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1. * Appling processing logic LOOP AT it_kna1 INTO wa_kna1. WRITE:/10 wa_kna1-customer, 30 wa_kna1-name, 60 wa_kna1-city. ENDLOOP.
Note: 1. Using TABLE OF you can create your own body 2. Using TYPES keyword Structures are created in ABAP programming 3. In ABAP programming always create Objet (Work Area & Body) based on Structures 4. Avoid creating Internal Table with OCCURS clause LOOP AT it INTO wa FROM m TO n: Reads multiple records from Body to Work Area based on given condition Example: 1. LOOP AT it INTO wa FROM 100. 2. LOOP AT it INTO wa FROM TO 50. 3. LOOP AT it INTO wa FROM 100 TO 200.
Rohini kumar
SAP-ABAP
23-08-2014 2. READ: It reads a single record from Body to Header Line (or) Work Area Syntax: READ TABLE it[INTO wa] [INDEX n][WITH KEY keyexpression] [TRANSPORTING fieldname] [Binary Serach] READ TABLE it: Reads a single record from Body to Header Line Ex: READ TABLE it INTO it. READ TABLE it INTO wa INDEX n: It reads a specific record (Line Number) from Body to Work Area Ex: READ TABLE it INTO wa INDEX 5. READ TABLE it INTO wa WITH KEY keyexpression: It reads a specific record which matches a given condition in Work Area Ex: READ TABLE it INTO wa WITH KEY customer=wa1-customer READ TABLE it INTO wa WITH KEY keyexpression TRANSPORTING ……….: Ex: READ TABLE it INTO wa WITH KEY customer=wa1-customer TRANSPORTING city (it will shows only city field) Binary Search: It reads data from Body to Work Area based on binary search algorithm Note: 1. Use binary search if Internal table is larze 2. Data should be sorted before Appling binary search algorithm 3. There should be no duplicate records in Internal Table 4. Binary search algorithm improves performance of programming
Rohini kumar
24
SAP-ABAP
25
SELECTION-SCREEN: Using Selection Screen you can create a selection screen based on given requirement (Input Values, Radio Buttons, Check Boxes…………..) Input Values: 1. You can create with ------ Select-Options 2. You can create with ------ Parameters 3. You can create with ------ Ranges 1. SELECT-OPTIONS: Using select-options you can create a selection screen with range of input values Syntax: SELECT-OPTIONS: s_kunnr for kna1-kunnr. With above syntax system will create a selection screen in the following manner S_kunnr
100 100
TO
200
With above syntax system will create an implicit Internal Table with following fields Low High Sign Option 100 200 I (including) BT (between) Note: The default comparison operator for select-options in ‘IN’ Pg) * provide tables work area TABLES kna1. * provide selection screen SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-009 SELECT-OPTIONS: s_kunnr FOR kna1-kunnr. SELECTION-SCREEN: END OF BLOCK b1. * provide objects TYPES: BEGIN OF ty_kna1, customer(20) TYPE C, name(20) TYPE C, city(20) TYPE C, END OF ty_kna1. DATA: wa_kna1 TYPE ty_kna1, It_kna1 TYPE TABLE OF ty_kna1. * provide extraction logic Rohini kumar
SAP-ABAP
26
SELECT kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1 WHERE kunnr IN s_kunnr. * Appling processing logic LOOP AT it_kna1 INTO wa_kna1. WRITE:/10 wa_kna1-customer, 30 wa_kna1-name, 60 wa_kna1-city. ENDLOOP. Text Elements: Using text elements (text-000 to text-009) you can provide field labels in selection screen Double click on Text-000 You will find a pop-up Yes Provide Text: Enter Customer Code Select Selection Texts tab Provide Text: Customer Code Activate the screen (Ctrl+F3) Go to back (F3) Note: Using Tables work area system will create a Work Area with all the fields of kna1 table. In programming it is mandatory to declare for declaring select-options Syntax for Creating Block: SELECTION-SCREEN: BEGIN OF BLOCK FRAME TITLE . …………….. ………………. SELECTION-SCREEN: END OF BLOCK .
Rohini kumar
SAP-ABAP
27
25-08-2014 Other SELECT-OPTIONS keywords: i) OBLIGATORY ii) NO INTERVALS iii) NO-EXTENSION iv) NO-DISPLAY i) OBLIGATORY: Using this addition you can make selection screen fields as Mandatory Syntax: SELECT-OPTIONS: s_kunnr FOR kna1-kunnr OBLIGATORY. ii) NO INTERVALS: Using no intervals you can remove high option from selection screen input field with selectoptions Syntax: SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO INTERVALS. iii) NO-EXTENSION: With this addition Multiple Selections option is removed from selection screen with selectoptions Syntax: SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO-EXTENSION. iv) NO-DISPLAY: With this addition selection screen input field will be hidden mode Syntax: SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO-DISPLAY. Working with Multiple Selection: Step-1: providing Random Values using Multiple Selection Execute your program Select Multiple Selection option Under Single Value provide values Select Clock symbol (F8) Execute (F8) Step-2: Providing Multiple Ranges using Multiple Selections Execute your program Select Multiple Selection option Under Select Ranges provide multiple ranges Select Clock symbol (F8) Rohini kumar
SAP-ABAP
28
Execute (F8) Step-3: Providing Excluding Random Values Execute your program Select Multiple Selection option Under Exclude Single Value provide values Select Clock symbol (F8) Execute (F8) Step-4: Providing Excluding Ranges Execute your program Select Multiple Selection option Under Exclude Ranges provide values Select Clock symbol (F8) Execute (F8) Step-5: Coping the Data from Excel sheet to Multiple Seletion Copy the data from Excel sheet (Ctrl+C) Select Multiple Selections option Press Ctrl+V (or) select second last button 2. PARAMETERS: Using parameters you can create a selection screen with single input value Syntax: PARAMETERS p_kunnr TYPE kunnr. (or) PARAMETERS p_kunnr LIKE kna1-kunnr. Note: 1. With above syntax system will define (or) create a selection screen in the following manner
P_kunnr
2. With above syntax no Internal Table is created by system 3. The default comparison operator for PARAMETERS is ‘EQ’
Rohini kumar
SAP-ABAP
29
Pg) * provide tables work area TABLES kna1. * provide selection screen SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-009 PARAMETERS p_kunnr TYPE kunnr. SELECTION-SCREEN: END OF BLOCK b1. * provide objects DATA: BEGIN OF wa_kna1, customer(20) TYPE C, name(20) TYPE C, city(20) TYPE C, END OF wa_kna1. * provide extraction logic SELECT SINGLE kunnr name1 ort01 FROM kna1 INTO wa_kna1 WHERE kunnr EQ p_kunnr. * Appling processing logic WRITE:/10 wa_kna1-customer, 30 wa_kna1-name, 60 wa_kna1-city. ENDSELECT. Note: 1. If you are not providing SINGLE addition with PARAMETERS for fletching a single record then it is mandatory to provide ENDSELECT 2. In real time never use SELECT with ENDSELECT (it reduces performance of the program) 3. RANGES: It work similar to SELECT-OPTIONS Syntax: RANGES s_kunnr FOR kna1-kunnr. Note: In new versions RANGES keyword is not allowed (it is out dated)
Rohini kumar
SAP-ABAP
Other Important Keywords for Internal Table: 1. APPEND keyword: It appends record from Work Area to Body Syntax: APPEND wa TO it. Pg) DATA: BEGIN OF wa, material(10) TYPE C, quan(10) TYPE C, END OF wa. DATA it LIKE TABLE OF wa. * fill data into it wa-material=’F001’. wa-quan=50. APPEND wa TO it. wa-material=’F002’. wa-quan=70. APPEND wa TO it. wa-material=’F002’. wa-quan=100. APPEND wa TO it. wa-material=’F001’. wa-quan=80. APPEND wa TO it. LOOP AT it INTO wa. WRITE:/10 wa-material, 30 wa-quan. ENDLOOP. 2. SORT keyword: It sorts Internal Table Body data based on ascending (or) descending Syntax: SORT BY ASCENDING (or) DESCENDING Note: The default order of sorting is ASCENDING Pg) DATA: BEGIN OF wa, material(10) TYPE C, quan(10) TYPE C, END OF wa. DATA it LIKE TABLE OF wa. * fill data into it Rohini kumar
30
SAP-ABAP
wa-material=’F001’. wa-quan=50. APPEND wa TO it. wa-material=’F002’. wa-quan=70. APPEND wa TO it. wa-material=’F002’. wa-quan=100. APPEND wa TO it. wa-material=’F001’. wa-quan=80. APPEND wa TO it. SORT it BY material ASCENDING. LOOP AT it INTO wa. WRITE:/10 wa-material, 30 wa-quan. ENDLOOP. 3. DELETE ADJACENT DUPLICATES keyword: Deletes adjacent duplicates from Internal Table Syntax: DELETE ADJACENT DUPLICATES FROM it COMPARING WHERE codition. Note: Before Appling above keyword it is mandatory to sort Internal Table Pg) DATA: BEGIN OF wa, material(10) TYPE C, quan(10) TYPE C, END OF wa. DATA it LIKE TABLE OF wa. * fill data into it wa-material=’F001’. wa-quan=50. APPEND wa TO it. wa-material=’F002’. wa-quan=70. APPEND wa TO it. wa-material=’F002’. wa-quan=100. APPEND wa TO it. Rohini kumar
31
SAP-ABAP
wa-material=’F001’. wa-quan=80. APPEND wa TO it. SORT it BY material. DELETE ADJACENT DUPLICATES FROM it COMPARING LOOP AT it INTO wa. WRITE:/10 wa-material, 30 wa-quan. ENDLOOP.
32
material.
26-08-2014 4. COOLECT Keyword: It provides summarized representation of data in an Internal Table Note: COLLECT checks the data based on Key Field (Character Field) in an internal table Body, if the record is not existing it will performs Append job, if it is already existing it will Add (Collects) Numeric Values based on Character Field inside the Body. Syntax: COLLECT wa INTO it. Pg) DATA: BEGIN OF wa, material(20) TYPE C, quan TYPE I, END OF wa. DATA: it LIKE TABLE OF wa, it1 LIKE TABLE OF wa. wa-material = ‘F001’. wa-quan = 50 APPEND wa TO it. wa-material = ‘F002’. wa-quan = 150 APPEND wa TO it. wa-material = ‘F001’. wa-quan = 550 APPEND wa TO it. wa-material = ‘F002’. wa-quan = 350 APPEND wa TO it. LOOP AT it INTO wa. COLLECT wa INTO it1. ENDLOOP. Rohini kumar
SAP-ABAP
33
LOOP AT it1 INTO wa. WRITE:/10 wa-material, 30 wa-quan. ENDLOOP. Ques-1: What is the difference between APPEND & COLLECT? Ans: APPEND keyword appends the record from Work Area to Body (always to next line in Internal Table). COLLECT keyword performs append job if the record fails to exist in the Body. If already exists it adds all Numeric Values on Right Side of Character Field inside the Body Ques-2: Whenever you will use COLLECT keyword in real time? Ans: Whenever I will get a requirement for providing consolidated totals based on customers, vendors, materials……..etc I will use COLLECT keyword Ques-3: Suppose there are more than one Character Fields then what is the rollback of COLLECT keyword? Ans: If there are two (or) more than two Character Fields it will Collect (add) the data only when both the Character Fields are same 5. MODIFY keyword: This keyword modifies Internal Table’s Body data based on given requirement Syntax: MODIFY it FROM wa [TRANSPORTING ……..] [INDEX n] [WHERE condition] Pg) DATA: BEGIN OF wa, material(20) TYPE C, quan TYPE I, unit(2) TYPE C, END OF wa. DATA it LIKE TABLE OF wa. wa-material = ‘F001’. wa-quan = 50 APPEND wa TO it. wa-material = ‘F002’. wa-quan = 150 APPEND wa TO it. wa-material = ‘F001’. wa-quan = 550 APPEND wa TO it. Rohini kumar
SAP-ABAP
34
wa-material = ‘F002’. wa-quan = 350 APPEND wa TO it. LOOP AT it INTO wa. wa-unit = ‘kg’. MODIFY it FROM wa TRANSPORTING unit. ENDLOOP. LOOP AT it INTO wa. WRITE:/10 wa-material, 30 wa-quan, 60 wa-unit. ENDLOOP. Note: 1. Always provide MODIFY with in LOOP………..ENDLOOP of the Internal Table which you want to modify 2. If you are providing MODIFY outside LOOP……..ENDLOOP then INDEX addition (or) WHERE condition is mandatory Ques-1: What is the difference between APPEND & MODIFY? Ans: APPEND always appends record to Internal Table (if record exists (or) not). MODIFY modifies (adds field value) only if records exists in an Internal Table Ques-2: When you will prefer MODIFY keyword in ABAP programming? Ans: When all the data in an Internal Table is filled and a new filed value is required to be added in Internal Table
Rohini kumar
SAP-ABAP
6. Deleting Data from Internal Table: i) FREE ii) REFRESH iii) CLEAR iv) DELETE i) FREE: It deletes Internal Table’s Body data along with memory Syntax: FREE it. (where it is Internal Table name) ii) REFRESH: It deletes Internal Table’s Body data but memory will not be affected Syntax: REFRESH it. iii) CLEAR: It deletes 1. Body data------- CLEAR it[ ]. 2. Work Area data------- CLEAR wa. 3. Ordinary Variable data --------- CLEAR total. Note: CLEAR it[ ] is applicable only where Internal Table is created with OCCURS clause Example: 1. CLEAR it[ ]. ------- deletes Header Line’s data 2. CLEAR it. -------- deletes Body’s data iv) DELETE: It deletes Body data based on requirement Syntax: DELETE it [INDEX n] [FROM m] [TO n] [WHERE condition] Example: 1. LOOP AT it INTO wa. DELETE it. ENDLOOP. 2. DELETE it INDEX 5. 3. DELETE it FROM 10 TO 20. 4. DELETE it WHERE material = ‘F001’ 27-08-2014 Rohini kumar
35
SAP-ABAP
7. DESCRIBE keyword: It returns the Count of number of records in an Internal Table Syntax: DATA n TYPE I. DESCRIBE TABLE it LINES n. Example: DATA: BEGIN OF wa, material(20) TYPE C, quan TYPE I, END OF wa. DATA it LIKE TABLE OF wa. DATA n TYPE I. wa-material = ‘F001’. wa-quan = 50. APPEND wa TO it. wa-material = ‘F002’. wa-quan = 150. APPEND wa TO it. wa-material = ‘F001’. wa-quan = 250. APPEND wa TO it. wa-material = ‘F002’. wa-quan = 350. APPEND wa TO it. DESRIBE TABLE it LINES n. WRITE n.
Rohini kumar
36
SAP-ABAP
37
8. Coping Data between Work Areas: i) MOVE keyword: It transfers (or) moves data from one Work Area to another Work Area if the Structures are same. Example: MOVE wa TO wa1. ii) wa1-material = wa-material. wa1-quan = wa-quan. iii) MOVE-CORRESPONDING keyword: It transfers (or) moves data from one Work Area to another Work Area if the Structures of both the Work Areas are different Example: MOVE-CORRESPONDING wa TO wa1. Note: In real time avoid using MOVE-CORRESPONDING instead use wa1-material = wa-material. wa1-quan = wa-quan.
Rohini kumar
SAP-ABAP
38
9. Coping Data between Internal Tables: i) LOOP AT it INTO wa. APPEND wa TO it1. ENDLOOP. ii) If Internal Tables are created with OCCURS clause it1[ ] = it[ ]. iii) APPEND LINES keyword: It performs, Copy the hold data from one Internal Table to another Internal Table (If there is no data in Target Internal Table) Appends the records at the end of another Internal Table (If Target Internal Table is already having some records) It adds the records from Source Internal Table to Target Internal Table based on given condition Syntax: APPEND LINES OF it [FROM m] [TO n] TO it1. Example: 1. APPEND LINES OF it TO it1. 2. APPEND LINES OF it FROM 2 TO 3 TO it1. Pg) * creating work area DATA: BEGIN OF wa, material(20) TYPE C, quan TYPE I, END OF wa. * creating bodies DATA: it LIKE TABLE OF wa, it1 LIKE TABLE OF wa. * appending data from work area to bodies wa-material = ‘F001’. wa-quan = 50. APPEND wa TO it. wa-material = ‘F002’. wa-quan = 150. APPEND wa TO it. wa-material = ‘F001’. wa-quan = 250. APPEND wa TO it1. wa-material = ‘F002’. wa-quan = 350. Rohini kumar
SAP-ABAP
39
APPEND wa TO it1. * coping data one body to another body APPEND LINES OF it TO it1. * displaying data of target body LOOP AT it1 INTO wa. ------------- CLEAR wa. WRITE:/10 wa-material, 30 wa-quan. ------------- CLEAR wa. ENDLOOP. Ques: What will happened if CLEAR is provided before WRITE & the same CLEAR is provided after WRITE? Ans: If CLEAR is provided before WRITE statements it will clear Work Area data so nothing is transformed from Work Area to Virtual page (Hence no output) If CLEAR is provided after WRITE statements data is transformed from Work Area to Virtual page then Work Area is cleared (Hence you will find output list)
Rohini kumar
SAP-ABAP
40
28-08-2014 Control Break Statements:- (Events) 1. AT FIRST 2. AT LAST 3. AT NEW 4. AT END OF 5. ON CHANGE OF Using these statements you can control the flow of ABAP programming statement with in the LOOP……………ENDLOOP AT FIRST: It triggers during first loop iteration (first loop pass) Syntax: AT FIRST. ---------------------ENDAT. Note: Use AT FIRST for providing Headers in ABAP Report AT LAST: It triggers for last line of an Internal Table (or) It triggers during last loop iteration Syntax: AT LAST. ---------------------ENDAT. Note: Use AT LAST for printing Grand Totals in a Report AT NEW: It triggers for a group of similar contents (based on Character Value) in an Internal Table. (or) It triggers whenever there is a change in field values in an Internal Table based on Character Value Syntax: AT NEW . ---------------------ENDAT. Note: Rohini kumar
SAP-ABAP
41
Use AT NEW for printing unique values for key fields in an Internal Table AT END OF: It will triggers the end of group of similar values in an Internal Table based on Character Field Syntax: AT END OF . ---------------------ENDAT. Note: Use AT END OF for returning grand totals in an Internal Table ON CHANGE OF: It works similar to AT NEW Syntax: ON CHANGE OF . ---------------------ENDON. Note: 1. Due to some draw backs currently we are not using ON CHANGE OF 2. You should provide above Control Break Statements within the LOOP……..ENDLOOP 3. Don’t provide any conditional statements (IF, CASE,…….etc) with in Control Break Statements Requirement: Material Details Report --------- AT FIRST The Material Cod is: F001 50 5000 100 10000 The Total Quantity is: 150 AT NEW The Total Amount is: 15000 The Material Cod is: F002 70 6000 100 12000 The Total Quantity is: 170 The Total Amount is: 18000 The Grand Total Quantity is: 320 The Grand Total Amount is: 33000 Solution: * creating work area Rohini kumar
AT END OF
---------AT LAST
SAP-ABAP
DATA: BEGIN OF wa, material(10) TYPE C, quan TYPE I, amount TYPE I, END OF wa. * creating internal table DATA it LIKE TABLE OF wa. * filling data into it wa-material = ‘F001’. wa-quan = 50. wa-amount = 5000. APPEND wa TO it. wa-material = ‘F002’. wa-quan = 70. wa-amount = 6000. APPEND wa TO it. wa-material = ‘F001’. wa-quan = 100. wa-amount = 10000. APPEND wa TO it. wa-material = ‘F002’. wa-quan = 100. wa-amount = 12000. APPEND wa TO it. * sorting it by material SORT it BY material. * appling Control Break Statements LOOP AT it INTO wa. AT FIRST. WRITE:/50 ‘Materials Details Report’ COLOR 1. SKIP. ULINE. ENDAT. Rohini kumar
42
SAP-ABAP
43
AT NEW material. WRITE:/ ‘The Material Code is:’, wa-material. SKIP. ENDAT. WRITE:/10 wa-quan, 30 wa-amount. AT END OF material. SUM. WRITE:/ ‘The Total Quantity is:’, wa-quan, / ‘The Total Amount is:’, wa-amount. ULINE. ENDAT. AT LAST. SUM. WRITE:/ ‘The Grand Total Quantity is:’, wa-quan, / ‘The Grand Total Amount is:’, wa-amount. ULINE. ENDAT. ENDLOOP. 30-08-2014 Ques: What is the difference between SUM & COLLECT keywords? Ans: COLLECT keyword is applicable LOOP……….ENDLOOP without usage of Control Break Statements COLLECT keyword performs totals inside internal table body based on one (or) more than one Character Values SUM keyword performs totals only one Single Character Value for Control Break Statements places the values in Work Area COLLECT keyword works outside LOOP………ENDLOOP also where as SUM keyword can be applied only with in LOOP………ENDLOOP
Rohini kumar
SAP-ABAP
44
INSERT keyword: Inserts Work Area data at a specific index position inside Internal Table Body Syntax: INSERT INTO Syntaxes for Internal Tables: 1. NO DATA: BEGIN OF material(10) quan END OF Note: Both Header Line & Body created
INDEX .
OCCURS TYPE C, TYPE I, .
0,
2. DATA TYPE OCCURS 0. Note: Only Body created based on all fields of database table 3. DATA TYPE OCCURS 0 WITH HEADERLINE. Note: Both Body & Header Line created 4. TYPES: BEGIN OF customer(10) name(10) city(10) END OF
ty_kna1, TYPE C, TYPE C, TYPE C, ty_kna1.
DATA: TYPE TYPE
, TABLE OF .
Note: Work Area & Body created based on Sturcture 5. TYPES: BEGIN OF ty_kna1, customer(10) TYPE C, name(10) TYPE C, city(10) TYPE C, END OF ty_kna1. DATA TYPE Note: Rohini kumar
TABLE
OF
INITIAL SIZE 0.
SAP-ABAP
45
The above Body is created when you transfer whole Body data to another Body Example: it1[ ] = it[ ]. System Fields for Internal Table: SAP is providing system variables maintained in a structure SYST There are 171 system variables in the structure & all system variables start with a prefix SY Example: 1. SY-DATUM----returns current system data 2. SY-UNAME----returns current login user name 3. SY-UZEIT------returns current time 4. SY-DATUM----returns current system data 5. SY-LANGU----returns current login language 6. SY-TABIX-----returns current LOOP pass 7. SY-TOCCU----returns OCCURS value 8. SY-TLENG----returns size of internal table 9. SY-TFILL----returns count of number of records in an internal table (it works like DESCRIBE keyword) Example: * creating internal table DATA: BEGIN OF it OCCURS 0, material(10) TYPE C, quan TYPE I, amount TYPE I, END OF wa. * creating variable DATA n TYPE
I.
* filling data into it wa-material = ‘F001’. wa-quan = 50. wa-amount = 5000. APPEND it TO it. wa-material = ‘F002’. wa-quan = 70. wa-amount = 6000. APPEND it TO it. wa-material = ‘F001’. wa-quan = 100. wa-amount = 10000. Rohini kumar
SAP-ABAP
APPEND it TO it. wa-material = ‘F002’. wa-quan = 100. wa-amount = 12000. APPEND it TO it. * counting number of records in internal table DESCRIBE TABLE it LINES n. WRITE:/ ‘size of it:’, SY-TLENG, / ‘number of records:’, SY-TFILL, / ‘OCCURS value:’, SY-TOCCU.
Rohini kumar
46
SAP-ABAP
47
DML Operations on Database Table: a) INSERT b) UPDATE c) DELETE Inserting Data into Database Table: MODIFY keyword: It will insert records in database table if they are not existing & performs modify operation if they are already existing Syntax: 1. MODIFY 2. MODIFY
FROM TABLE FROM TABLE
Example-1: TABLES kna1. DATA: wa TYPE kna1, It TYPE TABLE OF kna1. wa-kunnr = ‘0000009083’. wa-name1 = ‘rahul’. wa-ort01 = ‘mumbai’. wa-pstlz = ‘400002’. APPEND wa TO it. MODIFY kna1 FROM TABLE it. WRITE:/
‘ number of records inserted:’, SY-DBCNT.
Example-2: LOOP AT it INTO wa. MODIFY kna1 FROM wa. ENDLOOP. UPDATE keyword: Updates specific fields based on given requirement Syntax: UPDATE SET field1 = wa-filed1, field2 = wa-field2………. ………….. WHERE . Rohini kumar
SAP-ABAP
48
Example: LOOP AT it INTO wa. UPDATE kna1 SET ort01 = wa-orto1, pstlz = wa-pstlz ENDLOOP.
WHERE kunnr = wa-kunnr.
DELETE keyword: Deletes database tables data based on given requirement Syntax: 1. DELETE 2. DELETE
FROM TABLE . FROM WHERE
Example-1: DELETE kna1 FROM TABLE it. WRITE:/ ‘number of records deleted:’, SY-DBCNT. Example-2: LOOP AT it INTO wa. DELETE FROM kna1 WHERE kunnr = wa-kunnr. ENDLOOP. Example-3: DELETE FROM
kna1 WHERE kunnr = ‘0000009083’.
INSERT keyword: Inserts data into database table Syntax: INSERT INTO
Rohini kumar
VALUES .
SAP-ABAP
49
Types of Internal Tables: 1. Standard Table 2. Hashed Table 3. Sorted Table 4. Index Table Note: The default Internal Table is Standard Assignments-1: Sno 100 101 102
Sname satya pruthvi raj
Phy 70 80 90 240
Assignment-2: Material Quan F001 50 F001 100 F002 70 F002 150
Students Details Report Chem Maths Total 60 90 220 70 60 210 80 80 250 210 230 680
F001 F002
150 220
Hint: 1. Create 3 Internal Tables 2. Use DELETE ADJACENT DUPLICATE keyword 3. Use CLEAR keyword
Rohini kumar
SAP-ABAP
50
01-09-2014
Data Dictionary It is also called ABAP Dictionary It is a repository of data T Code for Data Dictionary is SE11 Objects in Data Dictionary: 1. Database Table 2. Structure 3. View 4. Data Element 5. Domain 6. Table Type 7. Type Group 8. Lock Object 9. Search Help Database Table: It is a set of fields which holds data persistently Data Element: Using Data Element you can provide field documentation for a specific field Conceptually Data Element = Field Lable + Domain Domain: It specifies the technical attributes of a field (Data Type & Field Size) Ques-1: Have ever created a Zee table in real time? Ans: Yes Ques-2: SAP is providing so many tables then why you created a table? Ans: SAP is not providing table for Allowances, Similarly SAP is not providing a table for Transportation Details. Example: Delivery challana number, date, truck number……….etc Similarly in real time we have to create a table for Customer mail ids for sending invoice details…….etc
Rohini kumar
SAP-ABAP
51
Table Creation: Go to SE11 Provide Title: ZMM_TR Select Create option Provide Short Description: Truck Entry Details Note: In real time we are working with application data. Application data is 2 types 1. Master Data 2. Transactional Data Master Data: It is created only once in Client Database & modified very rarely Example: Bank Master Data, Customer Master Data, Vendor Master Data, Employee Master Data…etc Transactional Data: It is always created based on Master Data It is modified frequently in SAP database Example: Purchase Order Data, Sales Order Data………..etc Delivery Class: It specifies the type of data a table can hold A-------specifies Application Data Provide Table View Maintenance: Display Maintenance Allowed (both display & create entries is allowed) Select Fields tab Field key Data Element TRNO ZTR_DAT Double click on ZTR_DAT You will find a message pop-up select Yes option Select Local Object option Again you will find a warning: application table should be client specific the press Enter You will find a pop-up: create the data element then click Yes Provide Short Description: Truck Number Provide Domain: ZTR_Domain Double click on Domain Name (ZTR_Domain) Click Yes Select Local Object Note: Rohini kumar
SAP-ABAP
52
$TMP is a default package for non-transportable object (local object) You will find a pop-up: create the domain click Yes Provide Short Description: Domain for Truck Field Data Type: CHAR No. Characters: 10 Activate the domain (Ctrl+F3) Select Local Object Go to back (F3) Select Field Label tab Length field lable Short 10 trno Medium 20 Truck Number Lang 40 Truck Number Heading 50 Truck Number Activate data element (Ctrl+F3) Go to back (F3) Field key data element Ddate LFDAT Driver ZDR_DAT Double click on ZDR_DAT Save Yes You will find a warning pop-up: Enter You will find a pop-up: create data element Yes Provide Short Description: Driver Name Provide Domain: CHAR20 Select Field Label tab Provide Short Description: Driver Name Length field lable Short 10 Dname Medium 20 Driver Name Lang 40 Driver Name Heading 50 Driver Name Activate data element (Ctrl+F3) Go to back (F3) Select Technical Settings button Provide Data Class: APPL0 (APPL0---for master data & APPL1---for transactional data) Provide Size Category: 0 (it means table holds up to 8000 records) Select Save option (Ctrl+s) Select back (F3) Activate Table (Ctrl+F3) During activation you will find a warning pop-up select Yes Rohini kumar
SAP-ABAP
Ignore the warnings & go back (F3) Step-1: Navigation for Inserting Records into a Table: Select Utilites---Table Contents---Create Entries TRNO:_______ Ddate:_________ Driver:_________ Save (Ctrl+S) Select Reset button for new record Step-2: Navigation for Viewing Records in a Table: Select Utilities---Table Contents---Display Select Clock symbol (F8)
Rohini kumar
53
SAP-ABAP
02-09-2014 Structure: It is a group of fields Physically it will never hold any data Structure can be reuse in other programs & other tables Differences between Structure & Table: Structure Table 1. It is a collection of fields & it 1. It is a Structure & hold data persistently Never hold data 2. It can be reuse in other tables 2. It cannot be reuse Difference between .INCLUDE & APPEND STRUCTURE: Using .include you can add a Structure in N no. of tables .include is best for adding Structure in ZEE tables Using Append Structure you can add a Structure only in a single table Append Structure is best for adding Structure in Standard Tables Structure Creation: Go to SE11 Select Data Type: ZMM_Order Select Create option You will find a pop-up select Structure option & press Enter Provide Short Description: Order Fields Provide Component: EBELN BEDAT Provide Component Type: EBELN BEDAT Activate structure (Ctrl+F3) Select Local Object You will find warnings pop-up then select Yes Ignore warnings & go back (F3) Navigation for Including a Structure in a Table: Go to SE11 Provide Database Table: ZMM_TR Select Change option Under Field: .include Under Data Element: ZMM_Order Activate table (Ctrl+F3) Select Contents option Select Clock symbol (F8) Rohini kumar
54
SAP-ABAP
55
Select SelectAll option (F9) Select Change option (F6) Add data & save (Ctrl+S) Select Next Entry option for next record
Primary & Foreign key Relationship: SAP is a tightly integrated package. In SAP between all the tables there is a relationship called Primary & Foreign key Relationship. Condition (or) Pre represents for maintaining a Relationship between Two Tables: In SAP if you want to create relationship between two tables there should be Key Field with common data between tables even the fields are not common there should be common data between two tables Establishing Relationship between Two Tables: Go to SE11 Provide Database Table: ZMM_DCTR Select Create option Provide Short Description: Challana Details Delivery Provide Delivery Class: A Provide Table View Maintenance: Display Maintenance Allowed Select Fields tab Field Key Data Element
MANDT MANDT DCNO ZDAT_DC Double click on ZDAT_DC Click on Yes, Local Object & Yes Provide Short Description: Data Element for DC Provide Domain: CHAR10 Select Field Label option Medium: 20 Field Label: Delivery Challana Activate Field (Ctrl+F3) Like add all required fields (DCdate, TRNO) Select TRNO field Select Foreign Keys option You will find a pop-up provide Short Text: Relationship Check Table: ZMM_TR Select Generate Proposal button Select Enter option Provide Field: .include
Rohini kumar
SAP-ABAP
56
Data Element: ZMM_Order (it provides EBLEN, BEDAT fields) Select Technical Settings option Provide Data Class: APPL1 (for Transactional data) Size Category: 0 (for upto 8000 records) Select Save option (Ctrl+s)
Data Class: It is a physical storage location (or) table space where tables are stored ultimately after activation. It is of 3 types 1. APPL0 (holds master data tables) 2. APPL1 (holds transactional data tables) 3. APPL2 (holds organizational & customizing data related tables) Size Category: It specifies the probable space requirement for a table in the database Go to back (F3) Activate the table (Ctrl+F3) Select Content option Apply F4 on Truck Number field You will find data related to Check Table Go to back (F3) Select Utilities--Table Contents--Create Entries Note: In real time we are not creating any relationships between tables Ques: What is the difference between Client Dependant & Client Independent tables? Ans: A table created without MANDT field is Client Independent table. Client Independent tables are available in other clients also with data A table created with MANDT field is Client Dependant table. Client Dependent tables are available in other clients also without data Note: In real time it is always advisable to create Client Dependant tables
Rohini kumar
SAP-ABAP
57
View: It is a logical table (virtual table) which is created based on other tables It hires Fields & Data from other tables Difference between Table & View: Table 1. Having its own fields & data 2. It holds either master data (or) Transactional data
View 1. Always created based on other table 2. It holds both master data & transactional data
Types of Views: 1. Database View 2. Projection View 3. Help View 4. Maintenance View Database View: It is always created based on two (or) more than two tables having relationship between them Database View Creation: Go to SE11 Select View option: ZMM_DNTR Select Create option You will find a pop-up select Database View Provide Short Description: Database View Tables: ZMM_TR ZMM_DCTR Select Relationships button You will find a pop-up double click on Check Box under referenced table heading & press Enter Select View Flds option Select Tables Fields option Double click on ZMM_TR Select all fields & press Enter Select Tables Fields option Double click on ZMM_DCTR Select DCNO, DCdate & press Enter Activate view (Ctrl+F3)
Rohini kumar
SAP-ABAP
58
Testing Database View: Select Contents option Select Clock symbol (F8) Note: View always holds common data (linked data between two (or) more than two tables) 03-09-2014 Projection View: It created based on a single table with specific fields Projection View Creation: Go to SE11 Select View option: ZPROJ_VIEW Select Creation option You will find a pop-up select Projection View option then press Enter Provide Short Description: Projection View Provide Basis Table: KNA1 Select Table Fields tab You will find all fields of KNA1 table then select KUNNR, NAME1, ORT01, PSTLZ then press Enter Activate view (Ctrl+F3) Testing Projection View: Select Contents option Click Clock symbol (F8)
Rohini kumar
SAP-ABAP
59
Search Help: Using search help you can search application data based on given search criteria Search help works based on F4 function key Note: In a table (or) tables there is large volume of application data. Manual search of data will take lot of time. SAP is providing an option called Search Help for searching data as for requirement Types of Search Help: 1. Elementary Search Help 2. Collective Search Help Elementary Search Help: It is always created based on a single table Creation of Elementary Search Help-1: Go to SE11 Select Search Help: ZELE_TRSEARCH Select Create option You will find a pop-up then select Elementary Search Help then press Enter Provide Short Description: Elementary Search Help for Truck Details Selection Method: ZMM_TR (table name) Search Help Parameter Import Export LPOS SPOS TRNO _/ _/ 1 1 DDATE _/ _/ 2 2 EBLEN _/ _/ 3 3 BEDAT _/ _/ 4 4 DRIVER _/ _/ 5 5 Activate search help (Ctrl+F3) Testing Search Help: Select F8 You will find a pop-up then press Enter Creation of Elementary Search Help-2: Go to SE11 Select Search Help: ZELE_DMSEARCH Select Create option You will find a pop-up then select Elementary Search Help then press Enter Provide Short Description: Elementary Search Help for Delivery Challana Details Selection Method: ZMM_DCTR (table name) Search Help Parameter Import Export LPOS SPOS DCNO _/ _/ 1 1 Rohini kumar
SAP-ABAP
DCDATE _/ _/ Activate search help (Ctrl+F3) Testing Search Help: Select F8 You will find a pop-up then press Enter
60
2
2
Collective Search Help: It is a group of two (or) more than two Elementary Search Help contained to form a Collective Search Help Creation of Collective Search Help: Go to SE11 Select Search Help: ZCOLL_TRDM Select Create option You will find a pop-up then select Collective Search Help option then press Enter Provide Short Description: Collective Search Help for DC details Select Included Search Help tab Provide Search Help: ZELE_TRSEARCH ZELE_DMSEARCH Activate search help Testing Collective Search Help: Select F8 You will find a pop-up then press Enter Calling a Search Help in an ABAP Program: Syntax: PARAMETERS MATCHCODE OBJECT Example: PARAMETERS p_tr MATCHCODE OBJECT ZELE_TRSEARCH Note: In real time calling a search help using MATCHCODE OBJECT is outdated Adding a Search Help in a Table: Go to SE11 Provide Database Table: ZMM_TR Select Change option Place cursor on TRNO field & select Srch Help option Provide Search Help Name: ZELE_TRSEARCH Select Yes & then Yes Activate table (Ctrl+F3) Rohini kumar
SAP-ABAP
Testing: Select Contents option Apply F4 on TRNO field You will find an error then Go to SE38 Provide Program: ZMM_TR Select Create option Write PARAMETERS p_tr TYPE ZMM_TR-TRNO. Activate program then go back & test the table
Rohini kumar
61
SAP-ABAP
62
Table Maintenance Generator (TMG): Using TMG you can directly Insert, Update, Delete data from a database table Note: 1. In real time for certain requirements when data is not linked with other tables. Data can be inserted (or) manipulated from table level directly. This can be done by creating a TMG on that table 2. TMG is allowed only for ZEE tables Creation of Table Maintenance Generator: Create Table First: Go to SE11 Provide Database Table: ZSD_MAIL Select Create option Provide Short Description: Customer Mail Table Provide Delivery Class: A Provide Table View Maintenance: Display Maintenance Allowed (both display & create entries is allowed) Select Fields tab Field key Data Element MANDT _/ MANDT KUNNR _/ KUNNR MAILID _/ ZMAIL_DAT Double click on ZMAIL_DAT You will find a message pop-up select Yes option Select Local Object option Again you will find a warning: application table should be client specific the press Enter You will find a pop-up: create the data element then click Yes Provide Short Description: Customer Mail Id Provide Domain: CHAR Select Field Label tab Length field lable Medium 20 Mail Id Activate data element (Ctrl+F3) Go to back (F3) Field key data element INDICATOR _/ Z_INDICATOR Double click on Z_INDICATOR Save Yes You will find a warning pop-up: Enter You will find a pop-up: create data element Yes Provide Short Description: Indicator Rohini kumar
SAP-ABAP
63
Provide Domain: CHAR20 Select Value Range tab FIX VAR Short Desciption 1 TO 2 CC 3 BCC Activate the domain (Ctrl+F3) Go to back (F3) Select Field Label tab Provide Short Description: Indicator Length field lable Medium 20 Indicator Activate data element (Ctrl+F3) Go to back (F3) Select Technical Settings button Provide Data Class: APPL0 (APPL0---for master data & APPL1---for transactional data) Provide Size Category: 0 (it means table holds up to 8000 records) Select Save option (Ctrl+s) Select back (F3) Activate Table (Ctrl+F3) During activation you will find a warning pop-up select Yes Ignore the warnings & go back (F3) Creating TMG: Go to SE80 Under Test Repository select Function Group option Provide Function Group: ZMAIL_GR then press Enter You will find a pop-up create object press Yes Again you will find a pop-up Short Text: Mail Group then press Enter Select Local Object
Go to SE11 Provide Database Table: ZSD_MAIL Select Change option Select Utilities---Table Maintenance Generator Provide Authorization Group: &NC& Provide Function Group: ZMAIL_GR Select One Step option Select Scr Number(s) button You will find a pop-up select Propose Screen Number option then press Enter Select Create option (F6)
Rohini kumar
SAP-ABAP
64
Select Save option (Enter) Select Local Object (Enter) Creating TCode: Go to SE93 Provide Transaction Code: ZMAIL Select Create option Provide Short Text: Customer Mail Details Select Transaction with Parameters (Parameter Transaction) option then press Enter Provide Transaction: SM30 Scroll down to bottom then provide Name of Screen Field Value ViewName SZD_MAIL Update X Save (Ctrl+s) Select Favorites---Inset Transaction Provide Transaction Code: ZMAIL then press Enter Testing TMG: Provide Run TCode: ZMAIL then press Enter Provide Table: ZSD_MAIL Select Maintain option Select New Entries button Insert records & save Navigation for maintain Default Values using TMG: Sometimes Date, User name, Time needs to be entered in a table. These values will not be inserted by client (inserted automatically by system) Create Table First: Go to SE11 Provide Database Table: ZFI_LIMITS Select Create option Provide Short Description: Bank Limits Provide Delivery Class: A Provide Table View Maintenance: Display Maintenance Allowed (both display & create entries is allowed) Select Fields tab Field key Data Element MANDT _/ MANDT COUNTER _/ INT1 Bank Name _/ BANKA Amount DMBTR Rohini kumar
SAP-ABAP
65
ERDAT ERDAT Uname ZUSER ERTIM ZTIMEDAT Select Currency Quantity Fields tab Provide Amount: Reference Table Reference Field T001 WAERS Select Technical Settings button Provide Data Class: APPL0 (APPL0---for master data & APPL1---for transactional data) Provide Size Category: 0 (it means table holds up to 8000 records) Select Save option (Ctrl+s) Select back (F3) Activate Table (Ctrl+F3) During activation you will find a warning pop-up select Yes Ignore the warnings & go back (F3) Providing default values using TMG: Select Utilities---Table Maintenance Generator Provide Authorization Group: &NC& Provide Function Group: ZMAIL_GR Select Find Scr Number option then press Enter Select Create option (F6) then press Enter Select Environment option Select Modification------Events You will find a message- do not make any changes on SAP data then press Enter Select New Entries option provide T Form Routine 05 Create_Entry Press Enter Under Editor double click You will find a pop-up then press Enter You will find a warnings pop-up then press Enter Provide code for default values FORM CREATE_ENTRY. ZFI_LIMITS-ERDAT = SY-DATUM. ZFI_LIMITS-UNAME = SY-UNAME. ZFI_LIMITS-ERTIM = SY-UZETT. ENDFORM. Activate table & go back Testing: Go to SM30 Provide Table: ZFI_LIMITS Rohini kumar
SAP-ABAP
Select Maintain option Select New Entries option Insert records & Save You will find a dump note: SAPLZMAIL_GR
Go to SE38 Provide Program: SAPLZMAIL_GR Select Change option Activate the program (Ctrl+F3)
Go to SM30 Provide Table: ZFI_LIMITS Select Maintain option Select New Entries option Insert records & Save
66
04-09-2014 Adding Check boxes in Table in TMG: Create Table First: Go to SE11 Provide Database Table: ZPP_MACHINE Select Create option Provide Short Description: Machine Down Time Provide Delivery Class: A Provide Table View Maintenance: Display Maintenance Allowed (both display & create entries is allowed) Select Fields tab Field key Data Element MANDT _/ MANDT MACHNO _/ ZMACH_DAT BUDAT _/ BUDAT STIME ZSTART_DAT ETIME ZEND_DAT DTIME ZDOWN_DAT CHK ZCHK_DAT
Double click on ZCHK_DAT Save Yes You will find a warning pop-up: Enter You will find a pop-up: create data element Yes Provide Short Description: Check Box Provide Domain: ZCHK_DOMAIN
Rohini kumar
SAP-ABAP
67
Provide Data type: CHAR Provide No.of Characters: 1 Select Value Range tab FIX VAR Short Desciption X ON OFF Activate the domain (Ctrl+F3) Go to back (F3) Select Field Label tab Provide Short Description: Check Box Length field lable Medium 20 Check Activate data element (Ctrl+F3) Go to back (F3) Select Technical Settings button Provide Data Class: APPL0 (APPL0---for master data & APPL1---for transactional data) Provide Size Category: 0 (it means table holds up to 8000 records) Select Save option (Ctrl+s) Select back (F3) Activate Table (Ctrl+F3) During activation you will find a warning pop-up select Yes Ignore the warnings & go back (F3) Providing Check boxes using TMG: Select Utilities---Table Maintenance Generator Provide Authorization Group: &NC& Provide Function Group: ZMAIL_GR Select Find Scr Number option then press Enter Select Create option (F6) then press Enter Select Environment option Select Modification------Events You will find a message- do not make any changes on SAP data then press Enter Select New Entries option provide T Form Routine 05 Create_Entry Press Enter Under Editor double click You will find a pop-up then press Enter You will find a warnings pop-up then press Enter Provide code for default values FORM CREATE_ENTRY. Rohini kumar
SAP-ABAP
68
ZDOWN_DAT = ZEND_DAT - ZSTART_DAT. ENDFORM. Activate table & go back Creating TCode: Go to SE93 Provide Transaction Code: ZDOWN Select Create option Provide Short Text: Machine Down Time Select Transaction with Parameters (Parameter Transaction) option then press Enter Provide Transaction: SM30 Scroll down to bottom then provide Name of Screen Field Value ViewName SPP_MACHINE Update X Save (Ctrl+s) Select Favorites---Inset Transaction Provide Transaction Code: ZDOWN then press Enter Testing: Go to SE38 Provide Program: SAPLZDOWN Select Change option Activate the program (Ctrl+F3)
Go to SM30 Provide Table: ZPP_MACHINE Select Maintain option Select New Entries option Insert records & Save
Rohini kumar
SAP-ABAP
69
Text Table: Use text table for storing explanatory texts. For storing such texts it is not advisable to store in Primary Table Note: Text Tables works based on Primary & Foreign key relationship Creation of Text Table: First Create Primary Table: Go to SE11 Provide Database Table: ZTEXT_TAB Select Create option Provide Short Description: Department Table Provide Delivery Class: A Provide Table View Maintenance: Display Maintenance Allowed (both display & create entries is allowed) Select Fields tab Field key Data Element MANDT _/ MANDT DEPT _/ ZDEPT_DAT Select Technical Settings button Provide Data Class: APPL0 (APPL0---for master data & APPL1---for transactional data) Provide Size Category: 0 (it means table holds up to 8000 records) Select Save option (Ctrl+s) Select back (F3) Activate Table (Ctrl+F3) During activation you will find a warning pop-up select Yes Ignore the warnings & go back (F3) Creating Text Table: Go to SE11 Provide Database Table: ZTEXT_TAB1 Select Create option Provide Short Description: Department Text Provide Delivery Class: A Provide Table View Maintenance: Display Maintenance Allowed (both display & create entries is allowed) Select Fields tab Field Rohini kumar
key
Data Element
SAP-ABAP
MANDT SPRAS DEPT DESC1
70
_/ _/ _/
MANDT (for client dependant table) SPRAS (for language selection) ZDEPT_DAT MAKTX
Select Technical Settings button Provide Data Class: APPL0 (APPL0---for master data & APPL1---for transactional data) Provide Size Category: 0 (it means table holds up to 8000 records) Select Save option (Ctrl+s) Select back (F3) Activate Table (Ctrl+F3) During activation you will find a warning pop-up select Yes Ignore the warnings & go back (F3)
Select SPRAS Select Foreign keys option You will find a pop-up then press Yes & then press Enter Select DEPT Select Foreign keys option Provide Check Table: ZTEXT_TAB Select Generate Proposal button At bottom select Keys Fields of a Text Table option Provide Cardinality 1:N then press Enter Select MANDT Select Foreign keys option You will find a pop-up then press Yes & then press Enter Activate table (Ctrl+F3)
Testing Text Table: Go to SE11 Provide Database Table: ZTEXT_TAB (primary table name) Select Change option Select Utilities----Table Contents----Create Enteries Here you will find text table options also then provide text & save
Rohini kumar
SAP-ABAP
Some Important Steps for Working with Standard Tables: Go to SE11 Provide Database Table: KNA1 Select Display option Select Contents option Step-1: Navigation for Getting Selected Fields in Output List: Select Settings---Format List----Choose Fields option By default all fields are selected then select Deselect option (Shift+F2) Select required fields KUNNR, NAME1, ORT01, PSTLZ then Enter Execute (F8) Step-2: Adding (or) Removing Fields from Selection Screen: Select Settings---Fields for Selection option Select & deselect fields based on requirement then Enter Step-3: Transforming Data from SAP to Local File (XL Sheet): Select F8 Select Local File option (last from 5th option) (Ctrl+Shift+F9) You will find a pop-up select Spread Sheet option then Enter You will find a pop-up apply F4 on Directory field You will find a pop-up then select Desktop Provide File Name: Customer then select Save option Select Generate option
Rohini kumar
71
SAP-ABAP
72
05-09-2014 Types of Tables: 1. Transparent Table 2. Cluster Table 3. Pooled Table Transparent Table: It is a default table in SAP It holds application data (master data & transactional data) It follows one-to-one relationship (a table created in Presentation Server, if with the same Structure & Fields another table created in Database Server) These tables can be accessed even outside SAP This table allows both Open SQL & Native SQL statements In real time we are mostly working with Transparent Table Pooled Table & Clustered Table: These tables holds SAP proprietary format data (system data, statistical data, control data……) These tables allows (or) follows many-to-one relationship (many tables data combined to form a Pooled Table & Clustered Table) These tables cannot be accessed outside SAP These tables allows only Open SAL statements Very rarely we are using these tables (most common tables used one BSEG, KONU) Note: You cannot apply Inner-Join statement on Cluster Table
Rohini kumar
SAP-ABAP
73
Open SQL & Native SQL Statements: Native SQL Statements: These are traditional SQL statements With Native SQL Statement request is directly forwarded to Database Server which processes the request & returns the response With Native SQL statement performance of the system is highly degraded Syntax: EXEC SQL. SELECT……………… ENDEXECSQL. Open SQL Statements: These are normal SQL statements which are converted to embedded SQL using database interface which is further passed to Buffer, if data is available in Buffer you will get the response
Rohini kumar
SAP-ABAP
74
Buffering Concept: Buffering is a way of improving performance which accessing data from database. Whenever you run a program it will make a request to Buffer for data, if it is not available it will make a request to Database Server which returns response to Buffer & simultaneously to Program. Next time whenever you run the same program this time it will collect the data directly from Buffer Note: Buffering is important for frequent & common accessing of application data Types of Buffering: 1. Single Record Buffering 2. Generic Buffering 3. Full Buffering Single Record Buffering:(SELECT SINGLE) This buffering is used for frequent access of data from database. Here volume of data is very large Generic Buffering:(WHERE ) Use generic buffering where records are accessed based on condition Full Buffering:(SELECT *) This buffer is allocated when you are fletching all the fields from database table Check Table: It works based on Primary & Foreign key relationship. Data is always validated at Field level Value Table: It is a default Check Table & it always maintained under Domain under Value Range option
Rohini kumar
SAP-ABAP
75
09-09-2014 MODULES MM Module: Materials Management Module Departments in MM Module: 1. Purchase 2. Warehouse 3. General Stores 4. Finance in MM Process Flow in MM Module: IT Department Purchase Requisition (Indent) PR Approval (HOD, VP, President) Purchasing Department
Vendor Analysis
Request for Quotation
Best Vendor
Vendor1
Vendor2
Vendor3
Quotation
PO Approval
Delivery (Manifacture+Pickup+Packing) Delivery Challana (Delivery Note) Row Material
Finished Goods General Store (GRS) Invoice Verification (Bill Processing) Vendor Payment
Rohini kumar
Purchase Order
Vendor1
SAP-ABAP
76
Purchase Order: Vendor: Vendor Details:
PO Date:
Payment Terms: Item No.of Pieces Unit price Amount 10 2 100 200 --
Brief Flow: PR PR Purchase RFQ PO PO Release GRN IV Vendor Payment Applications & Tables in MM Module: 1. Purchase Requisition: Tcodes: ME51N, ME52N, ME53N Tables: EBAN Note: The key field is BANFN (PR number) 2. Purchase Order: Tcodes: ME21N, ME22N, ME23N Tables: EKKO, EKPO, EKBE, EKKN, EKAN, EKET Note: The key field is EBELN (PO number) 3. Goods Receipt: Rohini kumar
SAP-ABAP
77
Tcodes: MIGO Tables: MKPF, MIEG Note: The key field is MBLNR (Material Document Number) 4. Invoice Verification: Tcodes: MIR0, MIR7 Tables: RBKP, RSEG Note: The key field is BELNR (Accounting Document Number) 5. Vendor Master Data: Tcodes: XK01, XK02, XK03 Tables: LFA1, LFB1, LFM1, LFBK, LFC1 Note: The key field is LIFNR (Vendor Account Number) 6. Material Master Data: Tcodes: MM01, MM02, MM03 Tables: MARA, MARC, MARM, MARD, MAKT, MVKE, MARC, MAST, MBEW, MSLB Note: The key field is MATNR (Material Code) 7. Service Entry Sheet: Tcodes: ML81N Tables: ESSR, ESSL Note: The key field is LBLNI (Entry Sheet Number)
Rohini kumar
SAP-ABAP
78
Inner Joins: Use inner joins for fletching common data from two (or) more than two tables Syntax-1: SELECT LFA1~lifnr LFA1~name1 EKKO~ebeln EKKO~bedat EKPO~menge EKPO~netpr INTO TABLE FROM LFA1 INNER JOIN EKKO ON LFA1~lifnr=EKKO~lifnr INNER JOIN EKPO ON EKKO~ebeln=EKPO~ebeln WHERE Syntax-2: SELECT
INTO
A~lifnr B~ebeln C~menge TABLE
WHERE
10-09-2014 Example: Lifnr name1 1 X 2 Y 3 Z 4 M Inner Join 1 1 2 2 3
Rohini kumar
A~name1 B~bedat C~netpr FROM LFA1 AS A INNER JOIN EKKO AS B ON A~lifnr=B~lifnr INNER JOIN KKPO AS C ON B~ebeln=C~ebeln
X X Y Y Z
ebeln lifnr bedat 100 1 1.6.2014 200 1 2.3.2014 300 2 3.10.2014 400 2 5.6.2014 500 3 10.9.2014 100 200 300 400 500
1.6.2014 2.3.2014 3.10.2014 5.6.2014 10.9.2014
1 1 2 2 3 4
Left Outer Join X X Y Y Z M
100 200 300 400 500
1.6.2014 2.3.2014 3.10.2014 5.6.2014 10.9.2014
SAP-ABAP
79
Requirement: Purchase Order Details based on Vendors Input: Vendor code------- s_lifnr Company code---- s_bukrs Plant ------s_werks Material type------ s_matnr Material group---- s_matkl Po date-------------- s_bedat
to to to to to to
Summary Details
Output: LFA1-lifnr EKKO-ebeln EKKO-bedat EKPO-matnr EKPO-menge EKPO-netpr 1000 3000 2.6.2.14 3001 15.6.2014 Totals
EKPO-meins 100-100 100-101
50 70 120
2000 PC 3000 PC 5000
1001 5001 3.6.201 5002 9.6.2014 5003 15.6.2014 Totals
F001 F002 F003
2 1 3 6
80 90 100 270
126
5270
Grand totals
Solution: Go to SE38 Provide Program: ZMM_Purchase_Order_Details Select Create Title: Purchase Order Details based on Vendors Type: Executable Program Select Save, Local Object * provide tables work area TABLES: LFA1, EKKO, EKPO * provide selection scree Rohini kumar
PC PC PC
SAP-ABAP
80
SELECTION-SCREE: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. SELECT-OPTIONS: s_lifnr FOR LFA1-lifnr s_bukrs FOR EKKO- bukrs s_mtart FOR EKPO-mtart s_matkl FOR EKPO-matkl s_bedat FOR EKKO-bedat SELECTION-SCREEN: END OF BLOCK b1. SELECTION-SCREE: BEGIN OF BLOCK b2 WITH FRAME TITLE text-001. PARAMETERS: p_rb1 RADIOBUTTON GROUP RG1 p_rb2 RADIOBUTTON GROUP RG1 SELECTION-SCREEN: END OF BLOCK b2. TYPES:
BEGIN OF lifnr TYPE ebeln TYPE bedat TYPE matnr TYPE meins TYPE mengeTYPE netpr TYPE END OF
DATA: wa_po it_po
ty_po, LIFNR, EBELN, BEDAT, MATNR, MEINS, MENGE_D, NETPR, ty_po.
TYPE ty_po, TYPE TABLE OF ty_po.
SELECT
LFA1~lifnr EKKO~ebeln EKKO~bedat EKPO~matnr EKPO~meins EKPO~menge EKPO~netpr INTO TABLE it_po FROM LFA1 INNER JOIN EKKO ON LFA1~lifnr = EKKO~lifnr INNER JOIN EKPO ON EKKO~ebeln = EKPO~ebeln WHERE LFA1~lifnr IN s_lifnr AND EKKO~bukrs IN s_bukrs AND EKPO~werks IN s_werks AND EKPO~mtart IN s_mtart AND EKPO~matkl IN s_matkl AND EKKO~bedat IN s_bedat. IF p_rb1 EQ ‘X’. SORT it_po BY lifnr. Rohini kumar
SAP-ABAP
LOOP
81
AT
AT NEW WRITE:/10 SKIP. ENDAT.
it_po
INTO wa_po.
lifnr. wa_po-lifnr COLOR 1.
FORMAT COLOR COL_GROUP INTENSIFIED OFF. NEW-LINE.ULINE AT 1(135). WRITE:/ SY-VLINE, 10 wa_po-ebeln, 30 wa_po-bedat, 50 wa_po-matnr, 70 wa_po-meins, 90 wa_po-menge, 100 wa_po-netpr, 135 SY-VLINE. AT END OF lifnr. SUM. FORMAT COLOR COL_TOTAL INTENSIFIED OFF. NEW-LINE.ULINE AT 1(135). WRITE:/ SY-VLINE, 10 ‘Totals’, 70 wa_po-menge, 90 wa_po-netpr, 135 SY-VLINE. ENDAT. AT LAST. SUM. FORMAT COLOR COL_TOTAL NEW-LINE.ULINE AT 1(135). WRITE:/10 ‘Grand Totals’, 70 wa_po-menge, 90 wa_po-netpr, 135 SY-VLINE. ENDAT. ENDLOOP. ELSE LOOP AT it_po INTO wa_po. Rohini kumar
INTENSIFIED OFF.
SAP-ABAP
AT FIRST. FORMAT COLOR COL_HEADING INTENSIFIED ON. NEW-LINE.ULINE AT 1(135). WRITE:/ SY-VLINE, 10 ‘Vendor Code’, 25 ‘PO Number’, 35 ‘PO Date’, 45 ‘Material Code’, 60 ‘Unit of Measure’, 70 ‘Quantity’, 80 ‘Unit Price’, 135 SY-VLINE. NEW-LINE.ULINE AT 1(135). ENDAT. FORMAT COLOR COL_GROUP INTENSIFIED OFF. NEW-LINE.ULINE AT 1(135). WRITE:/ SY-VLINE, 5 wa_po-lifnr, 10 wa_po-ebeln, 30 wa_po-bedat, 50 wa_po-matnr, 70 wa_po-meins, 90 wa_po-menge, 100 wa_po-netpr, 135 SY-VLINE. ENDLOOP. ENDIF.
Rohini kumar
82
SAP-ABAP
LFA1 Table: This table holds Vendor Master Data Fields: 1. Lifnr-------Vendor Number 2. Land1-----Country of Vendor 3. Name1----Name of Vendor 4. Ort01-----City of Vendor 5. Pstlz------Postal Code of Vendor 6. Adrnr-----Address Number Links: LFA1~adrnr ADRC~addrnumber 7. Brsch-----Industry Key EKKO Table: This table holds Purchase Order Header Data Fields: 1. Ebeln-------Purchase Order Number 2. Bukrs------Company Code 3. Bsart-------Purchasing Document Type 4. Statu-------Status of Purchase Order 5. Lifnr-------Vendor Number Links: LFA1~lifnr EKKO~lifnr 6. Zterm------Payment Terms 7. Zbd1p-----Cash Discount Percentage 8. Ekorg------Purchase Organization (Purchase Department) 9. Ekgrp------Purchasing Group 10.Waers------Currency 11.Wkurs------Exchange Rate 12.Bedat-------Purchase Order Date 13.Inco1, Inco2-------International Terms for Carrying Bussiness 14.Knumv------Tax Number Links: Rohini kumar
83
SAP-ABAP
EKKO~knumv KONU~knumv 15.Kalsm------Pricing Procedure 16.Frgke-------Release Indicator EKPO Table: This table holds Purchase Document Item Data Fields: 1. Ebeln-------Purchase Order Number Links: EKKO~ebeln EKPO~ebeln 2. Ebelp------Item Number 3. Txzo1-----Item Text 4. Matnr-----Material Code 5. Werks-----Plant 6. Lgort------Storage Location 7. Matkl-----Material Group 8. Menge------Purchase Order Quantity 9. Meins------Unit of Measurement 10.Netpr------Unit Price 11.Netwr------Total Price 12.Mwskz-----Sales Tax Code 13.Elikz--------Delivery Completed Indicator
Rohini kumar
84
SAP-ABAP
85
11-09-2014 Message Handling: Using MESSAGE keyword you can display your own message Note: SY-SUBRC It returns values after ABAP statement It returns 0 if an ABAP statement is processed successfully otherwise it returns Exception (other than 0 value) Example: SELECT………………… ………………………….. IF SY-SUBRC EQ 0. MESSAGE ‘Data Found’ TYPE ‘I’. ELSE. MESSAGE ‘Enter Valid Input’ TYPE ‘E’. Message Class: You can store all the messages in Message Class also T-code for Message Class is SE91 Example: IF SY-SUBRC EQ 0. MESSAGE I000(zmm_mess1). ELSE. MESSAGE E001(zmm_mess1). Double click on zmm_mess1 (OR) Go to SE91 Provide Message Class: zmm_mess1 Select Create option Provide Short Text: Message Handling Select Save option Provide Messages 000---------Data Found 001---------Enter Valid Input Select Save option Activate Message Handling
Rohini kumar
SAP-ABAP
86
Message Options: I-----Information------Information pop-up is displayed S----Status------Message is displayed in Status Bar W----Warning-----A yellow color warning message is displayed & Control will switch to next Screen E-----Error------Red color message is displayed & Control will stay in same Screen A----Amend-----Control will switch to Screen 0 X-----Exit-------Control will switch to ABAP Runtime Screen (ST22)
Rohini kumar
SAP-ABAP
87
12-09-2014 Modularization Techniques: There are 5 modularization techniques in SAP. They are 1. Subroutines 2. Function Modules 3. Include 4. Macro 5. Field Symbol In real time you should ensure that every program should be highly readable & reusable For achieving readability & reusability we have to work with modularization techniques Subroutines: Subroutine is like a mini program which can be called within the same program (or) from other programs Using Subroutines you can perform Calculations, Call other function modules, Write statements……….etc Types of Subroutines: 1. Internal Subroutines 2. External Subroutines Internal Subroutines: In this both calling part & definition part are in same program Syntax: PERFORM
USING
FORM USING --------------------------------ENDFORM.
………….
………….
Note: 1. In above syntax PERFORM will call its FORM & simultaneously pass Parameters to its FORM 2. Subroutine name can be any name. The same name should be used both in PERFORM & FORM 3. The Parameters defined in PERFORM are called Actual Parameters. These parameters have global visibility & must be defined in a program Rohini kumar
SAP-ABAP
88
4. The parameters maintained in FORM are called Formal Parameters. These parameters have local visibility & are automatically created based on Actual Parameters 5. Actual Parameters will pass values to Formal Parameters by using USING option 6. The number of Actual Parameters should be same that of Formal Parameters Example: WRITE:/ ‘Welcome to Subroutine’. PERFORM sub. WRITE:/ ‘First Call’. PERFORM sub. WRITE:/ ‘Second Call’. FORM sub. WRITE:/ ‘Inside Sub’. ENDFORM. Output: Welcome to Subroutine Inside Sub First Call Inside Sub Second Call
Rohini kumar
SAP-ABAP
89
Debugging: Break Point: Using break point the execution of a program can be terminated & until the break point is reached Note: In real time for large programs debugging each & every part of a program is time consuming. If you know where the problem arises you can directly keep a break point & test the program Types of Break Points: 1. Dynamic Break Point 2. Static Break Point Dynamic Break Point: Dynamic break point is kept automatically & can be removed during runtime It is automatically discarded whenever system is logged off Note: Dynamic break point is used if you are not aware of the exact problem in your program. During debugging you can set dynamic break point at different, different places & you can remove the same dynamically Static Break Point: It is kept by using a keyword BREAK-POINT (or) BREAK Note: Static break point is used if you know the exact problem in your program & you want to debug the same code N number of times
Rohini kumar
SAP-ABAP
Pass by Value & Pass by Reference: Pass by Value: In pass by value, value (or) values is passed from Actual Parameters to Formal Parameters Both calling part & definition part will share different memory locations In call by value nothing is reflected back to calling part Example: DATA v1 TYPE C VALUE ‘a’. PERFORM sub USING v1. WRITE:/ v1. FORM sub USING VALUE(p1). p1 = ‘b’. WRITE:/ p1. ENDFORM. Output: b a Pass by Reference: In pass by reference value is not passed to Formal Parameters instead a Pointer (or) Reference (or) Address is passed to Formal Parameters Any changes done in Formal Parameters will be effected to Actual Parameters also Example: DATA v1 TYPE C VALUE ‘a’. PERFORM sub USING (or) CHANGING v1. WRITE:/ v1. FORM sub USING (or) CHANGING p1. p1 = ‘b’. WRITE:/ p1. ENDFORM. Output: b b
Rohini kumar
90
SAP-ABAP
91
External Subroutines: In external subroutines both PERFORM & FORM maintained in separate programs Example: Go to SE38 Program: ZMM_GRM_DETAILS Create Title: GRM Details Type: Executable Program Save Local Object TABLES: MKPF, MSEG. SELECTION-SCREEN: BEGIN OF SELECT-OPTIONS: s_mblnr FOR s_werks FOR s_budat FOR SELECTION-SCREEN: END OF PERFORM s_werks-low
BLOCK b1 WITH FRAME TITLE text-000. MKPF-mblnr, MSEG-werks, MKPF-budat. BLOCK b1.
extsub (ZMM_GRM_FORM) USING s_mblnr-low s_werks-high s_budat-low s_budat-high.
s_mblnr-high
Double click on ZMM_GRM_FORM You will find a pop-up select Yes Save & Yes You will find a pop-up deselect With Top Incl check box the press Enter
TYPES: BEGIN OF ty_mseg, mblnr TYPE mblnr, budat TYPE budat, menge TYPE menge_D, matnr TYPE matnr, dmbtr TYPE dmbtr, END OF ty_mseg. DATA: wa_mseg It_mseg
TYPE ty_mseg, TYPE TABLE OF ty_mseg.
FORM extsub USING VALUE(grm_low) VALUE(grm_high) VALUE(plnt_low) VALUE(plnt_high) VALUE(date_low) VALUE(date_high) Rohini kumar
SAP-ABAP
92
SELECT MKPF~mblnr MKPF~budat MSEG~menge MSEG~matnr INTO TABLE it_mseg FROM MKPF INNER JOIN MSEG ON MKPF~mblnr = MSEG~mblnr WHERE MKPF~mblnr BETWEEN grm_low AND grm_high AND MSEG~werks BETWEEN plnt_low AND plnt_high AND MKPF~budat BETWEEN date_low AND date_high AND MSEG~bwart EQ ‘101’. LOOP AT WRITE:/10 30 50 70 90 ENDLOOP. ENDFORM.
it_mseg INTO wa_mseg. wa_mseg-mblnr, wa_mseg-budat, wa_mseg-menge, wa_mseg-matnr, wa_mseg-dmbtr.
Output: s_mblnr : 49000000 to 490005000 s_werks: 1000 to 1200 s_budat: 15.11.1994 to 01.06.2009 Execute (F8)
Rohini kumar
MSEG~dmbtr
SAP-ABAP
13-09-2014 MKPF Table: It holds Material Document Header Data Fields: 1. Mblnr ---------- Material Document Number 2. Mjahr ---------- Material Document Year 3. Blart ---------- Material Document Type 4. Budat ---------- Material Document Date 5. Xblrn ---------- Reference Document (Purchase Order Document) Number MSEG Table: It holds Material Document Item Data Fields: 1. Mblnr ------ Material Document Number 2. Mjahr ------ Material Document Year 3. Bwart ------ Moment Type 4. Werks ------ Plant 5. Lgort ------- Storage Location 6. Charg ------ Batch Number 7. Lifnr ------- Vendor Account Number Link: LFA1-lifnr MSEG-lifnr 8. Shkzg ------- Debit / Credit Indicator 9. Dmbtr ------ Amount in Local Currency 10.Menge ------ Quantity 11.Meins ------- Unit of Measurement 12.Ebeln ------- Purchase Order Number Link: EKPO-ebeln MSEG-ebeln 13.Ebelp -------- Item Number
Link: Rohini kumar
93
SAP-ABAP
EKPO-ebelp MSEG-ebelp 14.Smbln ------- Number of Material Document Number 15.Kostl -------- Department 16.Aufnf ------- Production Order Number
Rohini kumar
94
SAP-ABAP
95
Function Module: Function Module is a piece of code which performs a specific task based on given requirement Function Module is a responsible program which always accepts Parameters & returns a Value Types of Function Modules: 1. Normal Function Module 2. Remote Enabled Function Module 3. ALV Function Module (ABAP List Viewer) Normal Function Module: It is a piece of code which performs a specific task based on given Parameters Remote Enabled Function Module: It is for distributed environment. You can call this function module within the system & across the system ALV Function Module: These are part of Normal Function Module Has they improves performance of a programming so they are separated from Normal Function Modules Function Group: It is a collection of identical objects Without Function Group you cannot create a Function Module In one Function Group we can maintain 99 Function Modules Apart from this SAP providing more than 120000 Function Modules which are surrounding more than 10000 Function Modules Syntax: CALL FUNCTION
‘’.
------ calling part (SE38)
FUNCTION . ------------------------------- definition part (SE37) ENDFUNCTION.
Function Module Interface: Rohini kumar
SAP-ABAP
96
These are Parameters which are pass & return from a Function Module Types of Function Module Interfaces: 1. Exporting 2. Importing 3. Tables 4. Changing Exporting: These are Variables (or) Field Groups which are pass to a Function Module in order to perform a task Importing: Function Modules always returns a value via Importing Parameters Tables: These are Internal Tables Changing: In latest versions Table Parameters are replaced by Changing Note: 1. Exporting & Importing Parameters works based on Pass by Value 2. Tables & Changing Parameters works based on Pass by Reference Steps for Create Function Module: 1. Work with SE80 (create Function Group) 2. Work with SE37 (create Function Module based on Function Group) 3. Work with SE38 (call Function Module) Step-1: Go to SE80 Under Test Repository select Function Group Provide Function Group name: ZCAL_GR Enter, Yes Provide Short Text: Function Group for Calculations Select Save, Local Object
Rohini kumar
SAP-ABAP
97
Step-2: Go to SE37 Function Module: ZCALC_MOD Create Function Group: ZCAL_GR Short Text: Function Module for Calculations Enter, Enter Import tab Parameter Name Typing Associated Type X TYPE I Y TYPE I Export tab Parameter Name Typing Associated Type Z TYPE I Exception tab Exception Short Text No_Data Wrong Calculation Source Code tab z = x + y. IF SY-SUBRC NE 0. RAISE No_Data. ENDIF. Activate Function Module (F8) Step-3: Go to SE38 Program: ZCALC_CALL_SUM Create Title: Function Module for Calculations Type: Executable Program Save, Local Object PARAMETERS: a TYPE I, b TYPE I. DATA
c TYPE I.
* calling function module CALL FUNCTION ‘ZCALC_MOD’. EXPORTING. Rohini kumar
SAP-ABAP
98
x = a. y = b. (or) IMPORTING. z = c. Select Pattern option Call Function: ZCALC_MOD WRITE:/ ‘The Addition is:’, c. Working with Standard Function Module: Go to SE37 Function Module: HR_RU_AGE_YEARS (standard function module name) Select F8 PERNR: 1000 --------- employee number BSDTE: 18.9.2014 -------- To days date Select F8 Assignment: Accept a number as input say 3900 & the Function Module should return the same number in figures say Three Thousand and Nine Hundred
Rohini kumar
SAP-ABAP
99
Include Program: Include Program’s memory is available to any ABAP work bench tool Example: INCLUDE ZNC1 WRITE:/ ‘work’. INCLUDE ZNC2 INCLUDE ZNC1. WRITE:/ ‘hard’. REPORT ZNC3 INCLUDE ZNC2. Note: Include Program is a program (or) reusable program without any Parameters
Rohini kumar
SAP-ABAP
100
Field Symbol: Field Symbol is analog to pointer concept in ‘C’ language It holds Reference of other Variables & returns Value stored in the Reference Note: Using Field Symbol you can improve performance of a program Example:
Go to SE38 Program: ZMM_FIELDSYMBOL Create Title: Field Symbols Type: Executable Program Save, Local Object
TABLES: LFA1. INCLUDE ZVEND_DECC. Double click on ZVEND_DECC Yes, Yes, Enter SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAM TITLE text-000. SELECT-OPTIONS: s_lifnr FOR LFA1-lifnr, s_land1 FOR LFA1-land1. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF lifnr TYPE land1 TYPE name1 TYPE ort01 TYPE pstlz TYPE stras TYPE END OF
ty_lfa1, lifnr, land1, name1, ort01, pstlz, stras, ty_lfa1.
FIELD-SYMBLOS
DATA
it_lfa1
TYPE TABLE OF
PERFORM get_data. PERFORM display_data. FORM get_data. Rohini kumar
TYPE
ty_lfa1. ty_lfa1.
SAP-ABAP
SELECT lifnr land1 name1 ort01 pstlz FROM LFA1 WHERE lifnr IN s_lifnr AND land1 IN s_land1. ENDFORM. FORM display_data. LOOP AT it_lfa1 ASSIGNING . WRITE:/10 -lifnr, 30 -land1, 50 -name1, 70 -ort01, 90 -pstlz, 110 -stras, ENDLOOP. ENDFORM.
101
stras
INTO
TABLE
Note: Nowadays most of the companies are using Field Symbols instead of Work area
Rohini kumar
it_lfa1
SAP-ABAP
102
19-09-2014 FOR ALL ENTRIES keyword: Using FOR ALL ENTRIES you can fetch common data between two tables Syntax: SELECT ……… FROM INTO TABLE FOR ALL ENTRIES IN WHERE Example: Segment wise Materials Details Input: 1. Material Code 2. Material Type 3. Material Group 4. Division Output: Material Code
Material Description
Segment Description
Processing Logic: 1. Get Matnr Spart fields from MARA table based on input 2. Pass Spart field of MARA table to TSPAT table & get Vtext field where Spras field EQ to ‘EN’ 3. Pass Matnr field of MARA table to MAKT table & get Maktx field where Spars field EQ to ‘EN’ Solution: Go to SE38 Program: ZMM_SEGMENTWISE_MATERIALS Create Title: Segment wise Materials Details Save, Local Object * providing tables work area TABLES: MARA. * providing input selection screen SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME SELECT-OPTIONS: s_mtart FOR MARA-mtart, s_matnr FOR MARA-matnr, s_matkl FOR MARA-matkl, Rohini kumar
TITLE text-000.
SAP-ABAP
103
s_spars FOR MARA-spars. SELECTION-SCREEN: END OF BLOCK b1. * creating structure for MARA table TYPES: BEGIN OF ty_mara, matnr TYPE matnr, spart TYPE spart, END OF ty_mara. * creating structure for MAKT table TYPES: BEGIN OF ty_makt, matnr TYPE matnr, maktx TYPE maktx, END OF ty_makt. * creating structure for TSPAT table TYPES: BEGIN OF ty_tspat, spart TYPE spart, vtext TYPE vtext, END OF ty_tspat. * creating structure for FINAL output TYPES: BEGIN OF ty_final, matnr TYPE matnr, maktx TYPE maktx, vtext TYPE vtext, END OF ty_makt. * creating work areas & internal tables DATA: wa_mara TYPE ty_mara, wa_makt TYPE ty_makt, wa_tspat TYPE ty_tspat, wa_final TYPE ty_final, it_mara TYPE TABLE OF it_makt TYPE TABLE OF it_tspat TYPE TABLE OF it_final TYPE TABLE OF * calling Subroutines PERFORM get_mara. PERFORM get_makt. PERFORM get_tspat. Rohini kumar
ty_mara, ty_makt, ty_tspat, ty_final.
SAP-ABAP
104
PERFORM combine_data. PERFORM display_data. * getting matnr & spart from MARA table by comparing with input FORM get_mara. SELECT WHERE AND AND
matnr matnr matkl spart
spart FROM MARA INTO TABLE it_mara IN s_matnr IN s_matkl IN s_spart.
IF SY-SUBRC NE 0. MESSAGE ‘Enter Valid Input’ TYPE ‘E’ DISPLAY LIKE ‘I’. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. * getting spart & vtext from TSPAT table by comparing spart of TSPAT with spart of MARA FORM get_tspat. IF NOT it_mara IS INITIAL. SELECT spart vtext FROM TSPAT INTO TABLE it_tspat FOR ALL ENTRIES IN it_mara WHERE spart = it_mara-spart AND spars EQ ‘EN’. ENDIF. ENDFORM. * getting matnr & maktx from MAKT table by comparing matnr of MAKT with matnr of MARA FORM get_makt. IF NOT it_mara IS INITIAL. SELECT matnr maktx FROM MAKT INTO TABLE it_makt FOR ALL ENTRIES IN it_mara WHERE matnr = it_mara-matnr AND spars EQ ‘EN’. ENDIF. Rohini kumar
SAP-ABAP
105
ENDFORM. * combining required fields i.e. matnr, maktx & vtext FORM combine_data. LOOP AT it_mara INTO wa_mara. wa_final-matnr = wa_mara-matnr. READ TABLE it_makt INTO wa_makt WITH KEY matnr = wa_mara-matnr. wa_final-maktx = wa_makt-maktx. READ TABLE it_tspat INTO wa_tspat WITH KEY spart = wa_mara-spart. wa_final-vtext = wa_tspat-vtext. APPEND wa_final TO it_final. ENDLOOP. ENDFORM. * displaying output FORM display-data. LOOP AT it_final INTO wa_final. AT FIRST. NEW-LINE.ULINE AT 1(135). WRITE:/ SY-VLINE, 10 ‘Material Code’, 30 ‘Material Description’, 60 ‘Segment Description’, 135 SY-VLINE. NEW-LINE.ULINE AT 1(135). ENDAT. FORMAT COLOR COL_GROUP INTENSIFIED OFF. NEW-LINE.ULINE AT 1(135). WRITE:/ SY-VLINE, 10 wa_final-matnr, 30 wa_final-maktx, 60 wa_final-vtext, 135 SY-VLINE. NEW-LINE.ULINE AT 1(135). ENDLOOP. ENDFORM. Rohini kumar
SAP-ABAP
106
20-09-2014 Pitfalls of FOR ALL ENTRIES: (Drawbacks) 1. Before applying FOR ALL EMTRIES it is mandatory to check whether base internal table is having data (or) not If you are not checking, Assume if base internal table is completely empty then it will fetch all records from database table 2. It act as a SELECT DISTINCT (It removes duplicate set of records from an internal table) Example: BSEG Table belnr hkgnt 1000 301011 301012 301012 ---- These records will be removed 301012 301013 301014 3. If base internal table is too large there will be performance degration Note: In real time always use 1. INNER JOINS for extracting common data between two tables 2. FOR ALL ENTRIES for extracting & combining multiple tables records
Rohini kumar
SAP-ABAP
MARA Table: It holds Material Master Data Fields: 1. Matnr -------- Material Number 2. Ersda --------- Date of Creation 3. Ernam -------- Person who Created that Material 4. Mtart --------- Material Type 5. Mbrsg -------- Industry Key 6. Matkl --------- Material Group 7. Bismt --------- Old Material Number 8. Miens --------- Unit of Measurement 9. Brgew -------- Gross Weight 10.Ntgew -------- Net Weight 11.Spart ---------- Division Code MAKT Table: It holds Material Description Details Fields: 1. Matnr -------- Material Number 2. Spras -------- Language Key 3. Maktx ------- Material Description TSPAT Table: It holds Division Description Details Fields: 1. Spras --------- Language Key 2. Spart --------- Division Code 3. Vtext --------- Division Description
Rohini kumar
107
SAP-ABAP
SD Module: Sales & Distribution Module Departments in SD Module: 1. Marketing 2. Excise 3. Billing 4. Finance part of SD Process Flow: Inquiry Quotation Sales Order Delivery Excise Invoice Invoice FI Module T Codes & Tables: Inquiry: Tcodes: VA11, VA12, VA13 Tables: VBAK, VBAP Note: The key field is vbeln Quotation: Tcodes: VA21, VA22, VA23 Tables: VBAK, VBAP Note: The key field is vbeln Sales Order: Tcodes: VA01, VA02, VA03 Tables: VBAK, VBAP Note: The key field is vbeln
Delivery: Rohini kumar
108
SAP-ABAP
Tcodes: Vl01N, VL02N, VL03N Tables: LIKP, LIPS Note: The key field is vbeln (Delivery Number) Excise Invoice: Tcodes: J1IS, J1IEX, J1ID Tables: J_1IEXCHDR, J_1IEXCDTL, J_1IMOCUST Note: The key field is exnum Invoice: Tcodes: VF01, VF02, VF03 Tables: VBRK, VBRP Note: The key field is vbeln (Invoice Number) Other Tables: VBKD, VBFA, VBPA, VBUK, VBUV, KONV, KONR
Rohini kumar
109
SAP-ABAP
110
String Operations: 1. SHIFT 2. TRANSLATE 3. REPLACE 4. STRLEN 5. OFFSET FUNCTIONALITY 6. SPLIT 7. CONCATINATE 8. CONDENSE SHIFT keyword: It shifts a specific string to left (or) right side by deleting required options in a particular string Syntax-1: SHIFT LEFT DELETING LEADING Syntax-2: SHIFT RIGHT DELETING TRAILING Example: ‘000001000’----------- 1000 DATA: str(10) TYPE C VALUE ‘000001000’. SHIFT str LEFT DELETING LEADING ‘0’ . WRITE:/ str. Output: 1000 Note: Size of the string variable must be equal to given string TRANSLATE keyword: It converts the case of a particular string from lower to upper and vice-versa Syntax-1: TRANSLATE str TO UPPER CASE Syntax-2: TRANSLATE str TO LOWER CASE Example: SATYA--------satya DATA: str(10) TYPE C VALUE ‘SATYA’. TRANSLATE str TO LOWER CASE. WRITE:/ str Output: satya REPLACE keyword: Rohini kumar
SAP-ABAP
111
It replaces a string with another string based on requirement Syntax: REPLACE WITH INTO Example: rupees-------dollars DATA: str(30) TYPE C VALUE ‘one thousand rupees’. REPLACE ‘rupees’ WITH ‘dollars’ INTO str. WRITE:/ str. Output: one thousand dollars STRLEN keyword: It returns length of a string Syntax: n = STRLEN ( str ). Where n is Integer Variable Example: DATA: str(10) TYPE C VALUE ‘satya’, n TYPE I. n = STRLEN ( str ). WRITE:/ n. Output: 5 OFFSET FUNCTIONALITY keyword: 0 1 2 3 4 5 6 7 --------offset A B C D E F G H 1. st = str + 2 ( 1 ). --------output------ C 2. st = str + 4 ( 2 ). --------output------ EF SPLIT keyword: It splits a single string based on special charectors Syntax: SPLIT AT INTO ….. Example: DATA: str(10) Rohini kumar
TYPE C VALUE ‘cool-drink’,
SAP-ABAP
112
str1(10) TYPE C, str2(10) TYPE C. SPLIT str AT ‘-’ INTO str1 str2. WRITE:/ str1, str2. Output: cool drink CONCATENATE keyword: It concatenates two (or) more than two strings into a final string Syntax: CONCATENATE INTO SAPARATED BY . Example-1: DATA: data(10) TYPE C. CONCATENATE SY-DATUM + 6(2) SY-DATUM + 4(2) SY-DATUM + 0(4) INTO date SAPARATED BY ‘.’. WRITE:/ date. Output: 20.09.2014 Example-2: DATA: year(4), mon(2), day(2), date(10). year = SY-DATUM + 0(4). mon = SY-DATUM + 4(2). day = SY-DATUM + 6(2). CONCATENATE day mon year INTO date SAPARATED BY ‘.’. WRITE:/ date. Output: 20.09.2014
Rohini kumar
SAP-ABAP
113
CONDENSE keyword: It combines a specific string by removing gaps between them Syntax: CONDENSE NO-GAPS. Example: DATA: str(20) TYPE C VALUE ‘satya narayana’. CONDENSE str NO-GAPS. WRITE:/ str. Output: satyanarayana Assignment: 1 1 2 1 2 1 2 1 2
Rohini kumar
3 3 3
4 4
5
SAP-ABAP
Looping Statements: Branching: a. Conditional Statements b. Unconditional Statements Conditional Statements: 1. IF…………ENDIF. Sytax-1: IF . Do this ENDIF. Sytax-2: IF . Do this ELSE. Do this ENDIF. Sytax-3: IF . Do this ELSE IF Do this ELSE. Do this ENDIF. Note: Use ELSE IF condition only a single condition is true 2. CASE…………..ENDCASE Syntax: CASE . WHEN . Do this WHEN . Do this ………. ………. Rohini kumar
114
SAP-ABAP
WHEN OTHERS. Do this ENDCASE. 3. WHILE statement: Syntax: WHILE ------------------ENDWHILE. Unconditional Statements: 1. DO…………….ENDDO. Syntax-1: DO. ----------------ENDDO. Syntax-2: DO TIMES. ----------------ENDDO. Syntax-3: DO TIMES VARYING FROM NEXT . ----------------ENDDO. Operators: a. Logical Operators b. Relational Operators Logical Operators: 1. AND 2. OR 3. NOT Relational Operators: 1. GT----- > Rohini kumar
115
SAP-ABAP
2. 3. 4. 5. 6.
LT ----- < GE ---- >= LE ---- = n. EXIT. ENDIF. Rohini kumar
SAP-ABAP
WRITE:/ SY-INDEX. ENDDO.
Rohini kumar
118
SAP-ABAP
Mathematical Operations: Ex: 5.55 1. FRAC -------- 0.55 2. CEIL --------- 6.0 3. FLOOR ----- 5.0 4. SIGN -------- 1 (+) 5. ABS --------- 5.55 (always returns only positive value) 6. TRUNC ---- 5.0 Ex: 6 / 2 7. REM -------- 0 8. DIV --------- 3 9. MOD ------- 0 FRAC: It returns fraction part from a decimal value CEIL: It returns highest value in existing decimal value FLOOR: It returns lowest value from a particular decimal value SIGN: It returns the signature (positive (or) negative) from a particular numeric value ABS: It returns absolute value from a numeric value TRUNC: It truncates (removes) decimal part from a numeric value
REM (or) MOD: These returns remainder DIV: It returns devisor Example: DATA: n TYPE P DECIMALS 2 VALUE ‘5.55’, m TYPE P DECIMALS 2. m = FRAC(n). WRITE:/ m m = TRUNC(n). WRITE:/ m Rohini kumar
119
SAP-ABAP
m m m m
= = = =
120
CEIL(n). WRITE:/ m FLOOR(n). WRITE:/ m ABS(n). WRITE:/ m SIGN(n). WRITE:/ m
Question: What is the difference between SY-TABIX & SY-INDEX? Answer: SY-TABIX returns current loop pass for Internal Tables i.e. LOOP………..ENDLOOP SY-INDEX returns current loop pass other than LOOP……….ENDLOOP i.e. DO…………..ENDDO. WHILE……………ENDWHILE. Assignments: 1. Formats a. 1 1 2 1 2 1 2 1 2 b. * * * * *
* * * *
3 3 3
4 4
5
* * *
* *
*
* * *
* * * *
* * *
c.
*
* *
* *
*
2. Write a program to print prime numbers between 1 to 100? 3. Write a program to accept two numbers and returns HCF & LCM of that numbers? 4. Accept a string and check whether it is palindrome (or) not?
Rohini kumar
SAP-ABAP
121
SAP and ABAP Memory: ABAP Memory: Transferring data between two programs is done using ABAP memory Transferring data from ABAP report to other Standard Application is done by using SAP memory Export Import Functionality: ZExport S_matnr to S_werks to S_budat to SELECT……………. ……………………. EXPORT it TO MEMORY ID ‘material’.
ZImport S_matnr to S_werks to SUBMIT ZExport WITH matnr IN S_matnr WITH werks IN S_werks Exporting list to memory and return IMPORT it FROM MEMORY ID ‘material’.
Question: Explain why you written Export Import Functionality in your real time? Answer: The above functionality is for reusability Sometimes we needs to write a logic which already provided by a program Instead of writing the same program from beginning you can use the above functionality for getting the data from other programs I written a program for calculating Ageing for Materials In that I need to get Closing Stack of a material which is already provided by a standard report MB5B I simply passed input parameters from my Z-program to MB5B using SUBMIT keyword In MB5B I written logic for Exporting data to my Z-program & I Imported data using IMPORT keyword to my Z-program Example: Go to SE38 Program: YIMPORT_PROG Create Title: Import Program Type: Executable Program Save, Local Object TABLES: EKPO. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-000. Rohini kumar
SAP-ABAP
SELECT-OPTIONS: s_matnr FOR EKPO-matnr, s_werks FOR EKPO-werks. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_ekpo, ebeln TYPE ebeln, matnr TYPE matnr, menge TYPE menge_D, netpr TYPE netpr, END OF ty_ekpo. DATA: wa_ekpo TYPE ty_ekpo, It_ekpo TYPE TABLE OF ty_ekpo. SUBMIT YEXPORT_PROG WITH matnr IN s_matnr WITH werks IN s_werks EXPORTING LIST TO MEMORY AND RETURN. IMPORT it_ekpo FROM MEMORY ID ‘matt’. LOOP AT it_ekpo INTO wa_ekpo. WRITE:/10 wa_ekpo-ebeln, 30 wa_ekpo-matnr, 60 wa_ekpo-menge, 90 wa_ekpo-netpr. ENDLOOP.
Double click on YEXPORT_PROG Yes Remove With Top INCL check box Enter, Enter, Enter
TABLES: EKPO. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-000. SELECT-OPTIONS: s_matnr FOR EKPO-matnr, s_werks FOR EKPO-werks. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_ekpo, ebeln TYPE ebeln, matnr TYPE matnr, Rohini kumar
122
SAP-ABAP
123
menge netpr END DATA
it_ekpo
TYPE menge_D, TYPE netpr, OF ty_ekpo. TYPE TABLE OF ty_ekpo.
SELECT ebeln matnr menge netpr FROM EKPO INTO TABLE it_ekpo WHERE matnr IN s_matnr AND werks IN s_werks. EXPORT it_ekpo TO MEMORY ID ‘matt’. Output: Execute IMPORT_PROG s_matnr 100-100 to s_werks 1000 to
Rohini kumar
100-500 1100
SAP-ABAP
124
23-09-2014 Support Project: In Support Project End user will raise Tickets (Issues) based on priority Issues are directly raised by End user in Production Client which are automatically updated to Solution Manager Solution Manager is a free Ticketing Tool given by SAP for raising tickets Help Desk people from Consulting Company will receive the Tickets & forward it to respective Functional Consultants based on priority If the issue is Functional (related to Application, Customizing Issue……….etc) then Functional Consultant will resolve it If the issue is Technical (related to Programming, Enhancement…….etc) then Functional Consultant will prepare Functional Document & forward it to Technical Consultant (ABAPER) Based on Functional Document ABAPER will create Technical Document & forward it to Team Leader for approval If everything is fine ABAPER will develop the Object in Development Client Once the Object is developed then series of Testing will done by ABAPER, Functional Consultant & End user Finally after final testing by End user the Object is transported to Production System with the help of Basis Consultant
Rohini kumar
SAP-ABAP
125
System Landscape: It is also known as Correction & Transportation System (CTS) In real time End user will raise issues which are received by Functional Consultant For Technical Issues Functional Consultant will prepare Functional Document & based on that Technical Consultant will prepare Technical Document Technical Consultant will forward Technical Document to Team Leader who will approve it Objects are developed in Development Client While creating Objects system will prompt you for to save the object In real time Objects are always saved in a Package Once Objects are saved system will generate Request Numbers (Main Request Number & Sub Request Number) Objects are always stored in Sub Request Number Once Object is developed based on coding standards you should release Request Numbers in SE10 Then you should forward a mail to Basis Consultant for transporting Transport Request (TR) numbers from Development Client to Quality Client In Quality Server testing is done by ABAPER, Functional Consultant, End user If everything is fine again you will forward a mail to Basis Consultant to transport the TR Numbers from Quality Server to Production Server Important Points to Remember: 1. In real time you will receive tickets from FC. If you are working in Client Place you will get Tickets directly from End user 2. Before creating TD you gather the same from your TL 3. In Development Client Objects are created & modified. Testing is not possible here as recent data not available here (only test data is available) Note: Never discus with an interviewer that your Development Client is 800. It is always other than 800 i.e. 100, 200, 300,…………. 4. Quality Server is meant for testing. Here recent data (10 days back) is available 5. Production Server is Live Server in real time. It holds live data of a company. Day to day activities of a company are maintained (or) stored in Production Server 6. Only Development Client is in change mode. Quality & Production Clients are always in display mode 7. In real time as an ABAPER you can access Development & Quality Clients 8. End user can access Quality & Production Clients 9. FC can access any of these Clients 10.Package is a collection of Objects. In real time we are not creating any package. Throughout the life time in a company we are working with a single package Rohini kumar
SAP-ABAP
126
11.Objects are always stored in Sub Request Number is transported from one client to another 12.In real time Basis Consultant is responsible for transporting Request Numbers from one client to another 13.Once a Request Number is released (or) transported system will prompt you for a new Request Number 14.In real time as a TC we have to work with Work Bench Request. FC will work with Customizing Request 15.Request Numbers are always forwarded from Development to Quality & Quality to Production Clients Note: Reverse transportation of a Request Number is not possible under any circumstances in SAP 16.In real time all the issues are posted in Production System & Threads are updated in Solution Manager 17.E071 is a standard table which holds all Objects & their Request Numbers history 18.In real time our job to create Object & release the Request Number in SE10 19.In real time different companies are having different System Landscapes. In some companies there will 1 Development & 3 Testing Clients & in some 1 Development & 1 Testing Client & in some companies Development & Quality Clients are Cross Clients 20.In Quality Server only 85% to 90% of testing is done as it holds recent data. If you want to test the live data you have to work with Production Server 24-09-2014 Steps in System Landscape: 1. Work with SE80 (create a Package) 2. Work with SE38 (create a Program) 3. Work with SE10 (release Sub Request Number, release Main Request Number) Step-1: Go to SE80 Select Package option Provide Package name: ZABAP Yes Short Description: New Package Save (OR) Go to SE11 Provide Database Table name: V_TDEVC Select Display option Select Contents option Select Package option Rohini kumar
SAP-ABAP
127
Provide Package name: ZABAP Short Description: New Package Save Step-2: Go to SE38 Program: ZDEMO_PACKAGE Create Title: Package Program Type: Executable Program Save Package: ZABAP Save (Enter) Note: 1. By default you may find a Request Number. The Request Number belongs to some other ABAPER 2. Never select Enter option on that pop-up
Select Create Request (F8) Short Description: HR/ABAP: Employee Details Report (24.09.2014) Enter Enter
WRITE:/ ‘Welcome to ABAP’. Activate program (Ctrl+F3) Step-3: Go to SE10 Select Work Bench Request Under Request Status, select Modifiable check box & deselect Released check box Select Display option Expand Main Request Number Select Sub Request Number Select Truck Symbol (F9) Select Main Request Number Select Truck Symbol (F9) Go to Back (F3) Select Released check box & deselect Modifiable check box Select Display option Note: Rohini kumar
SAP-ABAP
128
Up to here you have to perform in real time, from here you have to send a mail to your Basis Consultant for transporting TR-Number from Development Client to Quality Client Once the Request Number is transported from Development Client to Quality Client as a TC now you have to login to Quality Server & test the Object If it is fine now you will send a mail to your FC to test the same If it is fine FC will update the Tread in Solution Manager to test the Object Similarly End user will perform final testing in Quality Server Note: Always store identical Objects in one Request Number & different Objects in different Request Numbers
Rohini kumar
SAP-ABAP
129
Version Management: Using Version Management you can get the history of a program with Request Numbers, User name, Date of creation & change It is highly useful to programmer if requires to retrieve old version instead of current version Example: Go to SE38 Program: ZDEMO Select Utilities ----------- Versions ------ Version Management Ques: How you can store an Object from Local Object to existing Package? Ans: Go to SE38 Program: name which is stored in Local object Select Goto ---- Object Directory Entry Select Change option Package: ZABAP Save Ques: How you can delete an Object from existing Request Number? Ans: Go to SE11 Database Table: E071 Display Contents option Object Name; program name (ZDEMO) Execute (F8)
Go to SE10 Select Display Expand Main Request Number Expand Sub Request Number Expand Program option Select your program Select Delete option You will find a message, Enter Yes
Rohini kumar
SAP-ABAP
Sub Objects in ABAP Editor: 1. Source Code 2. Variants 3. Attributes 4. Documentation 5. Text Elements Source Code: It is nothing but source code of a program Attributes: It specifies attributes of a program (Title, Type, Date of creation & Change,………..etc) Documentation: Using this option you can provide documentation for a program Example: Go to SE38 Program: ZDEMO Documentation Change Provide Purpose: The report is displaying segment wise materials details Provide Integration: No Provide Prerequisites: s_matnr s_werks Save Text Elements: Using Text Elements you can maintain Labels (or) Selection Screen Fields Example: Go to SE38 Program: ZDEMO Text Elements Change Selection Text Name Text s_matnr Material Code s_werks Plant Activate
Rohini kumar
130
SAP-ABAP
131
Variants: Using Variants you can provide default input values for a Selection Screen In background scheduling report, the reports are executed automatically by system in background. For such reports the input values are supplied by using Variants Example: Go to SE38 Program: ZDEMO Variants Change Variant: ZVAR Create Enter input values i.e. 100-100 to 100-500 fart Select Attribute option (F6) Meaning: Variant Creation Save Run the report Select Get Variant option Double click on variant name (ZVAR)
Rohini kumar
SAP-ABAP
132
ABAP-EDITOR Interview Questions & Answers: 1Q: What is ERP? Ans: ERP is a package under which all the business resources are integrated in one system 2Q: When did ABAP Consultant meets Clients? Ans: ABAP Consultant will not meet Clients Only Functional Consultant will meets Clients ABAP Consultant only meets Functional Consultant 3Q: What are the Services in R/3 Architecture? Ans: There are 9 services in R/3 Architecture 1. Dialog service 2. Update service 3. Spool service 4. Background service 5. En-Queue service 6. Message service 7. Gateway service 8. SAP GUI front end service 9. Database service 4Q: Where you can also execute programs other than ABAP Editor (SE38)? Ans: We can also execute programs in Object Navigator (SE80) 5Q: What is the default Data type in ABAP Programming? Ans: Character (C) 6Q: What are the SAP provided Business Data types? Ans: QUAN, CURR, NUME 7Q: What is : operator in ABAP programming? Ans: It is called Chain Operator. It is for repeating Declarative Part 8Q: Which file is generated by system when you execute the program? Ans: SAPGUI.EXE file
Rohini kumar
SAP-ABAP
133
9Q: What is purpose of Activating the Objects? Ans: To store the Objects in Database Server To integrate the Objects with each other To debug & transport the objects 10Q: What is the T Code for Debugging? Ans: /H 11Q: How many sessions you can open simultaneously in SAP? Ans: 6 sessions 12Q: What is the use of Internal Table in SAP? Ans: For storing different types of application data from different tables at one place 13Q: What is the difference between Database table & Internal table? Ans: Database Table Internal Table 4. It is created in Database Server ------- 1. It is created in Application Server 5. It holds data permanently ------- 2. It holds data temporarily 6. It holds only specific type of data ----- 3. It holds data of different tables of at one place 14Q: What is the default comparison operator for SELECT-OPTIONS? Ans: ‘IN’ 15Q: What is the default comparison operator for PARAMETERS? Ans: ‘EQ’ 16Q: What is the default order of SORT? Ans: ASCENDING 17Q: What is difference between APPEND & COLLECT? Ans: APPEND keyword appends the record from Work Area to Body (always to next line in an Internal Table) COLLECT keyword performs append job if the record fails to exist in the Body If already records exists it adds all Numeric Values on right side of Character Field inside the Body 18Q: When you will use COLLECT keyword in real time? Ans: Whenever I will get a requirement for providing consolidated totals based on Customers, Vendors, Materials,………etc Rohini kumar
SAP-ABAP
134
19Q: Suppose there are more than two Character Fields then what is the roll of COLLECT keyword? Ans: If there are more than two Character Fields it will collect the data (adds) only when both the Character Fields are same 20Q: What is difference between APPEND & MODIFY keywords? Ans: APPEND always appends record to Internal Table (if record exists (or) not) MODIFY always modifies (adds field value) only if record exists in an Internal Table 21Q: When you will prefer MODIFY keyword in ABAP programming? Ans: When all the data in an Internal Table is filled and a new field value is required to be added in an Internal Table 22Q: What will happen if CLEAR is providing before Work Area & the same CLEAR is provided in after Work Area? Ans: If CLEAR is provided before Work Area data so nothing is transferred from Work Area to Virtual Page (hence no output) If CLEAR is provided after Work Area, data is transferred from Work Area to Virtual Page then Work Area is cleared (hence you will find output) 23Q: What is difference between SUM & COLLECT keyword? Ans: COLLECT keyword is applicable with in LOOP………ENDLOOP without usage of Control Break Statements COLLECT keyword performs totals inside internal body based on one (or) more than one Character Fields SUM keyword performs totals only on Single Character Field for Control Break Statements & places the values in Work Area COLLECT keyword works outside LOOP………ENDLOOP also where as SUM can be applied only within LOOP…….ENDLOOP 24Q: What is default Internal Table in SAP? Ans: Standard Table 25Q: What is the prefix for System Variables? Ans: SY
Rohini kumar
SAP-ABAP
135
INTERNAL TABLES 1Q : How to delete duplicates from an internal table? Ans: To delete all duplicate entries from a sorted internal table (e.g. just after SORT), you can use the DELETE ADJACENT DUPLICATES FROM i_tab statement. You can use the COMPARING addition to limit the fields that are used to test for duplicate entries Ex: SORT i_tab by matnr werks logort. DELETE ADJACENT DUPLICATES FROM i_tab COMPARING matnr werks. All duplicates with same combination of matnr and werks will be deleted 2Q : What are types of internal tables? Ans: There are three types of Internal Tables exist 1. Standard Internal Tables: These tables have a linear index and can be accessed using the index or the key. The response time is in linear relationship with number of table entries. These tables are useful when user wants to address individual table entries using the index. 2. Sorted Internal Tables: These tables also have an index and the key. But, the response time is in logarithmic relationship with number of table entries, since it uses binary search algorithm instead of linear search. These tables are useful when user wants the table to be sorted while additional entries have to be added. 3. Hashed Internal Tables: These tables have no index, but have the key. The response time is constant irrespective of number of table entries, since it uses a Hash algorithm. These tables are useful when user wants to access the entries with key only.
Rohini kumar
SAP-ABAP
136
3Q : What is the size of internal table? Ans: The size of the internal tables is set using the 'OCCURS n' clause. Here ‘n’ refers to a integer number that specifies the size. Usually it given as 'OCCURS 0' which creates an internal table with the memory space of 8kb. The size of the internal table is the product of width and number of lines of the internal table. We can set the estimated number of lines of internal table in the OCCURS parameter. When first table entry is filled the runtime system allocates suitable memory to hold the whole table If the memory allocated is not sufficient then again a block of memory is allocated (in case of number of lines more than estimated lines). Therefore the OCCURS parameter does not affect the actual size of the internal table but the performance of the internal table operations. So if you are not able to estimate the lines, then give occurs parameter to zero. Then system automatically does it for you. 4Q : What is the effective way of using internal table record? Ans: Create Internal table without Header. Do all the internal table operations by Creating Work area. This would be the efficient way of coding. Don't forget to CLEAR Work area whenever it is required. 5Q : Explain Sorted Tables in Sap internal tables? Ans: This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition. 6Q : What is difference between internal table and structure? Ans: Internal table holds multiple records and structure holds single record during runtime.
Rohini kumar
SAP-ABAP
137
7Q : What are field groups and internal tables? Ans: Field groups are nothing but a similar type of fields grouped under single name (group) or grouping of the fields is called field groups. Internal tables are stored temp memory/in buffer for the further processing of the fields. 8Q : What is sap internal tables key? Ans: The key identifies table rows. There are two kinds of key for internal table keys 1. Standard key 2. User- defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method. If a table has a structured line type, its default key consists of all of its non-numerical columns that are not references or themselves internal tables. If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty. The user-defined key can contain any columns of the internal table that are not references or themselves internal tables. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key. 9Q : Explain Hashed tables in sap? Ans: This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.
Rohini kumar
SAP-ABAP
138
10Q: What do mean by table types. Ans: The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types: 1. Standard tables It has an internal linear index. From a particular size upwards, the indexes of internal tables are administered as trees. In this case, the index administration overhead increases in logarithmic and not linear relation to the number of lines. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. The key of a standard table is always non-unique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries. 11Q: What are control levels in internal tables? Ans: The control breaks in an Internal Table are Control Levels are of 5 types 1) AT FIRST 2) AT NEW 3) AT END OF 4) AT LAST 5) ON CHANGE OF 12Q: How can you specify internal tables as data objects? Ans: Data objects that are defined either with the data type of an internal table (or) directly as an internal table, are always fully defined in respect of their line type, key and access method. However, the number of lines is not fixed. Thus internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restrictions on the number of lines an internal table may contain are the limits of your system installation. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 GB. A more realistic figure is up to 500 MB. Rohini kumar
SAP-ABAP
139
An additional restriction for hashed tables is that they may not contain more than 2 million entries. The line types of internal tables can be any ABAP data types - elementary, structured, or internal tables. The individual lines of an internal table are called table lines or table entries. Each component of a structured line is called a column in the internal table. 13Q: What is generic internal table? Ans: Unlike other local data types in programs, we do not have to specify the data type of an internal table fully. Instead, we can specify a generic construction, that is, the key or key and line type of an internal table data type may remain unspecified. We can use generic internal tables to specify the types of field symbols and the interface parameters of procedures. We cannot use them to declare data objects. 14Q: Explain standard internal tables? Ans: This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option with key access, the response time is logarithmically proportional to the number of table entries.
Rohini kumar
SAP-ABAP
140
15Q: What are internal tables, value tables, check tables, transparent tables? Ans: Internal table: It is a standard data type object, which exists only during the runtime of the program. Check table: Check table will be at field level checking. Value table: Value table will be at domain level checking Ex: scarr table is check table for carrid. Transparent table: Exists with the same structure both in dictionary as well as in database exactly with the same data and fields 16Q: Explain choosing a table type in internal table. Ans : The table type (and particularly the access method) that you will use depends on how the typical internal table operations will be most frequently executed. 17Q: Explain row type and line type concept? Ans: Line type refers to the structure of an internal table Whereas row type is the actual part that contains the data and it refers to the table body Creating internal table using line type and row type concept is for reusability purpose. Line type and Row type are defined at DDIC LEVEL. 18Q: What is the difference between internal table and work area? Ans : An internal table is a run time instance. It get created when program starts execution. *It get destroyed when program terminates. It has two different parts: Header Line (optional) Body (Compulsory). *Any value that comes to (or) goes from internal table, that travels through header line.
Rohini kumar
SAP-ABAP
141
19Q: Difference between database tables and internal tables? Ans : The basic difference is database tables are stored in DB server Internal tables are virtual tables these are created run time only Internal tables are created dynamically The memory of internal tables is not permanent memory For internal tables the memory will be created in the application server and it is external memory and terminates after the program termination. 20Q: What is the difference between collect and append? Ans: Collect holds summarized data (collect the sums based on name etc) Append will appends the data from header line (work area) to body
Rohini kumar
SAP-ABAP
142
DATA DICTIONARY Interview Questions & Answers: 1Q: Have you ever created a Z-Table? Why explain the requirement? Ans: Yes, SAP is not providing table for Allowances. Simultaneously SAP is not providing a table for Transportation Details. Simultaneously in real time we have to create a table for Customer Mail Ids for sending invoice details………….etc 2Q: Explain difference between Standard Table & Z-Table? Ans: Standard Table is system defined table. It starts with A, B,C,………………….X Z-Table is user defined table. It starts with Y (or) Z 3Q: What is the difference between Structure & Table? Ans: Structure Table 3. It is a collection of fields & it 1. It is a Structure & hold data persistently Never hold data 4. It can be reuse in other tables 2. It cannot be reuse 4Q: What is the difference between View & Table? Ans: Table View 3. Having its own fields & data 1. Always created based on other table 4. It holds either master data (or) 2. It holds both master data & transactional data Transactional data 5 Q: What is the difference between Top-Bottom & Bottom-Top approach of crating tables? Ans: Top-Bottom: Table---Data Element----Domain Bottom-Top: Domain-----Data Element----Table 6 Q: What is a View? Explain the importance of View? Ans: It is a logical table (virtual table) which is created based on other tables It hires Fields & Data from other tables It is used to generate reports based on user required fields
Rohini kumar
SAP-ABAP
143
7 Q: What is the difference between Database View & Projection View? Ans: Database View is always created based on two (or) more than two tables having relationship between them Projection View is created based on a single table with specific fields 8 Q: What is the difference between Open SQL statements & Native SQL statements? Ans: Native SQL Statements: These are traditional SQL statements With Native SQL Statement request is directly forwarded to Database Server which processes the request & returns the response With Native SQL statement performance of the system is highly degraded Syntax: EXEC SQL. SELECT……………… ENDEXECSQL. Open SQL Statements: These are normal SQL statements which are converted to embedded SQL using database interface which is further passed to Buffer, if data is available in Buffer you will get the response 9 Q: Explain Buffering & its advantages? Ans: Buffering is a way of improving performance which accessing data from database. Whenever you run a program it will make a request to Buffer for data, if it is not available it will make a request to Database Server which returns response to Buffer & simultaneously to Program. Next time whenever you run the same program this time it will collect the data directly from Buffer 10 Q: What are the different types of Tables? Ans: There are 3 types of tables in SAP 4. Transparent Table 5. Cluster Table 6. Pooled Table 11Q: Mention some Cluster Tables that you are using in real time? Ans: These tables hold SAP proprietary format data (system data, statistical data, control data……) Example: BSEG, KONU 12Q: What is the difference between .INCLUDE & APPEND STRUCTURE? Rohini kumar
SAP-ABAP
Ans:
144
Using .INCLUDE you can add a Structure in N no. of tables .INCLUDE is best for adding Structure in ZEE tables Using APPEND STRUCTURE you can add a Structure only in a single table APPEND STRUCTURE is best for adding Structure in Standard Tables
13 Q: How many tables you can reuse a Structure in other tables? Ans: N number of tables 14 Q: How many times APPEND STRUCTURE can be used by other tables? Ans: only One time 15 Q: What is Database Utility? Ans: Using Database Utility you can reactivate a table (adjust a table in database) The Tcode is SE14 Sometimes you may find errors when you change the Primary key (or) Domain name, it Data type…….etc you will find an error Structure Level Changes To adjust such errors select Utilities----Database Object---Database Utility Scroll down to bottom select Activate and Adjust Database 16 Q: What is the difference between Data Element & Domain? Ans: Data Element: Using Data Element you can provide field documentation for a specific field Conceptually Data Element = Field Lable + Domain Domain: It specifies the technical attributes of a field (Data Type & Field Size) 17 Q: What are main functionalities of Domain? Ans: Maintains Data type Technical attributes of Fields Value Range 18Q: What is Value Range under Domain option? Ans: Using Value Range you can maintain fixed values and can be called in other programs as a Search Help 19Q: What is the Search Help? How you can maintain a search to specific field in a table? Ans: Using search help you can search application data based on given search criteria Rohini kumar
SAP-ABAP
145
Search help works based on F4 function key 20Q: It is possible to create a field without Data Element? Ans: Yes, using Predefined Type option But it is always advisable to create with Data Element only 21Q: What is the difference between Client Dependent Table & Client Independent Table? Ans: A table created without MANDT field is Client Independent table. Client Independent tables are available in other clients also with data A table created with MANDT field is Client Dependant table. Client Dependent tables are available in other clients also without data 22Q: It is possible to create a table without Primary key? Ans: No 23Q: What is the difference between Master Data & Transactional Data? Ans: Master Data: It is created only once in Client Database & modified very rarely Example: Bank Master Data, Customer Master Data, Vendor Master Data, Employee Master Data…etc Transactional Data: It is always created based on Master Data It is modified frequently in SAP database Example: Purchase Order Data, Sales Order Data………..etc 24Q: Define Data Class & Size Category? Ans: Data Class: It is a physical storage location (or) table space where tables are stored ultimately after activation. It is of 3 types 4. APPL0 (holds master data tables) 5. APPL1 (holds transactional data tables) 6. APPL2 (holds organizational & customizing data related tables) Size Category: It specifies the probable space requirement for a table in the database 25Q: What is TMG? What is the need of creating TMG in real time? Ans: Using TMG you can directly Insert, Update, Delete data from a database table Rohini kumar
SAP-ABAP
146
In real time for certain requirements when data is not linked with other tables. Data can be inserted (or) manipulated from table level directly. This can be done by creating a TMG on that table 26Q: It is possible to create TMG on Standard Tables? Ans: No, TMG is allowed only for Z-tables 27Q: How you can create List Boxes & Check Boxes in TMG? Ans: CHK
ZCHK_DAT
Double click on ZCHK_DAT Save Yes You will find a warning pop-up: Enter You will find a pop-up: create data element Yes Provide Short Description: Check Box Provide Domain: ZCHK_DOMAIN Provide Data type: CHAR Provide No.of Characters: 1 Select Value Range tab FIX VAR Short Desciption X ON OFF Activate the domain (Ctrl+F3) 28Q: How you can provide Default Values such as Date & Time automatically in a table whenever user select Save option? Ans:
Providing default values using TMG: Select Utilities---Table Maintenance Generator Provide Authorization Group: &NC& Provide Function Group: ZMAIL_GR Select Find Scr Number option then press Enter Select Create option (F6) then press Enter Select Environment option Select Modification------Events You will find a message- do not make any changes on SAP data then press Enter Select New Entries option provide T Form Routine 05 Create_Entry Press Enter Under Editor double click
Rohini kumar
SAP-ABAP
147
You will find a pop-up then press Enter You will find a warnings pop-up then press Enter Provide code for default values FORM CREATE_ENTRY. ZFI_LIMITS-ERDAT = SY-DATUM. ZFI_LIMITS-UNAME = SY-UNAME. ZFI_LIMITS-ERTIM = SY-UZETT. ENDFORM. Activate table & go back 29Q: Mention some important Events that you created with TMG? Ans: CREATE_ENTRY 30Q: What is One Step & Two Step option in TMG? Ans: One Step---By these option we can insert all the records at a time Two Step---By these option we can insert one by one record 31Q: Why Function Group is added while creating TMG? Ans: 32Q: What is Authorization Group & Authorization Object in TMG? Ans: Authorization Group is for which group of clients can access table Ex: &NC& 33Q: How will add table values to a request number in ABAP? Ans: 34Q: What is the difference between SE11 & SE16? Ans: SE11 for creating all Data Dictionary Objects in SAP SE16 for just viewing data of specific table. Here manipulation of data is not possible
Rohini kumar
SAP-ABAP
148
35Q: Why it is mandatory to Activate a table in SAP? Ans: To store the Objects in Database Server To integrate the Objects with each other To debug & transport the objects 36Q: What is Indexing in SAP? What are types of Indexes? Ans: 37Q: What is Lock Object? Have you created Lock Object? Ans: No 38Q: What is the difference between Structure & Type Group? Ans: Structure: It is a group of fields Physically it will never hold any data Structure can be reuse in other programs & other tables Type Group: It is a group of Structures 39Q: What is Text Table? What is its significance? Ans: Use text table for storing explanatory texts. For storing such texts it is not advisable to store in Primary Table Text Tables works based on Primary & Foreign key relationship 40Q: How you can add a Field in Standard Table? Ans: Using Append Structure option 41Q: What are various Dictionary Objects? Ans: 10.Database Table 11.Structure 12.View 13.Data Element 14.Domain 15.Table Type 16.Type Group 17.Lock Object 18.Search Help 42Q: What is the significance of Data Dictionary in SAP? Rohini kumar
SAP-ABAP
149
Ans: It is also called ABAP Dictionary It is a repository of data T Code for Data Dictionary is SE11 43Q: Is it possible to create DDL operations directly in SAP? Ans: No
1Q : What are the layers of data description in R/3? Ans: • The external layer. • The ABAP/4 layer. • The database layer. 2Q : Define external layer? Ans: The external layer is the plane, at which the user sees and interacts with the data, That is, the data format in the user interface. This data format is independent of the database system used. 3Q : Define ABAP/4 layer? Ans: The ABAP/4 layer describes the data formats used by the ABAP/4 processor. 4Q : Define Database layer? Ans: The database layer describes the data formats used in the database. 5Q : What is a Data Class? Ans: The Data class determines in which table space the table is stored when it is created in the database. 6Q : What is a Size Category? Ans: The Size category describes the probable space requirement of the table in the database.
Rohini kumar
SAP-ABAP
150
7Q : How many types of size categories and data classes are there? Ans: There are five size categories (0-4) and 11 data classes Only three of size categories are appropriate for application tables: 1. APPL0- Master data (data frequently accessed but rarely updated) 2. APPL1- Transaction data (data that is changed frequently) 3. APPL2- Organizational data (customizing data that is entered when system is configured and then rarely changed) The other two types are: 4. USR 5. USR1 - Intended for customer's own developments. 8Q : What are control tables? Ans: The values specified for the size category and data class are mapped to database-specific values via control tables. 9Q : What is the function of the transport system and workbench organizer? Ans: The function of the transport system and the Workbench Organizer is to manage any changes made to objects of the ABAP/4 Development Workbench and to transport these changes between different SAP systems. 10Q: What is a table pool? Ans : A table pool (or pool) is used to combine several logical tables in the ABAP/4 Dictionary. The definition of a pool consists of at least two key fields and a long argument field (VARDATA). 11Q: What are pooled tables? Ans : These are logical tables, which must be assigned to a table pool when they are defined. Pooled tables can be used to store control data (such as screen sequences or program parameters).
Rohini kumar
SAP-ABAP
151
12Q: What is a table cluster? Ans : A table cluster combines several logical tables in the ABAP/4 Dictionary. Several logical rows from different cluster tables are brought together in a single physical record. The records from the cluster tables assigned to a cluster are thus stored in a single common table in the database. 13Q: How can we access the correction and transport system? Ans : Each time you create a new object or change an existing object in the ABAP/4 Dictionary, you branch automatically to the Workbench Organizer or correction and transport system. 14Q: Which objects are independent transport objects? Ans : Domains, Data elements, Tables, Technical settings for tables, Secondary indexes for transparent tables, Structures, Views, Match code objects, Match code Ids, Lock objects. 15Q: How is conversion of data types done between ABAP/4 & DB layer? Ans : Conversion between ABAP/4 data types and the database layer is done within the database interface. 16Q: How is conversion of data types done between ABAP/4 & external level? Ans : Conversion between the external layer and the ABAP/4 layer is done in the SAP dialog manager DYNP. 17Q: What are the Data types of the external layer? Ans : ACCP, Char, CLNT, CUKY, CURR, DATS, DESC, FLTP, INT1, INT2, INT4, LANG, LCHR, LRAW, NUMC, PREC, QUAN, RAW, TIMS, UNIT,VARC. 18Q: What are the Data types of the ABAP/4 layer? Ans : Possible ABAP/4 data types: Rohini kumar
SAP-ABAP
152
C: Character. D: Date, format YYYYMMDD. F: Floating-point number in DOUBLE PRECISION (8 bytes). I: Integer. N: Numerical character string of arbitrary length. P: Amount of counter field (packed; implementation depends on h/w platform). S: Time Stamp YYYYMMDDHHMMSS. V: Character string of variable length, length is given in the first two bytes. X: Hexadecimal (binary) storage. 19Q: How can we set the table spaces and extent sizes? Ans : You can specify the extent sizes and the table space (physical storage area in the database) in which a transparent table is to be stored by setting the size category and data class. 20Q: What is the function of the correction system? Ans : The correction system manages changes to internal system components. Such as objects of the ABAP/4 Dictionary 21Q: What are local objects? Ans : Local objects (Dev class$TMP) are independent of correction and transport system. 22Q: What is a Development class? Ans : Related objects from the ABAP/4 repository are assigned to the same development class. This enables you to correct and transport related objects as a unit. 23Q: What is a data dictionary? Ans : Data Dictionary is a central source of data in a data management system. Its main function is to support the creation and management of data definitions. It has details about • What data is contained? • What are the attributes of the data? • What is the relationship existing between the various data elements?
Rohini kumar
SAP-ABAP
153
24Q: What functions does a data dictionary perform? Ans : In a data management system, the principal functions performed by the data dictionary are • Management of data definitions. • Provision of information for evaluation. • Support for s/w development. • Support form documentation. • Ensuring that the data definitions are flexible and up-to-date. 25Q: What are the features of ABAP/4 Dictionary? Ans : The most important features are: • Integrated to aABAP/4 Development Workbench. • Active in the runtime environment. 26Q: What are the uses of the information in the Data dictionary? Ans : The following information is directly taken from the Data dictionary: • Information on fields displayed with F1 help. • Possible entries for fields displayed with F4 help. • Matchcode and help views search utilities. 27Q: What are the basic objects of the data dictionary? Ans: • Tables • Domains • Data elements • Structures • Foreign Keys 28Q: What are the aggregate objects in the data dictionary? Ans: • Views • Match codes • Lock objects. 29Q: In the ABAP/4 Dictionary Tables can be defined independent of the underlying database (T/F). Ans: True.
Rohini kumar
SAP-ABAP
154
30Q: ABAP/4 Dictionary contains the Logical definition of the table. Ans : 31Q: A field containing currency amounts (data type CURR) must be assigned to a reference table and a reference field. Explain. Ans: As a reference table, a system containing all the valid currencies is assigned or any other table, which contains a field with the currency key format. This field is called as reference field. The assignment of the field containing currency amounts to the reference field is made at runtime. The value in the reference field determines the currency of the amount. 32Q: A field containing quantity amounts (data type QUAN) must be assigned to a reference table and a reference field. Explain? Ans : As a reference table, a system table containing all the valid quantity units is assigned or any other table, which contains a field with the format or quantity units (data type UNIT). This field is called as reference field. The assignment of the field containing quantity amounts to the reference field is made at runtime. The value in the reference field determines the quantity unit of the amount. 33Q: What is the significance of Technical settings (specified while creating a table in the data dictionary)? Ans: By specifying technical settings we can control how database tables are created in the database. The technical settings allows us to • Optimize storage space requirements. • Table access behavior. • Buffering required. • Changes to entries logged. 34Q: What is a Table attribute? Ans: The table's attributes determine who is responsible for maintaining a table and which types of access are allowed for the table. The most important table attributes are: • Delivery class. • Table maintenance allowed. • Activation type. Rohini kumar
SAP-ABAP
155
35Q: What is the significance of Delivery Class? Ans: • The delivery class controls the degree to which the SAP or the customer is responsible for table maintenance. • Whether SAP provides the table with or without contents. • Determines the table type. • Determines how the table behaves when it is first installed, at upgrade, when it is transported, and when a client copy is performed. 36Q: What is the max. no. Of structures that can be included in a table or structure. Ans: Nine. 37Q: What are two methods of modifying SAP standard tables? Ans: • Append Structures and • Customizing Includes. 38Q: What is the difference between a Substructure and an Append Structure? Ans: • In case of a substructure, the reference originates in the table itself, in the form of a statement include.... • In case of an append structure, the table itself remains unchanged and the reference originates in the append structure. 39Q: To how many tables can an append structure be assigned. Ans: One. 40Q: If a table that is to be extended contains a long field, we cannot use append structures why? Ans: Long fields in a table must always be located in the end, as the last field of the table. If a table has an append structure the append line must also be on the last field of the table. 41Q: Can we include customizing include or an append structure with Pooled or Cluster tables? Ans: No. 42Q: What are the two ways for restricting the value range for a domain? Rohini kumar
SAP-ABAP
156
Ans: • By specifying fixed values. • By stipulating a value table. 43Q: Structures can contain data only during the runtime of a program (T/F) Ans: True. 44Q: What are the aggregate objects in the Dictionary? Ans: • Views • Match Code. • Lock Object. 45Q: What are base tables of an aggregate object? Ans : The tables making up an aggregate object (primary and secondary) are called aggregate object. 46Q: The data of a view is not physically stored, but derived from one or more tables (t/f) Ans: True. 47Q: What are the 2 other types of Views, which are not allowed in Release 3.0? Ans: • Structure Views. • Entity Views. 48Q: What is a Match Code? Ans: Match code is a tool to help us to search for data records in the system. Match Codes are an efficient and user-friendly search aid where key of a record is unknown. 49Q: What are the two levels in defining a Match Code? Ans: • Match Code Object. • Match CodeId. *50Q: What is the max no of match code Id's that can be defined for one Match code object?* Ans: A match code Id is a one character ID that can be a letter or a number. *51Q: Can we define our own Match Code ID's for SAP Matchcodes?* Ans : Yes, the number 0 to 9 are reserved for us to create our own Match Code Ids for a SAP defined Match code object. Rohini kumar
SAP-ABAP
157
52Q: What is an Update type with reference to a Match code ID? Ans : If the data in one of the base tables of a match code ID changes, the match code data has to be updated. The update type stipulates when the match code is to be updated and how it is to be done. The update type also specifies which method is to be used for Building match codes. You must specify the update type when you define a match code ID. 53Q: Can matchcode object contain Ids with different update types? Ans: Yes. 54Q: What are the update types possible? Ans : The following update types are possible: • Update type A: The matchcode data is updated asynchronously to database changes. • Update type S: The matchcode data is updated synchronously to database changes. • Update type P: The matchcode data is updated by the application program. • Update type I: Access to the matchcode data is managed using a database view. • Update type L: Access to the matchcode is achieved by calling a function module. 55Q: What are the two different ways of building a match code object? Ans : A match code can be built in two different ways: 1. Logical structure: The match code data is set up temporarily at the moment when the match code is accessed. (Update type I, k). 2. Physical Structure: The match code data is physically stored in a separate table in the database. (Update type A, S, P).
Rohini kumar
SAP-ABAP
158
56Q: What are the differences between a Database index and a match code? Ans: • Match code can contain fields from several tables whereas an index can contain fields from only one table. • Match code objects can be built on transparent tables and pooled and cluster tables. 57Q: What is the function of a Domain? Ans: • A domain describes the technical settings of a table field. • A domain defines a value range, which sets the permissible data values for the fields, which refers to this domain. • A single domain can be used as basis for any number of fields that are identical in structure. 58Q: Can you delete a domain, which is being used by data elements? Ans: No. 59Q: What are conversion routines? Ans: • Non-standard conversions from display format to sap internal format and vice-versa are implemented with so called conversion routines. 60Q: What is the function of a data element? Ans: A data element describes the role played by a domain in a technical context. A data element contains semantic information. 61Q: Can a domain, assigned to a data element be changed? Ans : Yes. We can do so by just overwriting the entry in the field domain. 62Q: Can you delete data element, which is being used by table fields. Ans : No. 63Q: Can you define a field without a data element? Ans : Yes. If you want to specify no data element and therefore no domain for a field, you can enter data type and field length and a short text directly in the table maintenance. 64Q: What are null values? Ans : If the value of a field in a table is undefined or unknown, it is called a null value. 65Q: What is the difference between a structure and a table? Ans : Structures are constructed the almost the same way as tables, the only difference using that no database table is generated from them. Rohini kumar
SAP-ABAP
159
66Q: What is a view? Ans : A view is a logical view on one or more tables. A view on one or more tables i.e., the data from a view is not actually physically stored instead being derived from one or more tables. 67Q: How many types of Views are there? Ans: • Database View • Help View • Projection View • Maintenance View 68Q: What is Locking? Ans : When two users simultaneously attempt to access the same data record, this is synchronized by a lock mechanism. 69Q: What is database utility? Ans : Database utility is the interface between the ABAP/4 Dictionary and the underlying the SAP system. 70Q: What are the basic functions of Database utility? Ans : The basic functions of database utility are: • Create database objects. • Delete database objects. • Adjust database objects to changed ABAP/4 dictionary definition. 71Q: What is Repository Info Systems? Ans : It is a tool with which you can make data stored in the ABAP/4 Dictionary available
Rohini kumar
SAP-ABAP
LFA1 Table: This table holds Vendor Master Data Fields: 1. Lifnr-------Vendor Number 2. Land1-----Country of Vendor 3. Name1----Name of Vendor 4. Ort01-----City of Vendor 5. Pstlz------Postal Code of Vendor 6. Adrnr-----Address Number Links: LFA1~adrnr ADRC~addrnumber 7. Brsch-----Industry Key
Rohini kumar
160
SAP-ABAP
EKKO Table: This table holds Purchase Order Header Data Fields: 1. Ebeln-------Purchase Order Number 2. Bukrs------Company Code 3. Bsart-------Purchasing Document Type 4. Statu-------Status of Purchase Order 5. Lifnr-------Vendor Number Links: LFA1~lifnr EKKO~lifnr 6. Zterm------Payment Terms 7. Zbd1p-----Cash Discount Percentage 8. Ekorg------Purchase Organization (Purchase Department) 9. Ekgrp------Purchasing Group 10.Waers------Currency 11.Wkurs------Exchange Rate 12.Bedat-------Purchase Order Date 13.Inco1, Inco2-------International Terms for Carrying Bussiness 14.Knumv------Tax Number Links: EKKO~knumv KONU~knumv 15.Kalsm------Pricing Procedure 16.Frgke-------Release Indicator
Rohini kumar
161
SAP-ABAP
EKPO Table: This table holds Purchase Document Item Data Fields: 1. Ebeln-------Purchase Order Number Links: EKKO~ebeln EKPO~ebeln 2. Ebelp------Item Number 3. Txzo1-----Item Text 4. Matnr-----Material Code 5. Werks-----Plant 6. Lgort------Storage Location 7. Matkl-----Material Group 8. Menge------Purchase Order Quantity 9. Meins------Unit of Measurement 10.Netpr------Unit Price 11.Netwr------Total Price 12.Mwskz-----Sales Tax Code 13.Elikz--------Delivery Completed Indicator
Rohini kumar
162
SAP-ABAP
MKPF Table: It holds Material Document Header Data Fields: 1. Mblnr ---------- Material Document Number 2. Mjahr ---------- Material Document Year 3. Blart ---------- Material Document Type 4. Budat ---------- Material Document Date 5. Xblrn ---------- Reference Document (Purchase Order Document) Number
Rohini kumar
163
SAP-ABAP
MSEG Table: It holds Material Document Item Data Fields: 1. Mblnr ------ Material Document Number 2. Mjahr ------ Material Document Year 3. Bwart ------ Moment Type 4. Werks ------ Plant 5. Lgort ------- Storage Location 6. Charg ------ Batch Number 7. Lifnr ------- Vendor Account Number Link: LFA1-lifnr MSEG-lifnr 8. Shkzg ------- Debit / Credit Indicator 9. Dmbtr ------ Amount in Local Currency 10.Menge ------ Quantity 11.Meins ------- Unit of Measurement 12.Ebeln ------- Purchase Order Number Link: EKPO-ebeln MSEG-ebeln 13.Ebelp -------- Item Number Link: EKPO-ebelp MSEG-ebelp 14.Smbln ------- Number of Material Document Number 15.Kostl -------- Department 16.Aufnf ------- Production Order Number
Rohini kumar
164
SAP-ABAP
MARA Table: It holds Material Master Data Fields: 1. Matnr -------- Material Number 2. Ersda --------- Date of Creation 3. Ernam -------- Person who Created that Material 4. Mtart --------- Material Type 5. Mbrsg -------- Industry Key 6. Matkl --------- Material Group 7. Bismt --------- Old Material Number 8. Miens --------- Unit of Measurement 9. Brgew -------- Gross Weight 10.Ntgew -------- Net Weight 11.Spart ---------- Division Code
Rohini kumar
165
SAP-ABAP
166
MAKT Table: It holds Material Description Details Fields: 1. Matnr -------- Material Number 2. Spras -------- Language Key 3. Maktx ------- Material Description TSPAT Table: It holds Division Description Details Fields: 1. Spras --------- Language Key 2. Spart --------- Division Code 3. Vtext --------- Division Description
INDEX 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
ABAP Transactions (or) Module Pool Programming (or) Dialog Programming Events in Module Pool Programming Sub Screen Area Table Control Tab Strip Control Mail Coding Applications LUW Functionality CHAIN Keyword Table Control Wizard Input / Output Field Assignment Log sheet Temperature Details Assignment Cheques Date Entry Screen Assignment Simple calculator Reports (Classical, Interactive, ALV, LDB (Logical Data Base) &SAP Query Reports ) 1. Classical Reports (Events in Classical Reporting) MM - PO and Tax Details Report KONV Table MM - Po Delivery Status Report (Assignment) 2. Interactive Reporting ( HIDE, SY-LSIND, SY-LISEL, GET CURSOR) SAP Memory (SET PARAMETER)
Rohini kumar
5 5 11 15 22 33 34 36 37 38 49 54 56 60 61 62 67 73 74 75 76
SAP-ABAP
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
SD - Invoice Details based on Customers VBRK, VBRP, ADRC Tables 3. ALV Reporting (Traditional ALV & ALV with OOP ) A)Traditional ALV(Simple, Blocked & Hierarchal Sequential ALVs) i) Simple ALV (Classical & Interactive ALV) a) Classical ALV MM - Open PO Details Report REUSE_ALV_GRID_DISPLAY MM - Restricted & Unrestricted stock details report material wise & plant wise Report MARD Table SLIS_SORTINFO_ALV, SLIS_LISTHEADER, SLIS_ALV_EVENT Monthly sales report based on customers Report (Assignment) Sales analysis report (Assignment) b) Interactive ALV Customer master details Report PP - Movement type wise sale production consumption details for materials Report SD - Sales register report SD Flow J_1IEXCHDR, VBFA Tables VBKD Table Material wise Invoice & Realization details Report(Assignment) ii) Blocked ALV Function Modules for Blocked ALVs SD - Invoice details Customer wise, Material wise & Segment wise Report iii) Hierarchal Sequential ALV MM - PO Price Change Report FI Module HR Module 4. Logical Database HR - Employee Details Report Employee Total Details Report (Assignment) 5. SAP Query Performance Tuning Indexing (Primary Index & Secondary Index) SQL Tracer Runtime Analysis ABAP Examples & ABAP Documentation Extended Program Check
Rohini kumar
167
77 82 84 84 85 85 85 90 92 95 96 97 98 99 99 108 120 122 123 124 124 125 125 126 128 128 136 139 145 145 149 150 152 153 155 157 158 159
SAP-ABAP
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
Code Inspector GET RUN TIME FIELD keyword Creating Custom Logical Database Material Ageing Report (Assignment) Packing Cost Material Report (Assignment) Overview of Reports OOABAP Section of a Class (Class Definition, Class Implementation & Class Execution) FI - Statement of Account based on Customer Report Local Class BSID & BSAD Tables Inheritance FI - Vendor Aging Report BSIT & BSAK Tables Abstract Class Employee Family & Previous Employers Details Report (Assignment) Employee Late Coming Report (Assignment) Global Class Constructor Asset Register Report (Assignment) PR to GR Report (Assignment) Interface Functionality Alias PP Module Event Functionality Exception Class B) ALV Object Oriented Programming Custom Control QM - Report for Quality Notifications Report PP - Packing cost material report using interactive functionality with 2 custom controls Report MAST, STAS, STOP & MBEW Tables Exception Coding Button Functionality Hyperlinks Functionality Questions & Answers Module Pool Programming Reports Interactive Reports OOABAP
Rohini kumar
168
160 161 163 165 166 167 168 170 172 178 178 179 179 186 187 194 195 196 201 202 203 204 210 211 213 220 221 221 222 226 234 235 236 243 244 244 246 272 278
SAP-ABAP
Rohini kumar
169
SAP-ABAP
170
MODULE POOL PROGRAMMING 24-09-2014 ABAP Transactions: It is also known as Module Pool Programming It is also known as Dialog Programming Transaction: A transaction is a series of Dialog Steps in which application will accept data from user which is finally updated to Database
Name1 Ort01
Flow Logic
Dialog Programming
Land1
Display exit
Note: Flow Logic (Events) acts as interface between Screen Painter & Dialog Programming Events in Dialog Programming: 1. PAI (Process After Input) 2. PBO (Process Before Output) 3. POH (Process on Help Request) 4. POV (Process on Value Request) PAI: It triggers after processing input values in a screen This event triggers whenever user interacts with a screen PBO: It triggers before screen display Note: 1. PAI will brings the data from Screen to Program Variables 2. PBO will brings the data from Program Variables to Screen Rohini kumar
SAP-ABAP
171
POH: It triggers whenever user select F1 Function Key. It is for help POV: It triggers whenever user select F4 Function Key. It is for search help Flow of Data in Module Pool Programming:
Transfer data from Screen to Program variables Dialog Programming
Screen
Transfer data from Program Variables to Screen Function Control Codes: It is also known as FCT codes Using FCT codes Function Codes can be controlled (or) identified in Module Pool Programming SY-UCOMM Logic
Logic
FCT
FCT
Display
Insert
Dialog Programming SY-UCOMM: It returns FCT value for a function key (button) in Dialog programming selected by user Steps: 1. Work with SE38 (create a Dialog Programming) 2. Work with SE51 (create a Screen) 3. Work with SE93 (create a T code) 4. Run the T code Rohini kumar
SAP-ABAP
172
Requirement:
Kunnar Land1 Name1 Ort01 Pstlz strs
Display
Clear
Exit
Solution: Step-1: Go to SE38 Program: ZSD_CUSTOMER_DETAILS Create Title: Customer Details Type: Module Pool Enter Package: ZABAP Save Create Request Short Description: SD/ABAP: Customer Details (25.09.2014) Enter Enter Step-2: Go to SE51 Program: ZSD_CUSTOMER_DETAILS Screen Number: 100 Create Short Description: Screen 100 Layout button Place a box (last from 6th option) on the screen Rohini kumar
SAP-ABAP
Note: Place the mouse pointer on the icon & click on it Bring mouse pointer on the screen & drag & drop it on the screen according to requirement Double click on Frame of the box You will find an attributes pop-up Provide Text: Customer Details Close Select Dictionary Program Fields button (F6) You will find a pop-up Table Name: KNA1 Enter You will find fields of the table Select Kunnr, Land1, Name1, Ort01, Pstlz, Stras Enter Place the fields with the help of mouse pointer on the box & right click Place 3 Push buttons (starting from 6th option) on Tool bar Double click on 1st Push button Text: Display FCT Code: Display Close Double click on 2nd Push button Text: Clear FCT Code: Clear Close Double click on 3rd Push button Text: Exit FCT Code: Exit Close Flow Logic button (F9) Remove comment for MODULE USER_COMMAND_100. Double click on USER_COMMAND_100 You will find a pop-up Create Object: Yes By default New Include selected Select Main Program Enter Yes
Rohini kumar
173
SAP-ABAP
174
TABLES: KNA1. DATA: BEGIN Land1 Name1 Ort01 Pstlz Stras END
OF wa_kna1, TYPE land1, TYPE name1, TYPE ort01, TYPE pstlz, TYPE stras, OF wa_kna1.
Scroll down to bottom Place cursor between MODULE…………ENDMODULE of USER_COMMAND_100. CASE SY-UCOMM. WHEN ‘Display’. SELECT SINGLE land1 name1 ort01 pstlz stras INTO wa_kna1 FROM KNA1 WHERE kunnr EQ KNA1-kunnr. WHEN ‘Clear’. CLEAR: wa_kna1, KNA1-kunnr. WHEN ‘Exit’. LEAVE PROGRAM. ENDCASE.
Activate the program Back (F3) Remove comment for MODULE STATUS_100. Double click on STATUS_100 Yes Main Program Enter Enter Place mouse pointer between MODULE…………ENDMODULE of STATUS_100
KNA1-land1 = wa_kna1-land1. KNA1-name1 = wa_kna1-name1. KNA1-ort01 = wa_kna1-ort01. KNA1-pstlz = wa_kna1-pstlz. KNA1-stras = wa_kna1-stras. Activate the program Back (F3) Activate the screen Rohini kumar
SAP-ABAP
175
Step-3: Go to SE93 Transaction Code: ZCUSTOMER Create Title: T code for Customer Details Enter Program: ZSD_CUSTOMER_DETAILS Screen Number: 100 Save Enter Run the T code (ZCUSTOMER) 25-09-2014 Brief Flow: 1. PBO (Screen is called) 2. PAI (This event will triggers whenever you select a Button) 3. PBO (This will carry the data from Program Variables i.e. wa_kna1-kunnr = KNA1kunnr to screen field) Debugging a Module Pool Program: Go to SE38 Program: ZSD_CUSTOMER_DETAILS Change Place cursor at WHEN ‘DISPLAY’. Select Stop Place cursor between MODULE………..ENDMODULE of STATUS_100. Select Stop Run T code (ZCUSTOMER) Enter
Rohini kumar
SAP-ABAP
176
Sub Screen Area: It is a location where sub screens can be called in Main screen Note: In SAP you can create only 1 Normal Screen in an application & remaining all are Sub screens Requirement: Material Code
Material Type Material Group Gross Weight Net Weight Division
Display Clear Exit
Material Description
Sub screen area (sub) Main screen (100)
sub screen (110)
Syntax for Calling Sub Screen in Sub screen area: CALL SUBSCREEN INCLUDING Example: CALL SUBSCREEN SUB INCLUDING ‘ZMM_MATERIAL_SUB’ ‘110’ Solution: Step-1: Go to SE38 Program: ZMM_MATERIAL_SUB Create Title: Materials Details with Sub Screen Type: Module Pool Save Package: ZABAP Enter Create Request Rohini kumar
SAP-ABAP
177
Short Description: MM/ABAP: Materials Details with Sub Screen (26.09.2014) Enter Enter Step-2: Go to SE51 Program: ZMM_MATERIAL_SUB Screen: 100 Create Short Description: Screen 100 Layout Dictionary Program Fields (F6) Table Name: MARA Enter Select matnr field Enter Place the field on the top of the screen Place Sub Screen Area (last from 5th option) on the screen Double click on Sub Screen Area Name: SUB Close Place 3 Push Buttons (starting from 6th option) under Sub Screen Area Provide Text & FCT code as per requirement Select Flow Logic Remove comment for MODULE USER_COMMAND_100 Double click on USER_COMMAND_100 Yes Main Program Enter Yes TABLES: MARA, MAKT. Place cursor between MODULE……….ENDMODULE of USER_COMMAND_100 CASE SY-UCOMM. WHEN ‘DISPLAY’. SELECT SINGLE mtart matkl brgew ntgew spart FROM MARA INTO (MARA-mtart, MARA-matkl, MARA-brgew, MARA-ntgew, MARA-spart) WHERE matnr = MARA-matnr. SELECT SINGLE maktx FROM MAKT INTO MAKT-maktx Rohini kumar
SAP-ABAP
WHERE matnr = MARA-matnr AND spras = ‘EN’. WHEN ‘CLEAR’. CLEAR: MARA, MAKT. WHEN ‘EXIT’. LEAVE PROGRAM. ENDCASE. Activate program Back (F3) Place cursor under PROCESS BEFORE OUTPUT CALL SUBSCREEN SUB INCLUDING ‘ZMM_MATERIAL_SUB’ ‘110’.
Activate screen Back (F3) Screen: 110 Create Short Description: Sub Screen 110 ** Screen Type: Sub Screen Layout **place a box (last from 6th option) on top left corner of the screen Double click on frame of the box Text: Material Details Close Dictionary Program Fields (F6) Table Name: MARA Enter Select matnr, matkl, brgew, ntgew, spart fields Enter Place the fields on the box Dictionary Program Fields (F6) Table Name: MAKT Enter Select maktx field Enter Place the field on the box Flow Logic Activate screen
Rohini kumar
178
SAP-ABAP
Step-3: Go to SE93 Transaction Code: ZMATERIAL Create Short Text: T code for Materials Details Enter Program: ZMM_MATERIAL_SUB Screen Number: 100 Save Enter Run T code (ZMATERIAL)
Rohini kumar
179
SAP-ABAP
180
27-09-2014 Table Control: Use table control for processing multiple records Syntax for declaring Table Control: CONTROLS TYPE TABLEVIEW USING SCREEN Object: Truck Entry Screen Vendor DC DC Truck Gross Net Tare PO Vendor Number Date Number weight Weight Weight Number number
Display
Insert
Update
Reset
Exit
Screen 100 Solution: Step-1: Go to SE11 Database Table: ZMM_DEMO Create Short Description: Truck Entry Table Delivery Class: A Table View Maintenance: Table View Maintained with Restrictions Fields Field key Data Element MANDT _/ MANDT DCNO _/ ZDCNO DCDATE _/ ZDC_DATE TNO ZTNO BRGEW BRGEW TWT TWT Rohini kumar
SAP-ABAP
NTGEW EBELN LIFNR
181
NTGEW EBELN LIFNR
Currency Quantity Fields Field Reference Table Reference Field BRGEW EKPO MEINS TWT EKPO MEINS NTGEW EKPO MEINS
Technical Settings Data Class: APPL1 Size Category: 0 Save Back (F3) Activate Table Yes
Step-2: Go to SE80 Function Group: ZTCGR Enter Yes Short Text: Function Group for Truck Details Enter Local Object Under ZTCGR you will find INCLUDES, Expand it You will find 2 INCLUDES Double click on an include with TOP as suffix Select Display/Change option TABLES: ZMM_DEMO, LFA1. CONTROLS: vcontrol TYPE TABLEVIEW USING SCREEN ‘100’. DATA: n TYPE I. wa_demo TYPE zmm_demo. it_demo TYPE TABLE OF zmm_demo.
Activate Back (F3) Right click on ZTCGR function group Create
Rohini kumar
SAP-ABAP
Screen You will find a pop-up Program: SAPLZTCGR Screen Number: 100 Enter Short Description: Screen 100 Layout F6 Table Name: LFA1 Enter Select Lifnr Enter Place the field on top of the screen Place a Box on the screen Double click on box frame Text: Truck Entry Close Place Table Control (last from 4th option) on the box Double click on Table Control At bottom under Separators check Vertical & check Horizontal Close F6 Table Name: ZMM_DEMO Select all fields except MANDT Enter Place the fields on table control Place 5 push buttons under table control Provide Text & FCT code as per requirement Flow Logic
Step-3: Place cursor under PROCESS AFTER INPUT. MODULE USER_DML. LOOP AT it_demo. FIELD: zmm_demo-dcno, zmm_demo-dcdate, zmm_demo-tno, zmm_demo-brgew, zmm_demo-twt zmm_demo-ntgew zmm_demo-ebeln, Rohini kumar
182
SAP-ABAP
zmm_demo-lifnr. ENDLOOP. Place cursor under PROCESS BEFORE OUTPUT. LOOP AT it_demo INTO wa_demo WITH CONTROL vcontrol. MODULE STATUS_100. ENDLOOP.
Double click on USER_DML Yes Enter Enter Yes
Place cursor between MODULE………..ENDMODULE of USER_DML CASE SY-UCOMM. WHEN ‘INSERT’. MODIFY zmm_demo FROM zmm_demo. IF SY-SUBRC EQ 0. MESSAGE ‘Record Inserted’ TYPE ‘S’. ENDIF. WHEN ‘UPDATE’. UPDATE zmm_demo SET brgew = zmm_demo-brgew twt = zmm_demo-twt ntgew = zmm_demo-ntgew WHERE dcno = zmm_demo-dcno. IF SY-SUBRC EQ 0. MESSAGE ‘Record Updated’ TYPE ‘S’. ENDIF. WHEN ‘ENTER’. zmm_demo-ntgew = zmm_demo-brgew - zmm_demo-twt. ENDCASE. Activate Back (F3) Remove comment for MODULE USER_COMMAND_100. Double click on USER_COMMAND_100 Rohini kumar
183
SAP-ABAP
184
Yes Enter Enter Yes Place cursor between MODULE…………..ENDMODULE of USER_COMMAND_100
CASE SY-UCOMM. WHEN ‘DISPLAY’. SELECT * FROM zmm_demo INTO TABLE it_demo WHERE lifnr = lfa1-lifnr. WHEN ‘RESET’. REFRESH it_demo. WHEN ‘EXIT’. LEAVE TO SCREEN 0. ENDCASE. MODIFY it_demo FROM zmm_demo INDEX vcontrol-current_line. IF SY-SUBRC NE 0. APPEND zmm_demo TO it_demo. ENDIF. Activate Back (F3)
Remove comment for MODULE STATUS_100. Double click on STATUS_100 Yes Enter Enter Yes
MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE
wa_demo-dcno wa_demo-dcdate wa_demo-tno wa_demo-brgew wa_demo-twt wa_demo-ntgew wa_demo-ebeln wa_demo-lifnr
TO TO TO TO TO TO TO TO
zmm_demo-dcno. zmm_demo-dcdate. zmm_demo-tno. zmm_demo-brgew. zmm_demo-twt. zmm_demo-ntgew. zmm_demo-ebeln. zmm_demo-lifnr.
DESCRIBE TABLE it_demo LINES n. Rohini kumar
SAP-ABAP
185
vcontrol-lines = n. //---it activates vertical scroll bar Back (F3) Activate screen
Right click on ZTCGR function group Activate Enter Right click on ZTCGR Create Transaction Transaction Code: ZTRUCK Short Text: Truck Entry ***Program: SAPLTCGR ***Screen Number: 100 Save
Run T code (ZTRUCK) 29-09-2014 Ques-1: Suppose in table control when I entered few records then I selected ‘Enter’ option, I found that the records are completely vanished from table control. Why it happens & What logic you will write to avoid problem? Ans: When you select ‘Enter’ control will moves from screen to program In program there is no logic provided for storing the table control data in internal table So nothing is transferred back to table control screen So it looks like empty Logic: MODIFY it_demo FROM zmm_demo INDEX vcontrol-current_line. IF SY-SUBRC NE 0. APPEND zmm_demo TO it_demo. ENDIF. Ques-2: In table control how you can perform auto calculations whenever ‘Enter’ key selected? Ans: Remove comment for SET PF_STATUS. Under MODULE STATUS_100 ‘xxxxxxxxx’. Remove ‘xxxxxxxxxx’ provide ’BACK’. Yes Yes Rohini kumar
SAP-ABAP
Short Text: BACK Enter Expand function keys option _/ ENTER Activate You will find a pop-up, Enter Function Text: Enter Enter Back (F3) Activate program
Rohini kumar
186
SAP-ABAP
187
Tab Strip Control: Syntax: CONTROLS TYPE TABSTRIP. Object: Former Loan Application Cooperative Bank -------- Main Screen 100 Farmer Loan Payment
- Tab Strip
Sub Screen Area
Sub Screen 110 FNAME FCOUNTRY
ZFARMER TABLE Account fname fcountry Fcity Postal Tel address number code
FCITY POSTAL CODE TEL ADDRESS
SAVE
Rohini kumar
Automatically account number should be generated by system i.e. 90000001
SAP-ABAP
188
Sub Screen 120 A/C NUMBER
ZLOAN Table A/C FNAME LOAN APPROVE NUMBER AMOUNT
FNAME LOAN AMOUNT APPROVE
A/C Number field is mandatory FName field is in display mode When you enter A/CNumber & then press Enter, FName will display automatically
SAVE
Sub Screen 130 A/C NUMBER
ZPAYMENT Table A/C FNAME LOAN LOAN INTEREST DUE NUMBER AMOUNT PAID
FNAME LOAN AMOUNT LOAN PAID INTEREST DUE
CALC
Rohini kumar
MAIL
A/C Number field is mandatory FName, Loan Amount & Interest fields are in display mode When you enter Loan Paid & press Calc button Interest will generated automatically
SAP-ABAP
189
30-09-2014 Solution: Step-1: Function Group Creation Go to SE80 Function Group: ZFARMGR Enter Yes Short Text: Function Group for Farmer Loan Enter Package: ZABAP Enter Create Request Number Short Description: MM:ABAP/ Farmer Loan (30.09.2014) Enter Enter Step-2: Providing Variables & Tables Expand Includes Double click on Top Include Display / Change TABLES: ZFARMER, ZLOAN, ZPAYMENT. CONTROLS STRIP TYPE TABSTRIP. DATA: x TYPE SY-DYNNR VALUE ‘110’. DATA: days TYPE I, approve TYPE C. * for mails DATA: t_doc TYPE SODOCCHGI1, t_receive TYPE SOMLRECI1 OCCURS 0 WITH HEADERLINE, t_text TYPE SOLISTI1 OCCURS 0 WITH HEADERLINE. DATA: v_interest(10) TYPE v_due(10) TYPE v_paid(10) TYPE text(100) TYPE Activate Back (F3) Rohini kumar
C, C, C, C.
SAP-ABAP
Step-3: Right click on ZFARMER Create Screen Screen Number: 100 Enter Short Description: Screen 100 Layout Place Text Field (starting from 2nd option) Double click on Text Field Text: Cooperative Bank Close Place Tab Strip Control on screen Double click on Tab Strip Control Name: STRIP Tab Title: 3 Close Place Sub Screen Area (last from 5th option) on tab strip control Double click on Sub Screen Area Name: SUB Close Double click on Tab1 Text: Farmer FCT Code: TAB1 Close Double click on Tab2 Text: Loan FCT Code: TAB2 ***Ref Field: SUB Close Double click on Tab3 Text: Payment FCT Code: TAB3 ***Ref Field: SUB Close Flow Logic Step-4: Remove comment for MODULE USER_COMMAND_100 Double click on USER_COMMAND_100 Yes Enter Rohini kumar
190
SAP-ABAP
Enter Yes Place cursor between MODULE…………….ENDMODULE of USER_COMMAND_100 CASE SY-UCOMM. WHEN ‘TAB1’. x = ‘110’. STRIP-ACTIVETAB = ‘TAB1’. WHEN ‘TAB2’. x = ‘120’. STRIP-ACTIVETAB = ‘TAB2’. WHEN ‘TAB3’. x = ‘130’. STRIP-ACTIVETAB = ‘TAB3’. ENDCASE. Activate Back (F3) Place cursor under USER_COMMAND_100 CALL SUBSCREEN SUB. Place cursor under PROCESS BEFORE OUTPUT CALL SUBSCREEN SUB INCLUDING ‘SAPLZFARMGR’ x. Activate Back (F3) Step-5: Right click on ZFARMGR Create Screen Screen Number: 110 Enter Short Description: Sub Screen 110 Screen Type: Sub Screen Layout Place a Box on top left corner of the screen Double click on frame of box Text: Farmer Details Close Rohini kumar
191
SAP-ABAP
F6 Table Name: ZFARMER Enter Except Mandt & Acno select all fields Enter Place the fields on the box Place a Push button on the box Double click on push button Text: Save FCT Code: SAVE Close Flow Logic Remove comment for MODULE USER_COMMAND_110 Double click on USER_COMMAND_110 Yes Enter Enter Yes Place cursor between MODULE……….ENDMODULE of USER_COMMAND_110
CASE SY-UCOMM. WHEN ‘SAVE’. SELECT SINGLE MAX( acno ) FROM ZFARMER INTO zfarmer-acno. IF zfarmer-acno EQ 0. zfarmer-acno = ‘9000000’. ELSE. zfarmer-acno = zfarmer-acno + 1. ENDIF. INSERT ZFARMER. IF SY-SUBRC EQ 0. MESSAGE S000(ZMESS_CLS) WITH zfarmer-acno. ENDIF. ENDCASE. 000
192
Double click on ZMESS_CLS Yes Short Text: Message Handling Messages tab Enter Enter Successfully generated a/c number & Save
Rohini kumar
SAP-ABAP
Back (F3) Activate Back (F3) Activate screen Back
Step-6: Right click on ZFARMGR Create Screen Screen Number: 120 Enter Short Description: Sub Screen 120 Screen Type: Sub Screen Layout Place a Box on top left corner of the screen Double click on frame of box Text: Farmer Loan Close F6 Table Name: ZLOAN Enter Select Acno, Fname, Lamount fields Enter Place fields on the box Place a check box (starting from 4th option) on the box Double click on check box Name: APPROVE Text: Approve Close Place a push button on the box Double click on push button Text: Save FCT Code: SAVE Close Double click on Fname I/O field *** at bottom select Program tab Input: Not Possible Close Flow Logic Place cursor under PROCESS AFTER INPUT Rohini kumar
193
SAP-ABAP
194
CHAIN. FIELD: zloan-acno MODULE CHECK ON INPUT, zloan-lamount. Remove comment for MODULE USER_COMMAND_120. ENDCHAIN.
Double click on CHECK Yes Enter Enter Yes
SELECT SINGLE acno FROM ZFARMER INTO zloan-acno WHERE acno = zloan-acno. IF SY-SUBRC NE 0. MESSAGE ‘Enter Valid Account Number’ TYPE ‘E’. ENDIF.
Activate Back Double click on USER_COMMAND_120. Yes Enter Enter Yes Place cursor between MODULE……..ENDMODULE of USER_COMMAND_120
SELECT SINGLE fname FROM ZFARMER INTO zloan-fname WHERE acno = zloan-acno. CASE SY-UCOMM. WHEN ‘SAVE’. zloan-ldate = SY-DATUM. zloan-approve = APPROVE. INSERT ZLOAN. IF SY-SUBRC EQ 0. MESSAGE ‘Record inserted’ TYPE ‘S’. ENDIF. ENDCASE. Activate Rohini kumar
SAP-ABAP
Back Activate screen Back Step-7: Right click on ZFARMGR Create Screen Screen Number: 130 Enter Short Description: Sub Screen 130 Screen Type: Sub Screen Layout Place a Box on top left corner Double click on frame of box Text: Payment Details F6 Table Name: ZPAYMENT Enter Except Mandt select all fields Enter Place fields on box Double click on Fname I/O field At bottom select Program tab Input: Not Possible Close Repeat the same procedure with Lamount, Iamount & Due amount *** double click on Loan Paid I/O field At bottom select Program tab Input: Required Place a push button on the box Text: Calc FCT Code: CALC Place another push button Text: Mail FCT Code: MAIL Flow Logic Place cursor under PROCESS AFTER INPUT CHAIN. FIELD: zpayment-acno MODULE CHECK1 ON INPUT, zpayment-lamount. Rohini kumar
195
SAP-ABAP
196
Remove comment for MODULE USER_COMMAND_130 ENDCHAIN.
Double click on CHECK1 Yes Enter Enter Yes Place cursor between MODULE…………ENDMODULE of USER_COMMAND_130
SELECT SINGLE acno FROM ZLOAN INTO zpayment-acno WHERE acno = zpayment-acno. IF SY-SUBRC NE 0. MESSAGE ‘Enter valid a/c number’ TYPE ‘E’. ENDIF.
Activate Back Double click on USER_COMMAND_130 Yes Enter Enter Yes Place cursor between MODULE………..ENDMODULE of USER_COMMAND_130
SELECT SINGLE fname lamount ldate approve FROM ZLOAN INTO (zpaymentfname, zpayment-lamount, zloan-ldate, zloan-approve) WHERE acno = zpayment-acno. CASE SY-UCOMM. WHEN ‘CALC’. IF zloan-approve EQ ‘x’. CALL FUNCTION ‘HR_99S_INTERVAL_BETWEEN_DATES’. EXPORTING begda = zloan-ldate endda = sy-datum IMPORTING days = days zpayment-iamount = ( (zpayment-lamount * 1 * days) / (100 * 30) ). zpayment-due = (zpayment-lamount + zpayment-iamount) - zpayment-lpaid. UPDATE ZLOAN SET lamount = zpayment-due WHERE acno = zpayment-acno. INSERT ZPAYMENT. ENDIF. Rohini kumar
SAP-ABAP
ENDCASE. Activate Back Activate screen Step-8: Right click on ZFARMGR Create Transaction Transaction Code: YFARMER Enter Program: SAPLZFARMGR Screen Number: 100 Save Back Step-9: Right click on ZFARMGR Activate Run T code (YFARMER)
Rohini kumar
197
SAP-ABAP
01-10-2014 Mail Coding: * for mail address T_receiver_rec_type = ‘U’. T_receiver_receiver = ‘
[email protected]’. * fill subject T_doc_obj_name = ‘TEXT’. T_doc_obj_descr = ‘Payment Details’. T_doc_obj_langu = SY-LANGU. *fill contents V_paid = zpayment-lpaid. V_due = zpayment-due. V_interest = zpayment-iamount. CONCATENATE ‘Account Number:’ zpayment-acno INTO TEXT. APPEND TEXT TO T_TEXT. CONCATENATE ‘Loan Paid:’ l_paid INTO TEXT. APPEND TEXT TO T_TEXT. CONCATENATE ‘Loan Due:’ v_due INTO TEXT. APPEND TEXT TO T_TEXT. CONCATENATE ‘Interest Amount:’ v_interest INTO TEXT. APPEND TEXT TO T_TEXT. CALL FUNCTION ‘SO_NEW_DOCUMENT_SEND_API1’. EXPORTING Document_data = t_doc. Commit_work = ‘x’. TABLES Object-content = t_text. Receivers = t_receiver. IF SY-SUBRC EQ 0. COMMIT WORK. * push mails to SAP inbox SUBMIT RSLONN01 WITH MODE = ‘INT’ AND RETURN. ENDIF. Activate Rohini kumar
198
SAP-ABAP
Applications: Application is a collection of screens Screen is a collection of fields Applications are created by Technical Consultant Customization of data in application is done by Functional Consultant Applications are used by End Users Example: Go to XK01 Vendor: 9872 Company Code: 1000 Purchase Organization: 1000 Account Group: 0001 Enter Title: MR Name: Ashok Search Tem: Broacomm Street: Ameerpet Postal Code: 500074 City: Hyderabad Country: IN Enter No data in this screen Enter Country: IN Bank Key: F000158 A/C Number: 9000006 Enter Enter Recon Account: 31000 Cash Management Group: A1 Enter No data in this screen Enter No data in this screen Enter Order Currency: INR Enter Save
Rohini kumar
199
SAP-ABAP
Go to SE11 Database Table: LFA1 Display Contents Lifnr: 9872 F8
Rohini kumar
200
SAP-ABAP
201
LUW Functionality: Logical Unit of Work By default all SAP applications follows LUW functionality Database Server Buffer
LFA1
LFAK
VENDOR: 9872
NAME
RECON
C CODE: 1000
CITY
P ORG: 1000
COUNTRY
CASH MANAGEMENT GROUP
A/C NUMBER: 0001 SAVE
Screen level validation Screen level validation Screen level validation Implicit commit Implicit commit Implicit commit
Explicit commit
06-10-2014 By default all SAP applications follows LUW functionality In between the Screens implicit commit will take place where implicit commit data from Screen is transferred to Database Buffer Whenever user applies Save option explicit commit will take place where explicit commit data from Database Buffer is transferred to respective Database Table
Rohini kumar
SAP-ABAP
202
CHAIN Keyword: By default standard application allows screen level validations If you want to perform field level validations you should write logic explicitly using CHAIN……..ENDCHAIN All implicit commit as DB LUW Commit & all explicit commit as SAP LUW Commit Advantages & Disadvantages of LUW: Disadvantage of LUW: If number of screens increases in an application, interaction between Presentation Server & Database Server also increases there by reducing the performance of system Advantage of LUW: With LUW the data is concisely transferred to Database
Rohini kumar
SAP-ABAP
203
Table Control Wizard: It is advance to Table Control In Table Control Wizard most of the logic is already provided by system Requirement: Equipment details based on Plant Input: Add New
Update
Equipment Number:
To
Equipment Date:
To
Plant
To
Material Code
To
Delete
Display
Save
Equi no
Equi date
Plant
5001
1.2.2014
1001
Sall
Material code F001
Quantity 2
dsall delete
Solution: Step-1: Go to SE11 Database Table: ZPP_EQUIPMENT Create Short Description: Equipment Details Delivery Class: A Table View Maint: Display / Maint Allowed with Restrictions Rohini kumar
Production order 3006001
Dept M & pp
SAP-ABAP
Field tab Field key Mandt _/ Sel _/ Equnr _/ Edate _/ Werks Matnr Menge Aufnr Dept
204
Data Element MANDT CHAR1 EQUNR ZEDATE WERKS_D MATNR MENGE_D AUFNR ZDEPT_DAT
Double click on ZDEPT_DAT Yes Enter Yes Short Description: Department Domain: ZDEPT_DEM Double click on ZDEPT_DEM Yes Short Description: Domain for Department Field Data type: CHAR 10 Value Range tab Fix val short description P & Engg Plant & Engg Mech Mechanical Prod Production’ Mstores Mould Stroes Activate domain Field Label Medium 20 Department Activate Back Field key Data Element Erdat ERDAT Ernam ERNAM
Technical Settings Data Class: APPL1 Size Category: 0 Currency Quantity Fields tab
Rohini kumar
SAP-ABAP
Menge EKPO Activate
205
meins
Step-2: Go to SE38 Program: ZPP_EQUIPMENT_DETAILS Create Title: Equipment Details Type: Executable Program Save TABLES: ZPP_EQUIPMENT, SSCRFIELDS. SELECTION-SCREEN: BEGIN OF PUSHBUTTON 10(10) BUTTON1 PUSHBUTTON 30(10) BUTTON2 PUSHBUTTON 50(10) BUTTON3 PUSHBUTTON 70(10) BUTTON4 SELECTION-SCREEN: END OF
LINE. USER-COMMAND USER-COMMAND USER-COMMAND USER-COMMAND LINE.
BUT1, BUT2, BUT3, BUT4.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE screen-000. SELECT-OPTION: s_equnr FOR zpp_equipment-equnr, S_edate FOR zpp_equipment-edate, S_werks FOR zpp_equipment-werks, S_matnr FOR zpp_equipment-matnr. SELECTION-SCREEN: END OF BLOCK b1. INITIALIZATION. BUTTON1 = ‘Add New’. BUTTON2 = ‘Update’. BUTTON3 = ‘Delete’. BUTTON4 = ‘Display’. DATA: wa TYPE ZPP_EQUIPMENT, It TYPE TABLE OF ZPP_EQUIPMENT. * validate the buttons AT SELECTION-SCREEN. IF SSCRFIELDS-UCOMM EQ ‘BUT1’. CALL SCREEN 100. Rohini kumar
SAP-ABAP
ELSEIF SELECT WHERE AND AND AND
206
SSCRFIELDS-UCOMM EQ ‘BUT2’. * FROM ZPP_EQUIPMENT INTO TABLE it equnr IN s_equnr matnr IN s_matnr werks IN s_werks edate IN s_edate.
LOOP AT it INTO wa. ENDLOOP. CALL SCREEN 100. ELSEIF SELECT WHERE AND AND AND
SSCRFIELDS-UCOMM EQ ‘BUT3’. * FROM ZPP_EQUIPMENT INTO TABLE equnr IN s_equnr matnr IN s_matnr werks IN s_werks edate IN s_edate.
it
LOOP AT it INTO wa. ENDLOOP. CALL SCREEN 200. ELSEIF SELECT WHERE AND AND AND
SSCRFIELDS-UCOMM EQ ‘BUT4’. * FROM ZPP_EQUIPMENT INTO TABLE it equnr IN s_equnr matnr IN s_matnr werks IN s_werks edate IN s_edate.
LOOP AT it INTO wa. ENDLOOP. CALL SCREEN 100. ENDIF. Step-3: Double click on 100 Yes Yes Rohini kumar
SAP-ABAP
Short Description: Screen 100 Main Screen Layout Place Table Control Wizard (last from 3rd option) on the screen Continue Name of Table Control: vcontrol (any name) Continue Internal Table: it Table Work Area: wa Continue Select Equnr, Edate, Werks, Matnr, Menge, Aufnr, Dept fields Continue Input Control Continue Scroll Continue Continue Complete
Step-4: Double click on equnr = equipment number Double click on edate = eq date Similarly maintain labels of all the fields Double click under Department field Provide drop down list box Place a push button on top of table control Double click on push button Text: Save FCT Code: SAVE Flow Logic Search for MODULE VCONTROL_MODIFY Double click on VCONTROL_MODIFY Yes Place cursor after MODULE VCONTROL MODIFY INPUT Enter CASE SY-UCOMM. WHEN ‘SAVE’. MODIFY ZPP_EQUIPMENT FROM wa. IF SY-SUBRC EQ 0. MESSAGE ‘Record saved’ TYPE ‘S’. ENDIF. Rohini kumar
207
SAP-ABAP
208
UPDATE ZPP_EQUIPMENT SET erdat = sy-datum ernam = sy-uname WHERE equnr = wa-equnr. Place cursor after MODIFY it FROM wa INDEX VCONTROL-CURRENT_LINE Enter IF SY-SUBRC NE 0. APPEND wa TO it. ENDIF. Activate During activation you will find an error---controls can only be defined globally Double click on Error Copy the lines CONTROLS: VCONTROL TYPE TABLE VIEW……………….. DATA: G_VCONTROL_LINES LIKE SY-LOOPC DATA: OK_CODE LIKE SY-UCOMM.
And remove the 3 lines Paste the 3 lines under Declaration Activate Back
Step-5: Remove comment for MODULE STATUS_100 Double click on STATUS_100 Yes Main Program Yes Place cursor between MODULE……..ENDMODULE of STATUS_100 CASE SY-UCOMM. WHEN ‘BUT2’. LOOP AT SCREEN. IF SCREEN-NAME EQ OR SCREEN-NAME EQ OR SCREEN-NAME EQ OR SCREEN-NAME EQ SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. Rohini kumar
‘wa-equnr’ ‘wa-edate’ ‘wa-werks’ ‘wa-dept’.
SAP-ABAP
WHEN ‘BUT4’. LOOP AT SCREEN. IF SCREEN-NAME EQ OR SCREEN-NAME EQ OR SCREEN-NAME EQ OR SCREEN-NAME EQ OR SCREEN-NAME EQ OR SCREEN-NAME EQ OR SCREEN-NAME EQ SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. ENDCASE.
209
‘wa-equnr’ ‘wa-edate’ ‘wa-werks’ ‘wa-dept’ ‘wa-matnr’ ‘wa-menge’ ‘wa-aufnr’.
Step-6: Remove comment for SET PF-STATUS ‘BACK’. Double click on BACK Yes Yes Short Text: Back Enter Expand Function Keys Provide BACK Activate Back Activate program Back Step-7: Remove comment for MODULE USER_COMMAND_100 Double click on USER_COMMAND_100 Yes Main Program Enter Place cursor between MODULE……….ENDMODULE of USER_COMMAND_100 CASE SY-UCOMM. WHEN ‘BACK’. LEAVE TO SCREEN 0. ENDCASE. Activate Rohini kumar
SAP-ABAP
Step-8: Double click on 200 Yes Short Description: Screen 200 Layout Place Table Control With Wizard (last from 3rd option) on the screen Continue Name of Table Control: VCONTROL1 Continue Internal Program Tabel: it Table Work Area: wa Continue Select all fields (SEL, EQUNR, ……………DEPT) Continue Input Control Scroll Continue Continue Complete Change the Labels of fields as per requirement *** select under SEL field & right click Convert Check Box Left Button Double click under DEPT field Drop Down List Box Close Place 3 push buttons above Table Control Provide Text & FCT codes as per requirement Flow Logic Step-9: Remove comment for MODULE STATUS_200 Double click on STATUS_200 Yes Main Program Enter Yes Place cursor between MODULE…………ENDMODULE of STATUS_200
Rohini kumar
210
SAP-ABAP
CASE SY-UCOMM. WHEN ‘BUT3’. LOOP AT SCREEN. IF SCREEN-NUMBER OR SCREEN-NUMBER OR SCREEN-NUMBER OR SCREEN-NUMBER OR SCREEN-NUMBER OR SCREEN-NUMBER OR SCREEN-NUMBER
211
EQ EQ EQ EQ EQ EQ EQ
‘wa-qunr’ ‘wa-edate’ ‘wa-matnr’ ‘wa-werks’ ‘wa-aufnr’ ‘wa-menge’ ‘wa-dept’.
SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. ENDCASE. Activate Back Step-10: Remove comment for MODULE USER_COMMAND_200 Double click on USER_COMMAND_200 Yes Main Program Enter Place cursor between MODULE………ENDMODULE of USER_COMMAND_200 DATA: v_ans type C. CASE SY-UCOMM. WHEN ‘DELETE’. CALL FUNCTION ‘POPUP_TO_CONFIRM’ EXPROTING TITLEBAR = ‘Deletion Conformation’ TEXT_QUESTION = ‘Do you want to delete’ TEXT_BUTTON_1 = ‘Yes’ TEXT_BUTTON_2 = ‘No’ IMPORTING Rohini kumar
SAP-ABAP
ANSWER = v_ans. IF v_ans EQ 1. LOOP AT it INTO wa. IF wa-sel EQ ‘X’ DELETE FROM ZPP_EQUIPMENT WHERE equnr = wa-equnr. IF SY-SUBRC EQ 0. MESSAGE ‘Record deleted’ TYPE ‘S’. ENDIF. ENDIF. ENDLOOP. ENDIF. WHEN ‘SALL’. LOOP AT it INTO wa. wa-sel = ‘X’. MODIFY it FROM wa TRANSPORTING sel ENDLOOP. WHEN ‘DSALL’. LOOP AT it INTO wa. wa-sel = ‘ ’. MODIFY it FROM wa TRANSPORTING sel ENDLOOP. WHEN ‘BACK’. LEAVE TO SCREEN 0. Activate Back Step-11: Double click on STATUS_200 Remove comment for SET PF_STATUS ‘BACK1’ Double click on BACK1 Yes Short Text: BACK Rohini kumar
212
SAP-ABAP
213
Enter Expand Function Keys option Type ENTER Activate Back Activate Back Activate
Ques: What is the difference between SSCRFIELDS-UCOMM & SY-UCOMM? Ans: SSCRFIELDS is a structure for maintaining text for the buttons in SELECTION-SCREEN SSCRFIELDS-UCOMM returns FCT code for buttons maintained in SELECTION-SCREEN SY-UCOMM returns FCT code for buttons maintained in SCREEN SY-UCOMM will works for both Screen & Selection-screen Syntax for creating Push buttons on selection screen: SELECTION-SCREEN PUSHBUTTON (size) USER-COMMAND . Example: SELECTION-SCREEN PUSHBUTTON 10(10) button1 USER-COMMAND BUT1. 08-10-2014 Note: SCREEN is a dynamic internal table. It is used for modifying screen. It is having following fields 1. Group1 2. Group2 3. Group3…………… 4. Input 5. Required 6. Invisible 7. Active
Rohini kumar
SAP-ABAP
214
Input / Output Field: Object: Screen Making Report Input: Add New
Display
------Selection-Screen P_Date
01.10.2014
When you press Add New the Date should transfer to Screen Screen 100 Screen Making Report
Save
Date
Clear
Machine
Back
Material Code
Red
Blue
Average
When you press Enter Total & Average display automatically ZPP_SCREEN Table: Date Machine Matnr Red Blue Green Total Rohini kumar
Green
Total
SAP-ABAP
215
Solution: TABLES: YMM_IOFIELDS, SSCRFIELDS SELECTION-SCREEN: BEGIN OF LINE. SELECTION-SCREEN: PUSHBUTTON 10(10) button1 USER-COMMAND BUT1, PUSHBUTTON 30(10) button2 USER-COMMAND BUT2. SELECTION-SCREEN: END OF LINE. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETERS p_date TYPE edate. SELECTION-SCREEN: END OF BLOCK b1. INITIALIZATION: button1 = ‘Add New’. button2 = ‘Dispay’. DATA: v1 TYPE I, v2 TYPE I, v3 TYPE I, redavg TYPE I, blueavg TYPE I, greenavg TYPE I. DATA: wa1 TYPE YMM_IOFIELDS, wa2 TYPE YMM_IOFIELDS, wa3 TYPE YMM_IOFIELDS, it TYPE TABLE OF YMM_IOFIELDS. AT SELECTION-SCREEN. IF SSCRFIELDS-UCOMM EQ ‘BUT1’. wa1-edate = p_date. wa2-edate = p_date. wa3-edate = p_date. CALL SCREEN 100. ELSEIF SSCRFIELDS EQ ‘BUT2’. SELECT * FROM YMM_IOFIELDS INTO TABLE it WHERE edate = p_date. READ TABLE it INTO wa1 INDEX 1. READ TABLE it INTO wa2 INDEX 2. Rohini kumar
SAP-ABAP
READ TABLE it INTO wa3 INDEX 3. ENDIF.
Double click on 100 Short Description: Screen 100 Layout Design screen as per requirement Flow Logic Remove comment for MODULE USER_COMMAND_100 Double click on USER_COMMAND_100 Yes Enter Enter Yes Place cursor between MODULE…………ENDMODULE
CASE SY-UCOMM. WHEN ‘SAVE’. MODIFY YMM_IOFIELDS FROM wa1. MODIFY YMM_IOFIELDS FROM wa2. MODIFY YMM_IOFIELDS FROM wa3. IF SY-SUBRC EQ 0. MESSAGE ‘Record saved’ TYPE ‘S’. ENDIF. WHEN ‘ENTER’. wa1-total = wa1-red + wa1-blue + wa1-green. wa2-total = wa2-red + wa2-blue + wa2-green. wa3-total = wa3-red + wa3-blue + wa3-green. IF wa1-red IS INITIAL. v1 = v1 + 1. ENDIF.
IF wa2-red IS INITIAL. v1 = v2 + 1. ENDIF. IF wa3-red IS INITIAL. v1 = v1 + 1. Rohini kumar
216
SAP-ABAP
ENDIF. IF wa1-blue IS INITIAL. v2 = v2 + 1. ENDIF.
IF wa2-blue IS INITIAL. v2 = v2 + 1. ENDIF. IF wa3-blue IS INITIAL. v2 = v2 + 1. ENDIF. IF wa1-green IS INITIAL. v3 = v3 + 1. ENDIF.
IF wa2-green IS INITIAL. v3 = v3 + 1. ENDIF. IF wa3-green IS INITIAL. v3 = v3 + 1. ENDIF. redgavg = ( wa1-red + wa2-red + wa3-red ) / v1. blueavg = ( wa1-blue + wa2-blue + wa3-blue ) / v2. greenavg = ( wa1-green + wa2-green + wa3-green ) / v3. WHEN ‘BACK’. LEAVE TO SCREEN 0. WHEN ‘CLEAR’. CLEAR: wa1, wa2, wa3, redavg, blueavg, greenavg. ENDCASE. Activate Back Remove comment for MODULE STATUS_100 Rohini kumar
217
SAP-ABAP
Double click on STATUS_100 Remove comment for SET PF-STATUS ‘ENTER’. Double click on ENTER Yes Short Text: Enter Enter Expand Function Keys Type ENTER Activate Back Activate Back Activate
Rohini kumar
218
SAP-ABAP
219
Assignments: 1. Log sheet Temperature Details Input: Add New
Display
------ Selection-Screen
Furnance Date
Screen 100 Log Sheet Temparature Details
Save
Clear
Furnance
Shift
Back
Date
Update
T1
T2
T3
T4
T5
T6
Average Booster Holder Temparature Details Furnance
Rohini kumar
Shift
Date
E1
E2
E3
E4
E5
E6
SAP-ABAP
ZLOGSHEET Table: Furnance Date Shift T1 T2 T3 T4 T5 T6 E1 E2 E3 E4 E5 E6 Solution:
Rohini kumar
220
SAP-ABAP
221
2. Cheques Date Entry Screen Input: Add New
Display
------ Selection-Screen
Cheque No Cheque Date
Chequs Date Entry Details
Cheque No
Cheq Date
Issue Date
Dep Date
Reliza Date
Cust No
Che Status
Cheq Amt
ZCHEQUE Table: Cheque Number Cheque Date Issue Date Deposit Date Realization Date Customer Number Cheque Status Cheque Amount Solution: TABLES: YMM_CHEQUE, SSCRFIELDS. SELECTION-SCREEN: BEGIN OF LINE. SELECTION-SCREEN: PUSHBUTTON 10(10) button1 USER-COMMAND BUT1, PUSHBUTTON 10(10) button2 USER-COMMAND BUT2. Rohini kumar
SAP-ABAP
222
SELECTION-SCREEN: END OF LINE. SELECTION-SCREEN: BEGIN OF SELECT-OPTIONS: s_cheqno FOR s_chdate FOR SELECTION-SCREEN: END OF
BLOCK b1 WITH FRAME TITLE TEXT-000. ymm_cheque-cheqno, ymm_cheque-cheqdate. BLOCK b1.
INITIALIZATION. button1 = ‘Add new’. button2 = ‘Update’. button3 = ‘Display’. DATA: wa TYPE YMM_CHEQUE, it TYPE TABLE OF YMM_CHEQUE. AT SELECTION-SCREEN. IF SSCRFIELDS-UCOMM EQ ‘BUT1’. CALL SCREEN 100. ELSEIF SSCRFIELDS-UCOMM EQ ‘BUT2’. SELECT * FROM YMM_CHEQUE INTO TABLE it WHERE cheqno IN s_cheqno AND cheqdate IN s_chdate. LOOP AT it INTO wa. ENDLOOP. CALL SCREEN 100. ELSEIF SSCRFIELDS-UCOMM EQ ‘BUT3’. SELECT * FROM YMM_CHEQUE INTO TABLE it WHERE cheqno IN s_cheqno AND cheqdate IN s_chdate. LOOP AT it INTO wa. ENDLOOP. Rohini kumar
SAP-ABAP
223
CALL SCREEN 100. ENDIF. Double click on 100 Yes Enter Enter Yes Design screen with table control with wizard as per requirement Flow Logic Place cursor between MODULE………..ENDMODULE of VCONTROL_MODIFY INPUT CASE SY-UCOMM. WHEN ‘SAVE’. MODIFY YMM_CHEQUE FROM wa. IF SY-SUBRC EQ 0. MESSAGE ‘Record saved’ TYPE ‘S’. ENDIF. ENDCASE. MODIFY it FROM wa INDEX VCONTROL-CURRENT_LINE. IF SY-SUBRC NE 0. APPEND wa TO it. ENDIF. Place cursor between MODULE……….ENDMODULE of STATUS_100 OUTPUT SET PF-STATUS ‘BACK’. CASE SY-UCOMM. WHEN ‘BUT2’. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘wa-cheqno’ OR SCREEN-NAME EQ ‘wa-cheqdate’ Rohini kumar
SAP-ABAP
OR OR OR OR OR
SCREEN-NAME SCREEN-NAME SCREEN-NAME SCREEN-NAME SCREEN-NAME
224
EQ EQ EQ EQ EQ
‘wa-idate’ ‘wa-ddate’ ‘wa-rdate’ ‘wa-custno’ ‘wa-cheqstatus’.
SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. WHEN ‘BUT3’. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘wa-cheqno’ OR SCREEN-NAME EQ ‘wa-cheqdate’ OR SCREEN-NAME EQ ‘wa-idate’ OR SCREEN-NAME EQ ‘wa-ddate’ OR SCREEN-NAME EQ ‘wa-rdate’ OR SCREEN-NAME EQ ‘wa-custno’ OR SCREEN-NAME EQ ‘wa-cheqamt’ OR SCREEN-NAME EQ ‘wa-cheqstatus’. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. ENDCASE. Place cursor between MODULE………..ENDMODULE of USER_COMMAND 100 CASE SY-UCOMM. WHEN ‘BACK’. LEAVE TO SCREEN 0. ENDCASE. Rohini kumar
SAP-ABAP
225
3. Simple calculator Simple Calculator
1
2
3
C
4
5
6
/
7
8
9
*
0
=
+
-
Solution:
Rohini kumar
SAP-ABAP
226
REPORTS ABAP Reports: In real time ABAP Reports are designed for analysis & based on the that analysis decision making will done In real time every report is designed based on certain format & every report have 3 parts 1. Input 2. Processing Logic 3. Output Selection-Screen
Processing Logic
Output
Databa se
The reports that will designed up to now are without a proper structured format Design the same reports in a proper structure format (with events) Types of Reports: 1. Classical Reports 2. Interactive Reports 3. ALV Reports (ABAP List Viewer) 4. LDB Reports (Logical Data Base) ------- for HR module only 5. SAP Query Reports
Rohini kumar
SAP-ABAP
227
Classical Reports: In classical reporting the entire output is maintained in a single list called Basic list Events in Classical Reporting: 1. INITIALIZATION 2. AT SELECTION-SCREEN 3. START-OF-SELECTION 4. END-OF-SELECTION 5. TOP-OF-PAGE 6. END-OF-PAGE 09-10-2014 INITIALIZATION: It triggers before selection-screen display Note: Use this event for initializing 1. Default values in selection-screen 2. Texts on push buttons in selection-screen 3. Texts for blocks, radio buttons, check boxes…………..etc AT SELECTION-SCREEN: It triggers once the control leaves from selection-screen & still selection-screen is in active mode i.e. It triggers at end of PAI when all the values are passed from selection-screen to program variables It is further divided into 5 types a) AT SELECTION-SCREEN b) AT SELECTION-SCREEN c) AT SELECTION-SCREEN d) AT SELECTION-SCREEN e) AT SELECTION-SCREEN
OUTPUT ON ON VALUE-REQUEST ON HELP-REQUEST ON
AT SELECTION-SCREEN OUTPUT: It triggers after initialization & before selection-screen display Use this event for modifying selection-screen AT SELECTION-SCREEN ON : It triggers once selection-screen is being processed & still the selection-screen is in active mode AT SELECTION-SCREEN ON VALUE-REQUEST: It triggers when you apply F4 function key on selection-screen fields Rohini kumar
SAP-ABAP
228
Use this event for Search Help AT SELECTION-SCREEN ON HELP-REQUEST: It triggers when you apply F1 function key on selection-screen fields Use this event for Help Documentation AT SELECTION-SCREEN ON : It triggers when validating radio buttons START-OF-SELECTION:
This event will triggers once your selection-screen is processed It triggers when you select F8 function key It triggers before reading data from database It triggers for all processing blocks in a program It is a default event triggered before extracting data from database
Note: In your program no need to provide this event But when you are writing INITIALIZATION (or) AT SELECTION-SCREEN it is mandatory to use START-OF-SELECTION END-OF-SELECTION: It triggers once all the data is read from logical database Note: Use this event in HR ABAP for displaying HR data You can use this event for writing one time logics (Display data…………..etc) TOP-OF-PAGE: It triggers before 1st record is output in Output List Note: Use this event for maintaining headers in ABAP reports END-OF-PAGE: It triggers after last record is output is Output List Note: Use this event for maintaining footers in ABAP reports Rohini kumar
SAP-ABAP
229
Ques-1: Suppose there are 20 pages in my report. How many times INITIALIZATION will triggers & TOP-OF-PAGE will triggers? Ans: INITIALIZATION will triggers only 1 time TOP-OF-PAGE will triggers 20 times Ques-2: What is LOAD-OF-PROGRAM event? Ans: This event will triggers before INITIALIZATION & once your program is loaded into memory Example: REPORT ZEVENTS NO STANDARD PAGE HEADING LINE-COUNT 20(4). TABLES: EKPO. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_matnr FOR ekpo-mantnr, s_werks FOR ekpo-werks. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_ekpo, Ebeln TYPE ebeln, Matnr TYPE matnr, Menge TYPE menge_D, Netpr TYPE netpr, END OF ty_ekpo. TYPES: BEGIN OF ty_t001w, Werks TYPE werks_D, END OF ty_t001w. TYPES: BEGIN OF ty_mara, Matnr TYPE ty_mara, END OF ty_mara. DATA: wa_ekpo TYPE ty_ekpo, Wa_mara TYPE ty_mara, It_mara TYPE TABLE OF ty_mara, It_ekpo TYPE TABLE OF ty_ekpo, It_t001w TYPE TABLE OF ty_t001w. INITIALIZATION. Rohini kumar
SAP-ABAP
230
S_werks-low = ‘1000’. S_werks-high = ‘1001’. S_werks-sign = ‘I’. S_werks-option = ‘BT’. APPEND s_werks. SELECT matnr FROM MARA INTO TABLE it_mara WHERE mtart IN (‘FERT’) LOOP AT it_mara INTO wa_mara. S_matnr-low = wa_mara. S_matnr-sign = ‘I’. S_matnr-option = ‘EQ’. APPEND s_matnr. ENDLOOP. T1 = ‘Selection’. AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘s_werks-low’ OR SCREEN-NAME EQ ‘s_werks-high’ OR SCREEN-NAME EQ ‘s_matnr-low’ OR SCREEN-NAME EQ ‘s_matnr-high’. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. AT SELECTION-SCREEN ON s_werks. SELECT werks FROM T001W INTO TABLE it_t001w WHERE werks IN s_werks. IF SY-SUBRC NE 0. MESSAGE ‘Enter valid plant’ TYPE ‘E’ DISPLAY LIKE ‘I’. LEAVE LIST-PROCESSING. ENDIF. START-OF-SELECTION. SELECT ebeln matnr menge netpr FROM EKPO INTO TABLE it_ekpo WHERE matnr IN s_matnr AND werks IN s_werks. Rohini kumar
SAP-ABAP
LOOP AT it_ekpo INTO wa_ekpo. WRITE:/10 wa_ekpo-ebeln, 30 wa_ekpo-matnr, 50 wa_ekpo-menge, 70 wa_ekpo-netpr, ENDLOOP. TOP-OF-PAGE. WRITE:/40 ‘PO Details Report’ COLOR 1. SKIP. ULINE. END-OF-PAGE. WRITE:/10 ‘page no’, SY-PAGNO. Ques: What is the flow of events? Ans: INITIALIZATION AT SELECTION-SCREEN OUTPUT START-OF-SELECTION
Rohini kumar
231
SAP-ABAP
232
Object: PO and Tax Details Report Input: S_lifnr (so) S_werks (so) S_mtart (so) S_burks (so) S_bedat (so) Output: Po number Po date Vendor name Vendor number Po quantity Unit price Total price Unit of measurement Material code Material description VAT CST Freight Processing Logic: 1. Get ebeln bedat matnr menge netpr meins netwr knumv ebelp lifnr from EKKO & EKPO using inner-joins based on input 2. Pass lifnr of EKKO to lfa1 and get name1 3. Pass matnr of EKPO to MAKT and get maktx 4. Get kumv kposn kschl kwert from KONV by passing knumv of EKKO and ebelp of EKKO Solution: REPORT ZMM_PO_TAX_DETAILS_REPORT NO STANDARD PAGE HEADING LINE-SIZE 400 LINE-COUNT 20(4). TABLES: EKPO, MAKT, KONV, LFA1, EKKO. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE t1. SELECT-OPTIONS: s_lifnr FOR ekko-lifnr, Rohini kumar
SAP-ABAP
s_werks FOR ekko-werks, s_mtart FOR ekko-mtart, s_bedat FOR ekko-bedat. PARAMETERS p_bukrs TYPE bukrs. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_ekko, ebeln TYPE ebeln, bedat TYPE bedat, knumv TYPE knumv, lifnr TYPE lifnr, ebelp TYPE ebelp, menge TYPE menge_D, netpr TYPE netpr, netwr TYPE netwr, meins TYPE meins, END OF ty_ekko. TYPES: BEGIN OF ty_makt, matnr TYPE matnr, maktx TYPE maktx, END OF ty_makt. TYPES: BEGIN OF ty_lfa1, lifnr TYPE lifnr, name1 TYPE name1, END OF ty_lfa1. TYPES: BEGIN OF ty_konv, knumv TYPE knumv, kposv TYPE ebelp, kschl TYPE kschl, kwert TYPE kwert, END OF ty_konv. TYPES: BEGIN OF ty_final, ebeln TYPE ebeln, bedat TYPE bedat, knumv TYPE knumv, lifnr TYPE lifnr, matnr TYPE matnr, ebelp TYPE kposn, menge TYPE menge_D, Rohini kumar
233
SAP-ABAP
234
netpr TYPE netpr, netwr TYPE netwr, meins TYPE meins, name1 TYPE name1, maktx TYPE maktx, vat TYPE kwert, cst TYPE kwert, frei TYPE kwert, END OF ty-final. DATA: wa_lfa1 TYPE ty_lfa1, wa_ekko TYPE ty_ekko, wa_makt TYPE ty_makt, wa_final TYPE ty_final, wa_konv TYPE ty_konv, it_ekko TYPE TABLE OF it_makt TYPE TABLE OF it_final TYPE TABLE OF it_konv TYPE TABLE OF
ty_ekko, ty_makt, ty_final, ty_konv.
INITIALIZATION. t1 = ‘Selection’. p_bukrs = ‘1000’. AT SELECTION-SCREEN. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘p_bukrs’. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. START-OF-SELECTION. PERFORM get_ekko. PERFORM get_lfa1. PERFORM get_makt. PERFORM get_konv. PERFORM combine_data. PERFORM display_data. FORM get_ekko. SELECT ekko~ebeln ekko~bedat ekko~knumv ekko~lifnr Rohini kumar
SAP-ABAP
235
ekpo~matnr ekpo~ebelp ekpo~menge ekpo~netpr ekpo~netwr ekpo~meins INTO TABLE it_ekko FROM EKKO INNER JOIN EKPO ON ekko~ebeln = ekpo~ebeln WHERE ekko~lifnr IN s_lifnr AND ekko~bukrs EQ p_bukrs AND ekpo~mtart IN s_mtart AND ekpo~bedat IN s_bedat. IF SY-BUBRC NE 0. MESSAGE ‘Enter valid input’ TYPE ‘E’ DISPLAY LIKE ‘I’. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. FORM get_lfa1. IF NOT it_ekko IS INITIAL. SELECT lifnr name1 FROM LFA1 INTO TABLE it_lfa1 WHERE lifnr = it_ekko-lifnr. ENDIF. ENDFORM. FORM get_makt. IF NOT it_ekko IS INITIAL. SELECT matnr maktx FROM MAKT INOT TABLE it_makt FOR ALL ENTRIES IN it_ekko WHERE matnr = it_ekko-matnr AND spras EQ ‘EN’. ENDIF. ENDFORM. FORM combine_data. LOOP AT it_ekko INTO wa_ekko. wa_final-ebeln = wa_ekko-ebeln. wa_final-bedat = wa_ekko-bedat. wa_final-matnr = wa_ekko-matnr. wa_final-menge = wa_ekko-menge. wa_final-meins = wa_ekko-meins. wa_final-netpr = wa_ekko-netpr. wa_final-netwr = wa_ekko-netwr. wa_final-knumv = wa_ekko-knumv. wa_final-ebelp = wa_ekko-ebelp. wa_final-lifnr = wa_ekko-lifnr. Rohini kumar
SAP-ABAP
236
READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_ekko-lifnr. wa_final-name1 = wa_lfa1-name1. READ TABLE it_makt INTO wa_makt WITH KEY matnr = wa_ekko-matnr. wa_final-maktx = wa_makt-maktx. APPEND wa_final TO it_final. ENDLOOP. ENDFORM. FORM get_konv. SORT it_final BY knumv ebelp. IF NOT it_final IS INITIAL. SELECT knumv kposn kschl kwert FROM KNOV INTO TABLE it_knov FOR ALL ENTRIES IN it_final WHERE knumv = it_final-knumv AND kposn = it_final-ebelp. ENDIF. LOOP AT it_final INTO wa_final. LOOP AT it_knov INTO wa_knov WHERE knumv = wa_final-knumv AND kposn = wa_final-ebelp. CASE wa_konv = kschl. WHEN ‘STKO’. wa_final-vat = wa_konv-kwert. WHEN ‘PBXX’. wa_final-cst = wa_konv-kwert. WHEN ‘PBOO’. wa_final-frei = wa_konv-kwert. ENDCASE. ENDLOOP. MODIFY it_final FROM wa_final TRANSPORTING vat cst frei. ENDLOOP. ENDFORM. FORM displaly_data. LOOP AT it_final INTO wa_final. WRITE:/10 wa_final-ebeln, 20 wa_final-bedat, 30 wa_final-lifnr, Rohini kumar
SAP-ABAP
237
40 wa_final-name1, 50 wa_final-menge, 60 wa_final-netpr, 70 wa_final-netwr, 80 wa_final-meins, 90 wa_final-matnr, 100 wa_final-maktx, 110 wa_final-vat, 120 wa_final-cst, 130 wa_final-frei. ENDLOOP. ENDFORM.
Rohini kumar
SAP-ABAP
10-10-2014 KONV Table: It is a conditions table for holding tax data. Fields: 1. KNUMV------ condition number 2. KPOSN ------- item number for condition 3. KSCHL ------- condition / tax type 4. KAWRT------ condition base value 5. KBETR ------ condition rate 6. KWERT ----- condition value
Rohini kumar
238
SAP-ABAP
Assignment: Po Delivery Status Report Input: S_Lifnr S_Bedat P_bukrs
Output: Po number Po date Vendor number Vendor name Po quantity Delivery quantity Open quantity Status Processing Logic: 1. Get ebeln, bedat, lifnr from EKKO based on input 2. Get lifnr, name1 from LFA1 by passing lifnr of EKKO 3. Get ebeln, menge, wemng from EKET by passing ebeln of EKKO Solution: Go to SE38 Program: YMM_PO_DELIVERY_STATUS Create Package: ZABAP Enter
Rohini kumar
239
SAP-ABAP
240
Interactive Reporting: In Classical Reporting the entire output is maintained in a single output list called Basic List. In Interactive Reporting you will find N number of output lists called Interactive Lists (or) Secondary Lists. In one interactive reporting you can maintain 20 secondary lists in sequence. AT LINE-SELECTION: It triggers whenever user interacts with a list HIDE Keyword: It holds the records selected by user in interactive reporting System Fields in Interactive Reporting: 1. SY-LSIND 2. SY-LISEL SY-LSIND: It returns current list index SY-LISEL: It returns list of contents selected by user from output list 11-10-2014 GET CURSOR keyword: If fetches the field name & value selected by user from output list Syntax: GET CURSOR FIELD VALUE .
Rohini kumar
SAP-ABAP
SAP Memory: Using SAP memory concept we can transfer the data from ABAP program to standard application SET PARAMETER keyword: Syntax: SET PARAMETER ID FIELD . Example: SET PARAMETER ID ‘mat’ FIELD f001. TOP-OF-PAGE DURING LINE-SELECTION event: Use this event for providing Headers in interactive reporting
Rohini kumar
241
SAP-ABAP
242
Object: Invoice Details based on Customers Input: S_kunrg (so) ------ customer number S_matnr (so) S_werks (so) S_ekdat (so) --------- bill date Output: Basic list screen 0 Customer Customer name city
Customer number C001
Customer street
Telephone number
C002 When you click on C001 then the control will goes to Interactive list 1 Interactive list 1 Bill number Bill date Material code Bill quantity Bill amount 400103
01.02.2014
100-101
150
120000
400104
10.10.2014
200-201
500
9500000
When you click on 400103 then the control will goes to Interactive list 2 When you click on 200-201 then the control will goes to T code VF03 Interactive list 2 Material code Material text Material type
VF03 Invoice number:
Rohini kumar
SAP-ABAP
243
Solution: Go to SE38 Program: ZSD_CUSTOMER_INVOICE_DETAILS Create Title: Customer Invoice Details Report Type: Executable Program Enter Packge: ZABAP Enter TABLES: VBRK, VBRP, ADRC, KNA1. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_kunrg FOR vbrk-kunrg, s_matnr FOR vbrk-matnr, s_werks FOR vbrk-werks, s_fkdat FOR vbrk-fkdat. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_vbrk, Vbenl TYPE vbeln_vf, fkdat TYPE fkdat, matnr TYPE matnr, netwr TYPE netwr, END OF ty_vbrk. TYPES: BEGIN OF ty_kna1, kunnr TYPE kunnr, name1 TYPE name1, city1 TYPE ort01, street TYPE stras, tel_number TYPE ad_tlnmbr, END OF ty_kna1. TYPES: BEGIN OF ty_mara, matnr TYPE matnr, maktx TYPE maktx, mtart TYPE mtart, END OF ty_mara. DATA: wa_mara TYPE ty_mara, wa_vbrk TYPE ty_vbrk, Rohini kumar
SAP-ABAP
wa_kna1 it_mara it_vbrk it_kna1
244
TYPE TYPE TYPE TYPE
DATA: v_kunnr v_matnr v_fnam(20) v_fval(20)
ty_kna1, TABLE OF ty_mara, TABLE OF ty_vbrk, TABLE OF ty_kna1.
TYPE TYPE TYPE TYPE
kunnr, matnr, C, C.
SELECT kna1~kunnr kna1~name1 adrc~city1 adrc~street adrc~tel_number INTO TABLE it_kna1 FROM KNA1 INNER JOIN ADRC ON kna1~adrnr = adrc~addrnumber WHEERE kna1~kunnr IN s_kunrg. LOOP AT it_kna1 INTO wa_kna1. WRITE:/10 wa_kna1-kunnr HOTSPOT, 20 wa_kna1-name1, 30 wa_kna1-city1, 40 wa_kna1-street, 50 wa_kna1-tel_number. ENDLOOP. AT LINE-SELECTION. CASE SY-LSIND. WHEN 1. GET CURSOR FIELD v_fnam VALUE v_kunnr. IF v_fnam EQ wa_kna1-kunnr. CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’ EXPORTING INPUT = v_kunnr IMPORTING OUTPUT = v_kunnr. SELECT vbrk~vbeln vbrk~ekdat vbrp~matnr vbrp~fkimg vbrp~netwr INTO TABLE it_vbrk FROM VBRK INNER JOIN VBRP ON vbrk~vbeln = vbrp~vbeln WHERE vbrk~kunrg EQ vbrp~v_kunnr AND vbrk~werks IN s_werks AND vbrk~fkdat IN s_fkdat Rohini kumar
SAP-ABAP
AND
245
vbrk~matnr IN s_matnr.
LOOP AT it_vbrk INTO wa_vbrk. WRITE:/10 wa_vbrk-vbeln HOTSPOT, 20 wa_vbrk-fkdat, 30 wa_vbrk-matnr HOTSPOT, 40 wa_vbrk-fkimg, 50 wa_vbrk-netwr. ENDLOOP. WHEN 2. GET CURSOR FIELD v_fnam VALUE v_matnr. IF v_fnam EQ wa_vbrk-matnr. SELECT mara~matnr makt~maktx mara~mtart INTO TABLE it_mara FROM MARA INNER JOIN MAKT ON mara~matnr = makt~matnr WHERE mara~matnr EQ v_matnr AND makt~spras EQ ‘EN’. LOOP AT it_mara INTO wa_mara. WRITE:/10 wa_mara-matnr, 20 wa_mara-maktx, 30 wa_mara-mtart. ENDLOOP. ELSEIF v_fnam EQ ‘wa_vbrk-vbeln’. GET CURSOR FIELD v_fnam VALUE v_fval. SET PARAMETER ID ‘VF’ FIELD v_fval. CALL TRANSACTION ‘VF03' AND SKIP FIRST SCREEN. ENDIF. ENDCASE. TOP-OF-PAGE. WRITE:/50 ‘Customer Details’ COLOR 1. SKIP. ULINE. Rohini kumar
SAP-ABAP
TOP-OF-PAGE DURING LINE-SELECTION. CASE SY-LSIND. WHEN 1. WRITE:/50 ‘Customer Invoice Details’ COLOR 1. SKIP. ULINE. WHEN 2. WRITE:/50 ‘Materials Details’ COLOR 3. SKIP. ULINE. ENDCASE.
Rohini kumar
246
SAP-ABAP
VBRK Table: This table holds billing document header data Fields: 1. VBELN ------- invoice number 2. FKDAT ------- billing type (domestic / export) 3. WAERK ------ document currency 4. VKOGR ------ sales organization 5. VTWEG ------ distribution channel 6. KALSM ------ pricing procedure 7. KNUMV ----- condition number Link: VBRK-KNUMV KONV-KNUMV 8. *** FKDAT -------- billing date 9. GJAHR -------- physical year 10.RFBSK -------- status of bill 11.KURRF ------- exchange rate 12.ZTERM ------- payment terms 13.BUKRS ------- company code 14. *** KUNRG ------- customer number 15.SPART ------ division 16.KDGRP ----- customer group 17. *** FKSTO ------- bill document cancelled VBRP Table: This table holds billing document item data Fields: 1. VBELN -------- invoice number Link: VBRK-VBELN VBRP-VBELN 2. 3. 4. 5. 6.
POSNR -------- item number *** FKImG -------- invoice quantity MEINS -------- unit of measurement NETWR ------ bill amount VGBEL ------ reference document number
Rohini kumar
247
SAP-ABAP
Note: VGBEL is nothing but delivery document number 7. AGBEL ---------- sales order number 8. MATNR --------- material code 9. ARKTX --------- item description 10.CHARG -------- batch number 11.MATKL -------- material group 12.SPART --------- division 13.WERKS ------- Plant 14.VKBUR ------- sales office ADRC Table: It holds business addresses Fields: 1. ADDRNUMBER ---------- address number Link: LFA1-ADRNR KNA1-ADRNR ADRC-ADDRNUMBER 2. NAME1 ------- name of customer / vendor 3. NAME_CO ------ C/O name 4. CITY1 -------- city 5. STREET ----- street 6. HOUSE_NUM1 ------ house number 7. STR_SUPPL1 -------- street 2 8. STR_SUPPL2 -------- street 3 9. STR_SUPPL3 -------- street 4 10.TEL_NUMBER ----- telephone number Navigation for identifying parameter ids: Go to VF01 Apply F1 on Billing Document You will find a pop-up, at bottom select Technical Information Note down parameter id: V1
Rohini kumar
248
SAP-ABAP
249
13-10-2014 ALV Reporting: ABAP List Viewer ALV is advanced reporting with additional features of reporting Types of ALVs: 1. Traditional ALV 2. ALV with OOP (Object Oriented Programming) Traditional ALV: These are classified into 3 categories 1. Simple ALV 2. Blocked ALV 3. Hierarchal Sequential ALV Advantages of ALV: 1. In traditional reporting you cannot maintain logos (pictures…………etc) With ALV reporting you can maintain logos using ALV Function Modules 2. With ALV reporting you can improve performance of programming by avoiding LOOP…..ENDLOOP 3. Using ALV reporting you can maintain Main Headings, Sub Headings……….etc 4. The main features of reporting are i) Exporting Data ii) Totals iii) Sub Totals iv) Filtering v) Column Alignment vi) Sorting ……………….etc The above features requires large amount of coding with traditional reporting Using ALV Function Modules you can minimize such coding 5. Layout Management With traditional reporting you cannot select output fields dynamically (no layout management) Suppose in a company there are 10 departments & each department users requires different fields from the same report Using layout management you can create & save his own layout 6. Using ALV reporting you can maintain data in Tabular format
Rohini kumar
SAP-ABAP
250
Simple ALV: These are classified into 2 categories 1. Classical ALV 2. Interactive ALV Classical ALV: Object: Open PO Details Report Solution: Go to SE38 Program: ZMM_PO_STATUS_DETAILS Create Title: PO Status Report Type: Executable Program Enter Package: ZABAP Enter TABLES: LFA1, EKKO, EKET. TYPE-POOLS SLIS. SELECTION-SCREEN: BEGIN OF SELECT-OPTIONS: S_lifnr FOR S_bukrs FOR S_bedat FOR SELECTION-SCREEN: END OF TYPES: BEGIN OF ty_final, Ebeln TYPE ebeln, bedat TYPE bedat, eindt TYPE eindt, lifnr TYPE lifnr, name1 TYPE name1, menge TYPE menge_D, wemng TYPE wemng, open TYPE menge_D, status TYPE maktx, END OF ty_final.
Rohini kumar
BLOCK b1 WITH FRAME TITLE TEXT-000. lfa1-lifnr, ekko-bukrs, ekko-bedat. BLOCK b1.
SAP-ABAP
251
TYPES: BEGIN OF ty_ekko, Ebeln TYPE ebeln, bedat TYPE bedat, lifnr TYPE lifnr, END OF ty_ekko. TYPES: BEGIN OF ty_lfa1, lifnr TYPE lifnr, name1 TYPE name1, END OF ty_lfa1. TYPES: BEGIN OF ty_eket, Ebeln TYPE ebeln, eindt TYPE eindt, menge TYPE menge_D, wemng TYPE wemng, END OF ty_eket. DATA: wa_ekko wa_lfa1 wa_eket wa_final it_ekko it_lfa1 it_eket it_final
TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE
ty_ekko, ty_lfa1, ty_eket, ty_final, TABLE TABLE TABLE TABLE
OF OF OF OF
ty_ekko, ty_lfa1, ty_eket, ty_final.
* provide ALV declaration DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV, WA_LAYOUT TYPE SLIS_LAYOUT_ALV, IT_FCAT TYPE SLIS_T_FIELDCAT_ALV. PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM
Rohini kumar
get_ekko. get_lfa1. get_eket. fill_cat. combine_data. layout. display_data.
SAP-ABAP
FORM get_ekko. SELECT ebeln bedat lifnr FROM EKKO INTO TABLE it_ekko WHERE lifnr IN s_lifnr AND bukrs IN s_bukrs AND bedat IN s_bedat. ENDFORM. FORM get_lfa1. IF it_ekko IS NOT INITIAL. SELECT lifnr name1 FROM LFA1 INTO TABLE it_lfa1 FOR ALL ENTRIES IN it_ekko WHERE lifnr = it_ekko-lifnr. ENDIF. ENDFORM. FORM get_eket. IF it_ekko IS NOT INITIAL. SELECT ebeln menge wemng FROM EKET INTO TABLE it_eket FOR ALL ENTRIES IN it_ekko WHERE ebeln = it_ekko-ebeln. ENDIF. ENDFORM. FORM combine_data. LOOP AT it_eket INTO wa_eket. wa_final-ebeln = wa_eket-ebeln. wa_final-eindt = wa_eket-eindt. wa_final-menge = wa_eket-menge. wa_final-wemng = wa_eket-wemng. wa_final-open = wa_eket-menge - wa_eket-wemng. IF wa_eket_menge GT wa_eket_wemng. wa_final-status = ‘Not delivered’. ELSE. wa_final-status = ‘delivered’. READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln = wa_eket-ebeln. wa_final-lifnr = wa_eket-lifnr. wa_final-bedat = wa_eket-bedat. READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_ekko-lifnr. wa_final-name1 = wa_eket-name1. Rohini kumar
252
SAP-ABAP
APPEND wa_final TO it_final. ENDLOOP. ENDFORM. FORM fill_cat. WA_FCAT-FIELDNAME = ‘ebeln’. WA_FCAT-SELTEXT_M = ‘PO Number’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘eindt’. WA_FCAT-SELTEXT_M = ‘Delivery date’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘lifnr’. WA_FCAT-SELTEXT_M = ‘Vendor Number’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘name1’. WA_FCAT-SELTEXT_M = ‘Vendor name. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘menge’. WA_FCAT-SELTEXT_M = ‘Quantity’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘wemng’. WA_FCAT-SELTEXT_M = ‘Delivery Quantity’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘open’. WA_FCAT-SELTEXT_M = ‘Open quantity’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘status’. WA_FCAT-SELTEXT_M = ‘Status’. APPEND WA_FCAT TO IT_FCAT. ENDFORM.
Rohini kumar
253
SAP-ABAP
FORM layout. WA_LAYOUT-ZEBRA = ‘X’. WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’. ENDFORM. FORM display. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-REPID ----- it returns current program name IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FCAT I_SAVE = ‘X’. TABLES. T_OUTTAB = it_final. ENDFORM.
Rohini kumar
254
SAP-ABAP
14-10-2014 Note-1: REUSE_ALV_GRID_DISPLAY It is for display the data in ALV grid The parameters are 1. Current program name It is important for activating layout management & for displaying logos & headings 2. Layout work area 3. Field catalog internal table 4. I_CALLBACK_USER_COMMAND It is for interactive purpose 5. I_STRUCTURE_NAME For providing structure 6. I_BACKGROUND_ID For maintaining background pictures 7. I_GRID_TITLE For maintaining title in ALV grid 8. IT_SORT For sorting data & for maintaining sub totals 9. I_SAVE For saving layouts 10.IT_EVENTS For events internal table 11.IS_PRINT For deactivating (or) activating the print mode for PDF formats…………etc 12.T_OUTTAB For output internal table Note-2: SLIS ------- is a Type Group Type Group: A type group is a group of similar structures & table types Rohini kumar
255
SAP-ABAP
256
It you want to use type group types in your program it is mandatory to declare respective type group with TYPE-POOLS keyword Note-3: SLIS_FIELDCAT_ALV is a standard SLIS structure with following fields 1. COL_POS ----------- column position 2. FIELDNAME ------ field name of output internal table 3. TABNAME --------- internal table name 4. CHECKBOX ------- with this option you can create check box for a specific field 5. JUST ----------------- it specifies left (or) right format for a specific field 6. NO_ZERO ---------- removes zeros from output list 7. EDIT_MASK ------- it hides the field data 8. NO_OUT ------------ removes a specific field catalog from output list 9. EMPHASIZE ------- it provides a specific default color for a field in ALV grid 10.OUTPUTLEN ------ specifies length (or) size for a catalog 11.SELTEXT_M ------ provides text for a particular field 12.FIX_COLOUMN 13.DECIMALS_OUT -- it round off a particular floating value by removing decimal values from it 14.EDIT ------------------- by default the field catalogs in a layout are in display mode. Using this option a field should be converted into change mode 15.HOTSPOT ------------ provides hand symbol 16.DO_SUM ----------- provides totals
Note-4: SLIS_LAYOUT_ALV is a standard SLIS structure for maintaining layout settings for ALV reporting It is having following fields 1. ZEBRA --------- alternate colors 2. COLWIDTH _OPTIMIZE ------- it will optimize the width of field catalog automatically based on domain length
Rohini kumar
SAP-ABAP
257
Object: Restricted & Unrestricted stock details report material wise & plant wise Input: S_matnr (so) S_werks (so) Output: Material code Material description Hyd uns Hyd res Pune uns Pune res Total uns Total res Total stock Tables: MARA MAKT MARD Ques-1: What do you mean by restricted & unrestricted stock? Ans: The stock which is produced by production department & it is in Quality check (or) it is in hold (or) stock returns is called restricted stock The stock which is ready for sale is called unrestricted stock *** Ques-2: This report is already provided by SAP (MMBE). Then why you created it? Ans: MMBE is providing materials details plant wise & storage location wise material by material My client gave a requirement for viewing all restricted & unrestricted stock at one time Solution: Go to SE38 Program: ZMM_STOCK_DETAILS_REPORT Create Package: ZABAP Enter Rohini kumar
SAP-ABAP
258
TABLES: MARA, MAKT, MARD. TYPE-POOLS SLIS. SELECTION-SCREEN: BEGIN OF SELECT-OPTIONS: s_matnr FOR S_werks FOR SELECTION-SCREEN: END OF
BLOCK b1 WITH FRAME TITLE TEXT-000. mara-matnr, mard-werks. BLOCK b1.
TYPES: BEGIN OF ty_mara, Matnr TYPE matnr, END OF ty_mara. TYPES: BEGIN Matnr maktx werks labst insme einme retme speme END
OF ty_mard, TYPE matnr, TYPE maktx, TYPE werks_D, TYPE labst, TYPE insme, TYPE einme, TYPE retme, TYPE speme, OF ty_mard.
TYPES: BEGIN Matnr maktx labst1 rest1 labst2 rest2 totuns totres total END
OF ty_final, TYPE matnr, TYPE maktx, TYPE labst, TYPE labst, TYPE labst, TYPE labst, TYPE labst, TYPE labst, TYPE labst, OF ty_final.
DATA: wa_mara TYPE ty_mara, Wa_mard TYPE ty_mard, Wa_mard1 TYPE ty_mard, Wa_final TYPE ty_final, It_mara TYPE TABLE OF ty_mara, It_mard TYPE TABLE OF ty_mard INITIAL SIZE 0, Rohini kumar
SAP-ABAP
259
It_mard1 TYPE TABLE OF ty_mard INITIAL It_final TYPE TABLE OF ty_fina1.
Rohini kumar
SIZE 0,
SAP-ABAP
MARD Table: It holds storage location data for materials Fields: 1. MATNR --------- material code 2. WERKS --------- plant 3. LGORT ---------- storage location 4. *** LABST ----- unrestricted stock 5. INSME ---------- stock in quality inspection 6. EINME ---------- total stock of all restricted stock 7. SPEME ---------- blocked stock 8. RETME --------- blocked stock returns Note: The above 4 fields combine to form restricted stock 9. LGPBE ---------- storage bin
Rohini kumar
260
SAP-ABAP
15-10-2014 SLIS_SORTINFO_ALV: It is a standard ALV structure for sorting output list It is having following fields 1. FIELDNAME -------------- field name for sorting 2. TABNAME ---------------- internal table name 3. UP --------------------------- ascending order 4. DOWN --------------------- descending order 5. SUBTOT ------------------ performs subtotals SLIS_LISTHEADER: It is a standard ALV structure for maintaining headings in output list It is having following fields 1. TYP -------------- type of heading (H, S, A) 2. KEY ------------- text for heading in 20 characters 3. INFO ------------ text for heading in 60 characters SLIS_ALV_EVENT: It is a standard ALV structure for maintaining events It is having following fields 1. NAME ----------- name of event 2. FORM ----------- subroutine name 16-10-2014 Navigation for Maintaining Logos: Go to Paint Design a picture Save it on desktop
Go to OAER Class Name: Pictures Class Type: OT Object Key: ABAP Execute At bottom expand Standard Document Types Double click on Screen Select your Logo Enter Enter
Rohini kumar
261
SAP-ABAP
Assignment-1: Monthly sales report based on customers Input: S_kunrg -------- customer code S_werks -------- plant S_fkart --------- bill type S_spart --------- division S_fkdat --------- bill date (01.04.2006 to 30.09.2006) S_bukrs -------- company code Output: Customer code (vbrk-kunrg) Customer name (kna1-name1) Apr 06 (vbrp-fkdat) May 06 (vbrp-fkdat) Jun 06 (vbrp-fkdat) July 06 (vbrp-fkdat) Aug 06 (vbrp-fkdat) Sep 06 (vbrp-fkdat) Oct 06 (vbrp-fkdat) Nov 06 (vbrp-fkdat) Dec 06 (vbrp-fkdat) Total Solution:
Rohini kumar
262
SAP-ABAP
Assignment-2: Sales analysis report Input: S_kunrg S_werks S_fkart S_bukrs S_fkdat S_spart Output: Customer name Today sales --------------- (15.10.2014) Yesterday sales ---------- (15.10.2013) Growth -------------------- ((Today sales – Yesterday sales) / Yesterday sales) * 100) Mtd sales ------------------ (01.10.2014 to 15.10.2014) Pmtd sales ---------------- (01.10.2013 to 15.10.2013) Growth -------------------- ((Mtd sales – Pmtd sales) / Pmtd sales) * 100) Ytd sales ------------------ (01.04.2014 to 15.10.2014) Pytd sales ----------------- (01.04.2013 to 15.10.2013) Growth -------------------- ((Ytd sales – Pytd sales) / Pytd sales) * 100) Solution:
Rohini kumar
263
SAP-ABAP
Interactive ALV: Syntax: FORM USING TYPE SY-UCOMM TYPE SLIS_SELFIELD. ------------------------ENDFORM. Requirement: Customer master details Input: S_kunnr Customer (button) Address (button) Output-1: Customer number Customer name Customer group Customer group description Region Region description Division Division description Output-2: Customer code Customer name Customer city Customer postal code Customer Street Customer telephone number Interactive Logic: If I double click on customer code switch to XD03 application Processing Logic-1: 1. Get kunnr name1 regio from kna1 table based on input 2. Get kunnr spart kdgrp from knvv table by passing kunnr of kna1 table 3. Get spart vtext from tspat table by passing spart of knvv table 4. Get kdgrp ktext from t151t table by passing kdgrp of knvv table Rohini kumar
264
SAP-ABAP
265
5. Get bland bezei from t005u table by passing region of kna1 table Processing Logic-2: 1. Provide inner join between kna1 table & adrc table (kunnr, name1, city1, post_code1, street, tel_number) Solution: TABLES: KNA1, ADRC. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_kunnr FOR kna1-kunnr. SELECTION-SCREEN: END OF BLOCK b1. SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-001. PARAMETERS: customer RADIOBUTTON GROUP rg1, address RADIOBUTTON GROUP rg1. SELECTION-SCREEN: END OF BLOCK b2. TYPE-POOLS SLIS. TYPES: BEGIN Kunnr Name1 Region END
OF ty_kna1, TYPE kunnr, TYPE name1, TYPE region, OF ty_kna1.
TYPES: BEGIN OF ty_knvv, Kunnr TYPE kunnr, spart TYPE spart, kdgrp TYPE kdgrp, END OF ty_knvv. TYPES: BEGIN OF ty_tspat, spart TYPE spart, vtext TYPE vtext, END OF ty_tspat. TYPES: BEGIN OF ty_t151t, kdgrp TYPE kdgrp, ktext TYPE ktext, END OF ty_t151t. Rohini kumar
SAP-ABAP
266
TYPES: BEGIN OF ty_t005u, bland TYPE regio, bezei TYPE bezei, END OF ty_t005u. TYPES: BEGIN OF ty_adrc, Kunnr TYPE kunnr, Name1 TYPE name1, City1 TYPE ort01, Post_code TYPE pstlz, Street TYPE stras, Tel_number TYPE ad_tlnmbr1, END OF ty_adrc. TYPES: BEGIN Kunnr Name1 Kdgrp Ktext Region Bezei Vtext END DATA: wa_kna1 wa_knvv wa_tspat wa_t151t wa_t005u wa_adrc wa_final it_kna1 it_knvv it_tspat it_t151t it_t005u it_adrc it_final
OF ty_final, TYPE kunnr, TYPE name1, TYPE kdgrp, TYPE ktext, TYPE regio, TYPE bezei, TYPE vtext, OF ty_final. TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE
ty_kna1, ty_knvv, ty_tspat, ty_t151t, ty_t005u, ty_adrc, ty_final, TABLE OF TABLE OF TABLE OF TABLE OF TABLE OF TABLE OF TABLE OF
ty_kna1, ty_knvv, ty_tspat, ty_t151t, ty_t005u, ty_adrc, ty_final.
DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV, IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, IT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV, Rohini kumar
SAP-ABAP
267
WA_EVENT TYPE SLIS_ALV_EVENT, WA_LAYOUT TYPE SLIS_LAYOUT_ALV, IT_EVENT TYPE SLIS_T_EVENT. PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM
get_kna1. get_knvv. get_tspat. get_t151t. get_t005u. get_adrc. combine_data. field_cat. layout. field_event. display_data.
FORM get_kna1. SELECT kunnr name1 regio FROM KNA1 INTO TABLE it_kna1 WHERE kunnr IN s_kunnr. IF SY-SUBRC NE 0. MESSAGE ‘Enter valid input’ TYPE ‘E’ DISPLAY LIKE ‘I’. LEAVE LIST-PROCESSING. ENDIF. ENDFORM. FORM get_knvv. IF NOT it_kna1 IS INITIAL. SELECT kunnr spart kdgrp FROM KNVV INTO TABLE it_knvv FOR ALL ENTRIES IN it_kna1 WHERE kunnr = it_kna1-kunnr. ENDIF. ENDFORM. FORM get_tspat. IF NOT it_knvv IS INITIAL. SELECT spart vtext FROM TSPAT INTO TABLE it_tspat Rohini kumar
SAP-ABAP
FOR ALL ENTRIES IN it_knvv WHERE spart = it_knvv-spart AND spras EQ ‘EN’. ENDIF. ENDFORM. FORM get_t151t. IF NOT it_knvv IS INITIAL. SELECT kdgrp ktext FROM T151T INTO TABLE it_t151t FOR ALL ENTRIES IN it_knvv WHERE kdgrp = it_knvv-kdgrp AND spras EQ ‘EN’. ENDIF. ENDFORM. FORM get_t005u. IF NOT it_kna1 IS INITIAL. SELECT bland bezei FROM T005U INTO TABLE it_t005u FOR ALL ENTRIES IN it_kna1 WHERE bland = it_kna1-regio AND spras EQ ‘EN’. ENDIF. ENDFORM. FORM get_adrc. SELECT kna1~kunnr kna1~name1 adrc~city1 adrc~post_code1 adrc~street adrc~tel_number INTO TABLE it_adrc FROM KNA1 INNER JOIN ADRC ON kna1~adrnr = adrc~addrnumber WHERE kna1~kunnr IN s_kunnr. ENDFORM. FORM combine_data. LOOP AT it_kna1 INTO wa_kna1. wa_final-kunnr = wa_kna1-kunnr. Rohini kumar
268
SAP-ABAP
wa_final-name1 = wa_kna1-name1. wa_final-regio = wa_kna1-regio. READ TABLE it_knvv INTO wa_knvv WITH KEY kunnr = wa_kna1-kunnr. wa_final-kdgrp = wa_knvv-kdgrp. wa_final-spart = wa_knvv-spart. READ TABLE it_tspat INTO wa_tsapt WITH KEY spart = wa_knvv-spart. wa_final-vtext = wa_tspat-vtext. READ TABLE it_t005u INTO wa_t005u WITH KEY bland = wa_kna1-regio. wa_final-bezei = wa_t005u-bezei. READ TABLE it_t151t INTO wa_t151t WITH KEY kdgrp = wa_knvv-kdgrp. wa_final-ktext = wa_t151t-ktext. APPEND wa_final TO it_final. ENDLOOP. ENDFORM. FORM FIELD_CAT. WA_FCAT-FIELDNAME = ‘KUNNR’. WA_FCAT-SELTEXT_M = ‘customer code’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘NAME1’. WA_FCAT-SELTEXT_M = ‘name’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘KDGRP’. WA_FCAT-SELTEXT_M = ‘customer group’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘KTEXT’. WA_FCAT-SELTEXT_M = ‘customer group description’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘REGIO’. WA_FCAT-SELTEXT_M = ‘region’. Rohini kumar
269
SAP-ABAP
APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘BEZEI’. WA_FCAT-SELTEXT_M = ‘region description’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘SPART’. WA_FCAT-SELTEXT_M = ‘division’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘VTEXT’. WA_FCAT-SELTEXT_M = ‘division description’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘KUNNR’. WA_FCAT-SELTEXT_M = ‘customer code’. WA_FCAT-TABNAME = ‘it_adrc’ APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘NAME1’. WA_FCAT-SELTEXT_M = ‘name’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘CITY1’. WA_FCAT-SELTEXT_M = ‘city’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘POST_CODE1’. WA_FCAT-SELTEXT_M = ‘postal code’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘STREET’. WA_FCAT-SELTEXT_M = ‘street’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘TEL_NUMBER’. WA_FCAT-SELTEXT_M = ‘tel_number’. APPEND WA_FCAT TO IT_FCAT1. ENDFORM.
Rohini kumar
270
SAP-ABAP
FORM field_event. WA_EVENT-NAME = ‘USER_COMMAND’. WA_EVENT-FORM = ‘INTERACTIVE’. APPEND wa_event TO it_event. ENDFORM. FORM layout. WA_LAYOUT-ZEBRA = ‘X’. WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’. ENDFORM. FORM display. IF customer EQ ‘X’. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-CPROG IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FCAT IT_EVENTS = IT_EVENT I_SAVE = ‘X’ TABLES T_OUTTAB = it_final. ELSE. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-CPROG IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FCAT1 IT_EVENTS = IT_EVENT I_SAVE = ‘X’ TABLES T_OUTTAB = it_adrc. ENDIF. ENDFORM.
Rohini kumar
271
SAP-ABAP
FORM INTERACTIVE USING UCOMM TYPE SY-UCOMM sel TYPE SLIS_SELFIELD. IF SEL-SEL_TAB_FIELD = ‘it_final-kunnr’ OR SEL-SET_TAB_FIELD = ‘it_adrc-kunnr’. SET PARAMETER ID ‘KUN’ FIELD SEL-VALUE. CALL TRANSACTION ‘XD03’. ENDIF. ENDFORM.
Rohini kumar
272
SAP-ABAP
17-10-2014 Object: Movement typewise sale production consumption details for materials Input: S_matnr ------------ material code S_werks ------------ plant S_bwart ------------ movement type S_budat ------------ posting date Input: Material code Material description Plant Production quantity Sale quantity Consumption quantity Return quantity Plant wise (button) Segment wise (button) All (button) Plant wise Output: Material code Plant Production Sale Consumption Return quantity Segment wise Output: Division Division description Production Sale Consumption Return quantity All Output: Material code Material description Division Rohini kumar
273
SAP-ABAP
274
Division description Plant Production (101, 102 movement types) Sale (601, 602 movement types) Consumption (261, 262 movement types) Return quantity (651, 652 movement types) Tables: MAKT MKPF MSEG Solution: ZNP_STOCK_MOVEMENT_DETAILS TABLES: MARA, MKPF, MSEG. TYPE-POOLS SLIS. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITEL TEXT-000. SELECT-OPTIONS: s_matnr FOR mara-matnr, s_werks FOR mseg-werks, s_budat FOR mkpf-budat, s_bwart FOR mseg-bwart. SELECTION-SCREEN: END OF BLOCK b1. SELECTION-SCREEN: BEGIN OF LINE. PARAMETERS: p_rb1 RADIOBUTTON GROUP rg1. SELECTION-SCREEN COMMIT 10(20) TEXT-001. PARAMETERS: p_rb2 RADIOBUTTON GROUP rg1. SELECTION-SCREEN COMMIT 40(20) TEXT-002. PARAMETERS: p_rb3 RADIOBUTTON GROUP rg1. SELECTION-SCREEN COMMIT 70(20) TEXT-003. SELECTION-SCREEN: END OF LINE. TYPES: BEGIN OF ty_mara, matnr TYPE matnr, spart TYPE spart, maktx TYPE maktx, Rohini kumar
SAP-ABAP
END
275
OF ty_mara.
TYPES: BEGIN OF ty_mseg, mblnr TYPE mblnr, budat TYPE budat, matnr TYPE matnr, werks TYPE werks_D, shkzg TYPE shkzg, bwart TYPE bwart, menge TYPE menge_D, END OF ty_mseg. TYPES: BEGIN OF ty_mseg, mblnr TYPE mblnr, budat TYPE budat, matnr TYPE matnr, werks TYPE werks_D, shkzg TYPE shkzg, bwart TYPE bwart, menge TYPE menge_D, END OF ty_mseg. TYPES: BEGIN OF ty_final, matnr TYPE matnr, maktx TYPE maktx, werks TYPE werks_D, spart TYPE spart, vtext TYPE vtext, prod TYPE menge_D, sale TYPE menge_D, cons TYPE menge_D, return TYPE menge_D, END OF ty_mseg. TYPES: BEGIN OF ty_tspat, spart TYPE spart, vtext TYPE vtext, END OF ty_tspat. DATA: wa_mara TYPE ty_mara, wa_mseg TYPE ty_mseg, wa_mseg1 TYPE ty_mseg, Rohini kumar
SAP-ABAP
276
wa_out TYPE ty_final, wa_tspat TYPE ty_tspat, wa_final TYPE ty_final, wa_final1 TYPE ty_final, wa_final2 TYPE ty_final, it_mara TYPE TABLE OF ty_mara, it_mseg TYPE TABLE OF ty_mseg INITIAL SIZE 0, it_mseg1 TYPE TABLE OF ty_mseg INITIAL SIZE 0, it_final TYPE TABLE OF ty_final INITIAL SIZE 0, it_final1 TYPE TABLE OF ty_final INITIAL SIZE 0, it_final2 TYPE TABLE OF ty_final INITIAL SIZE 0, it_out TYPE TABLE OF ty_final INITIAL SIZE 0, it_tspat TYPE TABLE OF ty_tspat. DATA: WA_FCAT IT_FCAT IT_FCAT1 IT_FCAT2 WA_LAYOUT WA_EVENT IT_EVENT
TYPE TYPE TYPE TYPE TYPE TYPE TYPE
SLIS_FIELDCAT_ALV, SLIS_T_FIELDCAT_ALV, SLIS_T_FIELDCAT_ALV, SLIS_T_FIELDCAT_ALV, SLIS_LAYOUT_ALV, SLIS_ALV_EVENT, SLIS_T_EVENT.
START-OF-SELECTION. PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM
get_mara. get_mseg. get_tspat. combine_data. combine_data1. fill_cat. layout. fill_event. display_data.
FORM get_mara. SELECT mara~matnr mara~spart makt~maktx INTO TABLE it_mara FROM MARA INNER JOIN MAKT ON mara~matnr = makt~matnr WHERE mara~matnr IN s_matnr AND spras EQ ‘EN’. Rohini kumar
SAP-ABAP
277
ENDFORM. FORM get_mseg. SELECT mkpf~mblnr mkpf~budat mseg~matnr mseg~werks mseg~shkzg mseg~bwart mseg~menge INTO TABLE it_mseg FROM MKPF INNER JOIN MSEG ON mkpf~mblnr = mseg~mblnr WHERE mkpf~budat IN s_budat AND mseg~werks IN s_werks AND mseg~matnr IN s_matnr AND mseg~bwart IN s_bwart. ENDFORM. FORM get_tspat. IF NOT it_mara IS INITIAL. SELECT spart vtext FROM TSPAT INTO TABLE it_tspat FOR ALL ENTRIES IN it_mara WHERE spart = it_mara-spart AND spras EQ ‘EN’. ENDIF. ENDFORM. FORM combine_data. LOOP AT it_mara INTO wa_mara. wa_final-matnr = wa_mara-matnr. wa_final-spart = wa_mara-spart. wa_final-maktx = wa_mara-maktx. READ TABLE it_tspat INTO WITH KEY spart = wa_mara-spart. wa_final-vtext = wa_tspat-vtext. APPEND wa_final = it_final. ENDLOOP. ENDFORM. FORM combine_data1. Rohini kumar
SAP-ABAP
278
SORT it_mseg BY matnr werks. it_mseg1[ ] = it_mseg[ ]. DELETE ADJACENT DUPLICATES FROM it_mseg1 COMPARING matnr werks. LOOP AT it_mseg1 INTO wa_mseg1. LOOP AT it_mseg INTO wa_mseg WHERE matnr = wa_mseg1-matnr AND werks = wa_mseg1-werks. READ TABLE it_mara INTO wa_mara WITH KEY matnr = wa_mseg-matnr. IF wa_mseg-bwart EQ ‘101’. wa_final-prod = wa_mara-prod + wa_mseg-menge. ENDIF. IF wa_mseg-bwart EQ ‘102’. wa_mseg-menge = (-1) * wa_mseg-menge. wa_final-prod = wa_mara-prod + wa_mseg-menge. ENDIF. IF wa_mseg-bwart EQ ‘602’. wa_final-sale = wa_mara-sale + wa_mseg-menge. ENDIF. IF wa_mseg-bwart EQ ‘601’. wa_mseg-menge = (-1) * wa_mseg-menge. wa_final-sale = wa_mara-sale + wa_mseg-menge. ENDIF. IF wa_mseg-bwart EQ ‘262’. wa_final-cons = wa_mara-cons + wa_mseg-menge. ENDIF. IF wa_mseg-bwart EQ ‘261’. wa_mseg-menge = (-1) * wa_mseg-menge. wa_final-cons = wa_mara-cons + wa_mseg-menge. ENDIF. IF wa_mseg-bwart EQ ‘651’. wa_final-return = wa_mara-return + wa_mseg-menge. ENDIF. Rohini kumar
SAP-ABAP
279
IF wa_mseg-bwart EQ ‘652’. wa_mseg-menge = (-1) * wa_mseg-menge. wa_final-return = wa_mara-return + wa_mseg-menge. ENDIF. ENDLOOP. wa_final-werks = wa_mseg-werks. MODIFY it_final FROM wa_final TRANSPORTING werks prod cons sale return WHERE matnr = wa_mseg-matnr. CLEAR wa_final. ENDLOOP. ENDFORM. FORM fill_cat. WA_FCAT-FIELDNAME = ‘MATNR’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Material Code’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘MAKTX’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Material description’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘WERKS’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Plant’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘VTEXT’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Segment’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘PROD’. WA_FCAT-TABNAME = ‘it_final’. Rohini kumar
SAP-ABAP
WA_FCAT-SELTEXT_M = ‘Production’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘SALE’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Sale’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘CONS’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Consumption’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘RETURN’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Returns’. APPEND WA_FCAT TO IT_FCAT. * for plant wise WA_FCAT-FIELDNAME = ‘MATNR’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Material Code’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘MAKTX’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Material description’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘WERKS’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Plant’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘PROD’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Production’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘SALE’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Sale’. APPEND WA_FCAT TO IT_FCAT1. Rohini kumar
280
SAP-ABAP
WA_FCAT-FIELDNAME = ‘CONS’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Consumption’. APPEND WA_FCAT TO IT_FCAT1. WA_FCAT-FIELDNAME = ‘RETURN’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Returns’. APPEND WA_FCAT TO IT_FCAT1. * for segment wise WA_FCAT-FIELDNAME = ‘MATNR’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Material Code’. APPEND WA_FCAT TO IT_FCAT2. WA_FCAT-FIELDNAME = ‘MAKTX’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Material description’. APPEND WA_FCAT TO IT_FCAT2. WA_FCAT-FIELDNAME = ‘VTEXT’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Segment’. APPEND WA_FCAT TO IT_FCAT2. WA_FCAT-FIELDNAME = ‘PROD’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Production’. APPEND WA_FCAT TO IT_FCAT2. WA_FCAT-FIELDNAME = ‘SALE’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Sale’. APPEND WA_FCAT TO IT_FCAT2. WA_FCAT-FIELDNAME = ‘CONS’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Consumption’. APPEND WA_FCAT TO IT_FCAT2. Rohini kumar
281
SAP-ABAP
282
WA_FCAT-FIELDNAME = ‘RETURN’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-SELTEXT_M = ‘Returns’. APPEND WA_FCAT TO IT_FCAT2. ENDFORM. FORM layout. WA_LAYOUT-ZEBRA = ‘X’. WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’. ENDFORM. FORM fill_event. WA_EVENT-NAME = ‘USER-COMMAND’. WA_EVENT-FORM = ‘INTERACTIVE’. APPEND wa_event TO it_event. ENDFORM. FORM display_data. IF p_rb1 EQ ‘X’. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-REPID IT_FIELDCAT = IT_FCAT1 IS_LAYOUT = WA_LAYOUT IT_EVENTS = IT_EVENT TABLES T_OUTTAB = IT_FINAL. ELSEIF p_rb2 EQ ‘X’. SORT it_final BY matnr spart. it_final1[ ] = it_final. DELETE ADJACENT DUPLICATES FROM it_final1 COMPARING matnr spart. Rohini kumar
SAP-ABAP
LOOP AT it_final1 INTO wa_final1. LOOP AT it_final INTO wa_final WHERE matnr = wa_final1-matnr AND spart = wa_final1-spart. wa_out-prod = wa_out-prod + wa_final-prod. wa_out-sale = wa_out-sale + wa_final-sale. wa_out-cons = wa_out-cons + wa_final-cons. wa_out-return = wa_out-return + wa_final-return. ENDLOOP. wa_out-matnr = wa_final-matnr. wa_out-maktx = wa_final-maktx. wa_out-vtext = wa_final-vtext. APPEND wa_out TO it_out. CLEAR wa_out. ENDLOOP. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-REPID IT_FIELDCAT = IT_FCAT2 IS_LAYOUT = WA_LAYOUT IT_EVENTS = IT_EVENT TABLES T_OUTTAB = IT_OUT. ELSEIF p_rb3 EQ ‘X’. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-REPID IT_FIELDCAT = IT_FCAT IS_LAYOUT = WA_LAYOUT IT_EVENTS = IT_EVENT TABLES T_OUTTAB = IT_FINAL. ENDIF. ENDFORM. FORM INTERACTIVE USING UCOMM TYPE SY-UCOMM SEL TYPE SLIS_SELFIELD REFRESH it_final2. Rohini kumar
283
SAP-ABAP
IF SEL-SEL_TAB_FIELD EQ ‘it_final-matnr’. LOOP AT it_final INTO wa_final WHERE matnr = SEL-VALUE. APPEND wa_final TO it_final2. ENDLOOP. ENDIF. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-REPID IT_FIELDCAT = IT_FCAT IS_LAYOUT = WA_LAYOUT TABLES T_OUTTAB = IT_FINAL2. ENDFORM.
Rohini kumar
284
SAP-ABAP
285
Object: Sales register report Input: S_fkart --------- billing type S_vbeln -------- billing number S_werks S_matnr S_fkdat -------- billing date S_bukrs S_spart Output: Invoice number Bill date Customer number Customer name Material number Material description Bill quantity Bill amount Customer PO number Customer PO date Excise number Excise date VAT CST CForm number CForm date Issue date Delivery number Sales order number Note: In real time vendor bill sell goods to customer to different states. To avail CST benefits customer will provide a CForm to vendor which is entered into SAP system through report Processing Logic: 1. Get vbeln fkdat kunrg matnr fkimg netwr knumv posnr based on input from vbrk & vbrp tables 2. Get kunnr name from kna1 by processing kunrg of vbrk 3. Get matnr maktx from makt by passing matnr of vbrk Rohini kumar
SAP-ABAP
4. 5. 6. 7. 8.
286
Get exnum exdat rdoc from j_1iexchdr by passing vbeln of vbrk Get vbeln vbelv from vbfa by passing vbeln of vbrk where vbtyp_v = ‘c’ Get bstkd bstdk from vbkd by passing vbelv of vbfa Get vbelv from vbfa by passing vbeln of vbrk where vbtyp_v = ‘j’ Get knumv kschl kposn kwert from konv by passing knumv of vbrk and posnr of vbrk 9. Get vbeln cno cdate idate from zsd_forms by passing vbeln of vbrk Solution: ZSD_SALES_REGISTER_SJU
Rohini kumar
SAP-ABAP
287
SD Flow: Inquiry Sales order Delivery Invoice If sub sequent is given (invoic) & I want preceding (sales order) SELECT vbelv FROM VBFA INTO TABLE it WHERE vbeln = it1_vbeln AND VBTYP_V = ‘C’. If sub sequent is given (invoic) & I want preceding (delivery) SELECT vbelv FROM VBFA INTO TABLE it WHERE vbeln = it1_vbeln AND VBTYP_V = ‘I’. If preceding is given (sales order) & I want sub sequent (invoice) SELECT vbeln FROM VBFA INTO TABLE it WHERE vbelv = it1_order AND VBTYP_N = ‘M’. If preceding is given (sales order) & I want sub sequent (delivery) SELECT vbeln FROM VBFA INTO TABLE it WHERE vbelv = it1_order AND VBTYP_N = ‘J’.
Rohini kumar
SAP-ABAP
288
18-10-2014 J_1IEXCHDR Table: It is also called Excise table It holds invoice header data Fields: 1. DOCYR ---------- year 2. DOCNO --------- excise document number 3. BUKRS ---------- company code 4. WERKS ---------- plant 5. EXGRP ---------- excise group 6. EXNUM --------- excise number 7. EXDAT --------- excise date 8. LIFNR ----------- vendor number 9. EXBED --------- basic excise duty 10.EXSED --------- special excise duty 11.EXAED -------- additional excise duty 12.CESS ----------- cess amount 13.RDOC --------- reference document (invoice) Link: VBRK-vbeln J_1IEXCHDR-rdoc VBFA Table: It holds sales document flow data In sales document flow, if one document is given you can get other document details from this table Fields: 1. VBELN ---------- subsequent document number 2. VBELV ---------- preceding document number 3. VBTYP_N ------ document category of subsequent document 4. RFMNG --------- reference quantity 5. MEINS ---------- unit of measurement 6. RFWRT --------- reference value 7. VBTYP_V ----- document category of preceding document
Rohini kumar
SAP-ABAP
VBKD Table: It holds sale document business data Fields: 1. VBELN -------------- sales order number 2. KDGRP ------------- customer group 3. LCNUM ------------ letter of credit number 4. BSTKD ------------- customer PO number 5. BSTKD ------------- customer PO date Assignment: Material wise Invoice & Realization details Input: S_matnr S_werks S_exdat -------invoice date Tables: VBRK VBRD MAKT TSPAT Output: Material number Material description Division description Remarks Jan Feb March Total Solution:
Rohini kumar
289
SAP-ABAP
290
20-10-2014 Blocked ALV: Using Blocked ALVs you can display multiple lists at one place In real time we are using blocked alvs in few scenarios such as if you want to display production affiance of different machines of one furnace in one Output list If client requires invoice details based on customers, materials, segments at one place we have to work with Blocked ALVs Function Modules for Blocked ALVs: 1. REUSE_ALV_BLOCK_LIST_INIT 2. REUSE_ALV_BLOCK_LIST_APPEND 3. REUSE_ALV_BLOCK_LIST_DISPLAY REUSE_ALV_BLOCK_LIST_INIT: It initializes lists in blocked alvs REUSE_ALV_BLOCK_LIST_APPEND: This function module 1. Maintains field catalogs 2. Maintains data in list 3. Append field catalogs & data with layout REUSE_ALV_BLOCK_LIST_DISPLAY: It displays data in list in blocked alvs
Rohini kumar
SAP-ABAP
291
Requirement: Invoice details Customer wise, Material wise & Segment wise Input: S_kunrg S_matnr S_werks S_bukrs S_fkdat Output: Customer number
Material code
Segment
Heading Name Total quantity
Heading Material description
Solution: ZSD_AUMR_SALES_CUS_MAT_DIV
Rohini kumar
Total quantity
Heading Segment description total quantity
Tables: VBRK VBRP MAKT KNA1 TSPAT
Total value
Total value
Total value
SAP-ABAP
292
Note: REUSE_ALV_BLOCK_LIST_ALV: It will initialize blocks in blocked alvs You should pass current program name to this function module REUSE_ALV_BLOCK_LIST_APPEND: It maintains blocks with field catalogs with data & Append field catalog & data to layout The parameters are 1. Layout work area 2. Field catalog internal table 3. Internal table name 4. Events internal table 5. Output internal table REUSE_ALV_BLOCK_LIST_DISPLAY: It will displays the data in output list No need to pass any parameters to this function module Note: In layout work area you should pass INFO-FIELDNAME for displaying row with a specific color given in output list
Rohini kumar
SAP-ABAP
293
*** Hierarchal Sequential ALVs: Using hierarchal sequential alvs you can display application data in hierarchal format Requirement: PO Price Change Report Input: S_lifnr S_matnr S_mtart S_werks S_matkl S_bedat Output: Sno
Material code Material description PO number PO date Vendor name Unit of measurement
Quantity
Processing Logic: 1. Get matnr from MARA based on input 2. Get ebeln bedat meins menge matnr netpr lifnr by passing matnr of MARA & based on input 3. Get lifnr name1 from LFA1 by passing lifnr of EKKO *** Ques: Explain procedure of working with Hierarchal ALVs? Answer: In Hierarchal Sequential ALVs we have to create 2 internal tables One for Header data (it_final1) & another for Item data (it_final) Both these internal tables should have a common field called KEY field In Header internal table the Key field should be unique In Item internal table the Key field should having number of items based on that unique key Pass these two internal tables to a function module called REUSE_ALV_HIERSEQ_LIST_DISPLAY Solution: ZMM_PO_PRICE_CHANGE_REPORT TYPE-POOLS SLIS. TABLES: EKKO, EKPO, LFA1, MARA. Rohini kumar
SAP-ABAP
294
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr, s_matnr FOR mara-matnr, s_bukrs FOR ekko-bukrs, s_mtart FOR ekpo-mtart, s_werks FOR ekpo-werks, s_matkl FOR ekpo-matkl, s_bedat FOR ekko-bedat. SELECTION-SCREEN:END OF BLOCK b1. TYPES: BEGIN OF ty_mara, matnr TYPE matnr, maktx TYPE maktx, END OF ty_mara. TYPES: BEGIN OF ty_lfa1, lifnr TYPE lifnr, name1 TYPE name1, END OF ty_lfa1. TYPES: BEGIN OF ty_ekko, ebeln TYPE ebeln, bedat TYPE bedat, matnr TYPE matnr, meins TYPE meins, menge TYPE menge_D, netpr TYPE netpr, lifnr TYPE lifnr, END OF ty_ekko. TYPES: BEGIN OF ty_final, key TYPE I, sno TYPE I, matnr TYPE matnr, maktx TYPE maktx, ebeln TYPE ebeln, bedat TYPE bedat, lifnr TYPE lifnr, name1 TYPE name1, meins TYPE meins, menge TYPE menge_D, netpr TYPE netpr, END OF ty_final. Rohini kumar
SAP-ABAP
295
DATA: wa_lfa1 wa_mara wa_ekko wa_final it_lfa1 it_mara it_ekko it_final it_final1
TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE
ty_lfa1, ty_mara, ty_ekko, ty_final, TABLE OF ty_lfa1, TABLE OF ty_mara, TABLE OF ty_ekko, TABLE OF ty_final, TABLE OF ty_final.
DATA: cnt TYPE I, count TYPE I VALUE 1. DATA: WA_FCAT WA_SORT WA_LAYOUT WA_EVENT IT_EVENT IT_SORT WA_KEY IT_FCAT PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM
TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE
SLIS_FIELDCAT_ALV, SLIS_SORTINFO_ALV, SLIS_LAYOUT_ALV, SLIS_ALV_EVENT, SLIS_T_EVENT, SLIS_T_SORTINFO_ALV, SLIS_KEYINFO_ALV, SLIS_T_FIELDCAT_ALV.
get_mara. get_ekko. get_lfa1. combine_data. layout. sort. fill_cat. key. display_hierseq.
FORM get_mara. SELECT mara~matnr makt~maktx INTO TABLE it_mara FROM MARA INNER JOIN MAKT ON mara~matnr = makt~matnr WHERE mara~matnr IN s_matnr AND spras EQ ‘EN’. ENDFORM. Rohini kumar
SAP-ABAP
296
FORM get_ekko. IF NOT it_mara IS INITIAL. SELECT ekko~ebeln ekko~bedat ekpo~matnr ekpo~meins ekpo~menge ekpo~netpr ekpo~lifnr INTO TABLE it_ekko FROM EKKO INNER JOIN EKPO ON ekko~ebeln = ekpo~ebeln FOR ALL ENTRIES IN it_mara WHERE ekpo~matnr = it_mara-matnr AND ekpo~werks IN s_werks AND ekpo~bukrs IN s_bukrs AND ekpo~mtart IN s_mtart AND ekpo~matkl IN s_matkl AND ekko~lifnr IN s_lifnr AND ekko~bedat IN s_bedat. ENDIF. ENDFORM. FORM get_lfa1. IF NOT it_ekko IS INITIAL. SELECT lifnr name1 FROM LFA1 INTO TABLE it_lfa1 FOR ALL ENTRIES IN it_ekko WHERE lifnr = it_ekko-lifnr. ENDIF. ENDFORM. FORM combine_data. LOOP AT it_mara INTO wa_mara. LOOP AT it_ekko INTO wa_ekko WHERE matnr = wa_mara-matnr. wa_final-matnr = wa_ekko-matnr. wa_final-ebeln = wa_ekko-ebeln. wa_final-bedat = wa_ekko-bedat. wa_final-meins = wa_ekko-meins. wa_final-menge = wa_ekko-menge. wa_final-netpr = wa_ekko-netpr. READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_ekko-lifnr. wa_final-name1 = wa_lfa1-name1. wa_final-maktx = wa_mara-maktx. Rohini kumar
SAP-ABAP
cnt = cnt + 1. wa_final-sno = cnt. wa_final-key = count. APPEND wa_final TO it_final. ENDLOOP. CLEAR cnt. count = count + 1. ENDLOOP. ENDFORM. FORM fill_cat. WA_FCAT-FIELDNAME = ‘MATNR’. WA_FCAT-SELTEXT_M = ‘Material Code’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘MAKTX’. WA_FCAT-SELTEXT_M = ‘Material Description’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘SNO’. WA_FCAT-SELTEXT_M = ‘S.no’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘EBELN’. WA_FCAT-SELTEXT_M = ‘PO Number’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘BEDAT’. WA_FCAT-SELTEXT_M = ‘PO Date’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘LIFNR’. WA_FCAT-SELTEXT_M = ‘Vendor Code’. WA_FCAT-TABNAME = ‘it_final’. Rohini kumar
297
SAP-ABAP
APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘NAME1’. WA_FCAT-SELTEXT_M = ‘Name’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘MEINS’. WA_FCAT-SELTEXT_M = ‘Unit of Measurement’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘MENGE’. WA_FCAT-SELTEXT_M = ‘PO Quantity’. WA_FCAT-TABNAME = ‘it_final’. WA_FCAT-DO_SUM = ‘X’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘NETPR’. WA_FCAT-SELTEXT_M = ‘Unit Price’. WA_FCAT-TABNAME = ‘it_final’. APPEND WA_FCAT TO IT_FCAT. ENDFORM. FORM sort. WA_SORT-FIELDNAME = ‘MATNR’. WA_SORT-TABNAME = ‘it_final1’. WA_SORT-SUBTOT = ‘X’. WA_SORT-UP = ‘X’. APPEND wa_sort TO it_sort. ENDFORM. FORM key. WA_KEY-HEADER01 = ‘KEY’. WA_KEY-ITEM01 = ‘KEY’. ENDFORM. Rohini kumar
298
SAP-ABAP
FORM layout. WA_LAYOUT-ZEBRA = ‘X’. WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’. ENDFORM. FORM display-hierseq. it_final1[ ] = it_final[ ]. DELETE ADJACENT DUPLICATES FROM it_final1 COMPARING key. CALL FUNCTION ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = SY-REPID IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FCAT IT_SORT = IT_SORT I_SAVE = ‘X’ I_TABNAME _HEADER = ‘it_final1’ I_TABNAME_ITEM = ‘it_final’ IS_KEYINFO = wa_key TABLES T_OUTTAB_HEADER = it_final1 T_OUTTAB_ITEM = it_final. ENDFORM.
Rohini kumar
299
SAP-ABAP
21-10-2014 Note: SLIS_KEYINFO_ALV: It holds the Key field details of bifurcation in hierarchal sequential alvs It is having fields such as 1. HEADER01 -------- header key field 2. ITEM01 ------------- item key field REUSE_ALV_HIRESEQ_LIST_DISPLAY: Using this function module you can display the in hierarchal format The parameters are 1. Current program name 2. Layout work area 3. Field catalog internal table 4. Sorting internal table 5. Layout for sale 6. Events internal table 7. Header internal table name 8. Item internal table name 9. Key work area for bifurcation 10.Header internal table 11.Item internal table
Rohini kumar
300
SAP-ABAP
FI Module: FICO Finance & Controlling Module In every company vendor will sell goods & customer will purchase In both the cases money inflow & outflow will take place Then FI module comes into picture Components in FI Module: 1. Accounting Document Number: For every finance transaction system will creates an accounting document number T Codes: 1. FB01 2. FB02 3. FB03 Tables: 1. BKPF 2. BSEG Key field: BELNR 2. Account Receivable: This document is created when vendor will receive money form customer T Codes: 1. F-28 2. FB02 3. FB03 Tables: 1. BSID 2. BSAD Key field: BELNR 3. Account Payable: This document is created when customer will pay money to vendor T Codes: 1. F-43 2. FB02 Rohini kumar
301
SAP-ABAP
3. FB03 Tables: 1. BSIK 2. BSAK Key field: BELNR 4. Asset Accounting: Every company has to purchase assets All assets are posted to asset accounting T Codes: 1. AB01 2. AB02 3. AB03 Tables: 1. ANEK 2. ANEP 3. ANLC 4. ANLZ 5. ANKA Key field: ANLNR (asset number) 5. G/L Account: General Ledger Account It is heart of Finance module All finance transactions are ultimately posted to a specific G/L Accont G/L Account holds both master data & transactional data T Codes: 1. FS01 2. FS10N 3. FAGLL03 4. FBL1N 5. FBL3N 6. FBL5N Tables: 1. SKA1 2. SKB1 Rohini kumar
302
SAP-ABAP
3. BSIS 4. BSAS Key field: HKONT, SAKNR Other Impartment Tables: 1. FAGLFLEXT 2. FAGLFLEXA 3. GLTO
Rohini kumar
303
SAP-ABAP
HR Module: Human Resource Module Components in HR Module: 1. Personal Administration i) Personal management ii) Organizational structure iii) Personality development iv) Compensation management v) Recruitment 2. *** Organizational Management 3. *** Payroll 4. Time Management 5. Travel Management Info Types: It is a set of related data fields stores information at one place in HR Every Info type is a 4 letter word Example: 0008 ------- basic salory 0021 ------- family 0023 ------- previous employers 0006 ------- addresses ……………….etc Applications in HR Module: 1. PA10 2. PA20 3. *** PA30 4. PA40 5. PA60 6. PA61 7. PC00_M40_CALC 8. PAYPC_RESULTS
Rohini kumar
304
SAP-ABAP
Tables: 1. PA0001 Info Type: It is an info type for organizational assignment Fields: 1. *** PERNR ------------ employee number 2. BUKRS ----------------- company code 3. PERSG ----------------- employee group 4. PERSK ----------------- employee sub group 5. BTRTL ----------------- personal sub area (department) 6. *** ABKRS ----------- payroll area 7. KOSTL ---------------- department 8. SNAME --------------- employee full name 9. ENAME --------------- employee name 2. PA0002 Info Type: It is an info type for employee personal data Fields: 1. PERNR -------- employee number 2. NACHN ------- last name 3. VORNA ------- first name 4. CNAME------- complete name 5. RUFNM ------- nick name 6. ANRED ------- title 7. GESCH ------- gender 8. *** GBDAT --- date of birth 9. ANZKD -------- number of children 10.FAMST -------- material status 22-10-2014 3. PA0006 Info Type: It is for Employee addresses Fields: 1. PERNR ---------- employee number 2. NAME2 --------- C/O name 3. STRAS ---------- street 4. ORT01 ---------- city 5. PSTLZ ---------- postal code 6. LAND1 --------- country Rohini kumar
305
SAP-ABAP
4. PA0009 Info Type: It is for Employee Bank details Fields: 1. PERNR ---------- employee number 2. BANKS --------- bank country name (sbi, icici) 3. BANKL --------- bank key (fct code) 4. BANKN --------- bank account number 5. PA0040 Info Type: It is for employee recurring payments & deduction Fields: 1. PERNR ---------- employee number 2. BEGDA --------- start date 3. ENDDA --------- end date 4. LGORT ---------- wage type (salary type ) 5. BETRG ---------- amount 6. PA0019 Info Type: It is for maintaining dates Retirement is stored in this info type Fields: 1. PERNR ----------- employee number 2. BEGDA ---------- retirement date 7. PA0021 Info Type: It is for employee family members details Fields: 1. PERNR ------------ employee number 2. FGBAT ------------ date of birth of family members 3. FAVOR ------------ first name 4. FANAM ----------- last name 5. SUBTY ------------ sub type 6. OBJPS ------------- object identification
Rohini kumar
306
SAP-ABAP
Example: Pernr 1000
307
Subty Objps 11 (Father) -12 (Mother) -1 (Wife) -2 (children) 01 02
Fanam suresh laxmi sita chinnu banti
8. PA0023 Info Type: It is for previous employers details Fields: 1. PERNR ---------- employee number 2. ARBGP --------- name of employer (google, tcs) 3. ORT01 ---------- city 4. BRANK -------- industry 5. TAETE --------- job of employee 9. PA0028 Info Type: It is for internal medical service details Fields: 1. PERNR ---------- employee number 2. NMF01 ---------- value (blood group) 3. NMF02 --------- value (height)…………..etc 10. PA0105 Info Type: It is for communication details Fields: 1. PERNR --------- employee number 2. USRTY --------- communication type (phone, email) 3. USRID ---------- communication number 11.PA0586 Info Type: It is for tax rebate details Fields: 1. PERNR --------- employee number 2. ITC01 ----------- investment code 3. PIN01 ----------- investment amount 4. ITC02 ----------- investment code 5. PIN02 ---------- investment amount Rohini kumar
SAP-ABAP
308
12.PA0587 Info Type: It is for PF contribution details Fields: 1. PERNR ----------- employee number 2. EEPFM ----------- PF account number 3. TSTID ------------ PF trust 4. PFAMT ---------- PF amount 13.PA0588 Info Type: It is for employee welfare schemes details Fields: 1. PERNR ---------- employee number 2. *** ESINO ----- employee state insurance number 3. ESIDP ----------- ESI dispensary (hospital) 13. TEVEN Table: It is for time event details Fields: 1. PERNR ---------- employee number 2. LDATE ---------- logical date 3. LTIME ----------- logical time 14.PA2001 Info Type: It is for absence details Fields: 1. PERNR ---------- employee number 2. AWART -------- absence type 3. ABWTG -------- absence days 4. ** ABRTG ----- payroll days 5. ** BEGDA ----- start date 6. ENDDA -------- end date Example: Pernr 1000
Rohini kumar
Begda 01.11.2014 (Saturday)
Endda 04.11.2014 (Tuesday)
Awart EL
Abwtg 2 Days
Abrtg 3 Days
SAP-ABAP
15.PA2002 Info Type: It is for attendance details Fields: 1. PERNR ----------- employee number 2. BEGDA ---------- start date 3. ENDDA ---------- end date 4. AWART ---------- attendance type 5. ABWTG ---------- attendance days 6. ABRTG ---------- payroll days 16.*** PA0008 Info Type: It is for basic pay details Fields: 1. PERNR ---------- employee number 2. TRFGR ---------- pay scale group 3. LGA01 ---------- wage type (salary type)---DA 4. BET01 ---------- amount for wage type (salary type) 5. LGA02 --------- wage type (salary type)---HRA 6. BET02 --------- amount for wage type (salary type)…………up to 30
Rohini kumar
309
SAP-ABAP
310
Logical Database: Logical database is a special type of program provided by SAP It collects a group of (or) a set of Related Fields together from Database & supplied it to Application program Note: The T code for working with logical database is SLDB Object: Employee Details Report Input: S_pernr ---------- Employee number S_persg --------- Employee group S_persk --------- Employee sub group S_abkrs --------- Payroll area Output: Employee number Employee name Date of joining Date of birth Department Designation Age Solution: Step-1: Create a structure with output fields Go to SE11 Structure: ZHR_EMP_STR Step-2: Inserting logical database in our program Go to SE38 Program: ZHR_EMPLOYEE_DETAILS_REPORT Create Title: Employee Details Report Type: Executable Program *** Logical Database: PNP (It is a special type of program name) Enter Rohini kumar
SAP-ABAP
311
TABLES: PERNR INFOTYPES: 0001, 0002. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_pernr FOR pernr-pernr, S_persg FOR pernr-persg, S_persk FOR pernr-persk, S_abkrs FOR pernr-abkrs, SELECTION-SCREEN: END OF BLOCK b1.
Activate Back Attributes Change HR Report Category You will find a pop-up provide Master Data: IE_P35L (for no selection screen display of PNP program) Enter Save Source Code Change
ZHR_EMPLOYEE_DETAILS TYPES: BEGIN OF ty_final, Pernr TYPE zhr_emp_str-pernr, Ename TYPE zhr_emp_str-ename, Doj TYPE zhr_emp_str-doj, Gbdat TYPE zhr_emp_str-gbdat, Dept TYPE zhr_emp_str-dept, Age TYPE zhr_emp_str-age, END OF ty_final. DATA: wa_final TYPE ty_final, it_final TYPE TABLE OF ty_final. DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_LAYOUT TYPE SLIS_LAYOUT_ALV. DATA: design(20), Dept(20), Hdate TYPE DATUM, Age TYPE I. Rohini kumar
SAP-ABAP
312
START-OF-SELECTION. GET PERNR. CHECK pernr-pernr IN s_pernr, AND pernr-persg IN s_persg, AND pernr-abkrs IN s_abkrs. IF SY-SUBRC EQ 0. PERFORM get_data. ENDIF. END-OF-SELECTION. PERFORM layout. PERFORM display_data. FORM get_data. SELECT SINGLE plstx FROM T528T INTO design WHERE plans = pernr-plans AND sprsl EQ ‘EN’ AND dept EQ ‘S’. SELECT SINGLE orgtx FROM T527X INTO dept WHERE orgeh = pernr-orgeh. CALL FUNCTION ‘RP_GET_HIRE_DATE’ EXPORTING PERSNR = pernr-pernr CHECK_INFOTYPES = ‘0001’ IMPORTING HIREDATE = hdate. CALL FUNCTION ‘HR_RU_AGE_YEARS’ EXPORTING PERSNR = pernr-pernr BSDATE = SY-DATUM IMPORTING VALUE = age. wa_final-pernr = p0002-pernr. wa_final-ename = p0002-nachn. wa_final-doj = hdate. Rohini kumar
SAP-ABAP
313
wa_final-gbdat = p0002-gbdat. wa_final-dept = dept. wa_final-age = age. APPEND wa_final TO it_final. ENDFORM. FORM display_data. CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’ EXPORTING I_STRUCTURE_NAME = ‘ZHR_EMP_STR’ IT_FIELDCAT = IT_FCAT IS_LAYOUT = WA_LAYOUT TABLES T_OUTTAB = IT_FINAL. ENDFORM. 24-10-2014 Ques: What are the different ways to creating FIELD CATALOGS? Ans : There are 3 ways to create FIELD CATALOGS 1. Manually Ex: WA_FCAT-FIELDNAME = ‘KUNNR’. WA_FCAT-SELTEXT_M = ‘Customer Code’. APPEND WA_FCAT TO IT_FCAT. 2. By using REUSE_ALV_FIELDCATALOG_MERGE function module 3. By passing DDIC Structure name to REUSE_ALV_LIST_DISPLAY function module
Rohini kumar
SAP-ABAP
Assignment: Employee Total Details Report Input: S_pernr --------employee number S_persg -------- employee group S_persk -------- employee sub group S_abkrs -------- payroll area Output: Gender (0002) Number of Children (0002) Address (0006) Telephone Number (0105) Mail Id (0105) Height (0028) Weight (0028) Employee group (0001) Employee sub group (0001) Bank account number (0009) Employee grade (0008) Solution:
Rohini kumar
314
SAP-ABAP
315
SAP Query: In real time for developing a report it will take lot of time for development i.e. Requirement ---- Functional Consultant-----Functional Document----Technical Consultant-----Technical Document------Object Creation------Unit Testing----Functional Testing-----User Testing-----go live (transfer to Production) using SAP Query you can create a report immediately through navigation Drawbacks: 1. If you want to perform calculations & other complex logics you cannot work with SAP Query 2. The T code for working SAP Query is SQVI Example: Customer Details Report Step-1: program creation Go to SQVI Quick Viewer: ZCUSTOMER Create Title: Customer Details Report Table Join Enter Insert Table (shift + F1) Table: KNA1 Insert Table (shift + F1) Table: VBAK Enter Back Selection Fields (for input fields) Select Customer Number List Fld Select (for output fields) Select Customer Number Name Sale Document Date on which created Save Back Yes Quick View ----- Additional Functions ----- Generate Program Quick View ---- Additional Funtions -----Display Report Name (copy this name)
Rohini kumar
SAP-ABAP
Step-2: T code creation Go to SE93 Transaction Code: ZCUST Create Short Text: T code for customer details Program and Selection Screen Enter Program: paste program name Save Back Execute T code Note: 1. You can create SAP Query directly in Production Server in real time 2. Selection screen number is 1000
Rohini kumar
316
SAP-ABAP
317
Performance Tuning: In real time we should create programs according coding standards along with that our program should show good performance as per performance standards Topics in Performance Tuning: 1. ** Indexing (SE11) 2. Runtime Analysis (SE30) 3. SQL Tracer (ST05) 4. Extended program check (SLIN) 5. Code Inspector (SCI) 6. Get runtime field 7. Performance tips
Rohini kumar
SAP-ABAP
318
25-10-2014 Indexing: Indexing is a way of searching Indexing is a way of improving performance while accessing the data from database Index: Index is a copy of a table with reduced fields Every index table contains 1. Primary key fields, 2. Non Primary key fields & 3. A Pointer field which always points to the position of record Index takes advantage of sorting using Binary search Every index contains pointer also So, that it points to the records of actual table which are not contained in the index table Types of Indexes: 1. Primary Index 2. Secondary Index Primary Index: Primary index contains primary key fields It always points to non primary key fields Primary index always take advantage of sorting Note: Primary Index is automatically created whenever a table is created in database Secondary Index: Secondary index is applied whenever a table will not take the advantage of sorting Secondary index contains non primary key fields It always points to primary key fields Secondary indexes are created 1. On large tables 2. Table which are frequently access 3. Tables having more coloumns Ques: When you create index on tables? Answer: I created secondary index on production efficient report First I debugged the program I found that control is taking lot of time for program execution Rohini kumar
SAP-ABAP
319
Then I will identify none primary key fields of that SELECT statement & based on that non-primary key fields I will created a secondary index Navigation for Creating Secondary Index: Go to SE38 Debug a program there control will staying on a SELECT statement for long time Identify non-primary key fields
Go to SE11 Database Table: AFRU Display Select Indexes Select Create option Create Entries Provide Index: ZAP You will find a warning there you will find a message “make reports in foreign name spaces”, Enter Again you will find a pop-up then select Maintain in Original Language Provide Short Description: Index for BUDAT field Field Name: BUDAT Activate (ctrl+F3)
Rohini kumar
SAP-ABAP
26-10-2014 SQL Tracer: (ST05) It provides information on 1. SQL statements operated in a program 2. All embedded SQL operations on a table i.e. prepare open cursor fetch reopen 3. Number of extracted by SELECT statements 4. Performance time for tables 5. Indexes associated with tables Example: Step-1: Go to ST05 Select Activate Tracer option Step-2: Program: any program name Execute Provide selection screen input Execute Step-3: Go to ST05 Select Performance Tracer ---------Tracer off Select Display Tracer option You will find a pop-up Enter Here you will find a screen with following fields 1. Duration 2. Object name 3. Operation 4. Number of records 5. Statement Duration -------- stores the time taken by a statement Object name --- specifies the table name Operation ------ specifies type of operation done on a SELECT statement No of records-- specifies number of records Statement ------ specifies the skeleton of SELECT statement in your program Rohini kumar
320
SAP-ABAP
321
Double click on Object Name ---------- it will show the table details specified in data dictionary (number of records, type of table…………….etc) Select Index Fields option ---------- here you will find indexes created in that table Select Trace List ----- Summarized Trace by SQL Statement --------- here you will find screen of summarized information of all executions on database table Select Display Detailed Trace List (F7) --------- here you will find a screen of all summarized information of all SELECT statements operated in your program Note: In real time SQL Tracer is used for identifying 1. The tables 2. The time taken by tables for a specific database operation, based on this we can identifying whether a table can be Buffered (or) Not
Rohini kumar
SAP-ABAP
322
Runtime Analysis: SE38 Go to SE38 Program: any program name Execute Provide Input values Execute Back Back Scroll down to bottom select Evaluate You will find a graph which shows the execution of a program in Micro Seconds
It always Green
APPLICATION SERVER
Always Green
DATABASE SERVER It may Red (or) Green
0
1
2
3
4
Back Tips & Tricks Expand SQL Interface option Double click on Select With Select List Select Measure Run Time option
Rohini kumar
5
ABAP PROGRAM
SAP-ABAP
ABAP Examples: SE38 Go to SE38 Environment ----- Examples -------ABAP Examples Here you will find topic wise examples ABAP Documentation: SE38 Go to SE38 Program: any program name Change Place Cursor on any keyword Press F1 Here you will find documentation for that key word
Rohini kumar
323
SAP-ABAP
324
Extended Program Check (EPC): SLIN It specifies Internal Errors, Warnings, Messages & Obsolete statements of a program Example: Go to SLIN (or) Go to SE38 Program: any program name Program ------ Check ------ Extended Program Check Select last 4 check boxes Select Execute (F8) Note: Try to maintain all options (Internal Errors, Warnings & Messages) as per as possible zeros
Rohini kumar
SAP-ABAP
325
Code Inspector (CI): SCI It will inspect your code comprehensively & it will check 1. Performance Checks 2. Security Checks 3. Syntax Checks 4. User Interface 5. Programming Guidelines Example: Go to SCI Provide Object Sel Name: ZOBJ Create Save Back Provide Check Variant Name: ZVAR Create Select General Checks, Performance Checks, Syntax Check Generation, Programming Convention & Internal Performance Test Save Back Provide Inspection Name: ZINS Create Select Single: Program: ZSD_SALES_REGISTER Check Variant: ZVAR Save Execute (F8) Results (shift + F6)
Rohini kumar
SAP-ABAP
GET RUN TIME FIELD keyword: It returns the execution time for each loop pass with in LOOP………ENDLOOP Example: DATA t1 TYPE I. DO 10 TIMES. GET RUN TIME FIELD t1. WRITE:/ t1. ENDDO. Activate Execute WAIT UP TO SECONDS keyword: It waits for ‘n’ seconds then it will perform execution This keyword we are using for Mail Sending Reports for wait time Example: WAIT UP TO 100 SECONDS.
Rohini kumar
326
SAP-ABAP
Performance Tuning:
Rohini kumar
327
SAP-ABAP
Creating Custom Logical Database: Go to SLDB Logical Database: ZLD_SD Create Short Text: Logical Database Enter Local Object Name of Root Node: KNA1 Text: KNA1 Table Database Table: KNA1 Enter Select KNA1 Insert Node Node Name: VBAK Text: VBAK Table Database Table: VBAK Execute (F5) Save Back Selections (radio button) Change Yes Enter Remove comment for SELECT-OPTIONS: s_kunnr FOR kna1-kunnr. SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
Activate Back Database Program Change Yes Double click on 1st INCLUDE DBZLD_SDNXXX You will find 4 includes, double click on 1st include (DBZLD_SDN001) Remove 1st comment (SELECT * FROM KNA1) Remove 4th comment (WHERE kunnr IN s_kunnr) Remove comment for ENDSELECT Activate Back
Double click on 2nd INCLUDE You will find 4 includes, double click on 1st include (DBZLD_SDN001) Rohini kumar
328
SAP-ABAP
Remove 1st comment (SELECT * FROM KNA1) Remove 4th comment (WHERE kunnr IN s_kunnr) Remove comment for ENDSELECT Activate
Go to SE38 Program: ZCALL_LDB Create Title: Calling LDB program Type: Executable Program Logical Database: ZLD_SD Enter
TABLES KNA1. GET KNA1. WRITE:/10 kna1-kunnr, 30 kna1-name1, 50 kna1-ort01. Activate Execute
Rohini kumar
329
SAP-ABAP
Assignment-1: *** Material Ageing Report Input: S_matnr S_werks S_budat Output: Material code Material description Last consumption date 0 to 30 days (A30) 31 to 60 days (A60) 61 to 90 days (A90) 91 to 120 days (A120) 121 to 150 days (A150) 151 to 180 days (A180) >180 days (A181) Tables: MKPF MSEG MARA MAKT Solution:
Rohini kumar
330
SAP-ABAP
331
Assignment-2: Packing Cost Material Report Input: S_matnr S_werks Output: Header Data: Material code Material description Item Data: Bom component Bom component description Unit of measurement Price Quantity Tables: MAST STAS MAKT MBEW Processing Logic: 1. Get matnr stlnr stlal from mast based on input 2. Get stlnr stlal from stas by passing stlal of mast & stlnr of mast where stlty EQ ‘m’ 3. Get stlnr idnrk meins menge from stop by passing stlnr of stas & stlkn of stas where stlty EQ ‘m’ 4. Get matnr verpr from mbew by passing matnr of mast where bwkey IN s_werks 5. Get matnr maktx from makt by passing matnr of mast & spras EQ ‘EN’ 6. Get matnr maktx from makt by passing idnrk of stop & spras EQ ‘EN’ Solution:
Rohini kumar
SAP-ABAP
Overview of Reports: Interview Topics: 1. More than 50 objects 2. System landscape 3. Objects (Ex: Material Ageing Report) 3.1. Inputs 3.2. Outputs 3.3. Tables & Fields 4. Business Process Flows (Ex: MM) 5. Events 5.1. Differences between Events 5.2. Flow of Events 5.3. Usage of Events 6. ALV Reporting 6.1. Field catalogs 6.2. Export & Import parameters 6.3. Function modules 6.4. Blocked ALV 6.5. Hierarchal Sequential ALV 6.6. Interactive ALV Flow of Events: Initialization At selection screen Start of selection End of selection Top of page Top of page during line selection End of page At user command
Rohini kumar
332
SAP-ABAP
333
Object Oriented Programming (or) Object Oriented ABAP Difference between Structured Programming & Object Oriented Programming: Structured Programming Object Oriented Programming 1. Not Reusable 1. Reusable 2. Not based on real life 2. Based on real life (not user friendly) 3. No data security 3. High data security 4. No exception handling 4. Exception handling Features of Object Oriented Programming: 1. Inheritance 2. Polymorphism 3. Abstraction 4. Encapsulation Inheritance: Creating new objects from existing object is called inheritance Example: DATA it_kna1 TYPE TABLE OF KNA1. Polymorphism: An identical object behaves differently in different different locations. This concept is called polymorphism Example: VBAK
LIKP
VBRK
vbeln vbeln vbeln (sales order) (delivery document) (invoice number) Abstraction: Hiding the implementation details is called abstraction Example: Function module, Include, Sub routine Encapsulation: In real world every object acts as a capsule of data Every object hides the data in such a way that outside world cannot access it. Encapsulation is achieved from abstraction Rohini kumar
SAP-ABAP
334
Class: Class is a template based on which objects are created All the features (Methods) of an object is encapsulated within a class As class is a template memory is not allocated by system to a class Object: It is real time entity It is always created based on a class (object is an instance of a class) As object is a real time entity memory is allocated by system to an object Every object holds data in such a way that outside world cannot access Access Specifiers: 1. Private 2. Protected 3. Public Private: Attributes declared under private access specifier can be access only by the methods of that particular class Protected: Attributes declared under protected access specifier can be access by the methods of base class as well as derived class Public: Attributes declared under public access specifier can be access by any object in your program Note: Methods should be declared under public access specifier Types of Classes: 1. Local class 2. Global class 3. Exception class 4. Unit Test class 5. Persistent class
Rohini kumar
SAP-ABAP
Section of a Class: 1. Class Definition 2. Class Implementation 3. Class Execution Class Definition: Attributes & Methods are defined under this section Syntax: CLASS DEFINITION. Example: CLASS cl_abc DEFINITION. PUBLIC SECTION. METHOD: get_data, combine_data, display_data. PRIVATE SECTION. DATA: var1, var2. PROTECTED SECTION. DATA: var3, var4. ENDCLASS. Class Implementation: Methods are implemented under this section Syntax: CLASS IMPLEMENTATION. Example: CLASS cl_abc IMPLEMENTATION. METHOD get_data. ----------------------ENDMETHOD. Rohini kumar
335
SAP-ABAP
METHOD combine_data. ----------------------ENDMETHOD. METHOD display_data. ----------------------ENDMETHOD. ENDCLASS. Class Execution: Under this section 1. Objects are defined 2. Objects are created 3. Methods are called Example: DATA obj TYPE REF TO cl_abc. CREATE OBJECT obj. CALL METHOD: obj->get_data, obj->combine_data, obje->display_data.
Rohini kumar
336
SAP-ABAP
337
Requirement: Statement of Account based on Customer Input: Customer code Company code Special G/L indicator Accounting document number Posting date Output: Customer number Customer name Accounting document number Document date Document type Reference document number Debit Credit Over due -------- Total Solution: ZFI_STATEMENT_ACCOUNT TABLES: KNA1, BSID. TYPE-POOLS SLIS. SELECTION-SCREEN: BEGIN OF SELECT-OPTIONS: s_kunnr FOR s_bukrs FOR s_umskz FOR s_belnr FOR s_budat FOR SELECTION-SCREE: END OF CLASS cl_overdue DEFINITION. PUBLIC SECTION. METHODS: get_bsid, combine_data, combine_data1, Rohini kumar
BLOCK b1 WITH FRAME TITLE TEXT-000. kna1-kunnr, bsid-bukrs, bsid-umskz, bsid-belnr, bsid-budat. BLOCK b1.
SAP-ABAP
338
fill_cat, layout, display_data. PRIVATE SECTION. TYPES: BEGIN OF ty_bsid, kunnr TYPE kunnr, name1 TYPE name1, belnr TYPE belnr, blart TYPE blart, bldat TYPE bldat, xblnr TYPE xblnr, shkzg TYPE shkzg, dmbtr TYPE dmbtr, END OF ty_bsid. TYPES: BEGIN OF ty_final, kunnr TYPE kunnr, name1 TYPE name1, belnr TYPE belnr, blart TYPE blart, bldat TYPE bldat, xblnr TYPE xblnr, shkzg TYPE shkzg, debit TYPE dmbtr, credit TYPE dmbtr, due TYPE dmbtr, line_color(4), END OF ty_final. DATA: wa_bsid wa_final wa_final1 it_bsid it_final it_final1
TYPE TYPE TYPE TYPE TYPE TYPE
ty_bsid, ty_final, ty_final, TABLE OF ty_bsid, TABLE OF ty_final, TABLE OF ty_final.
DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV, WA_LAYOUT TYPE SLIS_LAYOUT_ALV, IT_FCAT TYPE SLIS_T_FIELDCAT_ALV. Rohini kumar
SAP-ABAP
339
ENDCLASS. CLASS cl_overdue IMPLEMENTATION. METHOD get_bsid. SELECT kna1~kunnr kna1~name1 bsid~belnr bsid~blart bsid~bldat bsid~xblnr bsid~shkzg bsid~dmbtr INTO TABLE it_bsid FROM BSID INNER JOIN KNA1 ON bsid~kunnr = kna1~kunnr WHERE bsid~kunnr IN s_kunnr AND bsid~umskz IN s_umskz AND bsid~budat IN s_budat AND bsid~bukrs IN s_bukrs AND bsid~belnr IN s_belnr. ENDMETHOD. METHOD combine_data. SORT it_bsid BY kunnr. LOOP AT it_bsid INTO wa_bsid. wa_final-kunnr = wa_bsid-kunnr. wa_final-name1 = wa_bsid-name1. wa_final-xblnr = wa_bsid-xblnr. wa_final-belnr = wa_bsid-belnr. wa_final-bldat = wa_bsid-bldat. wa_final-blart = wa_bsid-blart. IF wa_bsid-shkzg = ‘H’. wa_final-credit = (-1) * wa_bsid-dmbtr. ELSE. wa_final-debit = wa_bsid-dmbtr. ENDIF. wa_final-due = wa_final-debit + wa_final-credit. APPEND wa_final TO it_final. CLEAR wa_final. ENDLOOP. ENDMETHOD. METHOD combine_data1. Rohini kumar
SAP-ABAP
SORT it_final BY kunnnr. LOOP AT it_final INTO wa_final. AT NEW kunnr. MOVE wa_final-kunnr TO wa_final1-kunnr. APPEND wa_final1 TO it_final1. CLEAR wa_final1. ENDAT. wa_final1-name1 = wa_final-name1. wa_final1-belnr = wa_final-belnr. wa_final1-bldat = wa_final-bldat. wa_final1-xblnr = wa_final-xblnr. wa_final1-blart = wa_final-blart. wa_final1-debit = wa_final-debit. wa_final1-credit = wa_final-credit. wa_final1-due = wa_final-due. APPEND wa_final1 TO it_final1. CLEAR wa_final1. AT END OF kunnr. SUM. wa_final1-due = wa_final-due. wa_final1-kunnr = wa_final-‘Total’. wa_final1-line_color = ‘C510’. APPEND wa_final1 TO it_final1. CLEAR wa_final1. ENDAT. AT LAST. SUM. wa_final1-due = wa_final-due. wa_final1-kunnr = wa_final-‘Grand Total’. wa_final1-line_color = ‘C510’. APPEND wa_final1 TO it_final1. Rohini kumar
340
SAP-ABAP
CLEAR wa_final1. ENDAT. ENDLOOP. ENDMETHOD. METHOD fill_cat. wa_fcat-fieldname = ‘KUNNR’. Wa_fcat-seltext_m = ‘Customer Code’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘NAME1’. Wa_fcat-seltext_m = ‘Customer Name’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘BELNR’. Wa_fcat-seltext_m = ‘Accounting Document Number’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘BLDAT’. Wa_fcat-seltext_m = ‘Document Date’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘BLART’. Wa_fcat-seltext_m = ‘Document Type’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘XBLNR’. Wa_fcat-seltext_m = ‘Reference Document Number’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘DEBIT’. Wa_fcat-seltext_m = ‘Debit’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘CREDIT’. Wa_fcat-seltext_m = ‘Credit’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘DUE’. Wa_fcat-seltext_m = ‘Over Due’. APPEND wa_fcat TO it_fcat. Rohini kumar
341
SAP-ABAP
ENDMETHOD. METHOD layout. wa_layout-zebra = ‘X’. wa_layout-colwidth_optimize = ‘X’. wa_layout-info_fieldname = ‘LINE_COLOR’. ENDMETHOD. METHOD display_data. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING IT_FIELDCAT = IT_FCAT. IS_LAYOUT = WA_LAYOUT I_SAVE = ‘X’ TABLES T_OUTTAB = IT_FINAL1. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA obj TYPE REF TO cl_overdue. CREATE OBJECT obj. CALL METHOD: obj->get_bsid, obj->combine_data, obj->combine_data1, obj->fill_cat, obj->layout, obj->display_data.
Rohini kumar
342
SAP-ABAP
27-10-2014 Local Class: In local class all the 3 sections of a class are maintained in ABAP Editor BSID & BSAD Table: BSID holds open items data & BSAD holds cleared items data. The fields will be same Fields: 1. BUKRS ---------- company code 2. KUNNR --------- customer code 3. UMSKZ --------- special G/L indicator 4. ** ZUONR ------ assignment (or) bill number 5. GJAHR ---------- financial year 6. BELNR ---------- accounting document number 7. BUDAT --------- posting date 8. BLDAT --------- bill date 9. XBLNR --------- reference document number 10.BLART --------- document type 11.SHKZG --------- debit (s) / credit (h) indicator 12.**DMBTR ----- amount in local currency 13.HKONT -------- G/L amount 14.**ZFBDT ------ base line date for due date calculation 15.ZTERM -------- payment terms
Rohini kumar
343
SAP-ABAP
344
Inheritance: Creating new objects from existing objects is called inheritance Syntax for declaring Derived Class: CLASS DEFINITION INHERITING FROM . --------------------ENDCLASS. Requirement: Vendor Aging Report Vendor aging report is prepared by customer based on respective vendors Input: S_lifnr S_prctr S_umskz S_bukrs Output: Vendor code Vendor name 0-30 days 31-60 days 61-90 days 91-120 days 121-150 days 151-180 days >-180 days Total amount Solution: ZFI_VENDOR_AGING_REPORTS TYPE-POOLS SLIS. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr, s_prctr FOR bsik-prctr, s_umskz FOR bsik-umskz, s_bukrs FOR bsik-bukrs. SELECTION-SCREEN: END OF BLOCK b1. Rohini kumar
SAP-ABAP
345
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-001. PARAMETERS keydate TYPE budat. SELECTION-SCREEN: END OF BLOCK b2. INITIALIZATION. keydate = SY-DATUM. AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘keydate’. MODIFY SCREEN. ENDIF. ENDLOOP. CLASS cl_base DEFINITION. PUBLIC SECTION. METHODS: get_bsik, combine_data. PROTECTED SECTION. TYPES: BEGIN OF ty_bsik, belnr TYPE belnr_d, bldat TYPE bldat, shkzg TYPE shkzg, dmbtr TYPE dmbtr, lifnr TYPE lifnr, END OF ty_bsik. TYPES: BEGIN OF lifnr TYPE name1 TYPE END OF
ty_lfa1, lifnr, name1, ty_lfa1.
TYPES: BEGIN OF ty_final, lifnr TYPE lifnr, name1 TYPE name1, a30 TYPE dmbtr, a60 TYPE dmbtr, a90 TYPE dmbtr, a120 TYPE dmbtr, a150 TYPE dmbtr, a180 TYPE dmbtr, Rohini kumar
SAP-ABAP
346
ag180 TYPE dmbtr, total TYPE dmbtr, END OF ty_final. DATA n TYPE I. DATA: wa_lfa1 wa_bsik wa_bsik1 wa_final it_lfa1 it_bsik it_bsik1 it_final it_final1
TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE
ty_lfa1, ty_bsik, ty_bsik, ty_final, TABLE TABLE TABLE TABLE TABLE
OF OF OF OF OF
ty_lfa1, ty_bsik, ty_bsik, ty_final, ty_final.
DATA: wa_fcat TYPE SLIS_FIELDCAT_ALV, wa_layout TYPE SLIS_LAYOUT_ALV, it_fcat TYPE SLIS_T_FIELDCAT_ALV. ENDCLASS. CLASS cl_base IMPLEMENTATION. METHOD get_bsik. SELECT belnr bldat shkzg dmbtr lifnr FROM BSIK INTO TABLE it_bsik WHERE lifnr IN s_lifnr AND bukrs IN s_bukrs AND prctr IN s_prctr AND umskz IN s_umskz AND bldat < keydate. SELECT belnr bldat shkzg dmbtr lifnr FROM BSAK APPENDING TABLE it_bsik WHERE lifnr IN s_lifnr AND bukrs IN s_bukrs AND prctr IN s_prctr AND umskz IN s_umskz AND bldat < keydate AND augdt > keydate. IF NOT it_bsik IS INITIAL. SELECT lifnr name1 FROM LFA1 INTO TABLE it_lfa1 Rohini kumar
SAP-ABAP
FOR ALL ENTRIES IN it_bsik WHERE lifnr = it_bsik-lifnr. ENDIF. ENDMETHOD. METHOD combine_data. SORT it_bsik BY lifnr. LOOP AT it_lfa1 INTO wa_lfa1. LOOP AT it_bsik INTO wa_bsik WHERE lifnr = wa_lfa1-lifnr. IF wa_bsik-zhkzg = ‘H’. wa_bsik-dmbtr = (-1) * wa_bsik-dmbtr. ENDIF. n = keydate - wa_bsik-bldat. IF n = 0. CONTINUE. ENDIF. wa_final-a30 = wa_final-a30 + wa_bsik-dmbtr. ELSEIF n GT 30 AND n LE 60. wa_final-a60 = wa_final-a60 + wa_bsik-dmbtr. ELSEIF n GT 60 AND n LE 90. wa_final-a90 = wa_final-a90 + wa_bsik-dmbtr. ELSEIF n GT 90 AND n LE 120. wa_final-a120 = wa_final-a120 + wa_bsik-dmbtr. ELSEIF n GT 120 AND n LE 150. wa_final-a150 = wa_final-a150 + wa_bsik-dmbtr. ELSEIF n GT 150 AND n LE 180. wa_final-a180 = wa_final-a60 + wa_bsik-dmbtr. ELSEIF n GT 180 . wa_final-Ag180 = wa_final-ag180 + wa_bsik-dmbtr. ENDIF. ENDLOOP. Rohini kumar
347
SAP-ABAP
wa_final-total = wa_final-a30 + wa_final-a60 + wa_final-a90 + wa_final-120 + wa_final0150 + wa_final-a180 + wa_final-ag180. wa_final-lifnr = wa_lfa1-lifnr. wa_final-name1 = wa_lfa1-name1. APPEND wa_final TO it_final. CLEAR wa_final. ENDLOOP. ENDMETHOD. ENDCLASS. CLASS cl_derived DEFINITION INHERITING FROM cl_base. PUBLIC SECTION. METHODS: fill_cat, layout, display_data. ENDCLASS. CLASS cl_derived IMPLEMENTATION. METHOD fill_cat. wa_fcat-filename = ‘lifnr’. wa_fcat-key = ‘x’. wa_fcat-seltext_m = ‘vendor code’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘name1’. wa_fcat-key = ‘x’. wa_fcat-seltext_m = ‘vendor name’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘a30’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘0-30 days’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘a60’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘31-60 days’. APPEND wa_fcat TO it_fcat. Rohini kumar
348
SAP-ABAP
wa_fcat-filename = ‘a90’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘61-90 days’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘a120’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘91-120 days’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘a150’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘121-150 days’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘a180’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘151-180 days’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘ag180’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘> 180 days’. APPEND wa_fcat TO it_fcat. wa_fcat-filename = ‘total’. wa_fcat-do_sum = ‘x’. wa_fcat-seltext_m = ‘total amount’. APPEND wa_fcat TO it_fcat. ENDMETHOD. METHOD layout. wa_layout-zebra = ‘x’. wa_layout-colwidth_optimize = ‘x’. ENDMETHOD. METHOD display_data. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_CALLBACK_PROGRAM = ‘X’ IS_LAYOUT = wa_layout Rohini kumar
349
SAP-ABAP
IT_FIELDCAT = it_fcat I_SAVE = ‘X’ TABLES T_OUTTAB = it_final. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA obj TYPE REF TO cl_derived. CREATE OBJECT obj. CALL METHOD: obj->get_bsik, obj->combine_data, obj->fill_cat, obj->layout, obj->display_data.
Rohini kumar
350
SAP-ABAP
BSIT & BSAK Tables: BSIK holds open item data for vendor & BSAK holds cleared item data for customers Fields: 1. LIFNR ----------- vendor code 2. BUKRS ---------- company code 3. KUNNR --------- customer code 4. UMSKZ --------- special G/L indicator 5. ** ZUONR ------ assignment (or) bill number 6. GJAHR ---------- financial year 7. BELNR ---------- accounting document number 8. BUDAT --------- posting date 9. BLDAT --------- bill date 10.XBLNR --------- reference document number 11.BLART --------- document type 12.SHKZG --------- debit (s) / credit (h) indicator 13.**DMBTR ----- amount in local currency 14.HKONT -------- G/L amount 15.**ZFBDT ------ base line date for due date calculation 16.ZTERM -------- payment terms
Rohini kumar
351
SAP-ABAP
352
28-10-2014 Abstract Class: Abstract classes are cannot be implemented Objects cannot be created for abstract classes Abstract class methods are also abstract in nature Derived class can implement abstract class methods by redefining the methods of abstract class in derived class Requirement: Employee Salary & Attendance Details report Input: S_pernr --------- employee number S_persg -------- employee group S_persk -------- employee sub group S_abkrs -------- payroll area S_date --------- period Attendance (radio button) Salary (radio button) Output: For Attendance: Employee number Employee name Present Leaves Rest Holiday enjoyed For Salary: Employee number Employee name Date of birth Basic salary Da Hra Solution: Go to SE11 Create structure YHR_SAL with following fields Pernr Rohini kumar
SAP-ABAP
353
Ename Bsal Da Hra Create another structure YHR_ATTEN with following fields Pernr Ename Present El Rest He
Go to SE38 Program: ZHR_ATTEN_SAL_DETAILS Create Title: Employee salary & attendance details report Type: Executable Program Logical Database: PNP Enter Enter Activate program Back Attributes Change HR Report Category Master Data (info types): IE_P35L Enter Enter Source Code Change
TABLES: PERNR. INFOTYPES: 0002, 0008. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_pernr FOR pernr-pernr, s_date FOR pernr-dayps. SELECTION-SCREEN: END OF BLOCK b1. SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-001. Rohini kumar
SAP-ABAP
354
PARAMETERS: p_rb1 RADIOBUTTON GROUP rg1, p_rb2 RADIOBUTTON GROUP rg1. SELECTION-SCREEN: END OF BLOCK b2. DATA: p_betrg TYPE pad_amt7s, p_lgart TYPE lgart. CLASS cl_abstract DEFINITION ABSTRACT. PUBLIC SECTION. METHODS: get_emp ABSTRACT IMPORTING pernr TYPE person, display_data ABSTRACT. PROTECTED DATA: wa_sal wa_atten it_sal it_atten gwa_tim wa_ph wa_ab wa_tp rest present el wrk he
SECTION. TYPE yhr_sal, TYPE yhr_atten, TYPE TABLE OF yhr_sal, TYPE TABLE OF yhr_atten, TYPE hrf_tim_b2, TYPE ptr_f_psp, TYPE ptr_f_ab, TYPE ptr_f_tp, TYPE I, TYPE I, TYPE I, TYPE I, TYPE I.
ENDCLASS. CLASS cl_atten DEFINITION INHERITING FROM cl_abstract. PUBLIC SECTION. METHODS: get_emp REDEFINITION, display_data REDEFINITION. ENDCLASS. CLASS cl_atten IMPLEMENTATION. METHOD get_emp. CALL FUNCTION ‘HR_FORMS_TIM_GET_B2_RESULTS’ Rohini kumar
SAP-ABAP
355
EXPORTING Pernr = pernr Begda = s_date-low Endda = s_date-high IMPORTING Tim_b2 = gwa_tim. LOOP AT gwa_tim-ft_psp INTO wa_psp. IF wa_psp-ftkla EQ ‘1’. He = he + 1. ENDIF. Wrk = wrk + 1. IF wa_psp-trprog = ‘OFF’. Rest = rest + 1. ENDIF. ENDLOOP. LOOP AT gwa_tim-ft_ab INTO wa_ab. IF wa_ab-awart EQ ‘100’. el = el + 1. ENDIF. ENDLOOP. Present = wrk wa_atten-pernr wa_atten-ename wa_atten-present wa_atten-el wa_atten-rest wa_atten-he
(rest + el + he). = pernr. = p0002-nachn. = present. = el. = rest. = he.
APPEND wa_atten TO it_atten. CLEAR: rest, el, present, he, wrk, wa_atten. ENDMETHOD. METHOD display_data. CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’ Rohini kumar
SAP-ABAP
EXPORTING I_STRUCTURE_NAME = ‘YHR_ATTEN’ TABLES T_OUTTAB = it_atten. ENDMETHOD. ENDCLASS. CLASS cl_sal DEFINITION INHERITING FROM cl_abrstract. PUBLIC SECTION. METHODS: get_emp REDEFINITION, display_data REDEFINITION, calc_sal, hold_sal. ENDCLASS. CLASS cl_sal IMPLEMENTATION. METHOD get_emp. wa_sal-pernr = pernr. wa_sal-ename = p0002-nachn. ENDMETHOD. METHOD calc_sal. CASE p_lgart. WHEN ‘MA90’. wa_sal-bsal = p_betrg. WHEN ‘MA80’. wa_sal-da = p_betrg. WHEN ‘MA70’. wa_sal-hra = p_betrg. ENDCASE. ENDMETHOD. METHOD hold_sal. APPEND wa_sal TO it_sal. ENDMETHOD. METHOD display_data. CALL FUNCTION ‘REUSE_ALV_LIST_DISPALY’ Rohini kumar
356
SAP-ABAP
EXPORTING I_STRUCTURE_NAME = ‘YHR_SAL’ TABLES T_OUTTAB = it_sal. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA: obj TYPE REF TO cl_atten, obj1 TYPE REF TO cl_sal. IF p_rb1 EQ ‘X’. CREATE OBJECT obj. ELSE. CREATE OBJECT obj1. ENDIF. GET PERNR. CHECK pernr-pernr IN s_pernr. IF SY-SUBRC EQ 0. IF p_rb1 EQ ‘X’. CALL METHOD obj->get_emp EXPORTING Pernr = pernr-pernr. RP_PROVIDE_FROM_LAST P0008 SPACE ‘18000101’ ‘99991231’. (or) REFRESH P0008[ ]. CALL FUNCTION ‘HR_READ_INFOTYPE’ EXPORTING Pernr = pernr-pernr Infty = ‘0008’ Begda = ‘20020101’ Endda = ‘99991231’ TABLES Infty_tab = P0008[ ]. DO 30 TIMES VARING p_betrg FROM P0008-bet01 NEXT P0008-bet02 VARING p_lgart FROM P0008-lga01 NEXT P0008-lga02. Rohini kumar
357
SAP-ABAP
CALL METHOD obj1->calc_sal. ENDDO. CALL METHOD obj1->hold_sal. ENDIF. ENDIF. END-OF-SELECTION. IF p_rb1 EQ ‘X’. CALL METHOD obj->display_data. ELSE. CALL METHOD obj1->display_data. ENDIF.
Rohini kumar
358
SAP-ABAP
Assignment: Employee Family & Previous Employers Details Report Input: S_pernr S_persg S_abkrs Experience (radio button) Family (radio button) Output: Experience: Employee number Employee name Date of birth Previous experience Current experience Total experience Family: Employee number Employee name Father Mather Spouse Child1 Child2 Solution:
Rohini kumar
359
SAP-ABAP
Assignment: Employee Late Coming Report Input: S_pernr S_persg S_abkrs S_period Output: Employee number Employee name Department Date In time Late Solution:
Rohini kumar
360
SAP-ABAP
361
29-10-2014 Global Class: In global class CLASS DEFINITION & CLASS IMPLEMENTATION parts are maintained in Class Builder (SE24) & Execution part is maintained in ABAP Editor (SE38) Requirement: Asset Acquisition Date Report Input: Asset number Output: Asset number Sub asset number Acquisition date Tables: ANLA Solution: Step-1: creating Structure & Table Type Go to SE11 Data Type: ZFI_ASSET Create ** Structure Enter Short Description: Structure for Asset fields Component Component Type ANLN1 ANLN1 ANLN2 ANLN2 ZUGDT ZUGDT
Activate Back Data Type: ZFI_TAB Create ** Table Type Enter Short Description: Table Type for Asset ** Line Type: ZFI_ASSET Activate
Rohini kumar
SAP-ABAP
362
Step-2: creating class definition & class implementation parts Go to SE24 Object Type: ZCL_ASSET_CLASS Create Description: Asset Class Enter Enter Attributes tab Attribute level visibility associated type IT_ANLA INSTANCE PRIVATE ZFI_TAB A_LOW INSTANCE PRIVATE ANLN1 A_HIGH INSTANCE PRIVATE ANLN1 WA_FCAT INSTANCE PRIVATE SLIS_FIELDCAT_ALV WA_LAYOUT INSTANCE PRIVATE SLIS_LAYOUT_ALV IT_FCAT INSTANCE PRIVATE SLIS_T_FIELDCAT_ALV Methods tab Method level CONSTRUCTOR INSTANCE
visibility PUBLIC
Place cursor on constructor Parameters Parameter associated type ASSET_LOW ANLN1 ASSET_HIGH ANLN1
description importing parameter importing parameter
description default method
Methods Double click on CONSTRUCTOR Yes Place cursor between METHOD…………..ENDMETHOD A_LOW = ASSET_LOW. A_HIGH = ASSET_HIGH. Activate Back Method GET_DATA
level INSTANCE
visibility PUBLIC
description method for getting data
Double click on GET_DATA Yes Place cursor between METHOD…………..ENDMETHOD Rohini kumar
SAP-ABAP
363
SELECT anln1 anln2 zugdt FROM ANLA INTO TABLE it_anla WHERE anln1 BETWEEN a_low AND a_high. Activate Back Method GET_DATA
level INSTANCE
visibility PUBLIC
description method for getting data
Double click on GET_DATA Yes Place cursor between METHOD…………..ENDMETHOD SELECT anln1 anln2 zugdt FROM ANLA INTO TABLE it_anla WHERE anln1 BETWEEN a_low AND a_high. Activate Back Method LAYOUT
level INSTANCE
visibility PUBLIC
description method for layout management
Double click on LAYOUT Yes Place cursor between METHOD…………..ENDMETHOD WA_LAYOUT-ZEBRA = ‘X’. WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’. Activate Back Method FILL_CAT
level INSTANCE
visibility PUBLIC
description method for field catalogs
Double click on FILL_CAT Yes Place cursor between METHOD…………..ENDMETHOD WA_FCAT-FIELDNAME = ‘ANLN1’. WA_FCAT-SELTEXT_M = ‘Asset Number’. APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘ANLN2’. WA_FCAT-SELTEXT_M = ‘Sub Asset Number’. Rohini kumar
SAP-ABAP
364
APPEND WA_FCAT TO IT_FCAT. WA_FCAT-FIELDNAME = ‘ZUGDT’. WA_FCAT-SELTEXT_M = ‘Acquisition Date’. APPEND WA_FCAT TO IT_FCAT. Activate Back Method level DISPLAY_DATA INSTANCE
visibility PUBLIC
description method for displaying output list
Double click on DISPLAY_DATA Yes Place cursor between METHOD…………..ENDMETHOD CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’ EXPORTING IT_FIELDCAT = IT_FCAT IS_LAYOUT = WA_LAYOUT TABLES T_OUTTAB = IT_ANLA. Activate Back Activate Step-3: class execution part Go to SE38 Program: ZFI_ASSET_DETAILS Create Title: asset acquisition details Type: Executable Program Enter Enter TABLES: ANLA. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_anln1 FOR anal-anln1. SELECTION-SCREEN: END OF BLOCK b1. DATA obj TYPE REF TO ZCL_ASSET_CLASS. Rohini kumar
SAP-ABAP
Pattern ABAP object patterns Enter Create Object Instance: obj Class: ZCL_ASSET_CLASS Enter
Asset_low = s_anln1-low. Asset_high = s_anln1-high.
Pattern ABAP object patterns Enter Call Method Instance: obj Class: ZCL_ASSET_CLASS Method: get_data Enter
CALL METHOD: obj->get_data, obj->layout, obj->fill_cat, obj->display_data.
Activate Execute Provide input Execute
Rohini kumar
365
SAP-ABAP
30-10-2014 Constructor: Constructor is a default method in Object Oriented ABAP It is called automatically whenever object is created Use this method for initializing values in Object Oriented ABAP
Rohini kumar
366
SAP-ABAP
Assignment: Asset Register Report Input: S_anln1 S_bukrs Output: Asset number (anln1) Sub asset number (anln2) Company code (bukrs) Plant (werks) Capitalization date (aktlv) Asset description (txt50) Acquisition value (kansw) Accumulated depreciated (knafa) Asset location (start) Asset class (anlkl) Quantity (menge) Unit of measurement (meins) Currency (waers) Tables: ANLC ANLA ANLB T499S T093B Solution:
Rohini kumar
367
SAP-ABAP
Assignment: PR to GR Report Input: S_pr number S_pr date Output: Pr number Pr quantity Item text Vendor number Vendor name Material number Material description Po number Po quantity Gr number Gr quantity Pending pr Pending po Solution:
Rohini kumar
368
SAP-ABAP
369
Interface Functionality: It is a template which extends the scope of a class & implements polymorphism Instances cannot be created based on interface Interface methods are always implemented in other class Difference between Class & Interface: Interface 1. implements polymorphism 2. method of interface are implemented In public section of other class 3. instances cannot be create
Class 1. Cannot implement it 2. Method of a class implemented in class itself 3. Instances can be created
Requirement: Input: S_sales order Deliver (radio button) Invoice (radio button) Solution: Step-1: creating Structure & Table Type Go to SE11 Data Type: ZSD_LIKP Create ** Structure Enter Short Description: Structure for Delivery fields Component Component Type VBELN VBELN_VF LFDAT LFDAT MATNR MATNR LFIMG LFIMG Currency / Quantity Fields Reference Table Reference Field EKPO MEINS
Activate Back Data Type: ZSD_LIKPTAB Create ** Table Type Enter
Rohini kumar
SAP-ABAP
370
Short Description: Table Type for LIKP ** Line Type: ZSD_LIKP Activate Data Type: ZSD_VBRK Create ** Structure Enter Short Description: Structure for Invoice fields Component Component Type VBELN VBELN_VF FKDAT FKDAT MATNR MATNR MAKTX MAKTX FKIMG FKIMG NETWR NETWR Currency / Reference Table VBAP T001
Quantity Fields Reference Field VRKME WAERS
Activate Back Data Type: ZSD_VBRKTAB Create ** Table Type Enter Short Description: Table Type for VBRK ** Line Type: ZSD_VBRK Activate
Step-2: creating class definition & class implementation parts Go to SE24 Object Type: ZINT_DEL_INV Create ** Interface Description: interface Enter Enter Attributes tab Attribute level visibility associated type Rohini kumar
SAP-ABAP
WA_VBELN
371
INSTANCE
PUBLIC
VBELN
Methods tab Method level GET_DATA INSTANCE DISPLAY_DATE INSTANCE
visibility PUBLIC PUBLIC
description method for getting data method for displaying data
Place cursor on get_data Parameters Parameter type associated type P_VBELN importing VBELN
description importing parameter
Activate Back Object Type: ZCL-DEL_CLASS Create Description: Delivery class Enter Enter Attributes tab Attribute level visibility associated type IT_LIKP INSTANCE PRIVATE ZSD_LIKPTAB Interfaces Interface methods ZINT_DEL_INV
description
Methods Double click on GET_DATA Yes Place cursor between METHOD…………..ENDMETHOD
SELECT vbeln FROM VBFA INTO zint_del_inv~wa_vbeln WHERE vbelv = p_vbelv AND vbtyp_n = ‘J’. IF zint_del_inv~wa_vbeln IS NOT INITIAL. SELECT likp~vbeln likp~lfdat lips~matnr lips~lfimg INTO TABLE it_likp FROM LIKP INNER JOIN LIPS ON likp~vbeln = lips~vbeln WHERE likp~vbeln = zint_del_inv~wa_vbeln. Rohini kumar
SAP-ABAP
372
ENDIF. Activate Back Method level DISPLAY_DATA INSTANCE
visibility PUBLIC
description method for displaying output list
Double click on DISPLAY_DATA Yes Place cursor between METHOD…………..ENDMETHOD CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_STRUCTURE_NAME = ‘ZSD_LIKP’ TABLES T_OUTTAB = IT_LIKP. Activate Back Activate Object Type: ZCL-INV_CLASS Create Description: Invoice class Enter Enter Attributes tab Attribute level visibility associated type IT_VBRK INSTANCE PRIVATE ZSD_VBRKTAB Interfaces Interface methods ZINT_DEL_INV
description
Methods Double click on GET_DATA Yes Place cursor between METHOD…………..ENDMETHOD
SELECT vbeln FROM VBFA INTO zint_del_inv~wa_vbeln WHERE vbelv = p_vbelv AND vbtyp_n = ‘M’. Rohini kumar
SAP-ABAP
373
IF zint_del_inv~wa_vbeln IS NOT INITIAL. SELECT vbrk~vbeln vbrk~fkdat vbrp~matnr vbrp~arktx vbrp~fkimg vbrp~netwr INTO TABLE it_vbrk FROM VBRK INNER JOIN VBRP ON vbrk~vbeln = vbrp~vbeln WHERE vbrk~vbeln = zint_del_inv~wa_vbeln. ENDIF. Activate Back Method level DISPLAY_DATA INSTANCE
visibility PUBLIC
description method for displaying output list
Double click on DISPLAY_DATA Yes Place cursor between METHOD…………..ENDMETHOD CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_STRUCTURE_NAME = ‘ZSD_VBRK’ TABLES T_OUTTAB = IT_VBRK. Activate Back Activate Step-3: class execution part Go to SE38 Program: ZSD_DEL_BILLING_DETAILS Create Title: invoice details Type: Executable Program Enter Enter SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETERS p_order TYPE vbeln. SELECTION-SCREEN: END OF BLOCK b1. SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-001. Rohini kumar
SAP-ABAP
PARAMETERS: p_rb1 RADIOBUTTON GROUP rg1, p_rb2 RADIOBUTTON GROUP rg1. SELECTION-SCREEN: END OF BLOCK b2. DATA: obj1 TYPE REF TO ZCL_DEL_CLASS, obj2 TYPE REF TO ZCL_DEL_CLASS. CREATE OBJECT: obj1, obj2. IF p_rb1 EQ ‘X’. CALL METHOD obj1->zint_del_inv~get_data EXPORTING P_vbeln = p_order. CALL METHOD obj1->zint_del_inv~display_data. ELSE. CALL METHOD obj2->zint_del_inv~get_data EXPORTING P_vbeln = p_order. CALL METHOD obj2->zint_del_inv~display_data. ENDIF.
Activate Execute Provide input Execute
Rohini kumar
374
SAP-ABAP
31-10-2014 Alias: Go to SE24 Object Type: ZCL_DEL_CLASS Change Aliases Method alias name Zint_del_inv~get_data sel1 Zint_del_inv~display_data sel
Activate Go to SE38 Program: ZSD_DEL_BILLING_DETAILS Change
Rohini kumar
375
visibility public public
SAP-ABAP
376
PP Module: Production & Planning Module Master Data for PP Module: 1. BOM (Bills of Materails) 2. Routing 3. Work Center BOM: Every main material is having sub components (sub materials) called BOM Costing department should calculate main material cost as well as sub material cost also T Codes: CS01, CS02, CS03 Tables: MAST, STOP, STKO Key Field: Stlnr Routing: These are the sequence of operations performed on a material in order to manufacture it T Codes: CA01, CA02, CA03 Tables: PLKO, PLPO, PLMZ Work Center: It is a place where operations are carried out T Codes: CR01, CR02, CR03 Tables: CRHD Production Order: In order to produce finished goods sales department have to give (or) raise production order to production department Rohini kumar
SAP-ABAP
377
T Codes: CO01, CO02, CO03, COLLN Tables: AFKO, AFPO, AFRU Key Field: Aufnr Types of Planning: 1. MRP (Material Requirement Planning) 2. Demand 3. Sales & Operations 4. Capacity Process Flow: Customers
Marketing
Production Planning
production department
Vendor
produce goods
Rohini kumar
inventory (or) ware house
SAP-ABAP
378
Event Functionality: In Object Oriented ABAP events will trigger & at the same time respective method will be executed In Object Oriented ABAP every event is having Event Handler (Method) which is executed whenever the event is fired Syntax for Calling Event Handler: SET HANDLER -> FOR . Requirement: Production Details based on Production Order Input: P_furnance P_plant S_posting date Output: Purchase order number Posting date Production start date Production end date Material number Production quantity Solution: Step-1: creating Structure & Table Type Go to SE11 Data Type: ZPP_AFRU Create ** Structure Enter Short Description: Structure for Order fields Component Component Type AUFNR AUFNR BUDAT BUDAT LMNGA RU_LMNGA Currency / Quantity Fields Reference Table Reference Field EKPO MEINS Rohini kumar
SAP-ABAP
Activate Back Data Type: ZPP_AFRUTAB Create ** Table Type Enter Short Description: Table Type for AFRU ** Line Type: ZPP_AFRU Activate Back
Data Type: ZPP_AFKO Create ** Structure Enter Short Description: Structure for AFKO fields Component Component Type AUFNR AUFNR GSTRI CO_GSTRI GLTRI CO_GLTRI PLNBEZ MATNR
Activate Back Data Type: ZPP_AFKOTAB Create ** Table Type Enter Short Description: Table Type for AFKO ** Line Type: ZPP_AFKO Activate Back
Data Type: ZPP_FINAL Create ** Structure Enter Short Description: Structure for FINAL fields Component Component Type AUFNR AUFNR BUDAT BUDAT GSTRI CO_GSTRI Rohini kumar
379
SAP-ABAP
GLTRI PLNBEZ LMNGA
380
CO_GLTRI MATNR RU_LMNGA
Currency / Quantity Fields Reference Table Reference Field EKPO MEINS
Activate Back Data Type: ZPP_FINALTAB Create ** Table Type Enter Short Description: Table Type for FINAL ** Line Type: ZPP_FINAL Activate Back
Step-2: creating class definition & class implementation parts Go to SE24 Object Type: ZINT_PROD_CLASS Create Description: class for production details Enter Attributes tab Attribute level visibility associated type WA_AFRU INSTANCE PRIVATE ZPP_AFRU WA_AFKO INSTANCE PRIVATE ZPP_AFKO WA_FINAL INSTANCE PRIVATE ZPP_FINAL IT_AFRU INSTANCE PRIVATE ZPP_AFRUTAB IT_AFKO INSTANCE PRIVATE ZPP_AFKOTAB IT_FINAL INSTANCE PRIVATE ZPP_FINALTAB WA_LAYOUT INSTANCE PRIVATE SLIS_LAYOUT_ALV Events tab Event level CHECK_DATA INSTANCE
visibility PUBLIC
Description checking data
Methods tab Method level NO_DATA INSTANCE
visibility PUBLIC
description method for event
Rohini kumar
SAP-ABAP
381
*** Detail View Event Handler For (check it) Class / Interface: ZCL_PROD_CLASS Event: CHECK_DATA Enter
Method GET_AFRU
level INSTANCE
visibility PUBLIC
description getting afru data
Place cursor on GET_AFRU Parameters Parameter type associated type P_RASCH importing RUEARSCHLU P_WERKS importing WERKS_D BUDAT_LOW importing BUDAT BUDAT_HIGH importing BUDAT
description importing parameter importing parameter importing parameter importing parameter
Methods Double click on GET_AFRU Yes Place cursor between METHOD………..ENDMETHOD
SELECT afru~aufnr afru~budat afru~lmnga INTO TABLE it_afru FROM AFRU INNER JOIN CRHD ON afru~arbid = crhd~objid WHERE chrd~rasch = p_rasch AND chrd~weks = p_werks AND afru~budat BETWEEN budat_low AND budat_high. IF SU-SUBRC NE 0. RAISE EVENT CHECK_DATA.\ ENDIF.
Activate Back Double click on NO_DATA Place cursor between METHOD………..ENDMETHOD
MESSAGE S000(RGS) WITH ‘No data found’. Activate Back Rohini kumar
SAP-ABAP
Method GET_AFKO
382
level INSTANCE
visibility PUBLIC
description method for getting afko data
Double click on GET_AFKO Yes Place cursor between METHOD…………..ENDMETHOD IF IS NOT it_afru INITIAL. SELECT aufnr gstri gltri plnbez INTO it_afko FROM AFKO FOR ALL ENTRIES IN it_afru WHERE aufnr = it_afru-aufnr. ENDIF. Activate Back Method COMBINE_DATA
level INSTANCE
visibility PUBLIC
description method for combining data
Double click on COMBINE_DATA Yes Place cursor between METHOD…………..ENDMETHOD LOOP AT it_afru INTO wa_afru. wa_final-aufnr = wa_afru-aufnr. wa_final-budat = wa_afru-budat. wa_final-lmnga = wa_afru-lmnga. READ TABLE it_afko INTO wa_afko WITH KEY aufnr = wa_afru-aufnr. wa_final-gstri = wa_afko-gstri. wa_final-gltri = wa_afko-gltri. wa_final-plnrez = wa_afko-plnrez. APPEND wa_final TO it_final. ENDLOOP. Activate Back Method LAYOUT Rohini kumar
level INSTANCE
visibility PUBLIC
description method for layout management
SAP-ABAP
383
Double click on LAYOUT Yes Place cursor between METHOD…………..ENDMETHOD WA_LAYOUT-ZEBRA = ‘X’. WA_LAYOUT-COWIDTH_OPTIMIZE = ‘X’. Activate Back Method DISPLAY_DATA
level INSTANCE
visibility PUBLIC
description method for displaying data
Double click on DISPLAY_DATA Yes Place cursor between METHOD…………..ENDMETHOD CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’ EXPORTING I_STRUCTURE_NAME = ‘ZPP_FINAL’ IS_LAYOUT = WA_LAYOUT TABLES T_OUTTAB = ZPP_FINALTAB Activate Back Activate Step-3: class execution part Go to SE38 Program: ZPP_PRODUCTION_DETAILS Create Title: production details Type: Executable Program Enter Enter TABLES AFRU. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETERS: p_rasch TYPE ruearschlu, p_werks TYPE werks_D. Rohini kumar
SAP-ABAP
384
SELECTION-SCREEN: END
OF BLOCK b1.
DATA: obj TYPE REF TO ZCL_PROD_CLASS. CREATE OBJECT
obj.
SET HANDLER obj->no_data obj. CALL METHOD obj->get_afru EXPORTING P_rasch = p_rasch P_werks = p_werks Budat_low = s_budat-low Budat_high = s_budat-high. CALL METHOD: obj->get_afko, obj->combine_data, obj->layout, obj->display_data. Activate Execute Provide input Execute
Rohini kumar
SAP-ABAP
385
Exception Class: In real time you will find number of exceptions (Run time errors) such as 1. Time out exception 2. SQL statement exception 3. Division by zero exception 4. No convert number exception 5. Type conflict exception 6. BCD overflow exception 7. *** Storage exception for internal table For all the above exceptions SAP is providing standard exception classes Exception class starting with prefix ‘CX’ These exception classes should be provided with in TRY……………ENDTRY using CATCH keyword Example: DATA: v1 TYPE I VALUE 0, v2 TYPE I, v3 TYPE I. TRY. v3 = v1 / v2. CATCH CX_SY_ZERODIVIDE. MESSAGE ‘Division by zero exception’ TYPE I. ENDTRY.
Rohini kumar
SAP-ABAP
386
ALV Object Oriented Programming: SLV SAP List Viewer It is advance to ALVs In OOALV we should work with Custom Control (List Viewer Control) In ALVs you cannot perform advanced operations such as 1. Maintaining buttons 2. Exception coding 3. Hyperlinks …………………..etc All these features are maintained by using a control called List Viewer Control SLV is totally based on Object Oriented Programming 01-11-2014 Custom Control:
------------ screen 100
----------------- custom control (container)
Steps in Custom Control: Step-1: Identify location of control using class CL_GUI_CUSTOM_CONTAINER Step-2: Display control in the location identified using class CL_GUI_AVL_GRID Step-3: Display data in the control using method SET_TABLE_FOR_FIRST_DISPLAY of CL_GUI_GRID class
Rohini kumar
SAP-ABAP
387
Requirement: Report for Quality Notifications Input: S_date Output: Notification number Complaint text Date Material code Solution: Go to SE38 Program: ZQM_QUALITY_NOTIF Create Title: Quality Notifications Type: Executable Program Enter Enter TABLES QMEL. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_erdat FOR qmel-erdat. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_qmel, qmnum TYPE qmnum, qmtxt TYPE qmtxt, erdat TYPE erdat, matnr TYPE matnr, END OF ty_qmel. DATA: it_qmel TYPE TABLE OF ty_qmel. DATA: wa_fcat TYPE lvc_s_fcat, wa_layo TYPE lvc_s_layo, it_fcat TYPE lvc_t_fcat. * defining objects for custom conrol DATA: container TYPE REF TO CL_GUI_CUSTOM_CONTAINER, Rohini kumar
SAP-ABAP
grid TYPE REF TO CL_GUI_ALV_GRID. PERFORM get_qmel. PERFORM layout. PERFORM fill_cat. CALL SCREEN 100. FORM get_qmel. SELECT qmnum qmtxt erdat matnr FROM QMEL INTO TABLE it_qmel WHERE erdat IN s_erdat. ENDFORM. FORM layout. WA_LAYO-ZEBRA = ‘X’. WA_LAYO-CWIDTH_OPT = ‘X’. ENDFORM. FORM fill_cat. wa_fcat-fieldname = ‘QMNUM’. wa_fcat-scrtext_m = ‘Notification Number’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘QMTXT’. wa_fcat-scrtext_m = ‘Complaint Text’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘ERDAT’. wa_fcat-scrtext_m = ‘Date’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘MATNR’. wa_fcat-scrtext_m = ‘Material Number’. APPEND wa_fcat TO it_fcat. ENDFORM.
Activate Double click on 100 Yes Short Description: Screen 100 Layout Place Custom Control on the screen
Rohini kumar
388
SAP-ABAP
Double click on Custom Control name: container Close Flow Logic Remove comment for MODULE STATUS_100 Double click on STATUS_100 Yes Main Program Enter Place cursor between MODULE…………ENDMODULE of STATUS_100 CREATE OBJECT container EXPORTING CONTAINER_NAME = ‘container’. IF SY-SUBRC EQ 0. CREATE OBJECT grid EXPORTING I_PARENT = container. IF SY-SUBRC EQ 0. CALL METHOD grid->set_table_for_first_display EXPORTING IS_LAYOUT = wa_layo CHANGING IT_FIELDCATALOG = it_fcat IT_OUTTAB = it_qmel. ENDIF. ENDIF. Activate Back
Remove comment for SET PF_STATUS ‘BACK’. Double click on BACK Yes Expand Function Key Provide BACK Activate Back
Remove comment for MODULE USER_COMMAND_100. Rohini kumar
389
SAP-ABAP
Double click on USER_COMMAND_100 Yes Main Program Enter
CASE SY-UCOMM. WHEN ‘BACK’. LEAVE TO SCREEN 0. ENDCASE.
Activate Back Activate Back Execute Provide input Execute
Rohini kumar
390
SAP-ABAP
391
Assignment: Packing cost material report using interactive functionality with 2 custom controls Input: S_matnr S_werks Output: Material code BOM component Material description BOM component description BOM quantity Amount Interactive Logic: If I double click on any material I should switch to MM03 along with material code Solution: ZPP_BOM_DETAILS TYPE-POOLS SLIS. TABLES: MAST, STAS, STOP, MAKT, MBEW. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_matnr FOR mast-matnr, s_werks FOR mast-werks. SELECTION-SCREEN: END OF BLOCK b1. * declaring objects for custom control DATA: container TYPE REF TO container1 TYPE REF TO l_tree TYPE REF TO grid TYPE REF TO DATA: n(5) header(100) wa_header it_header
Rohini kumar
TYPE TYPE TYPE TYPE
CL_GUI_CUSTOM_CONTAINER, CL_GUI_CUSTOM_CONTAINER, CL_GUI_ALV_TREE_SIMPLE, CL_GUI_ALV_GRID.
C, C, SLIS_LISTHEADER, SLIS_T_LISTHEADER.
SAP-ABAP
392
TYPES: BEGIN OF ty_mast, matnr TYPE matnr, stlnr TYPE stnum, stlal TYPE stlal, END OF ty_mast. TYPES: BEGIN OF ty_stas, stlnr TYPE stnum, stlal TYPE stlal, stlkn TYPE stlkn, END OF ty_stas. TYPES: BEGIN OF ty_stpo, stlnr TYPE stnum, idnrk TYPE idnrk, menge TYPE menge_D, END OF ty_stpo. TYPES: BEGIN OF ty_makt, matnr TYPE matnr, maktx TYPE maktx, END OF ty_makt. TYPES: BEGIN OF ty_mbew, matnr TYPE matnr, verpr TYPE verpr, END OF ty_mbew. DATA: wa_mast wa_makt wa_makt1 wa_stpo wa_mbew it_mast it_makt it_makt1 it_stas it_mbew
TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE
ty_mast, ty_makt, ty_makt, ty_stpo, ty_mbew, TABLE OF TABLE OF TABLE OF TABLE OF TABLE OF
TYPES: BEGIN OF ty_final, matnr TYPE matnr, maktx TYPE maktx, Rohini kumar
ty_mast, ty_makt, ty_makt, ty_stas, ty_mbew.
SAP-ABAP
393
idnrk TYPE idnrk, maktx1 TYPE maktx, menge TYPE menge_D, verpr TYPE verpr, END OF ty_final. DATA: wa_final TYPE ty_final, it_final TYPE TABLE OF ty_final. DATA: WA_FCAT WA_LAYO WA_SORT IT_SORT IT_FCAT
TYPE TYPE TYPE TYPE TYPE
LVC_S_FCAT, LVC_S_LAYO, LVC_S_SORT, LVC_T_SORT, LVC_T_FCAT.
CLASS cl_click DEFINITION. PUBLIC SECTION. METHODS: click FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING e_row. ENDCLASS. CLASS cl_click IMPLEMENTATION. METHOD click. READ TABLE it_final INTO wa_final INDEX e_row. SET PARAMETER ID ‘MAT’ FIELD wa_final-idnrk. CALL TRANSACTION ‘MM03’ AND SKIP FIRST SCREEN. END METHOD. END CLASS. START-OF-SELECTION. PERFORM get_mast. PERFORM get_stas. PERFORM get_stpo. PERFORM get_makt. PERFORM get_mbew. PERFORM combine_data. PERFORM sort. PERFORM layout. Rohini kumar
SAP-ABAP
PERFORM fill_cat. CALL SCREEN 100. FORM get_mast. SELECT matnr stlnr stlal FROM MAST INTO TABLE it_mast WHERE matnr IN s_matnr AND werks IN s_werks. ENDFORM. FORM get_stas. IF NOT it_mast IS INITIAL. SELECT stlnr stlal stlkn FROM STAS INTO TABLE it_stas FOR ALL ENTRIES IN it_mast WHERE stlnr = it_mast-stlnr AND stlty EQ ‘M’. ENDIF. ENDFORM. FORM get_stpo. IF NOT it_stas IS INITIAL. SELECT stlnr ldnrk menge FROM STOP INTO TABLE it_stpo FOR ALL ENTRIES IN it_stas WHERE stlnr = it_stas-stlnr AND stlkn = it_stas-stlkn AND stlty EQ ‘M’. ENDIF. ENDFORM. FORM get_makt. IF NOT it_mast IS INITIAL. SELECT matnr maktx FROM MAKT INTO TABLE it_makt FOR ALL ENTRIES IN it_mast WHERE matnr = it_mast-matnr AND spras EQ ‘EN’. ENDIF. IF NOT it_stpo IS INITIAL. SELECT matnr maktx FROM MAKT INTO TABLE it_makt1 FOR ALL ENTRIES IN it_stpo WHERE matnr = it_stpo-idnrk AND spras EQ ‘EN’. ENDIF. Rohini kumar
394
SAP-ABAP
ENDFORM. FORM get_mbew. IF NOT it_stpo IS INITIAL. SELECT matnr verpr FROM MBEW INTO TABLE it_mbew FOR ALL ENTRIES IN it_stpo WHERE matnr = it_stpo-ldnrk. ENDIF. ENDFORM. FORM combine_data. LOOP AT it_mast INTO wa_mast. LOOP AT it_stpo INTO wa_stpo WHERE stlnr = wa_mast-stlnr. wa_final-matnr = wa_mast-matnr. READ TABLE it_makt INTO wa_makt WITH KEY matnr = wa_mast-matnr. wa_final-maktx = wa_makt-maktx. wa_final-idnrk = wa_stpo-idnrk. READ TABLE it_makt1 INTO wa_makt WITH KEY matnr = wa_stpo-idnrk. wa_final-maktx1 = wa_makt-maktx. wa_final-menge = wa_stpo-menge. READ TABLE it_mbew INTO wa_mbew WITH KEY matnr = wa_stpo-idnrk. wa_final-verpr = wa_mbew-verpr. APPEND wa_final TO it_final. ENDLOOP. ENDFORM. FORM fill_cat. wa_fcat-fieldname = ‘MATNR’. wa_fcat-seltext_m = ‘Material Code’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘MAKTX’. wa_fcat-seltext_m = ‘Material Description’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘IDNRK’. Rohini kumar
395
SAP-ABAP
wa_fcat-seltext_m = ‘BOM Component’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘MAKTX1’. wa_fcat-seltext_m = ‘BOM Component Description’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘MENGE’. wa_fcat-seltext_m = ‘Quantity’. wa_fcat-do_sum = ‘X’. APPEND wa_fcat TO it_fcat. wa_fcat-fieldname = ‘VERPR’. wa_fcat-seltext_m = ‘Amount’. wa_fcat-do_sum = ‘X’. APPEND wa_fcat TO it_fcat. ENDFORM. FORM sort. wa_sort-fieldname = ‘MATNR’. wa_sort-up = ‘X’. wa_sort-subtot = ‘X’. APPEND wa_sort TO it_sort. ENDFORM. FORM layout. wa_layout-zebra = ‘X’. wa_layout-colwidth_optimize = ‘X’. ENDFORM.
Double click 100 Yes Short Description: Screen 100 Layout Design screen as per requirement Layout Remove comment for MODULE STATUS_100 OUTPUT Double click on STATUS_100 Yes Main Program Enter
Rohini kumar
396
SAP-ABAP
Place cursor between MODULE…………..ENDMODULE wa_header-typ = ‘H’. wa_header-info = ‘Reddy Labs’. APPEND wa_header TO it_header. DESCRIBE TABLE it_final LINES n. CONCATENATE ‘Number of Records’ n INTO header SAPARATED BY ‘:’ wa_header-typ = ‘S’. wa_header-info = header. APPEND wa_header TO it_header. CREATE OBJECT container1 EXPORTING CONTAINER_NAME = ‘container1’. CREATE OBJECT l_tree EXPORTING I_PARENT = ‘container1’. CALL METHOD l_tree->create_report_header EXPORTING CONTAINER_NAME = ‘container’. IF SY-SUBRC NE 0. CREATE OBJECT grid EXPORTING I_PARENT = container. IF SY-SUBRC EQ 0. CALL METHOD grid->set_table_for_first_display EXPORTING I_SAVE = ‘X’ IS_LAYOUT = wa_layout CHANGING IT_OUTTAB = it_final IT_FIELDCATALOG = it_fcat IT_SORT = it_sort. DATA obj TYPE REF TO CL_CLICK. Rohini kumar
397
SAP-ABAP
CREATE OBJECT obj. SET HANDLER obj->click FOR grid. ENDIF. ENDIF. ENDMODULE.
Remove comment for MODULE USER_COMMAND_100 INPUT. Double click on COMMAND_100 Yes Main Program Enter Place cursor between MODULE…………..ENDMODULE
CASE SY-UCOMM. WHEN ‘&F03’. LEAVE TO SCREEN 0. ENDCASE.
Rohini kumar
398
SAP-ABAP
03-11-2014 MAST Table: It holds material header data Fields: 1. MATNR ------------ material number 2. WERKS ------------ plant 3. STLAN ------------- BOM usage 4. STLAL ------------- alternate BOM 5. STLNR ------------- BOM number STAS Table: It holds items in BOM Fields: 1. STLTY ------------ BOM category 2. STLNR ------------ BOM number 3. STLAL ------------ alternate BOM 4. STLKN ----------- BOM item number STPO Table: It holds BOM item data Fields: 1. STLTY ------------ BOM category 2. STLNR ------------ BOM number 3. STLKN ----------- BOM item number 4. IDNRK ----------- BOM component (MATNR) 5. MENGE --------- quantity 6. MEINS ---------- unit of measurement MBEW Table: It holds material valuation data Fields: 1. MATNR ---------- material number 2. BWKEY ---------- plant 3. LBKUM ---------- total stock 4. SALK3 ----------- total value 5. VERPR ---------- moving average price
Rohini kumar
399
SAP-ABAP
400
Exception Coding: Using Exception coding you can display color in ALV OOPs For displaying color you can add a field called exception using standard field EXCPFNAME which is part of LVC_S_LAYO Requirement: Open Sales Order Report The sales orders for which delivery is partially done are called open sales orders In some companies delivery (or) invoice is done for more quantity then given in sales order Such sales orders are opening nature Input: S_kunnr S_vbeln ------- sales order number P_werks S_erdat Output: Sales order number Sales order date Customer number Customer name Sale order quantity Delivery quantity Invoice quantity Open quantity Solution: ZSD_OPEN_SALESORDER_REPORT
Rohini kumar
SAP-ABAP
Button Functionality: Using this functionality you can add additional buttons on ALV tool bar Requirement: Employee Allowances Report Input: S_pernr --------- employee number S_persg --------- employee group S_abkrs --------- payroll area S_persk --------- employee sub group Output: Check box Employee number Date of birth Date of joining Medical allowance CA (Canteen Allowance) LTA (Leave Travelling Allowance) INSERT (button) SELECT ALL (button) DESELECT ALL (button) Solution: Step-1: Go to SE11 Database Table: ZHR_TAB_ALLOW Create Short Description: Table for allowances Field Data Element MANDT MANDT SEL CHAR1 PERNR PERSNO GBDAT GBDAT DOJ ZEMPDOJ MEDICAL ZMEDICAL LAT ZLTA CA ZCA Activate Back Rohini kumar
401
SAP-ABAP
402
Step-2: Go to SE38 Program: ZHR_EMPLOYEE_ALLOWANCE_REPORT Create Title: employee allowance report using button functionality Type: Executable Program Enter Enter TABLES PERNR. INFO TYPES: 0001, 0002. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_pernr FOR pernr-pernr, s_persg FOR pernr-persg, s_abkrs FOR pernr-abkrs, s_persk FOR pernr-persk. SELECTION-SCREEN: END OF BLOCK b1. DATA: container TYPE REF TO CL_GUI_CUSTOM_CONTAINER, grid TYPE REF TO CL_GUI_ALV_GRID. DATA: wa_button wa_layo wa_fcat it_fcat
TYPE TYPE TYPE TYPE
STB_BUTTON, LVC_S_LAYO, LVC_S_FCAT, LVC_T_FCAT.
DATA: wa_allow TYPE ZHR_TAB_ALLOW, it_allow TYPE TABLE OF ZHR_TAB_ALLOW. CLASS cl_button DEFINITION. PUBLIC SECTION. METHODS: tool FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING e_object e_interactive, command FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING e_ucomm. ENDCLASS.
Rohini kumar
SAP-ABAP
CLASS cl_button IMPLEMENTATION. METHOD tool. wa_button-function = ‘INSERT’. wa_button-text = ‘Insert’. APPEND wa_button TO e_object->mt_toolbar. wa_button-function = ‘SAL’. wa_button-text = ‘Select All’. APPEND wa_button TO e_object->mt_toolbar. wa_button-function = ‘DALL’. wa_button-text = ‘Deselect All’. APPEND wa_button TO e_object->mt_toolbar. ENDMETHOD. METHOD command. CASE e_ucomm. WHEN ‘INSERT’. LOOP AT it_allow INTO wa_allow WHERE sel = ‘X’. MODIFY ZHR_TAB_ALLOW FROM wa_allow. ENDLOOP. WHEN ‘SALL’. LOOP AT it_allow INTO wa_allow. wa_allow-sel = ‘X’. MODIFY it_allow FROM wa_allow TRANSPORING sel. ENDLOOP. WHEN ‘DALL’. LOOP AT it_allow INTO wa_allow. wa_allow-sel = ‘ ’. MODIFY it_allow FROM wa_allow TRANSPORING sel. ENDLOOP. ENDCASE. CALL METHOD grid->refresh_table_display. ENDMETHOD. Rohini kumar
403
SAP-ABAP
404
ENDCLASS. START-OF-SELECTION. GET PERNR. CHECK pernr-pernr IN AND pernr-persg IN AND pernr-persk IN AND pernr-abkrs IN
s_pernr s_persg s_persk s_abkrs.
IF SY-SUBRC EQ 0. PERFORM get_emp. ENDIF. END-OF-SELECTION. PERFORM layout. PERFORM fill_cat. CALL SCREEN 100. FORM get_emp. wa_allow-pernr = pernr-pernr. wa_allow-gbdat = pernr-gbdat. CALL FUNCTION ‘RP_GET_HIRE_DATE’ EXPORTING PERSNR = pernr-pernr CHECK_INFOTYPES = ‘0001’ IMPORTING HIREDATE = wa_allow-doj. APPEND wa_allow TO it_allow. CLEAR wa_allow. ENDFORM. FORM layout. wa_layo-zebra = ‘X’. wa_layo-cwidth_opt = ‘X’. ENDFORM.
Rohini kumar
SAP-ABAP
FORM fill_cat. wa_fcat-fieldname = ‘SEL’. wa_fcat-scrtext_m = ‘Check’. wa_fcat-checkbox = ‘X’. wa_fcat-edit = ‘X’. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. wa_fcat-fieldname = ‘PERNR’. wa_fcat-scrtext_m = ‘Employee Number’. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. wa_fcat-fieldname = ‘GBDAT’. wa_fcat-scrtext_m = ‘Date of Birth’. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. wa_fcat-fieldname = ‘DOJ’. wa_fcat-scrtext_m = ‘Date of Joining’. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. wa_fcat-fieldname = ‘MEDICAL’. wa_fcat-scrtext_m = ‘Medical Allowance’. wa_fcat-edit = ‘X’. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. wa_fcat-fieldname = ‘LTA’. wa_fcat-scrtext_m = ‘Leave Travelling Allowance’. wa_fcat-edit = ‘X’. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. wa_fcat-fieldname = ‘CA’. wa_fcat-scrtext_m = ‘Canteen Allowance’. wa_fcat-edit = ‘X’. APPEND wa_fcat TO it_fcat. CLEAR wa_fcat. ENDFORM. Rohini kumar
405
SAP-ABAP
Double click on 100 Yes Short Description: Screen 100 Layout Design screen as per your requirement Flow Logic Remove comment for MODULE STATUS_100 OUTPUT. Double click on STATUS_100 Place cursor between MODULE…………….ENDMODULE
SET PF_STATUS ‘BACK’. CREATE OBJECT container EXPORTING CONTAINER_NAME = ‘container’. IF SY-SUBRC EQ 0. CREATE OBJECT grid EXPORTING I_PARENT = container. IF SY-SUBRC EQ 0. CALL METHOD grid->set_table_for_first_display EXPORTING IS_LAYOUT = wa_layo CHANGING IT_FIELDCATALOG = it_fcat IT_OUTTAB = it_allow. DATA obj TYPE REF TO CL_BUTTON. CREATE OBJECT obj. SET HANDLER: obj->tool FOR grid, obj->command FOR grid. CALL METHOD grid->set_toolbar_interactive. ENDIF. ENDIF. ENDMODULE. Rohini kumar
406
SAP-ABAP
Remove comment for MODULE USER_COMMAND_100 INPUT. Double click on USER_COMMAND_100 Place cursor between MODULE…………….ENDMODULE CASE SY-UCOMM. WHEN ‘BACK’. LEAVE TO SCREEN 0. ENDCASE. 04-11-2014 Syntax for Declaring Event Handler: METHODS: FOR EVENT OF IMPORTING ……………….. Note: E_object is an instance created based on standard class CL_ALV_EVENT_TOOLBAR_SET The respective class is having an attribute MT_TOOLBAR (Table Type)
Rohini kumar
407
SAP-ABAP
408
Hyperlinks Functionality: Using hyperlink functionality you can switch to respective hyperlink based on specific URL address SAP is providing a structure LVC_S_HYPE which is having fields 1. HANDLE (integer) 2. HREF (url) Requirement: Vendor hyperlinks report Input: S_erdat Output: Vendor number Vendor name Hyperlink Logic: When you click on vendor number we have to switch particular web address Solution: ZMM_VENDOR_LINKS
Rohini kumar
SAP-ABAP
409
Questions & Answers:
Module Pool Programming: Ques-1: Suppose in table control when I entered few records then I selected ‘Enter’ option, I found that the records are completely vanished from table control. Why it happens & What logic you will write to avoid problem? Ans: When you select ‘Enter’ control will moves from screen to program In program there is no logic provided for storing the table control data in internal table So nothing is transferred back to table control screen So it looks like empty Logic: MODIFY it_demo FROM zmm_demo INDEX vcontrol-current_line. IF SY-SUBRC NE 0. APPEND zmm_demo TO it_demo. ENDIF. Ques-2: In table control how you can perform auto calculations whenever ‘Enter’ key selected? Ans: Remove comment for SET PF_STATUS. Under MODULE STATUS_100 ‘xxxxxxxxx’. Remove ‘xxxxxxxxxx’ provide ’BACK’. Yes Yes Short Text: BACK Enter Expand function keys option _/ ENTER Activate You will find a pop-up, Enter Function Text: Enter Enter Back (F3) Activate program
Rohini kumar
SAP-ABAP
410
Ques-3: What is the difference between SSCRFIELDS-UCOMM & SY-UCOMM? Ans: SSCRFIELDS is a structure for maintaining text for the buttons in SELECTIONSCREEN SSCRFIELDS-UCOMM returns FCT code for buttons maintained in SELECTIONSCREEN SY-UCOMM returns FCT code for buttons maintained in SCREEN SY-UCOMM will works for both Screen & Selection-screen
Rohini kumar
SAP-ABAP
411
Reports: Ques-1: Suppose there are 20 pages in my report. How many times INITIALIZATION will triggers & TOP-OF-PAGE will triggers? Ans: INITIALIZATION will triggers only 1 time TOP-OF-PAGE will triggers 20 times Ques-2: What is LOAD-OF-PROGRAM event? Ans: This event will triggers before INITIALIZATION & once your program is loaded into memory Ques-3: What is the flow of events? Ans:
INITIALIZATION AT SELECTION-SCREEN OUTPUT START-OF-SELECTION END-OF-SELECTION TOP-OF-PAGE END-OF-PAGE
Ques-4: What do you mean by restricted & unrestricted stock? Ans: The stock which is produced by production department & it is in Quality check (or) it is in hold (or) stock returns is called restricted stock The stock which is ready for sale is called unrestricted stock *** Ques-5: This report is already provided by SAP (MMB). Then why you created it? Ans: MMB is providing materials details plant wise & storage location wise material by material My client gave a requirement for viewing all restricted & unrestricted stock at one time
Rohini kumar
SAP-ABAP
412
*** Ques-6: Explain procedure of working with Hierarchal ALVs? Answer: In Hierarchal Sequential ALVs we have to create 2 internal tables One for Header data (it_final1) & another for Item data (it_final) Both these internal tables should have a common field called KEY field In Header internal table the Key field should be unique In Item internal table the Key field should having number of items based on that unique key Pass these two internal tables to a function module called REUSE_ALV_HIERSEQ_LIST_DISPLAY
Rohini kumar
SAP-ABAP
413
FAQS IN REPORTS 1.) What is the purpose of reports in real time? Ans: In real time ABAP Reports are designed for analysis & based on the that analysis decision making will done 2.) What are the three mandatory details for generating report? Ans: a.) Input b.) Processing Logic c.) Output 3.) What are the flow of events in ABAP reports? Ans: Flow of Events: Initialization At selection screen Start of selection End of selection Top of page Top of page during line selection End of page At user command 4.) What is the diff b/w START-OF-SELECTION & AT SELECTION-SCREEN? Ans: START-OF-SELECTION: This event will triggers once your selection-screen is processed It triggers when you select F8 function key It triggers before reading data from database It triggers for all processing blocks in a program It is a default event triggered before extracting data from database AT SELECTION-SCREEN: It triggers once the control leaves from selection-screen & still selection-screen is in active mode i.e. It triggers at end of PAI when all the values are passed from selection-screen to program variables
Rohini kumar
SAP-ABAP
414
5.) What is the diff b/w AT SELECTION-SCREEN & AT SELECTION-SCREEN OUTPUT? Ans: AT SELECTION-SCREEN: It triggers once the control leaves from selection-screen & still selection-screen is in active mode i.e. It triggers at end of PAI when all the values are passed from selection-screen to program variables AT SELECTION-SCREEN OUTPUT: It triggers after initialization & before selection-screen display Use this event for modifying selection-screen 6.) What is the diff b/w INITIALIZATION & START-OF-SELECTION? Ans: INITIALIZATION: It triggers before selection-screen display Note: Use this event for initializing 4. Default values in selection-screen 5. Texts on push buttons in selection-screen 6. Texts for blocks, radio buttons, check boxes…………..etc START-OF-SELECTION: This event will triggers once your selection-screen is processed It triggers when you select F8 function key It triggers before reading data from database It triggers for all processing blocks in a program It is a default event triggered before extracting data from database 7.) Why is it mandatory to use start-of-selection when we are writing initialization and at selection-screen? Ans: 8.) What is LOAD-OF-PROGRAM event? Ans: This event will triggers before INITIALIZATION & once your program is loaded into memory
Rohini kumar
SAP-ABAP
9.) What are the events in classical reporting? Ans: 7. INITIALIZATION 8. AT SELECTION-SCREEN 9. START-OF-SELECTION 10.END-OF-SELECTION 11.TOP-OF-PAGE 12.END-OF-PAGE 10.) What are the events in interactive reporting? Ans: AT LINE-SELECTION: TOP-OF-PAGE DURING LINE-SELECTION 11.) What is the functionality of AT LINE-SELECTION? Ans: It triggers whenever user interacts with a list 12.) What is the functionality if GET CURSOR keyword? Ans: If fetches the field name & value selected by user from output list Syntax: GET CURSOR FIELD VALUE . 13.) How u can transfer data b/w two reports? Ans: 14.) What is the functionality of SY-LISEL in interactive reporting? Ans: It returns list of contents selected by user from output list 15.) What is the functionality of SY-LSIND in interactive reporting? Ans: It returns current list index 16.) How to switch from 14 to 4 list in interactive reporting? Ans:
Rohini kumar
415
SAP-ABAP
416
17.) What is the output of following code? INITIALIZATION. WRITE:/ 'Hello Abap'. Ans: 18.) What is the diff between SELECT SINGLE .... & SELECT SINGLE…. UP TO 1 ROW? Ans: 19.) What is the functionality of SCREEN internal table in reports? Ans: 20.) How u can create dynamic selection screens in reports? Ans: 21.) How u make a field mandatory apart from OBLIGATORY keyword? Ans: 22.) How u can make a selection screen field in invisible mode? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field EDIT_MASK ------- it hides the field data 23.) What are various events used on ALV reporting? Ans: WA_EVENT-NAME = ‘USER_COMMAND’. WA_EVENT-FORM = ‘INTERACTIVE’. 24.) What are the function modules in ALV reporting? Ans: 1. REUSE_ALV_GRID_DISPLAY It is for display the data in ALV grid 2. REUSE_ALV_BLOCK_LIST_INIT It initializes lists in blocked alvs 3. REUSE_ALV_BLOCK_LIST_APPEND This function module Maintains field catalogs Maintains data in list Append field catalogs & data with layout Rohini kumar
SAP-ABAP
417
4. REUSE_ALV_BLOCK_LIST_DISPLAY It displays data in list in blocked alvs 5. REUSE_ALV_HIRESEQ_LIST_DISPLAY Using this function module, you can display the in hierarchal format 25.) What is the diff b/w REUSE_ALV_LIST_DISPLAY & REUSE_ALV_GRID_DISPLAY? Ans: 26.) How u can perform following operations in alvs: a.) Editing field values? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field EDIT ------------------- by default the field catalogs in a layout are in display mode. Using this option a field should be converted into change mode b.) How to get hotspot on fields? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field HOTSPOT ------------ provides hand symbol c.) How u can fix a column? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field FIX_COLOUMN ----------- you can fix a coloumn d.) How u can color a particular field? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field EMPHASIZE ------- it provides a specific default color for a field in ALV grid e.) How u can remove zeros in alv output? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field NO_ZERO ---------- removes zeros from output list f.) How u can highlight a particular row in alv reporting? Ans: In layout work area you should pass INFO-FIELDNAME for displaying row with a specific color given in output list Rohini kumar
SAP-ABAP
418
g.) How u can create checkboxes? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field CHECKBOX ------- with this option you can create check box for a specific field h.) How u can perform auto totals and subtotals? Ans: SLIS_FIELDCAT_ALV is a standard SLIS structure with following field DO_SUM ----------- provides totals 27.) How to debug background jobs? Ans: 28.) Explain the fields of SCREEN Internal table? Ans: 29.) Explain how hierarchal alvs works? Ans: In Hierarchal Sequential ALVs we have to create 2 internal tables One for Header data (it_final1) & another for Item data (it_final) Both these internal tables should have a common field called KEY field In Header internal table the Key field should be unique In Item internal table the Key field should having number of items based on that unique key Pass these two internal tables to a function module called REUSE_ALV_HIERSEQ_LIST_DISPLAY 30.) What is the function module used for printing heading and logo in alv? Ans: SLIS_LISTHEADER: It is a standard ALV structure for maintaining headings in output list It is having following fields 4. TYP -------------- type of heading (H, S, A) 5. KEY ------------- text for heading in 20 characters 6. INFO ------------ text for heading in 60 characters Navigation for Maintaining Logos: Go to Paint Design a picture Save it on desktop Rohini kumar
SAP-ABAP
Go to OAER Class Name: Pictures Class Type: OT Object Key: ABAP Execute At bottom expand Standard Document Types Double click on Screen Select you Logo Enter Enter
31.) What is event internal table in ALVS? Ans: SLIS_ALV_EVENT: It is a standard ALV structure for maintaining events It is having following fields 3. NAME ----------- name of event 4. FORM ----------- subroutine name 32.) How u can work with interactive alvs? Ans: If I double click on customer code switch to XD03 application Syntax: FORM USING TYPE SY-UCOMM TYPE SLIS_SELFIELD. ------------------------ENDFORM. 33.) Explain the parameters of REUSE_ALV_GRID_DISPLAY? Ans: REUSE_ALV_GRID_DISPLAY It is for display the data in ALV grid The parameters are 13.Current program name It is important for activating layout management & for displaying logos & headings 14.Layout work area 15.Field catalog internal table Rohini kumar
419
SAP-ABAP
420
16.I_CALLBACK_USER_COMMAND It is for interactive purpose 17.I_STRUCTURE_NAME For providing structure 18.I_BACKGROUND_ID For maintaining background pictures 19.I_GRID_TITLE For maintaining title in ALV grid 20.IT_SORT For sorting data & for maintaining sub totals 21.I_SAVE For saving layouts 22.IT_EVENTS For events internal table 23.IS_PRINT For deactivating (or) activating the print mode for PDF formats…………etc 24.T_OUTTAB For output internal table 34.)What are the various ways of creating FIELDCATALOGS in ALVS?Which one u feel is the best?Why? Ans: There are 3 ways to create FIELD CATALOGS 4. Manually Ex: WA_FCAT-FIELDNAME = ‘KUNNR’. WA_FCAT-SELTEXT_M = ‘Customer Code’. APPEND WA_FCAT TO IT_FCAT. 5. By using REUSE_ALV_FIELDCATALOG_MERGE function module 6. By passing DDIC Structure name to REUSE_ALV_LIST_DISPLAY function module 35.) What is the functionality of REUSE_ALV_FIELDCATALOG_MERGE? Ans: 36.) What is logical database reporting?How it is useful in realtime? Ans: Rohini kumar
SAP-ABAP
421
37.) What is the Function module used for Hierarichal alvs? Ans: 1. REUSE_ALV_HIRESEQ_LIST_DISPLAY Using this function module, you can display the in hierarchal format 38.) Explain the function module of blocked alvs? Ans: 1. REUSE_ALV_BLOCK_LIST_INIT It initializes lists in blocked alvs 2. REUSE_ALV_BLOCK_LIST_APPEND This function module Maintains field catalogs Maintains data in list Append field catalogs & data with layout 3. REUSE_ALV_BLOCK_LIST_DISPLAY It displays data in list in blocked alvs 39.) Explain one requirement where u used blocked alvs in realtime? Ans: Using Blocked ALVs you can display multiple lists at one place In real time we are using blocked alvs in few scenarios such as if you want to display production affiance of different machines of one furnace in one Output list If client requires invoice details based on customers, materials, segments at one place we have to work with Blocked ALVs 40.) How u can improve performance of programming?Give atleast 15 tips for the same? Ans: 41.) Mention some 30 system fields that u used on realtime? Ans: 42.) What are the system fields used on interactive reporting? Ans: 3. SY-LSIND 4. SY-LISEL 43.) What are the pitfalls for for all entries keyword? Ans: Rohini kumar
SAP-ABAP
422
44.) How many times initialization and top-of-page triggers in report having 20 pages? Ans: INITIALIZATION will triggers only 1 time TOP-OF-PAGE will triggers 20 times 45.) Why u created restricted and unrestricted stock report when already SAP is providing such report in the form of MMBE? Ans: MMBE is providing materials details plant wise & storage location wise material by material My client gave a requirement for viewing all restricted & unrestricted stock at one time 46.) What is Code inspector? How it is useful in real time? Ans: It will inspect your code comprehensively & it will check 6. Performance Checks 7. Security Checks 8. Syntax Checks 9. User Interface 10.Programming Guidelines 47.) What is the functionality of HIDE keyword? Ans: It holds the records selected by user in interactive reporting 48.) How u can transfer data from alv reporting to MM01 Application? Ans: 49.) How u can create listbox in reports? Ans: 50.) If there are 50 records i want message at 10th record then how to do you do. Ans: 51) Difference between sy-tabix,sy-index and sy-subrc Ans: 52.) How you can convert alv report to oo abap report, is there any possibilities ? Ans: 53.) Can we define select statements in end-of-selection event? Ans: Rohini kumar
SAP-ABAP
423
54.) I have internal table a b 1 1 1 1 1 2 1 2 2 2 when does "at new" event triggers at 'a' and 'b'? ans: 55.) In interactive reports in 20th secondary list if double click what will happen? Ans: 56.) What are the abap runtime errors we have faced in reporting? Ans: In real time you will find number of exceptions (Run time errors) such as 8. Time out exception 9. SQL statement exception 10.Division by zero exception 11.No convert number exception 12.Type conflict exception 13.BCD overflow exception 14.*** Storage exception for internal table 57.) What is the use of initialization event? We can initialize the input values in selection screen without initialization event also but why we are using initialization event? Ans: Initialization Event triggers before selection-screen display Note: Use this event for initializing 1. Default values in selection-screen 2. Texts on push buttons in selection-screen 3. Texts for blocks, radio buttons, check boxes…………..etc 58.) After developing source code in development server how many reviews we will get for our source code. Ans: 59.) Tell me some Table and fields that u created in reports?\ Ans: Rohini kumar
SAP-ABAP
424
60.) What is the toughest report u created, what difficulties u faced and how u overcome those? Ans: 61.) What is the use of SLIS type pool in abap reports? Ans: 62.) What are Alv reports? How they are different from normal reports? Ans: ALV is advanced reporting with additional features of reporting 7. In traditional reporting you cannot maintain logos (pictures…………etc) With ALV reporting you can maintain logos using ALV Function Modules 8. With ALV reporting you can improve performance of programming by avoiding LOOP…..ENDLOOP 9. Using ALV reporting you can maintain Main Headings, Sub Headings……….etc 63.) What are the various ways of creating buttons in selection screens? Ans: Page number: 230 64.) How indexing is helpful in resolving performance issues in reports? Explain with ur experience in real time? Ans: Indexing is a way of searching Indexing is a way of improving performance while accessing the data from database I created secondary index on production efficient report First I debugged the program I found that control is taking lot of time for program execution Then I will identify none primary key fields of that SELECT statement & based on that nonprimary key fields I will created a secondary index 65.) What is system landscape in ur company? Ans:
Rohini kumar
SAP-ABAP
425
66.) What is ABAP/4 QUERY?(Sap Query). Ans: In real time for developing a report it will take lot of time for development i.e. Requirement ---- Functional Consultant-----Functional Document----Technical Consultant-----Technical Document------Object Creation------Unit Testing----Functional Testing-----User Testing-----go live (transfer to Production) using SAP Query you can create a report immediately through navigation 67.) How do you validate the selection criteria of report? Ans: 68.) How SUBMIT keyword is helpful in ABAP REPORTS? Ans: * push mails to SAP inbox SUBMIT RSLONN01 WITH MODE = ‘INT’ AND RETURN.
Rohini kumar
SAP-ABAP
426
FAQS IN REPORTS: 1 Q: What are SAP reports? Ans: SAP Reports are event-driven programs using ABAP/4 programming language These reports are used to fetch business-specific data from SAP standard databases under specified selection criteria Fetched data is processed to display result on output screen User develop SAP report object on ABAP editor using the standard SAP transaction SE38 2Q: What are ABAP report types? Ans: ABAP report types are of 7 types ABAP report types are available in report’s attributes screen They are: 1. Executable program 2. Function group (containing function modules) 3. Include 4. Interface pool 5. Class pool 6. Module pool 7. Subroutine pool 3Q: How many lists can be displayed through an interactive report? Ans: Maximum 21 lists can be displayed (1 basic list+ 20 secondary lists). 4Q: what is the event that will be triggered first in an ABAP report? Ans: Initialization event is triggered first if user executes an ABAP report But if the program is of type 1, M, F, or S; then LOAD-OF-PROGRAM is triggered first and then INITIALIZATION event. 5Q: What are the differences between simple and interactive ABAP reports? Ans: A simple ABAP report allows the user to interact with the whole business-result data. In case of interactive reports user can interact with specific result data at a time.
Rohini kumar
SAP-ABAP
427
6Q: How do you read selected lines of database table into an internal table in packages of predefined size? Ans: SELECT * FROM INTO TABLE PACKAGE SIZE . Where n is variable. 7Q: How do you write a DATA object from ABAP/4 program to ABAP/4 memory and restore the same from memory to program. Ans: EXPORT [FROM ] [FROM ]…. TO MEMORY ID . The ID , which can be up to 32 characters long, identifies the data in memory. 8Q: Name the function modules to write data from an Internal Table to the Presentation Server. Ans: 1. DOWNLOAD 2. WS_DOWNLOAD. 9Q: How to determine the attributes of an internal table? Ans: DESCRIBE TABLE [LINES ] [OCCURS ]. 9Q: What is interactive reporting? Ans: It helps you to create easy-to-read lists You can display an overview list first that contains general information and provide the user with the possibility of choosing detailed information that you display on further lists. 10Q: What are the uses of interactive reporting? Ans: The user can actively control data retrieval and display during the session Instead of an extensive and detailed list, you create a basic list with condensed information from which the user can switch to detailed displays by positioning the cursor and entering commands The detailed information appears in secondary lists.
Rohini kumar
SAP-ABAP
428
11Q; what are the event key words in interactive reporting? Ans: Event Keyword Event AT LINE-SELECTION Moment at which the user selects a line by double clicking on it or by positioning the cursor on it and pressing F2 AT USER-COMMAND
Moment at which the user presses a function key
TOP-OF-PAGE DURING
Moment during list processing of a
LINE-SELECTION
Secondary list at which a new page starts.
12Q: What is secondary list? Ans: It allows you to enhance the information presented in the basic list The user can, for example, select a line of the basic list for which he wants to see more detailed information You display these details on a secondary list Secondary lists may either overlay the basic list completely or you can display them in an extra window on the screen The secondary lists can themselves be interactive again. 13Q: How to select valid lines for secondary list? Ans: To prevent the user from selecting invalid lines, ABAP/4 offers several possibilities. At the end of the processing block END-OF-SELECTION, delete the contents of one or more fields you previously stored for valid lines using the HIDE statement. At the event AT LINE-SELECTION, check whether the work area is initial or whether the HIDE statement stored field contents there. After processing the secondary list, clear the work area again. This prevents the user from trying to create further secondary lists from the secondary list displayed. 14Q: Can we call reports and transactions from interactive reporting lists? Ans: Yes, It also allows you to call transactions or other reports from lists These programs then use values displayed in the list as input values The user can, for example, call a transaction from within a list of change the database table whose data is displayed in the list Rohini kumar
SAP-ABAP
429
15Q: What are system fields for secondary lists? Ans: 1. SY-LSIND Index of the list created during the current event (basic list = 0) 2. SY-LISTI Index of the list level from which the event was triggered. 3. SY-LILLI Absolute number of the line from which the event was triggered. 4. SY-LISEL Contents of the line from which the event was triggered. 5. SY-CUROW Position of the line in the window from which the event was triggered 6. SY-CUCOL Position of the column in the window from which the event was triggered 7. SY-CPAGE Page number of the first displayed page of the list from which the event was triggered. 8. SY-STARO Number of the first line of the first page displayed of the list from which the event was triggered (counting starts with 1). Possibly, a page header occupies this line. 9. SY-STACO Number of the first column displayed in the list from which the event was triggered 10.SY-UCOMM Function code that triggered the event. 11.SY-PFKEY Status of the displayed list. 16Q: What are the page headers for secondary lists? Ans: On secondary lists, the system does not display a standard page header and it does not trigger the event TOP-OF-PAGE. To create page headers for secondary list, you must enhance TOP-OF-PAGE: Syntax TOP-OF-PAGE DURING LINE-SELECTION. The system triggers this event for each secondary list. If you want to create different page headers for different list levels, you must program the processing block of this event accordingly, For example by using system fields such as SY-LSIND or SY-PFKEY in control statements (IF, CASE) 17Q: What are the types of messages? Ans: A message can have five different types. These message types have the following effects during list processing: 1. A (=Amend): 2. E (=Error) or W (=Warning): 3. I (=Information): 4. S (=Success):
Rohini kumar
SAP-ABAP
430
18Q: What are the drill-down features provided by ABAP/4 in interactive lists? Ans: ABAP/4 provides some interactive events on lists such as AT LINE-SELECTION (double click) or AT USER-COMMAND (pressing a button). You can use these events to move through layers of information about individual items in a list. 19Q: What is meant by stacked list? Ans: A stacked list is nothing but secondary list and is displayed on a full-size screen unless you have specified its coordinates using the window command. 19Q: Is the basic list deleted when the new list is created? Ans: No. It is not deleted and you can return back to it using one of the standard navigation functions like clicking on the back button or the cancel button. 20Q: What is meant by hotspots? Ans: A Hotspot is a list area where the mouse pointer appears as an upright hand symbol. When a user points to that area (and the hand cursor is active), a single click does the same thing as a double-click. Hotspots are supported from R/3 release 3.0c. 21Q: What is the length of function code at user-command? Ans: Each menu function, push button, or function key has an associated function code of length FOUR (for example, FREE), which is available in the system field SYUCOMM after the user action. 22Q: Can we create a GUI status in a program from the object browser? Ans: Yes. You can create a GUI STATUS in a program using SET PF-STATUS. 23Q: In which system field does the name of current gui status is there? Ans: The name of the current GUI STATUS is available in the system field SY-PFKEY.
Rohini kumar
SAP-ABAP
431
24Q: Can we display a list in a pop-up screen other than full-size stacked list? Ans: Yes, we can display a list in a pop-up screen using the command WINDOW with the additions starting at X1 Y1 and ending at X2 Y2 to set the upper-left and the lower-right corners where x1 y1 and x2 y2 are the coordinates. 25Q: What is meant by hide area? Ans: The hide command temporarily stores the contents of the field at the current line in a system-controlled memory called the HIDE AREA. At an interactive event, the contents of the field are restored from the HIDE AREA. 26Q: When they get cursor command used in interactive lists? Ans: If the hidden information is not sufficient to uniquely identify the selected line, the command GET CURSOR is used. The GET CURSOR command returns the name of the field at the cursor position in a field specified after the addition field, And the value of the selected field in a field specified after value. 27Q: How can you display frames (horizontal and vertical lines) in lists? Ans: You can display tabular lists with horizontal and vertical lines (FRAMES) using the ULINE command and the system field SY-VLINE. The corners arising at the intersection of horizontal and vertical lines are automatically drawn by the system. 28Q: What are the events used for page headers and footers? Ans: The events TOP-OF-PAGE and END-OF-PAGE are used for pager headers and footers. 29Q: How can you access the function code from menu painter? Ans: From within the program, you can use the SY-UCOMM system field to access the function code. You can define individual interfaces for your report and assign them in the report to any list level. If you do not specify self-defined interfaces in the report but use at least one of the three interactive event keywords. Rohini kumar
SAP-ABAP
432
AT LINE-SELECTION, AT PF, OR AT USER-COMMAND in the program, the system automatically uses appropriate predefined standard interfaces. These standard interfaces provide the same functions as the standard list described under the standard list. 30Q: How the at-user command serves mainly in lists? Ans: The AT USER-COMMAND event serves mainly to handle own function codes. In this case, you should create an individual interface with the Menu Painter and define such function codes. 31Q: How to pass data from list to report? Ans: ABAP/4 provides three ways of passing data: 1. Passing data automatically using system fields 2. Using statements in the program to fetch data 3. Passing list attributes 32Q: How can you manipulate the presentation and attributes of interactive lists? Ans: 1. Scrolling through Interactive Lists. 2. Setting the Cursor from within the Program. 3. Modifying List Lines. 33Q: How to call other programs? Ans: Report Transaction 1. Call and return SUBMIT AND RETURN 2. Call without return SUBMIT You can use these statements in any ABAP/4 program.
CALL TRANSACTION LEAVE TO TRANSACTION
34Q: How many lists can a program can produce? Ans: Each program can produce up to 21 lists One basic list and 20 secondary lists If the user creates a list on the next level (that is, SY-LSIND increases), the system stores the previous list and displays the new one. Only one list is active, and that is always the most recently created list
Rohini kumar
SAP-ABAP
433
35Q: What’s ABAP dictionary and its role in SAP? Ans: ABAP dictionary is the central information base for the developers. This manages all definitions(metadata) required for different applications in SAP. ABAP dictionary is completely integrated into ABAP development workbench. All other component of ABAP development workbench can access the data definitions(meta data) stored in the data dictionary. Role: ABAP data dictionary supports Definition of user-defined types (data elements, structures, table types). Structure of database objects (tables, indexes and views) can also be defined. These user-defined types/objects are then automatically created in the underlying relational database using the above data definitions. The ABAP dictionary also provides tools for editing screen fields (e.g., for assigning a field an input help i.e. F4 help). Data dictionary ensures data integrity, consistency and security. 36Q: What are the main object types of ABAP dictionary? Ans: Tables: Tables are defined in the ABAP Dictionary independently of the database. A table having the same structure is then created from this table definition in the underlying database. Views: Views are logical views on more than one table. The structure of the view is defined in the ABAP Dictionary. A view on the database can then be created from this structure. Types: (elements, structures, table types) Types are created in ABAP programs. The structure of a type can be defined globally in ABAP programs. Changes to a type automatically take effect in all the programs using the type. Lock objects: These are used to synchronize access to the same data by more than one user. Function modules that can be used in application programs are generated from the definition of a lock object in the ABAP Dictionary.
Rohini kumar
SAP-ABAP
434
Domains: Different fields having the same technical type can be combined in domains. Domain defines the value range of all table fields and structure components that refer to this domain. Data element: The ABAP Dictionary also contains the information displayed with the F1 and F4 help for a field in an input template. The documentation about the field is created for a data element. Input help: The list of possible input values that appears for the input help is created by a foreign key or a search help. 37Q: What are the components of a table definition. Ans: Table fields: For table fields, field names and data types are defined. Foreign keys: Relationship between the table and the other tables are defined. Technical settings: Data class and size category defines that what type of table to be created and how much space required. Indexes: Secondary indexes are created for a table for faster data selection. Again following are defined for a table fields: 1. Field name --------- can be of maximum 16 characters in a table and must start with a letter. 2. Key flag ----------- determines if a field should be the table key. 3. Field type --------- depicts the data type of the field in the ABAP dictionary. 4. Field length ------ denotes the number of valid places in the field. 5. Decimal places----- Number of places after decimal point for float type value. 6. Short text ----------- describes the business meaning of the field. 7. Also fields from other structures can be added to the table definition as include.
Rohini kumar
SAP-ABAP
435
38Q: What are the assignment options to the field? Ans: 1. Direct assignment of data types, field length, short text to a field 2. Data element assignment to a field 3. An input check (check table) for a field can be defined with a foreign key. 4. A search help can be assigned to a field. 5. Reference field or reference table must be specified for a table field that holds currency or quantity type value. 39Q: What’s reference table and reference field? Ans: Reference table is specified for fields containing quantities(data type QUAN) or currency(Data type CURR). This reference table must contain a field with the format for the currency key (data type CUKY) or unit of measure (data type UNIT). This field is called the reference field of the output field. The reference field can also reside in the table itself. 49Q: What is the maximum depth of nested includes in a table? Ans: Maximum depth is 9 i.e. maximum 9 structures can be included in a table/structure. 50Q: What are the uses of foreign keys in SAP? Ans: Using foreign keys (as main table-field is linked with check table), input value check for any input field can be done. Foreign keys can also be used to link several tables. 51Q: How many types of data classes are there in SAP? Ans: 1. Choose APPL0(master data) for data that is frequently accessed but rarely updated/changed. 2. Choose APPL1 (transaction data) for data that is frequently changed. 3. Choose APPL2 (organizational data) for customizing data that is defined/entered during system installation and rarely changed.
Rohini kumar
SAP-ABAP
436
52Q: How many types of size category are there in SAP? Ans: There are five size categories. Size category from 0 to 4 can be chosen for the tables. A certain fixed memory size is assigned to each category in the SAP database. 53Q:What is delivery class? Ans: We need to insert an delivery class value while creating customized table in SAP through the transaction code SE11. Delivery class is that which regulates the transport of the table’s data records (during SAP installations, SAP software upgrade, client copies, and data transport to other SAP system). SAP and its customers have different write types depending on the variety of delivery class. If Delivery class is A, it depicts that the application table for master and transaction data changes only rarely. 54Q: What is value table? Ans: Value table is maintained at domain level in SAP. During domain creation, value range of the domain is defined by specifying value table. Suppose for a particular domain, its value table holds the values ‘A’, ‘B’, ‘Z’. So whenever the domain will be used, system will allow to use these values only.
Rohini kumar
SAP-ABAP
437
FAQS IN INTERACTIVE REPORTS: 1Q: What are the event key words in interactive reporting ? Ans: 1. AT LINE-SELECTION Moment at which the user selects a line by double-clicking on it or by positioning the cursor on it and pressing F2 2. AT USER-COMMAND Moment at which the user presses a function key 3. TOP-OF-PAGE DURING LINE-SELECTION Moment during list processing of a secondary list at which a new page starts 2Q: What is secondary list ? Ans: Secondary lists allow you to enhance the information presented in the basic list. The user can, for example, select a line of the basic list for which he wants to see more detailed information You display these details on a secondary list. Either secondary lists may overlay the basic list completely (or) you can display them in an extra window on the screen. The secondary lists can themselves be interactive again. 3Q: How to select valid lines for secondary list? Ans: To prevent the user from selecting invalid lines, ABAP/4 offers several possibilities. At the end of the processing block END-OF-SELECTION, delete the contents of one or more fields you previously stored for valid lines using the HIDE statement. At the event AT LINE-SELECTION, check whether the work area is initial or whether the HIDE statement stored field contents there. In the latter case, create a secondary list, since you previously stored field contents for valid lines only. After processing the secondary list, clear the work area again. This prevents the user from trying to create further secondary lists from the secondary list displayed.
Rohini kumar
SAP-ABAP
438
4Q: How to create user interfaces for lists ? Ans: The R/3 system automatically generates a graphical user interface (GUI) for your lists that offers the basic functions for list processing, such as saving or printing the list. If you want to include additional functionality, such as pushbuttons, you must define your own interface status. To create a new status, the Development Workbench offers the Menu Painter. With the Menu Painter, you can create menus and application toolbars. And you can assign Function keys to certain functions. At the beginning of the statement block of AT END-OF-SELECTION, activate the status of the basic list using the statement: SET PF-STATUS 'STATUS'. 5Q: Can we call reports and transactions from interactive reporting lists ? Ans: YES, Interactive reporting also allows you to call transactions or other reports from lists. These programs then use values displayed in the list as input values. The user can, for example, call a transaction from within a list to change the database table whose data is displayed in the list. 6Q: How to maintain lists ? Ans: To return from a high list level to the next-lower level (SY-LSIND), the user chooses Back on a secondary list. The system then releases the currently displayed list and activates the list created one step earlier. The system deletes the contents of the released list. To explicitly specify the list level into which you want to place output, set the SY-LSIND field. The system accepts only index values which correspond to existing list levels. It then deletes all existing list levels whose index is greater or equal to the index you specify. For example, if you set SY-LSIND to 0, the system deletes all secondary lists and overwrites the basic list with the current secondary list. 7Q: What are the page headers for secondary lists? Ans: On secondary lists, the system does not display a standard page header and it does not trigger the event TOP-OF-PAGE. To create page headers for secondary list, you must enhance TOP-OF-PAGE: Rohini kumar
SAP-ABAP
439
Syntax: TOP-OF-PAGE DURING LINE-SELECTION The system triggers this event for each secondary list. If you want to create different page headers for different list levels, You must program the processing block of this event accordingly, For example by using system fields such as SY-LSIND or SY-PFKEY in control statements (IF, CASE). 8Q:What is meant by stacked list ? Ans: Stacked list is nothing but secondary list and is displayed on a full-size screen unless you have specified its coordinates using the window command. 9Q: Is the basic list deleted when the new list is created? Ans: No. It is not deleted and you can return back to it using one of the standard navigation functions like clicking on the back button or the cancel button. 10Q:What is meant by hotspots ? Ans: Hotspot is a list area where the mouse pointer appears as an upright hand symbol. When a user points to that area (and the hand cursor is active), A single-click does the same thing as a double-click. Hotspots are supported from R/3 release 3.0c. 11Q: In which system field does the name of current gui status is there ? Ans: The name of the current GUI STATUS is available in the system field SY-PFKEY. 12Q: What is meant by hide area ? Ans: The hide command temporarily stores the contents of the field at the current line in a system-controlled memory called the HIDE AREA. At an interactive event, the contents of the field is restored from the HIDE AREA. When calling a secondary list from a list line for which the HIDE fields are stored, the system fills the stored values back into the variables in the program. In the program code, insert the HIDE statement directly after the WRITE statement for the current line.
Rohini kumar
SAP-ABAP
440
13Q: When the get cursor command used in interactive lists ? Ans: If the hidden information is not sufficient to uniquely identify the selected line ,the command GET CURSOR is used. The GET CURSOR command returns the name of the field at the cursor position in a field specified after the addition field, and the value of the selected field in a field specified after value. 14Q: How to pass data from list to report ? Ans: ABAP/4 provides three ways of passing data: 1. Passing data automatically using system fields 2. Using statements in the program to fetch data 3. Passing list attributes 15Q: How to call other programs ? Ans: Report Transaction Call and return SUBMIT AND RETURN CALL TRANSACTION Call without return SUBMIT LEAVE TO TRANSACTION System fields used in interactive Reporting: The SY-LSIND system field contains the index of the list currently created. While creating a basic list, SY-LSIND equals 0. With each interactive event, the system automatically sets the following system fields System field Information: SY-LINCT --------- total line count of a list SY-LINNO -------- current line no where cursor is placed. SY-LSIND -------- Index of the list currently created during the current event (basic list = 0) SY-LISTI ---------- Index of the list level from which the event was triggered SY-LILLI ---------- Absolute number of the line from which the event was triggered SY-LISEL --------- Contents of the line from which the event was triggered SY-CUROW ------ Position of the line in the window from which the event was triggered (counting starts with 1) SY-CUCOL ------- Position of the column in the window from which the event was triggered (counting starts with 2) SY-UCOMM ----- Function code that triggered the event SY-PFKEY ------- Always contains the status of the current list. Rohini kumar
SAP-ABAP
441
TOP-OF-PAGE DURING LINE-SELECTION: The system triggers this event for each secondary list. If you want to create different page headers for different list levels, you must program the processing block of this event accordingly, For example by using system fields such as SY-LSIND or SY-PFKEY in control statements (IF, CASE) Data from System Fields of Interactive Lists: From system fields, you retrieve the following information: The index of a list, The position of the list in the output window & The location of the cursor The only system field that contains the contents of the selected line is SY-LISEL. Passing Data by Program Statements: To pass individual output fields or additional information from a line to the corresponding processing block during an interactive event, Use following statements HIDE: The HIDE statement is one of the fundamental statements for interactive reporting Using the HIDE technique, you can at the moment you create a list level define, which information later to pass to the subsequent secondary lists. Example: HIDE: SPFLI-CARRID, SPFLI-CONNID, NUM. READ LINE: Use the statements READ LINE & READ CURRENT LINE to explicitly read data from the lines of existing list levels. These statements are tightly connected to the HIDE technique. Syntax: READ LINE [INDEX ] [FIELD VALUE [INTO ]... [INTO ]] [OF CURRENT PAGE|OF PAGE ]. Example: READ LINE SY-INDEX FIELD VALUE BOX.
Rohini kumar
SAP-ABAP
442
GET CURSOR: Use the statements GET CURSOR FIELD & GET CURSOR LINE to pass the output field or output line on which the cursor was positioned during the interactive event to the processing block. Syntax: GET CURSOR FIELD [OFFSET ] [LINE ] [VALUE ] [LENGTH ]. SET
CURSOR: To set the cursor, use the SET CURSOR statement This statement sets the cursor in the most recently created list While creating the basic list, this is always the basic list itself While creating a secondary list, this is the previous list.
ABAP allows you to call reports as well as transactions using these statements: Report Transaction Call and return SUBMIT AND RETURN CALL TRANSACTION Call without return SUBMIT LEAVE TO TRANSACTION Typical Structure of ABAP Program: 1. Report Definitions * 2. Table and Data definitions * 3. Initialization event 4. Screen Select Options/Inputs * 5. Selection-screen event 6. Start-of-selection event 7. Performs and other Events * Statements 8. End-of-selection event 9. Initialization
Rohini kumar
SAP-ABAP
OOABAP: 1Q: Principles of oops? Ans: 5. Inheritance 6. Polymorphism 7. Abstraction 8. Encapsulation 2Q: What is difference between procedural & OO Programming? Ans: Structured Programming Object Oriented Programming 1. Not Reusable 1. Reusable 2. Not based on real life 2. Based on real life (not user friendly) 3. No data security 3. High data security 4. No exception handling 4. Exception handling 3Q: What is class? Ans: Class is a template based on which objects are created All the features (Methods) of an object is encapsulated within a class As class is a template memory is not allocated by system to a class 4Q: What is object? Ans: It is real time entity It is always created based on a class (object is an instance of a class) As object is a real time entity memory is allocated by system to an object Every object holds data in such a way that outside world cannot access 5Q: Can we instantiate a class within implementation of other class? Ans: 6Q: What is deferred key word? Ans: 7Q: How we can refer to a class without defining it? Ans: 8Q: Can we put non declarative statement e.g. START-OF-SELECTION within a class Ans: Rohini kumar
443
SAP-ABAP
444
9Q: What is static attribute & method? Ans: 10Q: How to create a global class? Ans: In global class CLASS DEFINITION & CLASS IMPLEMENTATION parts are maintained in Class Builder (SE24) & Execution part is maintained in ABAP Editor (SE38) 11Q: How can we pass importing parameter? Pass by value/pass by reference Ans: 13Q: Can we changed pass by reference in any method? Ans: 14Q: What is preferred parameter? Ans: More than one optional & no mandatory 15Q: Can we pass returning parameter by reference? Ans: No, Only pass by value 16Q: Can static method use instance attribute ? Ans: 17Q: Can a method call itself? Ans: 18Q: What is me variable? Ans: 19Q: What is constructor? What are types of constructor? When it is called? Ans: Constructor is a default method in Object Oriented ABAP It is called automatically whenever object is created Use this method for initializing values in Object Oriented ABAP 20Q: Can we have export parameter in Instance constructor? Ans: 21Q: Can instance constructor raise exception? Ans: Rohini kumar
SAP-ABAP
445
22Q: When static constructor is called? Ans: 23Q:Can we have interface for static class or constructor? Ans: 24Q: What is abstract class? Ans: Abstract classes are cannot be implemented Objects cannot be created for abstract classes Abstract class methods are also abstract in nature Derived class can implement abstract class methods by redefining the methods of abstract class in derived class 25Q: Can we implement abstract method in abstract class? If not then where it can be implemented? Ans: 26Q: What is final class & Method? Ans: 27Q: Can subclass call super class constructor? Ans: 28Q: Can we call static constructor more than once in a program? Ans: 29Q: What is method redefinition? Ans: 30Q: What is interface? Ans: It is a template which extends the scope of a class & implements polymorphism Instances cannot be created based on interface Interface methods are always implemented in other class 31Q: Can we implement interface in private section of any class? Ans: 32Q: Is it mandatory to implement all the methods of interface? Ans: Rohini kumar
SAP-ABAP
446
33Q: What is alias? Instead of specifying full name of interface methods we can assign it a name which can directly trigger. Ans: 34Q: What is Friendship? Ans: 35Q: What is event handler method? Ans: 36Q: Can we have more than one event handler method for same event? Ans: 37Q: Can event have import parameter? Ans: 38Q: How you handled exception during programming? Ans: 39Q: What is cleanup section? Ans: 40Q: What is BADI? Ans: 41Q: What is check box for multiple usse in BADI? Ans: 42Q: How to search a BADI ? Ans: 43Q: What is Value table and Check table, Difference between them? Ans: 44Q: What are secondary index’s? Ans: 45Q: What is the draw back of secondary index’s? Ans: 46Q: What are conversion routines? Ans: Rohini kumar
SAP-ABAP
47Q: At which level are they mantained? Ans: 48Q: what are Predeifined data types? Ans: 49Q: Which predefined data type uses conversion routines? Ans: 50Q: What are logical units of work? Ans: 51Q: When is difference btw native and open sql Ans: 52Q: Difference between Modify and Update Ans: 53Q: Which is more efficient for all entries or joins? Ans: 54Q: When is implicit commit triggered. Ans: 55Q: What are RFC? Ans: 56Q: How do u create a destination system? Ans: 57Q: What are different types of commits used? Ans: 58Q: What are search helps? Ans: 59Q: Types of tables? Ans: 60Q: Difference between pool tables and cluster tables? Ans: Rohini kumar
447
SAP-ABAP
448
61Q: What is a delivery class? Ans: 62Q: What are the types of delivery class? Ans: 63Q: Difference between System tables and control tables? Ans: 64Q: What is normalization? Ans: 65Q: What is BCNF? Ans: 66Q: What is persistant class? Ans:
SAP-ADV ABAP NAME
: Rohini Kumar
TOPICS
: BDC SCRIPTS SMART FORMS ENHANCEMENTS ALE BAPI
Rohini kumar
SAP-ABAP
Rohini kumar
449
SAP-ABAP
450
INDEX 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
BDC Data Transfer Techniques (Inbound & Outbound) Steps in BDC Data Transfer Technique Methods in BDC (Session, Call Transaction, LSMW & Direct Input methods) 1. Session Method Upload bank data from Notepad using session method Uploading data from XL Sheet using Session Method 2. Call Transaction Method Upload pricing data using Call Transaction Method 3. LSMW SKIP Functionality . Upload material master data with MM01 using flat file with headings & logo BDC with Table Control Upload vendor master data using XK01 using Table Control File Handling Opening a File in Application Server in Output Mode (Write Mode) Opening a File in Input Mode (Read Mode) Upload asset master data with AS02 using Call Transaction Method (Assignment) Upload employee payroll for infotype 14 with PA30 using Call Transaction Method (Assignment) SAP Scripts Flow of Creating Form (Steps) Goods receipt form using Scripts Function Modules for Print Program PO Form using Scripts(Assignment) Standard Forms Smart Forms Steps in Working of Smart Forms PO Form using Smart Forms SAP Enhancements (Userexits, Customerexits, BADI, Enhancement Frame Work & BTE) 1. Userexits Validate sales order application using Userexits 2. Customerexits (Function Exits, Menu Exits, Screen Exits & Field Exits) a) Function Exits Validate vendor master application for postal code b) Menu Exits c) Screen Exits
Rohini kumar
5 5 6 7 8 10 15 21 23 29 35 35 36 37 38 38 40 43 44 45 47 48 56 57 58 61 63 64 81 81 81 83 83 83 86 88
SAP-ABAP
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
d) Fieldexits 3. BADI(Standard, Custom &Filter BADIs) i) Standard BADI Watch Point Navigation for Finding BADI (3 Methods) Validate BOM application (CS01) for alternate Bom using Standard BADI Add a menu in FBL5N application using Standard BADI . Add a screen in XD01, XD02 with field Sales Manager using Standard BADI ii) Custom BADI iii) Filter BADI Determine tax code for sales organization using Filter BADI 4. Enhancement Framework Provide Profit center as obligatory in F-28 application In MB31 provide Document date & Posting date as previous date Add fields in FB03 application ( Dmbtr, Hlcont ) Add screen in VF01, VF02, VF03 with ZZBOXNO, ZZSIZE, ZZTEXT 5. BTE Add indicator field in FBL5N application Cross Applications (ALE & IDOC) Records (Control, Data & Status) ALE Architecture Message Type Types of IDOCs (Standard IDOC, Custom IDOC &Extended IDOC) a) Standard IDOC Distributing material master data Sending Changes to Inbound System IDOC Filtering(Segment Filtering, IDOC Filtering &Reduced IDOC Filtering) 1. Segment Filtering 2. IDOC Filtering 3. Reduced IDOC Type Distributing Transactional Data b) Custom IDOC c) Extended IDOC Trouble Shooting & Recovery Debugging IDOCs EDI Steps in EDI Process Flow BAPI BOR Types of BAPIs (Standard BAPI, Custom BAPI & Extended BAPI)
Rohini kumar
451
92 93 94 96 97 98 100 102 107 107 107 111 113 114 115 117 120 120 125 126 128 130 131 131 131 137 139 139 140 146 148 154 160 167 168 169 171 174 176 177
SAP-ABAP
77 78 79 80 81 82 83 84 85 86 87 88
Rohini kumar
452
1. Standard BAPI 2. Custom BAPI Adobe Forms Debugging Techniques Table Level Debugging Modifying Data during Debugging Debugging Background Jobs Lock Object Search Help Exit Questions & Answers BDC SCRIPTS & SMART FORMS
177 181 186 189 189 190 191 192 195 197 197 217
SAP-ABAP
453
BDC: Batch Data Communication BDC is a data transfer technique from one system to another system *** Real time need for BDC: 1. Assume client wants to enter (or) process 1000 materials using MM01 T-code. Manually it will take lot of time for the same. In this case we have to use BDC 2. In real time every company have to update their prices quarterly (or) half yearly using VK11 T-code. Again manually, it will take lot of time. In this case also we have to use BDC 3. In HR module ESI Numbers have to be modified yearly for workers. This is again timeconsuming process. In this case also we have to use BDC In all above examples manually clients have to process application data & there is no guaranty that data is 100% consistent SAP is providing a technique called BDC for data transfer Data Transfer Techniques: There are two types of data transfer techniques 1. Outbound 2. Inbound Outbound: SAP SAP (source system)
Non-SAP
Inbound: SAP SAP (target system) Non-SAP Note: BDC is an Inbound data transfer technique
Rohini kumar
SAP-ABAP
454
Steps in BDC Data Transfer Technique: Step-1: In real time Flat File (XL Sheet (or) Note pad) is provided by end user (client) Step-2: Functional Consultant will analyses Flat File & there only he will converts Non-SAP data into SAP format Functional Consultant will prepare Functional Document & provide it to Technical Consultant Step-3: Technical Consultant will write an interface program (BDC program) in SAP system & he will upload the data from Flat File to Internal table (created based on Flat File) Step-4: In real time some data might be in SAP format (or) Non-SAP format All Non-SAP format data is converted into SAP format using validations in application Step-5: Before validation we have to perform mapping logic **For that we have to create mapping logic internal table based on BDC Data Structure Step-6: From mapping logic internal table (it_bdcdata) data will goes to respective application where LUW is performed With LUW data is finally transferred to database tables Note: BDC is a part of conversion technique Flat File: In real time Flat File (mainly XL Sheet) is provided by end user
Rohini kumar
SAP-ABAP
455
Mapping Logic: BDC Data (structure) Program (module pool program) Dynpro (screen number) Dynbegin (start screen) Fnam (field name) Fval (field value) Methods in BDC: 1. ** Session method 2. ** Call Transaction method 3. LSMW (this job is done by Functional Consultant) 4. Direct Input method (it is out dated)
Rohini kumar
SAP-ABAP
456
Session Method: Features: 1. Use session method for uploading large amount of data (more than 10000 records) 2. Data can be processed in Foreground as well as Background 3. *** In BDC in session method error records are captured using Log File 4. In session method respective Log File is already given by SAP 5. *** Multiple applications can be processed at one time 6. Asynchronous processing 7. Synchronous updating 8. It is a slower method but consistent Function Modules in Session Method: 1. BDC_OPEN_GROUP 2. BDC_INSERT 3. BDC_CLOSE_GROUP BDC_OPEN_GROUP: It will open a session in SM35 BDC_INSERT: It transfers mapped data from mapping logic internal table to session BDC_CLOSE_GROUP: It closes a session which is already opened. Flow of Data in Session Method: Flat File (using function module) It_data (using LOOP………ENDLOOP) Wa_data (using APPEND keyword) It_bdcdata (using BDC_INSERT function module) Session Session processed (SM 35) Screens LUW Database Tables Rohini kumar
SAP-ABAP
457
Processing: Transferring the data from Flat File (Presentation Server) ultimately to Session (Application Server) is called processing In session method processing is asynchronous (all records from Flat File are ultimately broad to session) Updating: Transferring the data from Application Server to Database Server is called updating In session method updating is synchronous In session method if a record is correctly committed to database then only next record is updated (next transaction can be processed only when the previous record is correctly written to the database) ** Recording: Using recording you can map Program name, Screen number, Field names………….etc You can map Screen Sequences You can map FCT values for different function codes (BACK, SAVE, ENTER………etc) Note: T Code for recording is SHDB
Rohini kumar
SAP-ABAP
458
Requirement: Upload bank data from Notepad using session method Solution: Step-1: Go to SHDB New Recording Recording: ZBANK_RECO Transaction Code: FI01 Start Recording Bank Country: IN Bank Key: SR Nagar Enter Bank Name: state bank on Hyderabad Street: SR nagar City: Hyderabad Bank Branch: SR nagar branch Save Save Back Note: In real time, Functional Consultants perform recording. As a Technical Consultant based on recording we have to create a program Step-2: Go to SHDB Select your recording name (ZBANK_RECO) Program Program Name: ZFI_BANK_UPLOAD Transaction For Recording Enter Title: BDC for FI01 Type: Executable Program Source Code Local Object You will find a program Remove starting 3 lines i.e. INCLUDE BDCRECXL START-OF-SELECTION ………………………. Rohini kumar
SAP-ABAP
459
From bottom remove last 2 lines i.e. PERFORM BDC_TRANSACTION USING …………………. Step-3: Write your program from begging of given program SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETER p_file TYPE rlgrap-filename. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_fi01, banks TYPE banks, bankl TYPE bankl, banka TYPE banka, stras TYPE stras, brnch TYPE brnch, END OF ty_fi01. DATA: wa_fi01 TYPE ty_fi01, it_01 TYPE TABLE OF ty_fi01. * mapping objects DATA: wa_bdcdata TYPE BDCDATA, it_bdcdata TYPE BDCDATA. DATA: fnam TYPE STRING. * F4 functionality AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file. PERFORM open_file. START-OF-SELECTION. PERFORM PERFORM PERFORM PERFORM
Rohini kumar
upload. open_session. process_data. close_session.
SAP-ABAP
460
FORM open_file. CALL FUNCTION ‘F4_FILENAME’ EXPORTING PROGRAM_NAME = SYST-CPROG DYNPRO_NUMBER = SYST-DYNNR FIELD_NAME = ‘p_file’ IMPORTING FILE_NAME = p_file. ENDFORM. FORM upload. fnam = p_file. CALL FUNCTION ‘GUI_UPLOAD’ EXPORTING FILENAME = fnam HAS_FIELD_SEPARATOR = ‘X’ TABLES DATA_TAB = it_fi01. ENDFORM. FORM open_session. CALL FUNCTION ‘BDC_OPEN_GROUP’ EXPORTING CLIENT = SY-MANDT GROUP = ‘Ashok’ USER = SY-UNAME KEEP = ‘X’. ENDFORM. ** FORM process_data. LOOP AT it_fi01 INTO wa_fi01. REFRESH it_bdcdata. Remove dummy values & provide work area wa_fi01-banks. wa_fi01-bankl. Rohini kumar
SAP-ABAP
461
wa_fi01-banka. wa_fi01-stras. wa_fi01-ort01. wa_fi01-brnch. * transfer mapped data to session CALL FUNCTION ‘BDC_INSERT’ EXPORTING TCODE = ‘FI01’ TABLES DYNPROTAB = it_bdcdata. ENDLOOP. ENDFORM. FORM close_session. CALL FUNCTION ‘BDC_CLOSE_GROUP’. ENDFORM. * screen mapping FORM BDC_DYNPRO USING PROG SCREEN. CLEAR wa_bdcdata. wa_bdcdata-program = prog. wa_bdcdata-dynpro = screen. wa_bdcdata-dynbegin = ‘X’. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. * field mapping FORM BDC_FIELD USING FIELD CLEAR wa_bdcdata. wa_bdcdata-fnam = field. wa_bdcdata-fval = value. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. Rohini kumar
VALUE.
SAP-ABAP
Step-4: Create a Flat File with Note pad IN SBI009 STATEBANKOFINDIA IN SBH008 STATEBANKOFHYD
462
LBNAGAR AMEERPET
HYDERABAD HYDERABAD
Step-5: Go to SE38 Execute Apply F4 Select your Flat File Open Execute
Go to SM35 Select your Session name Process Background Process
07-11-2014 Question-1: Assume my Session has been processed & after processing, I want my Session to be displayed in SM35 for status check. How you can achieve this task? Answer: By providing exporting parameter KEEP = ‘X’ you can get your processed session back in SM35 Question-2: How you can maintain Logs (or) Error records in Session method? Answer: In Session method SAP is providing a Log file by default No need to create a Log file for handling error records You can find Log file by using SM35 Go to SM35 Select your session Select Log option (F7) Select your session Select Display button
Rohini kumar
SAP-ABAP
463
Uploading data from XL Sheet using Session Method: Using TEXT_CONVERT_XLS_TO_SAP you can upload the data from XL Sheet to internal table Requirement: Upload bank data from XL Sheet using session method Solution: Step-1: Go to SHDB New Recording Recording: ZBANK_RECO Transaction Code: FI01 Start Recording Bank Country: IN Bank Key: SR Nagar Enter Bank Name: state bank on Hyderabad Street: SR nagar City: Hyderabad Bank Branch: SR nagar branch Save Save Back Note: In real time, Functional Consultants perform recording. As a Technical Consultant based on recording we have to create a program Step-2: Go to SHDB Select your recording name (ZBANK_RECO) Program Program Name: ZFI_BANK_UPLOAD Transaction For Recording Enter Title: BDC for FI01 Type: Executable Program Source Code Local Object You will find a program Remove starting 3 lines Rohini kumar
SAP-ABAP
464
i.e. INCLUDE BDCRECXL START-OF-SELECTION ………………………. From bottom remove last 2 lines i.e. PERFORM BDC_TRANSACTION USING …………………. Step-3: Write your program from begging of given program ** TYPE-POOLS TRUXS. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETER p_file TYPE rlgrap-filename. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_fi01, banks TYPE banks, bankl TYPE bankl, banka TYPE banka, stras TYPE stras, brnch TYPE brnch, END OF ty_fi01. DATA: wa_fi01 TYPE ty_fi01, it_01 TYPE TABLE OF ty_fi01. * mapping objects DATA: wa_bdcdata TYPE BDCDATA, it_bdcdata TYPE BDCDATA. DATA: t_raw TYPE TRUXS_T_TEXT_DATA. * F4 functionality AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file. PERFORM open_file. START-OF-SELECTION. PERFORM upload. Rohini kumar
SAP-ABAP
PERFORM open_session. PERFORM process_data. PERFORM close_session. FORM open_file. CALL FUNCTION ‘F4_FILENAME’ EXPORTING PROGRAM_NAME = SYST-CPROG DYNPRO_NUMBER = SYST-DYNNR FIELD_NAME = ‘p_file’ IMPORTING FILE_NAME = p_file. ENDFORM. FORM upload. CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP’ EXPORTING I_TAB_RAW_DATA = t_raw I_FILENAME = p_file TABLES I_TAB_CONVERTED_DATA = it_fi01. ENDFORM. FORM open_session. CALL FUNCTION ‘BDC_OPEN_GROUP’ EXPORTING CLIENT = SY-MANDT GROUP = ‘rgs’ USER = SY-UNAME. ENDFORM. ** FORM process_data. LOOP AT it_fi01 INTO wa_fi01. REFRESH it_bdcdata.
Rohini kumar
465
SAP-ABAP
466
Remove dummy values & provide work area wa_fi01-banks. wa_fi01-bankl. wa_fi01-banka. wa_fi01-stras. wa_fi01-ort01. wa_fi01-brnch. * transfer mapped data to session CALL FUNCTION ‘BDC_INSERT’ EXPORTING TCODE = ‘FI01’ TABLES DYNPROTAB = it_bdcdata. ENDLOOP. ENDFORM. FORM close_session. CALL FUNCTION ‘BDC_CLOSE_GROUP’. ENDFORM. * screen mapping FORM BDC_DYNPRO USING PROG SCREEN. CLEAR wa_bdcdata. wa_bdcdata-program = prog. wa_bdcdata-dynpro = screen. wa_bdcdata-dynbegin = ‘X’. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. * field mapping FORM BDC_FIELD USING FIELD CLEAR wa_bdcdata. wa_bdcdata-fnam = field. Rohini kumar
VALUE.
SAP-ABAP
467
wa_bdcdata-fval = value. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. Step-4: Create a Flat File MS-XL IN SBI009 STATEBANKOFINDIA IN SBH008 STATEBANKOFHYD
LBNAGAR AMEERPET
Step-5: Go to SE38 Execute Apply F4 Select your Flat File Open Execute
Go to SM35 Select your Session name Process Background Process
Question-1: How you can perform background processing in Session method? Answer: Using program RSBDCSUB you can execute session in background Example: In above program modify subroutine PERFORM close_session. FORM close_session. CALL FUNCTION ‘BDC_CLOSE_GROUP’. SUBMIT RSBDCSUB VIA SELECTION-SCREEN. ENDFORM. Execute F4 Select your Flat File Rohini kumar
HYDERABAD HYDERABAD
SAP-ABAP
468
Execute You will find a selection screen Session: RGS Execute
Question-2: Suppose I’m having a Flat File with 50000 records. It happened that the system crashed while uploading data. How I know the number of records exactly uploaded? Answer: I will go to respective database table & copy the key values to the table & execute it Question-3: Assume there are 1000 records out of which I uploaded 500 records & remaining I want to upload next day. How you will, you perform this job. Answer: I will check the status of the records uploaded & I will delete the records from Flat File which are correctly uploaded & remaining I will execute once again on next day Question-4: I’m having 2 Flat Files with 500 records & 50000 records. Which method will you prefer for both Flat Files? Answer: For 500 records Call Transaction Method For 50000 records Session Method
Rohini kumar
SAP-ABAP
469
Call Transaction Method: Features of Call Transaction Method: 1. Use Call Transaction Method for uploading small amount of data (master data) 2. Data can be uploaded foreground & as well as background 3. ** Only single application can be processed at one time with one BDC program 4. ** In Call Transaction Method we have to create Log file explicitly using structure BDCMSGCOLL 5. Synchronous processing (record by record) 6. Asynchronous updating by default (even you can switch updating mode to synchronous) 7. Faster than Session method. Because in Call Transaction Method control will not wait for updating process to be happened. It simply transfers the control to Message Service (or) Update Service to perform the same. That’s why this method is faster than Session method Note: In Call Transaction Method session function modules are not required ** Syntax for Call Transaction Method: CALL TRANSACTION USING MODE UPDATE MESSAGE INTO OPTIONS FROM Parameters & Modes in Call Transaction Method: Parameter Mode 1. MODE A ----------- Foreground E ----------- Error N ----------- Background 2. UPDATE A ----------- Asynchronous S ------------ Synchronous 3. MESSAGE M Append Mode (A): It is foreground processing Error Mode (E): If error occurs then only it will display screen & remaining processing is background No Display Mode (N): It is background processing Rohini kumar
SAP-ABAP
470
Update Parameter: Using this parameter, you can switch the control from asynchronous to synchronous Message Parameter: It is for error handling in Call Transaction Method Flow of Data in Call Transaction Method: Flat File (using function module) It_data (using LOOP………ENDLOOP) Wa_data (using APPEND keyword) It_bdcdata (using function module CALL TRANSACTION) Screens LUW Database Tables
Rohini kumar
SAP-ABAP
471
Requirement: Upload pricing data using Call Transaction Method Every company will increases the prices of their finished products using VK11 application Solution: Step-1: Go to SHDB New Recording Recording: ZVK11_RECO Transaction Code: VK11 Start Recording Condition Type: ZZ01 Enter Sales Organization: 1000 Distribution Channel: 10 Material: 100-100 Amount: 500 Unit: INR Valid From: 01.07.2014 Valid To: 31.12.2014 Save Save Back Step-2: Go to SHDB Select your recording name (ZVK11_RECO) Program Program Name: ZMM_VK11_UPLOAD Transaction For Recording Enter Title: BDC for VK11 Type: Executable Program Source Code Local Object You will find a program Remove starting 3 lines i.e. INCLUDE BDCRECXL START-OF-SELECTION ………………………. Rohini kumar
SAP-ABAP
472
From bottom remove last 2 lines i.e. PERFORM BDC_TRANSACTION USING …………………. Step-3: Write your program from begging of given program ** TYPE-POOLS TRUXS. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETER p_file TYPE rlgrap-filename. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_fi01, banks TYPE banks, bankl TYPE bankl, banka TYPE banka, stras TYPE stras, brnch TYPE brnch, END OF ty_fi01. DATA: wa_vk01 TYPE ty_fi01, vk_01 TYPE TABLE OF ty_fi01. * mapping objects DATA: wa_bdcdata TYPE BDCDATA, it_bdcdata TYPE BDCDATA. DATA: t_raw TYPE TRUXS_T_TEXT_DATA. * F4 functionality AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file. PERFORM open_file. START-OF-SELECTION. PERFORM PERFORM PERFORM PERFORM Rohini kumar
upload. process_data. fill_cat. display_data.
SAP-ABAP
473
FORM open_file. CALL FUNCTION ‘F4_FILENAME’ EXPORTING PROGRAM_NAME = SYST-CPROG DYNPRO_NUMBER = SYST-DYNNR FIELD_NAME = ‘p_file’ IMPORTING FILE_NAME = p_file. ENDFORM. FORM upload. CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP’ EXPORTING I_TAB_RAW_DATA = t_raw I_FILENAME = p_file TABLES I_TAB_CONVERTED_DATA = it_fi01. ENDFORM. ** FORM process_data. LOOP AT it_fi01 INTO wa_fi01. REFRESH it_bdcdata. Remove dummy values & provide work area wa_fi01-banks. wa_fi01-bankl. wa_fi01-banka. wa_fi01-stras. wa_fi01-ort01. wa_fi01-brnch. * transfer mapped data to session CALL FUNCTION ‘BDC_INSERT’ EXPORTING TCODE = ‘FI01’ TABLES DYNPROTAB = it_bdcdata. Rohini kumar
SAP-ABAP
474
ENDLOOP. ENDFORM. * screen mapping FORM BDC_DYNPRO USING PROG SCREEN. CLEAR wa_bdcdata. wa_bdcdata-program = prog. wa_bdcdata-dynpro = screen. wa_bdcdata-dynbegin = ‘X’. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. * field mapping FORM BDC_FIELD USING FIELD
VALUE.
CLEAR wa_bdcdata. wa_bdcdata-fnam = field. wa_bdcdata-fval = value. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. Step-4: Create a Flat File MS-XL IN SBI009 STATEBANKOFINDIA IN SBH008 STATEBANKOFHYD Step-5: Go to SE38 Execute Apply F4 Select your Flat File Open Execute Go to SM35 Select your Session name Rohini kumar
LBNAGAR AMEERPET
HYDERABAD HYDERABAD
SAP-ABAP
Process Background Process
Rohini kumar
475
SAP-ABAP
476
08-11-2014 Question: What is the difference between Session Method & Call Transaction Method? Answer: Session Method Call Transaciton Method 1. It for uploading large amount of data 1. It for uploading small amount of data 2. Multiple applications can be processed 2. Only single application can be processed at one time with one BDC program at one time with one BDC program 3. In this method respective Log File is 3. In this method we have to create Log file already given by SAP explicitly using structure BDCMSGCOLL 4. Asynchronous processing 4. Synchronous processing 5. Synchronous updating 5. Asynchronous updating 6. It is a slower method but consistent 6. Faster than Session method Question: How will you handle error records BDC? Answer: In real time client will ask error records during BDC upload For that we have to provide him Logs in the form of error file In Session Method Log file you can find directly in SM35 In Call Transaction Method as processing synchronous we have to create a Log file internal table based on structure BDCMSGCOLL which holds log details during processing of application The error records are looped to respective work area which further exported to Funtion Module FORMAT_MESSAGE It returns a Message ID which I will capture by using a dummy internal table
Rohini kumar
SAP-ABAP
477
LSMW: Legacy System Migration Work bench It is convenient tool for migrating Non-SAP (or) Legacy data from one system to another system Difference between BDC & LSMW: BDC 1. Same Flat file can be uploaded Number of times 2. Here recording you have to do Separately using SHDB 3. Mapping is maintained manually Using program
LSMW 1. Use this method for uploading data at one time 2. Recording is in-built 3. Mapping is done by system itself
Method in LSMW: 1. Batch Input Recording (Session Method) 2. IDOC Method 3. BAPI Method 4. Direct Input Method Note: The T code for working with LSMW is LSMW In real time LSMW is mostly performed by Functional Consultant Example: Go to LSMW Project: ZFI_LSMW Sub Project: ZFI_SUBPRO Project: ZFI_SESSION Create Entry Description: LWMW Project Enter Description: Sub Project Enter Name: Session name F8 If Numbering Off is selected get it into Numbering On If Double Click = Display get it into Double Click = Change
Rohini kumar
SAP-ABAP
**** Step-1: Maintain object attributes With this step you can maintain attributes for your method i.e. Method name, Recording details……………etc Select F8 Option Recording Overview Create Recording (Ctrl + F1) Recording: FILSMW Description: Recording Enter Transaction Code: FI01 Enter Bank Country: IN Bank Key: B0001 Enter Bank Name: SBH Street: LBNagar City: Hyderabad Bank Branch: LBNagarBranch Save Double click on BNKA-BANKS Name: BANKS Name: Bank Country Default Value: ____________ Enter Double click on BNKA-BANKL Name: BANKL Name: Bank Key Default Value: ____________ Enter Repeat the same procedure with BNKA-STRAS, BNKA-ORT01, BNKA-BRNCH Save Back Back Batch Input Recording Recording: FILSMW Enter Save Back
Rohini kumar
478
SAP-ABAP
479
Step-2: Maintain source structure With this step source structure is created based on flat file F8 Create Source Structure: ITBANK Description: Bank internal table Enter Save Back Step-3: Maintaing source fields With this step fields are created F8 Select ITBANK Table Maintaince (Ctrl + F9) Field name Type Length BANKS C 3 BANKL C 10 BANKA C 40 STRAS C 40 ORT01 C 40 BRNCH C 40
Description Country Key Name Street City Branch
Save Back Save Back
Step-4: Maintain structure relations With this step recording is linked with source structure ITBANK F8 Save Back Step-5: Maintain field mapping & conversion groups With this step field mapping is done F8 Select BANKS Source Field (Ctrl + F2) You will find a pop-up, Double click on BANKS Select BANKL Source Field (Ctrl + F2) Rohini kumar
SAP-ABAP
480
You will find a pop-up, Double click on BANKL Repeat the same procedure for BANKA, STRAS, ORT01, BRNCH Save Back
Step-6: Maintain fixed values and translating user defined routines With this step routing are linked with LSMW Note: This step is not required ignore it Select Step-7 Step-7: Specify fields With this step flat file is maintained Create a flat file (XL (or) Notepad) in the following manner IN B0001 SBH LBNagar Hyderabad LBNagarBranch
F8 Double click Legacy Data On The PC (Frontend) Apply F4 on File Select your flat file from required path Name: Flat file Delimitor Tablator
Note: If headings are maintained in Flat file it is mandatory to select check Fields Names At Start Of File Enter Save Note: Sometimes you may find an error ‘Field names at start of File………….up to 45 charectors…..remaing data saved’. If you get this error Doublce click on Convert Data File: your flat file path Save Back Rohini kumar
SAP-ABAP
Step-8: Assign fields With this step flat file is linked with source structure FIBANK F8 Save Back Step-9: Read data With this step data is uploaded from flat file to source structure Execute Execute Back Back Step-10: Display read data With this step data in source structure can be viewed Execute Enter Back Step-11: Convert data With this step screen mapping is done. This step is directly linked with Step-1 Execute Execute Back Back Step-12: Display converted data With this step converted data is displayed Execute Enter Back Step-13: Create batch input session With this step session is created Execute Execute You will find a message ‘1 batch input folder with 1 transaction created’, Enter Step-14: Run batch input session With this step session is processed Execute Select your session Rohini kumar
481
SAP-ABAP
Process Enter Enter Enter
Rohini kumar
482
SAP-ABAP
483
09-11-2014 SKIP Functionality: Requirement: Upload material master data with MM01 using flat file with headings & logo Flat File: A-922 A-923
M M
ROH Sodaash ROH Sodaash
Solution: ZMM_MM01_BDC1
Rohini kumar
Kg Kg
R1111 R1111
1000 1000
Kg Kg
800 800
SAP-ABAP
484
BDC with Table Control: Requirement: Upload vendor master data using XK01 using Table Control Flat File: 9444 1000 1000 0001 MR Satya Google LBNagar Hyderabad IN, IN, IN, IN, IN, IN SBI001,SBH001, ICICI001, HDFC001, CANARA001, AXIS001 30941209294, 30941209295, 30941209296, 30941209297, 30941209298, 30941209299 31000 A1 INR Solution: Go to SHDB New Recording Transaction Code: XK01 Start Recording Vendor: 8733 Company Code: 1000 Purchase Org: 1000 Account Group: 0001 Title: MR Name: Satya Search Term: Google Postal Code: 500074 City: Hyderabad Country: IN Enter No data in this screen Enter Country: IN Bank Key: SBH001 Bank Account: 30941209294 Enter Enter Recoun. Amount: 31000 Cash Mng Group: A1 Enter No data in this screen Enter No data in this screen Enter Order Currency: INR Enter Rohini kumar
SAP-ABAP
Save Save Back Select your recording Program Program Name: ZVENDOR_UPLOAD Transfer For Recording Enter Title: BDC for recording Type: Executable Program Source Code Remove starting 3 lines Remove last 3 lines Write your program ZXK01_UPLOAD
Rohini kumar
485
SAP-ABAP
486
File Handling: If flat file is maintaining in presentation server then any-body can manipulated it Even flat files can be maintained in application server also where data is more secure as it is managed by administrator If the flat file is maintained in presentation server then it is a part of Physical File Handling If the flat file is maintained in application server then it is a part of Logical File Handling Opening a File in Application Server in Output Mode (Write Mode): Syntax: OPEN DATASET FOR OUTPUT IN BINARY MODE. ------------------------CLOSE DATASET . Example: Go to SE38 Program: ZSD_OPEN_DATASET Create Title: Opening dataset Type: Executable Program Enter Local Object PARAMETERS p_file(100) TYPE C. INCLUDE ZCUSTOM. OPEN DATASET p_file FOR OUTPUT IN BINARY MODE. SELECT kunnr land1 name1 ort01 pstlz stras FROM KNA1 INTO TABLE it_kna1 UPTO 10 ROWS. LOOP AT it_kna1 INTO wa_kna1 FROM 1 TO 4. TRANSFER wa_kna1 TO p_file. ENDLOOP. CLOSE DATASET p_file. Double click on ZCUSTOM Yes Enter Rohini kumar
SAP-ABAP
Local Object TYPES: BEGIN OF ty_kna1, kunnr TYPE kunnr, land1 TYPE land1, name1 TYPE name1, ort01 TYPE ort01, pstlz TYPE pstlz, stras TYPE stras, END OF ty_kna1. DATA: wa_kna1 TYPE ty_kna1, it_kna1 TYPE TABLE OF ty_kna1.
Activate Back Activate Execute P_file: D:\opendataset.txt Execute
Rohini kumar
487
SAP-ABAP
488
Opening a File in Input Mode (Read Mode): Syntax: OPEN DATASET FOR INPUT IN BINARY MODE. ------------------------CLOSE DATASET . Example: Go to SE38 Program: ZSD_CUSTOMER Create Title: BDC for customer master data Type: Module Pool Save Local Object
Go to SE51 Program: ZSD_CUSTOMER Screen: 100 Create F6 Table: KNA1 Enter Select required fields (kunnr, land1, name1, ort01, pstlz, stras) Enter Place the fields on the screen Place two buttons (INSERT, EXIT) on the screen Provide Text & FCT code of buttons Flow Logic Remove comment for MODULE USER_COMMAND_100 Double click on USER_COMMAND_100 Yes Main Program Enter
TABLES KNA1. Place cursor between MODULE…………ENDMODULE of USER_COMMAND_100 CASE SY-UCOMM. WHEN ‘INSERT’. INSERT KNA1. Rohini kumar
SAP-ABAP
IF SY-SUBRC EQ 0. MESSAGE ‘Record inserted’ TYPE ‘I’. ELSE. MESSAGE ‘Inserting failed’ TYPE ‘E’. ENDIF. WHEN ‘EXIT’. LEAVE TO SCREEN 0. ENDCASE. Activate Back Activate
Go to SE93 Transaction Code: ZCUST Screen: 100 Save
Go to SE38 Program: ZSD_CUSTOMER_BDC Create Title: BDC for customer data Type: Executable Program Enter Enter
PARAMETERS p_file(100) TYPE C. INCLUDE ZCUSTOM. DATA: wa_bdcdata TYPE BDCDATA, it_bdcdata TYPE BDCDATA. OPEN DATASET p_file FOR INPUT IN BINARY MODE. DO. READ DATASET p_file INTO wa_kna1. IF SY-SUBRC NE 0. EXIT. ELSE. REFRESH it_bdcdata. Rohini kumar
489
SAP-ABAP
PERFORM bdc_dynpro USING ‘zsd_customer_bdc’ ‘100’. PERFORM bdc_field USING: ‘kna1-kunnr’ wa_kna1-kunnr, ‘kna1-land1’ wa_kna1-land1, ‘kna1-name1’ wa_kna1-name1, ‘kna1-ort01’ wa_kna1-ort01, ‘kna1-pstlz’ wa_kna1-pstlz, ‘kna1-stras’ wa_kna1-stras, ‘bdc-okcode’ ‘/00’. CALL TRANSACTION ‘ZCUSTOM’ USING it_bdcdata MODE ‘A’. ENDIF. ENDDO. CLOSE DATASET p_file. FORM bdc_dynpro USING prog screen. CLOSE wa_bdcdata. wa_bdcdata-program = prog. wa_bdcdata-dynpor = screen. wa_bdcdata-dynbegin = ‘X’. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. FORM bdc_field USING field value. CLOSE wa_bdcdata. wa_bdcdata-fname = field. wa_bdcdata-fval = value. APPEND wa_bdcdata TO it_bdcdata. ENDFORM. Execute P_file: D:\opendataset.txt
Rohini kumar
490
SAP-ABAP
491
Assignment-1: Upload asset master data with AS02 using Call Transaction Method Flat File: Asset number 3000006
Sub asset number Company code 0 0005
Recording: Go to SHDB New Recording Recording: ZREC_AS02 Transaction Code: AS02 Start Recording Asset: 3000003 Sub Number: 0 Company Code: 0005 Enter Quantity: 200 Save Back Save Solution: Go to SHDB Select your recording Program Title: BDC for AS02 Type: Executable Program Source Code Remove first 3 lines Remove last 2 lines & write your program
Rohini kumar
Qunatity 300
SAP-ABAP
492
Assignment-2: Upload employee payroll for infotype 14 with PA30 using Call Transaction Method Flat File: Employee number 1000 1001 1002
Amount 3000 5000 7000
Recording: Go to SHDB New Recording Recording: ZREC_PA30 Transaction Code: Pa30 Start Recording Employee number: 1000 Infotype: 14 Sty: M110 F6 Start: 01.04.2013 To: 31.03.2014 Wage Type: M110 Amount: 3000 Save Back Save Solution: Go to SHDB Select your recording Program Title: BDC for PA30 Type: Executable Program Source Code Remove first 3 lines Remove last 2 lines & write your program
Rohini kumar
SAP-ABAP
493
SAP Scripts: Using Scripts you can design Forms & send the data for print outs Components of Scripts: 1. Form 2. Page 3. Window 4. Page Window 5. Layout 6. Paragraph Formats 7. Character Formats 8. Header Form: It is a collection of pages Page: It is a collection of windows Window: It is the smallest element of a form, which holds actual data Page Window: Using this option windows are maintained in a page in SAP Scripts Layout: All windows are adjusted in a page using layout Paragraph Formats: With this option you can maintain Font size, Style, Color, Underline……….etc for text on a form Character Formats: Using this option you can maintain Font size, Style, Color…….etc for text (for special characters in a form) Header: Using header administrative data (client number, date of creation, date of change, user id……..etch) is maintained
Rohini kumar
SAP-ABAP
494
*** Types of Windows: 1. Main Window 2. Constant Window 3. Variable Window Main Window: It is a default window in forms Use this window for maintaining dynamic length data (transactional data) In one page you can maintain 99 Main Windows (Main 00 to Main 98) Note: Without Main Window you cannot work with Scripts Constant Window: It is reflected to all the pages of a form Note: Maintain Logos, Headers, Footers……….etc using this window Variable Window: It is restricted to a specific page Flow of Data in Scripts: (Printer, Fax…….etc) External Devices
SAPLD
Form
SE38
Driver Program
Database
Rohini kumar
SAP-ABAP
Note: SAPLD provides interface between Form Painter & External Devices Note: T code for working with Scripts is SE71 Flow of Creating Form (Steps): 1. Page 2. Paragraph Formats 3. Character Formats 4. Assign paragraph formats to header 5. Create windows 6. Assign all windows to page using page window 7. Write logic for each window 8. Adjust all windows in layout 9. Activate form 10.Create driver program (print program)
Rohini kumar
495
SAP-ABAP
496
Requirement: Goods receipt form Heading
Logo
User:
Page: 3 of 60
Date: Sno
matnr movement type
quantity
amount
Page Total:
Heading
Logo
User:
Page: 3 of 60
Date: Sno
Carry forward amount: matnr movement type
quantity
amount
Heading
Logo Page Total:
User:
Page: 3 of 60
Date: Carry forward amount: Sno
matnr movement type
quantity
amount
Grand Total:
Solution: Step-1: Form Go to SE71 Form: ZFORM_GRN Rohini kumar
SAP-ABAP
Create You will find a message, Enter Meaning: GRN Form Step-2: Select Pages Page: PAGE1 Next Page: PAGE1 Enter Meaning: page1 Step-3: Select Paragraph Formats Paragraph: P1 Enter Meaning: p1 Font Family: COURIER Font Size: 12 BOLD ON Step-4: Select Character Formats Char. Format: C1 Enter Meaning: c1 Family: HELVE Size: 10 BOLD ON Step-5: Select Header (F5) Basic Settings First Page: PAGE1 Default Paragraph: P1 Step-6: Select Windows Edit ------ Create Element Window: LOGO Meaning: window Enter Rohini kumar
497
SAP-ABAP
498
Window Type: CONST Edit ------- Create Element Window: PAGE Meaning: window Enter Repeat the same procedure for USER, HEADER, HEADER1
Step-7: Select Page Windows Edit ----- Create Element You will find a pop-up, Double click on HEADER Window Width: 5 Window Height: 5 Edit ----- Create Element Double click on HEADER1 Window Width: 5 Window Height: 5 Edit ----- Create Element Repeat the same procedure for USER, PAGE, MAIN, CONST, LOGO windows Note: When you maintain MAIN window using Page Windows you will get MAIN window again in the pop-up (as we can maintain 99 MAIN windows in a Page). So next time you don’t select it Step-8: Double click on MAIN window Edit ----- Text Elements Goto ----- Change Editor /: /E /: /: * /: /: * * = /E * *
SUMMING &wa_msg-dmbtr& INTO &wa_sum& ELEL TOP IF &page& NE 1 ,,,,,,,,,,Carry forward amount: &wa_sum& ENDIF ENDTOP &sno&,,&wa_mseg-matnr&,,&wa_mseg-bwart&,,&wa_mseg-menge& &wa_mseg-dmbtr& PAGE_TOTAL &uline(60)& ,,,,,,,,,,Page total: &wa_sum&
Rohini kumar
SAP-ABAP
* /E GRAND_TOTAL * &uline(60)& * ,,,,,,,,,,Grand total: &wa_sum& Back Step-9: Double click HEADER window Edit ----- Text Elements Goto ----- Change Editor /: * * *
BOX WIDTH 7 CM HEIGHT 4 LN FRAME 4 TW INTENSITY 8 ,,Reddy labs An Anji Reddy Group Ameerpet-500074 Back Next Page
Step-10: Double click on HEADER1 window Edit ----- Text Elements Goto ----- Change Editor * &uline(60)& * * Sno,,,,Material,,,,Material Type,,,,Quantity,,,,Amount * &uline(60)& Back Step-11: Double click on LOGO window Edit ----- Text Elements Goto ----- Change Editor /: BITMAP enjoy OBJECT GRAPHICS ID BMAP TYPE BCOL Back Next Page Step-12: Double click on PAGE window Edit ----- Text Elements Goto ----- Change Editor Rohini kumar
499
SAP-ABAP
/: BOX WIDTH 5 CM HEIGHT 1 LN FRAME 4 TW * PAGE &page& OF &sapscript_jobpages& Back Step-13: Double click on USER window Edit ----- Text Elements Goto ----- Change Editor /: BOX WIDTH 5 CM HEIGHT 2 LN FRAME 4 TW * USERNAME: &sy-uname& * DATE: &sy-datum& Back Step-14: Select Settings Form Painter By default graphical pc editor selected, Deselect it Select Graphical Form Painter Enter Adjust all the windows according to the size of data Select Minimize Settings ------ Form Painter Deselect Graphical Form Painter check box Select Graphical PC Editor check box Select Utilities -------- Printing Text You will find a pop-up Output Device: LP01 Print Preview Form Activate Local Object Step-15: Go to SE38 Program: ZGRN_FORM Create Title: Forms for GRN details Type: Executable Program Enter Local Object Write driver program Rohini kumar
500
SAP-ABAP
501
ZGRN_COL_FORM TYPES: MKPF, MSEG. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_mblnr FOR mkpf-mblnr, s_werks FOR mseg-werks, s_bukrs FOR mseg-bukrs, s_budat FOR mkpf-budat. SELECTION-SCREEN: END OF BLOCK b1. TYPES: BEGIN OF ty_mseg, matnr TYPE matnr, bwart TYPE bwart, menge TYPE menge_D, dmbtr TYPE dmbtr, END OF ty_mseg. DATA: wa_mseg TYPE ty_mseg, it_mseg TYPE TABLE OF ty_mseg. DATA: sno TYPE I, wa_sum TYPE DMBTR. PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM
get_mseg. open_form. start_form. process_form. end_form. close_form.
FORM get_mseg. SELECT mseg~matnr mseg~bwart mseg~menge mseg~dmbtr INTO TABLE it_mseg FROM MKPF INNER JOIN MSEG ON mkpf~mblnr = mseg~mblnr WHERE mkpf~mblnr IN s_mblnr AND mseg~werks IN s_werks AND mseg~bukrs IN s_bukrs AND mseg~budat IN s_budat. ENDFORM. FORM open_form. Rohini kumar
SAP-ABAP
CALL FUNCTION ‘OPEN_FORM’. EXPORTING LANGUAGE = SY-LANGU FORM = ‘ZFORM_GRN’. ENDFORM. FORM start_form. CALL FUNCTION ‘START_FORM’ EXPORTING STARTPAGE = ‘PAGE1’ LANGUAGE = SY-LANGU FORM = ‘ZFORM_GRN’. ENDFORM. FORM process_form. LOOP AT it_mseg INTO wa_mseg. sno = sno + 1. CALL FUNCTION ‘WRITE_FORM’ EXPORTING ELEMENT = ‘ELE1’ WINDOW = ‘MAIN’. IF sno = 8. CALL FUNCTION ‘WRITE_FORM’ EXPORTING ELEMENT = ‘PAGE_TOTAL’ WINDOW = ‘MAIN’. CALL FUNCTION ‘CONTROL_FORM’ EXPORTING COMMAND = ‘NEW-PAGE’. sno = 0. ENDIF. AT LAST. CALL FUNCTION ‘WRITE_FORM’ EXPORTING ELEMENT = ‘GRAND_TOTAL’ WINDOW = ‘MAIN’. ENDAT. Rohini kumar
502
SAP-ABAP
ENDLOOP. ENDFORM. FORM end_form. CALL FUNCTION ‘END_FORM’. ENDFORM. FORM close_form. CALL FUNCTION ‘CLOSE_FORM’. ENDFORM.
Execute driver program Material Doc: 49000000 to 49000100 Execute You will find a pop-up, Output Device: LP01 Print Preview
Rohini kumar
503
SAP-ABAP
Function Modules for Print Program: 1. OPEN_FORM: Activates a form in SAP Scripts (pass Form name & Language) 2. STRAT_FORM: It opens a form from a specific page (pass Form name & Page name) 3. WRITE_FORM: It is for calling text elements in SAP Scripts (pass Text element name & Window name) 4. END_FORM: It is for closing START_FORM 5. CLOSE_FORM: It is for closing OPEN_FORM Script Symbols: 1. * ----- default paragraph 2. ----- continous text 3. = ------- extended line 4. / ------- line field (one line gap) 5. /= ------ line field & extended line 6. /: ------ command line (it is for script commands i.e. BOX, BITMAP) 7. /* ------ comment line 8. /E ------ text element 9. TW ---- twip 1 TW = 1/20 PT (points) 1 PT = 1/72 inches Debugging SAP Scripts: Go to SE71 Form: ZFORM_GRN Utilities ------ Activate Debugger Go to SE38 Program: ZGRN_COL_FORM Debugging
Rohini kumar
504
SAP-ABAP
505
Assignment: PO Form Heading
Logo
Vendor Number:
PO Number:
Vendor Name:
PO Date:
Address: Item no Item description
UOM
PO Quantity
UPrice Tprice
Total Amount: PO Quantity: Pending Quantity: Delivery Quantity:
Logic: * Item number &space(5)&Item description &space(30)& Unit of measurement &space(5)& PO Quantity &space(5)& Unit price &space(5)& Total price &space(5)& / BOX FORM 4 TW / BOX HIEGHT 2 LN FRAME 4 TW INTENSIVILY 8 / BOX WIDTH ‘15’ CH HIEGHT ‘15’ LN FRAME 4 TW / BOX WIDTH ‘30’ CH HIEGHT ‘15’ LN FRAME 4 TW Solution: ZGRN_FORM
Rohini kumar
SAP-ABAP
506
10-11-2014 Standard Forms: SAP is providing standard forms which are stored in a table TNAPR In these standard forms we have to make our own modifications based on requirement & customize the same in NACE T-code Example: Step-1: coping a standard form into user defined form Go to SE71 Utilities ----- Copy From Client Form Name: MEDRUCK Source Client: 800 Target Form: ZPO_MEDO Execute Package: YABAP Enter Create Request Step-2: adding a logo in a form Go to Paint Design a logo Save it on desktop
Go to SE78 Expand Graphics-General Graphics Double click on BMAP-Bit Map Images Graphics ---- Input Apply F4 on File Name Select your logo Name: SCRIPTLOGO Description: script logo Color Bit Map Image Enter Graphic Transport Enter
Go to SE71 Form: ZPO_MEDD Change Page Windows Try to find HEADER window by selecting Next Page option
Rohini kumar
SAP-ABAP
Double click on HEADER window Edit ---- Text Elements Goto ---- Change Editor Place cursor on INCLUDE Apply End by keyboard Enter /: BITMAP SCRIPTLOGO OBJECT GRAPHICS ID BMAP TYPE BCOL Back Form ---- Activate Utilities ----- Printing Test Print Preview Step-3: adding a field lable based on logic Go to SE71 Form: ZPO_MEDO Change Page Windows Double click on INFO1 window Edit ---- Text Elements Goto ---- Change Editor Place cursor starting of 1st line Apply 4 times Enter & see that existing code should not be deleted AS Modifing Layout /: IF ekko-lifnr > 1001 / Plant ID is 1001 /: ENDIF Back Form ----- Activate Step-4: customizing a form in NACE T-code Note: This job is done by MM Functional Consultant
Go to NACE Application EF Output Types Position Output Type: NEU Enter Select NEU On left side double click on processing Routines
Rohini kumar
507
SAP-ABAP
Display / Change Form: ZPO_MEDD Save Enter
Step-5: testing the application with ME9F Go to ME9F Vendor: 1000 to 3000 Execute Select any one check box Display Message Step-6: transporting a form from one client to another client Note: We know that SAP Script is client dependant Using program RSTXR3TR we can transport a form from one client to another client
Go to SE10 Display Expand Main request number Select sub request number Select Truck symbol Relase Select main request number Select Truck symbol Relase
Go to SE38 Program: RSTXR3TR Execute Transport Request: LID0001 Export File Name: ‘ZPO_MEDD’ Execute
Log on to 810 client Go to SE38 Program: RSTXR3TR Execute Transport Request: LID0001 Import File Name: ZPO_MEDD Execute Go to SE71-------- Form: ZPO_MEDO---------- Change
Rohini kumar
508
SAP-ABAP
509
**Smart Forms: It is a smartest way of working with forms ** Difference between Scripts & Smart Forms: Script Smart Forms 1. It is client dependent 1. It is client independent 2. Table is created manually using BOX 2. Table can be created automatically through navigation 3. Data transfer between Print Program & 3. Data transfer between Print Program & Form is record by record (window by window) Form at one time using a unique Function Module 4. Paragraph formats & character formats 4. Paragraph formats & character formats Cannot be reuse can be reuse 5. Back ground pictures cannot be created 5. Can be created 6. With out MAIN window you cannot work 6. You can work without MAIN window With Scripts also 7. You cannot work with Scripts without 7. You can work Print Program 8. ** Templates cannot be created 8. Can be created Components of Smart Forms: 1. Form 2. Style 3. Text Module Form: It is a collection of Pages Style: It is for Paragraph Formats & Character Formats Text Module: Maintains conditional data Types of Windows: 1. Main Window 2. Secondary Window 3. Final Window 4. Copies Window Main Window: Use this for holding dynamic length data (transactional data) Rohini kumar
SAP-ABAP
510
Note: Without Main window also you can work with Smart Forms Secondary Window: Use this for holding fixed length data (master data) Final Window: Use this for holding final data (totals, grand totals) Copies Window: Use this for copy (or) original format data **Components of Window: 1. Text (maintains logic) 2. Template (static tables can be created) 3. Folder (holds different components together) 4. Address (maintains address) 5. ** Program Lines (create program) 6. Command (maintains page breaks) 7. Alternate (flip flop logic (if condition)) 8. Loop (maintains loops) 9. Table Line (different cells logic) 10.Table (holds data dynamically) 11.Graphic (maintains logo) Flow of Data in Smart Forms: (Printer, Fax…….etc) External Devices
Smart Form
Driver Program (Unique Function Module)
Database Rohini kumar
SAP-ABAP
Steps in Working of Smart Forms: 1. Create style (paragraph formats & character formats) 2. Create form 3. Form 3.1. Form interface (import & table parameters) 3.2. Form attributes (maintain styles) 4. Global definitions (create global variables) 5. Create page 5.1. Background picture 5.2. ** Print mode for duplex 6. Create windows 6.1. Graphics window 6.2. Text window 6.3. Alternate window 6.4. Table window 6.5. Template window 6.6. Main window……………..etc 7. Adjust windows in a layout (form painter) 8. Activate form 9. Create print program Note: T code for working with Smart Forms is SMARTFORMS
Rohini kumar
511
SAP-ABAP
512
Requirement: PO Form Heading
Logo
Vendor Number:
PO Number:
Vendor Name:
PO Date:
Address: Item no Item description
PO Quantity
UPrice Tprice
Total Amount: PO Quantity: Pending Quantity: Delivery Quantity: Page Number
Solution: Step-0: creating structure Go to SE11 Data Type: ZPO_STRUC Create Structure Enter Short Description: structure for PO details Component Compenent type EBELP EBELP MAKTX MAKTX MENGE MENGE NETPR NETPR NETWR NETWR Currency / Quantity Rohini kumar
SAP-ABAP
Reference table EKPO T001 T001 Activate
513
Reference field MEINS WAERS WAERS
Step-1: (creating Paragraph Format & Character Format) Go to SMARTFORMS Style: ZPO_STYLE Create P1 -Paragraph Format: Right click on Paragraph Formats Create Node Paragraph Formats: P1 Enter Description: p1 Font Font Family: COURIER Font Size: 12 Font Style: BOLD P2 -Paragraph Format: Right click on Paragraph Formats Create Node Paragraph Formats: P2 Enter Description: p2 Indents and Spacing Alignment: CENTER Font Font Family: HELVE Font Size: 15 Font Style: BOLD P3- Paragraph Format: Right click on Paragraph Formats Create Node Paragraph Formats: P3 Enter Description: p3 Indents and Spacing Rohini kumar
SAP-ABAP
514
Alignment: CENTER Font Font Family: HELVE Font Size: 12 Font Style: BOLD
C1- Character Format: Right click on Charector Formats Create Node Charector Formats: C1 Enter Font Font Family: HELVE Font Size: 10 Font Style: BOLD Doble click on Header Data Standard Paragraph: P1 Style----- Activate Enter Back Step-2: creating Form (Import & Table parameters) Form: ZPO_FORM Create You will find a form, the left part is called Navigation Tree, the right part is called Maintain Screen. Using Form Painter you can design layout By default Form Attributes is selected, on Maintaince Screen select Output Options tab Style: ZPO_STYLE Import parameters: Double click on Form Interface By default Import tab is selected, provide Parameter name Type assignment Associated type EBELN TYPE EBELN BEDAT TYPE BEDAT LIFNR TYPE LIFNR Table parameters: Tables Parameter name Type assignment Associated type IT_EKPO LIKE ZPO_STRUC Rohini kumar
SAP-ABAP
515
Step-3: creating Global variables Double click on Global Definaitions Variable name Type assignment Associated type TOTAL TYPE DMBTR WA_EKPO TYPE ZPO_STRUC Types TYPES: BEGIN OF ty_lfa1, lifnr TYPE lifnr, name1 TYPE name1, adrnr TYPE adrnr, END OF ty_lfa1. TYPES: BEGIN city1 street END
OF ty_adrc, TYPE ort01, TYPE stras, OF ty_adrc.
Global Data Variable name Type assignment Associated type WA_LFA1 TYPE TY_LFA1 WA_ADRC TYPE TY_ADRC Form Routines Currency / Quantity Fields Field name Reference table Wa_ekpo-menge wa_ekpo-menge Wa_ekpo-netpr wa_ekpo-netpr Wa_ekpo-netwr wa_ekpo-netwr
Data type quan curr curr
Step-4: creating windows (LOGO, PO, PAGE, HEADER, VENDOR) Logo window: Right click on PAGE1 Create------- Window Window: LOGO Meaning: window for logo Enter Right click on LOGO window Create ------ Graphic Apply F4 on Name field Rohini kumar
SAP-ABAP
516
You will find a pop-up Color Bit Map Image check box & Deselect Block and White Image check box Execute Select any one Logo based on your requirement Note: 1. In real time logo is provided by client 2. While creating logo you can adjust the size of the logo using Resolution option 3. Double click on PAGE1 on maintaince screen you will find Background Picture option with this you can maintain background pictures in Smart Forms 4. Select Output Options tab under that you will find Print Mode. If Print Mode is D you can provide double side printing 5. By default Page Format is Potrate Format which is for form with less fields. If form contains more fields (say 15, 20,…….etc) use Landscape Format PO window: Right click on LOGO window Create ------- Window Window: PO Meaning: template for po Enter Right click on PO window Create ------ Template To increase the Width & Height of a template, double click on PO window On maintaince screen select Output Options tab Width: 10 Height: 10 Note: Only upto 25 only we can provide for Height & Width
Enter Double click on Template 1 Select Template tab Increase the width of a template based on your requirement Right click on C1 Split ------ Line Right click on C1 Split ------ Cell Right click on C2 Split ------ Cell Under Template tab, select Pattern option (1st button)
Rohini kumar
SAP-ABAP
By default all the patterns are deselected, select Display Framed Patterns option Double click on 2nd pattern Right click on Template 1 Create ----- Folder 1 Right click on Folder 1 Create ------ Text Right click on Text 1 Create ------ Text Similarly create 3 more texts (Text2, Text3, Text4) Double click on Text1 On maintaince screen, select Output Options tab Scroll down to bottom Line: 1 Coloumn: 1 Double click on Text2 On maintaince screen, select Output Options tab Scroll down to bottom Line: 1 Coloumn: 2 Double click on Text3 On maintaince screen, select Output Options tab Scroll down to bottom Line: 2 Coloumn: 1 Double click on Text4 On maintaince screen, select Output Options tab Scroll down to bottom Line: 2 Coloumn: 2 Double click on Text1 Select Conditions Output Options Web Properties General Attributes Select Edit option PO Number (or) Goto ----- Change Editor * PO Number Back Double click on Text2 Rohini kumar
517
SAP-ABAP
Select Edit option Goto ---- Change Editor P1 &EBELN& Back (or) Select Field List ON/ OFF option At bottom expand Import interface Drag & drop EBELN on Editor Double click on Text3 Select Edit option PO Date Double click on Text4 At bottom expand Import interface Drag & drop BEDAT on Editor PAGE window: Right click on PO window Create ------ Window Window: PAGE Meaning: page number Enter Right click on PAGE window Create ---- Text At bottom expand System Fields Drag & drop PAGE on Editor (&SFSYT-PAGE&) Note: SFSY-is a standard structure for Smart Forms sytem fields HEADER window: Right click on PAGE window Create ----- Window Window: HEADER Meaning: widow for header text Enter Right click on HEADER window Create ----- Text Double click on Text5 Select Editor option Goto ------ Change Editor Rohini kumar
518
SAP-ABAP
P2 REDDY LABS P2 ,,,,,,An Anji Reddy group P2 ,,,,,, Ameerpet-10 Back VENDOR window: Right click on HEADER window Create ------ Window Window: VENDOR Meaning: window for vendor details Enter Right click on VENDOR window Create ----Flow Logic -----Program Lines Input parameters Output parameters LIFNR WA_LFA1 WA_ADRC SELECT SINGLE name1 FROM LFA1 INTO wa_lfa1 WHERE lifnr = lifnr. IF NOT wa_lfa1 IS INITIAL. SELECT SINGLE city1 street FROM ADRC INTO wa_adrc WHERE addrnumber = wa_lfa1-kunnr. Execute Right click on CODE1 Create ----- Text Expand Global Data option Expand WA_LFA1 Editor option Goto ---- Change Editor * Vendor Number: &WA_LFA1-LIFNR& * Vendor Name: &WA_LFA1-NAME1& * City: &WA_LFA1-CITY1& * Street: &WA_LFA1-STREET& MAIN window: Right click on MAIN window Create ----- Table On maintaince screen you will find %LTYPE1 Split %LTYPE1 into 5 equal parts Right click on %LTYPE1 Insert ------ Empty Line Underneath Split %LTYPE2 into 2 parts Under Table tab Rohini kumar
519
SAP-ABAP
Select Pattern option Select Display Framed Patterns Double click on 2nd pattern Select Data tab Internal Table: IT_EKPO Into; WA_EKPO Select Calculations tab Operation Field name Target field SUM total wa_ekpo-netwr total Expand HEADER option under Tables Right click on HEADER Create ----- Table Line Line Type: %LTYPE1 Right click on %CELL1 Create --- Text Conditions Output Options Web Properties General Attributes Edit Goto ----- Change Editor P3 Item Number Right click on %CELL2 Create --- Text Editor Goto --- Change Editor P3 Item Text Right click on %CELL3 Create --- Text Editor Goto --- Change Editor P3 PO Quantity Right click on %CELL4 Create --- Text Editor Goto --- Change Editor P3 Unit Price Rohini kumar
520
Time after loop
SAP-ABAP
Right click on %CELL5 Create --- Text Editor Goto --- Change Editor P3 Total Price Right click on MAIN window Create ----- Table Line Line Type: LTYPE1 Right click on %CELL6 Create --- Text Conditions Output Options Web Properties General Attributes Editor Goto --- Change Editor P3 &WA_EKPO-EBELP& Right click on %CELL7 Create --- Text Editor Goto --- Change Editor P3 &WA_EKPO-ARKTX& Right click on %CELL8 Create --- Text Editor Goto --- Change Editor P3 &WA_EKPO-MENGE& Right click on %CELL9 Create --- Text Editor Goto --- Change Editor P3 &WA_EKPO-NETPR& Right click on %CELL10 Create --- Text Editor Rohini kumar
521
SAP-ABAP
Goto --- Change Editor P3 &WA_EKPO-NETWR& Right click on Footer option Create ----- Table Line Line Type: LTYPE2 Right click on CELL11 Create ---- Text Conditions Output Options Web Properties General Attributes P3 Total Amount Back Right click on CELL12 Create ----- Text Editor Goto ---- Change Editor P3 &TOTAL& Back Step-5: adjust windows in a layout Select Form Painter option Adjust all the windows in layout as per client requirement (based on data size) The MAIN widow size should be large as it holds item data Form Painter Step-6: activating form Select Activate Step-7: creating driver program Go to SE38 Program: ZMM_CALL_SMART_FORM Create Title: Driver program for smart form Type: Executable Program Enter Enter Write your driver program
Rohini kumar
522
SAP-ABAP
523
12-11-2014 Note: SSF_FUNCTION_MODULE_NAME: This function module returns a smart form function module generated on activation of smart form Ques-1: Why we should call SSF_FUNCTION_MODULE_NAME instead of hard coding the function module name itself? Answer: We know that in real time we have to transport the objects from one client to another client If the form is in Quality Server the system may assign a different version of function module name to respective form & the same happen in Production Server also So therefore it always advisable to call SSF_FUNCTION_MODULE_NAME which returns the function module currently which system you are working Ques-2: What are the common errors you are facing while working with smart forms? Answer: 1. Incorrect parameter with call function This exception you will get if you not pass all the parameters which you maintained in smart form 2. Type conflict when calling a function module This exception you will find when data type of smart form parameters will not match with attributes of print program 3. Reference field …………unknown in form This error you will find if you are not maintaining Currency / Quantity fields in smart form 4. *** sometimes your print program will not be executed at all This will happen when your Window (specially Templates) are not maintained properly 5. Template does not fit into window This will happen when template height is more than window height 6. Form generation error This error you will find if form is having internal errors in Production Server thow it is perfectly tested in Development Server
Rohini kumar
SAP-ABAP
524
7. *** Table is wider than window This error you will find if your Table (or) Template is wider than your window based on which is created 8. Graphic cannot be displayed This error you will find if graphic is not maintained properly Ques-3: How do you work with Alternate option in smart form? Answer: Righ click on any one Window (say LOGO) Create ----- Window Alternate Right click on Alternate Window Create ----- Flow Logic ------- Alternate Conditions option Field name Relational Operator LIFNR double click Select =/= (NE) option Comparision Values ‘ ’ Right click on True option Create ------ Text Editor PO Created
Right click on Flase option Create ----- Text Editor PO not created
Form Painter Adjust Alternate window Activate form Ques-4: How you can work with more than one Page in smart form? Answer: Right click on PAGE1 Create ------ Page Right click on PAGE2 Rohini kumar
SAP-ABAP
Create ---- Window Window: LETTER Meaning: Window for letter description Save Right click on LETTER window Create ----- Text Editor Goto ------ Change Editor * ,,,,,,,,,,Dear Satya, * ,,,,,,,,,,Yor are shortlisted in Google as a Technical Consultant * ,,,,,,,,,,Thanking you,
Back Double click on MAIN window Window Type: Secondary Window Double click on PAGE1 Next Page: PAGE2 Double click on PAGE2 Next Page:______ Activate form
*** Ques-5: How you can convert a smart form into PDF format? Answer: Run your print program Provide input Execute Select Print option (Ctrl + P) At bottom you will find a print request number note down it (say 11,5716) Go to SE38 Program: RSTXPDFT4 Execute Spool Request: 11,5716 Execute Save Ques-6: How you can debug a smart form? Answer: Go to SMARTFORMS Form: ZPO_FORM Change Rohini kumar
525
SAP-ABAP
526
Expand VENDOR window Double click on CODE1 Provide BREAK-POINT Activate form Go to SE38 Program: ZMM_CALL_SMART_FORM (print program) Execute
Note: In smart forms you can set only Static Break Point. You cannot set Dynamic Break Point Ques-7: How you can work with Excel Sheet in smart forms? Answer: DATA fnam TYPE STRING. CALL FUNCTION ‘GUI_DOWNLOAD’ Ques-8: How you can print multiple records in smart forms? Answer: ZMM_CALL_SMART_FORMN TABLES: EKPO, EKKO, LFA1, ADRC. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_ebeln FOR ekko-ebeln. SELECTION-SCREEN: END OF BLOCK b1. DATA: fname TYPE RS38L_FNAM, control TYPE SSFCTRLOP. DATA: BEGIN OF wa_ekko, ebeln TYPE ebeln, bedat TYPE bedat, lifnr TYPE lifnr, END OF wa_ekko. DATA: wa_ekpo TYPE zpo_strucc, it_ekpo TYPE TABLE OF zpo_strucc. DATA: fnam TYPE STRING. Rohini kumar
SAP-ABAP
CONTROL-NO_OPEN CONTROL-PREVIEW CONTROL-NO_DIALOG CONTROL-NO_CLOSE
527
= ‘X’. = ‘X’. = ‘X’. = ‘X’.
START-OF-SELECTION. CALL FUNCTION ‘SSF_OPEN’ EXPORTING USER_SETTINGS = ‘X’. CONTROL_PARAMETERS = control. CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’ EXPORTING FORMNAME = ‘ZPO_FORM’ IMPORTING FM_NAME = FNAME. LOOP AT S_EBELN. PERFORM get_data USING s_ebeln-low. CALL FUNCTION FNAME EXPORTING CONTROL_PARAMETERS = control EBELN = s_ebeln-low BEDAT = wa_ekko-bedat LIFNR = wa_ekko-lifnr TABLES IT_EKPO = it_ekpo. ENDLOOP. CALL FUNCTION ‘SSF_CLOSE’. FORM get_data USING ORDER. SELECT SINGLE ebeln bedat lifnr FROM EKKO INTO wa_ekko WHERE ebeln EQ ORDER. IF NOT wa_ekko IS INITIAL. SELECT ebelp txz01 menge netpr netwr FROM EKPO INTO TABLE it_ekpo WHERE ebeln = wa_ekko-ebeln. ENDIF. ENDLOOP. Rohini kumar
SAP-ABAP
Ques-9: How you can migrate SAP Script to smart form? Answer: Go to SMARTFORMS Utilities ---- Migration ----- Import SAP Script Form Form: ZPO_MEDD Name: ZPO_MEDD Enter Ques-10: How you can generate smart form into PDF format during runtime of print program? Answer:
Ques-11: How you can send of a form in the form of mail? Answer: Ques-12: How you can write code in smart forms? Answer: Ques-13: How you can maintain Page Breaks in smart forms? Answer:
Rohini kumar
528
SAP-ABAP
529
13-11-2014 SAP Enhancements: SAP is highly customizable Using SAP Enhancements you can add additional functionalitites in existing once without disturbing the same Types of SAP Enhancements: 1. Userexits 2. Customerexits 3. BADI 4. Enhancement Frame Work 5. BTE Userexits: Userexits are empty code blocks within subroutines Object: Validate sales order application using Userexits Business Requirements: In real time using VA01 application sales order is created which is again modified by using VA02 Write an enhancement to validate VA02 such that one user created sales order is allowed to modify is by same user only Solution: Go to SE38 Program: MV45AFZB Display Select Enhance option Edit ---- Enhancement Operations ----- Show Implicit Enhancement Options Try to search for USEREXIT_CHECK_VBAK subroutine Right click on spot under form USEREXIT_CHECK_VBAK Enhancement Implementation ----Create Implementation You will find a message, select Code option You will find a pop-up, select Create option Again you will find a pop-up, provide Enhancement Implementation: ZENC_VA02 Short Text: enhancement for VA02 implementation Enter Enter Rohini kumar
SAP-ABAP
Enter Again you will find that pop-up, select your Enhancement name i.e. ZENC_VA02 Enter IF SY-TCODE EQ ‘VA02’. IF VBAK-ERNAM NE SY-UNAME. MESSAGE ‘Access denied’ TYPE ‘E’. ENDIF. ENDIF. Activate Testing the Application: Go to VA02 Order: 4969 Enter You will find a pop-up, Enter Navigation for Deleting Enhancement: Go to SE38 Program: MV45AFZB Display Enhance Place cursor on your enhancement name i.e. ZENC_VA02 Right click on it Enhancement Implementation ----- Undo Implementation Activate Note: MV45AFZB & MV45AFZZ are the very important Userexits for VA01, VA02 application which we are working in real time Currently Userexits are outdated except above
Rohini kumar
530
SAP-ABAP
531
Customerexits: Customerexits are advanced to Userexits Instead of adding customization in existing code it is always better to provide your own customization using a T code which is done by Customerexits Note: Customerexits is based on Fucntional Consultant Types of Customerexits: 1. Function Exits 2. Menu Exits 3. Screen Exits 4. Field Exits Function Exits: Object: Validate vendor master application for postal code Business Requirement: Some times users will not enter Postal code, City, Tax code……..etc in an application which are optional but important for clients Provide validation such that without entering Postal code the transaction should not be created Note: ** The T code for working Customerexits is CMOD ** The T code for identifying Customerexits for an application is SMOD Solution: Step-1: identifying Package name of an application Go to XK01 System -----Status Double click on Program Name Goto ---- Attributes Note down package name (FBK) Step-2: identifying Customerexits for an application Go to SMOD Apply F4 on Enhancement field You will find a pop-up, at bottom select Information System button Package: FBK Rohini kumar
SAP-ABAP
532
Enter Note down Customerexits (SAPMF02K) Note: In real time Customerexits for an application is provided by Functional Consultant Step-3: writing enhancement Go to CMOD Project: ZENC_XK01 Create Short Text: customerexits for xk01 Save Enhancement Assignments button Select your enhancement SAPMF02K Enter You may find an error message ‘SAP enhancement……….SAPMF02K already belongs to project……….’ If you are getting such error you have to delete the old enhancement Deleting Customerexits Enhancement: Note down old enhancement name (ZH1XK01) Go to /OCMOD Project: ZH1XK01 Deactivate Delete option Yes Enter Note: ** In Customerexits you cannot reuse the same exit in more than one project Select Components option Yes Double click on function module EXIT_SAPMF02K_001 Scroll down to bottom Double click on INCLUDE IF I_LFA1-PSTLZ IS INITIAL. MESSAGE ‘Enter postal code’ TYPE ‘E’. ENDIF. Activate Back Rohini kumar
SAP-ABAP
Back Back Activate project Testing the Application: Go to XK01 Vendor: 4275 Create
Rohini kumar
533
SAP-ABAP
534
Menu Exits: Add a menu in MC94 application Solution: Step-1: identifying Package name of an application Go to MC94 System -----Status Double click on Program Name Goto ---- Attributes Note down package name (MCP2) Step-2: identifying Customerexits for an application Go to SMOD Apply F4 on Enhancement field You will find a pop-up, at bottom select Information System button Package: MCP2 Enter Note down Customerexits (MCP20003) Step-3: writing enhancement Go to CMOD Project: ZENC_MC94 Create Short Text: customerexits for mc94 Save Enhancement Assignments button Select your enhancement MCP20003 Enter You may find an error message ‘SAP enhancement……….MCP20003 already belongs to project……….’ If you are getting such error you have to delete the old enhancement Deleting Customerexits Enhancement: Note down old enhancement name (ZHMC94) Go to /OCMOD Project: ZHMC94 Deactivate Delete option Yes Enter Close Rohini kumar
SAP-ABAP
Select Components option Yes Display / Change option Display / Chane option Double click on +CU1 Function Text: Call FAGLL03 Enter Double click on +CU2 Function Text: Call FBL5N Enter Double click on EXIT_SAPMMCP6_003 Scroll down to bottom Double click on INCLUDE ZXSOPU03 Display / Change option CASE I_FCODE. WHEN ‘+CU1’. CALL TRANSACTION ‘FAGLL03’. WHEN ‘+CU2’. CALL TRANSACTION ‘FBL5N’. ENDCASE.
Activate Back Back Back Activate project
Testing the Application: Go to MC94 Planning Type: apply F4 select any one Enter Active Version Extras ---- Customer Functions ---- Call FAGLL03 ------ Call FBL5N
Rohini kumar
535
SAP-ABAP
Screen Exits: Object: Add a screen with following fields in CS01, CS02, CS03 applications ZZORDER PO number ZZDATE PO date ZZVENDOR vendor number Solution: Step-1: adding fields to table Go to SE11 Database Table: STKO Display Append Structure You will find a message, Enter Append Name: ZSTKO_APP Enter Short Description: Additional fields for stko table Component Component Type ZZORDER EBELN ZZDATE BEDAT ZZVENDOR LIFNR Activate Step-2: identifying Package name of an application Go to CS01 System -----Status Double click on Program Name (screen) Goto ---- Attributes Note down package name (CS) Step-3: identifying Customerexits for an application Go to SMOD Apply F4 on Enhancement field You will find a pop-up, at bottom select Information System button Package: CS Enter Note down Customerexits (PCSP0003) Step-4: writing enhancement Go to CMOD Project: ZENC_CS01 Rohini kumar
536
SAP-ABAP
Create Short Text: customerexits for cs01 Save Enhancement Assignments button Select your enhancement PCSP0003 Enter Select Components option Yes Double click on 0114 You find a message, select Maintain in Original Language option You should find a message ‘for program SAPLXCSA is been created’, Enter
If you are not getting such message you have to delete the old enhancement Deleting Customerexits Enhancement: Go to /OSE51 Project: SAPLXCSA Screen Number: 1100 Delete option Yes Enter Close
Short Description: Sub Screen 1100 Sub Screen Layout F6 Table Name: STKO Enter Scroll down to bottom Select your fields (ZZORDER, ZZDATE, ZZLIFNR), Enter Place the fields on the screen Activate Back
Double click on EXIT_SAPLCSDI_004 Double click on CSCI_STKO Append Structure Enter Append Name: ZCSCI_APP Enter Short Description: additional fields
Rohini kumar
537
SAP-ABAP
Component ZZORDER ZZDATE ZZVENDOR
538
Component Type EBELN BEDAT LIFNR
Activate Back Back Scroll down to bottom Double click on INCLUDE ZXCSAU04 Display / Change option TABLES STKO. STKO-ZZEBELN = USERDATA-ZZORDER. STKO-ZZDATE = USERDATA-ZZDATE. STKO-LIFNR = USERDATA-ZZLIFNR. Activate Back Back Double click EXIT_SAPLSOI_005 Double click on INCLUDE Display / Change option USERDATA-ZZORDER = STKO-ZZEBELN. USERDATA-ZZDATE = STKO-ZZBEDAT. USERDATA-ZZLIFNR = STKO-ZZLIFNR. Activate Back Back Back Activate project Testing the Application: Go to CA01 Material: 100-101 Bom: 1 Header (cap symbol) Customer Fields Purchase Document: 30005 Po Date: 11.11.2014 Vendor: satya Save Rohini kumar
SAP-ABAP
14-11-2014 Assignment: Add following fields in ME21N, ME22N, ME23N ZZDEL Delivery priority Customerexit: MM06C005 Solution:
Rohini kumar
539
SAP-ABAP
Fieldexits: Using fieldexits you can modify field labels of data elements in data dictionary Example: Go to CMOD Goto ----- Text Enhancements ------Keywords ----Change Data Element: REGIO Enter Shot Field Lable: State Medium Field Lable: State Long Field Lable: State Heading: State Short Description: State Save Note: SAP is not recommending Fieldexits in real time
Rohini kumar
540
SAP-ABAP
541
BADI: Bussines Addins It is based on object oriented programming In Userexits (Customerexits) the same exit cannot be reuse in other projects In BADIs the same BADI definition can be implemented in N number of implementations BADI concept is purly designed based on object oriented programming For implementing BADI, SAP will provide you an interactive & respective implementation class Here interface is a collection of methods where you have to implement the additional code Note: T codes for working with BADIs are 1. SE18 -------- for BADI definition 2. SE19 -------- for BADI implementation Types of BADI: 1. Standard BADI 2. Custom BADI 3. Filter BADI
Rohini kumar
SAP-ABAP
***Standard BADI: In Standard BADI, BADI definitions are predefined (given by SAP) In Standard BADI we have to provide only implementation section Object-1: Validate customer master application for postal code Solution: Go to SE19 Classic BADI BADI Name: CUSTOMER_ADD_DATA Create Impl Enter Implementation Name: ZXD01_IMPL Enter Short Text: implementation for xd01 application Interface tab Double click on CHECK_ALL_DATA Yes Enter You may find a message ‘implementation ZXD01_IMPL migrated’, Enter You will find a pop-up, Select Create option Again you will find a pop-up, provide Enhancement Implementation: ZCUSTOMER_IMPL Short Text: implementation for xd01 application Enter Select your implementation (ZXD01_IMPL) Enter You may find a wrong method Back Again double click on CHECK_ALL_DATA Place cursor between METHOD………..ENDMETHOD IF S_KNA1-PSTLZ IS INITIAL. MESSAGE ‘Enter postal code’ TYPE ‘E’. ENDIF. Activate Back Activate
Rohini kumar
542
SAP-ABAP
Testing the Application: Go to XD01 Account Group: 004 bill to party Customer number: 5869 Enter Title: Mr Name: satya City: Hyderabad Country: IN Save You will find an error message ‘Enter postal code’
Rohini kumar
543
SAP-ABAP
Watch Point: Watch point is a cleaver break point Use watch point for watching the errors in standard applications The another purpose of watch point is to watch a specific record in an internal table during debugging Note: You can keep maximum 5 wach points in ABAP for a specific report Example: Go to XD01 Provide required input Save Apply /H in Command prompt (/H is a T code for debugging) Enter Enter Watch point button You will find a pop-up, provide ***Variable: SY-MSGTY (system field for capturing messages) Enter You will find a message ‘watch point created’ F7
Rohini kumar
544
SAP-ABAP
Navigation for Finding BADI: 1st Method: Go to SE90 Expand Enhancements option Expand Bussiness Add-ins Double click on Definitions Execute 2nd Method: Go to SE80 Select Package Provide CS Enter Expand Enhancements Expand Classic BADIs Def *** 3rd Method: Go to SE24 Object Type: CL_EXITHANDLER Display Double click on method GET_INSTANCE Place cursor at call method CL_EXITHANDLER GET_CLASS_NAME_BY_INTERFACE Select Dynamic Break Point, stop
Go to CS01 Variable: EXIT_NAME F7…………. Material: 100-101 Plant: 1000 Bom: 1 Enter
Rohini kumar
545
SAP-ABAP
546
Object-2: Validate BOM application (CS01) for alternate Bom Business Requirement: In real time every material is having an alternate Bom But some materials alternate Bom not possible Provide to control on such materials such that user try to create alternate Bom system through an error Solution: Go to SE19 Classic BADI BADI Name: BOM_UPDATE Create Impl Enter Implementation Name: ZBOM_IMPL Enter Short Text: implementation for BOM application Interface tab Double click on CHANGE_AT_SAVE Yes Enter You may find a wrong method Back Again double click on CHANCE_AT_SAVE Place cursor between METHOD………..ENDMETHOD DATA: WA TYPE STPOB. LOOP AT DELTA_STPOB INTO WA. IF WA_IDNRK EQ ‘100-101’. IF I_STLAL > 1. MESSAGE ‘Alternate Bom not allowed’ TYPE ‘E’. ENDIF. ENDIF. ENDLOOP. Activate
Rohini kumar
SAP-ABAP
547
Testing the Application: Go to CS01 Material: 100-101 Plant: 1000 Bom: 1 Save You will find an error message ‘Alternate Bom not allowed’ ***Assignment: In MIRO (or) MIGO you will find posting date & document date Posting date never be less than document date Provide control such that if user provides document date greather than posting date gives error BADI Definition: INVOICE_UPDATE Solution:
Rohini kumar
SAP-ABAP
Object-3: Add a menu in FBL5N application Solution: Go to SE90 Expand Enhancements Expand Bussiness Addins Double click on Definitions Package: FREP Execute Note down BADI name
Go to SE19 Classic BADI BADI Name: F5_ITEMS_MENUE01 Create Impl Enter Implementation Name: ZFI_ITEM Enter Short Text: implementation for FBL5N application Interface tab Double click on LIST_ITEMS01 You may find a wrong method Back Again double click on LIST_ITEMS01 Place cursor between METHOD………..ENDMETHOD
CALL TRANSACTION ‘FAGLL03’
Activate Back Double click on LIST_ITEMS02 Place cursor between METHOD………..ENDMETHOD
CALL TRANSACTION ‘FBL5N’ Activate Back Activate
Rohini kumar
548
SAP-ABAP
Testing the Application: Go to FBL5N Customer Account: 1000 Execute Extras ------Call FBL5N o ----- Call FAGLL03
Rohini kumar
549
SAP-ABAP
Object-4: Add a screen in XD01, XD02 with following field Sales Manager Solution: Go to SE11 Database Table: KNA1 Display Append Structure Create Append Append Name: ZKNA1_APP Enter Short Text: Additional fields Component Component Type ZZSM ZSM Activate Go to SPRO Select SAP Reference Img option Expand Logistic General Expand Bussiness Partner Expand Customers Expand Control Expand Adaption of Customers Own Master Data Fields Select Prepare Modification- Free Enhancement of Customer Master Record You will find a message, Enter New Entries Screen Grp Description Z5 Sales manager Save On left side double click on Label Tab Pages by selecting Screen Grp Z5 You will find another screen Select New Entries button Number Function Code Description 5000 TAB1 Sales manager Save Back Back Back Back Rohini kumar
550
SAP-ABAP
Select 2nd option Bussiness Addin Processing of Master data Enhancements You will find a pop-up, at bottom select Create option Implementation Name: ZCUST_ADD_SM Enter Implementation Short Text: Badi implementation Save You may find a message ‘implementation ZCUST_ADD_SM migrated’, Enter At bottom select Create option Enhancement Implementation: ZSM_IMPL Short Text: Addition of extra field Select your implementation name (ZSM_IMPL) Enter Interface tab Scroll down to bottom, Double click on last method CHECK_ADD_ON_ACTIVE Place cursor between METHOD………..ENDMETHOD
IF I_SCREEN_GROUP EQ Z5. E_ADD_ON_ACTIVE = ‘X’. ENDIF. Activate Back Activate Back Select 3rd option Bussiness Addin Customer Sub screen You will find a pop-up, at bottom select Create option You will find a pop-up, provide Implementation Name: ZCUST_CS_DATA Enter Implementation Short Text: Badi implementation Attributes tab Scroll down to bottom Select ‘+’ Insert Row Screen Grp Z5
Save You may find a message, Enter You will find pop-up, at bottom select Create option Enhancement Implementation: ZSM_IMPL_SM Short Text: Badi implementation Enter
Rohini kumar
551
SAP-ABAP
You will find a pop-up, select your implementation name ZSM_IMPL_SM Enter Interface tab Scroll vertical scroll bar up Double click on GET_TAXI_SCREEN Place cursor between METHOD………..ENDMETHOD
CASE I_TAXI_FCODE. WHEN ‘TAB1’. E_SCREEN = ‘5000’. E_PROGRAM = ‘ZBADI_SM’. ENDCASE. Activate Back Activate
Go to SE38 Program: ZBADI_SM Create Title: Sales manager Type: Module Pool Enter
Go to SE51 Program: ZBADI_SM Screen Number: 5000 Create Short Description: Sub Screen 5000 Sub Screen Layout F6 Table Name: KNA1 Enter Scroll down to bottom, select your field name ZZSM Enter Place the field on the screen Flow Logic Remove comment for MODULE STATUS_5000 Double click on STATUS_5000 Yes Main Program
Rohini kumar
552
SAP-ABAP
Enter Yes TABLES KNA1. Place cursor between MODULE……….ENDMODULE of STATUS_5000 IF SY-TCODE EQ ‘XD03’. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘KNA1-ZZSM’. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. ENDIF. Activate Back Activate Testing the Application: Go to XD01 Account Group: bill to party Customer: 500025 Enter Title: Mr Name: Satya Search Term: 1 Street: LB Nagar Postal code: 500074 City: Hyderabad Country: IN Enter You will find your screen with Sales manager field
Rohini kumar
553
SAP-ABAP
***Assignment: Add following fields in VL01N, VL02N Order number Order date Delivery challana number Delivery challana date Driver Hint: Add fields in LIKP table BADI name is LE_SHP_TAB_CUST_HEAD Solution:
Rohini kumar
554
SAP-ABAP
555
Custom BADI: In Custom BADI, BADI definition is custom defined Filter BADI: It is a part of Custom BADI In Filter BADI, the same definition can be called in different implementations Object: Determine tax code for sales organization Solution: Go to SE18 Utilities --- Create Classic BADI Definition Name: ZBADI_CUST_FILTER Enter Scroll down to bottom, select Filter Depend check box Filter Type: VKORG Save Interface tab Note: Based on your definition name system will create an interface ZIF_EX_BADI_CUST_FILTER Double click on interface name ZIF_EX_BADI_CUST_FILTER Method GET_TAX
Level INSATANCE
Description getting tax details
Select method GET_TAX Parameters Parameter P_TAX
Type CHANGING
Associated Type I
Activate During activation you will find a message, Enter Once your interface is activated system will add additional parameter FLT_VAL based on your filter type VKORG Go to SE19 Classic BADI BADI Name: ZBADI_CUST_FILTER Rohini kumar
SAP-ABAP
Create Impl Enter Implementation Name: ZBADI_FIL Enter Short Text: implementation for filter badi Scroll down to bottom Select ‘+’ Insert Row
Sales org 1000
Save Interface tab Double click on GET_TAX Place cursor between METHOD………..ENDMETHOD
IF FLT_VAL = ‘1000’. P_TAX = 10. ENDIF.
Activate Back Activate Back
Classic BADI BADI Name: ZBADI_CUST_FILTER Create Impl Enter Implementation Name: ZBADI_FIL Enter Short Text: implementation for filter badi Attributes Scroll down to bottom Select ‘+’ Insert Row
Sales org 1020 Save Interface tab Double click on GET_TAX Rohini kumar
556
SAP-ABAP
Place cursor between METHOD………..ENDMETHOD IF FLT_VAL = ‘1020’. P_TAX = 12. ENDIF.
Activate Back Activate Back
Classic BADI BADI Name: ZBADI_CUST_FILTER Create Impl Enter Implementation Name: ZBADI_FIL Enter Short Text: implementation for filter badi Scroll down to bottom Select ‘+’ Insert Row
Sales org 1030
Save Interface tab Double click on GET_TAX Place cursor between METHOD………..ENDMETHOD
IF FLT_VAL = ‘1030’. P_TAX = 8. ENDIF. Activate Back Activate
Go to SE38 Program: ZCAL_CUSTOM_FILTER_BADI Create Title: Method of filter badi Type: Executable Program
Rohini kumar
557
SAP-ABAP
558
Save SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETERS v_vkorg TYPE vkorg. SELECTION-SCREEN: END OF BLOCK b1. DATA v_tax TYPE I. DATA obj TYPE REF TO ZFI_EX_BADI_CUST_FILTER. * get reference of the class implemented CALL METHOD CL_EXITHANDLER=>GET_INSTANCE CHANGING INSTANCE = obj. IF SY-SUBRC NE 0. MESSAGE ‘Error in calling BADI’ TYPE ‘E’. ELSE. CALL METHOD obj->get_tax EXPORTING FLT_VAL = V_VKORG CHANGING P_TAX = V_TAX. IF NOT V_TAX IS INITIAL. WRITE:/ ‘The tax code for sales organization’, V_VKORG ‘is’, V_TAX. ENDIF. ENDIF.
Rohini kumar
SAP-ABAP
559
Enhancement Framework: BADIs are based on object oriented programming But SAP is not providing BADIs for all requirements Restricted to specific applications & only for specific requirements Using Framework you can enhance all types of SAP objects Object-1: In VA01 you will find a field called Sales office, which is meant for sales office data Generally clients are instructed not to enter Sales office data as it pickup automatically from master data (KNVV table) Some times clients will enter wrong data into Sales office, which is wrongly updated to transactional tables Provide an enhancement to deselect Sales office field Solution: Go to VA01 Apply F1 on Sales office You will find a pop-up, select 4th option Technical Information Double click on Screen 101 Double click on FELDAUSWAHL-101 Double click on subroutine FELDAUSWAHL-101 Enhance Edit ---- Enhancement Operations ----Show Implicit Enhancement Options Right click under spot under FORM FELDAUSWAHL-101 Enhancement Implementation ----Create Implementation Code Create Enhancement Implementation: ZVA01_IMPL Enter Select your implementation name ZVA01_IMPL Enter IF SY-TCODE EQ ‘VA01’. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘VBAK-VKBUR’. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. Rohini kumar
SAP-ABAP
ENDLOOP. ENDIF. Activate Testing the Application: Go to VA01 Sales office is in display mode
Rohini kumar
560
SAP-ABAP
Object-2: Provide Profit center as obligatory in F-28 application Solution: Go to F-28 Apply F1 on Profit Center Technical Information Double click on Screen 103 Double click on DYNPRO_KOPF_MODIF Double click on subroutine DYNPRO_KOPF_MODIF Enhance Edit ---- Enhancement Operations ----Show Implicit Enhancement Options Right click under spot under FORM DYNPRO_KOPF_MODIF Enhancement Implementation ----Create Implementation Code LOOP AT SCREEN. IF SCREEN-NAME EQ ‘BSEG-PRCTR’. SCREEN-REQUIRED = 1. MODIFY SCREEN. ENDIF. Activate Testing the Application: Go to F-28 There you will find Profit center became mandatory
Rohini kumar
561
SAP-ABAP
562
Object-3: In MB31 you will find Document date & Posting date as current date Provide an enhancement such that I want both the dates by default as previous dates Solution; Go to MB31 Apply F1 on Document date Technical Information Double click on Screen 300 Double click on MODULE BELEGKOPF_VORGSCHLOG You will find a subroutine, Double click on it Enhance Edit ---- Enhancement Operations ----Show Implicit Enhancement Options Right click on spot above ENDFORM Enhancement Implementation ----Create Implementation Code Create Enhancement Implementation: ZMB_MB31 Short Text: Implementation for MB51 application Enter Select your implementation ZMB_MB31 Enter MKPF-BUDAT = SY-DATLO - 1. MKPF-BLDAT = SY-DATLO - 1. Activate Testing the Application: Go to MB31 There you will find previous date
Rohini kumar
SAP-ABAP
*** Object-4: Add following fields in FB03 application Dmbtr, Hlcont Solution: Go to SE11 Data Type: BKPF_ALV Display Append Structure Enter Append Name: ZBKPF_APP Enter Short Description: Additional fields Component Component Type HKONT HKONT DMBTR DMBTR Currency / Quantity Fields Reference Table Reference Field T001 WAERS Activate
Go to FB03 Document List Apply F1 on Document number Technical Information Double click on Program name Go to REUSE_ALV_GRID_DISPLAY Find internal table Enhance Edit ---- Enhancement Operations ----Show Implicit Enhancement Options Right click on spot under FORM GRID_DISPLAY Enhancement Implementation ----Create Implementation Code Create Enhancement Implementation: ZENC_FB03 Short Text: Implementation for FB03 application Enter Select your implementation ZENC_FB03 Enter
Rohini kumar
563
SAP-ABAP
DATA: wa_s1 TYPE BKPF_ALV, It_i1 TYPE TABLE OF BKPF_ALV. TYPES: BEGIN OF ty_bseg1, Belnr TYPE belnr_D, Hkont TYPE hkont, Dmbtr TYPE dmbtr, Gjahr TYPE gjahr, END OF ty_bseg1. DATA: wa_bseg1 TYPE ty_bseg1, It_bseg1 TYPE TABLE OF ty_bseg1. APPEND LINES OF GT_YBKPF_ALV TO IT_I1. REFRESH GT_YBKPF_ALV. SELECT belnr hkont dmbtr FROM BSEG INTO TABLE it_bseg1 WHERE belnr = wa_s1-belnr. Testing the Application: Go to FB03 Document List Company code: 1000 Document number: 100000000 Execute Change Layout Scroll down to bottom Double click on G / L Account Double click on Amount_In_LC You will find your fields
Rohini kumar
564
SAP-ABAP
Object-5: Add screen in VF01, VF02, VF03 with ZZBOXNO, ZZSIZE, ZZTEXT Solution; Go to SE11 Database Table: VBRK Display Append Structure Create Append Append Name: ZVBRK_APP Enter Short Description: Additional fields Component Component Type ZZBOXNO ZBOXNO ZZSIZE ZSIZE ZZTEXT ZTEXT Activate
Go to SE80 Program: SAPMV60A At bottom, expand Screens option Find 6001 screen & double click on it Double click on MODULE CUST_HEAD_ACTIVATE You will find a subroutine, double click on it Enhance Right click under FORM CUST_HEAD_ACTIVATE
LOOP AT SCREEN. IF SCREEN-NAME EQ ‘TABSTRIP_TAB06’. GS_CUST_TAB_HEAD_OPTION = ‘invocice’. GS_CUST_TAB_HEAD_PROGRAM = ‘ZSD_INVV’. GS_CUST_TAB_HEAD_DYNPRO = ‘100’. IF SCREEN-ACTIVE = 1. SCREEN-INVISIBLE = 0. MODIFY SCREEN. ENDIF. TABSTRIP_TAB06 = GS_CUST_TAB_HEAD_CAPTION. ENDIF. Rohini kumar
565
SAP-ABAP
ENDLOOP. Activate
Go to SE38 Program: ZSD_INVV Create Title: Invoice details Type: Modulpe Pool Save
Go to SE51 Program: ZSD_INVV Screen: 100 Create Short Description: Sub screen 100 Sub Screen Layout F6 Table Name: VBRK Enter Scroll down to bottom, select your fields Enter Place the fields on screen Flow Logic Remove comment for MODULE STATUS_100 Double click on STATUS_100 Yes Main Program Enter Yes
IF SY-TCODE EQ ‘VF03’. LOOP AT SCREEN. IF SCREEN-NAME EQ ‘VBRK-ZZBOXNO’ OR SCREEN-NAME EQ ‘VBRK-ZZSIZE’ OR SCREEN-NAME EQ ‘VBRK-ZZTEXT’. SCREEN-INPUT = 0. ENDIF. ENDLOOP. ENDIF. Rohini kumar
566
SAP-ABAP
567
Activate Back Activate Testing the Application: Go to VF02 Bill number: 90030506 Enter Goto ---Header ---Header Invoice tab Your fields will be displayed Fill data Save Assignment-1: Add fields Purchase requisition number & Requisitioner name in MB51 application EBAN-BOMFN, EBAN-AFNAM Solution:
Assignment-2: Add fields storage bin (MARD-LGPBE) in MB5B Solution:
***Assignment-3: Validate Sales order quantity (VBAP-KWMENG) with PO quantity (EKPO-MENGE) If Sales order quantity is > PO quantity provide a control on VA01 application Solution:
Rohini kumar
SAP-ABAP
BTE: Business Framework Business Transaction Events For standard applications SAP is providing BTE For BTE a specific function module is attached When BTE triggers respective function module is called Note: BTE is mostly for finance transactions T code for BTE is FIBF *** Identifing Event Associated with an Application: Go to SE93 Transaction Code: FBL5N Display Double click on Program name Select Find option Find: OPEN Enter Double click on 1650
Rohini kumar
568
SAP-ABAP
Object: Add indicator field in FBL5N application Solution: Go to SE11 Database Table: RFPOS Display Append Structure Create Append Append Name: ZFI_FBL5N Enter Short Text: indicator field Component Component Type ZZIND ZIND
Extras ---- Enhancement Category Enter Can be Enhanced option Enter Activate
Go to SE11 Database Table: RFPOSX Display Append Structure Create Append Append Name: ZFI_FBL5N1 Enter Short Text: indicator field Component Component Type ZZIND ZIND
Extras ---- Enhancement Category Enter Can be Enhanced option Enter Activate
Go to BERE Execute Select Event 1650 Sample Function Module option
Rohini kumar
569
SAP-ABAP
Copy button To: ZSAMPLE_INTERFACE_0001650 Function Group: F4 Enter Enter Function Module: ZSAMPLE_INTERFACE_0001650 Change Remove comment for E_POSTAB = I_POSTAB
IF I_POSTAB-SHKZG = ‘H’. I_POSTAB-ZZIND = ‘Credit’. ELSE. E_POSTAB-ZZIND = ‘Debit’. ENDIF. Activate Go to FIBF Settings ----- Products ---- Of a Customer New Entries Products A ZFBL5N _/ Save Back Back Settings ---- PS Modules ---- Of a Customer New Entries Event Product Function Module 1650 ZFBL5N ZSAMPLE_INTERFACE_0001650 Save
Go to SE38 Program: RFPOSXEXTEND Activate Yes Enter
Testing Application: Go to FBL5N Customer Account: 1000 Rohini kumar
570
SAP-ABAP
Company code: 1000 Execute Change Layout Double click on Indicator Enter
Rohini kumar
571
SAP-ABAP
572
Ques-1: What are the different ways of idntifing Customerexits (Functionexits)? Answer: Go to SE93 Transaction Code: XK01 Display Double click on Program name Find option Find: CALL CUSTOMER_FUNCTION Enter Double click on 001 Ques-2: What is the difference between Implicit & Explicit Enhancement? Answer: Under implicit enhancement you can write your own code Adding Z-enhancement in already existing one is called Explicit enhancement Example: Go to SE93 Transaction Code: VA01 Display Double click on Program Name You will find a spot given by SAP Enhance Right click ES_SAPMV45A Enhancement Implementation ----Create Implementation Ques-3: What is the difference between Enhancement spot (point) & Enhancement section? Answer: In enhancement spot both customized & standard code will be executed In enhancement section only customized code will be executed Ques-4: What is Transaction Variant in enhancements? Answer: Using transaction variant you can provide enhancements You can make fields as Required, Output only, Invisible mode……etc using SHDO (Transaction Variant) With above concept you have to create a Z-T code & the same you should provide it to end user (standard applications should not be effected)
Rohini kumar
SAP-ABAP
573
Cross Applications: (ABAP / CA) It is a part of distributed environment in which various business applications are running in different system Such that they can integrate at one point (or) another to stay synchronize ALE: Application Linking Enabling ALE is SAP’s distributed technology for distributing (or) exchanging business process between two systems (SAP (or) Non-SAP) In real time if two companies are having same SAP systems (Servers) & if they want to exchange their business data Similarly, if two (or) more than two systems are working with different systems (other than SAP) & they want to interact with SAP system we have to work with tool called ALE IDOC: Intermediate Document IDOC is a container with which business data can be exchanged between two systems Components of IDOC: 1. IDOC Type 2. Segment Type 3. Records IDOC Type: It specifies the structure & format of an IDOC It is simply collection of Segments Standard IDOC Types have a suffix with 01, 02, 03…………. Which is known as Version Number Segment Type: It is a collection of fields Standard starts with prefix ‘E1’ Example: E1KNA1M E1MARA1M
Rohini kumar
SAP-ABAP
574
Records: Records are classified into 1. Control Record 2. Data Record 3. Status Record Control Record: It holds control level information (IP address of both Sender & Receiver, Message Type information, Segment Type information…………..etc) Only one Control Record exists in an IDOC The structure & format of Control Record is same for all IDOCs Control Record information is finally updated to a table EDIDC Data Record: It holds actual data It is again having 2 sections 1. Admin Section (holds segment type information) 2. Data Section (holds actual data in 1000 bytes) Data Record information is finally updated to a table EDIDU (the structure related to it is EDIDD) Status Record: IDOC have to travel through different layers (Application layer, ALE Service layer, Communication layer) At each layer the status information of an IDOC can be gathered from Status Record Status Record information is updated to EDIDS Sender
Receiver
Outbound
Inbound
1-49 Status Numbers
50-99 Status Numbers
Note: 1. There exists only one Control Record in an IDOC 2. Status Records & Data Records can be many 3. In real time as an ALE Consultant we have to work with only IDOCs Rohini kumar
SAP-ABAP
Run Time Components of IDOC: During run time a unique IDOC Number is attached to an IDOC All the Segments are translated into Data Records A unique Control Record is attached A unique Status Record is attached based on an IDOC status
Rohini kumar
575
SAP-ABAP
576
ALE Architecture: Outbound Program
Application Layer CDM (Receivers) Database
Message Type Master IDOC MASTER_IDOC_DISTRIBUTED
ALE Service Layer
Receivers Master IDOC Changes are made IDOC filtering
version change
field conversion
Communication
communication
communication
IDOC
IDOC
IDOC
Syntax Checks
Database Layer
Communication Layer
IDOC Port created Partner Profile table created ARFC_DEST_SHIP
Outbound System
RFC Remote Function Call
Rohini kumar
Integration Layer
SAP-ABAP
577
Database Read data from IDOC
status 51
Posting Program
application IDOC application IDOC Not posted
status 53
posted
IDOC Syntax Checks IDOC filtering
Version Change
Field Conversion
Basic Integrity Checks IDOCs Partner Profile Created Ports are created INBOUND_IDOC_SYNCHRONOUS Inbound System
Rohini kumar
SAP-ABAP
578
Message Type: These are unique application identities SAP is providing an unique identity for all application data to identify the same Note: T code for Message Type is WE81 & WE82
1. 2. 3. 4. 5. 6.
Message Type MATMAS CREMAS DEBMAS ORDERS ORDRSP COSMAS
Description material master vendor master customer master purchase order sales order cost center
Model View Functionality: It is also called Customer Distribution Model It acts as bag of information for Sender The information is that Receiver & the type of data that he want to send (Message Type) T code is BD64 Model View Sender Receiver Message Type
Partner Profile: Using Partner Profiles Ports can be created T codes are WE21 & BD64 Process Flow: Master Data
Material
MATMAS (WE81)
MATMAS05 (WE30)
Master IDOC
ALE Testing Tool (WE19) Transactional data
Rohini kumar
PO orders
ORDERS
ORDERS05
Process codes Communication IDOC (WE41) (WE021 & WE03)
RFC (SM59)
Master IDOC
Process codes Communication IDOC
SAP-ABAP
579
Types of IDOCs: 1. Standard IDOC 2. Custom IDOC 3. Extended IDOC Standard IDOC: In this all IDOC options (Message Type, IDOC Type, Segment Type…………etc) are already provided by SAP Object: Distributing material master data Message Type: MATMAS IDOC Type: MATMAS05 Logical Systems: These are unique client identities In real time for each client Logical Systems needs to be created Solution: Steps: Client 800 1. Work with SALE Create Logical Systems Assign Logical Systems to Clients 2. Work with SM59 Create RFC destinations
Client 810
2. Work with SM59 Create RFC destinations
3. Work with BD64 Create Model View 4. Work with BD64 Create Partner Profiles 5. Work with BD64 Distribute Model View
5. Work with BD64 Create Ports
6. Work with MM01 Create Material
6. Work with WE20 Create Process Codes
7. Work with BD10 Run Outbound program Rohini kumar
SAP-ABAP
8. Work with WE05 IDOC List
580
8. Work with WE05 Check status of IDOC 9. Work with MM03
Step-1: Creating logical systems: Go to SALE Expand Basic Settings Expand Logical Systems Select Define Logical System option Enter Note: Logical systems are client independent New Entries Logical System Name MATT800 SENDER MATT810 RECEIVER Save Back Back Assigning Logical Systems to Clients: Select Assign Logical System to Client option Enter Double click on 800 client Logical System: MATT800 Save Enter Back Double click on 810 client Logical System: MATT810 Save Enter Step-2: Creating RFC destinations in 800 client: Go to SM59 Select ABAP Connections Rohini kumar
SAP-ABAP
Create RFC Destination: MATT810 Description: RFC for Client 810 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 810 User: user1 PW Status: rgsabap Enter Enter Save Enter Remote Logon button Working under client 810
Creating RFC destinations in 810 client: Go to SM59 ABAP Connections Create RFC Destination: MATT800 Description: RFC for Client 800 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 800 User: user1 PW Status: Rgsabap Enter Enter Save Note: In real time the above 2 steps are done by Basis Consultant Step-3: Creating Model View Select client 800 session Go to BD64 By default Create Model View button is deselected Select F9 Rohini kumar
581
SAP-ABAP
Select Create Model View button Short Text: Model view for material details Technical Name: MATERIALM Enter Scroll down to bottom Select short description of your model view Select Add Message Type Sender: MATT810 Receiver: MATT800 Message Type: MATMAS Enter Again, select Add Message Type Sender: MATT800 Receiver: MATT810 Message Type: MATMAS Enter Save
Step-4: Creating Partner Profiles Environment ---- Generate Partner Profiles Partner System: MATT810 Execute You will find a message ‘port 000000104 with RFC destination has been created’ Note: Sometimes you may find an error message in red color. In such case Go back Again, execute Back Step-5: Distributing Model View: Edit --- Model View ---- Distribute Enter You should find a message ‘model view has been created’ Creating Ports: Select client 810 session Go to BD64 Select your model view name Environment ---- Generate Partner Profiles Rohini kumar
582
SAP-ABAP
Partner System: MATT800 Execute You will find a message ‘port has been created’
Step-6: Creating process codes in 810 client: Go to WE20 Expand Partner Type LS Select Sender logical system name (MATT800) Right side scroll down to bottom Under Inbound Parameters Double click on MATMAS By default you will find Process Code: AFSA which is wrong one, provide Process Code: MATN Save Creating material in 800 client: Select client 800 session Go to MM01 Material: u-883 Industry Sector: mechanical grp Material Type: 1 Enter Select Basic Data1 & Basic Data2 Enter Material: sodaash Base unit of Measure: kg Material group: 001 Gross wt: 1200 Weight unit: kg Net weight: 1000 Save Note: The above material is created by end user Step-7: Running Outbound program: Go to BD10 Material: u-883 Message Type: MATMAS Rohini kumar
583
SAP-ABAP
584
Logical System: MATT810 Execute You will find a message ‘master IDOC is created for message type MATMAS’, Enter Again, you will find a message ‘communication IDOC created for message type MATMAS’, Enter
Step-8: Displaying IDOC List: Go to WE05 Execute Note: In real time we should work with only outbound system. In outbound system you should always get status as Green (or) Yellow Checking status of IDOC in 810 client: Select client 810 session Go to WE05 Execute Step-9: Working with MM03: Go to MM03 Material: u-883 Enter Enter
Rohini kumar
SAP-ABAP
585
Sending Changes to Inbound System: Change Pointers Technique: Steps: 1. Work with BD50 2. Work with BD52 3. Work with BD61 4. Work with SE38 (execute RBDM IDOC) 5. Work with WE05 Step-1: Go to BD50 In real time sometimes all the Message Types may be selected, first you Deselect them & then Select your Message Type MATMAS Save Step-2: Go to BD52 Message Type: MATMAS Enter Here we have to add additional tables & fields related to material Step-3: Go to BD61 Select Change Pointer Activated Generally check box Save Step-4: Go to SE38 Program: RBDMIDOC Execute Message Type: MATMAS Execute You will find a message, Enter Enter
Go to MM02 Material: u-883 Enter Select Basic Data1, Basic Data2 Enter Make some changes i.e. material: soda bottle, Gross wt: 800………etc
Rohini kumar
SAP-ABAP
Save Go to SE38 Program: RBDMIDOC Execute Message Type: MATMAS Execute You will find a message ‘1 master IDOC generated’, Enter Again, you will find a message ‘1 communication IDOC generated’, Enter
Step-5: Go to WE05 Execute Scroll down to bottom, Double click on your IDOC Number
Rohini kumar
586
SAP-ABAP
IDOC Filtering: 1. Segment Filtering 2. IDOC Filtering 3. Reduced IDOC Filtering Segment Filtering: Unnecessary Segments can be filtered using Segment Filtering Steps: 1. Work with BD56 2. Work with BD10 3. Work with BE05 Step-1: Go to BD56 Message Type: MATMAS Enter New Entries Ty Sender Ty Receiver Segment Type LS MATT810 LS MATT800 E1MARMM Save Step-2: Go to BD10 Material: u-883 Message Type: MATMAS Logical System: MATT800 Execute Step-3: Go to WE05 Execute Note: Mandatory Segments cannot be deleted
Rohini kumar
587
SAP-ABAP
588
IDOC Filtering: Assume a company is having N number of Company Codes operating in different countries Assume a customer is approaching to Company Code 1000 for business His customer master data will be available not only to 1000 Company Code but also to other Company Code which is not required from 1000 Company Code perspective Whenever a customer is created for 1000 Company Code, it should be allowed by the system It the same is done for other Company Codes it should be filtered out In customer distribution model you should create a Filter Set based on Company Code…….etc Whenever Master IDOC is created then system will check whether the Company Code is matching with Filter Set (or) not If not matching respective Segment is filtered out Steps: Client 800 Client 810 1. Work with SALE Create Logical Systems Assign Logical Systems to Clients 2. Work with SM59 Create RFC destinations
2. Work with SM59 Create RFC destinations
3. Work with BD64 Create Model View *** Create Filter Set 4. Work with BD64 Create Partner Profiles 5. Work with BD64 Distribute Model View
5. Work with BD64 Create Ports
6. Work with XD01 Create Material
6. Work with WE20 Create Process Codes
7. Work with BD12 Run Outbound program 8. Work with WE05 IDOC List Rohini kumar
8. Work with WE05 Check status of IDOC
SAP-ABAP
Step-1: Creating logical systems: Go to SALE Expand Basic Settings Expand Logical Systems Select Define Logical System option Enter Note: Logical systems are client independent New Entries Logical System Name CUST800 SENDER CUST810 RECEIVER Save Back Back Assigning Logical Systems to Clients: Select Assign Logical System to Client option Enter Double click on 800 client Logical System: CUST800 Save Enter Back Double click on 810 client Logical System: CUST810 Save Enter Step-2: Creating RFC destinations in 800 client: Go to SM59 Select ABAP Connections Create RFC Destination: CUST810 Description: RFC for Client 810 Target Host: SAPLID Logon & Security tab Rohini kumar
589
SAP-ABAP
Scroll down to bottom Language: EN Client: 810 User: user1 PW Status: rgsabap Enter Enter Save Enter Remote Logon button Working under client 810
Creating RFC destinations in 810 client: Go to SM59 ABAP Connections Create RFC Destination: CUST800 Description: RFC for Client 800 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 800 User: user1 PW Status: Rgsabap Enter Enter Save Note: In real time the above 2 steps are done by Basis Consultant Step-3: Creating Model View: Select client 800 session Go to BD64 By default Create Model View button is deselected Select F9 Select Create Model View button Short Text: Model view for customer master Technical Name: CUSTOM ORDER Enter Rohini kumar
590
SAP-ABAP
Scroll down to bottom Select short description of your model view Select Add Message Type Sender: CUST810 Receiver: CUST800 Message Type: DEBMAS Enter Again, select Add Message Type Sender: CUST800 Receiver: CUST810 Message Type: DEBMAS Enter Save
Creating Filter Set: Expand Model View Expand Sender Expand Receiver Expand DEBMAS You will find No Filter Set, double click on it Create Filter Group Expand Data Filtering Expand Filter Group Double click on Global Co Cde ‘+’ Insert Row Value List GL_1000 Enter Enter Save Step-4: Creating Partner Profiles Environment ---- Generate Partner Profiles Partner System: CUST810 Execute You will find a message ‘port 000000104 with RFC destination has been created’ Note: Sometimes you may find an error message in red color. In such case Go back Again, execute Back Rohini kumar
591
SAP-ABAP
Step-5: Distributing Model View: Edit --- Model View ---- Distribute Enter You should find a message ‘model view has been created’ Note: On distributing Model View, model view will became client independent Creating Ports: Select client 810 session Go to BD64 Select your model view name Environment ---- Generate Partner Profiles Partner System: CUST800 Execute You will find a message ‘port has been created’ Step-6: Creating process codes in 810 client: Go to WE20 Expand Partner Type LS Select Sender logical system name (CUST800) Right side scroll down to bottom Under Inbound Parameters Double click on DEBMAS By default you will find Process Code: DEB2 which is wrong one, provide Process Code: DEBM Save Creating customer in 800 client: Select client 800 session Go to XD01 Account Group: Bill to party Customer: 7856 ***Company Code: 1000 Enter Title: Mr Name: Satya Search Term: 1 Street: LB Nagar Postal Code: 500074 Rohini kumar
592
SAP-ABAP
City: Hyderabad Country: IN Save Step-7: Running Outbound program: Go to BD12 Customer: 7856 Output Type: DEBMAS Execute Step-8: Displaying IDOC List: Go to WE05 Execute Select DEBMAS Execute Double click on IDOC Number Expand Data Records
Go to XD01 Customer: 7856 Company Code: 3000 Enter Title: Mr Name: Satya City: Hyderabad Country: IN Save
Go to BD12 Customer: 7856 Output Type: DEBMAS Execute
Checking status of IDOC in 810 client: Select client 810 session Go to WE05 Execute
Rohini kumar
593
SAP-ABAP
Reduced IDOC Type: Unwanted fields can be filtered using Reduced IDOC Type Steps: 1. Work with BD53 2. Work with BD64 3. Work with BD10 4. Work with WE05 Step-1: Go to BD53 Reduced Message Type: ZRED_MATMAS Create Message Type Ref: MATMAS Enter Description: Reduced message type for material type Enter Place cursor on E1MARMM Select button You will find a white color change instead of red color to the segment Double click on that segment Select the fields which you want to filter Select button Enter Save Step-2: Creating Model View: Select client 800 session Go to BD64 By default Create Model View button is deselected Select F9 Select Create Model View button Short Text: Model view for customer master Technical Name: CUSTOM ORDER Enter Scroll down to bottom Select short description of your model view Select Add Message Type Sender: CUST810 Receiver: CUST800 Message Type: DEBMAS Rohini kumar
594
SAP-ABAP
Enter Again, select Add Message Type Sender: CUST800 Receiver: CUST810 Message Type: DEBMAS Enter Save
Step-3: Go to BD10 Material: u-883 Message Type: MATMAS Logical System: MATT800 Execute Step-4: Go to WE05 Execute Note: In real time we are not working with Reduced IDOC Filtering
Rohini kumar
595
SAP-ABAP
596
Distributing Transactional Data: Method: Message Control Technique In Message Control Technique whenever application document is created, IDOC is created & dispatched to Inbound system ***Object: Distribute Purchase Order Data using Message Control Technique Message Type: ORDERS IDOC Type: ORDERS05 Steps: Client 800 1. Work with SALE Create Logical Systems Assign Logical Systems to Clients 2. Work with SM59 Create RFC destinations
Client 810
2. Work with SM59 Create RFC destinations
3. Work with BD64 Create Model View 4. Work with BD64 Create Partner Profiles 5. Work with BD64 Distribute Model View
5. Work with BD64 Create Ports
6. Work with XK01 Create Vendor master 7. Work with WE20 Maintain Partner Profiles 8. Work with MN05 Maintain Conditional Records Note: Conditional Records are maintained by Functional Consultant 9. Work with ME21N Create Purchase Order based on vendor Rohini kumar
SAP-ABAP
597
Note: Purchase Order creation is done by end user. Once ME21N is executed IDOC is created & dispatched to Inbound system 10. Work with ME22 Check the status of IDOC Solution: Step-1: Creating logical systems: Go to SALE Expand Basic Settings Expand Logical Systems Select Define Logical System option Enter Note: Logical systems are client independent New Entries Logical System Name MATT800 SENDER MATT810 RECEIVER Save Back Back Assigning Logical Systems to Clients: Select Assign Logical System to Client option Enter Double click on 800 client Logical System: MATT800 Save Enter Back Double click on 810 client Logical System: MATT810 Save Enter
Rohini kumar
SAP-ABAP
Step-2: Creating RFC destinations in 800 client: Go to SM59 Select ABAP Connections Create RFC Destination: MATT810 Description: RFC for Client 810 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 810 User: user1 PW Status: rgsabap Enter Enter Save Enter Remote Logon button Working under client 810 Creating RFC destinations in 810 client: Go to SM59 ABAP Connections Create RFC Destination: MATT800 Description: RFC for Client 800 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 800 User: user1 PW Status: Rgsabap Enter Enter Save Note: In real time the above 2 steps are done by Basis Consultant
Rohini kumar
598
SAP-ABAP
Step-3: Creating Model View Select client 800 session Go to BD64 By default Create Model View button is deselected Select F9 Select Create Model View button Short Text: Model view for material details Technical Name: ORDDMOD Enter Scroll down to bottom Select short description of your model view Select Add Message Type Sender: MATT810 Receiver: MATT800 Message Type: ORDERS Enter Again, select Add Message Type Sender: MATT800 Receiver: MATT810 Message Type: ORDERS Enter Save Step-4: Creating Partner Profiles Environment ---- Generate Partner Profiles Partner System: MATT810 Execute You will find a message ‘port 000000104 with RFC destination has been created’ Note: Sometimes you may find an error message in red color. In such case Go back Again, execute Back Step-5: Distributing Model View: Edit --- Model View ---- Distribute Enter You should find a message ‘model view has been created’ Rohini kumar
599
SAP-ABAP
Creating Ports: Select client 810 session Go to BD64 Select your model view name Environment ---- Generate Partner Profiles Partner System: MATT800 Execute You will find a message ‘port has been created’, Enter Step-6: Creating vendor master Select client 800 session Go to XK01 Create a Vendor with providing mandatory inputs (9343, 1000, 001…) Save Step-7: Maintaining Partner Profiles Go to WE20 Select Create option (F5) Partner: 9343 Save Under Outbound Parameters Select ‘+’ Insert Row Create Outbound Parameters Partner Role: VN Message Type: ORDERS Receiver Port: A0000106 Select Transfer IDOC Immediately option Basic Type: ORDERS05 Save Select Message Control tab Scroll down to bottom Select ‘+’ Insert Row Application Message Type Process Code EF NEU ME10 Save Note: With the above navigation we should provide 1. Whom to transfer (Receiver address) 2. What to transfer (Message Type & IDOC Type) 3. Mode of dispatch (Transfer Immediately & Collect IDOCs) 4. Medium of data transfer (Port) Rohini kumar
600
SAP-ABAP
Step-8: Maintaining Conditional Records Go to MM05 Output Type: NEU Key Combination button You will find a pop-up, Enter Execute Vendor Function Partner Medium 9343 VN 9343 A
601
Date / Time Language 4 EN
Save Step-9: Creating Purchase Order based onvendor Go to ME21N Vendor: 9343 Enter Purchase Organization: 1000 Purchase Group: 001 Company Code: 1000 Enter Currency: EUR Material: 100-101 Quantity: 30 Net Price: 3000 Plant: 1000 Save You will find a message ‘Standard PO record under the number 45000-17462 created’ Step-10: Checking status of IDOC Go to ME22 You will find the Purchase Order: 45000-17462, Enter Header Messages Once PO is created accurately you will find an Output Type in green color Select that Output Type Select Processing Log option IDOC 00034355549 has been created & success
Rohini kumar
SAP-ABAP
602
Custom IDOC: In Custom IDOC all IDOC options are customized Steps: Client 800 1. Work with SALE Create Logical Systems Assign Logical Systems to Clients 2. Work with SM59 Create RFC destinations 3. Work with WE31 Create Segment Type 4. Work with WE30 Create IDOC Type 5. Work with WE81 Create Message Type 6. Work with WE82 Link Message Type & IDOC Type 7. Work with BD64 Create Model View 8. Work with WE21 Create Port 9. Work with WE20 Maintain Partner Profiles 10. Work with SE38 Create Stand Alone program 11. Run Stand Alone program Solution: Step-1: Creating logical systems: Go to SALE Rohini kumar
Client 810
2. Work with SM59 Create RFC destinations
SAP-ABAP
Expand Basic Settings Expand Logical Systems Select Define Logical System option Enter
Note: Logical systems are client independent New Entries Logical System Name MATT800 SENDER MATT810 RECEIVER Save Back Back Assigning Logical Systems to Clients: Select Assign Logical System to Client option Enter Double click on 800 client Logical System: MATT800 Save Enter Back Double click on 810 client Logical System: MATT810 Save Enter Step-2: Creating RFC destinations in 800 client: Go to SM59 Select ABAP Connections Create RFC Destination: MATT810 Description: RFC for Client 810 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 810 Rohini kumar
603
SAP-ABAP
User: user1 PW Status: rgsabap Enter Enter Save Enter Remote Logon button Working under client 810
Creating RFC destinations in 810 client: Go to SM59 ABAP Connections Create RFC Destination: MATT800 Description: RFC for Client 800 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 800 User: user1 PW Status: Rgsabap Enter Enter Save Note: In real time the above 2 steps are done by Basis Consultant Step-3: Creating Segment Type Select client 800 session Go to WE31 Segment Type: Z1SEG Create Short Description: custom segment type Field Name Data element KUNNR KUNNR NAME1 NAME1 LAND1 LAND1 ORT01 ORT01 PSTLZ PSTLZ STRAS STRAS Rohini kumar
604
SAP-ABAP
605
Save Step-4: Creating IDOC Type Go to WE30 Object Type: Z1CUST_01 Create F5 You will find a message ‘assignment line is longer than 800’, Enter Short Description: custom IDOC type Select your IDOC Type Create Segment You will find a pop-up, provide Segment Type: Z1SEG Select Mandatory Segment option Min: 1 Max: 1 Enter Save Step-5: Creating Message Type Go to WE81 Display / Change option You will find a message, Enter New Entries Message Type Short Text ZCUSTM for customer segment Save Step-6: Linking Message Type & IDOC Type Go to WE82 Display / Change option You will find a message, Enter New Entries Message Type Basic Type (or) IDOC Type ZCUSTM Z1CUST_01 Save Step-7: Creating Model View Go to BD64 F9 Rohini kumar
Release 620
SAP-ABAP
Create Model View Short Text: model view for customer IDOC Technical Name: CUSTOMID Enter Scroll down to bottom Select your model view description Add Message Type option Sender: MATT800 Receiver: MATT810 Message Type: ZCUSTM Enter Save
Step-8: Creating Port Go to WE21 Transactional RFC option Create You will find a pop-up, Enter Description: Port creation RFC Destination: MATT810 Save Step-9: Maintaining Partner Profiles Go to WE20 Partner Type: LS Create Partner Number: MATT810 Save Scroll down to bottom Under Outbound Parameters Select ‘+’ create Outbound Parameters Message Type: ZCUSTM Basic Type: Z1CUST_01 Receiver Port: A0000127 Select Transfer IDOC Immediately option Save Step-10: Creating Standard alone program Go to SE38 Program: ZSD_IDOC_PROGRAMMING Create Title: Standard alone program Rohini kumar
606
SAP-ABAP
Type: Executable Program Save Write your program
Step-11: Executing standard alone program Go to SE38 Program: ZSD_IDOC_PROGRAMMING Execute Provide input Execute
Rohini kumar
607
SAP-ABAP
608
17-11-2014 Extended IDOC: Extended IDOC = Predefined IDOC Type + Additional Segment Steps: Client 800 1. Work with SALE Create Logical Systems Assign Logical Systems to Clients 2. Work with SM59 Create RFC destinations
Client 810
2. Work with SM59 Create RFC destinations
3. Work with WE31 Create Segment Type 4. Work with WE30 Create Extended IDOC Type 5. Work with WE82 Link Message Type & IDOC Type & Extended IDOC Type 6. Work with BD64 Create Model View 7. Work with WE21 Create Port 8. Work with WE20 Maintain Partner Profiles 9. Work with SMOD Create Extended IDOC program 10. Work with CMOD Link Extended IDOC program with CMOD 11. Work with XD01 Create customer master 12. Run BD12 Rohini kumar
SAP-ABAP
13. Work with WE05 Solution: Step-1: Creating logical systems: Go to SALE Expand Basic Settings Expand Logical Systems Select Define Logical System option Enter Note: Logical systems are client independent New Entries Logical System Name EXT1800 SENDER EXT1810 RECEIVER Save Back Back Assigning Logical Systems to Clients: Select Assign Logical System to Client option Enter Double click on 800 client Logical System: EXT1800 Save Enter Back Double click on 810 client Logical System: EXT1810 Save Enter Step-2: Creating RFC destinations in 800 client: Go to SM59 Select ABAP Connections Create RFC Destination: EXT1810 Rohini kumar
609
SAP-ABAP
Description: RFC for Client 810 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 810 User: user1 PW Status: rgsabap Enter Enter Save Enter Remote Logon button Working under client 810
Creating RFC destinations in 810 client: Go to SM59 ABAP Connections Create RFC Destination: EXT1800 Description: RFC for Client 800 Target Host: SAPLID Logon & Security tab Scroll down to bottom Language: EN Client: 800 User: user1 PW Status: Rgsabap Enter Enter Save Note: In real time the above 2 steps are done by Basis Consultant Step-3: Creating Segment Type Select client 800 session Go to WE31 Segment Type: Z1SEG Create Short Description: custom segment type Field Name Data element Rohini kumar
610
SAP-ABAP
KUNNR NAME1 LAND1 ORT01 PSTLZ STRAS
611
KUNNR NAME1 LAND1 ORT01 PSTLZ STRAS
Save Step-4: Creating Extended IDOC Type Go to WE30 Object Type: Z1CUST_02 Extension radio button Create Enter Linked Basic Type: DEBMAS05 Description: IDOC Extension Enter Select E1KNA1M Create Enter Segment Type: Z1SEG Select Mandatory Segment option Min: 1 Max: 1 Enter Save Step-5: Linking Message Type & Extended IDOC Type Go to WE82 Display / Change option New Entries Message Type Basic Type Extension Release DEBMAS DEBMAS05 Z1CUST_02 620 Save Step-6: Creating Model View Go to BD64 Display / Change (F9) Create Model View Short Text: model view for Extended IDOC Rohini kumar
SAP-ABAP
Technical Name: EXTMOD Enter Scroll down to bottom Select your model view description Add Message Type option Sender: EXT1800 Receiver: EXT1810 Message Type: DEBMAS Enter Save
Step-7: Creating Port Go to WE21 Transactional RFC option Create You will find a pop-up, Enter Description: Port creation RFC Destination: EXT1810 Save Step-8: Maintaining Partner Profiles Go to WE20 Partner Type: LS Create Partner Number: EXT1810 Save Scroll down to bottom Under Outbound Parameters Select ‘+’ create Outbound Parameters Message Type: DEBMAS Basic Type: DEBMAS05 Extension: Z1CUST_02 Receiver Port: A00000111 Select Transfer IDOC Immediately option Save Step-9: Creating Extended IDOC program Go to SMOD Enhancement: VSV00001 Display Components Double click on EXIT_SAPLVV01_001 Rohini kumar
612
SAP-ABAP
613
Double click on INCLUDE ZXVSVN01 Display / Change option DATA: WA_KNA1 TYPE Z1SEG, WA_DATA TYPE EDIDD, WA_MAPPING TYPE E1KNA1M. CASE SEGMENT_NAME. WHEN ‘E1KNA1M’. READ TABLE IDOC_DATA INTO WA_DATA WITH KEY SEGNAM = ‘E1KNA1M’. WA_MAPPING = WA_DATA + SDATA. SELECT SINGLE KUNNR NAME1 ORT01 PSTLZ STRAS FROM KNA1 INTO WA_KNA1 WHERE KUNNR = WA_MAPPING-KUNNR. WA_DATA-SDATA = WA_KNA1. WA_DATA-SEGNAM = ‘Z1SEG’. APPEND WA_DATA TO IDOC_DATA. ENDCASE. Step-10: Linking Extended IDOC program with CMOD Go to CMOD Project: EXTIDOC Create Short Text: linking Enhancement Assignments Enhancement SAPVSV00001 You may find an error note down that project name Project: ZIDOC Activate Step-11: Creating customer master Go to XD01 Account Group: bill to party Customer: 9634 Enter Title: Mr Name: Satya Rohini kumar
SAP-ABAP
City: Hyderabad Country: In Save Step-12: Running BD12 Go to BD12 Customer: 9634 Output Type: DEBMAS Logical System: EXT1810 Execute Step-13: Checking IDOC status Go to WE05 Execute Double click on your IDOC Number Expand Data Records Here you will find your IDOCs
Rohini kumar
614
SAP-ABAP
*** Trouble Shooting & Recovery: 1. Message ‘0 Master IDOC is created’ No data in databse 2. Message ‘0 Communication IDOC generated’ No Logical System defined in SALE 3. Status 29 Error in ALE Service Layer (or) Error in Custom (or) Extended program 4. Status 26 Error in Syntax Check (or) If Segment is wrong (or) Mandatory Segments are deleted (or) If Partner Profiles are not maintained in WE20 Important T codes for ALE: 1. WE19 (ALE Testing Tool) It is for testing IDOCs Example: Go to WE19 IDOC Number: 8110 (it is wrong) Execute Double click on IDOC Number Standard Inbound option You will find a pop-up with error message 2. BD20 It is for processing partial IDOCs 3. WE09 It is for searching IDOCs which are being processed as on date
Rohini kumar
615
SAP-ABAP
Debugging IDOCs: 1st Method: Go to BD20 IDOC Number: 801120 Command Prompt: /H Enter Enter F6……………….. 2nd Method: Go to SE37 Function Module: IDOC_INPUT Display Place Dynamic Break Point at DESCRIBLE TABLE IDOC_DATA LINES Go to BD20 IDOC Number: 801120 Execute ***Question: How you can change the status of an IDOC? Answer: Using standard program RBDAPP01
Rohini kumar
616
SAP-ABAP
617
EDI: Electronic Data Interchange Paperless work EDI is computer to computer exchange of routine business data (Purchase Orders, Invoices, Sales Orders………..etc) in standard format Advantages of EDI: Availability of data in electronic forms Reduced data entry errors Paperless work Better competitive advantage Accuracy of data Speed Security Difference between ALE & EDI: ALE is SAP’s distributed technology for transferring data between two systems In ALE data transfer is done between Logical Systems EDI is not SAP’s technology In EDI data transfer is done in standard format between Business Partners EDI Architecture: MM
SD
IDOC
IDOC
EDI Sub System
Rohini kumar
Network
EDI Sub System
SAP-ABAP
EDI Architecture Involves: 1. EDI Enable Applications For creating business processes such as Purchase Orders, Invoices, Sales Orders…….. etc 2. Carrier of Data (IDOC) 3. EDI Sub Systems 4. Middleware Technologies (networks). These converts IDOC interfaces into EDI Enabled Message Types Example: Middleware Technologies, Web methods, EAI …………..etc Middle Wares: 1. EAI Enterprise Application Integration 1.1. MA Series 1.2. Web Methods 2. EDI Systems 2.1. Gentian 2.2. Mercator 3. SAP XI Exchange infrastructure 4. SAP Net wavers
Rohini kumar
618
SAP-ABAP
Steps in EDI Process Flow: 1. Work with WE21 Create File Port 2. Work with XK01 Create vendor 3. Work with WE20 Maintain Partner Profiles 4. Work with MN05 Maintain Conditional Records 5. Work with ME21N Create Purchase Order based on vendor 6. Work with ME22 Check status of IDOC Solution: Step-1: Creating File Port Go to WE21 File Create Port: IDOCPORT Description: Port creation Scroll down to bottom Function Module: EDI_PATH_CREATE_USERNAME Inbound File tab Function Module: EDI_PATH_CREATE_USERNAME Save Outbound Trigger tab RFC Destination: SERVER_EXEC Save Note: SERVER_EXEC will transfer the IDOC file to Web methods Step-2: Creating Vendor Go to XK01 Create a vendor 9347 by providing mandatory fields Save Rohini kumar
619
SAP-ABAP
620
Step-3: Maintaining Partner Profiles Go to WE20 Partner Type: LI Create Partner Number: 9347 Save Under Outbound Parameters Select ‘+’ Create Outbound Parameter Partner Role: VM Message Type: ORDERS Receiver Port: IDOCPORT Transfer IDOC Immediately option Start Sub System option Basic Type: ORDERS05 Save Message Control ‘+’ Insert Row Application Message Type Process Code EF NEU ME10 Save Step-4: Maintaining Conditional Records Go to MN05 Output Type: MEU Key Combination Enter Execute Vendor Function Partner Medium 9347 VN 9347 6 Save Step-5: Go to ME21N Vendor: 9347 Enter Purchase Organization: 1000 Purchase Group: 001 Company Code: 1000 Enter Rohini kumar
Language EN
SAP-ABAP
621
Currency: INR Material: 100-101 PO Quantity: 10 Net Price: 3000 Plant: 1000 Save Once you save the application you will get a message ‘Purchase Order ……… created’
Step-6: Checking status of IDOC Go to ME22 F6 Header ------- Messages Here you will find a green color status Select that status, select Processing Log option You should find message ‘IDOC created & written to file’
Rohini kumar
SAP-ABAP
622
BAPI: Business Application Programming Interface It is an interface programming across business applications Difference between BDC & BAPI: BDC 1. In BDC we have to update the database Via Screens 2. Screen mapping is compulsory 3. BDC programs not effective for Large applications (poor performance) 4. In up gradation projects as there may be New screens with new fields therefore you Have to rewrite your BDC program 5. BDC is not available for Enjoy transactions
BAPI 1. BAPI updates the database directly 2. No mapping required 3. BAPI ensures very good performance for all SAP applications 4. Same BAPI programs can be reused
5. Can upload data for Enjoy Transactions Also
Features of BAPI: 1. BAPI is an interface programming 2. It is based on Object Oriented Programming 3. It supports all types of Languages (.Net, Java, VC++………etc) 4. It supports all type of Communication interfaces (RFC, COM, DCOM, CORBA, TIBCO………….etc) 5. In BAPI, RFC function module converted to method & the same method is accessed by 3rd party communication interfaces 6. BAPI is synchronous Business Object: The entire business objected oriented programming is designed based on business objects Every business object holds business data & does not allow it to access by outside world Components of Business Object: 1. Kernel 2. Integration Layer 3. Interface Layer 4. Communication Layer Kernel: It holds inherent data
Rohini kumar
SAP-ABAP
Integration Layer: In this layer methods are defined for accessing Kernel data Interface Layer: Here interfaces (BAPIs) are maintained for integrating with methods Communication Layer: All communication interfaces (RFC, CORBA……..etc) can access this layer Other Components of Business Object: 1. Object Type 2. Key Fields 3. Methods 4. Attributes ………….etc Object Type: Business Objects are created based on Object Type It acts as a blue print (or) template for creating business objects Key Fields: Using this option key fields are maintained (Customer Number, Sales Order………etc) Methods: The main logic for extracting business data is maintained using Methods Attributes: These are the parameters which are passed & returns from Methods These are actually part of Methods
Rohini kumar
623
SAP-ABAP
624
BOR: Business Object Repository It is the central repository for all business object types & their BAPIs Features of BOR: 1. It acts as central access point (or) repository for all Business Objects, Object Types, Their Key Fields, Methods …………..etc 2. All 3rd party Communication interfaces can access Business Objects stored in BOR 3. Business Objects maintained in BOR remains stable for a long time Note: The T code for working with BOR is BAPI & SW01 Where BAPIs are used in Real Time: 1. In all modules (SD, MM, PP, HR ………etc) 2. In dimensional products (CRM, APO, SCM………etc) 3. In ALE directly
Rohini kumar
SAP-ABAP
625
***Types of BAPIs: 1. Standard BAPI 2. Custom BAPI 3. Extended BAPI Standard BAPI: In standard BAPI, all BAPI function modules are predefined Object: Create a bank in client database Solution: Go to SE38 Program: ZFI_BAPI_BANK Create Title: Uploading bank data using BAPI Type: Executable Program Save SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETERS: p_banks TYPE banks, p_bankl TYPE bankl. SELECTION-SCREEN: END OF BLOCK b1. DATA: wa_bank_address TYPE BAPI1011_ADDRESS, wa_return TYPE BAPIRET2. wa_bank_address-bank_name wa_bank_address-street wa_bank_address-city wa_bank_address-bank_brnch
= = = =
‘Sbi’. ‘Lbnagar’. ‘Hyderabad’. ‘Lbnagarbranch’.
CALL FUNCTION ‘BAPI_BANK_CREATE’ EXPORTING BANK_COUNTRY = p_banks BANK_KEY = p_bankl BANK_ADDRESS = wa_bank-address IMPORTING RETURN = wa_return. IF SY-SUBRC EQ 0. CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’ Rohini kumar
SAP-ABAP
EXPORTING WAIT = ‘X’. ENDIF. IF wa_return-message IS NOT INITIAL. WRITE:/30 wa_return-message. ELSE. MESSAGE ‘Bank created successfully’ TYPE ‘I’. ENDIF.
Rohini kumar
626
SAP-ABAP
627
Object-2: Create interface program for update bank data Solution: SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. PARAMETERS: p_banks TYPE banks, p_bankl TYPE bankl. SELECTION-SCREEN: END OF BLOCK b1. DATA: wa_bank_address TYPE BAPI1011_ADDRESS, wa_return TYPE BAPIRET2. wa_bank_address-bank_name wa_bank_address-street wa_bank_address-city wa_bank_address-bank_brnch
= = = =
‘Sbi’. ‘Tnagar’. ‘Chennai’. ‘Tnagarbranch’.
wa_bank_addressx-street = ‘X’. wa_bank_addressx-city = ‘X’. wa_bank_addressx-bank_brnch = ‘X’. CALL FUNCTION ‘BAPI_BANK_CHANGE’ EXPORTING BANK_COUNTRY = p_banks BANK_ADDRESS = wa_bank-address BANK_ADDRESSX = wa_bank-addressx IMPORTING RETURN = wa_return. IF SY-SUBRC EQ 0. CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’ EXPORTING WAIT = ‘X’. ENDIF. IF wa_return-message IS NOT INITIAL. WRITE:/30 wa_return-message. ELSE. MESSAGE ‘Bank updated successfully’ TYPE ‘I’. ENDIF.
Rohini kumar
SAP-ABAP
*** Assignment: Create BAPI interface program for creating sales order using BAPI_SALEORDER_CRETEDAT2 Solution:
Rohini kumar
628
SAP-ABAP
629
23-11-2014 Custom BAPI: In Custom BAPI, BAPI function modules are custom defined Object: Create customized BAPI for invoice object Phases: 1. Analysis Phase 2. Design Phase 3. Implementation Phase 4. Test & Release Phase Analysis Phase: During this phase Project Managers will analyze which BAPI project should be implemented for current project Design Phase: During this phase BAPI Structures & Tables are designed Implementation Phase: During this phase BAPI project will be implemented It is further having following sub phases 1. Working with SE11 (DDIC) 2. Working with SE37 (Create RFC Form) 3. Working with SWo1 (create Business Object) 4. Working with SE38 (create Interface program) Test & Release Phase: In this phase BAPI is tested & released Solution: Step-1: Creating Structure: Go to SE11 Data Type: ZBAPI_INVSTR Create Structure Short Description: Invoice details Component Component Type VBELN VBELN_VF FKDAT FKDAT Rohini kumar
SAP-ABAP
MATNR ARKTX FKIMG NETWR
630
MATNR ARKTX FKIMG NETWR
Currency / Quantity Fields tab Reference Table Reference Field EKPO MEINS T001 WAERS Activate Creating Table: Go to SE11 Database Table: ZBAPI_INVTABLE Create Short Description: Invoice table Delivery Class: A Table View Maintenance: Display / Maintenance View Allowed Fields Field Data Element MANDT _/ MANDT VBELN _/ VBELN_VF FKDAT FKDAT MATNR MATNR ARKTX ARKTX FKIMG FKIMG NETWR NETWR Currency / Quantity Fields tab Reference Table Reference Field EKPO MEINS T001 WAERS
Technical Settings Data Class: APPL0 Size Category: 0 Save Back Activate Utilities ----- Table Contents ----- Create Entries Provide input & Save
Rohini kumar
SAP-ABAP
631
Step-2: Creating RFC Function Module Go to SE37 Goto ---Function Groups ---- Create Group Function Group: ZBAPI_FGR Short Text: BAPI Group Enter Function Module: ZBAPI_BILL_FUNCTION Create Function Group: ZBAPI_FGR Short Text: BAPI module for invoice Enter Enter Attributes tab *** Remote Enabled Module Import tab Parameter Name Typing Associated Type VBELN_LOW TYPE ZBAPI_INVSTR-VBELN VBELN_HIGH TYPE ZBAPI_INVSTR-VBELN DATE_LOW TYPE ZBAPI_INVSTR-FKDAT DATE_HIGH TYPE ZBAPI_INVSTR-FKDAT
Pass Value _/ _/ _/ _/
Export tab Parameter Name Typing RETURN TYPE
Associated Type BAPIRET2
Pass Value _/
Tables tab Parameter Name Typing IT_INV LIKE
Associated Type ZBAPI_INVTABLE
Source Code tab SELECT * FROM ZBAPI_INVTABLE INTO TABLE IT_INV WHERE VBELN BETWEEN VBELN_LOW AND VBELN_HIGH AND FKDAT BETWEEN DATE_LOW AND DATE_HIGH. IF SY-SUBRC NE 0. RAISE INVALID-INPUT. ENDIF. Activate Back Function Module --- Release----- Release Rohini kumar
SAP-ABAP
632
Step-3: creating Business Object Go to SWO1 Object Type: ZCUS_BILL Create Object Type: ZCUS_BILL Object Name: BILLINGG Name: Invoice Details Description: Invoice Details Program: ZBILL_INV Application: V Enter Select Key Fields Create (F5) Yes Table: ZBAPI_INVTABLE Enter Select VBELN Enter You will find a pop-up, Enter Select Methods Utilities ---- API Methods --- Add Method Function Module: ZBAPI_BILL_FUNCTION Enter You will find a pop-up, select Next Step option Next Step option You will find a message ‘Do you want to generate a template automatically for missing section’, Yes Save Back Testing the Business Object: Object Type ---- Change Release Status To ------- Implemented Test button Execute Provide input Execute You should find entries in your internal table Note: In real time if your testing is not fine go to SE37 & solve the issue Rohini kumar
SAP-ABAP
Creating Business Object in BOR: Go to SWO1 Change Object Type: ZCUS_BILL Change Select ZCUS_BILL Edit ----- Change Release Status ----Object Type ---- To Released Enter Enter Expand Methods Select your method (ZBAPIFUNCTION) Edit ---- Change ---- Release Status ---- Object Type Component----- To Released *** Generate (Ctrl + F3)\ Go to BAPI Scroll down you will find your Business Object Note: In real time as a ABAP Consultant we should create business objects in BOR Assignment-1: Create standard BAPI for creation of material using BAPI_MATERIAL_SAVEDATA Assignment-2: Create standard BAPI for creating purchase order using BAPI_PO_CREATE
Rohini kumar
633
SAP-ABAP
634
Adobe Forms: Using Adobe Forms you can design interactive forms with various interactive actions In Smart Forms we can design only Paper Forms But using Adobe Forms you can design PDF (or) Online Forms System Requirements for Installing Adobe Forms: 1. Adobe life cycle designer 2. Java stack 3. Version ECC 6.0 & above 4. QUI patch level should be greater than 5 Note: T code for working with Adobe Forms is SFP Adobe forms can be exploited using ABAP knowledge Web Dynpro Java Script Object: Develop an invoice form using Adobe forms Solution: Go to SFP Interface: ZBILL_INT Create Description: Invoice interface Enter By default Import option is selected On right side select Append Row option VBELN TYPE VBELN_VF Double click on Types option TYPES: BEGIN OF TY_VBRP, VBELN TYPE VBELN_VF, MATNR TYPE MATNR, FKIMG TYPE FKIMG, ARKTX TYPE ARKTX, NETWR TYPE NETWR, END OF TY_VBRP. TYPES: T_VBRP TYPE TABLE OF TY_VBRP. Rohini kumar
SAP-ABAP
Double click on Global Data On right side select Append Row option IT_VBRP TYPE T_VBRP Double click on Code Initialization Above Input Parameters, select Append Row Above Output Parameters, select Append Row VBELN IT_VBRP SELECT VBELN MATNR FKIMG ARKTX NETWR FROM VBRP INTO TABLE IT_VBRP WHERE VBELN = VBELN.
Activate Back Form: ZBILL_FORM Create Description: Invoice form Interface: ZBILL_INT Enter Expand Import Drag & drop VBELN under ZBILL_FORM Expand Global Data option Drag & drop IT_VBRP under ZBILL_FORM Expand System Fields Expand SFPSY Drag & drop DATE, USER NAME under ZBILL_FORM Layout Palettes ---- Library Place Text Icon on Design view Place Image Icon on design view Double click on Image Ok Select any Logo, Open Right click on image Palettes ----- Object Embed Image Data Close Place VBELN, DATE, USER NAME on design view Place IT_VBRP on design window Save Close
Rohini kumar
635
SAP-ABAP
Activate Go to SE38 Program: ZSD_ADOBE_FORM Create Title: Adobe form Type: Executable Program Save
PARAMETERS p_vbeln TYPE vbeln_vf. DATA: fname TYPE RS38L_FNAM, output TYPE SFPOUTPUTPARAMS. PERFORM open_form. PERFORM call_form. PERFORM close_form. FORM open_form. CALL FUNCTION ‘FP_JOB_OPEN’ CHANGING IE_OUTPUTPARAMS = output. ENDFORM. FORM call_form. CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’ EXPORTING I_NAME = ‘ZBILL_FORM’ IMPORTING E_FUNCNAME = fname. CALL FUNCTION FNAME EXPORTING VBLEN = p_vbeln. ENDFORM. FORM close_form. CALL FUNCTION ‘FP_JOB_CLOSE’. ENDFORM. Activate Execute Provide input Execute Rohini kumar
636
SAP-ABAP
Debugging Techniques: Table Level Debugging: Using table level debugging you can manipulate data directly from table level Example: Go to SE11 Database Table: KNA1 Display Contents Kunnr: 1000 to 1005 Execute Select Select All option (F9) Display (F7) Command Prompt: /H Enter Enter Debugging ----Switch to New ABAP Debugger Variable CODE
Enter Scroll horizontally Click on Change Field Remove SHOW & provide EDIT
Note: For delete ------ DELE For modify ---- EDIT For insert ------ INSR
Enter F6 ………………. F8 Provide input (which you want to modify) Save Next Entry Provide input (which you want to modify) Save
Rohini kumar
637
SAP-ABAP
Modifying Data during Debugging: Go to SE38 Program: any program name Debugging Provide input values Execute Tables Table: internal table name F6 Double click on the record which you want to modify Click on Pen option Modify & Enter
Rohini kumar
638
SAP-ABAP
Debugging Background Jobs: Go to SM37 Job Name: any job name Execute You will find a job name tick its check box ***Command Prompt: JDBG Enter Enter
Rohini kumar
639
SAP-ABAP
Lock Object: Using lock object you can maintain data integrity between applications Example: Go to SE11 Database Table: YCUSTOM Create Short Description: custom table Delivery Class: A Table View Maintained: Display / view allowed Fields tab Field name Data element MANDT MANDT KUNNR KUNNR NAME1 NAME1
Technical Settings Data Class: APPL0 Size Category: 0 Save Back Activate Utilities ---- Table Contents ---- Create Entries Kunnr: 1000 Name1: satya Save
Go to SE38 Program: ZLOCK Create Title: lock object program Type: Executable Program Save
TABLES YCUSTOM. PARAMETERS p_cust TYPE KUNNR. START-OF-SELECTION. CALL SCREEN 100. Double click on 100 Rohini kumar
640
SAP-ABAP
Yes Short Description: main screen Layout F6 Table: YCUTOM Enter Select all fields, Enter Place the fields on screen Flow Logic Remove comment for MODULE STATUS_100 Double click on STATUS_100 Yes Main Program Enter
SELECT SINGLE * FROM YCUSTOM WHERE KUNNR = p_cust.
Go to /OSE11 Lock Object: EZLCK1 Create Short Description: lock object Tables Name: YCUSTOM Lock Mode: WRITE LOCK Activate
Note: Once your lock object is activated system will create 2 function modules One for applying lock & Another for releasing lock
Goto ---- Lock Modules Copy Request Lock function module (ENQUEUE_EZLCK1) Select your program session (SE38) Pattern Call Function: paste (ENQUEUE_EZLCK1) Enter
CALL FUNCTION ‘ENQUEUE_EZLCK1’ EXPORTING MODE_YCUSTOM = ‘E’ MANDT = SY-MANDT Rohini kumar
641
SAP-ABAP
KUNNR = p_cust. Activate
Remove comment for MODULE USER_COMMAND_100 Double click on USER_COMMAND_100 Yes Main Program Enter Select DDIC (SE11) session Copy Release Lock function module (DEQUEUE_EZLCK1) Go to SE38 session Pattern Call Function: paste (DEQUEUE_EZLCK1) Enter
CALL FUNCTION ‘DEQUEUE_EZLCK1’ EXPORTING MODE_YCUSTOM = ‘E’ MANDT = SY-MANDT KUNNR = p_cust. Activate Back Activate Testing: Go to SE38 Execute your program Done Go to /OSE38 Execute your program Not Done Note: In real time locks are released manually using T code SM12 o Go to SM12 o List o Select locks o Lock Entry ----- Delete All Rohini kumar
642
SAP-ABAP
Search Help Exit: Example: Go to SE11 Database Table: YCUST1 Create Short Description: custom table Delivery Class: A Table View Maintained: Display / view allowed Fields tab Field name Data element MANDT MANDT KUNNR KUNNR NAME1 NAME1 1000 1001 1002 1003
Technical Settings Data Class: APPL0 Size Category: 0 Save Back Activate Insert the following records into table satya satya satya pruthvi Go to SE37 Function Module: F4IF_SHLP_EXIT_EXAMPLE Copy To: ZSEARCH_MOD Function Group: ZFGR Enter Enter Function Module: ZSEARCH_MOD Change Scroll down to bottom, before EXIT
SORT RECORD_TAB. DELETE ADJACENT DUPLICATES FROM RECORD_TAB. Activate Rohini kumar
643
SAP-ABAP
Go to SE11 Search Help: ZSEAR_HELP Create Enter Short Description: elementary search help Selection Method: ZCUST1 Search Help Exit: ZSEAR_HELP Scroll down to bottom, provide Search Help Parameter Export Import NAME1 _/ _/
644
LPOS 1
SPOS 1
Activate
Go to SE38 Program: ZCALL_SEARCH Create Title: search help exit program Type: Executable Program Save
PARAMETERS p_search MATCHCODE OBJECT ZSEAR_HELP. Activate Execute Apply F4 on field You will find only sorted list i.e. 1000 satya 1004 pruthvi
Rohini kumar
SAP-ABAP
645
Questions & Answers:
BDC: Question-1: Assume my Session has been processed & after processing I want my Session to be displayed in SM35 for status check. How you can achieve this task? Answer: By providing exporting parameter KEEP = ‘X’ you can get your processed session back in SM35 Question-2: How you can maintain Logs (or) Error records in Session method? Answer: In Session method SAP is providing a Log file by default No need to create a Log file for handling error records You can find Log file by using SM35 Go to SM35 Select your session Select Log option (F7) Select your session Select Display button Question-3: How you can perform background processing in Session method? Answer: Using program RSBDCSUB you can execute session in background Example: In above program modify subroutine PERFORM close_session. FORM close_session. CALL FUNCTION ‘BDC_CLOSE_GROUP’. SUBMIT RSBDCSUB VIA SELECTION-SCREEN. ENDFORM. Execute F4 Select your Flat File Rohini kumar
SAP-ABAP
646
Execute You will find a selection screen Session: RGS Execute
Question-4: Suppose I’m having a Flat File with 50000 records. It happened that the system crashed while uploading data. How I know the number of records exactly uploaded? Answer: I will go to respective database table & copy the key values to the table & execute it Question-5: Assume there are 1000 records out of which I uploaded 500 records & remaining I want to upload next day. How you will you perform this job? Answer: I will check the status of the records uploaded & I will delete the records from Flat File which are correctly uploaded & remaining I will execute once again on next day Question-6: I’m having 2 Flat Files with 500 records & 50000 records. Which method will you prefer for both Flat Files? Answer: For 500 records Call Transaction Method For 50000 records Session Method Question-7: What is the difference between Session Method & Call Transaction Method? Answer: Session Method Call Transaciton Method 7. It for uploading large amount of data 1. It for uploading small amount of data 8. Multiple applications can be processed 2. Only single application can be processed at one time with one BDC program at one time with one BDC program 9. In this method respective Log File is 3. In this method we have to create Log file already given by SAP explicitly using structure BDCMSGCOLL 10.Asynchronous processing 4. Synchronous processing 11.Synchronous updating 5. Asynchronous updating 12.It is a slower method but consistent 6. Faster than Session method Question-8: How will you handle error records BDC? Answer: In real time client will ask error records during BDC upload Rohini kumar
SAP-ABAP
647
For that we have to provide him Logs in the form of error file In Session Method Log file you can find directly in SM35 In Call Transaction Method as processing synchronous we have to create a Log file internal tabld based on structure BDCMSGCOLL which holds log details during processing of application The error records are looped to respective work area which further exported to Funtion Module FORMAT_MESSAGE It returns a Message ID which I will capture by using a dummy internal table 1.) What is the full form of bdc? Ans: Batch data communication 2.) What is alternate to batch input session? Ans: Call transaction and call dialog. 3.) What are the steps in bdc session? Ans: The first step is to identify screens of a transaction the program will process Next step is to write a bdc program to build a bdc table will be used to submit data in sap. The final step is to submit the bdc table to the system in the batch mode or through a single call transaction method. 4.) What table stores on line messages? Ans: T100 5.) What do u do if system crashes in middle of bdc? Ans: I will check the number of record updated and delete the same from flat file and upload again. (I will check the log file in sm35) 6.) What do u do with errors in bdc session? Ans: Analyze the input file format and entries in internal table bdc data. 7.) What are the commands for sequential file and their syntax? Ans: 1. Read dataset file into . 2. Open dataset file in binary mode 3. Close dataset . 4. Transfer to . 5. Delete dataset . Rohini kumar
SAP-ABAP
8.) Why batch input? Ans: To upload large amount of information at peak times 9.) Can data be put directly in database in sap? Ans: No, only when data has been entered into transaction. 10.) Explain at high levels, the batch input sessions? Ans: Batch data is placed in queues called batch input sessions Then placed into Application programs for maintenance Then into the database 11.) What are the function modules for batch input? Ans: 1. Bdc_open_group 2. Bdc_insert 3. Bdc_close_group 12.) What is the structure of bdc table? Ans: 1. Program (program name) 2. Dynrpo (screen numbers) 3. Dynbegin (start screen) 4. Fnam (fieldnames) 5. Fval (field values) 13.) Write down the coding example of filling the data into bdc table ? Ans: 14.)How do u find the transaction number, screen numbers and fieldnames? Ans: System->status F1 Technical attributes Functional Tech specs Recording 15.) What are the processing modes of batch input? Ans: 1. Foreground 2. Background Rohini kumar
648
SAP-ABAP
649
3. Display with errors 16.) What is the effect of bdc_cursor field in bdc table? Ans: U can set the cursor and enter the corresponding field value and corresponding Fieldname on which the cursor to be positioned 17.) Why u choose session or call transaction method? Ans: When u want to update database for a single transacton->ctm U can update the database in asynchronous mode. U can update huge database updating for more than one transaction. 18.) How u can trap error in ctm? Ans: Errors can be trapped using a structure BDCMSGCOLL, whose field MSGTYP will become ‘E’ whenever an error occurs. There errors are formatted using FORMAT_MESSAGE in the desired format and stored in an internal table. 19.) What are the diff types of update modes? Ans: 1. Synchronous 2. Asynchronous 20.) What is diff b/w session method and lsmw? Ans: In session the method of updation is ‘BATCH INPUT’ we require a program to be coded. In lsmw the method of updation is BATCHINPUT, DIRECT INPUT, IDOC, BAPI. Here method is through navigation. 21.) How do u find the information in current screen? Ans: Menu->system->status 22.) How do u save data in bdc tables? Ans: By using field name BDC_OKCODE and value is ‘/11’. 23.) What is multiple line field? Ans: It is special field, which allows user to enter multiple lines in it. 24.) What is the last entry in bdc tables? Rohini kumar
SAP-ABAP
650
Ans: The last entry is to save data using BDC_OKCODE and the value is ‘/11’. 25.) An index is added to the fieldname to indicate which line is to be populated by bdc session? Ans: 26.) What is batch input session? Ans: Intermediate step between internal table and database table Data along with the action is stored in session i.e. Data for screen fields, to which screen the data should be passed, the program behind the screen. 27.) A situation: an abap program creates a batch input session. We need to submit the Program and batch input session in background. How will u do it? Ans: Go to SM36 and create a background job by giving job name, job class and job steps (background scheduling steps). 28.) What are the problems in processing batch input sessions? Ans: If user forgets to ‘keep’ session then session is automatically removed from session queue and the log remains 29.) Which mode in call transaction allows background processing? Ans: ‘n’ 30.) What is the syntax of call transaction method? Ans: 31.) Is it possible to use call transaction without bdc table? Ans: Yes, in such case the current program is suspended, the transaction specified is brought up and a user must enter data into screens. 32.) How many sessions are opened with BDC_OPEN_GROUP? Ans: One. 33.) What is batch input or bdc? Ans: The methods ctm and session are collectively called batch input for transferring data between systems. Rohini kumar
SAP-ABAP
651
34.) What are the advantages of batch input? Ans: Ensures data integrity No manual interaction for data transfer 35.) What is synchronous database update? Ans: No new transaction is started until previous transaction is written to database. 36.) Suppose there are 1000 records and there is an error at 66 record. How will u identify and send it to end user? Ans: Using BDCMSGCOLL u can capture error records and using T code SLG1 u can find it. 37.) I am uploading 1000 records using session method. I have an error at 950 record. What will happen in both ctm and session method? Ans: Up to 949 records are updated using session method. Except 950 remaining all records are update using ctm. 38.) What is the use of OK_CODE in bdc? Ans: Bdc_okcode will hold all the ok codes in the bdc program, When u pass fields to a screen after filling the fields we need to click on a button to move other screens, So here, button will have a ok_code internally to know this we are recording in a program After that, we will store this ok_code in bdc_okcode field to trigger next operation. 39.) How will generate and processing the session in the same program? Ans: In ur program using SUBMIT RSBDCSUB VIA SELECTION-SCREEN 40.) How will run bdc program in background? Ans: RSBDCSUB 41.) I want to upload 10 lakh records and each record is taking 1 minute for processing. How will solve this issue? Ans: Break the records into 100/1000 sessions and process ur session it will take same time as it take for single sessions. We can go through lsmw direct input method. Use bapi run in background. 42.) How does u know that updation is successful or not? Rohini kumar
SAP-ABAP
652
Ans: Using BDCMSGCOLL u can find the errors In session method go to SM35 see the status (the green shows successful & red with errors) 43.) If I want to upload 5 lakh records. Which method do think is best? Ans: Session as it provide log for each record processed 44.) What is ‘keep’ in bdc structure? Ans: It is an indicator to check processed sessions If this flag is set then session is kept even after it is processed otherwise session is deleted after its processing is over. 45.) After running a bdc program with session, I found few errors next morning. What will u do? Ans: Correct the error records (ur flat file) and run bdc program. If problem is not in session then I will check the bdc program. 46.) U are given FD for bdc, how will u decide which method to use? Ans: It depends on client requirement If it is large data use session method. Small amount of data use ctm. 47.) How will run bdc program in background? Ans: RSBDCSUB (or) SM36 48.) What is the utility of BDC_CURSOR? Ans: Move cursor location to a specific screen field where data need to be inserted. 49.) What is the difference between batch input and direct input? Ans: Batch Input Direct Input 1. Validations are done based on predefined 1. Validations are done by applications Function Module 2. We cannot send the fields according to 2. Fields can be send (our requirement) Our requirement
Rohini kumar
SAP-ABAP
653
50.) How do u write a program in session such that it will run the program without going to SM35 and creates a session? Ans: SUBMIT RSBDCSUB VIA SELECTION-SCREEN AND RETURN. 51.) How will u handle Table Control in bdc? Ans: 52.) What are the types of batch input? Ans: 1. Classical batch input 2. Call transaction 3. Call dialog 53.) How u can execute a function code in bdc session? Ans: Bdcdata-fnam = ‘bdc_okcode’. Bdcdata-fval = ‘=upda’. 54.) How we can position a cursor on a particular field? Ans: Bdcdata-fnam = ‘bdc_cursor’. Bdcdata-fval = ‘fieldname’. 55.) What are dialog users and background users? Ans: Dialog users are normal interactive users in sap system. Background users are user master records that are specially defined for providing authorizations for background processing jobs. 56.) What are update modes in call transaction? Ans: 1. Synchronous (s) 2. Asynchronous (a) 3. Local (l) 57.) What does message parameter indicate? Ans: It indicates that all system messages issues during call transaction are written into internal table created based on
Rohini kumar
SAP-ABAP
654
58.) What is direct input? Ans: To enhance batch input procedure, the system offers direct input technique especially for transferring for large amount of data. It does not create sessions but stores data directly in database. The direct input programs are executed directly in background To maintain and start these programs use program RBMVSHOW (or) T code BMV0. 59.) What are the features of recording? Ans: Generates a batch input program from recorded data. 60.) How do u set up batch input process? Ans: Data analysis: analyze the data that is to be transferred to SAP system. Generate SAP structures: generate structures to incorporate for incorporation into data export programs. Develop transfer programs: bdc program Create sequential file: export the data to be transferred to a sequential file. Create batch input program: read data to be transferred from the sequential file. Process batch input data: process data and add it to sap system(ctm and session method). Analyze errors: check all data is successfully processed. Analyze error session: correct and reprocess erroneous session. 61.) What is CTU_PARAMS? Ans: This is a structure defined in SE11 that must be used to declare the type of variable After the options from keyword of call transaction…. DATA: WA_PARAMS TYPE CTU_PARAMS. WA_PARAMS-DISMODE = ‘X’. WA_PARAMS-UPDMODE = ‘X’. CALL TRANSACTION ‘SM04’ USING IT_BDCDATA OPTIONS FROM WA_PARAMS. 62.) What are the commands available for controlling batch input session? Ans: 1. /bbeg------- restart transaction 2. /bbdel------ delete transaction from from batch input session 3. /n ----------- terminate current transaction 4. /bda--------- foreground processing 5. /bde--------- display mode to error mode 6. /bend------- end current batch input session Rohini kumar
SAP-ABAP
63.)Diff b/w session and call transaction method. Session method 1.)Using call transaction syntax 2.)Only one transaction is called. 3.)The abap program must do the error handling itself (call transaction return error messages into internal table) 4.)By default standard size is not used. 5.)Update mode can be chosen.(syn,asyn) 6.)U may use racommit of ctu_params To not stop the bdc at the end of commit_work 7.)Sy-binpt is always set to space using nobinpt Of ctu_params 8.)As sy-binpt is reset to ‘x’ after commit work it Can be set to ‘x’ again by using nobiend of ctu_params Option cattmode of ctu_params can be used. 9.)All display modes can be used including p and s. 10.)Recording(shdb). Session method: 1.)It is saved to database using function modules Bdc_open_group,bdc_insert,bdc_close_group and Later run by sm35 or programs rsbdcsub,rsbdcbtc. It does not run ctu but bdc_start_group. 2.)Several transaction can be processed with one session. 3.)There is built in error and recovery mechanism in sm35 To view error records and run the erroneous records again (note:bdc data cannot be corrected) 4.)By default standard size is used(22 lines * 84 columes) 5.)Update mode is always synchronous. 6.)Transaction execution always stops at commit_work. 7.)Sy-binpt value is always ‘x’. 8.)Always stops after commit_work. 9.)Always display modes can be used except p & s. 10.)Extended log,expert mode,cancel if log occurs. 63.) How do I record a batch input session for later playback? Ans: SHDB(recording) 64.) Why SHDB doesn’t record some screens? Ans: There was probably a commit work. By default recording stops after commit_work
Rohini kumar
655
SAP-ABAP
656
65.) How will copy a recording? Ans: Display the recording There is a button to export to a file on ur presentation server. Create a recording without T code and without starting the recorder, A but to input is displayed 66.) How does recording work? Ans: It works similarly as ctm, It is surrounded by kernel SET_TRANS_VAR for activating and deactivating recording using function module BDC_RECORD_TRANSACTION. SHDB records the bdc data into APQI and APQD tables. Lsmw uses same technique but records bdc data into tables SAPDMC (or) LSGBDC* tables.
Rohini kumar
SAP-ABAP
657
BDC FAQS: 1Q: What should be the approach for writing a BDC program? Ans: Analysis the Data Generate SAP structure Develop transfer program Create sequential file Create batch input program Process batch input data 2Q: What is the alternative to batch input session? Ans: Call transaction & Call Dialog 3Q: What are the steps in a BDC session ? Ans: The first step in a BDC session is to identify the screens of the transaction that the program will process. Next step is to write a program to build the BDC table that will be used to submit the data to SAP. The final step is to submit the BDC table to the system in the batch mode or as a single transaction by the CALL TRANSACTION command. 4Q: What are the problems in processing batch input sessions? How is batch input process different from processing on line? Ans: Sessions cannot be run in parallel and not fast. 5Q: What do you do when the system crashes in the middle of a BDC batch session? Ans: Check no. of records already updated and Delete them from input file and Run BDC again. 6Q: What do you do with errors in BDC batch session? Ans: Analysis and correct input file format and entries in internal table BDCDATA. 7Q: What are the commands that allow you to process sequential file? What is their syntax? Ans :1. READ DATASET (reading) and 2. TRANSFER (writing) Syntax: Rohini kumar
SAP-ABAP
OPEN DATASET for < appending=" MESSAGE. READ DATASET INTO. CLOSE DATASET. DELETE DATASET. TRANSFER to
658
" output=" "> in mode at POSITION
8Q: What is the process for transferring data from legacy system to SAP? Ans: FTP file transfer, Manufacturer –specific field transfer NFS (network file system) (or) BDC. 9Q: How many types of tables exists and what are they in data dictionary? Ans: 10Q: What is the step-by-step process to create a table in data dictionary? Ans: Create Domain. Create Data Element. Create Actual Table. 11Q: Can a transparent table exist in data dictionary but not in the data base physically? Ans: NO 12Q: What are the domains and data elements? Ans: 13Q: Can you create a table with fields not referring to data elements? Ans: NO. 14Q: What is the advantage of structures? How do you use them in the ABAP programs? Ans: 15Q: What does an extract statement do in the ABAP program? Ans: An extract dataset consists of a sequence of records. These records may have different structures. All records with the same structure form a record type. You must define each record type of an extract dataset as a field group, using the FIELDGROUPS statement. Rohini kumar
SAP-ABAP
659
When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset. 16Q: What is a collect statement? How is it different from append? Ans: COLLECT: When the line is inserted, the system checks whether there is already a table entry that matches the key. If there is no corresponding entry already in the table, the COLLECT statement has the same effect as inserting the new line. If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry. 17Q: What is Open SQL v/s Native SQL? Ans: Open SQL allows you to access database tables declared in the ABAP Dictionary regardless of the database platform that your R/3 System is using. Native SQL allows you to use database-specific SQL statements in an ABAP program. This means that you can use database tables that are not administered by the ABAP Dictionary, and therefore integrate data that is not part of the R/3 System. 18 (a). What does an EXEC SQL stmt do in ABAP? Ans: To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows: EXEC SQL. ENDEXEC. 18(b). What is the disadvantage of using EXEC SQL stmt do in ABAP? Ans: Using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax 19Q: What is the meaning of ABAP editor integrated with ABAP data dictionary? Ans: Area menu
Rohini kumar
SAP-ABAP
660
20Q: What is an interactive report? What is the obvious differences of such report compared with classical type reports? Ans: Interactive reporting allows the user to participate in retrieving and presenting data at each level during the session. Gives a basic list form, which the user can call detailed information by positioning the cursor and entering the commands Classical reports consists of one program the creates a single list which contains clustered data requested, regardless of the details the user wants to see. 21Q: What is a drill down report? Ans: A drilldown report is a report used for the interactive evaluation of data. (Interactive reports) 22Q: How do you write a function module in SAP? Describe?. Ans: Create function group. Create function module program in se37. Specify the parameters for passing data to and from the module and the exceptions. Write source code. Write executable program calling the functional program. 23Q: What are the exceptions in function module? Ans: Exceptions are used to handle errors. The Function module checks for any type of error & raise exception & returns SYSUBRC to the calling program. Main program checks for SY-SUBRC for any errors and then takes action accordingly. 24Q: What is a function group? Ans: Function Modules that operate with same data can be grouped in one known as function group. 25Q: How are the date and time field values stored in SAP? Ans: SY-DATUM & SY-UZEIT 26Q: What are the fields in a BDCTab Table? Ans: 1. PROGRAM 2. DYNPRO 3. DYNBEGIN Rohini kumar
SAP-ABAP
661
4. FNAM 5. FVAL 27Q: Name few data dictionary objects? Ans: 28Q: Why batch input? Ans :- To input a large amount of information at off peak times. 29Q: Can data be put directly into the database? Ans:- No, only after the data has been entered via transaction. 30Q: Explain at high level, the batch input process? Ans : Batch data is placed into queues called batch input sessions Then placed into the application programs for maintenance into the database 31Q: What are the function modules associated with batch input? Ans :1. BDC_OPEN_GROUP , 2. BDC_CLOSE_GROUP , 3. BDC_INSERT 32Q: What is the structure of the BDC table? Ans :Program / Dynpro / Start / Field Name / Field Content 33Q: Write out a coding example for filling a BDC Table? Ans :FORM REFEESH CLEAR MOVE to -PROGRAM TO -DYNPRO ‘X’ TO -DYNBEGIN APPEND CLEAR MOVE: TO -FNAM TO -FVAL APPEND
Rohini kumar
SAP-ABAP
662
34Q: How do you find the transaction number, program number and field names? Ans : Transaction no., Program no – System -> status Field names - F1, Technical help 35Q: What are the processing modes for Batch Input? Ans :1. Process on screen (foreground) , 2. Display errors only and 3. Process in the background 36Q: What are the available OK Codes that can be utilized during batch input processing? Ans :/n –-------- terminates current batch input transaction and marks as incorrect. /bdel –---- delete current batch input transaction from session. /bend –----- terminate batch input processing and mark session as incorrect. /bda –------ change display mode to process the session on screen instead of displaying only errors. /bde –------ change display mode to display only errors instead of processing the session on the screen. 37Q: What is the effect of the BDC_CURSOR field name in the BDC table? Ans :You can set the cursor and enter as a corresponding field value the name of the field on which the cursor is to be positioned 38Q: How many types of BDCs you have done? Ans: 39Q: Why you choose Call transaction and/or session method? Ans: Call transaction is mainly used when you want to update the database using a single transaction You can also update the database in asynchronous mode, Whereas session is used to perform huge database updations using more than one transaction and which will last for a long time. 40Q: What are different types of Update modes? Ans: In BDC’s we have two types of updation modes – 1) Synchronous 2) Asynchronous Rohini kumar
SAP-ABAP
663
41Q: What is main difference between session method and LSMW? Ans: In the context of session method, the method of updating is “Batch Input” , we require a program to be coded, But in the context of LSMW method, The methods of updating using “Batch Input/Direction Input” from an IDOC, from a BAPI structure. No source code is required the complete operation is performed in 16 steps sequence 42Q: What is main difference between CATT and LSMW? Ans: Using LSMW you can update any kind of data but no changes to database are allowed, Whereas CATT tool can update only master data, which also allows changes to the master data and also a significant testing of data is possible 43Q: Give real time work done by u in BDC ? Transactions used ? parameters passed with functions? Ans:
44Q: Will ask u for screen no's and dynpro names for BDC that u say u have done? Ans: 45Q: Which technical field in the BDCDATA table holds the last cursor position? Ans: 46Q: How do you read a LOCAL sequential file? Ans: 47Q: How do you write a sequential file? Ans: 48Q: How do you send the BDCDATA table in a Call Transaction statement? Ans: 49Q: What loop do you code for a READ DATASET statement? Ans:
Rohini kumar
SAP-ABAP
664
50Q: What are the steps in a BDC session ? Ans: The first step in a BDC session is to identify the screens of the transaction that the program will process. Next step is to write a program to build the BDC table that will be used to submit the data to SAP. The final step is to submit the BDC table to the system in the batch mode or as a single transaction by the CALL TRANSACTION command.
Rohini kumar
SAP-ABAP
665
SCRIPTS & SMART FORMS: Ques-1: Why we should call SSF_FUNCTION_MODULE_NAME instead of hardcoding the function module name itself? Answer: We know that in real time we have to transport the objects from one client to another client If the form is in Quality Server the system may assign a different version of function module name to respective form & the same happen in Production Server also So therefore it always advaisable to call SSF_FUNCTION_MODULE_NAME which returns the function module currently which system you are working Ques-2: What are the common errors you are facing while working with smart forms? Answer: 9. Incorrect parameter with call function This exception you will get if you not pass all the parameters which you maintained in smart form 10.Type conflict when calling a function module This exception you will find when data type of smart form parameters will not match with attributes of print program 11.Reference field …………unknown in form This error you will find if you are not maintaining Currency / Quantity fields in smart form 12.*** sometimes your print program will not be executed at all This will happen when your Window (specially Templates) are not maintained properly 13.Template doesnot fit into window This will happen when template height is more than window height 14.Form generation error This error you will find if form is having internal errors in Production Server thow it is perfectly tested in Development Server
15.*** Table is wider than window This error you will find if your Table (or) Template is wider than your window based on which is created Rohini kumar
SAP-ABAP
16.Graphic cannot be displayed This error you will find if graphic is not maintained properly Ques-3: How do you work with Alternate option in smart form? Answer: Righ click on any one Window (say LOGO) Create ----- Window Alternate Right click on Alternate Window Create ----- Flow Logic ------- Alternate Conditions option Field name Relational Operator LIFNR double click Select =/= (NE) option Comparision Values ‘ ’ Right click on True option Create ------ Text Editor PO Created
Right click on Flase option Create ----- Text Editor PO not created
Form Painter Adjust Alternate window Activate form Ques-4: How you can work with more than one Page in smart form? Answer: Right click on PAGE1 Create ------ Page Right click on PAGE2 Create ---- Window Window: LETTER Meaning: Window for letter description Save Right click on LETTER window Rohini kumar
666
SAP-ABAP
Create ----- Text Editor Goto ------ Change Editor * ,,,,,,,,,,Dear Satya, * ,,,,,,,,,,Yor are shortlisted in Google as a Technical Consultant * ,,,,,,,,,,Thanking you,
Back Double click on MAIN window Window Type: Secondary Window Double click on PAGE1 Next Page: PAGE2 Double click on PAGE2 Next Page:______ Activate form
*** Ques-5: How you can convert a smart form into PDF format? Answer: Run your print program Provide input Execute Select Print option (Ctrl + P) At bottom you will find a print request number note down it (say 11716) Go to SE38 Program: RSTXPDFT4 Execute Spool Request: 11716 Execute Save Ques-6: How you can debug a smart form? Answer: Go to SMARTFORMS Form: ZPO_FORM Change Expand VENDOR window Double click on CODE1 Provide BREAK-POINT Activate form Go to SE38 Rohini kumar
667
SAP-ABAP
668
Program: ZMM_CALL_SMART_FORM (print program) Execute Note: In smart forms you can set only Static Break Point. You cannot set Dynamic Break Point Ques-7: How you can work with Excel Sheet in smart forms? Answer: DATA fnam TYPE STRING. CALL FUNCTION ‘GUI_DOWNLOAD’ Ques-8: How you can print multiple records in smart forms? Answer: ZMM_CALL_SMART_FORMN TABLES: EKPO, EKKO, LFA1, ADRC. SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000. SELECT-OPTIONS: s_ebeln FOR ekko-ebeln. SELECTION-SCREEN: END OF BLOCK b1. DATA: fname TYPE RS38L_FNAM, control TYPE SSFCTRLOP. DATA: BEGIN OF wa_ekko, ebeln TYPE ebeln, bedat TYPE bedat, lifnr TYPE lifnr, END OF wa_ekko. DATA: wa_ekpo TYPE zpo_strucc, it_ekpo TYPE TABLE OF zpo_strucc. DATA: fnam TYPE STRING. CONTROL-NO_OPEN = ‘X’. CONTROL-PREVIEW = ‘X’. CONTROL-NO_DIALOG = ‘X’. CONTROL-NO_CLOSE = ‘X’. Rohini kumar
SAP-ABAP
669
START-OF-SELECTION. CALL FUNCTION ‘SSF_OPEN’ EXPORTING USER_SETTINGS = ‘X’. CONTROL_PARAMETERS = control. CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’ EXPORTING FORMNAME = ‘ZPO_FORM’ IMPORTING FM_NAME = FNAME. LOOP AT S_EBELN. PERFORM get_data USING s_ebeln-low. CALL FUNCTION FNAME EXPORTING CONTROL_PARAMETERS = control EBELN = s_ebeln-low BEDAT = wa_ekko-bedat LIFNR = wa_ekko-lifnr TABLES IT_EKPO = it_ekpo. ENDLOOP. CALL FUNCTION ‘SSF_CLOSE’. FORM get_data USING ORDER. SELECT SINGLE ebeln bedat lifnr FROM EKKO INTO wa_ekko WHERE ebeln EQ ORDER. IF NOT wa_ekko IS INITIAL. SELECT ebelp txz01 menge netpr netwr FROM EKPO INTO TABLE it_ekpo WHERE ebeln = wa_ekko-ebeln. ENDIF. ENDLOOP.
Rohini kumar
SAP-ABAP
670
Ques-9: How you can migrate SAP Script to smart form? Answer: Go to SMARTFORMS Utilities ---- Migration ----- Import SAP Script Form Form: ZPO_MEDD Name: ZPO_MEDD Enter Ques-10: How you can generate smart form into PDF format during runtime of print program? Answer:
Ques-11: How you can send of a form in the form of mail? Answer: Ques-12: How you can write code in smart forms? Answer: Ques-13: How you can maintain Page Breaks in smart forms? Answer: 1. ) How to Force a page break within table loop ? Ans: Create a loop around the table. Put a Command node before the table in the loop that forces a NEWPAGE on whatever condition you want. Then only loop through a subset of the internal table (based on the conditions in the Command node) of the elements in the Table node. 2.) Difference between 'form interface' and 'global definitions' in global settings of smart forms? Ans: Form Interface is where you declare what must be passed in and out of the smart form (in from the print program to the smart form and out from the smart form to the print program). Global definition is where you declare data to be used within the smart form on a global scope. Rohini kumar
SAP-ABAP
671
ie: anything you declare here can be used in any other node in the form. 3.) How u can convert Smart Forms Output to PDF? Ans: There is a way to download smart form in PDF format. Please do the following: 1. Print the smart form to the spool. 2. Note the spool number. 3. Download a PDF file (Acrobat Reader) version of the spool by running Program RSTXPDFT4 and entering the noted spool number. 4.) How u print a Smart Form Double sided (Duplex printing)? Ans: Your customer wants your PO Smart Form to be able to print "Terms and Conditions" on the backside of each page. They do not want to purchase pre-printed forms with the company's logo on the front and terms & conditions on the back. Easy - page FRONT lists page CONTACTS as next page and CONTACTS lists FRONT as next page. Since CONTACTS does not contain a MAIN window, it will print the contacts info and then continue on to FRONT for the rest of the main items. Additionally, set print mode on FRONT to D (duplex) and set CONTACTS to 'blank' (for both resource name and print mode - this is the only way to get to the back of the page). 5.) How u can transport SMARTFORM? SE01? Ans: 6.) How do you make sure that both, the SMARTFORM & it's function module gets transported? (or) Does the FM with same name gets generated automatically in the transported client? Ans: A smart form is transported no differently than any other object. If it is assigned to a development class that is attached to a transport layer, it will be transported. The definition is transported, and when called, the function module is regenerated. This leads to an interesting situation. On the new machine, it is very likely the function module name will be different than the name on the source system. Make sure, before you call the function module, you resolve the external name to the internal name using the 'SSF_FUNCTION_MODULE_NAME' function module. Typically, generate the SF, then use the pattern to being in the interface. Rohini kumar
SAP-ABAP
672
Then change the call function to use the name you get back from the above function module. 7.)How to protect lines in the main window from splitting between pages? Ans: It was easy with SAP script, but how to do it with SFs For 4.7 version if you are using tables there are two options for protection against line break 1. You can protect a line type against page break. 2. You can protect several table lines against page break for output in the main area. Protection against page break for line types Double-click on your table node and choose the Table tab page. Switch to the detail view by choosing the Details pushbutton. Set the Protection against page break checkbox in the table for the relevant line type. Table lines that use this line type are output on one page. Protection against page break for several table lines: Expand the main area of your table node in the navigation tree. Insert a file node for the table lines to be protected in the main area. If you have already created table lines in the main area, you can put the lines that you want to protect again page break under the file using Drag &Drop. Otherwise, create the table lines as sub nodes of the file. Choose the Output Options tab page of the file node and set the Page Protection option. All table lines that are in the file with the Page Protection option set are output on one page. In 4.6, Alternatively in a paragraph format use the Page protection attribute to determine whether or not to display a paragraph completely on one page. Mark it if you want to avoid that a paragraph is split up by a page break. If on the current page (only in the main window) there is not enough space left for the paragraph, the entire paragraph appears on the next page. 8.) What are the differences between SAP Scripts and Smart forms? Ans: SAP Scripts are client dependent whereas Smart forms are client independent. SAP Scripts require a driver program to display the output whereas in smart forms the form routines can be written so that it is standalone. An integrated Form Builder helps to design Smart forms more easily than SAP Scripts A Table Painter and Smart styles to assist in building up the smart forms On activation a function module is generated for Smart forms
Rohini kumar
SAP-ABAP
673
9.) Is multiple page formats possible in smart forms? Ans: Multiple page formats is possible in smart forms 10.) How can I insert symbols in Smart forms? Ans: Select the Text node. Change Editor (Click the button above Check near the Editor) Go to menu Include->Characters->SAP Symbols Choose the SAP symbol that you want to insert. 11.) I have a smart form which works fine in DEV. After transporting it to PROD, there is no Function module generated for this smart form. As a result my program dumps in PROD? Ans: The Smart form that is created in the Development may not have the same name in the Production server. So it is always advised to use the Function Module SSF_FUNCTION_MODULE_NAME 12.) How u write Function Module name by passing the Smart form name? Ans: 13.) How can I make the Smart forms to choose a printer name by default? Ans: 14.) How can I display the total number of pages in Smartforms? Ans: SFSY-FORMPAGES -----------to display the total number of pages in the Smart forms SFSY-PAGE--------------------- Current page number SFSY-FORMPAGE------------ Total number of pages in the currently formatted layout set SFSY-JOBPAGE---------------Total number of pages in the currently formatted print request SFSY-COPYCOUNT---------Original-1,1st copy-2 SFSY-DATE------------ Date SFSY-TIME------------ Time SFSY-USERNAME--- Username 15.) What are the various text formatting options in Smartforms? Ans: &symbol(Z)&----------- Omit Leading Zeros &symbol(S)&----------- Omit Leading Sign &symbol()& -----------Display Leading Sign to the Right &symbol(C)& ----------Compress Spaces Rohini kumar
SAP-ABAP
674
&symbol(.N)& ---------Display up to N decimal places &symbol(T)& ----------Omit thousands separator &symbol(R)& ----------Right justified &symbol(I)& -----------Suppress output of the initial value 16.) Where can I provide the input parameters to the smart form? Ans: The input parameters for the smart form can be defined in Global Settings->Form Interface. The Associated Type must be defined in the ABAP Dictionary. 17.) Where can I define my own global types for the smart form? Ans: The global types (within the smart form) can be defined in Global Settings->Global Definitions->Types The types defined here will be global through the entire smart form. Also the form routines can be defined Global Settings->Global Definitions->Form Routines 18.)I have defined my own Program Lines, where I have used a global variable G_TEXT. I get an error G_TEXT is not defined? Ans: Whenever using the global variables in the Program Lines, enter the variable name in Input Parameters if you are going to use (read) the variable. If you are going to both read/write the variable value enter the same in Output Parameters. 19.) I have created a table node for display. Where can I check the condition which must satisfy to display the table? Ans: The conditions can be defined in the Conditions tab. In smart forms all the nodes have a condition tab where you can specify the condition to be satisfied to access the node. 20.) How can I define Page Protect in Smart forms? Ans: To define Page Protect for a node go to the Output options and check the Page Protection checkbox.
Rohini kumar
SAP-ABAP
675
21.) What is the difference between Template and Table in Smart forms? Ans: The Template contains a fixed number of rows and columns, where the output is fixed. The Table can have variable number of rows 22.) Where can I define the paragraph and character format for the smart forms? Ans: The paragraph and character format for the smart forms can be defined in the transaction SMARTSTYLES 22.) How will add watermark to smart form output? Ans: Go to the properties of 'PAGE', Tab 'Background Picture' Add the graphic image name here 23.) How to add buttons and radio buttons etc in smart forms? Ans: Buttons is not possible in smart forms (only in adobe forms it is possible). But you can insert checkboxes and radio buttons in smart forms. You can print a check box in different ways.. By inserting symbols and making window as check box.. Once go through the thread u will get to k now different ways 24.) How u can keep checkboxes in smart form? Ans: To use Check box in smart form do the following: Change the editor to 'PC Editor' and take the menu. In text editor of TEXT ELEMENTS.. Insert -> Characters -> SAP Symbols In print preview u can't see these changes.. 25.) How u can debug smart forms? Ans: By keeping a static breakpoint in program lines (BREAK . 26.) How can I provide a background shading to the table? Ans: In the Table Painter, you can specify the color and shading for the table lines.
Rohini kumar
SAP-ABAP
676
Faqs in Smartforms: 1.) What is the difference b/w Scripts and Smartforms? 2.) What is the diff b/w Table and a Template? In which requirements do u prefer table and in which cases u prefer template? 3.) How u can debug smartforms? 4.) How u can migrate scripts into smartforms? 5.) How u can convert scripts or smartforms into pdf format? 6.) How u can print signature in last page in smartforms? 7.) How u can apply control break functionality in smartforms? 8.) What is the functionality of : a.)Loop b.)Alternate c.)Command d.)Graphic e.)Program lines in smartforms. Given explanation with a real time example? 9.) Is main window is mandatory in smartforms? 10.) Is print program is mandatory in smartforms? 11.) How u can write a program in form in smartforms?(using program lines). 12.) How u can acheive page break in smartforms? 13.) What is page protection in smartforms? 14.) How is pre printed stationary done in smartforms? 15.) Is it possible to create a table in a normal window?Yes. 16.) Assume I hard coded a runtime function module in print program? If i am quality client for tesing I am getting dump? Why? 17.) How u can print multiple records say invoices and employee numbers with one time print program execution? 18.) What is the functionality of a.)SSF_FUNCTION_MODULE_NAME b.)SSF_OPEN c.)SSF_CLOSE 19.) I am getting an error Table is wider than window? How will u rectify it? 20.) How u can run a form without getting print dialog? 21.) I want 3 page to be printed out of 5 pages? How will u achieve it?
Rohini kumar
SAP-ABAP
677
Ques-1: What are the different ways of idntifing Customerexits (Functionexits)? Answer: Go to SE93 Transaction Code: XK01 Display Double click on Program name Find option Find: CALL CUSTOMER_FUNCTION Enter Double click on 001 Ques-2: What is the difference between Implicit & Explicit Enhancement? Answer: Under implicit enhancement you can write your own code Adding Z-enhancement in already existing one is called Explicit enhancement Example: Go to SE93 Transaction Code: VA01 Display Double click on Program Name You will find a spot given by SAP Enhance Right click ES_SAPMV45A Enhancement Implementation ----Create Implementation Ques-3: What is the difference between Enhancement spot (point) & Enhancement section? Answer: In enhancement spot both customized & standard code will be executed In enhancement section only customized code will be executed Ques-4: What is Transaction Variant in enhancements? Answer: Using transaction variant you can provide enhancements You can make fields as Required, Output only, Invisible mode……etc using SHDO (Transaction Variant) With above concept you have to create a Z-T code & the same you should provide it to end user (standard applications should not be effected)
Rohini kumar
SAP-ABAP
***Question-5: How you can change the status of an IDOC? Answer: Using standard program RBDAPP01
Rohini kumar
678