메뉴 건너뛰기

SAP 한국 커뮤니티

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

양키 2011.04.14 18:49 조회 수 : 8828

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).  

번호 제목 글쓴이 날짜 조회 수
488 Working with Substitution Exit [6] file 노름마치 2009.07.10 3099
487 Creating Custom Screen in XD01 [2] file 노름마치 2009.07.10 3100
486 sap perforamnce check t-code list [2] sapjoy 2014.06.16 3125
485 Implementing Field Exit for the transaction MK01 [3] file 노름마치 2009.07.10 3188
484 Do and Dont's in ABAP Programming [5] file sapjoy 2007.04.18 3215
483 Working with User-Exits for the transaction VA01 [3] file 노름마치 2009.07.10 3224
482 jco_tutorial-ja_doo [2] file kk 2008.01.23 3230
481 Creating Change Documents for Custom tables (Step-by-step procedure) Using SCDO [2] file 노름마치 2009.07.10 3244
480 Adding Custom Fields using EEWB Transaction [1] file 노름마치 2009.07.10 3263
479 BTE_Scenario on Business Transaction Events [7] file 노름마치 2009.07.10 3320
478 Restrict users (sales persons) to view or change Sales order data - Using Enhancement framework [3] file 노름마치 2009.07.10 3326
477 SAP tips Journal - 6,7월 호 (2008) [9] file onefineday 2009.02.11 3333
476 Setting the screen elements as mandatory in the transaction DP95 using Enhancement Framework [2] file 노름마치 2009.07.10 3371
475 User Parameter 조회 펑션 [3] 양키(이경환) 2014.03.04 3372
474 드롭다운 리스트 key값 조회하기 [4] file 아밥뽀 2014.09.22 3411
473 ALV TOOLBAR 메뉴 버튼을 올립니다. [6] file 블루보이 2013.06.26 3414
472 About QuickViewer [10] file 가보자 2007.04.12 3415
471 ABAP for Power Users [1] file 강진규 2007.04.03 3416
470 Creating Change Document Object Using SCDO [2] file 노름마치 2009.07.10 3422
469 BDC 수행시 COMMAND 명령어 sapjoy 2014.09.18 3432