Monday, 9 December 2013

How to Display Traffic Lights in Report Output : SAP ABAP

Sometime there will a requirements to display the Traffic Light Signal icons in report output.

In this post, we will see how to display the Traffic Lights Signal icons in report output.

Setp-1: Create a report program form SE38 transaction and paste the below code.

REPORT ZVENU_TRAFFIC_SIGNALS.

*--Declaration of variables
DATA: L_GREEN(4)  TYPE C VALUE '@08@',
      L_YELLOW(4) TYPE C VALUE '@09@',
      L_RED(4)    TYPE C VALUE '@0A@'.

*--Printing the GREEN Traffic light
WRITE: / L_GREEN , 'Green Signal'.

*--Printing the GREEN Traffic light
WRITE: / L_YELLOW , 'Yellow Signal'.

*--Printing the GREEN Traffic light
WRITE: / L_RED , 'Red Signal'.

Step-2: Save and Activate.

Step-3: Execute the report. Now you will be able to see the traffic lights in output, which is as soon below.


Important Notes:
  • Every ICONs in SAP has its own two digit code associated with it. 
  • To display the ICON in Report/ALV output we need to pass the the icon code between to @@ symbols. i.e @XX@.
Regards,
Venugopal M N

Wednesday, 20 November 2013

Step by Step Procedure to add Button in Application Toolbar in ALV Output: SAP ABAP

Problem Statement: 

In some situation, there will be a requirement to add custom button in application tool bar of ALV output. In this tutorial we will see the step by step procedure to add new button to application tool bar.


Step-1: Create the report ‘ZAPP_BUTTTON_RPT’ from SE38 transaction and copy paste the below code.

*&---------------------------------------------------------------------*
*& Report  ZAPP_BUTTTON_RPT
*&---------------------------------------------------------------------*

REPORT zapp_buttton_rpt.

TYPE-POOLS: slis.  " SLIS contains all the ALV data types

*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: t_sbook      TYPE TABLE OF sbook.
DATA: t_fieldcat   TYPE slis_t_fieldcat_alv,
      x_fieldcat  
TYPE slis_fieldcat_alv.

*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.

*--Fetch the required data from databaase table
  
SELECT * FROM sbook INTO TABLE t_sbook.

*--Build field catalog
  x_fieldcat
-fieldname  = 'CARRID'.    " Fieldname in the data table
  x_fieldcat
-seltext_m  = 'Airline Name'." Column description
  
APPEND x_fieldcat TO t_fieldcat.
  
CLEAR x_fieldcat.

  x_fieldcat
-fieldname  = 'CONNID'.
  x_fieldcat
-seltext_m  = 'Con. No.'.
  
APPEND x_fieldcat TO t_fieldcat.
  
CLEAR x_fieldcat.

*--Call FM to disaplay data in ALV GRID format
  
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    
EXPORTING
*     i_callback_program       = 
*     i_callback_pf_status_set = ''
*     i_callback_user_command  = ''
      it_fieldcat              
= t_fieldcat
    
TABLES
      t_outtab                 
= t_sbook
    
EXCEPTIONS
      program_error            
= 1
      
OTHERS                   = 2.
  
IF sy-subrc NE 0.
    
MESSAGE 'Error in displaying output.' TYPE 'E'.
  
ENDIF.

Step-2: Save, Activate and Execute the above program. Output of the program looks like as follows.



Step-3: Now go to SE90 transaction.
Expand the Objects from the left 'Repository Information System' section as follows.
i.e. Repository Information System >> Program Library >> Program Subobjects >> GUI Status
Double click on GUI Status, and enter Program Name as 'SAPLKKBL' and Extcute.

The screen looks as follows.


Upon executing, we will see the list of available GUI Status

Step-3: 
Select the CHECKBOX corresponds to STANDARD.
From Menu, go to GUI Status >> Copy (Click On COPY)


Step-4: Popup window appears, fill the details as follows and click on 'COPY'.


Step-5: Below window will appears, click on 'COPY'. 


Step-6: Now the GUI status is copied to your program. This can be seen as below.


Step-7: Double click on the 'ZSTANDARD' GUI Status. It will take you to below screen.


Step-8: Enter the function code as '&BUT' as shown above and double click on the same to proceed further. 

Upon double clicking following screen appears, select 'Static Text' Radio Button and press OK.

Step-9: Below screen appears, enter Function text, Icon Name and Information Text as show below and press OK.

As you can see in the above figure, we have selected "Folder Icon". You select the icon of your interest by F4 help on Icon name field.

Step-9: Assign Function to function key. In our example we have selected "Shift-F1", then press OK.

Step-10: Below screen appears, now validate the data entered and press OK.


Step-11: Upon pressing OK it will take you to below screen.


Save the changes to GUI status and Activate.

Step-12: Now go back to your program. Copy and Paste the below code. SAVE and ACTIVATE the program.

*&---------------------------------------------------------------------*
*& Report  ZAPP_BUTTTON_RPT
*&---------------------------------------------------------------------*

REPORT zapp_buttton_rpt.

TYPE-POOLS: slis.  " SLIS contains all the ALV data types

*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: t_sbook      TYPE TABLE OF sbook.
DATA: t_fieldcat   TYPE slis_t_fieldcat_alv,
      x_fieldcat  
TYPE slis_fieldcat_alv.

*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.

*--Fetch the required data from databaase table
  
SELECT * FROM sbook INTO TABLE t_sbook.

*--Build field catalog
  x_fieldcat
-fieldname  = 'CARRID'.    " Fieldname in the data table
  x_fieldcat
-seltext_m  = 'Airline Name'." Column description
  
APPEND x_fieldcat TO t_fieldcat.
  
CLEAR x_fieldcat.

  x_fieldcat
-fieldname  = 'CONNID'.
  x_fieldcat
-seltext_m  = 'Con. No.'.
  
APPEND x_fieldcat TO t_fieldcat.
  
CLEAR x_fieldcat.

  
DATA: l_repid TYPE sy-repid.
  l_repid 
= sy-repid.

*--Call FM to disaplay data in ALV GRID format
  
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    
EXPORTING
      i_callback_program       
= l_repid
      i_callback_pf_status_set 
= 'SUB_PF_STATUS'
      i_callback_user_command  
= 'USER_COMMAND'
      it_fieldcat              
= t_fieldcat
    
TABLES
      t_outtab                 
= t_sbook
    
EXCEPTIONS
      program_error            
= 1
      
OTHERS                   = 2.
  
IF sy-subrc NE 0.
    
MESSAGE 'Error in displaying output.' TYPE 'E'.
  
ENDIF.

*&---------------------------------------------------------------------*
*&      Form  sub_pf_status
*&---------------------------------------------------------------------*
*  Sub-Routine to Set the PF status
*----------------------------------------------------------------------*
FORM sub_pf_status USING rt_extab TYPE slis_t_extab..
  
SET PF-STATUS 'ZSTANDARD'.
ENDFORM.                    "sub_pf_status

*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*   Sub-Routine to handle the click on the ALV aoutput
*----------------------------------------------------------------------*
FORM user_command USING r_ ucomm    LIKE sy-ucomm
                       rs_selfield 
TYPE slis_selfield.

  
IF r_ucomm EQ '&BUT'.
    
MESSAGE 'Custom button is clicked.' TYPE 'S'.
  
ENDIF.

ENDFORM.  "User_command

Step-13: Execute(F8) the program. Now we can see the newly added BUTTON in application toolbar.


Click on the button to see the success message written in the code.

Conclusion:
Thus we have learnt the procedure to add the Button in Application Toolbar in ALV Output.


Regards,
Venugopal M N

Sunday, 13 October 2013

Features of the ABAP Program & ABAP Editor

Following are the some of the features of ABAP programming.
  • Syntax of the ABAP is similar to COBOL
  • ABAPStatements and keywords are case insensitive
  • Custom ABAP programs must start with  “Y” or “Z” and can be up to 30 characters in length
  • ABAP is case sensitive during the comparison
  • Every ABAP statement / expression  must end with a period (Full Stop)
  • Tokens within a statement must be separated by at least one space
Following are the some of the features of SAP ABAP Editor.
  • The editor is similar to notepad
  • Use CTRL+C to copy the selected portion of the source code
  • Use CTRL+V to paste the selected portion of the source code
  • Use CTRL+X to cut the selected portion of the source code
  • Use CTRL+S key to save the program in the ABAP editor
  • USE CTRL+F1 to transform from CHANGE/DISPLAY mode
  • USE CTRL+F2 for syntax check
  • USE CTRL+F3 for activating the program
  • Use CTRL+< to comment the ABAP statement
  • Use CTRL+> to uncomment ABAP statement


CLIENT in SAP

  • CLIENT is the topmost hierarchy in SAP database
  • Client dependent tables will have field of data type MANDT
  • Each function module in SAP is assigned to aclient
  • The object developed by the developer is stored in a package and request number and finally saved under a client number assigned  for particular module

CLIENT / Server Concept

SAP follows client server architecture. 




Client requests for some information from the server by passing some data. Server serves/ sends the information requested from the client. This network topology is called client / server architecture.

SAP : R/3 System Architecture & Components

R/3 System Architecture

R/3 system is a 3 tier architecture having
1. Presentation Server
2. Application Server
3. Database Server

  • Presentation server 
The local desktop serves as the presentation server, which is nothing but SAP GUI where the user logon to the client and work from the local machine
  • Application server
The server/computer on which the programs are run or executed is the application server. Application server receives the input from the presentation server and interpret the ABAP code and sends back the result to the presentation server
  • Database server
  1. The server/computer which receivers the request from the application server and interprets it and sends the request to RDBMS and collect the data requested from the RDBMS and sends back to the application server.
  2. All objects such as source code/generated binary code, tables etc. are physically present in the RDBMS
  3. R/3 is having the single database, which makes the operation of entire architecture faster and results in better performance

R/3 Architecture Components

List of R/3 components are as follows
  • DISPATCHER
  • WORK PROCESS
  • DATABASE CONNECTIVITY
DISPATCHER:
This is a component which acts as an interface between Presentation Layer and the Application Server. It receives the request from the user from the Presentation Server/Layer and allocates work area for each request from the user.

WORK PROCESS:
This is a Component which allocates memory area for each request received from dispatcher on roll-in and roll-out basis. Once the request is process, the memory area is rolled out to allocate the next request from the dispatcher.

DATABASE CONNECTIVITY:
OPEN SQL - It receives the SAP R/3 specific OPEN SQL statement from the user and converts it into database specific NATIVE SQL format (Database used at the backend)

NATIVE SQL – It checks for the syntax in the request received and passes the request to the database through the gateway service

SAP Basis - An Overview

SAP Basis is the technological platform that supports the entire range of SAP applications. Basis is similar to an operating system for R/3. It provide run-time environment for ABAP code.

One cannot execute ABAP/4 program without BASIS. Syntax checking, binary code generation will be done by the SAP basis

It is a layer of abstraction between the business applications and the operating system and database, which ensures that applications can be run on any platform (Portability).

SAP Basis supports following Operating Systems:
  • UNIX (AIX, HP-UX, Solaris, Linux)
  • Microsoft - Windows
  • Apple - i5/OS
  • Z/OS


SAP Basis Supported Database is
  • IBM DB2
  • Informix 
  • MaxDB
  • Oracle
  • Microsoft SQL Server


ABAP Runtime Environment

SAP BASIS provides the runtime environment for the ABAP code. All ABAP programs reside inside the SAP database. 

In the database all ABAP code exists in two forms:
  • Source Code - which can be viewed and edited with the ABAP Workbench tools
  • Generated code - which is a binary code generated after activation of the source code


ABAP programs execute under the control of the runtime system, which is part of the SAP kernel

Features of the Runtime
  • It is part of the SAP kernel
  • Responsible for processing ABAP statements
  • Controlling the flow logic of screens
  • Responding/Handling to events to events
  • Convert the database-independent ABAP statements (Open SQL) to database specific (Native SQL) statements