Tuesday, September 3, 2024

How to implement screen exit for a SAP standard transaction

 

How to implement screen exit for a SAP standard transaction HOT

By Roshini

Introduction

SAP provides standard transactions to enter data into database. But a client may want to maintain some additional information in SAP other than what is provided.

To make provisions for this, additional screens have to be provided and additional fields must be added into appropriate database table.

To pave way for this, SAP has provided the option for screen exits. Usually, SAP provides the following:

1.     An append structure in the database table with the new fields.

2.     A subscreen area into the standard screen – where the programmer can attach his subscreen of his own program with the new fields.

3.     A function group under which the new subscreen has to be created with the new fields.

4.     Function exits to synchronize the PBO and PAI of the standard SAP program with the PBO and PAI of the subscreen – so that data can flow back and forth between the standard SAP program and the program written by the developer for the subscreen. These function modules also exist in the same function group under which the subscreen will have to be developed.

Finally, a linkage has to be done between the subscreen area of standard SAP screen with the custom subscreen constructed by the developer.

Typically, SAP provides an enhancement in which the developer can create an append structure, use the function exits to synchronize the PBO and PAI of the standard SAP program and the custom subscreen program, and make the necessary linking( as mentioned above in step 4. But, again, this is not a hard and fast rule. Linking in some case, is also done by configurations.) SAP also usually provides the name of the function group under which the subscreen has to be developed.

Necessary guidance about implementing a screen exit development is usually available in the Documentation section of the enhancement ( can be availed by transaction SMOD).

Pre-Requisites

The developer to work on screen exit should have essential knowledge on the following:

  • DDIC concepts, including the knowledge of append structure.
  • Concept of SAP Enhancements and implementing them using Projects.
  • Concept of function exits.
  • Knowledge on Module Pool – including subscreens, Tabstrip controls etc.

Steps

Guidelines

So, a developer can follow the guidelines mentioned below to implement a screen exit to a standard SAP transaction, as and when required:

Find out the Required Enhancements

1.     Go to SMOD. Press F4 in the Enhancement field. In the next popup window, click pushbutton ‘SAP Applications’. A list will appear that contains information on all the enhancements, categorized under functional areas. Developer must search for the enhancements relevant to his functional area of interest – for e.g., Purchasing, Asset Accounting, etc.

2.     Note down the enhancements. Then, come to the initial screen of SMOD and view the documentation of each enhancement to find out which one is required for your development.

Utilize the Enhancement in a Project

After you have found one, do as directed in the documentation. Generally, the steps are as follows:

1.     Create a project using CMOD including your enhancement.

2.     Create the append structure with new fields.

3.     Go to the desired function group and create a subscreen with the new fields. Write PBO and PAI for the subscreen, if required.

4.     Use the function exits in the enhancement to link the PBO and PAI of the subscreen with that of the main SAP program supporting the SAP transaction.

5.     Maintain necessary linkage between the subscreen area of standard SAP program with the custom subscreen developed along with the custom program name. This can be done in the project (developed by CMOD including the enhancement) or outside as a part of configuration.

6.     Activate the project.

7.     Test to ensure that required functionality are met.

Case Study 1

Add three new custom fields for Asset master and maintain information for them

Requirement

Three fields in the legacy system have to be maintained in Asset master. These fields are:

1.     Original Asset number – 20 characters

2.     Location 2 – 15 Characters.

3.     Model no – 20 characters

Location 2 should start with ‘L’.

Pre-Analysis

Finding out the Enhancement

As described above, the enhancement is determined. It was found, that enhancement AIST0002 will serve the purpose. It contains the following components (can be viewed by transaction SMOD):

Exit Type Description EXIT_SAPL1022_001 Function Exit Check of User-Defined Fields when Using Create and Change BAPI EXIT_SAPLAIST_002 Function Exit Transfer Data for User Subscreens in PBO. EXIT_SAPLAIST_003 Function Exit Transfer of User-Defined Fields to SAP Master Data Transactions CI_ANLU Customizing Include Include structure to add new fields

Studying the Function Exits

The function module level documentation for the function exits are then viewed from transaction SE37. The documentation clearly laid out for the purpose for their use:

EXIT_SAPLAIST_002

Function module Level Documentation

This function module is called by asset master data maintenance at the start of the dialog. (When changing, it is called after reading of the data from the database; when creating it is called after the transfer of the default values from the asset class and reference asset.) The purpose of the function module is to enable this function group to recognize the master data. For interpreting or controlling master data fields that are important for user fields, it is possible to transfer to global variables at this point, so that they can be recognized when the user subscreens are processed.

Import Parameters

Understanding

This function module is called at the PBO to pass the information retrieved from the database to pass them to the custom subscreen and its underlying program. Import parameter : I_ANLU will be populated with the values for user-defined fields which will be passed to the subscreen program. So, there must be some sort of variable assignment from I_ANLU.

EXIT_SAPLAIST_003

Function module Documentation: This function module is called by SAP asset master data maintenance after the screens are processed, but before saving. The purpose of the function module is to transfer fields entered on user sub-screens of SAP asset data maintenance to the database for updating. The export parameter for this function module is:

Understanding

This function module will be used to transfer the user entered data in the subscreen fields to the main SAP program, which will then be saved into the database.

Studying the Documentation of the Enhancement

The enhancement documentation (as is viewed from the initial screen of SMOD] also supports the idea. Moreover, it informs that we need to develop a subscreen under function group XAIS. This is the function group under which the two function exit modules also exist. So, if the custom subscreen refers to the global data of the function group XAIS, then those values will also be available to these function exits as well.

Going to SE80 and viewing the function group XAIS helps us to inform that there are three DDIC tables declared for it:

Deciding the Final course of Action

After making all the investigations, the final course of action was determined.

SrlNo Step Justification

1.     A project has to be created using transaction CMOD where the enhancement AIST0002 will be included.

2.     Customizing include CI_ANLU has to be created with the custom fields demanded When CI_ANLU will be developed, the custom fields will get appended to the database table ANLU. Also, these fields will be used to create screen fields in the new subscreen.

3.     A custom subscreen, say, 9000 will be developed under function group XAIS. The screen group for the screen will be ‘CUST’ (or any name). The three custom fields added to table ANLU (by creating CI_ANLU) will be used to create new fields in the screen.

In the PAI of the subscreen, validation for Location to start with ‘L’ will be added. The subscreen with three new fields has to be developed so that it can be attached to a subscreen area of the asset master screens.

1.     In the custom include of the function exit module ‘EXIT_SAPLAIST_002’, the following code will be written:-

ANLU = I_ANLU. I_ANLU is the import parameter of this FM. The value is assigned to the global variable ANLU, referring which the three new subscreen fields are developed. So, data retrieved from database table ANLU will be passed to this FM as I_ANLU by the standard SAP main program. The value will be taken and passed to the global variable of the function group XAIS, so that the three custom fields (referring to ANLU of XAIS) get populated.

1.     In the custom include of the function exit module ‘EXIT_SAPLAIST_003’, the following code will be written:-

E_ANLU = ANLU. The changed values in the subscreen fields exist in global variable ANLU for the function group XAIS. This function exit module will pass the data back to the SAP main program as E_ANLU.

1.     Proper linkage/configuration has to be done so that the new subscreens get linked to the appropriate subscreen area of the Asset master screen. This has to be done – otherwise, the new custom subscreen will not be displayed in the Asset master screens.

Development

Creating a Project to include the enhancement

1.     Go to transaction CMOD and create a project.

2.     Enter a description for the project. Then, click on the pushbutton ‘Enhancement Assignments’ in the Application Toolbar.

3.     Enter the name of the enhancement and Save.

4.     Go to ‘Components’.

Creating Custom Include for ANLU

The screen shown below will appear, showing all the enhancement components under the assignment AIST0002. Double-click on the name of the Include Structure to create it.

Create the include structure with three new fields, as required. Then, save and activate it.

Develop the subscreen and the program

Go to transaction SE80. For the function group XAIS, create a new subscreen 9000.

Create it as subscreen.

Then, go to the Layout of the screen and create three new fields from Database table ANLU.

Drag the fields in the screen body and place them.

Then, save and activate the screen and come back to screen flow editor.

Create the PAI module to add validation for field “Location 2”, as required .

Activate the whole function group and come out.

Write code in the Function Exits to synchronize the programs

Now, code has to be written in the function modules EXIT_SAPLAIST_002 and EXIT_SAPLAIST_003 so that data flows to and fro between the main SAP program and custom subscreen program. For that, go back to transaction CMOD and change the function exits.

Write code in the function module EXIT_SAPLAIST_002 called once at the beginning of the transaction:

Write code in EXIT_SAPLAIST_003 to pass the data from the subscreen to SAP main program.

Then, activate everything – the whole project and come out.

Complete the configuration to link the subscreen

The development portion is complete. Now, linking of the subscreen has to be done with the subscreen area of the main program. In most of the cases, this linking can be done in the enhancement itself. But, here, requirement is a bit different. It is done by configuration using SPRO.

Assets are created under Asset class. And for each asset class, there is a layout assigned to it. For a layout, there are multiple tab pages assigned to it. And, for each tab page, there are multiple screen groups/field groups assigned.

Here, the requirement is to create these three custom fields in the tab page ‘General’ of asset master screen ( AS01/AS02/AS03/AS91).

Determine the Layout

To achieve this, first of all, we need to find out which layout is assigned to asset class 1000.For that, go to transaction AOLK( information has to be obtained from functional consultant).Select the Asset Class ‘1000’ and click on folder ‘General Assignment of Layout’.

Here, for Asset class 1000, for all the user groups, tab layout SAP is assigned. Since layout ‘SAP’ cannot be changed, it has to be copied and manipulated to include our screen group. Later, the new layout has to be assigned over here.

Create new tab layout

Go to transaction AOLA. Copy the tab layout ‘SAP’ to create another layout, say, YSUB.

System will copy all the settings and will inform you about that.

Select your newly created layout and double-click on the folder ‘Tab page titles’.

You want to put your custom fields in the tab page “General”. So, select this tab page entry and double-click on the folder "Position of Groups".

Here, all the field groups currently residing in the tab-page “General” are shown. Add an entry for your newly created fields.

Select the group box from the list. An entry will come with “U” padded with the custom subscreen prepared by you.

Then, save and come out.

Assign the new Layout to Asset Class

Now, go to tcode AOLK and assign tab layout YSUB for asset class 1000.

Save and come out.

Test the Exit

Everything is over. Now, go to transaction code AS01/02/03 or AS91 to deal with an asset of asset class 1000. You will see your new fields added to the screen. Add values to them…save. Then, enter into the tcodes again to see whether the values entered by you are being displayed or not.

Original Source: ittoolbox.com

 

What is the difference between SMOD and CMOD?

 

What is the difference between SMOD and CMOD?

CMOD is the Project Management of SAP Enhancements (i.e., SMOD Enhancements). SMOD contains the actual enhancements and CMOD is the grouping of those SMOD enhancements. 

User exits (Function module exits) are exits developed by SAP. The exit is implementerd as a call to a function module. The code for the function module is written by the developer. You are not writing the code directly in the function module, but in the include that is implemented in the function module. 

The naming standard of function modules for function module exits is: 
EXIT_<program name><3 digit suffix> 

The call to a functionmodule exit is implemented as: 
CALL CUSTOMER.-FUNCTION <3 digit suffix> 

For Example: 

The program for transaction VA01 Create salesorder is SAPMV45A

1. If you search for CALL CUSTOMER-FUNCTION program SAPMV45A you will find ( Among other user exits): 

CALL CUSTOMER-FUNCTION '003'
  exporting
    xvbak   = vbak
    xvbuk   = vbuk
    xkomk   = tkomk
  importing
    lvf_subrc = lvf_subrc
  tables
    xvbfa = xvbfa
    xvbap = xvbap
    xvbup = xvbup. 

The exit calls function module EXIT_SAPMV45A_003 

2. How to find user exits 

Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT 

If you know the Exit name, go to transaction CMOD. Choose menu Utillities->SAP Enhancements

Enter the exit name and press enter. 

You will now come to a screen that shows the function module exits for the exit. 

or use this ABAP program to search for user exits :-

Finding the user-exits of a SAP transaction code

3. Using Project management of SAP Enhancements 

You want to create a project to enhance transaction VA01

- Go to transaction CMOD
- Create a project called ZVA01
- Choose the Enhancement assign radio button and press the Change button
In the first column enter V45A0002 Predefine sold-to party in sales document . Note that an enhancement can only be used for 1 project. If the enhancement is allready in use, and error message will be displayed
- Press Save
- Press Components. You can now see that enhancement uses user exit EXIT_SAPMV45A_002. 
- Double Click on the exit.
Now the function module is displayed. Double click on include ZXVVAU04 in the function module
Insert the following code into the include: E_KUNNR = '2155'. 

Activate the include program. Go back to CMOD and activate the project. 
Goto transaction VA01 and create a salesorder. Note that Sold-to-party now automatically is "2155" 

 

Field exits (SMOD/CMOD) Questions and Answers

 

Field exits (SMOD/CMOD) Questions and Answers

1. Field exit was created with CMOD, but is not processed when calling the screen.

   o  Since the field exit is not processed until PAI, an action must be
      triggered on the screen (Return, Save, ...).

   o  Set profile parameter abap/fieldexit to YES and restart the
      system.

   o  After activating the function module FIELD_EXIT... and the field
      exit, leave the transaction on whose screen the field exit is to
      be executed. The screen is not generated until the transaction is
      started.

   o  Do not work on different application servers since there may be
      some delay before the field exit is activated.

   o  The profile parameter must be set on all or none of the
      application servers.

   o  If the field exit is to only be active on specific screens, check
      whether you chose the correct program and the correct screen
      number (take care with subscreens).

   o  Using SE51 -> Field list, check that the screen field does have a
      reference to a data element. In the name of the field exit use the
      name of the data element and not the field name.

   o  After transport, field exits are marked as active but will not be
      processed. Tip: First try deactivating the field exit once more
      and then afterwards, activate it again.

2. How is performance affected by setting abap/fieldexit?

   o  If a screen is generated and the profile parameter is set, a check
      is run on 2 tables (TDDIR, TDDIRS) to see whether a field exit
      must be generated for the respective field. In practice, the
      screen load is not generated until the screen is selected after an
      update. The user should not notice any difference because screen
      generation is very fast.

3. Can you read the contents of other screen fields in the field exit?

   o  In principle, every field exit can store its value in the global
      variables of the function group (TOP) and hence make them
      available to other field exits. Note here that field exits are
      always called and not only if an entry is made in the field or if
      the field is empty. In addition, it is not possible to make any
      assumptions about the order in which the field exits will be
      called in the future.

4. How does the field exit behave on step loop fields ?

   o  After the user has entered data, the field exit is called in PAI
      as often as there are visible fields in the step loop. The system
      variable SY-STEPL is incremented each time. If a new value is
      assigned to the field, it is displayed in the module between LOOP
      and ENDLOOP. This module is also called once for each visible step
      loop line.

5. Can field exits be debugged ?

   o  No. Field exits must be tested separately in the ABAP/4
      Development Workbench. For errors which only occur in the screen
      environment, it is helpful to write interesting variable to the
      file system using TRANSFER... . These can then be analysed there.

6. What can you do if the field contents are no longer transported to to
   ABAP/4.

   o  Check whether a value is assigned to the field OUTPUT.

7. When is the field exit called if a conversion exit is attached to the
   data element ?

   o  The field exit is called after the conversion exit. This means
      that the INPUT field receives the data in the same format as the
      ABAP/4 program also receives it.

8. Although a global field exit is inactive, a function module is called
   which does not exist (for example FIELD_EXIT_PROGRAMM_@)

   o  This is an error in the kernel which no longer occurs as of 3.0C.
      As a temporary measure, it is useful to assign a program and a
      screen which do not exist to the field exit and then activate the
      field exit.

9. Field exit is not visible in CMOD, although created.

   o  If you want to create a field exit for a data element, a function
      module is proposed with the name FIELD_EXIT_. This
      function module must exist for the field exit to work. If you do
      not create this function module, but do create one with a suffix,
      the data element is not displayed in CMOD.

10.Field exit is not executed although it is active.

   o  Fields which do not have the 'Input field' attribute usually do
      not trigger a field exit. The field exit is designed to allow an
      extended input check. It is therefore only called for input fields
      - even if they are not ready for input at runtime of the
        application by LOOP AT SCREEN.
      This rule does not apply, however, if the field is located within
      a steploop. Here the field will be always activated, even if it is
      invisible.

   o  Field exits can only be executed for fields that are directly
      related tothe dictionary. If the relation is indirect, i.e. via an
      ABAP declaration (  LIKE ), no field exit can be executed.

11.Field exits on check buttons do not work

   o  Field exits are only intended for input fields. As check buttons
      count as graphical elements, you cannot install field exits on
      them.

12.Field exits do not work on selection screens

 

Difference Between BADI and User Exits

 

Difference Between BADI and User Exits

Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software. 

As with customer exits two different views are available:

In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional software to standard SAP source code without having to modify the original object. 

In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard logic if one is available.

In contrast to customer exits, Business Add-Ins no longer assume a two-level infrastructure (SAP and customer solutions), but instead allow for a multi-level system landscape (SAP, partner, and customer solutions, as well as country versions, industry solutions, and the like). Definitions and implementations of Business Add-Ins can be created at each level within such a system infrastructure.

SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces. You do not have to register Business Add-Ins in SSCR.

The Business Add-In enhancement technique differentiates between enhancements that can only be implemented once and enhancements that can be used actively by any number of customers at the same time. In addition, Business Add-Ins can be defined according to filter values. This allows you to control add-in implementation and make it dependent on specific criteria (on a specific Country value, for example).

All ABAP sources, screens, GUIs, and table interfaces created using this enhancement technique are defined in a manner that allows customers to include their own enhancements in the standard. A single Business Add-In contains all of the interfaces necessary to implement a specific task.

The actual program code is enhanced using ABAP Objects. In order to better understand the programming techniques behind the Business Add-In enhancement concept, SAP recommends reading the section on ABAP Objects.
 

 

Finding the user-exits of a SAP transaction code

 

Finding the user-exits of a SAP transaction code

*
* Finding the user-exits of a SAP transaction code
*
* Enter the transaction code in which you are looking for the user-exit
* and it will list you the list of user-exits in the transaction code.
* Also a drill down is possible which will help you to branch to SMOD.
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*              http://www.sap-img.com
*
 
report zuserexit no standard page heading.
tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
         tables : tstct.
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
parameters : p_tcode like tstc-tcode obligatory.
 
select single * from tstc where tcode eq p_tcode.
if sy-subrc eq 0.
   select single * from tadir where pgmid = 'R3TR'
                    and object = 'PROG'
                    and obj_name = tstc-pgmna.
   move : tadir-devclass to v_devclass.
      if sy-subrc ne 0.
         select single * from trdir where name = tstc-pgmna.
         if trdir-subc eq 'F'.
            select single * from tfdir where pname = tstc-pgmna.
            select single * from enlfdir where funcname =
            tfdir-funcname.
            select single * from tadir where pgmid = 'R3TR'
                               and object = 'FUGR'
                               and obj_name eq enlfdir-area.
 
            move : tadir-devclass to v_devclass.
          endif.
       endif.
       select * from tadir into table jtab
                     where pgmid = 'R3TR'
                       and object = 'SMOD'
                       and devclass = v_devclass.
        select single * from tstct where sprsl eq sy-langu and
                                         tcode eq p_tcode.
        format color col_positive intensified off.
        write:/(19) 'Transaction Code - ',
             20(20) p_tcode,
             45(50) tstct-ttext.
                    skip.
        if not jtab[] is initial.
           write:/(95) sy-uline.
           format color col_heading intensified on.
           write:/1 sy-vline,
                  2 'Exit Name',
                 21 sy-vline ,
                 22 'Description',
                 95 sy-vline.
           write:/(95) sy-uline.
           loop at jtab.
              select single * from modsapt
                     where sprsl = sy-langu and
                            name = jtab-obj_name.
                   format color col_normal intensified off.
                   write:/1 sy-vline,
                          2 jtab-obj_name hotspot on,
                         21 sy-vline ,
                         22 modsapt-modtext,
                         95 sy-vline.
           endloop.
           write:/(95) sy-uline.
           describe table jtab.
           skip.
           format color col_total intensified on.
           write:/ 'No of Exits:' , sy-tfill.
        else.
           format color col_negative intensified on.
           write:/(95) 'No User Exit exists'.
        endif.
      else.
          format color col_negative intensified on.
          write:/(95) 'Transaction Code Does Not Exist'.
      endif.
 
at line-selection.
   get cursor field field1.
   check field1(4) eq 'JTAB'.
   set parameter id 'MON' field sy-lisel+1(10).
   call transaction 'SMOD' and skip first   screen.
 
*---End of Program

 

A Short Tutorial on User Exits

 

A Short Tutorial on User Exits

Content Author: Abhishek

User exits

1. Introduction
2. How to find user exits
3. Using Project management of SAP Enhancements 

1. Introduction
User exits (Function module exits) are exits developed by SAP. The exit is implementerd as a call to a functionmodule. The code for the function module is writeen by the developer. You are not writing the code directly in the function module, but in the include that is implemented in the function module.

The naming standard of function modules for functionmodule exits is: 
EXIT_<program name><3 digit suffix> 

The call to a functionmodule exit is implemented as:
CALL CUSTOMER.-FUNCTION <3 digit suffix>

Example:

The program for transaction VA01 Create salesorder is SAPMV45A

If you search for CALL CUSTOMER-FUNCTION i program
SAPMV45A you will find ( Among other user exits):

CALL CUSTOMER-FUNCTION '003'
  exporting
    xvbak   = vbak
    xvbuk   = vbuk
    xkomk   = tkomk
  importing
    lvf_subrc = lvf_subrc
  tables
    xvbfa = xvbfa
    xvbap = xvbap
    xvbup = xvbup.

The exit calls function module EXIT_SAPMV45A_003

2. How to find user exits
Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT

If you know the Exit name, go to transaction CMOD.

Choose menu Utillities->SAP Enhancements. Enter the exit name and press enter.

You will now come to a screen that shows the function module exits for the exit.

3. Using Project management of SAP Enhancements
We want to create a project to enahance trasnaction VA01

- Go to transaction CMOD
- Create a project called ZVA01
- Choose the Enhancement assign radio button and press the Change button

In the first column enter V45A0002 Predefine sold-to party in sales document . Note that an enhancement can only be used i 1 project. If the enhancement is already in use, and error message will be displayed

Press Save

Press Components. You can now see that enhancement uses user exit EXIT_SAPMV45A_002. Double click on the exit.

Now the function module is displayed. Double click on include ZXVVAU04 in the function module

Insert the following code into the include: E_KUNNR = '2155'.

Activate the include program. Go back to CMOD and activate the project. 

Goto transaction VA01 and craete a salesorder. 

Note that Sold-to-party now automatically is "2155"

 

What is User Exits?

 

What is User Exits? 

The following document is about exits in SAP :-

The R/3 enhancement concept allows you to add your own functionality to SAP’s standard business applications without having to modify the original applications. 

SAP creates user exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.

Types of Exits 
There are several different types of user exits. Each of these exits acts as hooks where you can attach or "hang" your own add-ons.

Menu Exits
Menu exits add items to the pulldown menus in standard SAP applications. You can use these menu items to call up your own screens or to trigger entire add-on applications.

SAP creates menu exits by defining special menu items in the Menu Painter. These special entries have function codes that begin with "+" (a plus sign). You specify the menu item’s text when activating the item in an add-on project.

Screen Exits
Screen exits add fields to screens in R/3 applications. SAP creates screen exits by placing special subscreen areas on a standard R/3 screen and calling a customer subscreen from the standard screen’s flow logic.

Function Module Exits 
Function module exits add functions to R/3 applications. Function module exits play a role in both menu and screen exits. 

When you add a new menu item to a standard pull down menu, you use a function module exit to define the actions that should take place once your menu is activated. 

Function module exits also control the data flow between standard programs and screen exit fields. SAP application developers create function module exits by writing calls to customer functions into the source code of standard R/3 programs. 

These calls have the following syntax: 

CALL CUSTOMER-FUNCTION ‘001’.

Field Exits
Field exits allow you to create your own programming logic for any data element in the Dictionary. You can use this logic to carry out checks, conversions, or business-related processing for any screen field.  Example: The data element BBBNR identifies a company’s international location number. You might want to set up your R/3 System so that all international location numbers are larger than 100. 

The field exit concept lets you create a special function module that contains this logic. 

You assign the special function module to the data element BBBNR. You then assign the module to any programs and screens in which users can add new international location numbers. When you activate your field exit, the system automatically triggers your special routine whenever a user enters a company location number. 

In 4.6c, you can use "RSMODPRF" program to create field exits.

An example of a user exits :-

MODULE user_exit_0001 INPUT 
    CASE okcode.
        WHEN 'BACK OR EXIT'.
            CASE sy-dynnr.
                    WHEN '100'.
                         SET SCREEN 0.
                         LEAVE SCREEN.
                    WHEN '200'.
******************************************************************************
**** Note that you can write any code that satisfy your needs.                                                     ****
**** But in this case, this was wrote as a sample code for reference sake.                                    ****
**** And you can test it.                                                                                                             ****
****************************************************************************** 
                         SET SCREEN 100.
                         LEAVE SCREEN.
             ENDCASE.
      ENDCASE. 

 

Sunday, September 1, 2024

ABAP Miscellaneous Questions

 

How do you get help in ABAP? 
HELP-SAP LIBRARY, by pressing F1 on a keyword.

 

Does SAP handle multiple currencies? Multiple languages? 
Yes.

What are the different modules of SAP? 
FI, CO, SD, MM, PP, HR.

Are programs client dependent? 

Yes. Group of users can access these programs with a client no.

 

What are the general naming conventions of ABAP programs? 
Should start with Y or Z.

 

Which transaction code can I used to analyze the performance of ABAP PROGRAM?

SE30 runtime analysis 
ST05 Performance trace

 

When top of the page event is triggered?

When the first write statements is occurring that time top of page event is triggered

 

What are internal tables? - Internal tables are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organizing the contents of database tables according to users need.

 What is a collect statement? How is it different from append? 
If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry. 

What’s an effective way of using an internal table record? What are the types of internal tables?

The types of internal tables are: standard table, sorted table and hashed table. Hash table is the most efficient of the three with a constant response time.

 

What are different data types in ABAP/4? 
Elementary - 
          predefined C,D,F,I,N,P,T,X.
          userdefined TYPES.
 Ex: see in Intel book page no 35/65

     Structured - 
         predefined    TABLES.
         User defined Field Strings and internal tables.

What are the different types of data dictionary objects? 
Tables, structures, views, domains, data elements, lock objects, Match code objects.

 

 

What is the step by step process to create a table in data dictionary?

Step 1: creating domains (data type, field length, range).

Step 2: creating data elements (properties and type for a table field).

Step 3: creating tables (SE11).

 

What happens when a table is activated in DD? 
It is available for any insertion, modification and updating of records by any user.

What are match codes? Describe? 
It is a similar to table index that gives list of possible values for either primary keys or non-primary keys.

 

What is an ABAP data dictionary?- ABAP 4 data dictionary describes the logical structures of the objects used in application development and shows how they are mapped to the underlying relational database in tables/views.

What are domains and data element? - Domains: Domain is the central object for describing the technical characteristics of an attribute of a business objects. It describes the value range of the field. Data Element: It is used to describe the semantic definition of the table fields like description the field. Data element describes how a field can be displayed to end-user.

Can you create a table with fields not referring to data elements? 
YES.  eg:- ITAB LIKE SPFLI.here we are referencing to a data object(SPFLI) not data element.

 

Can a transparent table exist in data dictionary but not in the data base physically?  NO.
TRANSPARENT TABLE DOES EXIST WITH THE SAME STRUCTURE BOTH IN THE DICTIONARY AS WELL AS IN THE DATABASE, EXACTLY WITH THE SAME DATA AND FIELDS.

What is foreign key relationship? - A relationship which can be defined between tables and must be explicitly defined at field level. Foreign keys are used to ensure the consistency of data. Data entered should be checked against existing data to ensure that there are now contradictions. While defining foreign key relationship cardinality has to be specified. Cardinality mentions how many dependent records or how referenced records are possible.

What are indexes? - Indexes are described as a copy of a database table reduced to specific fields. This data exists in sorted form. This sorting form eases fast access to the field of the tables. In order that other fields are also read, pointers to the associated record of the actual table are included in the index. The indexes are activated along with the table and are created automatically with it in the database.

Describe data classes. - Master data: It is the data which is seldomly changed. Transaction data: It is the data which is often changed. Organization data: It is a customizing data which is entered in the system when the system is configured and is then rarely changed. System data: It is the data which R/3 system needs for itself.

Define Meta data, Master data and Transaction data - Meta Data: Data that describes the structure of data or MetaObjects is called Metadata. In other words data about data is known as Meta Data. Master Data: Master data is data that remains unchanged over a long period of time. It contains information that is always needed in the same way. Characteristics can bear master data in BW. With master data you are dealing with attributes, texts or hierarchies. Transaction data: Data relating to the day-to-day transactions is the Transaction data.

What are internal tables check table, value table, and transparent table? - Internal table: It is a standard data type object, which exists only during the runtime of the program.

Check table: Check table will be at field level checking.

Value table: Value table will be at domain level checking ex: scarr table is check table for carrid.

Transparent table: - Exists with the same structure both in dictionary as well as in database exactly with the same data and fields.

Difference between transparent tables and pooled tables. - Transparent tables: Transparent tables in the dictionary have a one-to-one relation with the table in database. Its structure corresponds to single database field. Table in the database has the same name as in the dictionary. Transparent table holds application data. Pooled tables. Pooled tables in the dictionary have a many-to-one relation with the table in database. Table in the database has the different name as in the dictionary. Pooled table are stored in table pool at the database level.

What is cardinality? 
For cardinality one out of two (domain or data element) should be the same for Ztest1 and Ztest2 tables. M: N
Cardinality specifies the number of dependent (Target) and independent (source) entities which can be in a relationship.

What is BDC programming? - Transferring of large/external/legacy data into SAP system using Batch Input programming. Batch input is an automatic procedure referred to as BDC (Batch Data Communications).The central component of the transfer is a queue file which receives the data vie a batch input programs and groups associated data into “sessions”.

What are the functional modules used in sequence in BDC? - These are the 3 functional modules which are used in a sequence to perform a data transfer successfully using BDC programming: BDC_OPEN_GROUP - Parameters like Name of the client, sessions and user name are specified in this functional modules.

BDC_INSERT - It is used to insert the data for one transaction into a session. BDC_CLOSE_GROUP - This is used to close the batch input session.

 

What should be the approach for writing a BDC program?

STEP 1: CONVERTING THE LEGACY SYSTEM DATA TO A FLAT FILE to internal table CALLED "CONVERSION".

STEP 2: TRANSFERING THE FLAT FILE INTO SAP SYSTEM CALLED "SAP DATA TRANSFER".

STEP 3: DEPENDING UPON THE BDC TYPE

 I) call transaction (Write the program explicitly)

ii) Create sessions (sessions are created and processed. if success data will transfer).

 

What is the structure of a BDC sessions. 
BDCDATA (standard structure).

What are the fields in a BDC_Tab Table. 
Program, dynpro, dynbegin, fnam, fval.

What has to be done to the packed fields before submitting to a BDC session? 
Fields converted into character type.

 

What is the alternative to batch input session?

Call transaction.

 

What is the advantage of structures? How do you use them in the ABAP programs?

Adv: - GLOBAL EXISTANCE (these could be used by any other program without creating it again).

 

What kinds of BDC programs are written?

Batch Input method,

Call Transaction method,

Direct Input method

 

What is the difference between Upload and WS_Upload?

The difference between WS_Upload and Upload is when you use function Upload it prompts for a dialog box where in you need to key in the file location. Where as in case of WS_Upload you specify the file location in the function input parameters itself

 

Upload requires a User Interaction for uploading i.e., user has to respond to the dialog boxes that appear while WS_Upload does not

 

 

Update types in Call transaction method. What is the difference?

Call transaction update types: S /A/L S-SYNCHRONOUS A-ASYNCHRONOUS L-LOCAL MEMORY synchronous mode is waiting for commit work and asynchronous is not waiting for commit work.

 

SM35 transaction. How to automate BDC?

After execution of batch input program, the session created is placed in the session queue which can be viewed using SM35 transaction executing / releasing the session will start the transfer of the data from the session into the database tables

 

Recording Function

Recording tr code: shdb. It’s used to find the screen no and field name and program name also. Mainly used to write bdc programs.

 

What is a batch input session? - BATCH INPUT SESSION is an intermediate step between internal table and database table. Data along with the action is stored in session i.e. data for screen fields, to which screen it is passed, program name behind it, and how next screen is processed.

 

Our ABAP program is working properly in Foreground. Can I schedule it for background processing on the weekend? 

SAP standard program RSBDCSUB helps you to schedule the job. Create a variant for RSBDCSUB with the BDC session name.

 

A situation: An ABAP program creates a batch input session. 
We need to submit the program and the batch session in back ground. How to do it? 

 Go to SM36 and create background job by giving 
 job name, job class and job steps (JOB SCHEDULING)

What is ERP? - ERP is a package with the techniques and concepts for the integrated management of business as a whole, for effective use of management resources, to improve the efficiency of an enterprise. Initially, ERP was targeted for manufacturing industry mainly for planning and managing core business like production and financial market. As the growth and merits of ERP package ERP software is designed for basic process of a company from manufacturing to small shops with a target of integrating information across the company.

 

What is SAP? - SAP is the name of the company founded in 1972 under the German name (Systems, Applications, and Products in Data Processing) is the leading ERP (Enterprise Resource Planning) software package.

Different types of ERP? - SAP, BAAN, JD Edwards, Oracle Financials, Siebel, PeopleSoft. Among all the ERP’s most of the companies implemented or trying to implement SAP because of number of advantages aver other ERP packages.

Why do you usually choose to implement SAP? - There are number of technical reasons numbers of companies are planning to implement SAP. It’s highly configurable, highly secure data handling, min data redundancy, max data consistency; you can capitalize on economics of sales like purchasing, tight integration-cross function.

Can BW run without a SAP R/3 implementation? - Certainly. You can run BW without R/3 implementation. You can use pre-defined business content in BW using your non-SAP data. Here you simply need to map the transfer structures associated with BW data sources (InfoCubes, ODS tables) to the inbound data files or use 3rd part tool to connect your flat files and other data sources and load data in BW. Several third party ETL products such as Acta, Informatics, Data Stage and others will have been certified to load data in BW.

What is IDES? - International Demonstration and Education System. A sample application provided for faster learning and implementation.

What is SAP R/3? - A third generation set of highly integrated software modules that perform common business function based on multinational leading practice. Takes care of any enterprise however diverse in operation, spread over the world. In R/3 system all the three servers like presentation; application server and database server are located at different system.

What are presentation, application and database servers in SAP R/3? - The application layer of an R/3 System is made up of the application servers and the message server. Application programs in an R/3 System are run on application servers. The application servers communicate with the presentation components, the database, and also with each other, using the message server. All the data are stored in a centralized server. This server is called database server.

Explain open SQL vs. native SQL? - ABAP Native SQL allows you to include database-specific SQL statements in an ABAP program. Most ABAP programs containing database-specific SQL statements do not run with different databases. If different databases are involved, use Open SQL. To execute ABAP Native SQL in an ABAP program, use the statement EXEC. Open SQL (Subset of standard SQL statements), allows you to access all database tables available in the R/3 System, regardless of the manufacturer. To avoid conflicts between database tables and to keep ABAP programs independent from the database system used, SAP has generated its own set of SQL statements known as Open SQL.

What are the events in ABAP/4 language?- Initialization, At selection-screen, Start-of-selection, end-of-selection, top-of-page, end-of-page, At line-selection, At user-command, At PF, Get, At New, At LAST, AT END, AT FIRST.

 

What are screen painter and menu painter?- Screen painter: Screen painter is a tool to design and maintain screen and its elements. It allows user to create GUI screens for the transactions. Attributes, layout, filed attributes and flow logic are the elements of Screen painter. Menu painter: Menu painter is a tool to design the interface components. Status, menu bars, menu lists, F-key settings, functions and titles are the components of Menu painters. Screen painter and menu painter both are the graphical interface of an ABAP/4 application.

What is DynPro?- DynPro is a Dynamic Programming which is a combination of screen and the associated flow logic Screen is also called as DynPro.

What are the components of SAP scripts?- SAP scripts is a word processing tool of SAP which has the following components: Standard text. It is like a standard normal document. Layout sets. - Layout set consists of the following components: Windows and pages, Paragraph formats, Character formats. Creating forms in the R/3 system. Every layout set consists of Header, paragraph, and character string. ABAP/4 program.

What are the different elements in layout sets? 
PAGES, Page windows, Header, Paragraph, Character String, Windows.

Can you use if then else, perform...etc statements in sap script? 
Yes.

 

What is Smart Forms?- Smart Forms allows you to create forms using a graphical design tool with robust functionality, color, and more. Additionally, all new forms developed at SAP will be created with the new Smart Form solution.

 

How can I make a differentiation between dependent and independent data? - Client dependent or independent transfer requirements include client specific or cross client objects in the change requests. Workbench objects like SAPscripts are client specific; some entries in customizing are client independent. If you display the object list for one change request, and then for each object the object attributes, you will find the flag client specific. If one object in the task list has this flag on, then that transport will be client dependent.

 

 

What is an ABAP/4 Query?- ABAP/4 Query is a powerful tool to generate simple reports without any coding. ABAP/4 Query can generate the following 3 simple reports: Basic List: It is the simple reports. Statistics: Reports with statistical functions like Average, Percentages. Ranked Lists: For analytical reports. - For creating a ABAP/4 Query, programmer has to create user group and a functional group. Functional group can be created using with or without logical database table. Finally, assign user group to functional group. Finally, create a query on the functional group generated.

What is ALV programming in ABAP? When is this grid used in ABAP?- ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.

What is CTS and what do you know about it?- The Change and Transport System (CTS) is a tool that helps you to organize development projects in the ABAP Workbench and in Customizing, and then transport the changes between the SAP Systems and clients in your system landscape. This documentation provides you with an overview of how to manage changes with the CTS and essential information on setting up your system and client landscape and deciding on a transport strategy. Read and follow this documentation when planning your development project.

What are logical databases? What are the advantages/ disadvantages of logical databases? - To read data from a database tables we use logical database. A logical database provides read-only access to a group of related tables to an ABAP/4 program. Advantages: i) check functions which check that user input is complete, correct, and plausible. ii) Meaningful data selection. iii) Central authorization checks for database accesses. iv) Good read access performance while retaining the hierarchical data view determined by the application logic. Disadvantages: i) If you don’t specify a logical database in the program attributes, the GET events never occur. ii) There is no ENDGET command, so the code block associated with an event ends with the next event statement (such as another GET or an END-OF-SELECTION).

What is the difference between macro and subroutine? - Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation. Subroutines (FORM) can be called from both the program the are defined in and other programs. A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice. A FORM is a local subroutine (which can be called external). A FUNCTION is (more or less) a subroutine that is called external. Since debugging a MACRO is not really possible, prevent the use of them (I’ve never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION.

What are datasets? - The sequential files (processed on application server) are called datasets. They are used for file handling in SAP.

What is AWB?. What is its purpose? - AWB stands for Administrator WorkBench. AWB is a tool for controlling, monitoring and maintaining all the processes connected with data staging and processing in the business information warehousing.

 

What is the difference between ALE, EDI, IDocs and BAPI?

The interface concept of the classic R/3 is based on two different strategies: Remote Function Calls (RFC) and data exchange through IDoc message documents. RFC makes direct and synchronous calls of a program in the remote system. If the caller is an external program it will call an RFC-enabled function in R/3 and if the calling program is the R/3 system it will call an RFC-function in another R/3-system or it will call a non-R/3 program through a gateway-proxy (usually rfcexec.exe). BAPIs are a subset of the RFC-enabled function modules, especially designed as Application Programming Interface (API) to the SAP business object, or in other words: are function modules officially released by SAP to be called from external programs.

IDocs are text encoded documents with a rigid structure that are used to exchange data between R/3 and a foreign system. Instead of calling a program in the destination system directly, the data is first packed into an IDoc and then sent to the receiving system, where it is analyzed and properly processed. Therefore an IDoc data exchange is always an asynchronous process. The significant difference between simple RFC-calls and IDoc data exchange is the fact, that every action performed on IDocs are protocolled by R/3 and IDocs can be reprocessed if an error occurred in one of the message steps.

While IDocs have to be understood as a data exchange protocol, EDI and ALE are typical use cases for IDocs. R/3 uses IDocs for both EDI and ALE to deliver data to the receiving system. ALE is basically the scheduling mechanism that defines when and between which partners and what kind of data will be exchanged on a regular or event triggered basis. Such a set-up is called an ALE-scenario.

The philosophical difference between EDI and ALE can be pinned as follows: If we send data to an external partner, we generally speak of EDI, while ALE is a mechanism to reliable replicate data between trusting systems to store a redundant copy of the IDoc data. The difference is made clear, when we think of a purchase order that is sent as an IDoc. If we send the purchase order to a supplier then the supplier will store the purchase order as a sales order. However, if we send the purchase order via ALE to another R/3 system, then the receiving system will store the purchase order also as a purchase order.


How do you determine which interface method to use when interfacing to SAP/R3? In other words, do you go with BAPI, IDocs, RFC or ALE and so on?


RFC is the technology that allows to call a function module within an R/3 system from another R/3 instance or an external program from an R/3 instance.

BAPI function modules are special function modules that are released by SAP as an official application programming interface, which is releases and supported for public use. Hence, BAPIs are a subset of the RFC enabled function modules. Technically, there is no difference between RFCs and BAPIs, but SAP wants you to use a BAPI to access R/3 functionality from external programs, whenever a BAPI exists.

IDoc is a transport vehicle for data transfer in and out of an R/3 system. The data transferred between the system in the IDoc format, which is a text format. The IDoc is either exchanged via a file, so R/3 writes the IDoc to a file and the other one picks up the IDoc and vice versa or the IDoc is handed other via an R/3 RFC call. To send an IDoc to R/3 you call the special BAPI function: IDOC_INBOUBD_ASYNCHRONOUS and to send it out, R/3 ultimately calls IDOC_SEND. (However, for sending you should customize the route in transaction menu WEDI, and let the IDoc engine do the work).

ALE is a scheduling mechanism that defines a scenario to determine the triggers and data types to exchange with an external system. ALE uses IDocs to exchange the data at a given time.

So the general decision is: Would you rather use IDocs (or ALE) or RFCs (or BAPIs) to exchange the data? If you need the data to be protocol led or to be exchanged asynchronously, then you need IDocs. If you can dispose of logging the data in the receiving system (and thus dispose of the possibility to reprocess the data), then you can call the handling RFC function directly, which is quicker, produces less data garbage, but requires that the sending system must care for the error handling.

 

How do you find if a logical database exists for your program requirements? 
SLDB-F4.

What are IDOCs? 
IDOCs are intermediate documents to hold the messages as a container.

What are interface/conversion programs in SAP? 
CONVERSION: LEGACY SYSTEM TO FLAT FILE.
INTERFACE: FLAT FILE TO SAP SYSTEM.

 

CoPilot For Eclipse - The Joule Alternative

GitHub CoPilot works alongside you in the Eclipse Editor. It autogenerates code suggestions, provides correction syntax. Free version includ...