To know the concepts of an internal tables please check the post – Internal tables – Part 1. In this section let’s see some operations on standard internal table practically in programs.
Putting data in a standard internal table using keyword – ‘APPEND’ statement.
The APPEND statement adds a single record to an existing internal table. This single record is always added after the last existing line in an internal table.
Lines 8-12: Declaring a structure with 3 fields. Name, Age and Gender.
Line 13: Declaring an internal table IT_EMP which is of type structure TY_EMP. Internal tables are capable to hold multiple records.
Line 14: Declaring a work area WA_EMP which is of type structure TY_EMP. Work area is capable to hold only one record at any given instance.
Line 16: Event Start-Of-Selection.
Line 20-22: Populating the fields name, age and gender of the work area WA_EMP.
Line 23: Putting the data from work area WA_EMP to internal table IT_EMP. This is done using ABAP keyword ‘APPEND’. This puts the first record in the internal table IT_EMP.
Line 26-28: Again, populating the fields name, age and gender of the work area WA_EMP.
Line 29: Putting the data from work area WA_EMP to internal table IT_EMP. This is done using ABAP keyword ‘APPEND’. This puts the second record in the internal table IT_EMP.
Line 31-35: ABAP keyword – ‘LOOP’ is used to access every record of the internal table and displaying on the screen using another ABAP keyword – ‘WRITE’.
below is the sample output of the program –
The first record in the output is ‘Prasenjit1’ which was added to the internal table at Line – 23 and second record was added to the table at Line – 29. Hence the APPEND statement always adds records to the internal table at the end.
Putting data in a standard internal table using keyword – ‘INSERT’ statement.
in the above program output we already have 2 records with index 1 and 2 respectively. Now we will try to add one record at index – 1 using INSERT statement. Code below.
Lines 38-40: Adding data to the work area.
Line 41: Adding data form work area into the internal using INSERT statement at position 1. Previously the employee name in the first record was – ‘Prasenjit1’, but now the first position has the employee name – ‘Prasenjit_new’. Below is the output.
Now lets try to modify a record using the ‘MODIFY’ statement.
For example – Age of the employee ‘Prasenjit1′ is ’36’. Lets change the age to ’26’. Below is the code to modify the data.
Line 43 – putting new value of the age in the field ‘age’ of the work area.
Line 45 : Modifying the record – 2 (mentioned in the index) with the new age value. Check out the program output once its executed.
We can even delete data form an internal table. Shall be discussed in another post.
3 Comments
Richard Moro · September 15, 2022 at 11:05 am
Hello there! I could have sworn Ive been to this blog in the past but after looking at some of the posts I realized its further to me. Nonetheless, Im very delighted I discovered it and Ill be bookmarking it and checking support frequently!
Jeanelle Troesch · September 15, 2022 at 6:12 pm
Thanks so much for the article post.Really thank you! Much obliged.
מאהבת הפרטית כדרך להתמודד עם האהבה הנכשלת - Cal's Trails · June 8, 2023 at 10:47 am
[…] דירות דיסקרטיות בראשון לציון פרטיות משמשות למגורים כאשר יש מאהב למרחקים ארוכים, בדרך כלל מתפקיד או תשוקה, או בעיות כלכליות הקשורות לאפשרויות דיור.דירות אלו מצוידות בכל הדרוש לבריחות אלו הרחק מהבית לפרטיות וסודיות כולל שמיכות, מחשבים ניידים, אוכל וכו'. לפיכך השכרות אלו מספקות דרך מפתה לעסקים המחפשים נוחות וקלות למגורים משרדיים המתאימים לכל אורח חיים כולל עובדים שעובדים מחוץ למשרדים ביתיים במשרה מלאה כגון […]
Comments are closed.