2014 Aug 26 8:24 PM
i have to optimize colored line any one heaving idea? Please rply ..
SELECT * FROM zsng2g_pkt_eh
INTO TABLE gt_pkt_eh
WHERE ZSNG2G_ENC_TYPE = gv_par_val_enc
AND ZSNG2G_EPC_CLASS = gv_par_val_epc
AND ZSNG2G_PACKET_LEVEL = '03'
AND ZSNG2G_REQUESTID = gv_id.
**-- selecting all the sn for give packet type list
SELECT eh_guid ZSNG2G_SN_SERIAL_NUMBER ZSNG2G_SN_COUNTER FROM zsng2g_sn_eh
INTO TABLE lt_sn_eh
WHERE ZSNG2G_SN_ENCODING_TYPE = gv_par_val_epc
AND ZSNG2G_SN_EPCCLASS = gv_par_val_enc.
* AND ZSNG2G_SN_COUNTER ge gt_pkt_ehx-ZSNG2G_RANGE_START
* AND ZSNG2G_SN_COUNTER le gt_pkt_ehx-ZSNG2G_RANGE_END.
*--Filling tbl_range
LOOP AT gt_pkt_eh into ls_pkt_eh. "where ZSNG2G_PACKET_TYPE = 'RANGE'.
if ls_pkt_eh-ZSNG2G_PACKET_TYPE = 'RANGE'.
ls_RANGE-RANGE_FROM = ls_pkt_eh-ZSNG2G_RANGE_START.
ls_RANGE-RANGE_TO = ls_pkt_eh-ZSNG2G_RANGE_END.
APPEND ls_range to lt_range.
ELSEif ls_pkt_eh-ZSNG2G_PACKET_TYPE = 'LIST' .
*--Fill tbl_list
LOOP AT lt_sn_eh into ls_sn_eh where ZSNG2G_SN_COUNTER ge ls_pkt_eh-ZSNG2G_RANGE_START and
ZSNG2G_SN_COUNTER le ls_pkt_eh-ZSNG2G_RANGE_END.
ls_list-TABLE_LIST = ls_sn_eh-ZSNG2G_SN_SERIAL_NUMBER.
APPEND ls_list to lt_list.
clear ls_list.
ENDLOOP.
2014 Aug 27 1:36 PM
Hi Manisha,
I just modified the colored code, just try this in your system and see any performance
1. Declare one more field flag type c in lt_sn_eh
2. Declare internal table lt_sn_eh as i mentioned
data lt_sn_eh type TABLE OF xxxxx with NON-UNIQUE SORTED KEY sn_counter COMPONENTS zsng2g_sn_counter.
*--Filling tbl_range
ls_sn_eh-flag = abap_true. " to make required entries
LOOP AT gt_pkt_eh INTO ls_pkt_eh. "where ZSNG2G_PACKET_TYPE = 'RANGE'.
IF ls_pkt_eh-zsng2g_packet_type = 'RANGE'.
ls_range-range_from = ls_pkt_eh-zsng2g_range_start.
ls_range-range_to = ls_pkt_eh-zsng2g_range_end.
APPEND ls_range TO lt_range.
ELSEIF ls_pkt_eh-zsng2g_packet_type = 'LIST' .
*--Fill tbl_list
MODIFY lt_sn_eh FROM ls_sn_eh USING KEY sn_counter TRANSPORTING flag WHERE zsng2g_sn_counter GE ls_pkt_eh-zsng2g_range_start AND
zsng2g_sn_counter LE ls_pkt_eh-zsng2g_range_end.
ENDIF.
ENDLOOP.
LOOP AT lt_sn_eh ASSIGNING <fs_sn_eh> USING KEY sn_counter.
if <fs_sn_eh>-flag = abap_true.
ls_list-table_list = ls_sn_eh-zsng2g_sn_serial_number.
APPEND ls_list TO lt_list.
CLEAR ls_list.
endif.
ENDLOOP.
2014 Aug 26 11:21 PM
2014 Aug 26 11:24 PM
2014 Aug 27 3:14 AM
in second loop it has condition.in parallel cursor method how to implement this becaz read is not possible with le and ge operator
2014 Aug 27 2:47 AM
Hi,
That coloured piece of code just loops at one internal table and fills another.
I can't imagine that it would have any significant effect on performance.
I think you're focusing on the wrong ABAP statements. Have you done a performance trace?
cheers
Paul
2014 Aug 27 3:14 AM
in second loop it has condition.in parallel cursor method how to implement this becaz read is not possible with le and ge operator
2014 Aug 27 12:21 PM
Like I said, that's not where your performance problem is.
cheers
Paul
2014 Aug 27 12:32 PM
Hi Manisha,
Try this.
Instead of work area declare field symbols.
Field symbols: <fs> like line of gt_pkt_eh.
LOOP AT gt_pkt_eh ASSIGNING <fs>.
CHECK ( <fs>-PACKET_TYPE = 'RANGE' OR
<fs>-PACKET_TYPE = 'LIST' ).
ENDLOOP.
Regards,
Venkat.
2014 Aug 27 12:55 PM
As per
SAP Documentation
CASE statements are clearer and a little faster than
IF-constructions.
Regards,
Avirat
2014 Aug 27 1:03 PM
Avirat Patel wrote:
As per SAP Documentation
CASE statements are clearer and a little faster than
IF-constructions.
Which SAP documentation?
"Clearer", agreed. "Faster", don't agree unless someone posts detailed runtime analysis.
2014 Aug 27 1:20 PM
2014 Aug 27 1:23 PM
What does the "Measure runtime" tell you? Do you see any appreciable difference in runtimes?
2014 Aug 27 1:32 PM
May be it works well where huge amount of data is available. and if It does not then why SAP has mentioned this note [Raising eyebrow].
if you know [you are a gem and i'm following you/your post always] kindly tell me .
2014 Aug 27 1:33 PM
That's the age-old SE80 performance examples...my results:
IF: 0 microseconds
CASE: 0 microseconds
It seems that CPU-Power has increased somewhat since the tests were designed (15 years ago?)
Thomas
2014 Aug 27 1:39 PM
It means that SAP has not upgrade its old age documentation?
2014 Aug 27 1:41 PM
That's the age-old SE80 performance examples...my results:
They are still available on the latest runtime analysis tool - SAT
2014 Aug 27 1:43 PM
Avirat Patel wrote:
It means that SAP has not upgrade its old age documentation?
Yeah! SAP & documentation, that's been on every ABAPer wishlist ad infinitum.
2014 Aug 27 1:48 PM
In that case we have to strongly follow gurus (Suhas & Thomas Z)
and getting valuable tips & tricks
2014 Aug 27 1:50 PM
Correct, there is a few examples for this. Doesn't make it easier to combat some of the "urban legends"...
In general, I would always look for significant differences when comparing runtimes and adjusting code (especially when code becomes more complex this way). Definition of "significant" might vary based on circumstances, but a few percent is not worth any effort in most cases.
The biggest performance hazards in my experience is still access to large data (DB or internal table) without index support, even more so when done in loops, and excessive memory usage (paging to disk).
Thomas
2014 Aug 27 1:50 PM
Avirat Patel wrote:
May be it works well where huge amount of data is available. and if It does not then why SAP has mentioned this note [Raising eyebrow].
What do you mean by huge amount of data in an IF...ENDIF or CASE..ENDCASE block?
I don't know why SAP has mentioned this note. It's also mentioned in the - ABAP Keyword Documentation. But i have never seen a piece of code being slower because of IF-blocks. Maybe they contribute a few additional microseconds in the "System" runtime, but i wouldn't mind correcting those.
2014 Aug 27 1:53 PM
Even better, follow your own observations, but make sure your test setups are correct.
Thomas
2014 Aug 27 3:37 PM
My result: Case is little faster more often. It won't be called a significant difference though.
/.
2014 Aug 27 3:51 PM
Good one
But how much is the difference in runtime if you reduce the number of WHEN- & the ELSEIF- blocks to (a more practical) value of 5 for example 🙂
2014 Aug 27 3:57 PM
Conditions 13 and 17 seem to run a little slower than the others, that's probably because the kernel performs a localisation check, moving to 14 and 18 respectively in countries where the former numbers are considered unlucky.
Otherwise a great-looking piece of code!
Thomas
2014 Aug 27 3:59 PM
IF 5 blocks are used, difference may be littler in that CASE.
2014 Aug 27 4:17 PM
2014 Aug 27 1:36 PM
Hi Manisha,
I just modified the colored code, just try this in your system and see any performance
1. Declare one more field flag type c in lt_sn_eh
2. Declare internal table lt_sn_eh as i mentioned
data lt_sn_eh type TABLE OF xxxxx with NON-UNIQUE SORTED KEY sn_counter COMPONENTS zsng2g_sn_counter.
*--Filling tbl_range
ls_sn_eh-flag = abap_true. " to make required entries
LOOP AT gt_pkt_eh INTO ls_pkt_eh. "where ZSNG2G_PACKET_TYPE = 'RANGE'.
IF ls_pkt_eh-zsng2g_packet_type = 'RANGE'.
ls_range-range_from = ls_pkt_eh-zsng2g_range_start.
ls_range-range_to = ls_pkt_eh-zsng2g_range_end.
APPEND ls_range TO lt_range.
ELSEIF ls_pkt_eh-zsng2g_packet_type = 'LIST' .
*--Fill tbl_list
MODIFY lt_sn_eh FROM ls_sn_eh USING KEY sn_counter TRANSPORTING flag WHERE zsng2g_sn_counter GE ls_pkt_eh-zsng2g_range_start AND
zsng2g_sn_counter LE ls_pkt_eh-zsng2g_range_end.
ENDIF.
ENDLOOP.
LOOP AT lt_sn_eh ASSIGNING <fs_sn_eh> USING KEY sn_counter.
if <fs_sn_eh>-flag = abap_true.
ls_list-table_list = ls_sn_eh-zsng2g_sn_serial_number.
APPEND ls_list TO lt_list.
CLEAR ls_list.
endif.
ENDLOOP.