SAP ABAP [2020] - ABAP 7.40/7.50- Read and Modify Internal Table
Вставка
- Опубліковано 2 сер 2024
- SAP ABAP [2020] - ABAP 7.40/7.50- Read and Modify Internal Table
#sapabap #oopsabap #ooabap
In this session, we will discuss how to read an entry of an internal table and also how to modify the record of the table.
What is SAP ABAP?
ABAP is a high-level programming language created by the German software company SAP SE.
ABAP is one of the many application-specific 4th generation languages first developed in the 1980s.
It was originally the report language for SAP R/2, a platform that enabled large corporations to build mainframe business applications for materials management and financial and management accounting.
In ABAP we have basically 2 types of programs:
1)Reports
2)Module pools
The module pool program defines more complex patterns of user interaction using a collection of screens.
The term “screen” refers to the actual, physical image that the user sees.
Each screen also has a "flow logic", which refers to the ABAP code implicitly invoked by the screens, which is divided into a "PBO" (Process Before Output) and "PAI" (Process After Input) section.
Dynpro - Dynamic program - refers to the combination of the screen and its flow logic.
Introduction to ABAP module pool programming.
Module pool programs are also called dialog programs.
The module Pool programs are basically reports that are prepared for different screens and to manage the sequence of events of these screens.
In the transaction SE80, you can see all the dynpros that you have for this kind of report, add new ones, add all types of elements to the report.
In this program, we will discuss new syntaxes in ABAP 7.40
Hi Sooraj, great video. In addition I would like to add a few comments.
I would read the table line as follows:
assign it_data[ name = 'sam' ] to field-symbol().
First this is faster than direct assignment.
Second and the foremost reason is that you can check if line exists with a sy-subrc check (because sy-subrc check works 4 or 5 times faster than line_exists statement)
Hi Bekir.. Thanks for your wonderful comment.. yes, the field symbol assignment also just works fine..it was put in to avoid the dump that may happen if line doesnt exist.
There is another approach also from SPS08, which is resut = value #( itab[ name = 'sam'] optional/default). This I had mentioned in my value Operator video.
I will try to include the field symbol assignment part in my upcoming video. The subscribers shouldn't miss on any detail regarding the subject. That's the whole idea :-)
@@SoorajSasidharanABAP Hi Sooraj, thanks for the update. I just wrote a test application to compare the field-symbol assignment and the assignment with value (with optional extension), and yes it works as fast as field symbol assignment and with no short dumps. Once again, thank you very much.
I'm a legacy pre 7.4 ABAP developer learning 7.5 syntaxes. Very well presented.
Thanks Raghu :-)
Always waiting for your videos. So that i can rewrite my existing lengthy code 😁😁🙏
Glad to know that Gagan.. Thanks for watching.. :-)
Very well explained !!! Looking for some more on similar Topic in SAP ABAP 7.50
Helping information,keep posting
Thanks Pradip... :-) keep watching:-)
Superb Suraj..Salute to u for sharing n helping other..appreciat👍
Thanks Majid. Glad that you like it.. :-)
Great insights Sooraj. Thanks! Keep uploading these useful videos
Thanks Anil.. Keep watching:-)
Great video, sirji
Very useful helping information
Like the way you explain. Thank you!
Well explained. Keep going!
Very nice video, greetings from Brazil
Great content👍.... Keep posting
Thank you, I will
Awesome content Sooraj!
Thank for your good info.....we are waiting for more updates in new syntaxes
Thanks and stay tuned.. :)
Short video with lots of knowledge... Would like to see many more
More to come! Thank you :)
Your ABAP 7.4 syntaxes are helping me alot in my coding .....thank you so much 🙂
Thanks Nikhil.. Keep watching:-)
Nice Suraj.
great learning... thank you 👏
Hi sooraj,
Great information and thanks for the sharing 😀😀😀
Glad that you liked it Vijay :-)
Really simple...easy to learn ....thanks a lot
Thank you Hiranmaye.. Keep watching :-)
Awesome Suraj। Thanks for updating 😊
Good job!
Very nicely explained.
Thank you so much Sir for your time and efforts
Thanks Abhishek..Keep watching, will try to upload more videos. :-)
Useful thanks!
Glad that it could help you.. :-)
Thanks for the video Sooraj, really useful.
Can you tell what's the performance of instructions like line_exists compared to binary search in large tables? Would you recomend it there?
Thanks
Useful. Thanks.
Glad that it helped you :-)
Well explained Sooraj !
Thank you Rahul.. :-)
Thank you, great video.
Glad it helped
great work, thanks.
Thanku Katja :-)
Hi, is the new syntax sequential read or binary read? I am thinking we need to be careful based on the size of your table?
Thanks Happy Diwali Sir 🙏. I have learned new syntaxes in ABAP. It's really helpful and overall it's free. Thanks & Please do continue Sir.
Very nice👍
Thank you! Cheers!
Thank you for detail explaination👍
great video ...easy to understand
Thanks man
thanks sooraj!
You are welcome Pavan.. :-)
great content bro
Thank you Virgilio.. :-)
Very useful video
Nice video
Great work... Thanks
👍🏼 very helpful
Great tips. Thank you so much
VERY NICE BRO , THANKS
Great job
Thank you
Hi sooraj . Are these syntaxes used in HANA ABAP coding ?
Nice video. Could you make a video on abap units with practical examples
Nice
thanks learned a lot
Glad it helped
Your modifying single entry. Can you post example of looping one table and reading 2nd table to Modify first table basing on index.
Can post an example on that with latest syntax.
Thanks.
Noted :-)
amazing .. so simple
Glad you like it!
@@SoorajSasidharanABAP i was searching for new techniques in abap to be updates then I found your channel, even some things i m using already line new inline declaration ...many of abapers dont know about it...they just following old stuff.
@@ajitmhatre9 haha that's very correct. you see change is inevitable :) Coding in the same way is boring :D
Can you discuss something related to Amdp's and some typical solutions in HANA
Noted.. :-)
What is the performance of this array like internal table access compared to hash table read/ binary search table read?
in case of sorted/hashed tables, there will be implicit BINARY search happening. We cannot use an explicit BINARY SEARCH addition with the new syntax.
Are there any Loop...EndLoop example with a new sintaxe ?
Can u see if this video helps?
ua-cam.com/video/WPNcz7nXQQg/v-deo.html
You can check out my other videos as well.. Thanks for watching.. :-)
Thankyou so much...can u post videos on abap -json conversion
superb explinations sir...can u explain explicit enhancements by real time examples
Thanks Harish.. will try to.. :-)
How about read with binary search in parallel cursor..how to exit loop in new syntax??please let us know
In case of sorted tables, there is an implicit BINARY SEARCH that happens. We cannot forcefully include the BINARY SEARCH option with the new syntax though :-)
Hi watched..but we can also use the below new syntax to avoid try catch block...
Data(ls_line) = VALUE #( LT_TAB[ key = value ] OPTIONAL/DEFAULT ).
In this we don't have to handle exception...also for addition of DEFAULT - you can give default value also if read fails... Also one more point in new syntax it always go for linear search , first it will check the table type ( if sorted table used then only perform binary) then do accordingly....
Hi Suman, I had already explained this in my VALUE operator video. :-) Thanks for your comment :)
is CL_DEMO_OUTPUT=>write( ) and CL_DEMO_OUTPUT=>display( ) different?
what about performance ? is it better than a Read Table ? can you Binary Seach somehow ?
We cannot use a forced BINARY SEARCH addition.. But if the table is a sorted table, it does an implicit Binary Search as per my understanding :-)
how to populate all entries from another internal table using value operator?
despite to simplify the code, what is the gain using this new code ?
Can you please post video's on RICEF object's
Noted.. :-)
how loop will work .pls explain
how to give OR condition in Try catch block
Suraj, what is the future for ABAPer?
there will be ABAPer as long as there is SAP :D
Difference between cl_demo_output=>write andcl_demo_output=>display
its just for displaying the contents as output. I use write before display so that both the outputs are on the same screen :)
Please dont use this class in productive version :)
Suraj, please zoom when u r displaying the code and thanks a lot
ABAP 7.4/7
5 read statement perform linear search not binary search
For sorted tables it does perform an implicit binary search as per
my understanding. We cannot use the extra keyword BINARY SEARCH with the new syntax.
9:45
TYPES: BEGIN OF ty_data,
name TYPE char20,
role TYPE char20,
END OF ty_data.
DATA: it_data TYPE STANDARD TABLE OF ty_data.
it_data = VALUE #( ( name = 'Ken' role = 'java' )
( name = 'Rom' role = 'abap' )
( name = 'Ben' role = 'c++' )
).
DATA(lv_index) = line_index( it_data[ name = 'Ken' ] ).
WRITE: / lv_index.
TYPES: BEGIN OF ty_data,
name TYPE char20,
role TYPE char20,
END OF ty_data.
DATA: it_data TYPE STANDARD TABLE OF ty_data.
it_data = VALUE #( ( name = 'Ken' role = 'java' )
( name = 'Rom' role = 'abap' )
( name = 'Ben' role = 'c++' )
).
cl_demo_output=>display( it_data ).
3:00
TYPES: BEGIN OF ty_data,
name TYPE char20,
role TYPE char20,
END OF ty_data.
DATA: it_data TYPE STANDARD TABLE OF ty_data.
it_data = VALUE #( ( name = 'Ken' role = 'java' )
( name = 'Rom' role = 'abap' )
( name = 'Ben' role = 'c++' )
).
Data(result) = it_data[ name = 'Ben' ]. "inside [ ] key the column name
WRITE: / result.
4:00
5:00
TYPES: BEGIN OF ty_data,
name TYPE char20,
role TYPE char20,
END OF ty_data.
DATA: it_data TYPE STANDARD TABLE OF ty_data.
it_data = VALUE #( ( name = 'Ken' role = 'java' )
( name = 'Rom' role = 'abap' )
( name = 'Ben' role = 'c++' )
).
DATA(result) = it_data[ name = 'Ben' ].
DATA(result1) = it_data[ name = 'Ben' ]-role.
DATA: result2 TYPE char20.
result2 = it_data[ name = 'Ben' ]-name.
WRITE: / 'result =', result.
WRITE: / 'result 1 =', result1.
WRITE: / 'result 2 =', result2.
6:00
TYPES: BEGIN OF ty_data,
name TYPE char20,
role TYPE char20,
END OF ty_data.
DATA: it_data TYPE STANDARD TABLE OF ty_data.
it_data = VALUE #( ( name = 'Ken' role = 'java' )
( name = 'Rom' role = 'abap' )
( name = 'Ben' role = 'c++' )
).
TRY.
DATA(result_try) = it_data[ name = 'Malvina' ]. "dump without try!
CATCH cx_sy_itab_line_not_found.
WRITE: / 'Not found!'.
ENDTRY.
7:30
TYPES: BEGIN OF ty_data,
name TYPE char20,
role TYPE char20,
END OF ty_data.
DATA: it_data TYPE STANDARD TABLE OF ty_data.
it_data = VALUE #( ( name = 'Ken' role = 'java' )
( name = 'Rom' role = 'abap' )
( name = 'Ben' role = 'c++' )
).
IF line_exists( it_data[ name = 'ken' ] ).
WRITE: / 'The value exists.'.
ELSE.
WRITE: / 'Sorry, not found.'.
ENDIF.
IF line_exists( it_data[ name = 'Ken' ] ).
WRITE: / 'The value exists.'.
ELSE.
WRITE: / 'Sorry, not found.'.
ENDIF.
Read with binary search runs faster than this