Dec 30, 2014

Sapscript/Smartforms Formatting options


&symbol(Z)& Omit Leading Zeros
&symbol(S)& Omit Leading Sign
&symbol(<)& Display Leading Sign to the Left
&symbol(>)& Display Leading Sign to the Right
&symbol(C)& Compress Spaces
&symbol(.N)& Display upto N decimal places
&symbol(T)& Omit thousands separator
&symbol(R)& Right justified
&symbol(I)& Suppress output of the initial value


Offset
Specifying an offset of N has the effect that the N left-most characters of the
symbol value will not be displayed. If the offset specified is greater than the
length of the value, nothing is output.
Syntax
&symbol+offset&
If symbol has the value 123456789, the following will be displayed:
&symbol& -> 123456789
&symbol+3& -> 456789
&symbol+7& -> 89
&symbol+12& ->
&symbol+0& -> 123456789


Output Length
If you require only a part of the symbol value, or the output has to fit into a box or
a field on the screen, without overlapping the edges of this area, then you can use
an output length specification to define how many character positions should be
copied from the value.
Syntax
&symbol(length)&
If symbol has the value 123456789.
&symbol(3)& -> 123
&symbol(7)& -> 1234567


Dec 15, 2014

Create Search Help in ABAP for Web Dynpro Component

This ABAP tutorial shows how to create search help and use it in Web Dynpro component for a context node attribute. First developers create Search Help in ABAP Data Dictionary using SE80 then assign Search Help to context node attribute using Input Help Mode and Dictionary Search Help properties in SAP Web Dynpro component.

This ABAP tutorial is formed of two sub-headings. First part in this tutorial shows how ABAP developers can create a search help in ABAP DATA Dictionary. The second section of the tutorial is dealing with how Web Dynpro developers can use this search help for a context node attribute.


Create Search Help in Data Dictionary

Call transaction SE80 Object Navigator. In Transport Organizer tab select Package from drop down list. Find your target package where you want to create your search help data dictionary object.


Right click on Dictionary Objects Context menu Create > Search Help


Type Search Help name. Leave Elementary search help as selected option.


Search Help create screen to define a new one


Type a short description. On Definition tab, type the master lookup table name at Selection method input textbox. Click on the first empty parameter line Search help parameter cell. Press F4 for possible entries or click on the F4 icon displayed when you click on the cell.


Double click on the field name you want to export to input text which is dislaying this search help. Mark the search help parameter as export.

Add all other desired fields but mark this time as import parameters

Enter the position number you want to see the field values in hit list using the LPos entery field. If you try to activate Search Help without hit list, you will get an error preventing the successfull activation of Search Help data dictionary object. Position in the hit list of an elementary search help Position of the parameter in the hit list.
Save and activate

Use Search Help in Web Dynpro Component for a Context Field

If you are going to use this Search Help on a Web Dynpro component, open component controller. Go to Context tab. Drill down the context node until you find the target field. Open properties of the attribute. There is a dropdown box at Input Help Mode property. You will see Dictionary Search Help. Change it from Automatic which is default to Dictionary Search Help.


Then enter the name of the Search Help data dictionary object which we have created in previous steps into the "Dictionary Search Help" property.


Save and activate your web dynpro component.
Here is the Search Help in action on a Web Dynpro web page.

Sep 30, 2014

Copying Fields from other Structures or Tables


1.  Create table / structure name. As an example below is table name

















2.  Choose from menu: Edit -> Transfer Fields


3.  Input structure name and press ‘Selection’.

4.  Select the fields and press Copy




5.  Paste the fields from Cipboard:


6.  All fields copied:




Sep 29, 2014

Create and Delete Folder in Frontend system using Class CL_GUI_FRONTEND_SERVICES

Procedure:
  1. Create Selection Screen with two radio buttons “Create Folder” and “Delete Folder”. And parameters to specify path for creating and deleting the folder.
  2. Give path and folder name in the selection screen
  3. Creating folder select the “Create Folder” Radio Button
  4. Deleting folder select the “Delete Folder” Radio Button  

Creation Process:












Deletion Process:









ABAP Codes:

*&----------------------------------------------------------------*
*& Report  Z_TEST001
*&
*&----------------------------------------------------------------*
*&
*&
*&----------------------------------------------------------------*

REPORT z_test001.

* Selection Screen Declarations
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_cr RADIOBUTTON GROUP rgb1 USER-COMMAND uco
                                    MODIF ID mod DEFAULT 'X',
            p_dr RADIOBUTTON GROUP rgb1 MODIF ID mod,
            p_cdir TYPE string,
            p_ddir TYPE string.
SELECTION-SCREEN END OF BLOCK b1.

* Data declarations
DATA: result TYPE char1,
      rc TYPE i,
      stripped_name TYPE string,
      v_string TYPE string.

************************************
* At Selection-Screen Output Event
************************************

AT SELECTION-SCREEN OUTPUT.

* Create Folder Checkbox Checked, Don’t display 
* the “Path to Delete Folder” parameter
  IF p_cr = 'X'.
    LOOP AT SCREEN.
      IF screen-name = 'P_DDIR' OR
        screen-name = '%_P_DDIR_%_APP_%-TEXT'.
        screen-input = 0.
        screen-invisible = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.

* Delete Folder Checkbox Checked, Don’t display the 
* “Path to Create Folder” parameter
    LOOP AT SCREEN.
      IF screen-name = 'P_CDIR' OR
        screen-name = '%_P_CDIR_%_APP_%-TEXT'.
        screen-input = 0.
        screen-invisible = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

************************************
* Start of Selection Event
************************************
START-OF-SELECTION.

  IF p_cr = 'X'.
    "create folder radio button is checked.

*   Clear result variable
    CLEAR result.

*     Get the folder name
    CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
      EXPORTING
        full_name     = p_cdir
      IMPORTING
        stripped_name = stripped_name
      EXCEPTIONS
        x_error       = 1
        OTHERS        = 2.

*   Check if the folder name exists under the specified
*   directory which you want to create
    CALL METHOD cl_gui_frontend_services=>directory_exist
      EXPORTING
        directory            = p_cdir
      RECEIVING
        result               = result
      EXCEPTIONS
        cntl_error           = 1
        error_no_gui         = 2
        wrong_parameter      = 3
        not_supported_by_gui = 4
        OTHERS               = 5.

*   If the folder name already exists then display a message.
    IF result = 'X'.

      CLEAR v_string.
      CONCATENATE 'ALREADY CONTAINS A FOLDER NAMED'
                  stripped_name
                  INTO v_string SEPARATED BY space.

      MESSAGE v_string TYPE 'I'.
      LEAVE LIST-PROCESSING.

*   If the folder name is not exist in the specified directory
    ELSE.

*     Clear return code
      CLEAR rc.

*     Create a new folder under the specified directory
      CALL METHOD cl_gui_frontend_services=>directory_create
        EXPORTING
          directory                = p_cdir
        CHANGING
          rc                       = rc
        EXCEPTIONS
          directory_create_failed  = 1
          cntl_error               = 2
          error_no_gui             = 3
          directory_access_denied  = 4
          directory_already_exists = 5
          path_not_found           = 6
          unknown_error            = 7
          not_supported_by_gui     = 8
          wrong_parameter          = 9
          OTHERS                   = 10.

      IF rc = 0.
        CLEAR v_string.
        CONCATENATE 'CREATED FOLDER NAMED'
                    stripped_name
                    INTO v_string SEPARATED BY space.

        MESSAGE v_string TYPE 'I'.
      ENDIF.

    ENDIF.

  ELSE.  "Delete folder radio button is checked.

*   Clear result variable
    CLEAR result.

*   Get the folder name
    CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
      EXPORTING
        full_name     = p_ddir
      IMPORTING
        stripped_name = stripped_name
      EXCEPTIONS
        x_error       = 1
        OTHERS        = 2.

*   Check if the folder name exists under the specified
*   directory which you want to create
    CALL METHOD cl_gui_frontend_services=>directory_exist
      EXPORTING
        directory            = p_ddir
      RECEIVING
        result               = result
      EXCEPTIONS
        cntl_error           = 1
        error_no_gui         = 2
        wrong_parameter      = 3
        not_supported_by_gui = 4
        OTHERS               = 5.

    IF result <> 'X'.

      CLEAR v_string.

      CONCATENATE 'THERE IS NO FOLDER NAMED'
                  stripped_name
                  INTO v_string SEPARATED BY space.

      MESSAGE v_string TYPE 'I'.
      LEAVE LIST-PROCESSING.

*   If the folder name exist, delete that folder from the
*   specified directory
    ELSE.

*     Clear return code
      CLEAR rc.

*      Delete folder from the specified directory
      CALL METHOD cl_gui_frontend_services=>directory_delete
        EXPORTING
          directory               = p_ddir
        CHANGING
          rc                      = rc
        EXCEPTIONS
          directory_delete_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          path_not_found          = 4
          directory_access_denied = 5
          unknown_error           = 6
          not_supported_by_gui    = 7
          wrong_parameter         = 8
          OTHERS                  = 9.
      IF rc = 0.
        CLEAR v_string.

        CONCATENATE 'DELETED FOLDER NAMED'
                    stripped_name
                    INTO v_string SEPARATED BY space.

        MESSAGE v_string TYPE 'I'.
        LEAVE LIST-PROCESSING.

      ENDIF.
    ENDIF.
  ENDIF.

Sep 26, 2014

Creating, Editing, and Deleting Enhancement Implementations

Use
  • If you have explicit enhancement options, you have to create the enhancement implementations for the related enhancement spots.
  • If you have implicit enhancement options, you create the enhancement implementations directly.
Procedure
  1. Start the Object Navigator (SE80).
  2. Open the package in which an enhancement implementation is defined or is to be created.
Create an enhancement implementation
  • If you have an explicit enhancement option, select the enhancement spot in the Object Navigator and in the context menu choose Implement.
  • For an implicit enhancement option, open the Enhancement Builder in the relevant tool (ABAP Editor, Function Builder, Class Builder) for executing an enhancement and continue with the following steps:
    1. Enter a name for the (simple) enhancement implementation.
    2. Enter a short text for the (simple) enhancement implementation.
    3. Select a composite enhancement implementation, or create a new one.
    4. Choose Creation of Enhancement (Enter).
      The subsequent process depends on the enhancement technology of the enhancement spot.
Edit an enhancement implementation
  1. Select the package and expand it.
  2. Expand the Enhancements node.
  3. Expand the Enhancement Implementations node.
  4. Select the desired enhancement implementation.
  5. Select Change from the context menu.
  6. If you only want to display the enhancement implementation, choose Display.
Delete an enhancement implementation
  1. Select the package and expand it.
  2. Expand the Enhancements node.
  3. Expand the Enhancement Implementations node.
  4. Select the desired enhancement implementation.
  5. In the context menu, choose Delete.

Ref: http://help.sap.com/saphelp_nw73ehp1/helpdata/en/5f/103a4280da9923e10000000a155106/content.htm


Creating, Editing, and Deleting Enhancement Spots

Create a composite enhancement spot
  1. Select the package in which you want to create the enhancement spot.
  2. Open the context menu and choose Create Enhancement Composite Enhancement SpotA dialog appears.
  3. Specify a name and a short description. Optionally, you can assign the new spot to an already existing composite enhancement spot.
  4. Activate the new spot.
Create a subordinate composite enhancement spot

  1. Open the desired package.
  2. Select the composite enhancement spot to which your new subordinate composite spot will belong.
  3. Open the context menu and choose Create → Subordinate Composite Enhancement Point. A dialog appears.
  4. Specify a name and a short description.
  5. Choose This graphic is explained in the accompanying text Activate to activate the new subordinate spot.

Result:
  • The selected composite enhancement spot and its newly created subordinate one are displayed in the object list in a list form (not as a tree) on the same level.
  • Choose the composite enhancement spot and select the Spot Composites tab to check whether the new subordinate composite is properly attached.
  • The header of the new subordinate spot has to contain the name of the composite enhancement spot to which this subordinate is attached.
  • Use a forward navigation to Navigate from parent to child and back.



Create a simple enhancement spot
  1. Select the package in which you want to create the simple enhancement spot.
  2. Open the context menu and choose Create Enhancement Enhancement SpotA dialog appears.
  3. Specify a name and a short description. Optionally, you can assign the new spot to an already existing composite enhancement spot.
  4. Select the desired technology from the Technology list. (Currently it is only possible to create enhancement spots of type “BAdI“.)
  5. Source code plug-ins can only be created inside the editor, because they contain points and sections.
  6. Activate the new simple enhancement spot.

Edit an enhancement spot
  1. Select the package and expand it.
  2. Expand the Enhancements node.
  3. Expand the Enhancement Spot node.
  4. Select the desired enhancement spot.
  5. Choose Change from the context menu.
  6. Choose Display if you only want to display the enhancement spot.

Delete an enhancement spot
  1. Select the package and expand it.
  2. Expand the Enhancements node.
  3. Expand the Enhancement Spot node.
  4. Select the desired enhancement spot.
  5. Choose Delete from the context menu.

Ref: https://help.sap.com/saphelp_nw70/helpdata/en/3b/0a39426f79f83ae10000000a1550b0/content.htm

Debugging Web Dynpro ABAP Applications

The ABAP runtime environment contains various tools that you can use for analysis purposes, such as for debugging source code. All source code written for Web Dynpro applications in ABAP can normally be tested using the debugger.
To allow it to test other Web Dynpro-specific program entities too, the debugger has been equipped with a special enhancement. In the phase model in the active application, you can typically see the following information at various points in time:
  • The structure of the content of the current controller,
  • The properties of the UI elements in the layout of the current view
  • The currently instantiated component usages

Starting the Debugger
The functions to debug Web Dynpro units are embedded in the New Debugger. Therefore you must have selected the new Debugger in your workbench settings.
Selecting the New Debugger
  1. In the menu, choose Utilities -> Settings... (return).
  2. Choose the parent tab page ABAP Editor.
    The settings for ABAP Editor open with the content of the child tab page Editor.
  3. Under Editor, select the option Front-End Editor (new).
  4. Switch to the Debugging tab page.
  5. Under ABAP Debugger, select the option New Debugger.
  6. Save your entries.
Starting the Debugging Process
  1. To run an application in debugging mode, you first need to set an external breakpoint in display mode in one of the methods in the component:
    Setting an external breakpoint (Setting an external breakpoint)
    Note Note
    Note that this is an external breakpoint.
    End of the note.
    The method in which you set the breakpoint depends on the purpose of the test run. To debug a view, for example, it is best to set the breakpoint in method WDDOMODIFYVIEW. Provided that the context of the view controller is not filled using a supply method, the view is fully instantiated in the phase model at this point in time.
  2. Now start a test run of the application from ABAP Workbench as usual.
Selecting the Web Dynpro Tool in the New Debugger
When you start the application, another session opens automatically for the debugger. If you have not yet saved any personal settings with regard to the layout of the debugger, the Editor tool will now appear on the left, with the Display Variables tool on the right.
  1. Select one of the three desktops in order to reconfigure it for debugging the Web Dynpro application (refer to Designing Work Areas).
  2. The right-hand edge of the debugger window has a bar of function symbols. Choose the Replace Tools symbol:
    Replace tools (Replace tools)
  3. In the New Tool window, open the lowest node (Special Tools) and choose Web Dynpro.
  4. Save your entries.
On the right of the debugger desktop, you will see that the previous tool has now been replaced by the Web Dynpro debugger. You can save this setting for future debugging activities. To do this, choose Save Layout in the debugger’s general toolbar:
Save layout (Ctrl+Shift+F3) (Save layout (Ctrl+Shift+F3))


Ref: http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/74d50bd1431b5ae10000000a42189c/content.htm

Mar 28, 2014

SAP Icons and Codes


A sample program to display all Icons in SAP:

*&----------------------------------------------------------*
*& Report  ZICONS                                           *
*&                                                          *
*&----------------------------------------------------------*
*&                                                          *
*&                                                          *
*&----------------------------------------------------------*

REPORT ZICONS.

TABLES: ICON.
INCLUDE <ICON>.
FIELD-SYMBOLS: <F>.

SELECT * FROM ICON.
   ASSIGN (ICON-NAME) TO <F>.
   WRITE:   /(5) <F>, 20 '@',21 ICON-ID+1(2),23 '@',
            ICON-OLENG,ICON-BUTTON,ICON-STATUS,
            ICON-MESSAGE,ICON-FUNCTION,ICON-NAME.
ENDSELECT.




~o~

Jan 25, 2014

Display data dynamically using Field Symbols

1.     Introduction: - Displaying the table contents dynamically as per table name mentioned on selection screen with help of field symbols.  If user enters MARA, then the data from MARA table is retrieved. If VBAK, then VBAK data is shown.  

2.     Steps:
Declare two parameter variables as below:-
Create a field symbol as below:-
Initially check whether table exists or not.
If table exists in database then by using create data statement create the data object and assign the reference to data object of w_dref reference variable.
Now assign the reference variable to field symbol as below:
In runtime after assign statement the <t_itab> structure will be same as table name entered on selection screen.
Now select the data from database and put it in field-symbol (dynamic internal table).
Now create the field catalog by using the function module .
Display the data by using function module  as below:-
  
Example:-
Give table name as mara on selection screen and no of records as 100 and press F8. 
List is displayed as below:
Now give table name as VBAK and press F8.

3.     Summary:-
The importance of this tutorial is to display the data as per table name mentioned on selection screen by user with Field symbols concept.
a)     First declare the two parameters one for table name and other for no of records to be displayed.
b)    Declare the field symbol of type standard table.
c)     Check table name given on selection screen exists or not.
d)    Create the internal table at runtime and select the data from table and place it in dynamic internal table (Field symbol).
e)     Create the field catalog and display the data.  
4.     Source Code:-
REPORT y_saptechnical_dynamic NO STANDARD PAGE HEADING.
*"Type-pool............................................................
TYPE-POOLS : slis.*"Parameters elements..................................................
PARAMETERS : p_table TYPE tabname OBLIGATORY,       " Table Name
             p_no    
TYPE i .                       " No of Records to be displayed

DATA:
  w_dref    
TYPE REF TO data,          " w_dref reference variable
  t_line    
TYPE c LENGTH 20.          " w_line to hold a line
DATA :
  t_fcat  
TYPE slis_t_fieldcat_alv.

FIELD-SYMBOLS: <t_itab> 
TYPE STANDARD TABLE.

START-OF-SELECTION.
  
SELECT SINGLE
         tabname                       
" Table Name
    
FROM dd02l
    
INTO t_line
   
WHERE tabname   EQ p_table
     
AND as4vers   EQ ' '
     
AND as4local  EQ 'A'
     
AND tabclass  NE 'INTTAB'
     
AND tabclass  NE 'APPEND'.

  
IF sy-subrc EQ 0.
    
CREATE DATA w_dref TYPE STANDARD TABLE OF (p_table).
    
ASSIGN w_dref->* TO <t_itab>.
    
IF sy-subrc EQ 0.
      
SELECT *                         " All Fields
        
FROM (p_table)
        
INTO TABLE <t_itab> UP TO p_no ROWS.

      
IF sy-subrc EQ 0.
        
PERFORM fill_catalog.
        
PERFORM display.
      ELSE.
        
MESSAGE text-002 TYPE 'S'.
        EXIT.
      ENDIF.                           
" IF sy-subrc EQ 0...
    ELSE.
      
MESSAGE text-003 TYPE 'S'.
      EXIT.
    ENDIF.
  ELSE.
    
MESSAGE text-003 TYPE 'S'.
    
LEAVE LIST-PROCESSING.
  ENDIF.                               
" IF sy-subrc EQ 0...
FORM display .
  
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    
EXPORTING
      it_fieldcat   = t_fcat
    
TABLES
      t_outtab      = <t_itab>
    
EXCEPTIONS
      program_error = 
1
      
OTHERS        2.
  
IF sy-subrc <> 0.
    
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE 'E'
            
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.                               
" IF sy-subrc <> 0...
ENDFORM.                               
" DISPLAY
FORM fill_catalog .
  
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    
EXPORTING
      i_program_name         = sy-repid
      i_structure_name       = p_table
    
CHANGING
      ct_fieldcat            = t_fcat
    
EXCEPTIONS
      inconsistent_interface = 
1
      program_error          = 
2
      
OTHERS                 3.
  
IF sy-subrc <> 0.
    
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE 'E'
            
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.                               
" IF sy-subrc <> 0...
ENDFORM.                               
" FILL_CATALOG



Source:
http://saptechnical.com/Tutorials/ABAP/FS/Index.htm
by Vineesh Batchu, Yash Technologies