100% found this document useful (1 vote)
1K views

Abap - All Interview Questions

This document contains questions and answers about ABAP topics like BAPI, RFC, extensions, exceptions, and syntax changes in ABAP 7.4. It discusses how BAPI EXTENSIONIN and EXTENSIONOUT are used to update and retrieve custom fields, and how to enhance standard BAPIs using extension tables. When calling BAPIs, errors are trapped in the returning parameters. The differences between RFCs and BAPIs are explained. RFCs allow remote function calls while BAPIs provide APIs through registered business objects. New syntax examples show how to read tables, handle exceptions, append data, use filters, and pass values in RFCs in ABAP 7.4. P

Uploaded by

Bharat Bhushan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views

Abap - All Interview Questions

This document contains questions and answers about ABAP topics like BAPI, RFC, extensions, exceptions, and syntax changes in ABAP 7.4. It discusses how BAPI EXTENSIONIN and EXTENSIONOUT are used to update and retrieve custom fields, and how to enhance standard BAPIs using extension tables. When calling BAPIs, errors are trapped in the returning parameters. The differences between RFCs and BAPIs are explained. RFCs allow remote function calls while BAPIs provide APIs through registered business objects. New syntax examples show how to read tables, handle exceptions, append data, use filters, and pass values in RFCs in ABAP 7.4. P

Uploaded by

Bharat Bhushan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 35

ABAP Interview questions and answers

Q: what is EXTENSIONIN and EXTENSIONOUT in BAPI ?


Ans: BAPI EXTENSIONIN is used to update custom fields of a table (ex: MARA).
BAPI EXTENSIONOUT is used to retrieve custom fields of a table.

Q: In interactive report if user 19 times double clicked, again he want


to main screen. how can do this?
Ans: If Sy-ucomm ='BACK'.
Leave to screen 0.
Endif.

How to enhance Standard BAPI ?


Ans: We can enhance only those standard bapi which is having table parameters (EXTENSIONIN
OR EXTENSIONOUT ) . For example we have following Standard BAPI which is having either
(EXTENSIONIN OR EXTENSIONOUT ) table parameters.

1) BAPI_PO_CREATE1 : This BAPI is having both parameters (EXTENSIONIN AND EXTENSIONOUT


)
2) BAPI_SALESORDER_CHANGE : This BAPI is having parameters ( EXTENSIONIN )
 

3) BAPI_SALESORDER_CREATEFROMDAT2 : This BAPI is having parameters ( EXTENSIONIN )


Process to enhance Standard BAPI :

Introduction
Customers often have to change the standard SAP objects in order to meet their own specific
requirements. This might involve passing some additional information by adding few extra fields to the
standard SAP table. These fields might get updated in underlying Standard SAP tables or customer
database table and ultimately serve the business purpose.

Business Scenario
For example, assume that there is extra information that we want to save to the database while
creating a new purchase order. I.e. Prepared By, Checked By, Approved By.

BAPI Extension Table


But this change might affect the further BAPI implementations. This is because BAPIs are designed
to implement SAP standard business processes through a predefined standard interface. I.e. its
import and export parameters for any BAPI are fixed. So addition of new customer fields has
absolutely nothing to do with this predefined BAPI interface. This is because these fields are added
to SAP database. So executing BAPI with the same import and export parameter is not sufficient.
We have to pass extra information about newly added fields. This information is passed to the BAPI
using BAPI table extension. The naming convention for BAPI table extensions is
BAPI_TE_<table_name>.
Here the customer first creates a data structure that contains the customer-specific fields. In our
example, it is CI_EKKODB. This structure is included in both the database table and the BAPI table
extension. This ensures that the enhancements to the database table and in the table extension are
always identical.
Extension container

An extension parameter (ExtensionIn) in the BAPI interface is used to pass on the enhancements
to the BAPI in container format. This extension parameter is always based on data
structure BAPIPAREX. Using this parameter BAPI understands the format of the data to be passed.
Here, the STRUCTURE refers to the name of the BAPI table extension though which extra
information is to be sent whereas VALUEPART1 to VALUEPART4 are the values that will be
inserted in the additional table fields along with the table key field.  Key field, here,
purchase_order_no is the extra information that needs to be passed to know the line in the database
table where the data record needs to be written.
So extension container could look like

STRUCTURE VALUEPART1 VALUEPART2 …..


BAPI_TE_MEPOHEADER 3300000180  Nikhil Pravin  Parvati

.
..

Here, ‘3300000180’ is the key field for EKKO table specifying which row to be updated. And
“Nikhil Pravin Parvati” is the extra fields of EKKO specified in BAPI_TE_MEPOHEADER.

Source Code
Once the BAPI Extension Table and Extension Container are filled, Execute the BAPI by passing
Extension Container as an table type argument.
How to add push button on selection screen?
TYPE-POOLS: icon.
TABLES sscrfields.
*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
SELECTION-SCREEN:
PUSHBUTTON /2(40) button1 USER-COMMAND but1,
PUSHBUTTON /2(40) button2 USER-COMMAND but2.
*--------------------------------------------------------------*
*At Selection-Screen
*--------------------------------------------------------------*
AT SELECTION-SCREEN.
CASE sscrfields.
WHEN 'BUT1'.
MESSAGE 'Button 1 was clicked' TYPE 'I'.
WHEN 'BUT2'.
MESSAGE 'Button 2 was clicked' TYPE 'I'.
ENDCASE.
*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*
INITIALIZATION.
button1 = 'Button 1'.
button2 = 'Button 2'.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = icon_okay
text = 'Continue'
info = 'Click to Continue'
IMPORTING
RESULT = button1
EXCEPTIONS
OTHERS = 0.

CALL FUNCTION 'ICON_CREATE'


EXPORTING
name = icon_cancel
text = 'Exit'
info = 'Click to Exit'
IMPORTING
RESULT = button2
EXCEPTIONS
OTHERS = 0.

Selection Screen Output

What is the difference between RFC and BAPI?


BAPI RFC
Just as Google offers Image/Chart/Map APIs OR RFC is nothing but a remote enabled function
Facebook offers APIs for Comment/Like, SAP offers module. So if there is a Function Module in SAP
APIs in the form of BAPIs. BAPI is a library of system 1 on server X , it can be called from a SAP
function modules released by SAP to the public so system 2 residing on server Y.
that they can interface with SAP.
In BAPI you create business object and those No Business Object is associated with a RFC.
business object are registered in BOR ( Business
Object Repository)
Outside world (JAVA, VB, .Net or any Non SAP Non–SAP world cannot connect to SAP using RFC.
system) can connect to SAP using a BAPI.
Error or Success messages are returned in a RFC does not have a return table.
RETURN table.
How to handle Error in BAPI ?

Ans: Error are trapped in Returning parameters in BAPI. Please check below code for your reference.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header  = gmhead
          goodsmvt_code    = gmcode
        IMPORTING
          goodsmvt_headret = mthead
        TABLES
          goodsmvt_item    = itab
          return           = errmsg.
      CLEAR errflag.

      LOOP AT errmsg.
        IF errmsg-type EQ 'E'.
          WRITE:/'Error in function', errmsg-message.
          errflag = 'X'.

        ELSE.
          WRITE:/ errmsg-message.
        ENDIF.
      ENDLOOP.

Q: Read table syntax in ABAP 7.4 and before ABAP 7.4?


// Before 7.40

READ TABLE lt_itab INDEX lv_index INTO ls_itab.

// After 7.40

DATA(ls_itab) = lt_itab[ lv_index ].

// Before 7.40

READ TABLE lt_itab INTO ls_itab WITH KEY id = lv_id.

// After 7.40

DATA(ls_itab) = lt_itab[ id = lv_id ].

// Before 7.40

READ TABLE lt_itab INDEX lv_index USING KEY lv_key INTO ls_itab.

// After 7.40

DATA(ls_itab) = lt_itab[ KEY lv_key INDEX lv_index ].

// As I mentioned before you have to use TRY-CATCH blocks to prevent


// getting dumps while trying to access lines you want.
Loop syntax in ABAP 7.4 and before ABAP 7.4?
Before 7.40 syntax:
DATA: gt_citys TYPE ty_citys,
       gs_ship  TYPE ty_ship,
       gs_city  TYPE ort01.
LOOP AT gt_ships INTO gs_ship.
  gs_city =  gs_ship–city.
  APPEND gs_city TO gt_citys.
ENDLOOP.

WITH 7.4 Syntax:

DATA(gt_citys) = VALUE ty_citys( FOR ls_ship IN gt_ships ( ls_ship–city ) ).

How to handle exception for READ Statement in ABAP7.4 if not record


found or sy-subrc NE 0.

SELECT *
FROM MARA
INTO TABLE @DATA(IT_MARA)
UP TO 50 ROWS
WHERE MTART = 'FERT'.

TRY .
DATA(wa_mara) = it_mara[ matnr = '0001' mtart = 'FERT' ].
CATCH CX_SY_ITAB_LINE_NOT_FOUND.
WRITE:/ 'Error Reading Record'.
ENDTRY.
WRITE:/ wa_mara-matnr.

Note: As we know if ABAP 7.4, new read syntax we can not use sy-
subrc, so in that case we use exception class CATCH
CX_SY_ITAB_LINE_NOT_FOUND. In TRY-ENDTRY block , if not
record found.
Append syntax in ABAP 7.4
TYPES:
BEGIN OF ty_data,
kunnr TYPE kunnr,
name1 TYPE name1,
ort01 TYPE ort01,
land1 TYPE land1,
END OF ty_data.
TYPES: tt_data TYPE STANDARD TABLE OF ty_data
WITH DEFAULT KEY.
* classical : Before ABAP 7.4
DATA: itab_multi_c TYPE tt_data.
FIELD-SYMBOLS: <fs> LIKE LINE OF itab_multi_c.
APPEND INITIAL LINE TO itab_multi_c ASSIGNING <fs>.
<fs>-kunnr = '123'.
<fs>-name1 = 'ABCD'.
<fs>-ort01 = 'LV'.
<fs>-land1 = 'NV'.
APPEND INITIAL LINE TO itab_multi_c ASSIGNING <fs>.
<fs>-kunnr = '456'.
<fs>-name1 = 'XYZ'.
<fs>-ort01 = 'LA'.
<fs>-land1 = 'CA'.
 
* With ABAP 7.4
DATA(itab_multi_comp) =
VALUE tt_data( ( kunnr = '123' name1 = 'ABCD' ort01 = 'LV' land1 = 'NV' )
( kunnr = '456' name1 = 'XYZ' ort01 = 'LA' land1 = 'CA' )
 

Filter syntax in ABAP 7.4


Example using FILTER ABAP 7.4
In the below example we will using FILTER to filter(include filter) IT_MARA internal table
for all 'FERT' records.

TYPES: BEGIN OF ty_filter,


MTART TYPE MARA-MTART,
END OF ty_filter.
DATA: IT_FILTER TYPE HASHED TABLE OF ty_filter WITH UNIQUE KEY MTART .
***INitialize filter Table
it_filter = VALUE #( ( MTART = 'FERT' ) ).

SELECT MATNR, MTART, MATKL


FROM MARA
INTO TABLE @DATA(it_mara)
UP TO 1000 ROWS .
DATA(it_FERT) = FILTER #( it_mara in it_filter WHERE mtart = mtart ).

LOOP AT it_fert INTO DATA(wa_fert).

WRITE:/ wa_fert-matnr, wa_fert-mtart.

ENDLOOP.

Which table store Output type name ?


How secondary access fast data?
How to select multiple record in alv report output

Q: why we pass value in RFC using Pass by Value only ?


Ans : Whenever we are using RFC enabled FM's we should use pass by value only. because RFC
may be used by other different systems. if we pass by reference that system may have that pass by
value so that system gets confuse to which value have to take. so that why's we should pass by
value only.
If the call is from outside SAP, then Pass by Reference is not possible. Hence passing by value is
mandatory.

Question 3:What is the difference between SAPSCRIPT and SMARTFORM? 


SAPSCRIPT SMARTFORM
SAPSCRIPT is client dependent. SMARTFORM is client independent.
SAPSCRIPT does not generate any Function SMARTFORM generates a Function Module when
module. activated.
Main Window is must. You can create a SMARTFORM without a Main
Window.
SAPSCRIPT can be converted to SMARTFORMS. SMARTFORMS cannot be converted to SCRIPT.
Use Program SF_MIGRATE.
Only one Page format is possible Multiple page formats are possible.
Such thing is not possible in SCRIPT. You can create multiple copies of a SMARTFORM
using the Copies Window.
PROTECT … ENDPROTECT command is used for The Protect Checkbox can be ticked for Page
Page protection. Protection.

The way SMARTFORM is developed and the way in which SCRIPT is developed is entirely different. Not
listing down those here. That would be too much. 

Question : What is the difference between macro and subroutine?

Macro Subroutine
Macro can be called only in the program where it Subroutine can be called from other
is defined.
programs also. To call subroutine we
use statement : PERFORM <f_select_data>
IN PROGRAM <program_b>. here f_select_data
is the subroutine name and program_b is
the program name in which we are calling
subroutine.

Macro can have maximum 9 parameters. Can have any number of parameters.
Macro can be called only after its definition. This is not true for Subroutine.
A macro is defined inside: Subroutine is defined inside:
DEFINE … FORM …..
…. …..
END-OF-DEFINITION. ENDFORM.
Macro is used when same thing is to be done in a Subroutine is used for modularization.
program a number of times.

Question 7: What is the difference between SAP memory and ABAP memory?

SAP Memory ABAP Memory


When you are using the SET/GET Parameter ID When you are using the EXPORT IMPORT
command, you are using the SAP Memory. Statements, you are using the ABAP Memory.
SAP Memory is User Specific. ABAP Memory is User and Transaction Specific.
What does this mean? The data stored in SAP What does this mean? The data stored in ABAP
memory can be accessed via any session from a memory can be accessed only in one session. If
terminal. you are creating another session, you cannot use
ABAP memory.
Question 9: What is the difference between SY-INDEX and SY-TABIX?
Remember it this way  TABIX = Table.
So when you are looping over an internal table, you use SY-TABIX.
When you use DO … ENDDO / WHILE for looping, there is no table involved.
So you use SY-INDEX.

For READ statement, SY-INDEX is used.

Sy-tabix: Sy-tabix return current loop pass. For example a loop trigger 10 times then sy-tabix will return
value from 1 to 10. it is used in internal table loops. it gets the no. of records in the internal table. But sy-
index always return value as “0 “ inside loop end loop . Check below program for your reference.

TABLES: pa0002.

data: itab type TABLE OF pa0002,
      wa type pa0002.

select pernr nachn name2 from pa0002
      into CORRESPONDING FIELDS OF TABLE itab UP TO 10 ROWS ..
  loop at itab into wa.
    write: / wa-pernr, wa-nachn, wa-name2.
    write:  sy-index.
    write: sy-tabix.
    endloop.

Pernr Name Sy-index Sy-tabix

Sy-index: Inside do enddo ,sy-index return value of loop pass but sy-tabix always return value 1 inside
do enddo. In below example sy-index return value 1 to 5 and sy-tabix returns value 1.

REPORT  ZINDEX_TABIX.

do 5 times.
  if sy-index = 2.
    CONTINUE.
endif.
    write /: sy-index.
    WRITE : sy-tabix.
  ENDDO.

Output:
Sy-index Sy-tabix
Note: In case of loop endloop sy-tabix will return current loop pass value
but sy-index will return value as 0 for loop pass. But in case of do enddo sy-
tabix always return value as 1 but sy-index return value of current loop pass.

Question 10: What is the difference between VIEW and a TABLE?

A table physically stores data.


A view does not store any data on its own. It can contain data from multiple tables and it just
accesses/reads data from those tables.

Question 11: What is the difference between Customizing and Workbench request?

A workbench request is client independent whereas a Customizing request is client dependent.


Changes to development objects such as Reports, Function Modules, Data Dictionary objects etc. fall
under Workbench requests.

Changes in SPRO / IMG that define system behavior fall under customizing requests.
An example would be ‘defining number ranges’ in SPRO.

In short, generally a developer would end up creating a Workbench request and a Functional Consultant
would create a Customizing request.

Question 12: What is the difference between PASS BY VALUE and PASS BY REFERENCE?
These concepts are generally used for Function modules or Subroutines etc. and their meaning can be
taken literally.

Say we are passing a variable lv_var:


CALL FUNCTION 'DEMO_FM'
   EXPORTING
     VAR  = lv_var.

When we PASS lv_var by VALUE , the actual value of lv_var is copied into VAR.
When we PASS lv_var by REFERENCE , the reference or the memory address of lv_var is passed to the
Function module. So VAR and lv_var will refer to the same memory address and have the same value. 

Question 13: What is the difference between Master data and Transaction data?
Master data is data that doesn’t change often and is always needed in the same way by business.
Ex: One time activities like creating Company Codes, Materials, Vendors, Customers etc.

Transaction data keeps on changing and deals with day to day activities carried out in business.
Transactions done by or with Customers, Vendors, and Materials etc. generate Transaction Data. So data
related to Sales, Purchases, Deliveries, Invoices etc. represent transaction data

Some important transactions here for Master Data:


Material: MM01, MM02, MM03
Vendor: XK01 , XK02 , XK03
Customer: XD01 , XD02 , XD03

Some Important transactions for Transaction data:


Purchase Order: ME21n , ME22n , ME23n
Sales Order: VA01 , VA02 , VA03
Goods Receipt: MIGO
Invoices: MIRO

Question 16: Can you describe the events in ABAP?

LOAD-OF-PROGRAM:
INITIALIZATION: If you want to initialize some values before selection screen is called
AT SELECTION SCREEN OUTPUT: PBO for Selection Screen
AT SELECTION SCREEN: PAI for Selection Screen
START-OF-SELECTION
END-OF-SELECTION
TOP-OF-PAGE
END-OF-PAGE

AT USER-COMMAND: When user click on say buttons in application toolbar. SY-UCOMM


AT LINE SELECTION: Double click by user on basic list. SY-LISEL
AT PF##: When User Presses any of the Function Keys
TOP-OF-PAGE DURING LINE SELECTION
Question 17:

What events do you know in Module Pool Programming?


PBO: you know this . If not you should know this . That's basic.
PAI: You know this. If not you should know this . That's basic.
POV: Process on Value request … i.e. when you press F4.
POH: Process on help request … i.e. when you press F1.

Question 18: Can you show multiple ALVs on a Single Screen?


Yes, there are multiple ways of doing this:
·         If you are using OOALV, you can create multiple custom containers  
   (cl_gui_custom_container) & put an ALV control (cl_gui_alv_grid) in each of those.
·         You can even use a Splitter container control and place multiple ALVs in each of
    the split container.
·         If you are using Normal ALV, You can use the following FMS:
1.      REUSE_ALV_BLOCK_LIST_INIT
2.      REUSE_ALV_BLOCK_LIST_APPEND
3.      REUSE_ALV_BLOCK_LIST_DISPLAY

Question 19: A system has two clients 100 and 500 on the same application server. If you make changes
to a SAPSCRIPT on client 100, will the changes be available in client 500?

No. SAPSCRIPT is client dependent. You will have to transport changes from client 100 to client 500.
However, for SMARTFORMS, Changes will be made both for client 100 and client 500.

Question 20: There are 1000’s of IDOCs in your system and say you no longer need some of them? How
will you get rid of those IDOCs?

One way is to archive the IDOCs using transaction SARA.


But what the interviewer was expecting was ‘How do you change IDoc Status’?
There are different ways of doing this:

A) Use FM IDOC_STATUS_WRITE_TO_DATABASE

B) USE FMs:
     EDI_DOCUMENT_OPEN_FOR_PROCESS and
     EDI_DOCUMENT_CLOSE_PROCESS

Question 21: What is the difference between CHAIN … ENDCHAIN and FIELD commands in Module
Pool?

If you want to validate a single field in Module Pool, you use the FIELD Command.
On error, this single filed is kept open for input.

If you however want to validate multiple fields, you can use the CHAIN … ENDCHAIN command. You
specify multiple fields between CHAIN and ENDCHAIN.
On error, all fields between CHAIN …… ENDCHAIN are kept open for input.

Question 22: What are the types of Function Modules? What is an UPDATE function module?
There are three types of Function Modules: Normal , RFC , UPDATE.

The aim of the Update function module is either to COMMIT all changes to database at once or to
ROLLBACK all the changes. By definition, an update function module is used to bundle all the updates in
your system in one LUW (logical unit of work).

This FM is called whenever COMMIT WORK statement is encountered in the calling program and the
way you call it is CALL FUNCTION XXX IN UPDATE TASK. 

Have a look at FM EDI_DOCUMENT_CLOSE_PROCESS_UPD and do a where used.


This FM is used as Update FM in case you make changes to IDoc contents/status via your program.

Question 23: How is the table sorted when you do not specify field name and Ascending or
Descending? On what criteria will the table be sorted? Do internal table have keys?

Yes, internal table have keys.


The default key is made up of the non-numeric fields of the table line in the order in which they occur.

Q: How many secondary Index can be created on a table ?

Ans : We can create maximum 9 secondary index.

Question 24: Explain what is a foreign key relationship? Explain this with the help of an example.
Let’s discuss about tables EKKO (PO header) and EKPO (PO line item).
Can you have an entry in table EKPO without having an entry in table EKKO?
In other words can you have PO line items without the PO header?

How does this happen? The answer is foreign key relationship.


So foreign keys come into picture when you define relationship between two tables.

  Foreign keys are defined at field level.


Check the foreign key relation for field EBELN of table EKPO.
The check table is EKKO. This just means that whenever an entry is made in EKPO, it is checked whether
the entered value for EBELN already exists in EKKO. If not, entry cannot be made to EKPO table.
 
Question 25 : What is the difference between a value table and a check table?

Check table is maintained when you define foreign key relationships. Check Table is defined at field
level.
For Check table, read question above.
Value table is defined and maintained at a domain level.
At a domain level, you can mention allowed values in the form of:
1) Single values
2) Ranges
3) Value table For example, have a look at domain SHKZG. Only allowed values are S and H for
Debit/Credit indicator. wherever you use this domain, the system will force you to use only these two
values: S and H.

Another example is domain MATNR. For this domain the value table is MARA.
So whenever , you use this domain the system will force you to use values for MATNR in table MARA.

Question 26: How do you find BAPI?

Approach1:
You can go to Transaction BAPI and then search for your desired object.
Say you want to find a BAPI for creating users in the system, in such case you can search for the ‘User’
and find the relevant BAPIs.

Approach2:
Another way is to find a Business Object. Say you want to find a BAPI for creating Material in SAP and
you know the Business Object for Material is BUS1001006. You can go to Transaction SWO1 and enter
the BO BUS1001006 in the BOR. Then have a look at the methods for this BO.

What is the length of function code at user-command?

Ans: Each menu function, push button, or function key has an associated function code of length FOUR
(for example, FREE), which is available in the system field SY-UCOMM after the user action.

Difference between .Append and. Include ?

Ans: Include structure allows to add one or more structure into structure or table. Also placed
positioning anywhere. Upto 6 include structure can be used in a table.
Append structure can be placed only at the end of a structure or table which also stops further insertion
of fields. Only one append structure can be used.

Performance technique in abap reports ?

Ans: 1. The sequence of fields must be same as per database table


2. During writing select query write all fields in sequence as per database table.
3. Never write select statements inside loop….endloop.
4. Use st05 SQL trace, se30 run time analysis, code inspector, SLIN (Extended Program Check),etc.
5. Use select single * statement instead of select *
6. Always use primary key
7. Use binary search but before using binary search sort that table in ascending order.
How the values will be passed to RFC Function module Pass by Value or Pass by reference?

Ans: Always Pass by Value.


RFC is Remote Function call so it can’t access the values with Pass by reference.

To how many tables can an append structure be assigned?

Ans: Only One. Append structure can not be reusable, we can not use it for multiple tables.

When top of the page event is triggered?


Ans: After executing first write statement in start-of-selection event.

How to execute ALV in background?

User Execution Steps


1. Run the original transaction and execute the report in background after entering the parameters
After this, the user can go to another transaction or even log off from SAP if needed and come back
to the report selection screen at a later point of time.

2. One the report selection screen, click on the ‘Disp. stored job’ button

3. If the status is green, then click on the execute button


4. This will display the original ALV.

The user can then execute any of the foreground ALV functions such as custom buttons / hotspots.

You can Run alv in Background but make sure it is alv list, not alv Grid FM. if you are alv list not
problem , but if you are using alv grid then you can code like this.
if sy-batch = ' '.
call 'REUSE_ALV_GRID_DISPLAY'.

else.
call 'REUSE_ALV_LIST_DISPLAY'.

endif.

if you are using OO alv then write this code..


CALL METHOD cl_gui_alv_grid=>offline
RECEIVING e_offline = off.
IF off IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
ENDIF.

How to Create authorization object?


Requirement – We have a few Z-tables in our system that consists of confidential data, which cannot be
accessed by all users. Only authorized persons can have access to the data. So, in case these tables are
being used in any program, for display/write purpose, that program would be executed only by Authorized
users. Please make sure to disable Table Entries, while creating tables, and not to create any Table
Maintenance Generator also. Only this program would be used to perform read/write operations on the
table.  

Resolution – We’ll see, step by step, what all needs to be done in order to fulfill the mentioned
requirement.  

Giving authorization to access (read / write) into z-tables  

Steps:  

1.       To begin with Authorization Object, we’ll enter the Tcode: SU21. Here, we will create the following, in
the order shown:  

                     I.      Object Class

                   II.      Authorization Object  
  

2.       On clicking the Object Class (as shown in the above screen shot), you’ll see the window shown
below. Enter the Object class name, description & click on SAVE. You can also use available objects,
to create your Authorization Object. Like in scase of HR module, you can make use of Object Class
“HR”, then you need not create
one. 

3.       Once you create Object class (E.g. Test), you’ll see a folder with that name in the list. Now your
object class is ready. We will need this Object class to encapsulate the Authorization object that we
will be creating. Click on the Object created, and then click on “Create - Authorization Object” (shown
in the figure step 1). On clicking, you’ll see the below shown

screen. 

Give respective field name, in our case, PERNR (Employee Number), as shown in the above
diagram. We will be keeping a check on the employee number, and see if the employee has
authorization to access the report (made to view z-tables) or not.  

4.       Now, we need to create a Role, inside which we will attach our Authorization Object. Enter
Transaction code: PFCG to create a role.  
 

Select the “Authorizations” tab. And Click on the icon next to “profile name”, as shown in the figure
above. On the click of that icon, the system will generate a Profile name and a description for the
same.  

5.       Click on the “Change authorization data” as shown in the figure below:  


 

You’ll see a new screen with the Role Name on top left. Here you will have to add your ‘Authorization
Object’ that was created in SU21.

6.Click on the “Manually” button shown in the toolbar, to add the Authorization object, as shown in the
figure below. Here you can add your Authorization object in the list and press enter.  

  
7. Now you need to add values (Employee numbers) in your object, for those who would be given
authorization. In our case, we will put a “*” symbol (to allow the system to provide access to any
employee, which is Assigned this role).

  

8. Press Save and then Generate the profile by clicking on ‘generate’ icon.  
 

9. Finally you come out of the screen pressing back button. And you will see the Authorizations tab
with a Green symbol, meaning, Authorization object has been assigned and the role can be
used.  

 
10. After these steps, if you want to give authorizations to say Employee No.: 96. Go to
Transaction SU01, click on the Roles tab and assign our role name, in our case : test_role.  

This way, you can assign this role to all those users, who are supposed to be authorized to access
the report (for data entry in the table).  

11. Finally, in the main program, which has been created, we need to write a small code, as shown
below, which will decide if that employee is authorized or not:  

REPORT  ZCHECK_AUTH.

DATA : L_PERNR TYPE PERNR_D.
SELECT SINGLE PERNR INTO L_PERNR FROM PA0105
  WHERE UNAME EQ SY-UNAME AND USRTY EQ '0001' AND
  BEGDA LE SY-DATUM AND ENDDA GE SY-DATUM.

AUTHORITY-CHECK OBJECT 'Z_OBJECT1'
         ID 'PERNR' FIELD L_PERNR.

IF sy-subrc <> 0.
    MESSAGE 'No authorization' TYPE 'E'.
ELSE.
**** Here you can have the Query to view the table or perform any
**** action related to the Z-tables

    MESSAGE 'Congrats! You are authorized' TYPE 'I'.
ENDIF.  
If the user passes this authorization check, the return code SY-SUBRC is set to 0. Hence, users who are
not assigned the Role, if they try to access this report; they’ll not be able to do the same.  

This way, you can provide authorizations on any Z- objects.

You might also like