Modularization Techniques-Questions and Answers - SAP ABAP


MODULARIZATION Questions and Answers

1. What are Modularization and its benefits?
If the program contains the same or similar blocks of statements or it is required to process the same function several times, we can avoid redundancy by using modularization techniques. By modularizing the ABAP/4 programs we make them easy to read and improve their structure. Modularized programs are also easier to maintain and to update.

2. How can we create callable modules of program code within one ABAP/4 Program?
A. By defining macros.
B. By creating include programs in the library.

3. What are subroutines?
Subroutines are program modules which can be called from other ABAP/4 programs or within the same program.

4. What are the types of Subroutines?
A. Internal Subroutines: The source code of the internal subroutines will be in the
same ABAP/4 program as the calling procedure (internal call).
B. External Subroutines: The source code of the external subroutines will be in an
ABAP/4 program other than the calling procedure.

5. What are the different types of parameters?
Formal parameters: Parameters which are defined during the definition of subroutine/FM with the FORM statement.
Actual parameters: Parameters which are specified during the call of a subroutine/FM with the PERFORM statement.

6. How can one distinguish between different kinds of parameters?
A. Input parameters are used to pass data to subroutines.
B. Output parameters are used to pass data from subroutines.

7. What are the different methods of passing data?
A. Calling by reference: During a subroutine call, only the address of the actual
parameter is transferred to the formal parameters. The formal parameter has no memory of its own, and we work with the field of the calling program within the subroutine. If we change the formal parameter, the field contents in the calling program also change.
B. Calling by value: During a subroutine call, the formal parameters are created as
copies of the actual parameters. The formal parameters have memory of their own. Changes to the formal parameters have no effect on the actual parameters.
C. Calling by value and result: During a subroutine call, the formal parameters are
created as copies of the actual parameters. The formal parameters have their own memory space. Changes to the formal parameters are copied to the actual parameters at the end of the subroutine.
The method by which INTERNAL TABLES are passed is By Reference.

8. What is the difference between the function module and a normal ABAP/4 subroutine?
-You CAN NOT CALL subroutiune out of SAP system.Means subroutines are used only in SAP R3 system.But as we seen earlier FM can be called by any system having valid RFC connection.
So suppose the requirement is to transfer data from SAP to NON SAP sytem then you have only one option to use FM as you can’t use Subroutine there.
-In contrast to normal subroutines function modules have uniquely defined interface for defining parameters.
-Sub routines do not return values/exceptions whereas FM does.
-Sub routines cannot be tested independently where as we can execute FM through SE37 independently.. Declaring data as common parts is not possible for function modules. Function modules are stored in a central library. (Function Group)

9. What is a function group?
-A function group is a collection of logically related modules that share global data with each other. All the modules in the group are included in the same main program. When an ABAP/4 program contains a CALL FUNCTION statement, the system loads the entire function group in with the program code at runtime. Every function module belongs to a function group.
- Each function group is identified by a four-character identifier called a Function Group ID.

10. What is the difference between internal tables and Extract datasets?
A. The lines of an internal table always have the same structure. By using extract
datasets, you can handle groups of data with different structure and get statistical figures from the grouped data.
B. You have to define the structure of the internal table at the beginning. You need
not define the structure of the extract dataset.
C. In contrast to internal tables, the system partly compresses extract datasets
when storing them. This reduces the storage space required.
D. Internal tables require special work area for interface whereas extract datasets
do not need a special work area for interface.

11. Does every ABAP/4 have a Modular Structure?
Yes. It is made up of processing blocks.

12. Name the ABAP/4 Modularization techniques.
-Functions Modules.
-Subroutines.
-Includes.
-Micros.
-Methods.

13. What is the Program attribute type for Function Group?
Program Type is " F " (Note: We can see this at Attributes of Main program of Function group)

14. Is it possible to pass data to and from include programs explicitly?
No. If it is required to pass data to and from modules it is required to use subroutines or Function modules.

15. It is NOT possible to create an ABAP/4 program, which contains only Subroutines (T/F).
-False.

16. A subroutine can contain Nested Form and End Form blocks. (T/F)
-False.

17. How to pass the data between calling programs and the subroutines/FM?
Using Parameters.

18. How can an internal table with Header line and one without header line be distinguished when passed to a subroutine?
-Itab [] is used in the form and end form if
the internal table is passed with a header line.

19. What should be declared explicitly in the corresponding ABAP/4 Statements to access
internal tables without header lines & why?
-Work Area (As we need to define IT & WA differently in Explicite option).
Reason- This is required as the Work Area is the interface for transferring data to and from the Body of the Internal Table.

20. A subroutine can be terminated unconditionally using EXIT. (T/F)
-True.
-A subroutine can be terminated upon a condition using CHECK Statement.
-Function Modules are also external Subroutines (T/F).

 
21. What is the Disadvantage of a Call by reference?

-During a call by reference damage or loss of data is not restricted to the subroutine, but will instantly lead to changes to the original data objects.

22. A function module can be called from a transaction screen outside an ABAP/4 program (T/F).
-True. We can it by SE37.

23. What is an update task?
-It is an SAP provided procedure for updating a DATABASE.

24. What happens if a function module runs in an update task?
The system performs the module processing asynchronously. Instead of carrying out the call immediately, the system waits until the next database update is triggered with the ‘COMMIT WORK’ command. The function modules are created and stored in the Function Library. (Function Group)

25. When a function module is activated syntax checking is performed automatically. (Y/N)
-True.

26. What is the use of the RAISING exception?
-The raising exception determines whether the calling program will handle the exception itself or leave the exception to the system.

27. It is possible to assign a local data object defined in a subroutine or function
module to a field group (T/F).
-False.

28. What is the difference between field-group header and other field groups?
-The header field group is a special field group for the sort criteria. The system automatically prefixes any other field groups with the header field group.

29. Can a field occur in several field groups?
-Yes. But it leads to unnecessary data redundancy.

30. What does the INSERT & EXTRACT Statement in Extract datasets do?
-It defines the fields of a field group.
-The data is written to virtual memory by extract commands.

31. A field-groups statement or an insert statement reverses storage space and
transfers values (T/F).
-False.

32. While using Extract datasets it is required to have a special work area for interface (T/F).
-False.

33. The LOOP-ENDLOOP on Extract datasets can be used without any kind of errors (T/F).
-False. It causes runtime errors. The Maximum no of key fields that can be used in a header is 50.

34. While sorting field groups we CAN NOT use more than one key field (T/F).
-False. While sorting, if the main storage available is not enough, the system writes data
to an external help file. The SAP profile parameter, which determines this help file, is DIR_SORTTMP.

35. What is the difference between the Function module and External Subroutine?
-Internal Table work area is not shared between the function module and calling program whereas subroutine shared same work area.
-We can leave a function module using Raise statement whereas check, exit or stops are
used to leave a subroutine.
-Function module has special interface to define parameters whereas subroutine don’t
have.

36. How to create Function Module?
-We can create function modules by using function builder. The transaction code
for function builder is SE37.

37. Is it necessary to attach the function module to a function group?
Yes, every function module must be attached to a function group. That means
function group acts as a container. A single function group may contain one or
more function modules which are logically related.

38. How many types of function modules are there?
There are two types of function modules –
1) Normal
2) Remote (RFC) Function Module.

39. How RFC function module differs from normal function module?

RFC stands for remote function call. As the name itself reveals, this function
module can be called remotely by using RFC destination. Here remote means,
external system, it may be a SAP system or Non-SAP system like Java system.

40. What are the advantages of function modules?
As we discussed above, it is one of the modularization techniques which helps
code re-usability. We can handle exceptions using function modules.

41. How to know whether a given function module is normal or RFC function module?
1) Go to SE37.
2) Enter the name of the function module you are provided.
3) Click on DISPLAY
4) Choose Attributes tab
5) under this tab, you can see Processing Type block.
6) If remote-enabled module is checked, then it is RFC otherwise normal function
module.

42. How many types of RFCs are there?
There are five types of RFCs-
1) Synchronous RFC
2) Asynchronous RFC
3) Transactional RFC
4) Queued RFC
5) Parallel RFC

43. What are the components of the Function Module?
- Attributes.
-Importing Parameters.
-Exporting Parameters.
-Changing Parameters.
-Tables.
-Exceptions.
-Source Code.

44. What are the two includes that got created automatically whenever we create “Function module”.
-Whenever we create any FM SAP automatically creates “Function Pool” along with following two includes.
1. Lfm_nameTOP************* for Global Data declarations.
2. Lfm_nameUXX************* for Function module which has got created.

45. What are different “Processing Types” for the Functional Modules?
-Following are the various “Processing Types” for the FM.
1.       Normal Function Module
2.       Remote-Enabled Module
3.       Update Module

46) What are the differences between Subroutines and Function Modules?
                           Subroutines
                        Function modules 
1. These are local. We can access the 
     Subroutine within the server only.
1. These are global. We can access the
    function module with in server as well as
    Outside the server.
2. We can’t execute the subroutine independently
2. we can execute function module independently using the T-code SE37
 
3. Subroutines can’t handle the Exceptions.
3. Function module can handle the errors
    through Exceptions.

47)  What are the differences between Macro & subroutine?
                             Macro
                            Subroutine
1. Definition & calling in the same program.
1. Definition & calling may/may not in the same
    Program.
2. Definition should be the 1st & calling should be
    The next.
2. Calling should be the 1st & Definition should
     Be the next.
3.  Macros can take up to 9 inputs.
3. Subroutines can take any no of inputs.
 4. Macros cannot be debugged.
4. Sub-routines can be debugged at run time.

48) What is the use of modularization?
1) Improves readability. That means, easy to read.
2) Re-usability, the procedures can be used in other programs as well.
3) Encapsulation of data.
4) Reduces code redundancies, i.e. Avoids duplication of code.

49) Which are the components of function group?

1. A main program.
2. A top include.
3. A UXX include.

4. A function module includes. 

Comments

Post a Comment

Popular posts from this blog

SAP ABAP-Internal Table Operations and Example Program

HR ABAP Interview Questions and Answers

BDC (Batch Data Communication) - SAP ABAP