ABAP coding question asked during asked in sap labs for experienced

  1. given a series you need to find out whether its arthimetic geometric or fibonacci. if not any of these print ‘series not identiafiable’.

INPUT : input 5 number separated by ‘,’ and output which type of series it is.

for Fibonacci series always starts with 1.

example :-

INPUT OUTPUT
1,3,5,7,9 Arithmetic
2,4,8,16,32 Geometric
1,1,2,3,5 Fibonacci
1,4,6,7,9 Series not identifiable

Solution:-

*&———————————————————————*
*& Report  ZSERIES
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT ZSERIES.

PARAMETERS p_a TYPE string.
DATA lv1 TYPE string,
lv2 TYPE string,
lv3 TYPE string,
lv4 TYPE string,
lv5 TYPE string.
DATA lv1_int TYPE i,
lv2_int TYPE i,
lv3_int TYPE i,
lv4_int TYPE i,
lv5_int TYPE i,
flag1 TYPE i,
flag2 TYPE i,
flag3 TYPE i.

INITIALIZATION.
flag1 0.
flag2 0.
flag3 0.
START-OF-SELECTION.
SPLIT p_a at ‘,’ INTO lv1 lv2 lv3 lv4 lv5.
lv1_int lv1.
lv2_int lv2.
lv3_int lv3.
lv4_int lv4.
lv5_int lv5.

if lv2_int – lv1_int lv3_int – lv2_int AND lv4_int – lv3_int lv5_int – lv4_int ).
flag1 1.
ENDIF.
if lv2_int / lv1_int lv3_int / lv2_int AND lv4_int / lv3_int lv5_int / lv4_int ).
flag2 1.
ENDIF.
if lv1_int AND lv2_int AND lv3_int AND lv4_int AND lv5_int ).
flag3 1.
ENDIF.

IF flag1 1.
WRITE  /‘arithimetic’.
ELSEIF flag2 1.
WRITE :/‘geometric’.
ELSEIF flag3 1.
WRITE :/‘fibonacci’.
ELSEIF flag1 AND flag2 AND flag3 ).
WRITE :/‘not identifiable’.
ENDIF.

 

2. Three tables were given as below:-

ZEMPLOYEE

Employee_id employee_type
10001 C
10002 C
10003 C
10004 P
10005 C
10006 C
10007 P
10008 C

ZEMPLOYEE_current_DETAILS

Employee_id project current_city current_country first_name Last_name
10001 city_walk bang INDIA ROHIT PORECHA
10002 sky_city del INDIA MITESH TYREWALA
10003 sky_city mum INDIA VIPUL SCREWALA
10004 sky_city hyd INDIA SAURAV NUTWALA
10005 sky_city del INDIA JATIN KUMAR
10006 city_walk bang INDIA HARI BISWAS
10007 city_walk mum INDIA JAY SRIVASTAV
10008 city_walk kol INDIA SAHIL JHUNJHUNWALA

zemployee_permanent

Employee_id Reporting to home_city origin_country
10001 10004 new york USA
10002 10004 london ENGLAND
10003 10004 paris FRANCE
10005 10004 barcelona SPAIN
10006 10007 dubai UAE
10008 10007 beijing CHINA

There is a company called ABC which recruits contractors and send them to various locations around the globe to implement SAP

ZEMPLOYEE table contains the list of employees in the company ABC and whether they are a permanent employee ( type P ) or a contractual employee ( TYPE C )

ZEMPLOYEE_CURRENT_DETAILS table contains the employee details and the current project they are assigned to and their current location

zemployee_permanent table contains the manager details of the employees who work as contracters and their home city and home country details

Below are the Questions

  1. Define a class with a constructor and create a instance only when the employee is a permanent employee of the company ‘ABC’ otherwise raise a suitable exception
  2. Define a method which displays all the employees working under a manager ( Employee Type P ) with the below details

Employee_id, First_name. Last_name,Current_city, Project, Reporting_to and the   Origin_country

SAP INTERVIEW QUESTIONS BASIC

Why you want to join our company

“ ABC is a leading organisation in the industry and it’s a matter of proud to work with such an organisation. This is also a reason to work here but

What attracted me more is the job profile. It completely matches with my strengths and interest, which makes me feel that I can be 100℅ efficient in my job along with a good amount of learning”.

2. What is use of check table and value table in SAP ABAP

CHECK TABLE:

A foreign key links two tables T1 and T2 by assigning fields of table T1 to the primary key fields of table T2.

Table T2 is then known as the check table of the foreign key.

VALUE TABLE:

Sometimes when you define a domain, you already know that all fields that use the domain will need to be checked against a particular table. You can store this information in the domain definition by specifying a value table.

If you try to define a foreign key for a field that points to this domain, the value table of the domain is proposed as the check table for the foreign key.

2. Difference between open SQL and Native SQL ?

There are two types of SQL being used in SAP ABAP programming language. They are

  • Native SQL
  • Open SQL

Open SQL allows to access the database tables declared in the ABAP dictionary regardless of the database platform that the SAP R/3 system is using.

Native SQL allows to use database-specific SQL statements in a SAP ABAP program. This means that one can use database tables that are not administered by ABAP dictionary, and therefore integrate data that is not part of the SAP R/3 system.

Open SQL is not confined to any particular type of database while a Native SQL is confined to a particular type.

ABAP programs that uses only Open SQL statements will work in any R/3 system, regardless of the database system in use. Open SQL statements can only work with database tables that have been created in the ABAP dictionary.

3. Pooled table and cluster table in SAP ABAP ?

Tables in Data dictionary which has many to one relationship with an underlying database table is called Pooled table. In simple words, Pooled tables appear as many tables in ABAP dictionary, but the thing is they are stored as a single table in the underlying database.

Table clusters store data from several cluster tables based on the primary key fields that they have in common. Rows from the cluster tables are combined into a single row in the table cluster. The rows are combined based on the part of the primary key they have in common.

The biggest advantage of cluster table and pooled table is they reduce the number of database reads and thereby improve performance.

4. views in SAP ABAP

Database views implement an Inner Join whereas Projection View, Maintenance View and Help View implement an Outer Join.

5. Delivery Class manages the transport of table data when installing or upgrading in a client copy when transporting between customer systems.

6.Technical settings allow you to optimize the storage requirements and table access behavior of database tables.

Technical Setting comprises of the following components:

  • Data Class: Designates the table to an area in the physical database where similar tables are grouped.
  • Size Category: Identifies the amount of disk space that will be required to hold the data records for a table in the database.
  • Buffering: Determines whether table records will be accessed directly from the database server or from global memory.
  • Logging: Creates before and after images of changes to the table of contents. Logging must be activated by the profile when the system is started.

7.The data class signifies a physical area in an underlying database where the table is logically stored. Also it throws light on what kind of data will be stored in the table. Data class helps us to categorize the table on the basis of type of data stored.

There are three important data classes

  • APPL0 – Master data – Master data is data which is frequently read, but rarely updated.
  • APPL1 – Transaction data – Transaction data is data which is frequently updated.
  • APPL2 – Organizational and customizing data – Organizational und customizing data is data which is defined when the system is initialized and then rarely changed.

8. The data class signifies a physical area in an underlying database where the table is logically stored. Also it throws light on what kind of data will be stored in the table. Data class helps us to categorize the table on the basis of type of data stored.

There are three important data classes

  • APPL0 – Master data – Master data is data which is frequently read, but rarely updated.
  • APPL1 – Transaction data – Transaction data is data which is frequently updated.
  • APPL2 – Organizational and customizing data – Organizational und customizing data is data which is defined when the system is initialized and then rarely changed.

RFC

  1. RFC’s are Client Independent Objects. RFC connections can always be used across the entire system. This means that an RFC connection you have defined in client 100 can also be used from client 110 also without any difference.
  2. There are 5 types of RFC’s available in SAP System. They are:
    • Synchronous RFC (sRFC)
    • Asynchronous RFC (aRFC)
    • Transactional RFC (tRFC)
    • Queued RFC (qRFC)
    • Parallel RFC (pRFC)
  3. TRFC’s

If an error occurs during a synchronous remote function call, the system cannot tell at what point the error occurred (most crucially, whether the function module was actually processed in R/3 before the operation failed). Restarting a failed call is therefore a dangerous thing to do, since there is a risk of duplicating a completed function call.

In Such cases, tRFC’s can be used which guarantees that each function call issued will be executed only once, even if the call is submitted repeatedly to the R/3 System. The system implements this safeguard by assigning a unique transaction ID (TID) to each transaction that you submit. When you attempt to process the transaction, the system checks whether that TID has already been processed or not. If it has, the transaction is ignored.

If the system is not available, it will write the Data into aRFC Tables with a transaction ID (SM58) which is picked by the scheduler RSARFCSE (which runs for every 60 seconds).

 

4. QRFC’s

If the system is not available, it will write the Data into aRFC Tables with a transaction ID (SM58) which is picked by the scheduler RSARFCSE (which runs for every 60 seconds).

 

Interview Questions BDC

  1. What is use of BDCDATA ?

While writing a BDC program, standard structure ‘BDCDATA’ is used to collect this information. The BDCDATA structure includes the following fields:

  • PROGRAM
  • DYNPRO
  • DYNBEGIN
  • FNAM
  • FVAL

BDCDATA structure is used to create an internal table in the BDC program which collect the above information for an entire transaction.

Syntax for declaring an internal table that collects the screen information for processing batch input.

DATA: it_bdcdata type table of bdcdata.

2. Methods to process batch input sessions

There are two methods to process batch input session:

  • Manually process batch input sessions in the Session Overview i.e. SM35 transaction code.
  • Execute program RSBDCSUB.

3. Update mode available in BDC

The update mode when processing batch input sessions can be synchronous or asynchronous.

Synchronous updating means that an update is completed for one transaction (or record) before processing continues to the next transaction (or record) in the batch input session. Asynchronous does not wait for the update before continuing.

4. HOLDDATE parameter is to be used when there is a requirement to lock session until a decided date

5.KEEP flag or parameter to indicate whether the batch input session should be kept (‘X’) or deleted (‘ ’) after the successful processing.

6.Between the time a batch input session is created and the time it is processed, changes might have been made to the SAP database. These changes may result in errors when processing the batch input session.

7. What needs to be done if system crashes in the middle of BDC ?

Simply check the number of records already updated and delete them from input sequential file. Run BDC session again for the remaining records to be updated.

Analysis the error and check what caused the error, rectify the input file or the entry in BDCDATA and reprocess it.

8. Difference between call transaction and session method

  • In CALL SESSION method, the SAP database is updated during the processing of the batch input session, not the execution of the BDC program. In CALL TRANSACTION method, the SAP database is updated during the execution of the BDC program.

 

  • In CALL SESSION method, errors are handled automatically by the system during the processing of the batch input session. Errors are recorded in a log and with the batch input session, error is kept. In CALL TRANSACTION method, errors are not handled automatically by the system. Errors must be handled explicitly in the BDC program.

 

  • In CALL SESSION method – Asynchronous Processing and Synchronous Database update. During processing, no transaction is started until the previous transaction has been written to the database. In CALL TRANSACTION method – Synchronous Processing and database update can be done either synchronously or asynchronously. One just need to specify the mode in the program.

 

  • CALL TRANSACTION method is faster than CALL SESSION Method.

9. CALL TRANSACTION <transaction code>
USING <bdc table>
[MODE <display mode>]
[UPDATE <update mode>]
[MESSAGES INTO <msg table>] .

10. How Do You Handle BDC For A Table Control?

Issue can be resolved by using the BDC OKCODE ‘=P+’ . It’s the BCD_OKCODE for Page down that can be used for scrolling down in table control.

To populate data into a row of internal table, an index is added to the field name to indicate which line or row is to be populated (Line Index).

Take the below example:

When BDCDATA table is being filled with the records, then keep on incrementing the count variable by 1 as it represents the line number of the table control. Concatenate the field name with the count to represent the row and column of the table control.

When the last line of the table control is reached then again reset the value of the count as one and set the command of page up i.e. ‘=P+’ inside the loop only. This is done only for that screen where table control is being used.

11. The approach for writing a BDC program should be:

  • Go to SHDB and record the transaction for which the data is to be uploaded into the SAP System.
  • Save the recording and Transfer the recording routine to a program.
  • Now modify that program as per your need. Say if you are uploading an excel file available in presentation server then use function modules to upload excel file data into internal table.
  • Then put a loop on internal table and pass required data to the recording routine and save data into BDCDATA table.
  • Finally CALL TRANSACTION statement can be used to process the data present in the BDCDATA table.
  • This way data can be uploaded into SAP System.

12. CTU_PARAMS is a structure which has components used to control processing of CALL_TRANSACTION. This structure is used to provide display mode, update mode, default size and more control components to the Call Transaction statement.

13.Mostly when a BDC is run in ‘N’ mode, the BDC stops at the first COMMIT WORK statement. To resolve the issue set the RACOMMIT component of CTU_PARAMS.

CTU_PARAMS-RACOMMIT = ‘X’

14. how to handle screen resolution issues

This can be resolved by setting default size parameter available in CTU_PARAMS structure and then pass the same to the Call Transaction statement.

SMARTFORMS

  1. Unlike SAP Scripts, in Smart Forms you can have only one main window. And that too its width should be same in all the pages whereas height can be varied. Only one main window per smartforms is allowed but you can have 99 sub-windows.

    Main Window – Smartforms – Only 1
    Main Window – SAP Scripts – 99

  2. Four Types of windows available in Smart Forms. They are:
    • Main Window:- Basically, we use main window when there is a need to display text or data which can cover several pages. display data of all the rows of a table (a table in which you are not very sure as to how many row it has), in such cases we always use main windows.
    •  Secondary Window :- used to display text or data output with a fixed length.Secondary windows are used when there is a need to display text and data in a predetermined output area.
    •  Copies Window :-  Copies Window is a special type of secondary window for making pages as copy or originalused when there is a requirement to print copies of the pages.
    •  Final Window:- Final window is to be used where there is a requirement to show/display details that has to be processed only at the end of the form processing.

3. Table node has 3 components- HEADER, ITEM and FOOTER

  • The Header component will be executed once.
  • The Item component can be used to process/display table contents.
  • At the end footer will be executed.

4. Form Interface is where we can declare what must be passed in and out of the smartform (in from the print program to the smartform and out from the smartform to the print program).

Global Definition is where we declare data to be used within the smartform on a global scope i.e. anything we declare here can be used in any other node in the form.

5. Download the PDF file version of the spool by running Program RSTXPDFT4 and entering the noted spool number.

6. &SFSY-PAGE& : Current page number

  • &SFSY-FORMPAGE& : Total number of pages in the currently formatted layout set
  • &SFSY-JOBPAGE& : Total number of pages in the currently formatted print request
  • &SFSY-COPYCOUNT& : Original-1,1st copy-2
  • &SFSY-DATE& : Date
  • &SFSY-TIME& : Time
  • &SFSY-USERNAME& : Username

7. Address can be printed quickly and smoothly using the address node available in smartforms.

8. By Putting a break point on the generated function module of the Smartform, one can debug it.

9. There are 4 different types of Text available in Smart Forms. They are:

  • Text Element
  • Text Module :- A Text Module acts as some sort of container of text, which makes reuse of text easier. There are texts that frequently appear in different forms.
  • Include Text
  • Dynamic Text

10. Command Nodes can be used to achieve page break. By using Command Node, one can manually control the numbers of records to be displayed per page based on some condition.