Professional Documents
Culture Documents
Manipulating Timestamps
Using macros
Inserting charts
Usually in ABAP, when you want to start the debugger from a certain point, you
just have to write "/H" in the
command window. But if you are in a modal screen or in a message display, you
cannot write the traditional
Back to top
Sometimes you may have only a table name and want to retrieve the name of
each field of the corresponding table. For example, when you want to use ASSIGN
COMPONENT fieldname OF TABLE table.
An ABAPer's first reaction is to read the standard ABAP basis tables DD02L,
DD03L, etc
This way of reading fields is very slow. Use methods from the class
CL_ABAP_TYPEDESCR instead.
Example:
descr_struc_ref ?= cl_abap_typedescr=>describe_by_name('SFLIGHT' ).
Here is the result of descr_struct_ref after the execution of this piece of code
TYPE_KIND C 1 u
LENGTH I 4 80
DECIMALS I 4 0
KIND C 1 S
STRUCT_KIND C 1 F
COMPONENTS h 8 Table[14x40]
HAS_INCLUDE C 1
3 | 0 |C |MANDT
3 | 0 |C |CARRID
4 | 0 |N |CONNID
8 | 0 |D |FLDATE
etc.
You have the fields name and a lot more information about the table. This class
can also handle structure, table type, etc.
Note that this method is very fast because it uses the database layer directly
thanks to SYSTEM CALLs.
When you create a select-option for an input to your program, for each field, the
default selection screen looks like this:
REPORT ZDANY_RESTRICT_SELECTION.
TYPE-POOLS sscr.
TABLES : sflight.
select-options :
INITIALIZATION.
optlist-name = 'OBJECTKEY1'.
optlist-options-eq = 'X'.
optlist-options-bt = 'X'.
ass-kind = 'S'.
ass-name = 'S_carrid'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY1'.
optlist-name = 'OBJECTKEY2'.
optlist-options-cp = 'X'.
optlist-options-ge = 'X'.
optlist-options-lt = 'X'.
optlist-options-ne = 'X'.
ass-kind = 'S'.
ass-name = 'S_connid'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY2'.
EXPORTING
restriction = restrict
EXCEPTIONS
TOO_LATE = 1
REPEATED = 2
SELOPT_WITHOUT_OPTIONS = 3
SELOPT_WITHOUT_SIGNS = 4
INVALID_SIGN = 5
EMPTY_OPTION_LIST = 6
INVALID_KIND = 7
REPEATED_KIND_A = 8
OTHERS = 9.
IF sy-subrc <> 0.
when you execute this piece of code, you will notice that for carrid, the selection
screen is now restricted :
Back to top
You want to call a program on your PC from an ABAP program ? try this function :
i_returncode TYPE i.
EXPORTING
command = 'CMD' <<==-- CMD calls the DOS prompt but you can put any program
here
* PARAMETER = 'test'
IMPORTING
returncode = i_returncode.
GUI_EXEC
GUI_FILE_SAVE_DIALOG
GUI_GET_DESKTOP_INFO
GUI_GET_FILE_INFO
etc...
Back to top
Did you ever try to use a variable from another program without passing this
variable as a parameter. This is very useful when you CANNOT add the field as a
standard parameter. For example, when you want to use a variable in a BADI
which is not already passed as a parameter. Another good example is when you
create a correction in a function and you want to keep the installation of the OSS
note automatic (if you add parameters in a note, the user will have to install the
note manually).
REPORT zdany_test_var_from_fm.
TABLES: spfli.
dbcnt = sy-dbcnt.
FUNCTION zfunction.
DATA: field(50).
FIELD-SYMBOLS: <dbcnt>.
field = '(ZDANY_TEST_VAR_FROM_FM)dbcnt'.
WRITE <dbcnt>.
field = '(ZDANY_TEST_VAR_FROM_FM)ITAB[]'.
ENDLOOP.
ENDFUNCTION
Back to top
There can be times when you need a list of active internal tables while you are
debugging ABAP code.
The first method, lets you see which table required a lot of memory
You can play around and try the other area than DSEG, some are interesting.
Back to top
This process is very easy but a lot of programmers don't know how to do it. You
just have to call the ABAP FM SAPGUI_PROGRESS_INDICATOR, at the appropriate
points.
REPORT zdany_progress_bar.
percentage_text(3) = sy-index.
percentage_text+3 = '%'.
EXPORTING
percentage = sy-index
text = percentage_text.
ENDDO.
Back to top
Manipulating Timestamps
Actually, we should use time stamp in our abap programs instead of the
traditional date and time fields.
REPORT zdany_tstamp.
TRY.
EXPORTING
tstmp = l_tstamp
RECEIVING
r_tstmp = l_tstamp_out.
CATCH cx_parameter_invalid_range .
EXIT.
CATCH cx_parameter_invalid_type .
EXIT.
ENDTRY.
SKIP.
To avoid the standard F4 help to be show, insert the event PROCESS ON-VALUE-
REQUEST request in the program and add a field statement for the field that
should trigger the F4 help. In the module called from PROCESS ON-VALUE-
REQUEST request, call function module F4IF_FIELD_VALUE_REQUEST.
Example:
.....
.....
* NOTE:
* Value: The value of the Dynpro field when calling the F4 help.
* You can limit the values shown, by inseting a value in this parameter
tabname = 'SFLIGHT'
fieldname = 'CARRID'
dynpprog = 'ZDANY_F4_OWN_CALL'
dynpnr = '0100'
dynprofield = 'SFLIGHT-CARRID'
* STEPL = 0
value = 'A*'
* TABLES
* RETURN_TAB =
* EXCEPTIONS
* FIELD_NOT_FOUND = 1
* NO_HELP_FOR_FIELD = 2
* INCONSISTENT_HELP = 3
* NO_VALUES_FOUND = 4
* OTHERS = 5
IF sy-subrc <> 0.
<field> event.
Note that for ranges both the low and high value of the field must have there own
ON VALUE-REQUEST
Example:
PERFORM f4_help_carrid.
PERFORM f4_help_carrid.
Back to top
Did you know that you can create an ALV Grid very fast; you don't need to define
a layout, a fieldcatalog, a container and all the other small things we usually
define in an ALV Grid. If we don't need to finetune the ALV Grid and just want to
display a list on the screen or to the printer, here is a very simple way to
proceed:
* calling the display of the grid, the system will automatically create the
fieldcatalog based
* You have to create an EMPTY screen, put NOTHING in the layout and this is going
to work
Instead of creating an empty screen 100, you can also define an empty selection
screen in you program and use it, no more screen painter required !
Back to top
When you press F4 on any date field the standard calendar opens in order for you
to choose a date. When you do not want the user to choose a weekend day or a
holiday, you can do it.
Two different type of calendars are defined in SAP, the holiday calendar and the
factory calendar.
in this screen, all the default holidays are predefined by country, you can add or
delete holiday as you want. I tried to create the Dany's day in ISP but I'm stuck
on a small access problem... stupid security !
Because a holiday can be different by country, the factory calendar is stored for
each plants, in table T001W, field FABKL.
EXPORTING
date_for_first_month = '20031208'
IMPORTING
select_date = select_date
EXCEPTIONS
OTHERS = 4.
While you are debugging your program, you can save the content of an internal
table.
If you need a unique key in a table or a sequential number for any other purpose,
you can use a range object .
- NRIV Number range intervals. Note: Field NRLEVEL Contains the last assigned
number.
In you program you read the next number by using the function
NUMBER_GET_NEXT
EXPORTING
nr_range_nr = '01'
object = 'ZTEST'
quantity = '1'
IMPORTING
number = l_number
* RETURNCODE =
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
OTHERS = 7.
display l_number.
You can also create the number range in your program instead of using SNRO
with the functions:
Back to top
REPORT ZDANY_DYN_LOCAL_TYPES.
l_count type i,
* We read information about each fields of SFLIGHT (see ABAP FAQ #2)
* We also need the information about the type "typ_count", note that
comp_tab = struct_type->get_components( ).
comp_fld-name = 'L_COUNT'.
comp_fld-type = elem_type.
* The new thing here is the "type handle" which create a pointer to a
* handle
break-point.
Back to top
Using macros
First : DO NOT use macros in a new program, there is a lot of better way to do it.
Some people come to my desk and tell me they found a "magic" function which
the code behind is invisible and it's impossible to trace this function. In some old
programs, you can see a strange call to what it look like a function but it's not,
it's a macro.
One of the most used macros is "break". To put a break-point in your code that
will break only for your user name, you probably use "break my_user_name".
This is not part of the ABAP language despite what a lot of people think; it's a
macro. If you have a look in table TRMAC, you will see :
Here is how to create a simple macro, for the sake of understanding what old
programs do. Again, do not
REPORT zdany_macro.
*Macro definition
DEFINE ZMULTIPLY.
END-OF-DEFINITION.
WRITE number1.
Back to top
The very useful SELECT statement could be fully dynamic from release 6.10 and
up.
For more information about the dynamic select, you can read the document
"Enhanced ABAP programming with Dynamic Open SQL" from Adrian Görler and
Ulrich Koch. Here is the link
https://webphl07.phl.sap.corp/~sapidb/011000358700002805272003E , this is a
PDF file.
REPORT zdany_dynamic_select.
* We use some parameters to dynamically control the select, this is not very
comp_tab = struct_type->get_components( ).
ENDLOOP.
comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
l_wa_name = 'l_WA'.
SELECT (lt_sel_list)
FROM (p_tabnam)
WHERE (lt_where)
GROUP BY (lt_group)
HAVING (l_having)
ORDER BY (lt_group).
WRITE: <l_fld>.
ENDLOOP.
SKIP.
ENDLOOP.
Back to top
Using JavaScript in ABAP
If you want to do some JavaScript tests in ABAP there is a good program to use :
DEMO_JAVA_SCRIPT_MINI_EDITOR. When you run this program, you can code
your Java in an ABAP editor, compile and execute it to test the result.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
REPORT ZDANY_JAVASCRIPT_TEST.
l_JS_PROCESSOR = CL_JAVA_SCRIPT=>CREATE( ).
concatenate
'l_source; '
if l_JS_PROCESSOR->LAST_CONDITION_CODE <> 0.
exit.
else.
endif.
if l_JS_PROCESSOR->LAST_CONDITION_CODE <> 0.
exit.
else.
endif.
write : / l_RETURN_VALUE.
Back to top
1. Start SE39
2. Choose Compare different systems
3. Enter both program names and the RFC destination of the remote program
4. Choose Display
Here is an example of the result, note that the system show difference in blue
You can also compare table content :
Back to top
Several texts can be entered for which the system searches. The search
text should be entered without formatting characters(*,+). Only the texts
are applied in the search, i.e. selection option conditions such as greater
than, equal to, etc., are ignored
You can restrict the search to either the program code or the flow logic of
the selected screens or both the program code and the flow logic of the
screens.
You can set the option to ignore the comments for search.
Found location +/- x lines: Here we can specify how many program lines
before and after the found location of the search string should be included
in the output.
We can also specify the option to search in all the includes used in the
specified programs.
Back to top
There is a way to avoid building a fully object-oriented program while still working
with non-object-oriented relational database. The object services layer now
provides a persistence framework that closes the object-relational gap. You no
longer need to write SQL code as objects are transparently loaded from the
database when needed. You must create a persistent class.
Choose transaction SE24 and create a persistent class; this class must be
protected.
In the class builder, a new button is added in the main toolbar - "Persistence" -
press it :
in the next screen, you just have to map which fields you need in your persistent
class
After having saved the previous screen, you will notice that the system creates a
set/get method for each field that you selected.
Activate the whole class. Now that we have a persistent object to access the
database table SFLIGHT, we must access it in a program. Here is a small example
to read/write data into SFLIGHT using persistent objects.
REPORT zdany_sflight_persistent.
l_seatsfree TYPE i,
l_seatsocc TYPE i.
l_flight_agent = zca_dany_sflight=>agent.
TRY.
l_flight = l_flight_agent->get_persistent(
i_carrid = 'LH'
i_connid = '0400'
i_fldate = '20031030' ).
IF l_seatsfree > 0.
l_seatsocc = l_flight->get_seatsocc( ) + 1.
l_flight->set_seatsocc( l_seatsocc ).
ENDIF.
ENDTRY.
COMMIT WORK.
There are lots of other methods and techniques that you can use in persistent
classes.
Back to top
1. Check whether your user has debugging authority. Auth. object S_DEVELOP
has to contain 'DEBUG'
o Use su01; ROLES
o Double click the different roles ->
o new session will open
o Choose Authorizations -> Display Authorization Data
2. go to the ABAP coding
3. go to the menu Utilities -> Settings / choose tab "ABAP editor " / choose
tab "Debugging" check the chek - box "Actv." in the User field enter the
user used in the Java logon (not the alias of the user!! e.g. for BRUNO enter
"3B1968D7DD1")
4. Press enter or choose OK to get back to your source code
5. If you set your next break-point a pop-up will occur to ask you if you want
to set an external break-point or a session break-point --> click external
break-point (= former HTTP break-point) -->
if you run you Java application now and the coding with the break-point is called
a new R/3 (CRM) window will open and you will see you code in debug mode
(may take some seconds)
Back to top
INITIALIZATION.
* We must check if a default variant was already entered by the user in a batch job
or in the transaction code
IF sy-slset IS INITIAL.
EXPORTING
EXCEPTIONS
variant_not_existent = 0
variant_obsolete = 0
OTHERS = 0.
ENDIF.
* After the initialization we start the real code of our program in the section
START-OF-SELECTION
START-OF-SELECTION.
Here is how to create a the variant "SAPDEFAULT" always using as a default date
today minus 30 days:
Here is the standard variant save screen. Enter a name and a description and
press "execute". Very few know how to handle the weird looking bottom part of
this screen:
1. Check the variables for which you want to maintain default values
2. Choose selection variables button and see the next one
The first part is a legend of the column headers (T D B Z). Because we want to
create a date, we double click on the traffic lights of the column "D" for Dynamic
date calculation. when the traffic light turn green, you can press on the down
arrow in the "T" column. This will bring a popup with all possibilities you can
imagine for defaulting a date. From a usability point of view, this is not really
good screens but nevertheless, this tool is very powerful.
Back to top
The checkpoint group is defined by double clicking on the checkpoint group in the
editor OR directly via transaction SAAB.
Below is the SAAB screen. In the breakpoints part of the screen, you can set it to
"inactive" or "break". All breakpoint groups will be shipped inactive by default.
Assert :
METHOD sort_by_name.
the_sorting_algorithm.
ASSERT ID dany
SUBKEY 'danysub1'
ENDMETHOD.
This will ensure that the table is sorted. Below is the result of the log for this
assert
Back to top
Step 1 :
You have to define a Root class using SE24, In this class you will defined all
variables you want to share in the attributes tab, This class must be "Shared
memory enabled" :
Step 2 : You have to define your shared memory object using the transaction
SHMA. It is important to put the class you created in step 1 in the field "root
class".
Step 3 : You have to write a program to write to the shared memory.
* when we attach for write, an exclusive lock is performed on the shared memory
object
hdl = zcl_sm_area=>attach_for_write( ).
*when we create our root object to access variables, we must use the new keyword
addition AREA HANDLE
* Create the link between the root object and the shared memory object
hdl->set_root( root ).
* commit
hdl->detach_commit( ).
Step 4 : You have to create a program to read from the shared memory
hdl = zcl_sm_area=>attach_for_read( ).
WRITE / hdl->root->big_var.
*Release lock
hdl->detach( ).
Back to top
Now, with the new tree control, when you want to give fully customizable tree, ou
need to dynamically set the order in the sort command.
The first method is by using a CREATE SUBROUTINE POOL with your sort. Each
time you will run the program, this subroutine will be recompiled. This is VERY
slow and we should avoid using this command whenever it's possible.
The second method is a simple trick that have no major impact on performance.
You duplicate each fields you want to sort, 1 copy for ascending and 1 for
descending. You move the fieldname only in 1 of those fields depending on what
order you want.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
REPORT z_dany_dyn_sort.
field1(6),
field2(6),
field3(6),
field4(6),
field5(6),
END OF ltt_fields.
DATA: l_field_asc1(6),
l_field_asc2(6),
l_field_asc3(6),
l_field_asc4(6),
l_field_asc5(6),
l_field_des1(6),
l_field_des2(6),
l_field_des3(6),
l_field_des4(6),
l_field_des5(6),
l_flag_invalid_field,
l_flag_not_asc_des.
INITIALIZATION.
DO 3 TIMES.
ls_fields-field1 = sy-index.
DO 3 TIMES.
ls_fields-field2 = sy-index.
DO 3 TIMES.
ls_fields-field3 = sy-index.
DO 3 TIMES.
ls_fields-field4 = sy-index.
DO 3 TIMES.
ls_fields-field5 = sy-index.
ENDDO.
ENDDO.
ENDDO.
ENDDO.
ENDDO.
START-OF-SELECTION.
* The order must be "ASC" or "DES" or space, any other value is rejected
l_flag_not_asc_des = 'X'.
CLEAR l_flag_not_asc_des.
* the field name must be = "FIELD1, 2, 3, 4 or 5", any other value is rejected
l_flag_invalid_field = 'X'.
'FIELD1FIELD2FIELD3FIELD4FIELD5' CS s_field5.
CLEAR l_flag_invalid_field.
* for a certain field, if the user ask descending order, the name of this field is
IF s_ord1 = 'ASC'.
l_field_asc1 = s_field1.
ELSE.
l_field_des1 = s_field1.
ENDIF.
ENDIF.
IF s_ord2 = 'ASC'.
l_field_asc2 = s_field2.
ELSE.
l_field_des2 = s_field2.
ENDIF.
ENDIF.
IF s_ord3 = 'ASC'.
l_field_asc3 = s_field3.
ELSE.
l_field_des3 = s_field3.
ENDIF.
ENDIF.
IF s_field4 IS NOT INITIAL.
IF s_ord4 = 'ASC'.
l_field_asc4 = s_field4.
ELSE.
l_field_des4 = s_field4.
ENDIF.
ENDIF.
IF s_ord5 = 'ASC'.
l_field_asc5 = s_field5.
ELSE.
l_field_des5 = s_field5.
ENDIF.
ENDIF.
* EACH field is used twice in the sort with different name for ascending and
descending. 1 of the
END-OF-SELECTION.
IF l_flag_not_asc_des = 'X'.
WRITE: / 'Only ASC for ascending or DES for DESCENDING are allowed for fields
S_ORDn'.
ENDIF.
Back to top
Inserting charts
It's a known fact that customers are very sensitive to the appeal of charts.
Creating graphical charts (bar, pie char, lines graphs) in ABAP is simple. There
are two main methods for creating charts in ABAP
There are also other classes and function modules derived from these ones. Use
transaction GRAL to explore all possibilities provided by this class and this FM.
The following are two short examples of the huge potential of function module
GFW_PRES_SHOW :
TYPE-POOLS: GFW.
REFRESH COLUMN_TEXTS.
VALUES-ROWTXT = 'Salary'.
VALUES-VAL1 = 50000.
VALUES-VAL2 = 51000.
APPEND VALUES.
VALUES-VAL1 = 49000.
VALUES-VAL2 = 51200.
APPEND VALUES.
COLUMN_TEXTS-COLTXT = '2003'.
APPEND COLUMN_TEXTS.
COLUMN_TEXTS-COLTXT = '2004'.
APPEND COLUMN_TEXTS.
* Call a chart into a standard container, this function could be used for many
* gfw_prestype_lines
* gfw_prestype_area
* gfw_prestype_horizontal_bars
* gfw_prestype_pie_chart
* gfw_prestype_vertical_bars
* gfw_prestype_time_axis
CALL FUNCTION 'GFW_PRES_SHOW'
EXPORTING
PRESENTATION_TYPE = GFW_PRESTYPE_LINES
TABLES
VALUES = VALUES
COLUMN_TEXTS = COLUMN_TEXTS
EXCEPTIONS
ERROR_OCCURRED = 1
OTHERS = 2.
Resulting in this:
The following uses the EXACT same function with a different presentation type
REFRESH VALUES.
REFRESH COLUMN_TEXTS.
VALUES-ROWTXT = ''.
VALUES-VAL1 = 10.
VALUES-VAL2 = 35.
VALUES-VAL3 = 45.
VALUES-VAL4 = 8.sul
VALUES-VAL5 = 2.
APPEND VALUES.
COLUMN_TEXTS-COLTXT = 'Fun'.
APPEND COLUMN_TEXTS.
COLUMN_TEXTS-COLTXT = 'Cars'.
APPEND COLUMN_TEXTS.
COLUMN_TEXTS-COLTXT = 'House'.
APPEND COLUMN_TEXTS.
COLUMN_TEXTS-COLTXT = 'Services'.
APPEND COLUMN_TEXTS.
COLUMN_TEXTS-COLTXT = 'Others'.
APPEND COLUMN_TEXTS.
EXPORTING
CONTAINER = 'CONTAINER'
PRESENTATION_TYPE = GFW_PRESTYPE_PIE_CHART
X_AXIS_TITLE = 'Expenses'
Y_AXIS_TITLE = 'Expenses2'
TABLES
VALUES = VALUES
COLUMN_TEXTS = COLUMN_TEXTS
EXCEPTIONS
ERROR_OCCURRED = 1
OTHERS = 2
Back to top
A lot of people use the SELECT SINGLE statement to check for the existence of a
value in a database. Other people prefer to use the 'UP TO 1 ROWS' variant of the
SELECT statement.
and
then looking at the result, not much apart from the extra ENDSELECT statement.
Look at the run time and memory usage and they may be worlds apart.
If not, here is a good example, credit for this example goes to Richard Harper, a
friend of mine on sapfans.com :
Create a Ztable called ZDifference with 2 fields in it, MANDT of type MANDT and
POSNR of type POSNR. Make sure both of these are keys. Also create a table
maintenance dialog for it (SE11->Utilities->Table Maintenance Generator). Fill
the table with ten rows 000001-000010.
Code:
******************************************************************
* Program: Z_Difference
* at least 10 records.
*
* Requested By:
* Reference Doc:
* Author: R Harper
* Modification History:
******************************************************************
Report Z_Difference
Message-id 38
Line-Size 80
Line-Count 0
Start-Of-Selection.
initial size 0
from zDifference
into w_Single.
*
Select Posnr
from zDifference
up to 1 rows
Skip 1.
Loop at t_Rows.
Write t_Rows.
EndLoop.
Up to 1 rows : 000010
The first 'SELECT' statement selected the first record in the database according to
any selection criterion in the 'WHERE' clause. This is what a 'SELECT SINGLE'
does. The second 'SELECT' has asked the database to reverse the order of the
records before returning the first row of the result.
In order to be able to do this the database has read the entire table, sort it and
then return the first record. If there was no ORDER BY clause then the results
would have been identical (ie both '000001') but the second select if given a big
enough table to look at would be far slower.
Note that this causes a problem in the Extended Program Check if the full key is
not specified in a 'SELECT SINGLE'. Replacing the 'SELECT SINGLE' by an "UP TO
1 ROWS" will give the same exact results without any warning but the program
will run slower and consume more memory. This is a good example of a warning
that we should ignore... considering you are sure of what you are doing !!
Back to top
When you use a range table in a select (SELECT * FROM sflight WHERE carrid IN
lt_carrid), you sometimes get a short dump with the error
DBIF_RSQL_INVALID_RSQL.
A lot of people think that a maximum number of records was reached; rumour
has it that it's somewhere between 1000 and 2000 records. This is false and
groundless. In fact, the problem is that the "IN" keyword is not native SQL and
the compiler converts it into native SQL. There is a limitation on the length of the
generated SQL string.
DO 5000 TIMES.
lt_range-sign = 'I'.
lt_range-option = 'EQ'.
lt_range-low = 'AA'.
APPEND lt_range.
ENDDO.
lt_range[2]-low OR
lt_range[3]-low OR
....
lt_range[5000]-low.
The short dump occur when the generated SQL caracter string is over a certain
threshold. This threshold is variable, could be between 2k and 32k (usually 4k or
8k) depending on the DB system. The threshold is stored in dbs/io_buf_size and
could NOT be change by programmers because this is maintained on DB level
(oracle, DB2, etc...) by IT.
1. Create some small packages (500 records) and call the SELECT within a
loop with APPENDING TABLE keyword
2. Usually the best way to do it is using a SELECT... FOR ALL ENTRIES IN...
instead.
Back to top
When you only know the function name to call at run-time, you have to call your
function dynamically. Here is an example of how to call a function dynamically
(note: comments were added to an existing example from the standard help)
REPORT ZDANY_DYN_FM_CALL.
*The constants and structures required to use the dynamic function call
type-pools abap.
* Exception table to handle the exception that can occur during the
CARRIER = 'XYZ'.
PARA_LINE-NAME = 'ID'.
PARA_LINE-KIND = ABAP_FUNC_EXPORTING.
PARA_LINE-NAME = 'ITAB'.
PARA_LINE-KIND = ABAP_FUNC_IMPORTING.
EXCP_LINE-NAME = 'NOT_FOUND'.
EXCP_LINE-VALUE = 1.
EXCP_LINE-NAME = 'OTHERS'.
EXCP_LINE-VALUE = 4.
insert EXCP_LINE into table EXCP_TAB.
*... and we dynamically call the function with the parameter-table and
* exception-table addition
parameter-table
PARA_TAB
exception-table
EXCP_TAB.
case SY-SUBRC.
when 1.
when 2.
endcase.
Back to top
1. Choose home -> R/3 entreprise -> direct download entreprise 1.2
2. download the .ZIP file,
3. Unzip
4. Cut and paste in an ABAP program
5. Compile and run
All your projects (including multiple classes, programs, function groups, screens
and tables) can be saved in less than one minute.
If you want to backup your work in order to keep a certain stable version while
you are programming, it might be preferable use a tool that is already embedded
in the Workbench: in se38/37/24/80, choose utilities -> versions -> generate
version