- In user exits we go by general method for enhancements while BADIs we use objects (oops concepts) methods for enhancement.
- User exits are used for adding additional functionality to the existing SAP standard transactions. Using User exits we can add additional functionality standard SAP functionality without making any changes to the original code. BADI is a standardized interface for ABAP sources that enables partners and customers to enhance SAP-delivered programs in their namespace.
- Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software.
- As with customer exits two different views are available:In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional software to standard SAP source code without having to modify the original object.
In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard logic if one is available. - In contrast to customer exits, Business Add-Ins no longer assume a two-level infrastructure (SAP and customer solutions), but instead allow for a multi-level system landscape (SAP, partner, and customer solutions, as well as country versions, industry solutions, and the like). Definitions and implementations of Business Add-Ins can be created at each level within such a system infrastructure.
- SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces. You do not have to register Business Add-Ins in SSCR.
- The Business Add-In enhancement technique differentiates between enhancements that can only be implemented once and enhancements that can be used actively by any number of customers at the same time. In addition, Business Add-Ins can be defined according to filter values. This allows you to control add-in implementation and make it dependent on specific criteria (on a specific Country value, for example).
- All ABAP sources, screens, GUIs, and table interfaces created using this enhancement technique are defined in a manner that allows customers to include their own enhancements in the standard. A single Business Add-In contains all of the interfaces necessary to implement a specific task.
Get all you need about SAP. Find SAP materials, SAP Real time issues, SAP Openings, SAP Resumes, SAP Tutorials with step by step navigations, SAP Certification Interview Questions etc covering almost all technical areas of SAP in ABAP, Workflow, Netweaver, Web-Services and many more......
Search This Blog
Monday, March 8, 2010
Difference Between BADI and User Exits/Customer Exits :
Difference between User exits & Customer exits :
- A user exit is considered a modification, since technically objects in SAP namespace are modified. Customer exits do not affect standard SAP source code.
- User Exits are forms (in the SAP Standard Includes) and are called by SAP standard programs using perform. Customer Exits are functions so they are called using call function (or more exactly Call customer function).
- Inside the form (user exit) you can read and change almost any global data from host program. Inside a function (customer exit) you can only access your import/export/changing/tables parameters.
- User exits are more flexible because you have more information to use in your code but on the other hand, it is very easy to manipulate erroneously global data and lead the standard program to a dump or even to make database inconsistent. Customer exits are more restrictive but you are sure any change you can make to any parameters will never lead to inconsistency.
- User-exit doesn't have any classification. In customer-exit we have function-module exit, screen exit, menu exit.
- User exits are basically designed For SD module. Customer exits are available for MM, SD, FI, HR... basically designed for all modules.
While changing User-exit, Access Key is required, whereas in Customer-exit no access key is needed.
User exits are flexible and inconsistent and customer exits are restrictive and consistent.
- User-Exit affects modifies the standard code and this change will be effected every time. Whereas Customer-Exit will be included (or called) into the main program only when the corresponding Project is active. Thus preserving us lot of resources time.
Sunday, March 7, 2010
Different Types of Internal Tables in SAP
Internal table: Allocating extra memory for a structure is called as Internal table. An internal table will have a header area and a body area. The Header area can store only one record and the body area can store more no. of records depending upon the size of the table defined during declaration.
Types of Internal tables:
STRUCTURED INTERNAL TABLES:
Syntax for Internal table based on LIKE option.
- Any variable defined for a table in ABAP using LIKE statement is by default a structure. It can hold only one record.
- If OCCURS <size> specification is added, SAP allocates Body area memory with out header line.
- If <size> is specified as '0', it adds 8 KB of data to the body area and if any other integer is given, memory equal to those no. of records is added.
- The memory size is not fixed with the size specification. It increases in the same width as specified in the OCCURS <size> specification.
- For defining Internal table with header line, we need to use the option WITH HEADER LINE.
- Internal tables with header line is used all SAP applications to program DML operations. These concepts are used in MPP and BDC also.
- If we need to populate data into internal table without header line, we need to define an explicit structure and populate data into that structure and append data from that into the body area of the internal table using APPEND or COLLECT statements.
- There are two statements for loading data into internal tables.
- Append statement is used to add header data always a new record. Whereas Collect statement verifies whether the current header data is available in the body area. If found, Integer fields are added up with the current header data value. Else, adds a new record. If there are no internal fields, no records are added.
- For displaying Internal Table data we can use the Data Base loops.
- Select - End select statement is used to fetch data from DB tables into Application Server memory. Memory created by ABAPer in form of structure or internal tables is called as Explicit memory.
- Loop - End loop is used to display data in internal tables.
- Example for using Loop - End loop and Append statements:
- In the above example, if the internal table doesn't have the WITH HEADER LINE option, it would have generated an error.
- For such internal tables, we need populate using an work area also display using an work area.
- In the above example if header line is not specified, define another wa (wa2) of the same type, add the values into that wa2 instead of wa. and in place of append statement, use "Append WA2 to WA".
- For displaying, in Loop statement, use "Loop at wa into wa2". Then in Write statement, use the values in wa2.
- When we give Select - End Select statement, the data is retrieved from the data base table record by record. For displaying all the records in one hit to the data base, use the option INTO TABLE <INT_TAB> in the SELECT statement. In this case, there is no need of any ENDSELECT.
- By using the above method, the performance of the program increases.
EXIT:This statement is used for coming out of the loop with out checking for any condition. SORT: This statement is used to sort data of the internal table based on the field selected for sorting in the manner required.
- If sorting is not specified, the sorting is done in Ascending order based on Key field.
- If no sorting mode is specified, then also sorting is done in the Ascending order based on the fields selected.
STANDARD: This internal table is used in ABAP to change Key field priority in the Internal table. Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition. This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps.
SORTED: Data is sorted into these internal tables at the time of Data population itself. These internal tables can't be resorted by ABAPer using "SORT" statement. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables. This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it.
Note: IF THE INDEX NUMBER IS SPECIFIED MORE THAN SIZE OF INTERNAL TABLE, THEN READ STATEMENT GETS DATA INTO HEADER OF THE LAST RECORD IN THE INTERNAL TABLE.
HASHED: These internal tables are called as Non index internal tables. As this internal body is created in Hashed format, indexing can't be generated for the records. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition. This table type is particularly suitable if you want mainly to use key access for table entries. Hashed tables are a useful way of constructing and using internal tables that are similar to database tables.
Tuesday, March 2, 2010
SELECT Statements in SAP ABAP
There are different types of Select Statements in ABAP. Below are some select statements for frequently used cases.
<FLD_LIST> -> List of Fields from Data Base table for selection
<DB_TABLE> -> Source Data Base Table
<WA> -> Target Work Area/Structure
<ITAB> -> Target Internal Table
<CONDITION> -> Where condition in the select statement based on DB Table Fields.
SELECT *|<FLD_LIST> (We can select all fields or the fields in given order of the internal table)FROM <DB_TABLE>INTO <WA>WHERE <CONDITION>.
Ex: SELECT * FROM KNA1
INTO W_KNA1
ENDSELECT.
2. SELECT *|<FLD_LIST>
Ex: SELECT * FROM KNA1
WRITE: / IT_KNA1-KUNNR, IT_KNA1-NAME1.
ENDLOOP.
3. SELECT SINGLE *|<FLD_LIST> (We can select all fields or the fields
in given order of the internal table)
Ex: SELECT SINGLE * FROM KNA1
INTO W_KNA1
STRUCTURE similar to KNA1)
NOTE: One important thing to remember for all the above cases (when using the <FLD_LIST> in the Select statement) is that, the order of the fields in the <FLD_LIST> should be same as the order of the fields defined in the Work Area/Internal Table.
4. SELECT <FLD_LIST>
The same functionality applies to all the three scenarios explained above.
NOTE: One Limitation here however is that, the Names of the Fields in the Internal Table should be the same as the names of the Data Base Table. Or else, system cannot find any such field and so the fields will not be updated.
Below is a detailed description of the Generic Select Statement Syntax and its different parts.
Syntax:
SELECT <result>
INTO <target>
FROM <source>
[WHERE <condition>]
[GROUP BY <fields>]
[HAVING <cond>]
The SELECT statement consists of a series of clauses, each of which fulfils a certain task:
SELECT clause: Defines the structure of the selection.
INTO clause: Defines the target area into which the selection from the SELECT clause is to be placed.
FROM clause: Specifies the database tables from which the data in the selection in the SELECT clause is to be read.
GROUP BY clause: Groups lines in the selection
HAVING clause: Restricts the number of line groups.
ORDER BY clause: Sorts the lines in the selection.
Sunday, February 28, 2010
What is the Value of 0/0 in SAP
What is the Value of 0/0?
If the same question is asked in a Mathematics class, what will the answer?
Here are some possible answers that I got from some of the students.
- Anything divided by zero is Infinity. So, first answer -> INFINITY
- If numerator of a ratio is zero (or we can say if Zero multiplied by anything –even a ratio) then the answer is ZERO.
Now read this interesting answer –> 0/0 = 1.Didn't understood how, considering algebraic mathematics… I will convert the expression as X / X which will be equal to ONE.
But the answer to all these arguments is the actual fact as per Mathematics Principles is that, 0/0 is UNDEFINED.
Now let us see what the value of 0/0 as per SAP. Write a small code as below:
DATA: VAR1 TYPE I,
VAR2 TYPE I,
VAR3 TYPE I.
VAR3 = VAR1 / VAR2.
WRITE: / VAR1, VAR2, VAR3.
You can see that there won't be any Run Time error and instead the answer will be ZERO.Now before the statement VAR3 = VAR1 / VAR2, set VAR1 to a non-zero value. We can see that it will generate a Run Time Error of "Divide by Zero".
Monday, February 22, 2010
Maintenance View
Maintenance views: It can be created for One or More tables, if more, only related tables. This view is created will all key fields of table automatically and joins are auto generated by SAP. We cannot change it. This Object can't be used as Dictionary Object for SE38 programs, with help table maintenance generator we should convert maintenance view as repository object. Unlike Database views, we can modify data from multiple tables also.
Navigations to create maintenance view.
1. SE11 -> SELECT OBJEC TYPE AS "VIEW" -> NAME THE VIEW ( ZMAINVIEW1 ) -> CLICK ON CREATE -> SELECT VIEW TYPE AS "MAINTENANCE VIEW" -> CLICK ON COPY -> ENTER SHORT DESCRIPTION FOR THE VIEW ( ANY ) -> SPECIFY PRIMARY TABLE ( MARA ) -> PRESS ENTER -> CLICK ON RELATIONSHIPS TO ADD OTHER TABLES FOR THE VIEW -> SELECT ONLY DEPENDENT TABLES ( MAKT ) -> CLICK ON COPY , BY DEFAULT SAP GENERATES A JOIN FOR THE TABLES , AND ADDS ALL KEY FIELDS FROM THE TABLES -> CLICK ON VIEW FIELDS TAB BUTTON TO SELECT REQUIRED OPTIONAL FIELDS -> CLICK ON TABLE FIELDS , TO SELECT REQUIRED FIELDS FROM BOTH TABLES -> CLICK ON MAINTENANCE STATUS -> SET THE ACCESS AS "READ/CHANGE/DELETE AND INSERT" ( DEFAULT SELECTED ) -> SAVE THE VIEW UNDER A PACKAGE -> ACTIVATE THE VIEW.
2. To generate Repository Object, Generate Table maintenance using
utilities menu -> table maintenance generator -> opens an interface -> Specify Authorization Group as "ATES" -> Name the Function Group to be created ( ZFGMAINVIEW1 ) -> select maintenance type as "one step" screen -> set the screen number as "123" -> click on create from application toolbar -> save the objects under a package -> SAP Generates Function Group with Code for maintenance view.
3. Test maintenance view code execution.
SE54 (TCODE ) -> Name the VIEW (ZMAINVIEW1 ) -> click on "TEST" PUSHBUTTON -> Opens another interface -> Click on Maintain Pushbutton -> Opens another screen with the contents of the view -> For creating new entries, click on "New Entries" from ATB. For changing existing contents, modify the values -> SAVE -> Changes will be updated in the DB tables.
Projection View
A view doesn't contain any data physically. It's only a logical way of grouping the required fields from one/more tables with required Joins and selection conditions. View gets records from respective database tables only in runtime and if any updates are done using the View, the data will be actually saved/modified in the database tables. If we try to create any new records using Views, all fields of the database tables which don't lie in the view are maintained either as Blank or Zero(depending on the data type).
Projection View can be created on One table. We can insert records into the actual database table using these Views. The main use of Projection View lies in giving the feasibility of projecting only the required fields out of the number of fields of the table, without all the fields literally in the program, making our programming easier. (for ex: create a Projection View with 30 fields out of 128 fields of VBAK table).
Navigations to create a Database view for.
SE11 -> Select "VIEW" -> Name the view ( ZPROJVIEW1 ) -> Click on Create -> Opens an interface , select view type as "Projection View" -> click on Continue -> Opens an interface -> Enter Description for the projection view ( any ) -> Name the table to be assigned for the View ( VBAK ) -> Press Enter -> Click on Table Fields to select the List of Fields from table ( here select all key fields and optional required fields ) -> select required fields and click on copy -> Click on Maintenance status tab button -> select Access as "read and change" -> Save -> Activate..
* use the view in SE38 to fetch data into Reports.
REPORT ZVIEWTEST2 LINE-SIZE 150 NO STANDARD PAGE HEADING.
DATA : ITAB LIKE ZPROJVIEW1 OCCURS 0 WITH HEADER LINE.
SELECT * FROM ZPROJVIEW1 INTO TABLE ITAB.
LOOP AT ITAB.
WRITE : / ITAB-VBELN , ITAB-KUNNR , ITAB-NETWR , ITAB-AUDAT , ITAB-VBTYP.
ENDLOOP.
Database View
A view doesn't contain any data physically. It's only a logical way of grouping the required fields from one/more tables with required Joins and selection conditions. View gets records from respective database tables only in runtime and if any updates are done using the View, the data will be actually saved/modified in the database tables. If we try to create any new records using Views, all fields of the database tables which don't lie in the view are maintained either as Blank or Zero(depending on the data type).
Database View can be created on One table as well as multiple tables. Only when it is created on top of one table, we can insert records into the actual database tables using the Views. When it's created with combination of multiple tables, we can only read the data from Database tables.
Navigations to create a Database view for.
se11 -> select Object type as "view" -> Name the view ( ZDBVIEW1 ) -> Click on Create -> Opens an interface with type of views , select "Data base view" -> click on continue -> opens another Interface -> Enter Description ( any ) -> name some table say, "SPFLI" -> press enter -> Click on Relationship pushbutton on screen to get The List of related tables ->select the required tables from the list (say SBOOK , SFLIGHT ) -> Click on Copy , internally SAP Generates Auto Joins Conditions -> Click on View Fields tab button -> Click on table fields to select required fields from tables -> go to "Selection Conditions" tab -> Give the selection conditions if required, with AND/OR for multiple selection -> save the view under a package , assign with request number ->Activate the view (ignore any warnings).
* use the view in SE38 to fetch data into Reports.
REPORT ZVIEWTEST1 LINE-SIZE 150 NO STANDARD PAGE HEADING.
DATA : ITAB LIKE ZDBVIEW1 OCCURS 0 WITH HEADER LINE.
SELECT * FROM ZDBVIEW1 INTO TABLE ITAB.
LOOP AT ITAB.
WRITE : / ITAB-CARRID , ITAB-CITYFROM , ITAB-CITYTO , ITAB-FLDATE , ITAB-PRICE.
ENDLOOP.
Saturday, February 20, 2010
Session Method
Session Method is one of the BDC methods which is best in Maintenance.
We use Three FM's in Session Method:
BDC_OPEN_GROUP for creating SESSION OBJECT.
BDC_INSERT to insert data of the internal table.
BDC_CLOSE_GROUP to close SESSION OBJECT MEMORY from the program.
Sample code:
DATA : BEGIN OF ITAB OCCURS 0,
STR(255) TYPE C,
END OF ITAB.
DATA : JTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
ITAB1 LIKE MARA OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 'D:\930AM\MATDATA.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB.
LOOP AT ITAB.
SPLIT ITAB-STR AT ',' INTO ITAB1-MATNR ITAB1-MTART ITAB1-MBRSH ITAB1-MEINS.
APPEND ITAB1.
ENDLOOP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'SESS9301'
KEEP = 'X'
USER = SY-UNAME.
LOOP AT ITAB1.
PERFORM PRGINFO USING 'SAPMZMPPSCR' '123'.
PERFORM FLDINFO USING 'ITAB-MATNR' ITAB1-MATNR.
PERFORM FLDINFO USING 'ITAB-MTART' ITAB1-MTART.
PERFORM FLDINFO USING 'ITAB-MBRSH' ITAB1-MBRSH.
PERFORM FLDINFO USING 'ITAB-MEINS' ITAB1-MEINS.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'ZCT930'
TABLES
DYNPROTAB = JTAB.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORM PRGINFO USING PROGRAMNAME SCRNUM.
REFRESH JTAB.
JTAB-PROGRAM = PROGRAMNAME.
JTAB-DYNPRO = SCRNUM.
JTAB-DYNBEGIN = 'X'.
APPEND JTAB.
ENDFORM.
FORM FLDINFO USING FLDNAME FLDVAL.
CLEAR JTAB.
JTAB-FNAM = FLDNAME.
JTAB-FVAL = FLDVAL.
APPEND JTAB.
ENDFORM.
LSMW
LSMW IS NAVIGATION FORMAT TO PERFORM BDC'S
LSMW IS A COLLECTION OF PROJECTS, PROJECT IS A COLLECTION OF SUB PROJECTS AND SUB PROJECT IS A COLLECTION OF OBJECTS.
LSMW -> NAME THE PROJECT , SUB PROJECT AND OBJECT -> CLICK ON CREATE FROM APPLICATION TOOLBAR -> OPENS ANOTHER INTERFACE ACCEPT SHORT DESCRIPTION -> OK -> TO LSMW PROCESS CLICK ON EXECUTE ( PRESS F8).
1) Maintain Object Attributes
IN THIS STEP WE CAN SPECIFY THE TARGET TCODE, WHERE DATA TO BE POPULATED FOR LSMW, WITH TCODE FIELD IDENTITIES WITH HELP OF RECORDING METHOD.
SELECT -> EXECUTE -> CLICK ON RECORDING OVERVIEW ( PB ON APPLICATION ) -> OPENS LPS SCREEN -> CLICK ON CREATE NEW RECORDING FROM APPLICATION TOOLBAR -> OPENS AN INTERFACE -> ENTER RECORDING METHOD NAME ( ZREC1) -> SHORT TEXT -> CONTINUE -> ENTER THE TCODE( MK01 ) -> Enter sample data -> Save the entries from tcode -> Generates a report in LPS with recording method fields, but in this step abaper has to assign recording methods fields to LSMW process , to do this -> click on Default all from application toolbar, assigns all fields of recording method into LSMW process-> save the entries -> come back -> come back -> change mode of screen -> select batch input recording -> name the recording (zrec1) -> save the entries -> come back.
2) Maintain Source Structures
In this process we are creating a structure where can be splitted from flat file, to populate data into corresponding fields of screen select -> execute -> change the mode of screen -> click on create structure from application toolbar -> name the structure ( ktab) -> short text -> ok -> Save the entries and come back.
3) Maintain Source Fields
In this process we are adding Fields for the structure with help tcode fields.
select -> execute -> change mode -> select name of structure -> click on create field -> specify field name -> description -> size of the field -> data type -> continue -> repeat the same step for all fiels of tcode where data to be populated -> save entries -> come back.
4) Maintain Structure Relations
In this step the relation between structure and Recording object should be assigined, this will be done automatically, else process manually,
select -> execute -> chane the mode -> save -> come back ( as relations are maintained by sap by default [zrec <<<< ktab]).
5) Maintain Field Mapping and Conversion Rules
In this process we are performing field mappings of recording ( lsmw ) to structure fields. To do this
select -> execute -> change the mode -> select field of Recording method (LIFNR) -> click on source field from application toolbar -> displays list of fields in KTAB ( structure ) -> double click on related field name ( field is mapped ) -> Repeat the same step for all fields-> save the entries and come back.
6) Maintain Fixed Values, Translations, User-Defined Routines
This step is require if we need to assign any default values, is a optional step [ we can avoid this step ].
select -> execute -> come back.
7) Specify Files
we can specify the file is from Presentation layer or application server to be extracted for data population.
select -> execute -> change the mode -> select the location ( legacy system PC ) -> click on add entry from application toolbar -> opens an interface -> enter path of source file in File ( field ) [c: \LFA1.txt] -> description in name field -> specify field separator (comma) -> continue -> save the entries -> come back ->
8) Assign FilesIn this process we are assigning File to the LSMW process.
select -> execute -> change the mode -> save -> come back.
9) Import Data
in this process the data from legacy system is populated into LSMW process, generates ".lsmw.read" file
select -> execute -> execute -> generates report -> come back -> come back.
10) Display Imported Data
In this process we are display the data of .read file in presentation layer.
select -> execute -> continue -> display report ( yellow color ) -> come back ->
11) Convert Datain this process generates ".conv" with help of ".read" file.
select -> execute -> execute -> generates a report -> come back -> come back ->
12) Display Converted Data
displays the converted data from application created by sap.
select -> execute -> continue -> generates the report -> come back.
13) Create Batch Input Sessionin this process creates a session object with name as object name defined in LSMW.
select -> execute -> execute.
14) Run Batch Input Sessionexecutes the SM35 tcode to process LSMW into sap r/3.
opens sm35 tcode -> select object name -> process.
Logical Data Base
LDB is a special Programming in ABAP to increase Performance of the Reports. It is a collection of nodes assigned with GUI and Select Statement. It is a Repository Object.
Before learning about creation of LDB, let us know about GET and PUT statements.
PUT : It is the statement used in source code of LDB in between SELECT-ENDSELECT to add selected data information in the Node.
GET: We can invoke the node using "GET" statement. It gets the data from NODE into the Presentation layer.
NOTE: Do not perform DML operations as it effects performance of Server. Inconsistent code in LDB causes lot of delay for all applications in SAP Data Base and even Application Server.
Navigations to create Logical Data Base:
*GUI Creation.
SLDB -> name the Logical Database( zmyldb_1) -> create -> Short text -> save -> Specify name of Root Node ( KNA1) -> short text -> Data base table ( KNA1) -> continue-> opens Logical Data base Editor -> Select the node -> click on Selections from Application toolbar -> opens a dialog box -> click on yes -> prompts another dialog box to create search helps ( no ) -> select all checkboxs prompted in LPS [ is used to generate GUI for Dynamic Selections from the table and Dynamic Field Selects from the table -> Click on transfer -> opens SE38 code -> code is generate by SAP -> Replace ? with Suitable name , remove comments for GUI statement if required -> save -> activate the source code -> come back.
(Remember that Node name and table name must be same.)
Adding Select Statement for the Node:
select the node from LDB editor -> click on Source Code From application toolbar -> opens ABAP editor with two include files as "Top Include file " AND "nxxx" FILE . Double click on top include file -> declare internal table. Double click on file -> opens another ABAP editor -> Double Click in "Node" code include statement -> activate the select statement as follows .
SELECT * INTO CORRESPONDING FIELDS OF ITAB
FROM MARA WHERE MATNR IN MATNUM.
PUT MARA.
APPEND ITAB.
ENDSELECT.
Don't forget to use PUT Statement between Select - Endselect , as it adds all data information in the Node -> save and Activate the code.
Once If the Logical Data Base is created with Nodes can be invoked from the program using SE38 -> name the program -> create -> short text -> type of program -> Logical Database (zmyldb_1) -> save -> opens ABAP editor -> use the code as follows.
NODES : MARA.
GET MARA.
Friday, February 19, 2010
Selection-Screen Statements in SAP ABAP
--> There are 11 statements used in ABAP under this category.
1) PARAMETERS.
2) SELECTION-SCREEN COMMENT.
3) SELECTION-SCREEN BEGIN OF LINE –
END OF LINE.
4) SELECTION-SCREEN SKIP.
5) SELECTION-SCREEN ULINE.
6) SELECTION-SCREEN PUSH BUTTON.
7) SELECTION-SCREEN BEGIN OF BLOCK –
END OF BLOCK.
8) SELECTION-SCREEN BEGIN OF SCREEN –
END OF SCREEN.
9) SELECTION-SCREEN FUNCTION KEY.
10) SELECT-OPTIONS.
11) SELECTION-SCREEN POSITION.
1) PARAMETERS:
--> Used to create I/O fields, check boxes and radio buttons in ABAP.
syntax:
PARAMETERS <VAR_NAME>
By default, name of the variable itself is displayed as label on GUI. To change label for GUI, activate the code in SE38
- click on 'GOTO' menu
- Text Elements
- Selection-text
- Opens an interface with list of GUI components in program, set the required text to be displayed on GUI as label
à activate
à comeback.
- Whenever a field is defined for checkbox, by default, variable is assigned to type 'C' data type.
If the checkbox is selected, value of the variable will be 'X'. Else, space.
c) Syntax for generating radio buttons using parameters statement:
à Radio buttons are defined under one group category.
- Under one group at least two components must be added.
- Only one of the radio button in a group can be selected.
Syntax: SELECTION-SCREEN COMMENT [/]<POS>(width)
<Label variable>
- It is a statement used in ABAP to add a label on selection-screen GUI.
selection-screen comment /20(15) LB1.
write: A.
INITIALIZATION. "-> Event
A = 900.
LB1 = 'A value'.
INITIALIZATION EVENT:
- It is an event in ABAP used to set default values for all GUI variables in SAP scrn.
- This is executed before loading the screen.
- For initializing such GUI variables, we need INITIALIZATION EVENT.
Before loading the screen, initialization event is executed and even before it, declaration part is executed.
Ans: (Explained above).
3) Selection-screen begin of line – end of line:
à Any input field created in SAP is created in new line. For displaying more than one input field in same row, the statements must be specified between Selection-screen Begin of line = = = = = Selection-screen End of line.
à But here, the labels of the input fields will not be displayed. For displaying them we need to add manually using Selection-screen comments stmt.
Ex: Selection-screen begin of line.
Selection-screen comment 1(10) LB1.
LB1 = 'Name'. LB2 = 'No:'.
4) Selection-screen skip [N]:
à Used for generating Blank lines on GUI for selection screen.
à N specifies the no. of lines to be skipped off.
5) Selection-screen ULINE:
à This is a statement used for generating Horizontal lines on GUI.
Syntax: SELECTION-SCREEN ULINE [/] [<POS>] [(WIDTH)].
6) Selection-screen Push Button:
à This is a statement used to add Push Buttons on GUI.
Syntax: Selection-screen pushbutton [/] [<POS>] [(WIDTH)] <LB1> User-command <PB1>.
where <LB1> is the variable on Pushbutton and <PB1> is the name of it.
Ex: Parameters: Kunnr like kna1-kunnr,
Land1 like kna1-land1,
Name1 like kna1-name1,
Ort01 like Kna1-ort01.
à This is a stmt used to create application tool bar components in selection screen.
Syntax: SELECTION-SCREEN FUNCTION KEY <Num>.
where Num is ranging from 1 to 5.
SSCR FIELDS: It is a structure in SAP for selection screens. Only 5 application tool bar components can be crated in a screen.
à Whenever application tool bar components are added using above stmt, for these components labels are defined under a structure called " SSCRFIELDS" as FC01, FC02, FC03, FC04 and FC05 related to respective function key number.
à For this structure we need to allocate implicit memory using "TABLES" statement.
Ex: TABLES SSCRFIELDS.
PARAMETERS: ID(10).
SELECTION-SCREEN FUNCTION KEY 1.
INITIALIZATION:
SSCRFIELDS-FUNCTXT_01 = 'FIRST ATC'.
SSCRFIELDS-FUNCTXT_02 = 'SECOND ATC'.
SSCRFIELDS-FUNCTXT_03 = 'THIRD ATC'.
à This statement is used for creating range of input fields for selection screen. Using this option, we can fetch required selected data from the DB table.
Syntax: SELECT-OPTION <Var> FOR <Existing variable>.
<Var> becomes a GUI variable for existing variable.
Ex: DATA CNO(5).
SELECT-OPTIONS CNUM FOR CNO.
à Internally, when SELECT-OPTIONS is used, a structure is created as below:
à By default the content of sign is 'I' and option will be BW (between) when range is selected or EQ (Equal to) when only LOW value is given. It means IN BETWEEN. i.e., fields in between the high and low values specified are selected or IS EQUAL to the value in LOW.
à If we set SIGN as 'E' (Exclusive), data other than the range/Value will be selected.
11) SELECTION-SCREEN POSITION:
àThis is the statement used to control position of GUI fields at lower position or at higher position.
à This must be used only between SELECTION-SCREEN BEGIN OF LINE ==== END OF LINE.
Syntax: SELECTION-SCREEN POSITION <Pos.>.
Where <Pos> is POS_LOW or POS_HIGH.
Ex: DATA: KUNNR LIKE KNA1-KUNNR,
SELECT-OPTIONS CNO FOR KUNNR.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) LB1.
SELECTION-SCREEN POSITION POS_HIGH.
PARAMETERS A TYPE I.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
LB1 = 'Customer name'.