ABAP General Interview Questions

Aired Consulting 10/17/2010 No Comment
ABAP General

What does ABAP stand for?

ABAP currently stands for Advanced Business Application Programming; however the original meaning was Allgemeiner Berichtsaufbereitungsprozessor, which is German for "generic report preparation processor" A different explanation is Anfänger Basteln An Programmen, which is german for "beginners tinker with programs"

What are the different types of internal tables?

There are three types of internal tables in ABAP, standard table, sorted table, and hashed table.

What is the difference between SAP memory and ABAP memory?

SAP Memory is a global memory area which all sessions within a SAPgui have access to. This allows for passing data between sessions. The SET PARAMETER ID and GET PARAMETER ID statements are
used to manipulate the SAP Memory.
SET PARAMETER ID 'MAT' field p_matnr.
GET PARAMETER ID 'MAT' field p_matnr.
ABAP Memory is a memory area which all programs in the call stack within the same internal session can access. The EXPORT and IMPORT statements are used here.
export p_matnr = p_matnr to memory id 'ZTESTMAT'.
import p_matnr = p_matnr from memory id 'ZTESTMAT'.

What are the events used in report programs?

Load-of-Program
Initialization
At Selection-Screen
At Selection-Screen on
At Selection-Screen on block
At Selection-Screen output
At Line-Selection
At User-Command
Start-of-Selection
End-of-Selection
Top-of-Page
End-of-Page

How are RANGES different from SELECT-OPTIONS?

They are the same, except SELECT-OPTIONS will provide an interface on the selection screen for the user to input data.

How to convert a date to internal or external format?

Use the functions modules CONVERT_DATE_TO_EXTERNAL or CONVERT_DATE_TO_INTERNAL
to convert the date. When converting to external format, the date format from the user's user profile will be used. When converting to internal format, the result will be in YYYYMMDD format.

Are header lines and the OCCURS extension obselete?

In regard to internal tables, header lines and the OCCURS extension are obselete. These are actually not allow in the OO context. The correct way to define internal tables and work areas are to use a TYPE statement to define the structure and the use a DATA statement to define the internal table and work area.
Types: begin of ttab,
       fld1(10) type c,
       fld2(10) type c,
       end of ttab.
 
data: itab type table of ttab.
data: wa like line of itab.

What is the difference between OCCURS n and INITIAL SIZE n?

OCCURS n is obsolete in OO Context and it is advisable to use INITIAL SIZE instead. The difference between the two is that OCCURS n allocates memory to store specified number of rows in the internal table and also creates a header line, whereas INITIAL SIZE allocates memory for the specified number of rows without creating the header line.

How do I create an internal deep structure in OO Approach?

TYPES: BEGIN OF t_msg,
  count TYPE sy-tabix,
  mtab TYPE STANDARD TABLE OF bdcmsgcoll
    WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0,
END OF t_msg.
DATA itab TYPE TABLE OF t_msg.

How do I download data in my internal table in a CSV file?

Use the Function Module SAP_CONVERT_TO_CSV_FORMAT to convert the internal table into Comma seperated format then download this internal table using the Function Module GUI_DOWNLOAD.
See a sample program below:
TYPE-POOLS:truxs.
DATA: BEGIN OF itab OCCURS 0,
        vbeln LIKE vbap-vbeln,
        posnr LIKE vbap-posnr,
      END OF itab.
DATA: itab1 TYPE truxs_t_text_data.
 
SELECT
  vbeln
  posnr
  UP TO 10 ROWS
  FROM vbap
  INTO TABLE itab.
 
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    i_field_seperator    = ';'
  TABLES
    i_tab_sap_data       = itab
  CHANGING
    i_tab_converted_data = itab1
  EXCEPTIONS
    conversion_failed    = 1
    OTHERS               = 2.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
 
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = 'C:\TEMP\test.txt'
  TABLES
    data_tab = itab1
  EXCEPTIONS
    OTHERS   = 1.

How can I get the IP address of the system programmatically?

You can use cl_gui_frontend_services to get the system IP address.
DATA ip_addr(50) TYPE c.
CALL METHOD cl_gui_frontend_services=>get_ip_address
  RECEIVING
    ip_address           = ip_addr
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.
DATA terminal LIKE USR41-TERMINAL.
CALL FUNCTION 'TERMINAL_ID_GET'
 EXPORTING
   USERNAME                   = sy-uname
 IMPORTING
   TERMINAL                   = terminal.

How can I download my internal table into an Excel file?

Use the function module SAP_CONVERT_TO_XLS_FORMAT to download the internal table to an excel file.
PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'c:\tmp\test.xls'.
DATA: itab LIKE t001 OCCURS 0 WITH HEADER LINE.
 
SELECT * FROM t001 INTO TABLE itab.
 
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
  EXPORTING
    i_filename     = p_file
  TABLES
    i_tab_sap_data = itab.

How can I read an Excel file from presentation server?

You can use the Function module ALSM_EXCEL_TO_INTERNAL_TABLE to read the Excel file into the internal table of type alsmex_tabline. From this internal table you can fill the target internal table.
TYPES: BEGIN OF t_upload,
           field1(12),
           field2(12),
           field3(12),
         END OF t_upload.
  DATA it_upload TYPE TABLE OF t_upload.
  DATA wa_upload TYPE t_upload.
  DATA itab TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename    = filename
      i_begin_col = 1
      i_begin_row = 1
      i_end_col   = 3
      i_end_row   = 65535
    TABLES
      intern      = itab.
 
  LOOP AT itab.
    CASE itab-col.
    WHEN '0001'.
        it_upload-field1 = itab-value.
    WHEN '0002'.
        it_upload-field2 = itab-value.
    WHEN '0003'.
        it_upload-field3 = itab-value.
    AT END OF row.
      APPEND t_upload.
      CLEAR t_upload.
    ENDAT.
  ENDLOOP.

How can I define my own F4 Input help processing for a field on the selection screen?

You can use the event AT SELECTION-SCREEN ON VALUE REQUEST FOR for defining your own input help for selection screen fields.
PARAMETER: p(10).
 
AT SELECTION-SCREEN ON VALUE REQUEST FOR p.
BREAK-POINT.
"Do your processing here...

How can I convert numerals into the corresponding text?

Use the Function Module SPELL_AMOUNT to convert the integer into text.
DATA v_int TYPE i VALUE '1000'.
DATA words LIKE SPELL.
 
CALL FUNCTION 'SPELL_AMOUNT'
 EXPORTING
   AMOUNT          = v_int
   LANGUAGE        = SY-LANGU
 IMPORTING
   IN_WORDS        = words
          .
WRITE words-word.

What is the difference between "'" and "`" in character strings?

The single quote character(') in character strings do not preserve white spaces at the end whereas the "`" character preserves white spaces as it is.
Eg.:
DATA v_char(32) TYPE c.
v_char = 'This is a'.
CONCATENATE v_char 'text   ' INTO v_char SEPARATED BY space.
*" v_char would be "This is a text"
CONCATENATE v_char `text   ` INTO v_char SEPARATED BY space.
*" v_char would be "This is a text   "

How can I set the initial values for SELECT OPTIONS at the start of the program?

In the event INITIALIZATION you could set the initial values for the selection screen fields. For SELECT OPTIONS you should fill the SIGN, OPTION, LOW, HIGH fields.
Eg: Set the date field with starting day of the month to last day of the month.
SELECT-OPTIONS: s_date FOR sy-datum.
 
INITIALIZATION.
  s_date-sign = 'I'.
  s_date-option = 'BT'.
  date+6(2) = '01'.
  s_date-low = sy-datum.
  CALL FUNCTION 'LAST_DAY_OF_MONTHS'
    EXPORTING
      day_in            = sy-datum
    IMPORTING
      last_day_of_month = s_date-high
    EXCEPTIONS
      day_in_no_date    = 1.
  APPEND s_date.

I am using a SELECT query on a database table. Since the number of records in the table is very large, the program dumps due to insufficient memory. How can I solve this?

In this case you could use the PACKAGE SIZE addition in the SELECT query to process in limited amount of data, thus avoiding the memory overloads.
Eg:
SELECT *
 FROM 
 INTO TABLE itab
 PACKAGE SIZE .
 
IF sy-subrc EQ 0.
*" Process the n records
ENDIF.
 
ENDSELECT.

How can I access parameters to MACROS?

The parameters in MACROS can be accessed by &1, &2 ...
DATA sum TYPE i.
 
"Macro definition
DEFINE add_macro.
sum = *&1 + &2*.
END-OF-DEFINITION.
 
START-OF-SELECTION.
add_macro 10 20.
WRITE sum.
Related Posts

No comments:

 

Aired | Copyright © 2009-2014| All Rights Reserved 2014 | Privacy Policy and Disclaimer

Contact Us | About Us