Ebook ABAP 101 Exercises Beginner Starting From Scratch
Ebook ABAP 101 Exercises Beginner Starting From Scratch
Ebook ABAP 101 Exercises Beginner Starting From Scratch
So you might say I took the wrong direction somewhere as I'm writing my first book without even
being engaged. Well, definitely if it weren't my parents I would never have written this book so I
thank them on the first place.
Nevertheless, I do have other people to thank. First and most important, Flávio Furlan, a former
work colleague and a permanent friend. We idealized this book long ago and after many
conversations (some on Skype during almost the whole dawn) we could see a good progress.
Firstly this book would be written in Portuguese, as it's our native language and due to the lack of
good SAP learning resources on such language. But we would rather reach as many people as
possible writing it in English and making it free of charge (or at least asking you to pay with a
single Tweet or Share on Facebook or LinkedIn).
I also must thank Jaime, who was one of my best ABAP students as he kept studying even after his
course had finished. He patiently was the very first person to complete all 101 exercises. Moreover,
he did a great job reviewing each question and giving awesome hints on how to make each question
shorter and clearer.
Last but not least I thank you for reading these words and for having no shame on start something
from scratch. I really hope this book can be your first steps on a great professional experience as an
ABAP developer.
Fábio Pagoti
ABAP Consultant and Trainer @ Ka Solution
Foreword by Flávio Furlan
I taught ABAP for more than 5 years. Our training was based on four weeks of theory and simple
exercises and one more week when students were requested to solve more difficult exercises. After
all those years, I can assure to say that our students learn the basics on theory-exercise weeks and
start to master in the last week, doing exercises by themselves.
You can read the help about WRITE, CONCATENATE and SELECT, but you will only learn when
you use it. That is the spirit of this book! Practice, practice and practice!
When I was studying for college admission, my brother, a former ITA engineer (Aeronautics
Institute of Technology in English, one of the most difficult college admissions in Brazil) used to
show me several completed exercise books. 100% completed! Exercise by exercise. Step by step.
That is what successful professionals have in common: hard work.
What you have in your hands looks silly in the beginning, but it gets more difficult and some
exercises could represents truly challenges. Do not give up! If you are a beginner ABAPer do a
favor to yourself, start from the exercise one and go further until the last one. It worth the effort!
Our first idea was just to present the exercises, but thanks to Fábio Pagoti and Jaime Freitas you can
also count with solutions. Remember: it’s not a crosswords book. There is no proud to complete it
checking the answers. Don’t lose your time checking the answers before actually solve (see that I
didn’t said try). Consider the words from Yoda Master for each exercise “Try not. Do... or do not.
There is no try”.
When you finish the last one, please generate a ZIP file with all solutions and e-mail me with
subject “Take it, Furlan!”. I dare you!
I really hope you enjoy and learn a lot with that book!
I also like to thank Fábio and Jaime! They really did a hard work to finish that! Thank you guys!
Flávio Furlan
Technical Architect @ Nestlé
Foreword by Jaime Freitas
The ebook “ABAP 101 Exercises - Beginner - Starting from scratch” is more than an extra learning
resource for ABAP freshmen. It's also a reusable guide and an opportunity to review many
techniques which are used on a daily basis during the development of Z programs or when
enhancing standard SAP Programs.
Without a shadow of a doubt, no matter if you are just starting or if you have been working for
some time with ABAP, this ebook deserves your attention.
Here, you will find the application of many concepts in an objective and dynamic way. This
concepts can be consulted or deepened by you later so you can address day-to-day doubts related
with a specific ABAP command, its use and variations.
I had access to this learning resource during its development phase when I had just finished an
ABAP course. Particularly, it was very useful for reviewing concepts which I learned during the
course. I truly believe this material will be useful in your daily job, being a young learner like me or
someone already inside on SAP world.
Jaime Freitas
However, as in any other learning process, practice is essential. The whole idea of this e-
book is to focus on the first steps you will need before deeping inside more complex ones.
Nowadays you can learn ABAP by reading SAP Press books, downloading SAP Trial
Versions, using ABAP Help, reading all different kinds of content from SAP Community Network,
following other sites and blogs as abap101.com (if you speak Portuguese) or ZEvolving.com (if you
speak English). Last but not least, there is Google. We recommend a mix of these information
sources during the time you are doing all exercises described in this e-book.
Nowadays, there are many other ways to create applications for SAP products (some don't
even use ABAP, like OpenUI5). Also, object orientation becomes more and more used by SAP and
its customers.
The authors of this book are totally willing to create other books like the one you are reading
now. These other books might focus on anything else related with ABAP development: Module
Pool programs, object orientation, SAP query, Data Dictionary, Smartforms, Enhancements, Web
Dynpro or a mix of those and others. In order to happen that, your feedback is essential.
You can visit ABAP101's contact page to give your feedback to us. We would appreciate a
lot such help.
What you should have/know before starting the exercises
• Access to a SAP server with development authorization (including SAP Logon or ABAP in
Eclipse if you use a recent version of SAP NetWeaver)
• What ABAP is and its purpose
• Any programming language experience (if you don't have prior experience, study each
exercise at least twice)
• SAP navigation (opening transactions, using the menu, etc)
• How to create an empty program (using SE38, SE80 or even Eclipse)
Answers
After having everything ready you are good to start the exercises. On the very first one you
might wonder "Where do I start?". You can refer to the ABAP help but it might be hard to find what
you need. That is the main reason why we have included answer and solutions for all exercises.
That's important - be honest with yourself! Even if you had to check the answer before
doing yours, try to understand it (but always try to do first without the answer). Don't go further
before reading all documentation available for each new keyword. Also, please understand that we
always offer possible answers. If you have a totally different one, that's great! Another good
exercise is to study the pros and cons of each possible one.
We also recommend to always look the answer before going to the next exercise, even if you
don't need it to code a valid solution. By doing this you will also learn by looking at other person's
code, which is always a good way to learn.
Exercises guidelines
To make this e-book useful for as many people as possible:
• SAP ERP tables are not used. In other words we always use the flight model and not tables
like MARA, VBAK, BSEG, etc
• Exercises order is not based on difficult level but on what you should know before going
further. Don't skip exercises!!!
General Instructions
• To make you organized, create a local package for everything you will create
• All exercises should be done
• The source code should be active
• Name your programs as Z_ABAP101_NNN, where NNN is the number of exercise
Part I - Data Types and Objects (1 - 40)
Declare a TYPE as a character with 10 positions.
Solution:
REPORT z_abap101_001.
Solution:
REPORT z_abap101_002.
Solution:
REPORT z_abap101_003.
Solution:
REPORT z_abap101_004.
Solution:
REPORT z_abap101_005.
Solution:
REPORT z_abap101_006.
Notes:
: (semicolon) is recommend in this case
name - This is a char with length 10
n_employees - This component (called ‘n_employees’ has the same type of the variable, but it is not
reusable)
Declare a type using the global structure SFLIGHT.
Solution:
REPORT z_abap101_007.
Notes:
Double click on SFLIGHT
It's a global definition (it's inside the repository)
This is a TYPE, not a variable.
Declare a structure type with the following components of the global structure SFLIGHT:
CARRID, CONNID, FLDATE, PRICE, CURRENCY, PLANETYPE, SEATSMAX and
SEATSOCC.
Solution:
REPORT z_abap101_008.
Solution:
REPORT z_abap101_009.
Solution:
REPORT z_abap101_010.
* 'carrid', 'connid' and 'fldate'. 2 components cannot have the same name so
* in the structure below we add a suffix for each component originated in the
local
* structure flight_booking
Solution:
REPORT z_abap101_011.
START-OF-SELECTION.
APPEND: 1 TO odd_numbers,
3 TO odd_numbers,
5 TO odd_numbers,
7 TO odd_numbers,
9 TO odd_numbers.
APPEND: 2 TO even_numbers,
4 TO even_numbers,
6 TO even_numbers,
8 TO even_numbers,
10 TO even_numbers.
Declare a table type with all components of the global structure SFLIGHT.
Solution:
REPORT Z_ABAP101_012.
START-OF-SELECTION.
sflight_work_area-CARRID = 'AA'.
sflight_work_area-CONNID = '0017'.
sflight_work_area-PRICE = '500.12'.
sflight_work_area-CARRID = 'AA'.
sflight_work_area-CONNID = '064'.
sflight_work_area-FLDATE = 20131225.
sflight_work_area-PRICE = '500.12'.
Solution:
REPORT Z_ABAP101_013.
Solution:
REPORT Z_ABAP101_014.
Solution:
REPORT Z_ABAP101_015.
Solution:
REPORT Z_ABAP101_016.
Solution:
REPORT z_abap101_017.
Solution:
REPORT z_abap101_018.
WRITE round_number.
Declare a variable of type date and give it halloween day.
Solution:
REPORT Z_ABAP101_019.
Solution:
REPORT z_abap101_020.
many_decimals = '123456789.987654321'.
Solution:
REPORT Z_ABAP101_021.
Solution:
REPORT Z_ABAP101_022.
Solution:
REPORT z_abap101_023.
Solution:
REPORT z_abap101_024.
Solution:
REPORT z_abap101_025.
Solution:
REPORT z_abap101_026.
Solution:
REPORT z_abap101_027.
TYPES ty_itab_sbook TYPE TABLE OF ty_sbook WITH KEY carrid connid fldate bookid.
Solution:
REPORT z_abap101_028.
Solution:
REPORT z_abap101_029.
Solution:
REPORT z_abap101_030.
Solution:
REPORT z_abap101_031.
Solution:
REPORT z_abap101_032.
Solution:
REPORT z_abap101_033.
Solution:
REPORT z_abap101_034.
Solution:
REPORT z_abap101_035.
Answer:
No. No initial value can be specified for internal tables and references
REPORT z_abap101_036.
Solution:
REPORT z_abap101_037.
Solution:
REPORT z_abap101_038.
Solution:
REPORT z_abap101_039.
Solution:
REPORT z_abap101_040.
Solution:
REPORT z_abap101_041.
START-OF-SELECTION.
WRITE v_result.
Write an executable program that get two integers inside variables and perform the addition,
subtraction, multiplication, division and power between them.
Solution:
REPORT z_abap101_042.
START-OF-SELECTION.
v_number_a = 5.
Solution:
REPORT z_abap101_043.
START-OF-SELECTION.
p_num_a = 5.
Solution:
REPORT z_abap101_044.
START-OF-SELECTION.
Solution:
REPORT z_abap101_045.
START-OF-SELECTION.
Solution:
REPORT z_abap101_046.
START-OF-SELECTION.
* Handle month
CASE sy-datum+4(2).
WHEN '01'.
v_month = 'January'.
WHEN '02'.
v_month = 'February'.
WHEN '03'.
v_month = 'March'.
WHEN '04'.
v_month = 'April'.
WHEN '05'.
v_month = 'May'.
WHEN '06'.
v_month = 'June'.
WHEN '07'.
v_month = 'July'.
WHEN '08'.
v_month = 'August'.
WHEN '09'.
v_month = 'September'.
WHEN '10'.
v_month = 'October'.
WHEN '11'.
v_month = 'November'.
WHEN '12'.
v_month = 'December'.
ENDCASE.
* Handle day
IF sy-datum+6(2) = '01'.
v_day = 'first'.
ELSEIF sy-datum+6(2) = '02'.
v_day = 'second'.
ELSEIF sy-datum+6(2) = '03'.
v_day = 'third'.
CASE sy-datum+6(2).
WHEN '04'.
v_day = 'four'.
WHEN '05'.
v_day = 'fif'.
WHEN '06'.
v_day = 'six'.
WHEN '07'.
v_day = 'seven'.
WHEN '08'.
v_day = 'eigh'.
WHEN '09'.
v_day = 'nin'.
WHEN '10'.
v_day = 'ten'.
WHEN '11'.
v_day = 'eleven'.
WHEN '12'.
v_day = 'twelf'.
WHEN '13'.
v_day = 'thirteen'.
WHEN '14'.
v_day = 'fourteen'.
WHEN '15'.
v_day = 'fitteen'.
WHEN '16'.
v_day = 'sixteen'.
WHEN '17'.
v_day = 'seventeen'.
WHEN '18'.
v_day = 'eighteen'.
WHEN '19'.
v_day = 'nineteen'.
ENDCASE.
CONCATENATE v_day 'th' INTO v_day.
ELSE.
CASE sy-datum+6(2). " 20-31
WHEN '20'.
v_day = 'twentieth'.
WHEN '21'.
v_day = 'twenty-first'.
WHEN '22'.
v_day = 'twenty-second'.
WHEN '23'.
v_day = 'twenty-third'.
WHEN '24'.
v_day = 'twenty-fourth'.
WHEN '25'.
v_day = 'twenty-fifth'.
WHEN '26'.
v_day = 'twenty-six'.
WHEN '27'.
v_day = 'twenty-seventh'.
WHEN '28'.
v_day = 'twenty-eighth'.
WHEN '29'.
v_day = 'twenty-first'.
WHEN '30'.
v_day = 'thirtieth'.
WHEN '31'.
v_day = 'thirty-first'.
ENDCASE.
ENDIF.
ENDIF.
* Handle Year
v_year = sy-datum(4).
* print result
WRITE: v_month, ' the ', v_day, ', ', v_year. NEW-LINE.
Write an executable program that reads the current system time and write the time in 6
different zones (3 of them should be compulsorily Greenwich, Delhi and Brasilia).
Solution:
REPORT z_abap101_047.
START-OF-SELECTION.
Solution:
REPORT z_abap101_048.
START-OF-SELECTION.
v_user = sy-uname.
TRANSLATE v_user TO UPPER CASE.
* One option
FIND ALL OCCURRENCES OF 'A' IN v_user MATCH COUNT v_vowels_count.
v_vowels_total = v_vowels_total + v_vowels_count.
FIND ALL OCCURRENCES OF 'E' IN v_user MATCH COUNT v_vowels_count.
v_vowels_total = v_vowels_total + v_vowels_count.
FIND ALL OCCURRENCES OF 'I' IN v_user MATCH COUNT v_vowels_count.
v_vowels_total = v_vowels_total + v_vowels_count.
FIND ALL OCCURRENCES OF 'O' IN v_user MATCH COUNT v_vowels_count.
v_vowels_total = v_vowels_total + v_vowels_count.
FIND ALL OCCURRENCES OF 'U' IN v_user MATCH COUNT v_vowels_count.
v_vowels_total = v_vowels_total + v_vowels_count.
* Another option
FIND ALL OCCURRENCES OF REGEX 'A|E|I|O|U' IN v_user MATCH COUNT
v_vowels_count.
WRITE v_vowels_total.
Write an executable program that counts a string length and if it's bigger than 2o characteres,
write 'Too big'. If not, write the string length.
Solution:
REPORT z_abap101_049.
START-OF-SELECTION.
IF v_string_length > 20 .
WRITE 'Too big'.
ELSE.
WRITE v_string_length.
ENDIF.
Write an executable program that counts from 1 to 100 and for each multiple of 8, write the
message: "The number [number] is a multiple of 8 ".
Solution:
REPORT z_abap101_050.
START-OF-SELECTION.
IF ( v_current_number MOD 8 ) = 0.
WRITE: 'The number', v_current_number, ' is a multiple of 8'.
NEW-LINE.
ENDIF.
ADD 1 TO v_current_number.
ENDWHILE.
Write an executable program that contains a routine which prints all usernames in the
system. (Check table USR04 and its content in transaction SE11, SE16 or SE16N).
Solution:
REPORT z_abap101_051.
START-OF-SELECTION.
SELECT bname
FROM usr04
INTO TABLE it_users.
*&---------------------------------------------------------------------*
*& Form print_users
*&---------------------------------------------------------------------*
* Prints all usernames in the system
*----------------------------------------------------------------------*
* -->US_T_USERS usernames
*----------------------------------------------------------------------*
FORM print_users USING us_t_users TYPE ty_users.
Solution:
REPORT z_abap101_052.
*&---------------------------------------------------------------------*
*& Form form_parameters
*&---------------------------------------------------------------------*
* Get 4 parameters in different ways
*----------------------------------------------------------------------*
* -->US_A text
* -->(USV_B) text
* -->CH_C text
* -->(CHV_D) text
*----------------------------------------------------------------------*
FORM form_parameters
USING us_a TYPE i
value(usv_b) TYPE i
CHANGING ch_c TYPE i
value(chv_d) TYPE i.
ENDFORM. "form_parameters
START-OF-SELECTION.
WRITE 'Before FORM'. NEW-LINE.
WRITE: 'gv_a: ', gv_a. NEW-LINE.
WRITE: 'gv_b: ', gv_b. NEW-LINE.
WRITE: 'gv_c: ', gv_c. NEW-LINE.
WRITE: 'gv_d: ', gv_d. NEW-LINE.
PERFORM form_parameters
USING
gv_a
gv_b
CHANGING
gv_c
gv_d
.
Solution:
REPORT z_abap101_053.
*&---------------------------------------------------------------------*
*& Form get_larger
*&---------------------------------------------------------------------*
* Compares 2 numbers and returns the largest. If equal returns itself
*----------------------------------------------------------------------*
* -->NUMBER_A Number A
* -->NUMBER_B Number B
* -->LARGEST_NUMBER Largest Number
*----------------------------------------------------------------------*
FORM get_larger
USING
number_a TYPE f
number_b TYPE f
CHANGING
largest_number TYPE f.
ENDFORM. "get_larger
START-OF-SELECTION.
Solution:
REPORT z_abap101_054.
*&---------------------------------------------------------------------*
*& Form get_larger
*&---------------------------------------------------------------------*
* Compares 2 numbers and returns a flag (true) if they are equal
*----------------------------------------------------------------------*
* -->NUMBER_A Number A
* -->NUMBER_B Number B
* -->FLAG Equal numbers indicator
*----------------------------------------------------------------------*
FORM set_flag_if_equal
USING
number_a TYPE f
number_b TYPE f
CHANGING
flag TYPE c.
IF number_a = number_b.
flag = abap_true.
WRITE flag. NEW-LINE.
ELSE.
flag = abap_false.
ENDIF.
ENDFORM. "get_larger
START-OF-SELECTION.
Solution:
REPORT z_abap101_055.
*&---------------------------------------------------------------------*
*& Form get_larger
*&---------------------------------------------------------------------*
* Compares 2 numbers and returns the largest. If equal returns itself
*----------------------------------------------------------------------*
* -->NUMBER_A Number A
* -->NUMBER_B Number B
* -->LARGEST_NUMBER Largest Number
*----------------------------------------------------------------------*
FORM get_larger
USING
number_a TYPE f
number_b TYPE f
CHANGING
largest_number TYPE f.
ENDFORM. "get_larger
*&---------------------------------------------------------------------*
*& Form get_larger
*&---------------------------------------------------------------------*
* Compares 2 numbers and returns a flag (true) if they are equal
*----------------------------------------------------------------------*
* -->NUMBER_A Number A
* -->NUMBER_B Number B
* -->FLAG Equal numbers indicator
*----------------------------------------------------------------------*
FORM set_flag_if_equal
USING
number_a TYPE f
number_b TYPE f
CHANGING
flag TYPE c.
IF number_a = number_b.
flag = abap_true.
* WRITE flag. NEW-LINE.
ELSE.
flag = abap_false.
ENDIF.
ENDFORM. "get_larger
*&---------------------------------------------------------------------*
*& Form division_or_power2
*&---------------------------------------------------------------------*
* takes two numbers and writes the result of the operation
* [higher_number / lower_number] if the numbers are different.
* If they are equal, write the result of the operation [number ^ 2].
*----------------------------------------------------------------------*
* -->NUMBER_A text
* -->NUMBER_B text
* -->RESULT text
*----------------------------------------------------------------------*
FORM division_or_power2
USING
number_a TYPE f
number_b TYPE f
CHANGING
result TYPE f.
PERFORM set_flag_if_equal
USING
number_a
number_b
CHANGING
lv_number_equal.
IF lv_number_equal = abap_true.
result = number_a ** 2.
ELSE.
DATA lv_larger_number TYPE f.
IF number_a = lv_larger_number.
result = number_a / number_b.
ELSE.
result = number_b / number_a.
ENDIF.
ENDIF.
START-OF-SELECTION.
PERFORM division_or_power2
USING 1 1
CHANGING gv_result.
PERFORM division_or_power2
USING 3 3
CHANGING gv_result.
PERFORM division_or_power2
USING 6 2
CHANGING gv_result.
PERFORM division_or_power2
USING 2 6
CHANGING gv_result.
PERFORM division_or_power2
USING 10 2
CHANGING gv_result.
PERFORM division_or_power2
USING 2 10
CHANGING gv_result.
Write an executable program that does NOT have a routine. The program should include a
work area with 5 fields of different types or more. Then, it must be populated and its fields should
be printed one per line, separated by one horizontal line. After testing your program, change the
output separating each field by two lines. During this process, refactor your code to include a
routine which handle the separation between each line.
Solution:
REPORT z_abap101_056.
START-OF-SELECTION.
* Before refactoring
* WRITE work_area-str.
* ULINE.
* WRITE work_area-date DD/MM/YY.
* ULINE.
* WRITE work_area-time.
* ULINE.
* WRITE work_area-integer.
* ULINE.
* WRITE work_area-hex.
* ULINE.
* After refactoring
WRITE work_area-str.
PERFORM separe_line.
WRITE work_area-date DD/MM/YY.
PERFORM separe_line.
WRITE work_area-time.
PERFORM separe_line.
WRITE work_area-integer.
PERFORM separe_line.
WRITE work_area-hex.
PERFORM separe_line.
*&---------------------------------------------------------------------*
*& Form separe_line
*&---------------------------------------------------------------------*
* Separe each output line
*----------------------------------------------------------------------*
FORM separe_line.
DO 2 TIMES.
ULINE.
ENDDO.
ENDFORM. "separe_line
Write an executable program with a routine that receives a work area containing five
different data types and count how many components are not filled. Finally, print result.
Solution:
REPORT z_abap101_057.
*&---------------------------------------------------------------------*
*& Form count_initial_components
*&---------------------------------------------------------------------*
* Gets a work area, counts how many components are initial and write
* the result
*----------------------------------------------------------------------*
* -->US_WORK_AREA work area
*----------------------------------------------------------------------*
FORM count_initial_components USING us_work_area TYPE ty_work_area.
DATA lv_initial_components_counter TYPE i.
IF us_work_area-str IS INITIAL.
lv_initial_components_counter = lv_initial_components_counter + 1.
ENDIF.
IF us_work_area-date IS INITIAL.
lv_initial_components_counter = lv_initial_components_counter + 1.
ENDIF.
IF us_work_area-time IS INITIAL.
lv_initial_components_counter = lv_initial_components_counter + 1.
ENDIF.
IF us_work_area-integer IS INITIAL.
lv_initial_components_counter = lv_initial_components_counter + 1.
ENDIF.
IF us_work_area-hex IS INITIAL.
lv_initial_components_counter = lv_initial_components_counter + 1.
ENDIF.
WRITE: 'Initial components: ', lv_initial_components_counter.
NEW-LINE.
ENDFORM. "count_initial_components
START-OF-SELECTION.
Solution:
REPORT z_abap101_058.
*&---------------------------------------------------------------------*
*& Form sum_numeric_components
*&---------------------------------------------------------------------*
* Receives a work area with numeric components and sum them.
*----------------------------------------------------------------------*
* -->US_WA Work area with numeric components
*----------------------------------------------------------------------*
FORM sum_numeric_components USING us_wa TYPE ty_work_area.
DATA lv_sum_result TYPE decfloat34.
WRITE lv_sum_result.
NEW-LINE.
ENDFORM. "sum_numeric_components
START-OF-SELECTION.
work_area-integer = 2.
work_area-float = '2.5'.
work_area-pack = '2.12345'.
work_area-decfloat34 = 1000000000000000000000000000000.
work_area_doubled-integer = work_area-integer * 2.
work_area_doubled-float = work_area-float * 2.
work_area_doubled-pack = work_area-pack * 2.
work_area_doubled-decfloat34 = work_area-decfloat34 * 2.
Solution:
REPORT z_abap101_059.
TYPES:
BEGIN OF ty_char_and_numeric,
char_comp1 TYPE string,
char_comp2 TYPE c LENGTH 3,
char_comp3 TYPE n LENGTH 10,
num_comp1 TYPE i,
num_comp2 TYPE f,
num_comp3 TYPE decfloat16,
END OF ty_char_and_numeric.
*&---------------------------------------------------------------------*
*& Form clear_char_or_numeric
*&---------------------------------------------------------------------*
* This routine clears some component values according to the following rules:
* a. Clear char components only if the sum of the numeric components is odd
(ignoring possible decimal places)
* b. Clear numeric components only if the sum of vowels in the three char
components is even (ignoring lower/upper case)
*----------------------------------------------------------------------*
* -->US_WA_CHAR_AND_NUMERIC text
*----------------------------------------------------------------------*
FORM clear_char_or_numeric USING us_wa_char_and_numeric TYPE
ty_char_and_numeric.
lv_sum_numeric =
us_wa_char_and_numeric-num_comp1 +
us_wa_char_and_numeric-num_comp2 +
us_wa_char_and_numeric-num_comp3.
ENDFORM. "clear_char_or_numeric
START-OF-SELECTION.
WRITE:
wa_char_cleared-char_comp1,
wa_char_cleared-char_comp2,
wa_char_cleared-char_comp3,
wa_char_cleared-num_comp1,
wa_char_cleared-num_comp2,
wa_char_cleared-num_comp3.
NEW-LINE.
WRITE:
wa_char_cleared-char_comp1,
wa_char_cleared-char_comp2,
wa_char_cleared-char_comp3,
wa_char_cleared-num_comp1,
wa_char_cleared-num_comp2,
wa_char_cleared-num_comp3.
NEW-LINE.
ULINE.
wa_numeric_cleared-char_comp1 = 'aeiouAEIOU'.
wa_numeric_cleared-char_comp2 = 'BCD'.
wa_numeric_cleared-char_comp3 = '0123456789'.
wa_numeric_cleared-num_comp1 = 2. " even
wa_numeric_cleared-num_comp2 = 10.
wa_numeric_cleared-num_comp3 = 100.
WRITE:
wa_numeric_cleared-char_comp1,
wa_numeric_cleared-char_comp2,
wa_numeric_cleared-char_comp3,
wa_numeric_cleared-num_comp1,
wa_numeric_cleared-num_comp2,
wa_numeric_cleared-num_comp3.
NEW-LINE.
WRITE:
wa_numeric_cleared-char_comp1,
wa_numeric_cleared-char_comp2,
wa_numeric_cleared-char_comp3,
wa_numeric_cleared-num_comp1,
wa_numeric_cleared-num_comp2,
wa_numeric_cleared-num_comp3.
NEW-LINE.
Write an executable program which contains three internal tables (their type must contain at
least three components of different data types). Each table will have a different type (standard,
sorted and hashed). Add 3 identical values in each table and view the contents of each table in the
debugger.
Solution:
REPORT z_abap101_060.
START-OF-SELECTION.
wa-id = '3'.
wa-name = 'John'.
wa-value = 50.
APPEND wa TO it_standard.
INSERT wa INTO TABLE it_sorted.
INSERT wa INTO TABLE it_hashed.
wa-id = '2'.
wa-name = 'Mary'.
wa-value = 60.
APPEND wa TO it_standard.
INSERT wa INTO TABLE it_sorted.
INSERT wa INTO TABLE it_hashed.
wa-id = '1'.
wa-name = 'Max'.
wa-value = 30.
APPEND wa TO it_standard.
INSERT wa INTO TABLE it_sorted.
INSERT wa INTO TABLE it_hashed.
BREAK-POINT.
Write an executable program which has a routine that receives an internal table and print how many
fields are filled with their default value (the line type of the table must have at least 4 fields).
Hint: each primitive type has a default value. For example, 0 (zero) is the default value of integers
whereas space ( ' ' ) is the default value of characters.
Solution:
REPORT z_abap101_061.
TYPES:
BEGIN OF ty_line,
id TYPE c LENGTH 10,
name TYPE string,
value TYPE i,
creation_date TYPE d,
END OF ty_line.
*&---------------------------------------------------------------------*
*& Form count_initial_fields_of_table
*&---------------------------------------------------------------------*
* Counts how many fields are filled with their default value
*----------------------------------------------------------------------*
* -->US_TABLE internal table
*----------------------------------------------------------------------*
FORM count_initial_fields_of_table USING us_table TYPE ty_table.
IF lwa_line-id IS INITIAL.
lv_initial_field_total = lv_initial_field_total + 1.
ENDIF.
IF lwa_line-name IS INITIAL.
lv_initial_field_total = lv_initial_field_total + 1.
ENDIF.
IF lwa_line-value IS INITIAL.
lv_initial_field_total = lv_initial_field_total + 1.
ENDIF.
IF lwa_line-creation_date IS INITIAL.
lv_initial_field_total = lv_initial_field_total + 1.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
wa-id = '1'.
wa-name = 'John'.
wa-value = 50.
wa-creation_date = '20140727'.
APPEND wa TO itab.
CLEAR wa.
wa-id = '2'.
wa-name = 'Mary'.
wa-value = 20.
* wa-creation_date = ?.
APPEND wa TO itab.
CLEAR wa.
wa-id = '3'.
wa-name = 'Max'.
* wa-value = ?.
* wa-creation_date = ?.
APPEND wa TO itab.
CLEAR wa.
wa-id = '4'.
* wa-name = ?.
* wa-value = ?.
* wa-creation_date = ?.
APPEND wa TO itab.
CLEAR wa.
Solution:
REPORT z_abap101_062.
TYPES:
BEGIN OF ty_line,
id TYPE c LENGTH 10,
name TYPE string,
value TYPE i,
creation_date TYPE d,
END OF ty_line.
*&---------------------------------------------------------------------*
*& Form count_initial_fields_of_line
*&---------------------------------------------------------------------*
* Counts and prints how many fields are blank by line
*----------------------------------------------------------------------*
* -->US_TABLE internal table
*----------------------------------------------------------------------*
FORM count_initial_fields_of_line USING us_table TYPE ty_table.
IF lwa_line-id IS INITIAL.
lv_initial_field = lv_initial_field + 1.
ENDIF.
IF lwa_line-name IS INITIAL.
lv_initial_field = lv_initial_field + 1.
ENDIF.
IF lwa_line-value IS INITIAL.
lv_initial_field = lv_initial_field + 1.
ENDIF.
IF lwa_line-creation_date IS INITIAL.
lv_initial_field = lv_initial_field + 1.
ENDIF.
WRITE: 'Line ', sy-tabix, ' => ', lv_initial_field, ' blank fields'.
NEW-LINE.
START-OF-SELECTION.
wa-id = '1'.
wa-name = 'John'.
wa-value = 50.
wa-creation_date = '20140727'.
APPEND wa TO itab.
CLEAR wa.
wa-id = '2'.
wa-name = 'Mary'.
wa-value = 20.
* wa-creation_date = ?.
APPEND wa TO itab.
CLEAR wa.
wa-id = '3'.
wa-name = 'Max'.
* wa-value = ?.
* wa-creation_date = ?.
APPEND wa TO itab.
CLEAR wa.
wa-id = '4'.
* wa-name = ?.
* wa-value = ?.
* wa-creation_date = ?.
APPEND wa TO itab.
CLEAR wa.
Solution:
REPORT z_abap101_063.
*&---------------------------------------------------------------------*
*& Form replace_spaces
*&---------------------------------------------------------------------*
* Replaces all occurrences of "space" by a "_" (underscore)
* using work areas (not field symbols).
*----------------------------------------------------------------------*
* -->CH_ITAB text
*----------------------------------------------------------------------*
FORM replace_spaces CHANGING ch_itab TYPE ty_tt_line.
ENDFORM. "replace_spaces
*&---------------------------------------------------------------------*
*& Form print_itab
*&---------------------------------------------------------------------*
* Prints internal table contents
*----------------------------------------------------------------------*
* -->US_ITAB text
*----------------------------------------------------------------------*
FORM print_itab USING us_itab TYPE ty_tt_line.
ENDFORM. "print_itab
START-OF-SELECTION.
wa-comp1 = 'ABAP101'.
wa-comp2 = 'One/Two/Three/Four Five/Six/Seven/Eight/Nine'.
wa-comp3 = '12 45'.
APPEND wa TO itab.
CLEAR wa.
PERFORM replace_spaces
CHANGING
itab.
Solution:
REPORT z_abap101_064.
*&---------------------------------------------------------------------*
*& Form replace_spaces
*&---------------------------------------------------------------------*
* Replaces all occurrences of "space" by a "_" (underscore)
* using field symbols (not work areas).
*----------------------------------------------------------------------*
* -->CH_ITAB text
*----------------------------------------------------------------------*
FORM replace_spaces CHANGING ch_itab TYPE ty_tt_line.
ENDFORM. "replace_spaces
*&---------------------------------------------------------------------*
*& Form print_itab
*&---------------------------------------------------------------------*
* Prints internal table contents
*----------------------------------------------------------------------*
* -->US_ITAB text
*----------------------------------------------------------------------*
FORM print_itab USING us_itab TYPE ty_tt_line.
ENDFORM. "print_itab
START-OF-SELECTION.
wa-comp1 = 'ABAP101'.
wa-comp2 = 'One/Two/Three/Four Five/Six/Seven/Eight/Nine'.
wa-comp3 = '12 45'.
APPEND wa TO itab.
CLEAR wa.
PERFORM replace_spaces
CHANGING
itab.
Solution:
REPORT z_abap101_065.
*&---------------------------------------------------------------------*
*& Form concatenate_strings
*&---------------------------------------------------------------------*
* Concatenate strings from an internal table
*----------------------------------------------------------------------*
* -->US_ITAB Internal table of strings
* -->CH_CONCATENATED_STRING Result
*----------------------------------------------------------------------*
FORM concatenate_strings
USING
us_t_strings TYPE table_of_strings
CHANGING
ch_concatenated_string TYPE string.
ENDFORM. "concatenate_strings
*&---------------------------------------------------------------------*
*& Form concatenate_strings_in_ways
*&---------------------------------------------------------------------*
* Receives an internal table of strings and concatenates
* their values in four different ways:
* Way 1: concatenate internal table texts by the line order
* Way 2: concatenate internal table texts by the text ascending order
* Way 3: concatenate internal table texts by the text descending order
* Way 4: concatenate internal table texts by the line reverse order
*----------------------------------------------------------------------*
* -->US_T_STRINGS Table of strings
* -->US_V_CONCAT_LOGIC Concatenation way # (1-4)
* -->CH_CONCATENATED_STRING Concatenated string
*----------------------------------------------------------------------*
FORM concatenate_strings_in_ways
USING
us_t_strings TYPE table_of_strings
us_v_concat_logic TYPE c
CHANGING ch_concatenated_string TYPE string.
CASE us_v_concat_logic.
WHEN '1'.
PERFORM concatenate_strings
USING
t_copied_strings
CHANGING
ch_concatenated_string
.
WHEN '2'.
SORT t_copied_strings.
PERFORM concatenate_strings
USING
t_copied_strings
CHANGING
ch_concatenated_string
.
WHEN '3'.
SORT t_copied_strings DESCENDING.
PERFORM concatenate_strings
USING
t_copied_strings
CHANGING
ch_concatenated_string
.
WHEN '4'.
* reverse loop
DATA vl_number_of_strings TYPE i.
FIELD-SYMBOLS <string_line> TYPE string.
DESCRIBE TABLE t_copied_strings LINES vl_number_of_strings.
UNASSIGN <string_line>.
vl_number_of_strings = vl_number_of_strings - 1.
ENDWHILE.
ENDCASE.
ENDFORM. "concatenate_strings_in_ways
START-OF-SELECTION.
PERFORM concatenate_strings_in_ways
USING
it_strings
'1'
CHANGING
gv_concatenated
.
WRITE: '1 - ', gv_concatenated, /.
CLEAR gv_concatenated.
PERFORM concatenate_strings_in_ways
USING
it_strings
'2'
CHANGING
gv_concatenated
.
WRITE: '2 - ', gv_concatenated, /.
CLEAR gv_concatenated.
PERFORM concatenate_strings_in_ways
USING
it_strings
'3'
CHANGING
gv_concatenated
.
WRITE: '3 - ', gv_concatenated, /.
CLEAR gv_concatenated.
PERFORM concatenate_strings_in_ways
USING
it_strings
'4'
CHANGING
gv_concatenated
.
WRITE: '4 - ', gv_concatenated, /.
CLEAR gv_concatenated.
Write an executable program with two parameters types as integers. The first represents a
number to be printed and the second represents the length of the number to be printed. Place zeros
to the left if necessary. Example:
• p_number = 15 p_length = 2. Output = 15
• p_number = 15 p_length = 6. Output = 000015
• p_number = 2014 p_length = 2. Output = 20
• p_number = 123456789 p_length = 10. Output = 0123456789
• p_number = 123456789 p_length = 4. Output = 1234
Solution:
REPORT z_abap101_066.
PARAMETERS:
p_number TYPE i,
p_length TYPE i.
START-OF-SELECTION.
DO vl_zeros TIMES.
CONCATENATE vl_left_zeros '0' INTO vl_left_zeros.
ENDDO.
CONCATENATE vl_left_zeros vl_number_string INTO vl_number_with_left_zeros.
WRITE: vl_number_with_left_zeros.
ENDIF.
Write an executable program with two parameters which represents a base and exponent.
Print the result of exponentiation. As both parameters are required for the operation they should be
mandatory.
Solution:
REPORT z_abap101_067.
START-OF-SELECTION.
Solution:
REPORT z_abap101_068.
AT SELECTION-SCREEN ON p_len.
START-OF-SELECTION.
DO p_len TIMES.
WRITE: 'Line [', sy-index , ']: ', p_text(sy-index).
NEW-LINE.
ENDDO.
Write an executable program which has two internal tables, with a header line and the other
without. Add five records in each table. In the case of the one with header line, use it embed work
area. For the other one, use a work area declared explicitly. Print the contents of both internal tables.
Solution:
REPORT z_abap101_069.
wa_line-id = 1.
wa_line-name = 'The One'.
wa_line-age = 10.
APPEND wa_line TO it_without_hat.
wa_line-id = 2.
wa_line-name = 'Bob'.
wa_line-age = 20.
APPEND wa_line TO it_without_hat.
wa_line-id = 3.
wa_line-name = 'Mary'.
wa_line-age = 30.
APPEND wa_line TO it_without_hat.
wa_line-id = 4.
wa_line-name = 'Chris'.
wa_line-age = 40.
APPEND wa_line TO it_without_hat.
wa_line-id = 5.
wa_line-name = 'Janet'.
wa_line-age = 50.
APPEND wa_line TO it_without_hat.
it_with_hat-id = 2.
it_with_hat-name = 'Bob'.
it_with_hat-age = 20.
APPEND it_with_hat.
it_with_hat-id = 3.
it_with_hat-name = 'Mary'.
it_with_hat-age = 30.
APPEND it_with_hat.
it_with_hat-id = 4.
it_with_hat-name = 'Chris'.
it_with_hat-age = 40.
APPEND it_with_hat.
it_with_hat-id = 5.
it_with_hat-name = 'Janet'.
it_with_hat-age = 50.
APPEND it_with_hat.
NEW-LINE.
IF it_without_hat = it_with_hat[].
WRITE ' ... without using []s we are using the work area and not the internal
table'.
ENDIF.
Have a routine that receives an internal table (with at least three columns) and the sort it by
its first column.
Solution:
REPORT z_abap101_070.
ENDFORM. "sort_1st_column
START-OF-SELECTION.
wa_person-id = 3.
wa_person-name = 'The One'.
wa_person-age = 30.
APPEND wa_person TO it_people.
wa_person-id = 2.
wa_person-name = 'Bob'.
wa_person-age = 20.
APPEND wa_person TO it_people.
wa_person-id = 1.
wa_person-name = 'Mary'.
wa_person-age = 10.
APPEND wa_person TO it_people.
wa_person-id = 5.
wa_person-name = 'Chris'.
wa_person-age = 50.
APPEND wa_person TO it_people.
wa_person-id = 4.
wa_person-name = 'Janet'.
wa_person-age = 40.
APPEND wa_person TO it_people.
PERFORM sort_1st_column
CHANGING
it_people.
Solution:
REPORT z_abap101_071.
FORM sort_any_column
USING us_v_column TYPE string
CHANGING ch_itab_people TYPE tt_people.
ENDFORM. "sort_any_column
START-OF-SELECTION.
wa_person-id = 3.
wa_person-name = 'The One'.
wa_person-age = 30.
APPEND wa_person TO it_people.
wa_person-id = 2.
wa_person-name = 'Bob'.
wa_person-age = 20.
APPEND wa_person TO it_people.
wa_person-id = 1.
wa_person-name = 'Mary'.
wa_person-age = 10.
APPEND wa_person TO it_people.
wa_person-id = 5.
wa_person-name = 'Chris'.
wa_person-age = 50.
APPEND wa_person TO it_people.
wa_person-id = 4.
wa_person-name = 'Janet'.
wa_person-age = 40.
APPEND wa_person TO it_people.
PERFORM sort_any_column
USING
'ID'
CHANGING
it_people.
PERFORM sort_any_column
USING
'NAME'
CHANGING
it_people.
Solution:
REPORT z_abap101_072.
FORM sort_any_columns
USING us_t_columns TYPE table_of_strings
CHANGING ch_itab_people TYPE tt_people.
CASE lv_number_of_lines.
WHEN 1.
READ TABLE us_t_columns INDEX 1 INTO lv_first_column.
SORT ch_itab_people BY
(lv_first_column) ASCENDING.
WHEN 2.
READ TABLE us_t_columns INDEX 1 INTO lv_first_column.
READ TABLE us_t_columns INDEX 2 INTO lv_second_column.
SORT ch_itab_people BY
(lv_first_column) ASCENDING
(lv_second_column) ASCENDING..
WHEN 3.
READ TABLE us_t_columns INDEX 1 INTO lv_first_column.
READ TABLE us_t_columns INDEX 2 INTO lv_second_column.
READ TABLE us_t_columns INDEX 3 INTO lv_third_column.
SORT ch_itab_people BY
(lv_first_column) ASCENDING
(lv_second_column) ASCENDING
(lv_third_column) ASCENDING.
ENDCASE.
ENDFORM. "sort_any_columns
START-OF-SELECTION.
wa_person-id = 3.
wa_person-name = 'The One'.
wa_person-age = 30.
APPEND wa_person TO it_people.
wa_person-id = 6.
wa_person-name = 'Peter'.
wa_person-age = 40.
APPEND wa_person TO it_people.
wa_person-id = 2.
wa_person-name = 'Bob'.
wa_person-age = 30.
APPEND wa_person TO it_people.
wa_person-id = 1.
wa_person-name = 'Mary'.
wa_person-age = 10.
APPEND wa_person TO it_people.
wa_person-id = 5.
wa_person-name = 'Chris'.
wa_person-age = 20.
APPEND wa_person TO it_people.
wa_person-id = 4.
wa_person-name = 'Bob'.
wa_person-age = 40.
APPEND wa_person TO it_people.
DATA it_sort_columns TYPE table_of_strings.
PERFORM sort_any_columns
USING
it_sort_columns
CHANGING
it_people.
REFRESH it_sort_columns.
PERFORM sort_any_columns
USING
it_sort_columns
CHANGING
it_people.
REFRESH it_sort_columns.
PERFORM sort_any_columns
USING
it_sort_columns
CHANGING
it_people.
REFRESH it_sort_columns.
Solution:
REPORT z_abap101_073.
START-OF-SELECTION.
DO v_difference TIMES.
v_multiplication_result = ( s_number-low + sy-index - 1 ) * 3.
WRITE v_multiplication_result.
NEW-LINE.
ENDDO.
Contains a select-options for numeric values and print all search criteria separated ",".
Solution:
REPORT z_abap101_074.
START-OF-SELECTION.
LOOP AT s_number.
IF s_number-sign = 'I'.
WRITE: 'Include'.
ELSE.
WRITE: 'Exclude'.
ENDIF.
CASE s_number-option.
WHEN 'EQ'.
WRITE: 'Equal', s_number-low.
WHEN 'NE'.
WRITE: 'Not equal', s_number-low.
WHEN 'LT'.
WRITE: 'Less than', s_number-low.
WHEN 'LE'.
WRITE: 'Less or equal', s_number-low.
WHEN 'GT'.
WRITE: 'Greater than', s_number-low.
WHEN 'GE'.
WRITE: 'Greater or equal', s_number-low.
WHEN 'BT'.
WRITE: 'between', s_number-low, ' and ', s_number-high.
WHEN 'BT'.
WRITE: 'not between', s_number-low, ' and ', s_number-high.
WHEN 'CP'. " Patterns are used in char and string select-options
WRITE: 'Contains pattern', s_number-low.
WHEN 'NP'.
WRITE: 'not the pattern', s_number-low.
ENDCASE.
NEW-LINE.
ENDLOOP.
Declare a select-options for numeric values without ranges. Then, validate if the number
zero is entered and if it is, show an error message.
Solution:
REPORT z_abap101_075.
AT SELECTION-SCREEN ON s_number.
LOOP AT s_number.
IF s_number-low = '0'.
MESSAGE 'Number zero is not allowed' TYPE 'E'.
ENDIF.
ENDLOOP.
Declare a select-options for numeric values without multiple ranges. Then, validate if a
range bigger than 100 is entered and if it is, show an error message.
Solution:
REPORT z_abap101_076.
AT SELECTION-SCREEN ON s_number.
Solution:
REPORT z_abap101_077.
Solution:
REPORT z_abap101_078.
Solution:
REPORT z_abap101_079.
Solution:
REPORT z_abap101_080.
INITIALIZATION.
Solution:
REPORT z_abap101_081.
AT SELECTION-SCREEN.
IF sy-ucomm = 'ACTION'.
CLEAR p_input.
ENDIF.
Declare three radio buttons and two input fields. If the first radio button is selected, both
input fields should be displayed and ready for input. If the second one is chosen, the first input field
should be mandatory and the second one should blocked for input. If the last radio button is chosen,
both input fields should not be displayed in the screen.
Solution:
REPORT z_abap101_082.
AT SELECTION-SCREEN.
v_last_action = sy-ucomm.
AT SELECTION-SCREEN OUTPUT.
IF v_last_action = 'ACTION'.
CASE 'X'.
WHEN p_first.
LOOP AT SCREEN.
IF screen-name = 'P_INPUT1' OR screen-name = 'P_INPUT2'.
screen-input = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN p_busin.
LOOP AT SCREEN.
IF screen-name = 'P_INPUT1'.
screen-required = 1.
MODIFY SCREEN.
ENDIF.
IF screen-name = 'P_INPUT2'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN p_econo.
LOOP AT SCREEN.
IF screen-name = 'P_INPUT1' OR screen-name = 'P_INPUT2'.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDCASE.
ENDIF.
Declare four parameters. The first two should have a character type and the last two a
numeric type. Separate each pair in the selection screen using selection screen blocks. Both blocks
should contain a frame so it's possible to see the separation between them.
Solution:
REPORT z_abap101_083.
Solution:
REPORT z_abap101_084.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01. " Define in text
elements
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02. " Define in text
elements
Solution:
REPORT z_abap101_085.
Solution:
REPORT z_abap101_086.
POSITION 1.
PARAMETERS p_check AS CHECKBOX.
POSITION 10.
PARAMETERS p_text TYPE string.
Solution:
REPORT z_abap101_087.
AT SELECTION-SCREEN.
IF sy-ucomm = 'PRESS'.
MESSAGE 'Button was pressed' TYPE 'I'.
ENDIF.
Create a tabbed block with 3 tabs. Each of them should have a different content.
Solution:
REPORT z_abap101_088.
INITIALIZATION.
tab1 = 'String'.
tab2 = 'Date'.
tab3 = 'Time'.
Declare three parameters. There should be a horizontal line separating the first two ones and
a blank line separating the last two.
Solution:
REPORT z_abap101_089.
PARAMETERS p_1.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN SKIP 1.
Solution:
REPORT z_abap101_090.
PARAMETERS:
p_name TYPE string LOWER CASE,
p_born TYPE d,
p_last TYPE t.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS:
s_luck FOR v_luck,
s_bad FOR v_bad_luck NO INTERVALS,
s_favo FOR v_favourite NO-EXTENSION.
INITIALIZATION.
v_person = 'Personal Data'.
v_autho = 'Authorization'.
v_number = 'Numbers'.
Declare a selection screen with two date parameters. The first once should be typed with the
primitive type. The second, with type SYST-DATUM. Is there any different between them when
filling the selection screen? What about the documentation displayed when you hit F1 key?
Solution:
REPORT z_abap101_091.
Solution:
REPORT z_abap101_092.
Solution:
REPORT z_abap101_093.
Solution:
REPORT z_abap101_094.
Solution:
REPORT z_abap101_095.
Solution:
REPORT z_abap101_096.
Solution:
REPORT z_abap101_097.
Solution:
Open transaction SE93 and follow as below.
Click on create and fill the popup with the transaction name and description. It must be a report
transaction.
Solution:
Create a program with one parameter representing an executable program name (also known
as report). The program should execute the program entered in the parameter.
Solution:
REPORT Z_ABAP101_100.
START-OF-SELECTION.
Solution:
REPORT z_abap101_101.
START-OF-SELECTION.
LOOP AT s_report.
ENDLOOP.
Appendices
Publishing your answers on the Internet
Doing 101 exercises is great. Showing the world (including recruiters) your answers is even better.
We recommend using GitHub.com to publish you answers. Learning how to use git (a software
which helps you versioning files) and GitHub (a website where you can publish and share code) is
beyond the scope of this ebook.
ABAP programs are not stored locally on developer's computer. In order to export your programs to
a local file you can use the “export program” option inside SE38 and SE80 or do it massively using
an open source project called SAPLink (saplink.org), Learning how to use SAPLink is also beyond
the scope of this ebook.
Check all these websites if you are interested on sharing the work you have done.
The Authors