Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

Friday, April 26, 2013

0 Difference between TYPE and LIKE in ABAP


Difference between TYPE and LIKE in SAP ABAP :


TYPE : It will allocate memory during execution (object type).
       TYPE will improve performance.
       It is used when userdefined object link with SAP system data type.
       TYPE refers to the user defined data types
       TYPE,assign datatype directly to the data object while declaring.
     
LIKE :  Tt will allocate memory immediatly.
        It is when data object link with the other data object.
        LIKE refers to existing data type of data object
        LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.

Thursday, April 25, 2013

0 Formatting options for all Data Types in ABAP


Formatting options for all Data Types in ABAP :



             Option
      Function
LEFT- JUSTIFIED
Output is left-justified.
CENTERED
Output is centered.
RIGHT- JUSTIFIED
Output is right-justified.
UNDER <g>

Output starts directly under field <g>.
NO-GAP
The blank after field <f> is omitted.
USING EDIT MASK <m>
Specifies format template<m>
USING NO EDIT MASK
Deactivates a format template specified in the ABAPDictionary.
NO-ZERO
If a field contains only zeros,these are replaced by blanks. For type C and Nfields, leading zeros are   replaced automatically.
NO-SIGN
The leading sign is not displayed on the screen.
DECIMALS <d>
<d> defines the number of digits after the decimal point.
EXPONENT <e>
In type F fields, the exponent is defined in <e>.
ROUND <r>

Type P fields are multiplied by 10**(-r) and then rounded
CURRENCY <c>
Format according to currency <c> in table TCURX.
UNIT <u>
The number of decimal places is fixed according to unit <u> specified in table T006 for type P fields.



0 Variables in SAP ABAP

Variables in  SAP ABAP :



Variables are named data objects, you can declare variables statically using declarative statements, or dynamically while a program is running. They allow you to store changeable data under a particular name within the memory area of a program.


DATA is a keyword which is used to declare the variables in SAP ABAP

Syntax :
DATA < Variable Name> Type <Data Type>
                           (Or)
DATA <Variable Name> Like <Data Type>
Ex: DATA V1 Type I.
       DATA V2 Like I.

Type is abap keyword for reference
Fields :
         Elementary
        DATA vendor_code(10) TYPE C.
         Reference to Non Elementary
        TYPES vend_code(10)  TYPE C,
        DATA  vendor_code TYPE vend_code.
         Reference to existing fields
        DATA : vend_code(10) TYPE C,
                                   vendor_code LIKE Vend_code.



0 Operators in ABAP


Operators in SAP ABAP
In the abap we have 3 types of operators
1.Mathematical Operator
2.Comparitive Operator
3.Relational (or) Logical Operator
Mathematical Operator:
         Basic operations +,-, / and * along with functions like sin, sqrt etc. are supported
         Priority of the operations
        functions ,
        exponential
        multiplication  ,division
-       addition  , subtraction
Operators
Description
Example
      +
Addition
3+2 = 5
      -
Subtraction
3-2 = 1
      *
Multiplication
3*2 = 6
     **
Exponential
3**2 = 9
     /
 Division
10/2 = 5.
  Mod
Reminder of division of 2 integers
3 mod 2 = 1

Comparitive Operator:

Operators
Description
Example
<(or) LT
Less than
a < b (or) a LT B
> (or) GT
Greater than
a > b (or) a GT b
< =(or) LE
Less than or equal
a <= b (or) a LE b
>= (or) GE
Greater than or equal
a >= b (or) a GE b
 = (or) EQ
Equal
a = b  (or) a EQ b
<> (or) NE
Not equal
a <> b (or) a NE b


Relational (or) Logical Operator:
Operators
Description
Example
AND
and
(a<b) and (a<c)
OR
or
(a<b) or (a<c)
NOT
not
A NOT b

Operands:
Operands are the variables which we need to perform the particular operator
Ex: c = a + b.
Here a,b and c are the operands and + and = are operators 

Wednesday, April 24, 2013

0 Comments in SAP ABAP

Comments in SAP ABAP


1.Comments are the non-executable statements these are used to improve the readability of the program
2.If we want to comment the entire line then we place * at the first character of the line
*----------------------------------------
3.If we want to comment the line we use “
Ex: c = a + b  “Adding a and b

0 SAP ABAP Versions

SAP ABAP Versions 

ABAP We have so many versions some of them are


SAP R/3 3.1I
SAP R/3 4.0B
SAP R/3 4.5B 
SAP R/3 4.7B
SAP R/3 4.6A
SAP R/3 4.6B
SAP R/3 4.6C 
SAP ECC5.0
SAP ECC 6.0
SAP ECC 7.0
Present we are using SAP ECC6.0

Noote : ECC means Enterprise Central Component 

0 Login to SAP System

Login to SAP System :

Once we initialize the SAP in your system then we can find the SAP icon in your desktop
Right Click On it 
Click on the start
Then one popup window will trigger like this
Select the server and click on log on button
Then it will ask the  username and password

Enter the user name and password and click on enter
then you will get sap initial screen 









Monday, April 15, 2013

0 What is SAP transaction code


SAP Transaction code is a short cut key attached to a screen
transaction code is the collection of the screens where we can develop our object, sap provided there own transaction code for each and every concept those are called standard transaction codes .

if you want we can provide our own transaction code those are called custom transaction codes

We can create custom Transaction Code using SE93

0 How to copy one internal table to another in ABAP


Copying an Internal Table into another Internal Table:
If you want to copy the entire contents of one internal table into another in one execution, use the MOVE statement or the assignment operator (=) as follows:
Syntax
MOVE <itab1> TO <itab2>.
This statement is equivalent to:
<itab2> = <itab1>.
Note : above syntax  works only if ITAB2 is Empty
For example if ITAB2 having records at that time we have to use APPEND LINES OF
Syntax :
APPEND LINES OF itab1 TO itab2.

This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX
contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.

0 SAP ABAP Sample Report

SAP ABAP Sample Report :


REPORT  zselect_multiple NO STANDARD PAGE HEADING.

*// Tables declaration
TABLES : vbak.

*// Types declaration for VBAK
TYPES : BEGIN OF ty_vbak,
        vbeln 
TYPE vbeln_va,
        erdat 
TYPE erdat,
        erzet 
TYPE erzet,
        ernam 
TYPE ernam,
        angdt 
TYPE angdt_v,
        
END   OF ty_vbak.

*// Types declaration for VBAP
TYPES : BEGIN OF ty_vbap,
        vbeln 
TYPE vbeln_va,
        posnr 
TYPE posnr_va,
        matnr 
TYPE matnr,
        matwa 
TYPE matwa,
        matkl 
TYPE matkl,
        arktx 
TYPE arktx,
        
END   OF ty_vbap.

*// Types declaration for Final Internal table
TYPES : BEGIN OF ty_final,
        vbeln 
TYPE vbeln_va,
        erdat 
TYPE erdat,
        erzet 
TYPE erzet,
        ernam 
TYPE ernam,
        angdt 
TYPE angdt_v,
        posnr 
TYPE posnr_va,
        matnr 
TYPE matnr,
        matwa 
TYPE matwa,
        matkl 
TYPE matkl,
        arktx 
TYPE arktx,
        
END   OF ty_final.

*// Internal table declaration
DATA : lt_vbak  TYPE TABLE OF ty_vbak,
       lt_vbap  
TYPE TABLE OF ty_vbap,
       lt_final 
TYPE TABLE OF ty_final.

*// Work area declaration
DATA : wa_vbak  TYPE ty_vbak,
       wa_vbap  
TYPE ty_vbap,
       wa_final 
TYPE ty_final.

*// Variable declaration
DATA : lv_count TYPE i.

*// Selection screen design
SELECTION-
SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-100.
SELECT-OPTIONS s_vbeln FOR vbak-vbeln.
SELECTION-
SCREEN END   OF BLOCK blk1.

*// Retrieve data from VBAK
IF s_vbeln IS NOT INITIAL.
  
SELECT vbeln erdat erzet ernam angdt
          
FROM vbak
          
INTO TABLE lt_vbak
         
WHERE vbeln IN s_vbeln.
*// Retrieve data from VBAP
  
IF lt_vbak IS NOT INITIAL.
    
SELECT vbeln posnr matnr matwa matkl arktx
            
FROM vbap
            
INTO TABLE lt_vbap
             
FOR ALL ENTRIES IN lt_vbak
           
WHERE vbeln = lt_vbak-vbeln.
  
ENDIF.
ELSE.
  
MESSAGE 'Please enter selection screen field value' TYPE 'I'.
  
EXIT.
ENDIF.

*// Populate data into final internal table
LOOP AT lt_vbap INTO wa_vbap.    " Item Table
  
READ TABLE lt_vbak INTO wa_vbak WITH KEY vbeln = wa_vbap-vbeln.
  
IF sy-subrc EQ 0.
    wa_final-vbeln = wa_vbak-vbeln.
    wa_final-erdat = wa_vbak-erdat.
    wa_final-erzet = wa_vbak-erzet.
    wa_final-ernam = wa_vbak-ernam.
    wa_final-angdt = wa_vbak-angdt.
    wa_final-posnr = wa_vbap-posnr.
    wa_final-matnr = wa_vbap-matnr.
    wa_final-matwa = wa_vbap-matwa.
    wa_final-matkl = wa_vbap-matkl.
    wa_final-arktx = wa_vbap-arktx.
    
APPEND wa_final TO lt_final.
    
CLEAR wa_final.
  
ENDIF.
ENDLOOP.

*// Count number of records in LT_FINAL table
DESCRIBE TABLE lt_final LINES lv_count.
WRITE : /10 'Number of Sales Records:', lv_count.
ULINE.
SKIP 1.

*// Display output
LOOP AT lt_final INTO wa_final.
  
WRITE : / wa_final-vbeln, wa_final-erdat, wa_final-erzet, wa_final-ernam, wa_final-angdt,
            wa_final-posnr, wa_final-matnr, wa_final-matwa, wa_final-matkl, wa_final-arktx.
ENDLOOP.
 

SAP-ABAP Copyright © 2011 - |- Template created by Vishnu - |- Powered by Blogger Templates