Search This Blog

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.
  1. Anything divided by zero is Infinity. So, first answer -> INFINITY
  2. If numerator of a ratio is zero (or we can say if Zero multiplied by anything –even a ratio) then the answer is ZERO.

  3. 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.
    There is no end to this. Even some will say X/Y where X = 2Y resulting in TWO. There is no end to these somehow "Innovative" answers.
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>
[<TYPE/LIKE> <DATATYPE/EXISTING VARIABLE>]
[DEFAULT <INITIAL_VALUES>] [LOWER CASE] [OBLIGATORY]
[MATCHCODE_OBJECT <SHLD>].

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
 à save
    à activate
    à comeback.

b) Syntax for generating checkboxes using parameters statement.:
    syntax: PARAMETERS <VAR_NAME> AS CHECKBOX. 
  • 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:

    syntax: PARAMETERS <VAR_NAME> RADIO BUTTON
                    GROUP <GROUP_NAME>.

 à 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.  
2) SELECTION-SCREEN COMMENT statement:

Syntax: SELECTION-SCREEN COMMENT [/]<POS>(width)
        <Label variable>
  • It is a statement used in ABAP to add a label on selection-screen GUI. 
Ex:     Parameters : A type I default 300.
          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.
à The need of this event is that there are some GUI variables like 'LABEL', 'PUSH BUTTONS', 'FUNTIONS KEYS', 'BLOCK NAMES', 'SCREEN TITLES' etc which cannot be initialized at the time of declaration using DEFAULT addition.
  • 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.  
FAQ: What is the need of initialization event when there is default addition in SAP?
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.
Parameters: Name(20).
Selection-screen comment 40(10) LB2.
Parameters: No.(10).
Selection-screen end of line.

        Initialization.    "-> Event
           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.
Selection-screen Pushbutton /10(10) LB1 User command PB1.
Selection-screen Pushbutton 30(10) LB2 User command PB2.

Initialization.    "Event
    LB1 = 'Abap Editor'.
    LB2 = 'Abap Dictionary'.
At Selection screen.    "Event
Case sy-ucomm.
    When PB1.
        Call Transaction 'se38'.
    When PB2.
        Call Transaction 'se11'.
End Case.  
7) Selection-screen Begin of Block ===== End of Block:

à This is a statement used to create Block in the selection-screen, which will be easier for the users to understand the related/grouped Selection screen fields.
Syntax:     SELECTION-SCREEN BEGIN OF BLOCK <B> WITH FRAME TITLE <T>.
     SELECTION-SCREEN END OF BLOCK <B>.
8) Selection-screen Begin of Screen ===== End of Screen:

à This is a statement used to create our own screens and can be understood in conjuction with Screen Painter. (Explained in Screen Painter/MPP concepts)
9) Selection-screen Function key:
    à 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.
  SELECTION-SCREEN FUNCTION KEY 2.
  SELECTION-SCREEN FUNCTION KEY 3.
             
              INITIALIZATION:                  
                   SSCRFIELDS-FUNCTXT_01 = 'FIRST ATC'.
                   SSCRFIELDS-FUNCTXT_02 = 'SECOND ATC'.
                   SSCRFIELDS-FUNCTXT_03 = 'THIRD ATC'.

AT SELECTION-SCREEN.     CASE SY-UCOMM.
         WHEN 'FC01'.
            MESSAGE I000(ZMSG_11AM).
         WHEN 'FC02'.
            MESSAGE I001(ZMSG_11AM).
         WHEN 'FC03'.
            LEAVE PROGRAM.
         ENDCASE.
10) SELECT-OPTIONS:
    à 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:
DATA:  BEGIN OF CNUM,
                SIGN(1),
                OPTION(2),
                LOW(5),
                HIGH(5),
            END OF CNUM.
This is predefined structure for select-options.  
à 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'.

ABAP Dictionary: Table Creation in SAP


  • We create tables in SAP by using the transaction SE11.
  • We have three Major parts to be defined while creating a table.
1) Delivery & Maintenance
2) Technical Settings
3) Fields

In Delivery & Maintenance we have different options.


Delivery:
  • A à Application table à Table cannot be altered. I.e., the structure of the table cannot be altered. But Read/Write/Delete and Change permissions are allowed for data.             
  • C à Custom table à Table structure can be altered. R/W/C & D permissions are allowed.
  • Gà Custom table with no modifications. à No update and no delete.
  • L à Temporary table. à This is used for session management. Data is stored only from login time to logout time and not permanently.
  • S à System table à SAP tables. These are used to hold application server information. ABAPer cannot use this option.
Maintenance :
This has three options.

1) Allowed
2) Allowed with restrictions
3) Not allowed.


Technical Settings:
We have two sub options in this.

  1. Data Class à APPL0 à Master table. Writes are less, Reads are more.

        à APPL1 à Transaction table. Writes are more, Reads are less.
  2. Size Category à 0 to 6.    (Determines the expected number of rows in the table. However this will not limit the number of rows created)

Fields: While creating fields in tables, we should associate some DATA TYPES to them. We can create tables with direct data types associated to the fields or by associating the Dictionary data types.
  1. Creation of tables with direct data types has the following drawbacks.
    1. Data is global for all clients.
    2. Data in current R/3 can't be communicated with another R/3.
    3. Table to Table relation is not possible.
    4. Search Helps can't be created. 
Dictionary DATA TYPES:                    


INT1 à Integer with 1 byte of memory (Can accept 255)
INT2 à Integer with 2 bytes of memory (Can accept upto 35,000)
INT4 à Integer with 4 bytes of memory (Can accept upto 10 digits)
FLTP à Float data type.
DEC à Decimal data type. Similar to packed data type.
CHAR à Character data type. Similar to type C.
NUMC à No. in form of character. Similar to type N.
TIMS à Time data type. Similar to type T.
DATS à Date data type. Similar to type D.
LANG à Language data type.
QUAN à Quantity data type.
CURR à Currency data type.
CUKY à Currency key. This is used along with above data type.
CLNT à Client data type.
RAW à Large objects.                            
LRAW à Large objects with binary format.

Primary Key:Whenever a table is created in SAP, the first field must be a primary key field. Else, SAP generates error.

    Primary key has three properties.
        1) Unique.
        2) Not Null.
        3) Tables Relationship.
  • All department tables are Transaction tables.
  • Table creation has two processes. Top to Bottom approach and Bottom to Top approach.
  • SAP uses Bottom to Top procedure. It is preferable.

DATA ELEMENT: It is a dictionary object in SAP assigned to a domain as label, to be reused by TABLES, IDOCS and Search-helps.

DOMAIN: It is also a dictionary object in SAP assigned with a data type and with constant size.
FAQ: Can we create tables in SAP without DATA ELEMENTS?
Ans à YES (But not recommended).


Navigations to create a table:

à SE11.                       
à Select Object type as 'TABLE'.
à <Create>,
à Opens an interface. Enter description.
à Set delivery class as 'A'.
à set 'Table Maintenance is allowed'.
à Click on 'fields' tab button.
à <Built in type>.
à Name the field. Assign with data type.
à Set the size (Ex: Cname: char(30), city: char(30). )
à Select first field as key field.
à <save>. Assign a request number.
à Click on 'Technical Settings' tab button.
à Opens another interface. Set the data class as 'APPLO/APPL1'.
à Set the size ( o to 6 ). <save>
à F3
à Activate the table.

Thursday, February 18, 2010

Relational, Logical and Conditional Operators in SAP ABAP


Relational Operators:
The following are the relational operators in ABAP.
  • EQ à =
  • NE à <>
  • GT à >
  • LT à <
  • GE à >=
  • LE à <=

We can use both the symbolic representation as well as the character representation.


Logical Operators: 
  • Checking relation between multiple conditions are processed using logical operators.
          OR:     If any one of the conditions satisfies, then only it returns true.
         AND:     If all conditions are satisfied, then only it returns true.

Conditional Operators:

  • Controlling execution of a block of statements is processed using conditional statements.

    Single IF statement: IF <condition>.
                                       ----Block of stmts---
                                       ENDIF.

    IF – Else statement: IF <condition>.
                                       ----Block of stmts---
                                       ELSE.
                                       ----Block of stmts---
                                       ENDIF.

    Multiple IF statement: IF <condition1>.
                                           ----Block of stmts---
                                           ELSEIF <condition2>.
                                           ----Block of stmts---
                                           ELSE.
                                           ----Block of stmts---
                                           ENDIF.
The CASE Control Structure:
  • This control structure is introduced with the CASE statement. The CASE control structure allows you to control which statement blocks are processed based on the contents of a data object.
            CASE <v>.      
                WHEN <v11> [OR <v12> OR ...].
        <Statement block>
    WHEN <v21>.[OR <v22> OR ...]
        <Statement block>
    WHEN <v31> [OR <v32> OR ...].
        <statement block>
    WHEN ...
    ......
    WHEN OTHERS.
        <statement block>
ENDCASE.
  • The statement block following a WHEN statement is executed if the contents of <v> are the same as those of one of the fields <vij>.
  • Afterwards, the program carries on processing after the ENDCASE statement.
  • The statement block after the optional WHEN OTHERS statement is executed if the contents of <v> does not equal any of the <vij> contents.
  • The last statement block must be concluded with ENDCASE.

ABAP Data Types


  • Data Types are the key words which specify the type of memory and size of memory.

  • ABAP Data Types can be classified into 2 types.
    1) Predefined Data Types
    2) User defined Data Types



  • Integer Data Type occupies 4 bytes of memory and we can store upto 10 digits in an integer.
  • Float data type stores 8 bytes of memory. This stores decimal data also. It is defined with 16 decimal places by default.
  • Packed data type is same as Float data type except that by default, there are no decimal places and ABAPER has to specify the required no. of decimal places.
  • Character data type can accept all ASCII characters and it occupy 1 byte of memory.
  • Number accepts only numbers but treats them as characters. i.e., string operations can be executed
  • Date data type is of 8 bytes long and stores date in YYYYMMDD format.
  • Time data type is of 6 bytes long and stores time in HHMMSS format.
  • String data type has variable size and it adjusts based on the data in the string. It can read only .txt files
  • Xstring is the hexadecimal formatted and similar to String type. i.e., it can read all files like .doc, .ppt, .xcs, .jpg, .bmp etc.
  • We can also create our own Data Types using "Types" or by creating custom objects like Structures, Classes, Interfaces etc.


Differences between Float and Packed data types:
  1. FLOAT has default decimal places of 16 & PACKED data type has 0.
  2. FLOAT decimal places are fixed whereas can be decided by the ABAPer for PACKED.
  3. PARAMETER, which creates GUI for data type is not supported by FLOAT while it is supported by PACKED type.

SAP R/3 - Application Server Architecture

Below picture illustrates the basic architecture of Application Server of SAP R/3.

  • Depending on Organization requirements, we can maintain one Application Server or Multiple Application Servers. 
  • INSTANCE: It is nothing but dispatcher and its corresponding work process.
  • Application Server consists of two types of Instances.
           1. Central Instance
           2. Dialogue or Additional Instance.
  • Central Instance: An instance with the Message Server is called as Central Instance.
  • All instances other than Central Instance are all called as DIALOG Instances or ADDITIONAL Instances.
  • Each instance is identified by 2 digit no.
  • A Dialog Instance doesn't exist on its own. It is always associated with a Central Instance.
  • Message Server Performs Load Balancing. It distributes the load over different available Instances.

 The internal architecture of and Instance can be seen in the below picture.
Instance has FIVE services.
  • Dispatcher
  • Work Process / ABAP Memory / P L Memory
  • Database Connectivity
  • Gateway Services
  • Message Services

Dispatcher:
  • It is an interface between Presentation Layer and Application Layer.
  • It can understand two types of requests(Languages) :
          1) ABAP request
          2) BAPI request – Used to communicate between SAP and Non-SAP systems. (For VB-Active X and for JAVA-Java Been)


Work Process:
  • It is the memory allocated in Application Server for the Presentation Layer or ABAP Memory or PL Memory.
  • There are 7 types of work Processes.
           1) Dialog WP         => Screen
           2) Update WP        => DB Updates
           3) Background WP => Background Jobs
           4) Spool WP           => Printing
           5) Enqueue WP      => Lock Management
           6) Message WP      => Internal Communications
           7) Gateway WP      => External Communications
      Only the first five WP’s can be seen and configured by the Administrator.


Data Base Connectivity:    
  • It is an interface between the Application Layer and DB Layer.
  • This service maintains the Connection Management with Data Base.
  •  It is again a collection of two sub services.
          1) Open SQL
          2) Native SQL
          Open SQL converts the ABAP request from WP into Native data base format and sends it to Native SQL where the request is processed after verification.


Gateway Services:
  • It is a service in Application Server controlled by data base connectivity to redirect the transaction request into specified DB Network.




Welcome

Welcome to SAP ALL FOR YOU. Please visit in few days again for all you need.