Tuesday 15 September 2015

Working with ALV ROW COLOR

Hi friends,

OBJECT : Display the Purchase order details in ALV report. If the cost of the material increases more than 1000 rs show in red color and cost of the material decreases less than 10 rs green color in ALV report.




Step 1 : execute SE38 T-Code in Command window.
Step 2 : Create a Executable program and it opens ABAP Editor.
Step 3 : See the code for following screen shots.








Sunday 30 August 2015

Operations In INTERNAL TABLE : 

  1. Pushing the data from work area to internal table by using there keywords APPEND,INSERT and COLLECT.
  2. Reading the data from internal table is two types.
  •  single record : by using READ keyword we read the singe record from internal  table.
  • Multiple records : bu using LOOP AT key word we read the multiple records from internal table to work area.
     3. Modify the data in an internal table by using MODIFY keyword.
     4. Delete the data in internal table by using 'DELETE' keyword.
     5. Sort the data in an internal table by using SORT keyword. 

APPEND :-

Append is a keyword which is used to move or transfers the data from work area to internal table.

syntax :- APPEND  <WORK AREA > TO <INTERNAL TABLE>.
Ex :-  APPEND WA_T001 TO IT_T001.

INSERT :-
Insert is a key word which is used to transfer the data from work area to internal table based on the Key-word.

syntax :- INSERT <WORK-AREA > TO <INTERNAL TABLE>
Ex :- INSERT WA_T001 TO IT_T001.



    

Thursday 6 August 2015

DATA DICTIONARY

Data dictionary is the central source of the database management system. 
The main functionality of the DDIC is to create or alter the tables.

Creating the db table by using DDIC in two ways: -
  1. Direct method / Pre defined method / Built in method
  2. Data element method.
Technical requirement to create the table: -
  1. Name of the table must be starts with ‘y’ or ‘z’ because 'a' to 'x' is reserved for SAP.
  2. Provide list of fields, data types and lengths.
  3. Provide the delivery class.
Provide the Technical settings.


Delivery class: - It defines the owner of the table as well as it controls the transport of the data from one table to another table.

Technical setting is nothing but combination of DATA CLASS & SIZE OF THE CATEGORY.
Data class: - Data class defines the physical area of the database in where our table is logically stored. Some of the important data classes are

APPL 0 is a Master data class
APPL 1 is a Transaction data class
APPL 2 is a Organisation data class

Master data class: - Master data class is the data, which data we can access frequently as well as update rarely.
Ex: - customer master data, employee master data

Transactional data: - It’s the data, which data we can access frequently as well as updated frequently.
Ex: - Sales order data, purchase order data
Technical data is dependent data.

Organizational data: - It’s the data, which data we can access frequently & updated rarely. Organizational data is created at the time system configures.
Ex: - Company data, branches data
Size category: - It determines the space require for the table.


Each table must have at least one field as primary field that should be the character data type that should be in the first field in the table.

Wednesday 5 August 2015

DATA DICTIONARY cont....


Steps to create the table by using direct method: -

SE11 is a sap TCODE for DATA DICTIONARY. 


            Execute SE11 in command prompt. it will display like below image.



  1. Select the radio button data base table.
  2. Provide the table name which must start with 'z' after that Click on create. 
  3. Provide short description name. 
  4. Provide delivery class as ‘A’. Select the display / maintenance allowed
  5. Click on fields tag. Click on predefined type button. 
  6. Provide the field names, data types, lengths and short description.


Field                Key                 Data type                    Length           Short Description
Eid                                          CHAR                         10                   Employee ID
Ename                                     CHAR                         25                   Name of the employee
Eadd                                       CHAR                         35                   Address of employee

Save the table (CTRL + S). Check the table (CTRL + F2). Click on technical settings. Select the data class as APPL 0 & size category as zero. Save the technical settings. Click on back. Then activate table (CTRL + F3).

Steps to provide the data to the table directly: -
In the menu bar click on utilities à table contents à provide the data. Click on save. Repeat same steps for all employees.
Steps to display the data from table: -

            In the menu bar click on utilities à Table contents display. Click on execute.


Note: -   In the real time, we never create the data base table by using direct method or predefined
 type. Because, if you want to establish the relation between any two tables, then you must maintain 
the same domain name in both the tables. In direct method there is no domain concept. So we go 
for Data element method.

Domain: - Domain is the collection of data types & lengths.
Data Element: - Data element is the collection of domain with short description.

Steps to create the table by using Data element method: -






Create the employee table by using data element type bottom up approach.




Steps to create the domain: -


  1. Execute SE11. 
  2. Select the radio button domain. 
  3. Provide the domain name which must be start with 'y' or 'z' by click on create. 
  4. Provide short description. 
  5. Provide the data type & length. Save the domain. 
  6. Check the domain. Activate the domain. Repeat the same steps for all domains.

Steps to create the data element: -

  1. Execute the SE11
  2. Select the radio button Data type
  3. Provide the data element name which must be start with 'y' or 'z'  Click on create. 
  4. select the radio button Data element Click on enter. Provide short description. 
  5. Provide domain which is already created. Save the data element.
  6.  Check the data element. Activate the data element. 
  7. Repeat the same steps for all the data elements.

Steps to create the table by using data element type (bottom up approach): - 

  1. Execute SE11. 
  2. Select the radio button database table. 
  3. Provide the table name. Click on create. Provide short description. 
  4. Provide delivery class is ‘A’.  Select Display / Maintenance allowed
  5. Click on filed tab. Provide the field name, data elements.




Note: - If you get the warning message enhancement category for table missing then in menu bar click on extras à enhancement category à enter à select the radio button can be enhancement (char type or numeric) à enter.

Note: - If you want to provide the data directly to the table then you must select the display maintenance allowed.

Note: - If you select the display maintenance allow with restrictions, then display only possible. Create records not possible.


Note: - If you select the display maintenance not allowed then display & create integer not possible.


DATA DICTIONARY CONT....

Types of tables: -
  1. Transparent tables
  2. Cluster tables
  3. Pool tables

Transparent tables: - Transparent tables are one to one relationship. That is if you create one transparent table in the data dictionary, then it’ll store like only one data base table in the data base.














Cluster table: - This tables are many – one relationship. That is if you create the many clustered tables in DDIC then they will form like a table cluster & store in the data base.


  1. Buffering isn’t possible for clustered table. From this reason only fetching the data from clustered table take more time.
  2. Clustered table is suitable when you fetch the fewer amounts of data from more fields.

Pooled table: -
  1. Pooled tables are many – one relationship. That means if you create many pooled tables in DDIC, then they will form like a table pool & stored in the data base. 
  2. Pooled tables are suitable when we fetch the large amount of data from fewer fields.

    Note: - Joins aren’t possible for Clustered & Pooled tables

Index: -

Indexes are used to improve the performance of the select query. There are two types of indexes.
  1. Primary index
  2. Secondary index
Primary index: - Primary index is the primary fields. Without a primary index we can’t create the data base table. We can place up to 16 primary indexes per table. We can create the primary index only for custom tables. Not for standard tables.

Secondary index: -Secondary index is possible for other than primary fields. Without a secondary index we can create the data base table. We can create up to 9 secondary indexes per a table. We can create secondary index for both standard & custom tables.

Some of filed names in T001:
BUKRS à Company code
BUTXT à Company name
ORT01 à City
LAND1 à Country

Some of field names in KNA1: -
KUNNR à Customer number
NAME1 à Name
ORT01 à City
LAND1 à Country
SPRAS à Language

Some of the field names in LFA1 : -
LIFNR à Vendor number
NAME1 à Name
ORT01 à City
LAND1 à Country
SPRAS à Language

DATA DICTIONARY Cont......

Adding some additional fields to the database tables :


Differences between data base table and structure : 





Syntax of declaring the structure / table in ABAP editor: -



Internal table: -
  1. Internal table is the collection of records.
  2. Internal tables are temporary tables. That means the data in internal table won’t save any where in SAP.
  3. Internal tables are dynamic memory location. That means we no need to provide the size of the internal table.
  4. The scope of the internal table is up to that program.

  5. Placing the data to the internal table as well as getting the data from internal table is always record by record.

Differences between data base table & internal tables: -



Syntax of declaring the internal table : -

Data <internal table> like table of <work area>.

Syntax of accessing the fields from work area :-

<work area name> - <file name>
Ex: WA – Eid.

Tuesday 4 August 2015

ABAP Basics


IT
 
Data: Begin of WA,
     Eid(10) type c,
Eid
Ename
Ename
1
Divya
Vidya nagar
2
Sai
Anand theter
     Ename(25) type c,
     Eadd(35) type c,
     End of WA.
Data IT like table of WA.
WA-Eid = '1'.
WA-Ename = 'divya'.
WA-Eadd = 'vidya Nagar'.
Append WA to IT.
WA-Eid = '2'.
WA-Ename = 'sai'.
WA-Eadd = 'anand theter'.
Append WA to IT.
Loop at IT into WA.
Write: / WA-Eid, WA-Ename, WA-Eadd.

Endloop.

  1. In the above program we defined one work area WA with three variables.
  2. First we fill the work area and transfer this records into internal table IT.
  3. here we are filling the internal table manually by using APPEND keyword.
  4. Internal table can hold up to 2GB storage.
  5. we can't access the data Directly from internal table so we loop the internal table into work area and print that data in output screen by using WRITE keyword.

Syntax to select query: -

Select is a Keyword which is used to fetch the Data from the database  and placed into internal table or work area.

syntax : 
Select <filed1> <filed2> …. from <data base table> into table <internal table> where <condition>.

EX : 

Data: Begin of WA,
     BUKRS(4) type C,
     BUTXT(25) type C,
     ORT01(25) type C,
     End of WA.
Data IT like table of WA.
Select BUKRS BUTXT ORT01 from T001 into table IT.
Loop at IT into WA.
Write:/ WA-BUKRS, WA-BUTXT, WA-ORT01.
Endloop.

result : 

1000  Punj Lloyd Ltd Gurgon.
2000      New Publications       Mumbai.


Syntax of declaring the field: -

Data <filed name>(<length>) type <data type>
                        (OR)
Data <filed name> type <data elements>
                        (OR)
Data <filed name> type <data base table> - <field name>
Ex: - Data BUKRS(4) type C.
                        (OR)
            Data BUKRS type BUKRS
                        (OR)
            Data Bukrs type T001-Bukrs.

Display the company codes, company names & cities.

step 1 :  identify the table we already knew T001 is a company table  which have all company related data.
Step 2 : Declare one work area and internal table with those fields.
Data: Begin of WA_T001,      "wa_t001 is a work area"
     BUKRS type T001-BUKRS,  "Bukrs : company code"
     BUTXT type T001-BUTXT,  "Butxt : company name" 
     ORT01 type T001-ORT01,  "Ort01 : company city" 
     End of WA_T001.
Data IT like table of WA_T001.

Step 3 : write select query. 
Select BUKRS BUTXT ORT01 from T001 into table IT.

Step 4 :loop the internal table data and print in output screen by using WRITE keyword.

Loop at IT into WA_T001.
Write:/ WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
Endloop.


Monday 3 August 2015

ABAP Basics Part-2

ABAP related T-CODE :


Select-options  : 

Select-options is a keyword which accepts the single value, multiple single values, single range & multiple ranges from selection screen or Key board.

Syntax of select-options: -
Select-options <name of the select-options> for <variable name>.

Ex: -
Data v1 type T001-BUKRS.
Select-options S_BUKRS for v1.


Syntax of select-options in select query: -

Select <filed1> <filed2> ---- from <database table> into table <Internal Table> where <filed> in <select-options>.

Based on given company codes, display the company codes, company names & cities.
Data v1 type T001-Bukrs.
Select-options S_BUKRS for v1.
Data: Begin of WA_T001,
     BUKRS type T001-BUKRS,
     BUTXT type T001-BUTXT,
     ORT01 type T001-ORT01, 
     End of WA_T001.
Data IT_T001 like table of WA_T001.

Select BUKRS BUTXT ORT01 from T001 into table IT_T001 where BUKRS in S_BUKRS.

Loop at IT_T001 into WA_T001.
  Write: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
Endloop.

PARAMETERS  : 

Parameter is a key word which accepts single value from selection screen at run time.
Syntax:-
Parameter <name of the parameter> type <data type>
Ex: - parameter P_BUKRS type T001-BUKRS.

Syntax of parameter in select query: -
Select <filed1> <filed2> ---- from <database table> into table <Internal Table> where filed = <parameter>
Ex: -
Select BUKRS BUTXT LAND1 from T001 into table IT_T001 where BUKRS = P_BUKRS.

Parameters P_LAND1 type KNA1-LAND1.

Data: Begin of WA_KNA1,
     KUNNR type KNA1-KUNNR,
     NAME1 type KNA1-NAME1,
     LAND1 type KNA1-LAND1,
     End of WA_KNA1.

Data IT_KNA1 like table of WA_KNA1.
Select KUNNR NAME1 LAND1 from KNA1 into table IT_KNA1 where LAND1= S_LAND1.
Loop at IT_KNA1 into WA_KNA1.
  Write: / WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-LAND1.
Endloop.
 

Difference between Select Query and Parameters


Sunday 2 August 2015

BADI (Business ADD-INS)


DEFINITION : BADIs are used to adding some additional functionality to the standard functionality 
                          without disturbing the standard functionality.

BADIs are introduced from 4.6C version on wards.

BADI contains 2 sections.
  1.  BADI Definition
  2.  BADI Implementation.

BADI Definition (se18): -

Each BADI definition contains one adapter class and interface. 
Adapter class taking care the version change management i.e when ever  the version is change if any changes required in the BADI those are taken care by adapter class.
Interface is the collection of methods which are defined but not implemented. Those are implemented through BADI implementation based on client requirement.

The TRANSACTION CODE FOR BADI Definition is SE18.

BADI Implementation(Se19): -
           BADI Implementation is nothing but implementing the methods which are defined in BADI definition. 

The TRANSACTION CODE FOR BADI Implementation is SE19.


Differences between Customer exit (Enhancement) and BADI.





Why we go for BADI's ? or What scenario we implement the BADI's ?

Ans :  BADI's are generally used to prevent the mistakes done by end user's or make 
things more easier to the end user.
      we will discuss some of the scenario's where we will use BADI's.



Some of the scenario: -
Scenario 1: -
In the real time MDM (Master Data Management) people create the Vendor and customer through
 ‘XK01’ & ‘XD01’ Tcode.  When ever they create vendor or customer they maintain these details
 in a excel sheet so that at the end of the month they take a printout put a sign and their respective 
superior's  also put a sign.This information is required to audit the companies. 

It is big problem to maintain these vendor details in a separate excel sheet so in order to over come 
    this  problem we we implement a BADI to maintain the key information in a excel sheet at the 
time of create & save the vendor & customer.
              

Scenario 2: -

At the time of creating the vendor and customer some times Material Data management
 (END USERS) people provide the incorrect recon account and cash management group. 
To avoid this we implement the BADI to preset the recon account and cash management 

group based on given company code.

 if you see the above image we create one (custom)z_table for company and respected recon account
   and we fill all the company and their recon account details into that Z_TABLE. so that we will 
assign these table to recon  account field. if end user or material data management people enter
incorrect Recon account it through an error and provide the recon account it is already entered in
our Z_TABLE. 

Scenario 3: -

At the time of creating the vendor or customer some times MDM people or end users provide the invalid terms of payment,to avoid this we implement the BADI to preset the terms of payment based on the purchase organisation or sales organisation.

In this BADI implementation first we need to identify the standard BADI and we implement a code
 in that we write our logic. So if the terms of payment they enter wrong it through an error and it                       automatically reset the Terms and Conditions for that vendor or customer.