메뉴 건너뛰기

SAP 한국 커뮤니티

where 조건을 상황에따라 바꿔볼까?

양키 2011.04.14 09:49 조회 수 : 8739

Query를 하다보면 조건문이 고정적일수도 있지만

상황에따라 다른 조건문을 붙여써야할경우가 생깁니다.

 

물론 이런경우 if문으로 전체쿼리를 분개시키는경우도 많이 보았습니다.

그것보다는 가독성 측면에서 아래와같이 써보면 어떨까 싶습니다.

 

* Where Condition
DATA where_clause Type String,
       and(4),
       or(4).
and ' AND'.
or ' OR'.

 

"Field1은 and조건의 데이타
if field1 is not initial
  CONCATENATE where_clause and ' field1 LIKE ''FF%''' INTO where_clause.
endif.

 

"Field2는 OR조건의 데이타
if field2 is not initial.
  CONCATENATE where_clause or ' field2 LIKE ''EE%''' INTO where_clause.
endif.


  SELECT test1 test2 test3

    INTO CORRESPONDING FIELDS OF TABLE IT_TEST

    FROM ZTEST
    WHERE field1 = 'X'

     (where_clause).  

번호 제목 글쓴이 날짜 조회 수
487 Effective_Code_Writing [3] file sapjoy 2007.04.18 2991
486 sap perforamnce check t-code list [2] sapjoy 2014.06.16 3042
485 Creating Custom Screen in XD01 [2] file 노름마치 2009.07.10 3055
484 Working with Substitution Exit [6] file 노름마치 2009.07.10 3064
483 Implementing Field Exit for the transaction MK01 [3] file 노름마치 2009.07.10 3150
482 Working with User-Exits for the transaction VA01 [3] file 노름마치 2009.07.10 3169
481 User Parameter 조회 펑션 [3] 양키(이경환) 2014.03.04 3176
480 Do and Dont's in ABAP Programming [5] file sapjoy 2007.04.18 3182
479 Creating Change Documents for Custom tables (Step-by-step procedure) Using SCDO [2] file 노름마치 2009.07.10 3194
478 jco_tutorial-ja_doo [2] file kk 2008.01.23 3197
477 Adding Custom Fields using EEWB Transaction [1] file 노름마치 2009.07.10 3217
476 BTE_Scenario on Business Transaction Events [7] file 노름마치 2009.07.10 3272
475 대용량 DATA 병렬 처리 샘플 프로그램 - Parallel Process [2] file moonical 2021.09.09 3285
474 Restrict users (sales persons) to view or change Sales order data - Using Enhancement framework [3] file 노름마치 2009.07.10 3297
473 BDC 수행시 COMMAND 명령어 sapjoy 2014.09.18 3300
472 SAP tips Journal - 6,7월 호 (2008) [9] file onefineday 2009.02.11 3303
471 Setting the screen elements as mandatory in the transaction DP95 using Enhancement Framework [2] file 노름마치 2009.07.10 3314
470 ALV TOOLBAR 메뉴 버튼을 올립니다. [6] file 블루보이 2013.06.26 3321
469 드롭다운 리스트 key값 조회하기 [4] file 아밥뽀 2014.09.21 3341
468 앞의 0으로 시작하는 문자 모두 지우기 sapjoy 2014.08.20 3349