• No results found

Authorization Objects are used to manipulate the current user’s privileges for specific data selection and activities from within a program.

In document SAP ABAP Interview Questions (Page 35-43)

Ntt data:

Ans 2. Authorization Objects are used to manipulate the current user’s privileges for specific data selection and activities from within a program.

We could always create our own authorization objects and implement it in our own abap programs. As an example, we will create our own authorization field similar to TCD used in S_TCODE Authorization object.

Steps to create authorization field 1. Go to transaction code SU20

2. Click the create new button on the application toolbar.

3. Enter “ZTCODE” in the Field Name and “TCODE” in the Data Element, then hit Enter.

4. Click the save button on the system toolbar.

Next step is to create the authorization class (see #1 in figure 1) and authorization object (see #2 in figure 1).

Steps to create authorization class 1. Go to transaction code SU21

2. Click on the Create button’s drop down icon and select “Object Class”. 3. Enter “ZTRN” on the Object Class field.

4. Give it a description and save it.

Steps to create authorization object

1. Again in SU21, in the list of authorization class (folder icon), click the one that we’ve created(ZTRN).

2. Click on the Create buttodrop down, this time selecting “Authorization Object”.

3. Enter “Z_TCODE” on the Object field and give it a description.

4. On the authorization fields section, enter ACTVT and ZTCODE. ACTVT is used to set and limit the activity of the user, while the ZTCODE is the

a list of tcodes.

5. On the Further Authorization Object Settings, click on “Permitted

activities” button. Here we will select the specific activities that we want to be available for our authorization object.

6. As an example, we will select 01(Create), 02(Change), and 03(Display). 7. Save and Exit.

Now we’re done creating our own authorization object, let us now use and assign it to a user.

Steps to create a role(see figure 2) 1. Go to transaction code PFCG.

2. Enter “ZAUTHTEST” on Role field and click the “Single Role” button.

3. Now give it a description, click the save button and click the Authorization tab.

4. Click the “Change Authorization Data” button inside the authorization tab. 5. Then click the “Manually” button on the application toolbar and type in the name of the authorization object that we’ve created earlier(”Z_TCODE”) and press enter.

6. Expand all the nodes, double click on the input field of the Activity and select activity 01 and 02.

7. Enter the tcode of our own abap program in ZTCODE field, in our example I used “ZCOMM” .

8. And also don’t forget to add the S_TCODE authorization object and enter ZCOMM on it’s field.

9. Now Click on the Generate button in the application toolbar and press enter on the pop-up screen.

10. press the back button and assign a specific user on the user tab and click User Comparison button.

11. Now create another role by repeating steps 1 to 9 but this time select activity 03 on step 6.

12. Then assign this 2nd role to another user.

(Figure 2)

Now let’s implement this authorization in our ABAP program. Let say we have a dialog program (ZCOMM) wherein we have a button on the screen that when clicked, the user will go to the Create/Edit screen(1000) if he’s

authorized. On the other hand, he will go to display only screen (2000) if he’s not authorized. To do that, simply add the code below on your program.

AUTHORITY-CHECK OBJECT ‘Z_TCODE’ “authorization object that we’ve created

ID ‘ACTVT’ FIELD ‘01′ “Activity = 01, authorized to create ID ‘ZTCODE’ FIELD ‘ZCOMM’. “tcodes that we wants to check for

authorization IF sy-subrc EQ 0.

CALL SCREEN 1000. “The user is authorized to create ELSE.

CALL SCREEN 2000. “User is not authorized to create (Display only) ENDIF.

2. How to run a report? 3. What is authorization? 4. Validation in module pool?

5. Chain and end chain in module pool?

If the validation has to be done for more than one field those fields are included between chain and end chain.

Ex

In PAI if you want to validate group of fields put in chain and End chain statement.

You can declare fields in the chain endchain.

CHAIN. FIELD chk_ABC. FIELD chk_DEF. FIELD chk_GHI. FIELD CHK-JKL. MODULE CHK_screenfields. ENDCHAIN.

MODULE CHK_screenfields INPUT. CLEAR okcode.

okcode = sy-ucomm. CASE okcode.

WHEN 'ENTER' OR 'EXECUTE'.

IF chk_ABC IS INITIAL AND chk_DEF IS INITIAL AND CHK_GHI IS INITIAL .

MESSAGE e000(zo_spa) WITH text-017. " Enter VALUES' ELSE.

... ENDIF. ENDIF.

ENDMODULE. " modify_screenfields INPUT

6. How to know the errors using bapi while uploading data? Ans.

A BAPI should be able to record and classify all possible errors that may occur a function Module BAPI_MESSAGE_GETDETAIL is used to handle the Error Messages.

You have to create a parameter named Return for every BAPI. This parameter returns exception messages or success messages to the calling program.

BAPIs themselves must not trigger any messages (such as MESSAGE xnnn) in the coding. In particular they must not generate terminations or display dialog boxes. Instead, all messages must be intercepted internally and reported back to the calling program in the Return parameter. Otherwise the BAPI will not be processed correctly and control may not be given back to the calling program.

All error messages or indeed any message that may be returned by the BAPI, must be defined in message table (Tools ® ABAP Workbench ® Development ® Programming environment ® Messages) and described in the documentation for the return parameter. This also applies to the most important or most likely error messages generated by other programs that can be indirectly passed via the BAPI to the application program.

You must not use exceptions in BAPI interfaces.

When a termination message (message type A) is triggered, a database rollback is executed in the standard programming model, that is, all tasks performed since the last COMMIT WORK are canceled. When you program BAPIs, we recommend that you also execute a database rollback in the return parameter for termination messages. You must describe this process in the documentation for the Return parameter. For messages of type E (error), the calling program performs the error handling.

Application developers are provided with two service BAPIs to diagnose and process error messages from BAPI calls:

BapiService.MessageGetDetail () displays the short and long texts of BAPI error messages.

BapiService.ApplicationLogGetDetail (), with which information in application logs can be displayed.

Features

The export parameter Return can be implemented as follows:

As a structure, whereby it must be defined in the function module as an export parameter, as well as in the method in the BOR.

As a table, whereby it must be defined in the function module as a table parameter, as well as in the method in the BOR as an export parameter. Before filling the Return parameter you should either initialize the structure with CLEAR or the table with REFRESH and CLEAR.

If the return parameter is not set or is set to an initial value this means that no error has occurred.

The Return parameter may be based on the following reference structures: BAPIRET2

You must use this reference structure when developing new BAPIS. BAPIRET1, BAPIRETURN

These reference structures are still partly used in old BAPIs. Both structures must be filled in the logon language.

7. Diff b/w sorted and hashed internal tables?

Ans. 1.Standard Internal Tables: These tables have a linear index and can be accessed using the index or the key. The response time is in linear

relationship with number of table entries.

These tables are useful when user wants to address individual table entries using the index.

2. Sorted Internal Tables: These tables also have an index and the key. But, the response time is in logarithmic relationship with number of table entries,

since it uses binary search algorithm instead of linear search. These tables are useful when user wants the table to be sorted

While additional entries have to be added.

3. Hashed Internal Tables: These tables have no index, but have the key. The response time is constant irrespective of number of table entries, since it uses a Hash algorithm. These tables are useful when user wants to access the entries with key only.

8. How to use NACE transaction (configuration)?

Ans. NACE is the t. Code to configure the form and driver program.

Example: if we create a form and driver program related to BILLING (invoice) or if

we want to identify the Form and program name of an application (Purchase order, sales order, billing, delivery note etc).

Goto NACE t.code Select Billing (V3)

|

Click on Output types

|

Now scroll down and identify the required output type (Ex: invoice) and select it

|

Now double click on ‘Processing routines’

|

Now click on Change icon to include our form name and program name

| Save

9. What are the methods to debug the scripts? Ans. Two ways to debug sap script.

first way is go to SE 71 and from menu bar select Utilities- >activate debugger .then go to SE38 execute the print program ,it automatically goes to debugging mode.

The other way is, run the program RSTXDBUG in se38. Execute it. A message will show that debugger is activated .now open the print program in se38.u will notice that the print program is automatically diverted to debugging mode.

10. Procedure of uploading data using bapi?

11. Difference b/w elementary search help and collective search help?

Ans. 1) Elementary search helps describe a search path. The elementary search help must define where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help). 2) Collective search helps combine several elementary search helps. Collective search help thus can offer

Several alternative search paths.

3) An elementary search help defines the standard flow of an input help.

4) A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with collective search help. 5) A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field.

6) Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in collective search help, they are expanded to the level of the elementary search helps when the input help is called.

12. Diff b/w function module and remote function module(RFC’S)? 13. ENHANCEMENT FRAME WORK?

Ans. The Enhancement Framework enables you to add functionality to

standard SAP software without actually changing the original repository objects and to organize these enhancements as effectively as possible.

The basic idea of the Enhancement Framework is to make modification-free

enhancements of development objects such as programs, function modules, global classes, and Web Dynpro components. It is the new state-of-the-art technology that SAP recommends to enhance and change SAP programs. These technologies and the new kernel-based BAdIs are now integrated in one framework that has the following features:

● Enhancements of existing development objects on different levels - for example, in an industry solution, in the IT department of the customer, and in a customer's company.

● Better upgrade support

● Switching of enhancements with the Switch Framework

● Support for grouping enhancements and appropriate tool support for documentation.

An enhancement project needs even more planning than a normal

development project because it combines the customer code with the code of the underlying application. Enhancements are changes at a very low technical level and should be performed very carefully so that they do not violate the logic of the program they enhance. It is highly recommended to set up a process that defines who is allowed to design and implement enhancements.

Scope and Limitations

The new Enhancement Framework is intended to integrate existing enhancement and modification concepts and addresses recent developments such as Web

Dynpro. The classic technology for appends and includes cooperates perfectly with the Enhancement Framework but is not yet integrated in it. If you want to be able to enhance all layers of an application, the classic append technology is still

necessary.

Integration

The main tool for performing enhancements is the Enhancement Builder, which is integrated in the ABAP Workbench.

The enhancements can be switched using the Switch Framework. An

enhancement takes effect when the package in which the above enhancement components are defined is assigned to a switch of the Switch Framework and this switch is not deactivated.

14. What is the main difference between Enhancements and BADI? Ans. Main difference Between: Enhancements is Client Dependent BADI is client in- dependent.

Classic enhancements can have only one Implementation. Whereas BADI can have Multiple Implementations, Enhancement means to modify the standard transaction based on the user requirements. But BADI is one part of enhancement. It’s full and full oops oriented concept.

ACCENTURE

1.HOW TO EDIT THE DATABASE TABLE?

In document SAP ABAP Interview Questions (Page 35-43)