Vous êtes sur la page 1sur 20

QB-3 M.

Rajagopalan

ABAP General

 What does ABAP stand for?


 What are the different types of internal tables?
 What is the difference between SAP memory and ABAP memory?
 What are the events used in report programs?
 How are RANGES different from SELECT-OPTIONS?
 How to convert a date to internal or external format?
 Are header lines and the OCCURS extension obselete?
 What is the difference between OCCURS n and INITIAL SIZE n?
 How do I create an internal deep structure in OO Approach?
 How do I download data in my internal table in a CSV file?
 How can I get the IP address of the system programmatically?
 How can I download my internal table into an Excel file?
 How can I read an Excel file from presentation server?
 How can I define my own F4 Input help processing for a field on the selection screen?
 How can I convert numerals into the corresponding text?
 What is the difference between "'" and "`" in character strings?
 How can I set the initial values for SELECT OPTIONS at the start of the program?
 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?
 How can I access parameters to MACROS?
 How can I import and export my ABAP developments?

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'.

24/Oct/2007 1 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

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.

24/Oct/2007 2 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

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.

24/Oct/2007 3 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

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.

24/Oct/2007 4 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

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.

24/Oct/2007 5 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

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 <fieldname> 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.

24/Oct/2007 6 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

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 <table>
INTO TABLE itab
PACKAGE SIZE <n>.

24/Oct/2007 7 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

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.

How can I import and export my ABAP developments?

SAPlink is an opensource community project that makes it easy to share ABAP developments between
programmers. It provides the ability to easily distribute and package custom objects.

ABAP Debugging

 How do I debug background Processes?


 How do I debug completed background process?
 How do I debug remote function calls?
 How do I debug Updates/System code?
 Why does it give a dump when I put a break-point in between SELECT and ENDSELECT?
 How do I set breakpoints in modal dialogs?

How do I debug background Processes?

In transaction SM50 (process overview), you can select a background process and choose
Program/Mode -> Program -> Debugging from the menu.

An alternative workaround, which allows you to step into a particular piece of code is to place a piece of
code in a endless DO-ENDDO, where you can change a variable to step out of the DO at a particular
point in your code. This allows you to hold the process at that point and debug it from SM50 as described
above. An implementation of this exists in function module C160_HOLD_FOR_DEBUG, which will enter
the endless loop if a particular environment variable is set, thereby allowing you to control its behaviour.
(Further instructions are found in the comments in subroutine INC14Z_HOLD_FOR_DEBUG of include
LC14ZFCB).

24/Oct/2007 8 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

How do I debug completed background process?

You can do this only after the job has finished execution. This will simulate the exact background scenario
with the same selection screen values as used in the job and sy-batch set to 'X'.

 Use SM37 to get list of jobs , type 'JDBG' in the command line ( no '/' ), put the cursor on the job
and press ENTER
 You are in debug mode now. Step through SAP program (press F7 couple of times) until you get
to code you need.

How do I debug remote function calls?

You can use the same techniques as described in How do I debug background Processes? above.

How do I debug Updates/System code?

Both options are available from the menu in debugging. Choose Settings -> System/Update Debugging to
activate either before proceeding.

Why does it give a dump when I put a break-point in between SELECT and ENDSELECT?

A breakpoint in SELECT loops can cause an exception through loss of the database cursor. The reason
for this is that during debugging a database commit is triggered and hence the cursor is lost.

How do I set breakpoints in modal dialogs?

There are two similar approaches to set breakpoints in modal dialogs:

Approach 1:

 Click on the Create shortcut icon on the toolbar.


 In the popup window choose "System command" and in the command enter "/h"
 A shortcut on the desktop would be created
 Drag and drop the shortcut to the modal window to set debugging on.

Approach 2:

 Create a txt file on the desktop with the following lines:

 [FUNCTION]
 Command=/H
 Title=Debugger

Type=SystemCommand

 Drag and drop this file to the modal window to set debugging on.

ALV

ALV stands for ABAP List viewer, although it is more recently reffered to as SAP List Viewer. It is a
technology for easy creation of report output, which provides a lot of functionality, like sorting, summation
etc., with very little programming effort.

24/Oct/2007 9 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

Frequently Asked Questions

 What are different function modules in ALV?


 How do I implement interactive reporting in ALV?
 Is it possible to create a list without a field catalog?

What are different function modules in ALV?

There are several function modules, the most common being REUSE_ALV_LIST_DISPLAY, which
provides for a simple list from one table of data. See function group SALV for a list of function modules.
(Note that these functions are not officially released by SAP for customer use, but are widely used).

ABAP Dictionary

 What types of objects can be created in the ABAP Dictionary?


 What types of tables can be created in the ABAP Dictionary?
 Which field differentiates a table from client-dependent and client-independent?
 What is the difference between Pooled tables and Cluster tables?
 What is the difference between Database tables and Views?
 What are the different types of Views?
 Can I use all the views in the ABAP program ?
 What is Table Maintenance Generator?
 What is One step, two step in Table Maintenance Generator?
 How do you activate the database table after making changes to it?
 In which table are the programs stored in?
 I have recently added a few fields to a custom table. But I don't get these fields in the table
maintenance program?
 What is the difference between INSERT and MODIFY?
 How do I create index on a database table?
 What is the difference between Check Table and Value Table?
 What is the difference between Domain and Data Elements?
 When I create new entries in the table the field values are always in Uppercase. How do I get the
data with mixed case?
 What is the need of reference table and reference field in Currency/Quantity fields?

What types of objects can be created in the ABAP Dictionary?

Tables
Views
Data Elements
Structures
Table Types
Type Groups
Domains
Search Helps
Lock Objects

What types of tables can be created in the ABAP Dictionary?

Transparent Tables
Pooled Tables
Cluster Tables

24/Oct/2007 10 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

Which field differentiates a table from client-dependent and client-independent?

The MANDT field of the table specifies whether the table is client independent or not.

What is the difference between Pooled tables and Cluster tables?

Cluster tables and Pooled tables have many to one relationship with the underlying database.

A table pool corresponds to a table in the database in which all records from the pooled tables assigned
to it are stored. Several logical data records from different cluster tables can be stored together in one
physical record in a table cluster.

 A pooled table cannot have the name having more than 10 characters.
 All the key fields of the pooled table must be of character data type.
 In pooled tables, the maximum length of the key field/data fields should not exceed the length of
varkey/vardata of the pool respectively.

 In cluster table the records having the same key are stored in a single key in the cluster.
 If there is an overflow of the data records a continuation record is created with the same table key.

What is the difference between Database tables and Views?

The Table has a physical storage of data whereas views do not have physical storage of data.

The view is derived from one or more tables which is created only with the required fields from the
database table(s). It can also be created with table inner joins and specifying conditions for data retrieval.

What are the different types of Views?

 Projection view - Just retrieves some fields from a single table.


 Help View - This is used for search help.
 Database View - This is inner join view of one or more tables
 Maintenance View - Helps in creating maintaining data of the application object. The data can be
distributed among several tables.

Can I use all the views in the ABAP program ?

No. You can use only projection view or database view in your ABAP program.

What is Table Maintenance Generator?

The Table Maintenance Generator is used to create table maintenance program to add, modify or delete
records in the database table. This can be accessed using transaction SE54 or in SE11 using the menu
Utilities->Table Maintenance Generator.

What is One step, two step in Table Maintenance Generator?

This specifies the screens to be created in the Table Maintenance Program.

Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one
screen where you can add, delete or edit records.

Two step: Two screens namely the overview screen and Single screen are created. The user can see the
key fields in the first screen and can further go on to edit further details.

24/Oct/2007 11 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

How do you activate the database table after making changes to it?

After making changes to the table, inorder to reflect the changes go to transaction SE14 and Choose Edit
and then choose Activate and Adjust Database.

In which table are the programs stored in?

The programs are stored in the table TADIR and the development class packages in TDEVC.

I have recently added a few fields to a custom table. But I don't get these fields in the table
maintenance program?

You have to delete and recreate your own existing table maintenance program to see your new fields.

What is the difference between INSERT and MODIFY?

Whenever you need to create new records in the database table use INSERT. Whenever using INSERT
be sure that a duplicate entry having the same values for the primary key fields are not present. Else it
may throw a dump.

When you use MODIFY it makes a check for the matching key field values. If present it modifies the
matching record, else it creates a new record in the database table.

How do I create index on a database table?

Go to transaction SE11, open your database table. Choose the menu, Goto->Indexes to create index.
Give your index name and choose the fields of the table. Be careful, an additional index may vanish with
the next upgrade or hotpackage.

What is the difference between Check Table and Value Table?

The Check Table is the dependent table to which the relationship is defined using foreign keys. The
contents of the check table field are shown in the input help for the referenced field.

The Value table is the table attached to a field at the domain level, where the entry to the field can be only
from the value table. They are not used in the Input Help.

What is the difference between Domain and Data Elements?

The Domain specifies the Technical attributes of the field such as the data type, length and the value
range.

The data element is an elementary type defining the description/text for the field when displaying on the
screen and Parameter ID.

When I create new entries in the table the field values are always in Uppercase. How do I get the
data with mixed case?

The reason for this is that the Domain for the field in the table might have Lowercase checkbox
unchecked. Check the Lowercase checkbox to preserve the case of your data.

24/Oct/2007 12 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

What is the need of reference table and reference field in Currency/Quantity fields?

The reference table and reference field are the fields which specify the currency key or Unit of Measure.
Suppose if the user specifies a currency amount say 1000$, the currency amount field would indicate the
amount 1000 and the currency key indicates that the currency specified is in Dollars.

Form Printing - SAPscript, Smartforms

 How many MAIN windows are allowed for SAPscript?

How many MAIN windows are allowed for SAPscript?

SAPscript allows for 99 MAIN windows

SAPScript

 How do I create Boxes in SAPScript?


 How do I set tabs between the fields in display?
 How do I create standard texts for the scripts?
 How can I debug my SAPScript?
 I have created a script in language DE. Now I need to translate it to EN. How could I do this?
 How can I Word Wrap the text being displayed in SAPScript?
 How can I display barcodes in SAPScripts?
 How can I print logos in SAPScripts?
 How can I copy SAPScripts from one client to another?
 How can I trigger new page in SAPScripts?
 How can I prevent page-break in the message that is to be displayed?
 How can I set the position of the leading sign to left/right?
 What are the various text formatting options in SAPScript?
 Frequently Used System Variables in SAPScript?

How do I create Boxes in SAPScript?

You can create Boxes in the SAPScript using the BOX command specifying the x,y co-ordinates and the
width and the height

BOX XPOS '0' CM YPOS '0.5' CM WIDTH '9.2' CM HEIGHT '3.5' CM FRAME 8 TW

How do I set tabs between the fields in display?

In the Paragraph Format tab, create a new paragraph format. In the "Tabs" Tab, enter the tab position
and the alignment for the fields.

How do I create standard texts for the scripts?

You can create standard texts using the transaction SO10. Then to insert these standard texts in the
SAPScript choose the menu, Insert->Text->Standard and choose the standard text that you want to
choose.

Alternatively, you can display standard texts in your SAP Scripts using the command:
INCLUDE ZSTEXT OBJECT TEXT ID ST LANGUAGE EN

 where ZSTEXT refers to the Standard Text name.

24/Oct/2007 13 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

How can I debug my SAPScript?

Go to the transaction SE71.


Enter the form name.
Choose the menu Utilities->Activate Debugger to enable debugging.

I have created a script in language DE. Now I need to translate it to EN. How could I do this?

Open your script in transaction SE71.


In the Header screen, in the Language Attributes Option, choose Translate to... Option to translate to
other languages.

How can I Word Wrap the text being displayed in SAPScript?

Use the Function Module RKD_WORD_WRAP to wrap the text and use this for output.

How can I display barcodes in SAPScripts?

Create a character format in the SAPScript.


Choose the Bar Code for the character format.

And finally to display barcodes, in the command enter:

<C1>&vbeln&</>

 where C1 is the character format created and vbeln is the variable for which the barcode is to be
created.

How can I print logos in SAPScripts?

1. Convert the logo to a TIFF(*.tif) file.


o Use the program RSTXLDMC to convert the TIFF file to standard text.
o Print this using the INCLUDE command:
o INCLUDE ZLOGO OBJECT TEXT ID ST
2. For bitmaps (*.bmp)
o Go to transaction SE78
o Choose BMAP under GRAPHICS
o Choose Import Graphic (F5)
o Select the image and upload
o In SE71 choose Insert->Graphics and then choose the image for display

How can I copy SAPScripts from one client to another?

In the transaction SE71, enter the Form name and choose the menu, Utilities->Copy from client to copy
SAPScripts from one client to another.

Use RSTXSCRP to import/export SAPScripts.

How can I trigger new page in SAPScripts?

Use the command NEW-PAGE to trigger a new page in SAPScript.

24/Oct/2007 14 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

How can I prevent page-break in the message that is to be displayed?

Enclose the text that you want to prevent page-break in PROTECT... ENDPROTECT
SAPscript will ensure that each line of this text is printed together on the same page.

/: PROTECT
* Text
* Within
* The same page
/: ENDPROTECT

How can I set the position of the leading sign to left/right?

You can use the SET SIGN command to output the leading sign at the left or right.

/: SET SIGN LEFT

/: SET SIGN RIGHT

What are the various text formatting options in SAPScript?

&symbol(Z)& Omit Leading Zeros

&symbol(S)& Omit Leading Sign

&symbol(<)& Display Leading Sign to the Left

&symbol(>)& Display Leading Sign to the Right

&symbol(C)& Compress Spaces

&symbol(.N)& Display upto N decimal places

&symbol(T)& Omit thousands separator

&symbol(R)& Right justified

Frequently Used System Variables in SAPScript?

&DATE& Currentdate

&DAY& Day

&MONTH& Month

&YEAR& Year

&TIME& Time of the day

&HOURS& Hours

24/Oct/2007 15 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

&MINUTES& Minutes

&SECONDS& Seconds

&PAGE& Page

&NEXTPAGE& Next page number

&SPACE& Blank

&ULINE& Underline

&VLINE& Vertical line

&NAME_OF_MONTH& Name of the Month


Smartforms

 How can I insert symbols in Smartforms?


 I have a smartform which works fine in DEV. After trasnsporting it to PROD, there is no Function
module generated for this smartform. As a result my program dumps in PROD?
 How can I make the Smartforms to choose a printer name by default?
 How can I make the Smartforms to display a print preview by default without displaying the popup
for print parameters?

How can I insert symbols in Smartforms?

Select the Text node.


Change Editor (Click the button above Check near the Editor)
Go to menu Include->Characters->SAP Symbols
Choose the SAP symbol that you want to insert.

I have a smartform which works fine in DEV. After trasnsporting it to PROD, there is no Function
module generated for this smartform. As a result my program dumps in PROD?

The Smartform that is created in the Development may not have the same name in the Production server.
So it is always advised to use the Function Module SSF_FUNCTION_MODULE_NAME to get the
Function Module name by passing the Smartform name.

DATA: fm_name TYPE rs38l_fnam.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'


EXPORTING
formname = 'ZSMARTFORM'
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form =1
no_function_module = 2

24/Oct/2007 16 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

OTHERS = 3.
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 fm_name


EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error =3
user_canceled =4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

How can I make the Smartforms to choose a printer name by default?

In the CALL FUNCTION of the Smartform Function Module, set the output options parameter to set the
printer name.

The output options is of the type SSFCOMPOP which contains the field TDDEST. Set the TDDEST field
to your default printer name.

How can I make the Smartforms to display a print preview by default without displaying the popup
for print parameters?

In the SSF_OPEN function module,


Set the OUTPUT OPTIONS paramter TDDEST to your printer name.
Set the CONTROL PARAMETERS and control parameters as shown below,

control-preview = 'X'.
control-no_open = 'X'.
control-no_close = 'X'.
control-no_dialog = 'X'.
control-device = 'PRINTER'.
control_parameters-no_dialog = 'X'.
control_parameters-no_open = 'X'.
control_parameters-no_close = 'X'.
OUTPUT_OPTIONS-TDDEST = 'PRINTER NAME'.

24/Oct/2007 17 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

OUTPUT_OPTIONS-TDNOPRINT = 'X'.

CALL FUNCTION 'SSF_OPEN'


EXPORTING
output_options = output_options
control_parameters = control
user_settings =''
EXCEPTIONS
formatting_error = 1
internal_error =2
send_error =3
user_canceled =4
OTHERS = 5.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Screen Painter

To use ALV in dynpro, create only a container in the dynpro.

In ABAP code (PBO/PAI), you have to use SALV class to create the list in the container of dynpro.

It is much more effective than to use the type Pool SLIS and function REUSE_ALV_GRID_DISPLAY

For example, you can then properly connect the screens with levels of different details or make fields of
the list seizable by the users.

 What is a BADI?

What is a BADI?

BADI stands for Business Add-In. These are like user exits but are implemented using ABAP Objects.
More information can be found here

ABAP Performance and Tuning

 What tools can be used to help with performance tuning?


 What are the steps to optimise the ABAP Code?
 What is the difference between SELECT SINGLE and SELECT ... UP TO 1 ROWS?
 Which is the better - JOINS or SELECT... FOR ALL ENTRIES...?

24/Oct/2007 18 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

What tools can be used to help with performance tuning?

ST05 is the SQL Trace transaction and can be used to measure the performance of the select statements
of the program. SE30 is the Runtime Analysis transaction and can be used to measure the application
performance. It also gives some tips on how to improve the performance through efficient code.

One of the best tools for static performance analyzing is Code Inspector (SCI). There are many options
for finding common mistakes and possible performance bottlenecks.

What are the steps to optimise the ABAP Code?

1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
3. Use as much index fields as possible from left to right in your WHERE statement
4. Either enable buffering in your database table or create Indexes to speed up the query.
5. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
6. Avoid using nested SELECT statement, SELECT within LOOPs.
7. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
8. Avoid using SELECT * and Select only the required fields from the table.
9. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure
to sort the internal table before binary search.
10. Avoid nested loops when working with large internal tables.
11. Use assign instead of into in LOOPs for large internal tables
12. When in doubt call transaction SE30 and use the examples and check your code

What is the difference between SELECT SINGLE and SELECT ... UP TO 1 ROWS?

SELECT SINGLE returns the first matching row for the given condition and it may not be unique, if there
are more matching rows for the given condition.

SELECT ... UP TO 1 ROWS retrieves all the matching records and applies aggregation and ordering and
returns the first record.

Inorder to check for the existence of a record then it is better to use SELECT SINGLE than using
SELECT ... UP TO 1 ROWS since it uses low memory and has better performance.

Which is the better - JOINS or SELECT... FOR ALL ENTRIES...?

When using FOR ALL ENTRIES the number of matching records is restricted to the number of records in
the internal table. If the number of records in the database tables is too large then join would cause
overheads in performance.

Some things to consider....

1. Use "CHECK" instead of IF/ENDIF whenever possible.


2. Use "CASE" instead of IF/ENDIF whenever possible.
3. Use "MOVE" with individual variable/field moves instead of "MOVE-CORRESPONDING",
creates more coding but is more effcient*.*

BDC

 How do I record a Batch Input session for later playback and analysis?
 What are the commands available in a batch input session?

24/Oct/2007 19 of 20
http://abaplearner.blogspot.com
QB-3 M. Rajagopalan

How do I record a Batch Input session for later playback and analysis?

Using transaction SHDB it is possible to record transactions as well as create skeleton programs that
contain all the necessary code for creating batch input sessions.

What are the commands available in a batch input session?

 /n - Terminate current batch input transaction and mark as incorrect


 /bdel - Delete current batch input (transaction) from session
 /bend - End current batch input session completely
 /bda - TO DO - please see help link below
 /bde - TO DO - please see help link below

Note: These commands are only available in foreground mode! They are also accessible via the menu
under System -> Services -> Batch Input.

24/Oct/2007 20 of 20
http://abaplearner.blogspot.com

Vous aimerez peut-être aussi