Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Covert into CASE ENDCASE

Former Member
0 Kudos

Hi,

How to convert into CASE & ENDCASE logic the below code:

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

2 REPLIES 2

matt
Active Contributor
0 Kudos
CASE sy-subrc.
  WHEN  0.

matt

Former Member
0 Kudos

Hi,

I do not see the real advantage of case in the above code. What I notice is a DB select within a loop which can easily be avoided using FOR ALL ENTRIES IN clause.

I am not sure what you want to achieve, but the code seems to be DB extensive.

Regards,

Saurabh