Optimize your ABAP Code
Most ABAP Z-programs have one complaint. That is ‘ sloooowwww ‘ . Yeah it’s true . But most of the slandered programs are slow too. But did u check why it takes soo much time.
The looking after Intimates planning tool is my major task at MAS. The previous planing tool was done by Attune. Which had the same defect. So they used two planing tools. Later the users were not happy with it and want a single tool with lots of lots of new features.
Harshana did most of the initial coding and left the country ( Now I know why
) . It was working fine on development server . even on Production server it was working fine. Two weeks later the first complain came from LC. Their band width was low and we thought that was the issue. Well thats one but they have been using the faster version of the previous tool and comparing to that it was slow.
Another week passed now everyone was complaining that the tool is slow. damn it !!! it takes about 30min to load. so I have to think again about optimizing . These are the bottlenecks i found . Which anyone wouldn’t consider as speed eating demons !!
1. Table joins
Always try to use keys for your table join. Try to join using from the top level to the bottom level of the table structure. Even if you feel its slow try changing the order.
2. Use Internal tables
Internal table is your buddy!!! . Always store data in the itab which is not changing rapidly by other parties. If you see a table is accessed frequently get all the necessary data into itab. But remember try to get only required . ‘ Select * ‘ is a bad idea
3. Use hash table when possible
Hash tables are much farter than Sorted tables or slandered tables. It stores data with keys and uses hash algorithm . But the major disadvantage is you cant loop through it. Or use ‘BINARY SEARCH’ after ‘READ TABLE’ statement.
4. Do not use ‘Order by’
Do not use order by for large tables. take the data into an itab and use ‘SORT BY’ to sort the data.
5. ALV issues.
Please fine tune your ALV. Do not use dropdowns if its not so important. Use re-usable handles instead. Better option is Hotspots.
Can you believe only doing these things I could reduce the loading time from 30 min to 30 sec !!!!!!
-
Posted by admin on February 17th, 2008 filed in SAP, ABAP | Comment now »
Function Module to send emails using SAP / ABAP
Since the day I got into my company there wasn’t a proper way of alerting people . Most of them were trying the mail sending codes on the net but they were not lucky enough to find out a working one. But here is solution which had worked finally.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | FUNCTION ZSENDMAIL. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" REFERENCE(SUBJECT) TYPE SO_OBJ_DES *" REFERENCE(P_TTEXT) TYPE BCSY_TEXT *" REFERENCE(I_TO) TYPE ADR6-SMTP_ADDR *" REFERENCE(I_FROM) LIKE SY-UNAME OPTIONAL *" REFERENCE(SEND_IMMD) TYPE C OPTIONAL *" REFERENCE(I_TYPE) TYPE SO_OBJ_TYP OPTIONAL *"---------------------------------------------------------------------- DATA: send_request TYPE REF TO cl_bcs, document TYPE REF TO cl_document_bcs, sender TYPE REF TO cl_sapuser_bcs, recipient TYPE REF TO if_recipient_bcs, xirecipient TYPE REF TO cl_xi_mail_recipient, bcs_exception TYPE REF TO cx_bcs, sent_to_all TYPE os_boolean, uname TYPE xubname, state TYPE alautoemail, r3syst TYPE sysysid, dest TYPE ad_symbdst, client TYPE ad_umand, nrecip TYPE i, sep_mail. DATA: line TYPE soli, subject2 TYPE so_obj_des, e_mail(50). CONSTANTS: comm_smtp TYPE so_comtype VALUE 'INT'. TRY. *--- create and set document document = cl_document_bcs=>create_document( i_type = i_type "see table TSOTD i_subject = subject * I_LENGTH = * I_LANGUAGE = SPACE i_importance = '5' "1 = high,5 = normal,9 = low i_sensitivity = '0' "standard i_text = p_ttext * I_HEX = * I_HEADER = * I_SENDER = ). *--- prevent dumps due to empty document IF document IS INITIAL. EXIT. ENDIF. *--- create persistent send request send_request = cl_bcs=>create_persistent( ). *--- add document to send request send_request->set_document( document ). *--- set sender if i_from is initial. sender = cl_sapuser_bcs=>create( sy-uname ). else. sender = cl_sapuser_bcs=>create( i_from ). endif. send_request->set_sender( sender ). *--- add recipients (e-mail, SMS, ... addresses) recipient = cl_cam_address_bcs=>create_internet_address( i_address_string = i_to ). send_request->add_recipient( i_recipient = recipient i_express = 'X' ) . if send_immd is not initial. send_request->set_send_immediately( 'X' ). endif. *--- send document sent_to_all = send_request->send( ). IF sent_to_all <> 'X'. "not ok EXIT. ENDIF. COMMIT WORK. "!!! *---exception handling CATCH cx_bcs INTO bcs_exception. WRITE bcs_exception->error_type. EXIT. ENDTRY. ENDFUNCTION. |
-
Posted by admin on February 17th, 2008 filed in SAP, ABAP | Comment now »
“Empty” - Full stop for tragic stories
Ahh .. finally after quite a long time .. well I was busy .. Really busy .. Having the best days of my life . But suddenly seems like it has change .. otherwise why I am writing here. But I guess this would be my final tragic story
since i’ll be moving to a Diary
I was feeling lucky .. I was overjoyed with my life .Yes after a rough time I was feeling good . After 2002 I was actually feeling living. Had a quite a balance with everything in my life and work ( hope Nayana wont see this
) . I was hitting my head on everything I can think of like the good old times and succeeded in almost everything. Did some amazing discoveries in SAP ( I’ll write about them soon ) . and getting ready to write first ever AJAX powered SAP Planing tool with unlimited GUI Possibilities. My first six months at MAS SAP was bit hard with Intimates planing tool . Praveen and I had some hard times dealing with the issues we had.
Time passes .. seasons change .. I think I am on a little break for my joyful life. No choice . Like always its going to be Silicon and me again ..
Please hold on for my findings on SAP .. I am back again at blogging world .. !!!!!!!!!!!!
Empty
PS:- don’t worry about adding comments .. I’ll delete them
-
Posted by admin on January 24th, 2008 filed in Uncategorized | Comment now »
Dynamic titile bars for Dynapro window ABAP
After long silance I want to write about ABAP development. For first one i choosed to write a very simple thing but most interested in by lot of ABAPers.
When we want to use dynamic title bars for dynapro its not a very hard thing to do. SAP help has the describe it but less information.
First you have to create a new title along with &1 &2 … &9 for the places you want to add dynamic text. You can have upto 9 texts like this.
Then at PBO level.
1 | Set titlebar 'TITLEBAR_100' with p1 p2. |
p1 p2 is char(n) type variables.
-
Posted by admin on December 13th, 2007 filed in SAP, ABAP | Comment now »
See the future - Part 2
With this post i will discuss about illutions .
Every one sees future with their own eyes . You see future as a dream at night . And then when you encountered the same visual again the first thing pops in to your mind is “Hey I’ve seen this somewhere ” . Sometimes you get to know people and before you meet them you feel close to them. Everybody has this experience . Don;t try to say no.
But how is this possible . Some says this is not a actual thing . Suddenly your brain thinks that some incident is more close to your self and thinks that he has seen it in his dreams.
In most religons it belives your mind can travel in great speed. According to Albert Einsties theories if something moves in speed of light then that person can see beyond the time. If our mind can travel at that speed why can’t it conquer time. Please remember that I am not talking about think about a place you have been. It just acessing data store of your brain.
When one develops his mind up to cirtain level some people were able to tell about the past of some objects by touching them. First I was thought “what a stupid idea ” And that’s only untill i get my flash drive. We use meterials to store information. So why can’t we thing the objects we touch store information arounds it.
-
Posted by admin on November 17th, 2007 filed in Uncategorized | Comment now »
House Season 4 Begins : Some People better left alone
Hmm the last week of September was an amazing week end. Soon after I came from Habarana I ran to my computer to download newest TV series. Prison break , Heroes , House , Numbers and Stargate atlantis was among the new season release of this month.
You might wonder why I have chosen “House MD” Series to write comment about. Well House’s character and behaviour made me to write something about him. House has an attitude to think he is always right and the mades wild guesses which is more to be true at the end. This drama was driving me crazy coz its like watching 21st centuary Sherloc Holmes. He tooks every case as another problem needs an answer and try to solve it. Numbers has the same characteristics . But when everytime I watch Numbers I feel like alien science. But not with House.
In the last season entire House’s crew left him. Dr. Forman resigns from the crew telling ” I don’t want to be House” . and he fires Dr. Chace . Dr. Camron decides to leave . and house was left alone . and he says he doesnt’ need any one.
a ctually he is right some times you feel good , safe with no one around you. and the thing matters to you is only the job you do .. a job that would make you really really happy.
-
Posted by admin on November 17th, 2007 filed in TV | Comment now »
MSN video using flash ?
Today I noticed something I never expected that microsoft will ever do. They have replaced their MSN video player which was using media player extention to flash player. Does that means microsoft finally agree that their streaming solution is bad ? Bad news for other people who are using windows media player to show videos on their website.
-
Posted by admin on August 21st, 2007 filed in Microsoft | 1 Comment »
See the Future - Part 1
Everyody likes to know what they will become. Everybody want to know will he be rich or poor. Everybody wants to see the future.
Horoscopes are the most widely used way of “predicting” the future . It will tell you most things about your life . But is it really accurate ? . Astrology is based on Maths . Math cannot be wrong . So then it should define your future accuratlely.
I got the chance to readout old astrology books . And noticed one thing . That all these predictions were based on Knowledge base which has been adding from thousand of years. Each planet denotes some part of human emotion. and emotions may change due to time . so all you have to do is draw a graph each emotion with their strenghths according to time.
So this is how to analyse this. Ok lets say E1 is your wealth. Wealth changes due to your education ( any kind of ) , the freedom of your mind and health. So E1 should vary on these facts. So if the planets can tell your emotional facts and you can predict the “Planets” using a network diagram you can think of what you will become. The ratio of each planet’s streangth match to a thousand years aged knowledgebase you can guessed what will happen.
So if you are so much interesting in discovering the truth rate yourself and put in to a graph or network flow and see for your self.
I must say this post is not to say astrology is wrong . I was just explaining how it can happen. But now i must say some thing about most astrological softwares and small predictions on sunday news papers . I have noticed that these predictions are genaral and if you forget your zodiac sign by any chance every prediction may feel relevant to you. In google IG portlet this is a very common thing.
-
Posted by admin on August 19th, 2007 filed in Uncategorized | 1 Comment »
21 years on planet earth
This post is for my 21st birthday
Yeah now i am concidered as full adult. But still I dnt feel it that way ..hmm anyway let me tell you how i spent 21 years.
My birth is a kind a extraordinary experience to my family. I was the first one to born in Colombo. My mother had to go through a surgery because i coulnt have a normal birth. Coz i would die ( I wish ). Naming me was a caios . coz they couldnt find a better name starting with “ke”. My mother want to name me as “Kevin” coz it was her some uncle’s name or what . But then father found a good name “Kesan” (meaning - the little stat who searches for a brighter light ) . But due to pronusing reasons it turned to “Keshan”.
My parents were moved from kandy to colombo . Finding a good school was not that easy. So i had to start with a small school . From grade 1 my target was grade 5 scholarship. So I can go to a good collage .. and I did . But it was the most stupidest thing I have done. and paasing OL’s with good results is the second stupid move.
Untill 2003 my life was rocking . There was no chalenge to me. I was really good at what i am good at. Everybody knew about me . then something happened. I started to realize i wasnt gaining the return I should get to what i do. I was starting to loose competitons . I lost most things that I wanted in my life just before my eyes.
The only thing I learnt from living 21 years is that never trust anyone. People don’t take ages to turn down on you. So now I don’t trust anyone not even me. Just in a snap u realize you dnt have ur parents , friends , loved ones and anyone around you if you are not the “One”.
Most of the times I tresuered What I don’t have . But when i lost everything and only one thing i have left on my hand. I am tring to save that with all my efforts , If I loose that I really don’t know what i will become ..
-
Posted by admin on August 10th, 2007 filed in Uncategorized | 4 Comments »
Better than me
Last night when i was watching TV I saw the video of Hinder’s Better than me video. After watching it I want to go through the lyrics. This part really took the attention of me.
But I remembered,
What it feels like beside you
I really miss your hair in my face
And the way your innocence tastes
And I think you should know this
You deserve much better than me
-
Posted by admin on July 22nd, 2007 filed in Uncategorized | Comment now »