‎2008 Jun 17 12:07 AM
Hi,
LOOP AT lt_element INTO ls_element.
READ TABLE lt_element_ident INTO ls_element_ident
WITH KEY element_id = ls_element-element_id BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE ls_element_ident-value TO lv_guid.
SELECT * FROM zcm_valuation_at
APPENDING CORRESPONDING FIELDS OF TABLE lt_caseattributes
WHERE case_guid = lv_guid.
ENDIF.
ENDLOOP.
***
LOOP AT lt_caseattributes INTO ls_caseattributes.
IF ls_caseattributes-ext_key IS INITIAL.
SELECT SINGLE ext_key
INTO CORRESPONDING FIELDS OF ls_caseattributes
FROM scmg_t_case_attr
WHERE case_guid = ls_caseattributes-case_guid.
ENDIF.
*To get the Status description of the Case
SELECT SINGLE stat_ordno_descr
INTO ls_caseattributes-status
FROM scmgstatprofst AS a
INNER JOIN scmg_t_case_attr AS b
ON aprofile_id = bprofile_id
AND astat_orderno = bstat_orderno
WHERE case_guid = ls_caseattributes-case_guid.
MODIFY lt_caseattributes FROM ls_caseattributes INDEX sy-tabix TRANSPORTING status ext_key.
ENDLOOP.
READ TABLE lt_caseattributes INTO ls_caseattributes INDEX 1.
Regards,
Maruti
‎2008 Jun 17 12:19 AM
hi try to remove the into corresponding and appending corresponding..in the selects.. select * is never prefered in many client locations.. so try to remove it as well..
looks like u are using binary search for read that good.. to have and rest looks gud..
‎2008 Jun 17 12:39 AM
LOOP AT lt_element INTO ls_element.
READ TABLE lt_element_ident INTO ls_element_ident
WITH KEY element_id = ls_element-element_id BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE ls_element_ident-value TO lv_guid.
SELECT * FROM zcm_valuation_at
APPENDING CORRESPONDING FIELDS OF TABLE lt_caseattributes
WHERE case_guid = lv_guid.
ENDIF.
ENDLOOP.
***
LOOP AT lt_caseattributes INTO ls_caseattributes. ---> HERE ADD A WHERE STM*
LOOP AT lt_caseattributes INTO ls_caseattributes WHERE ext_key EQ = ''
IF ls_caseattributes-ext_key IS INITIAL. --> DELETE THIS
SELECT SINGLE ext_key
INTO CORRESPONDING FIELDS OF ls_caseattributes
FROM scmg_t_case_attr
WHERE case_guid = ls_caseattributes-case_guid.
ENDIF. --> DELETE THIS
*To get the Status description of the Case
SELECT SINGLE stat_ordno_descr
INTO ls_caseattributes-status
FROM scmgstatprofst AS a
INNER JOIN scmg_t_case_attr AS b
ON aprofile_id = bprofile_id
AND astat_orderno = bstat_orderno
WHERE case_guid = ls_caseattributes-case_guid.
MODIFY lt_caseattributes FROM ls_caseattributes INDEX sy-tabix TRANSPORTING status ext_key.
ENDLOOP.
READ TABLE lt_caseattributes INTO ls_caseattributes INDEX 1.
ALSO AVOID INTO CORRESPONDING...NESTED LOOPS ALSO!!!
bye
Gabriel P-
Edited by: Gabriel Fernando Pulido V. on Jun 16, 2008 6:39 PM
‎2008 Jun 17 7:31 AM
Hi,
try this kind of code:
==================================
***********
start new
*********
DATA:
lt_scmgstatprofst LIKE scmgstatprofst OCCURS 0 WITH HEADER LINE,
wa_scmg_t_case_attr LIKE scmg_t_case_attr.
SELECT * FROM scmgstatprofst INTO TABLE lt_scmgstatprofst.
SORT lt_scmgstatprofst BY profile_id stat_orderno.
*********
end new
*******
LOOP AT lt_element INTO ls_element.
READ TABLE lt_element_ident INTO ls_element_ident
WITH KEY element_id = ls_element-element_id BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE ls_element_ident-value TO lv_guid.
SELECT * FROM zcm_valuation_at
APPENDING CORRESPONDING FIELDS OF TABLE lt_caseattributes
WHERE case_guid = lv_guid.
ENDIF.
ENDLOOP.
***
LOOP AT lt_caseattributes INTO ls_caseattributes.
IF ls_caseattributes-ext_key IS INITIAL.
SELECT SINGLE ext_key
INTO CORRESPONDING FIELDS OF ls_caseattributes
FROM scmg_t_case_attr
WHERE case_guid = ls_caseattributes-case_guid.
ENDIF.
*To get the Status description of the Case
**************
start deletion
**************
SELECT SINGLE stat_ordno_descr
INTO ls_caseattributes-status
FROM scmgstatprofst AS a
INNER JOIN scmg_t_case_attr AS b
ON aprofile_id = bprofile_id
AND astat_orderno = bstat_orderno
WHERE case_guid = ls_caseattributes-case_guid.
************
end deletion
************
***********
start new
*********
CLEAR wa_scmg_t_case_attr.
SELECT SINGLE * FROM scmg_t_case_attr INTO wa_scmg_t_case_attr
WHERE case_guid = ls_caseattributes-case_guid.
READ TABLE lt_scmgstatprofst WITH KEY
profile_id = wa_scmg_t_case_attr-profile_id
stat_orderno = wa_scmg_t_case_attr-stat_orderno
BINARY SEARCH.
IF sy-subrc IS INITIAL.
ls_caseattributes-status = lt_scmgstatprofst-stat_ordno_descr.
ENDIF.
*********
end new
*******
MODIFY lt_caseattributes FROM ls_caseattributes INDEX sy-tabix
TRANSPORTING status ext_key.
ENDLOOP.
READ TABLE lt_caseattributes INTO ls_caseattributes INDEX 1.
==================================
Regards
Walter Habich
Edited by: Walter Habich on Jun 17, 2008 8:41 AM
‎2008 Jun 17 7:38 AM
Hi,
Try to remove select statements from the loop.
instead select values in internal table first and then use that internal table in loop for modify or append.
Instead of corresponding fields use to table and try to use for all entries in select statement.
Reward pts if usefull
Regards,
Dhan
‎2008 Jun 17 7:50 AM
Hi,
To improve performance :
1. Replace Select * by Select fields.....
2. Sort table before using Read table along with binary search.
3. Use INTO TABLE instead of APPENDING CORRESPONDING FIELDS OF TABLE and for INTO CORRESPONDING FIELDS OF also.
4. We can use FOR ALL ENTRIES instead of Join depending on the case.
5. Try to give all possible conditions in Where clause of Select statement and even ordering is important.
6. Try to remove Select inside the Loop.
Hope this will help you.
Plz reward if useful.
Thanks,
Dhanashri.
Edited by: Dhanashri Pawar on Jun 17, 2008 8:50 AM