FORM get_option_master TABLES pt_item STRUCTURE zcoht610
pt_zcoht648 STRUCTURE zcoht648
USING pv_zprodh
CHANGING ps_zcoht647 STRUCTURE zcoht647.
DATA: lt_cr_list TYPE gt_ty_char_list WITH HEADER LINE, "분류사양
lt_op_list TYPE gt_ty_char_list WITH HEADER LINE. "옵션사양
DATA: BEGIN OF lt_option OCCURS 0 ,
atnam TYPE atnam,
atwrt TYPE atwrt,
zkrech TYPE zekrech,
zkbetr TYPE kbetr_kond,
konwa TYPE konwa,
END OF lt_option.
DATA: lv_table_name(30), "옵션 마스터 테이블 이름
lv_condition(100), "분류사양 조건
lv_field_name TYPE dd03d-fieldname.
FIELD-SYMBOLS <lv_field_name> TYPE any.
* 제품군으로 옵션 마스터 테이블 선택
CASE pv_zprodh(10).
WHEN '4HM00B0000' . "고압전동기
lv_table_name = 'ZCOHT650'.
WHEN '4HM00A0000' . "저압전동기
lv_table_name = 'ZCOHT649'.
WHEN '4HK00A0000'. "기어
lv_table_name = 'ZCOHT651'.
ENDCASE.
CHECK NOT lv_table_name IS INITIAL.
* 분류사양/옵션사양 분리
PERFORM split_characteristic_list TABLES pt_item
lt_cr_list "분류사양
lt_op_list. "옵션사양
CHECK NOT lt_cr_list[] IS INITIAL AND NOT lt_op_list[] IS INITIAL.
LOOP AT lt_cr_list.
"분류사양 조건
IF sy-tabix = 1.
CONCATENATE lt_cr_list-atnam ` EQ ` '''' lt_cr_list-atwrt ''''
INTO lv_condition.
ELSE.
CONCATENATE lv_condition ` AND ` lt_cr_list-atnam ` EQ ` '''' lt_cr_list-atwrt ''''
INTO lv_condition .
ENDIF.
"필드에 분류사양 채우기
CONCATENATE 'PS_ZCOHT647-' lt_cr_list-atnam INTO lv_field_name.
ASSIGN (lv_field_name) TO <lv_field_name>.
CHECK sy-subrc = 0.
<lv_field_name> = lt_cr_list-atwrt.
CLEAR lv_field_name.
UNASSIGN <lv_field_name>.
ENDLOOP.
TRY.
SELECT atnam atwrt zkrech zkbetr konwa
INTO CORRESPONDING FIELDS OF TABLE lt_option
FROM (lv_table_name)
FOR ALL ENTRIES IN lt_op_list
WHERE zprodh = pv_zprodh(10)
AND (lv_condition) "분류사양 조건
AND atnam = lt_op_list-atnam
AND atwrt = lt_op_list-atwrt
AND datuv <= sy-datum
AND datbi >= sy-datum.
CATCH cx_sy_dynamic_osql_error.
ENDTRY.
LOOP AT lt_option.
MOVE-CORRESPONDING lt_option TO pt_zcoht648 .
pt_zcoht648-zqtnr = ps_zcoht647-zqtnr. "견적번호
pt_zcoht648-zitnr = ps_zcoht647-zitnr. "견적원가 항번
pt_zcoht648-zvsnr = ps_zcoht647-zvsnr. "견적원가 버전번호
CASE lt_option-zkrech.
WHEN 'A'. "백분율
pt_zcoht648-vvopt = ps_zcoht647-netpr * pt_zcoht648-zkbetr / 100 . "옵션가 = 표시가*조건값/100
pt_zcoht648-waers = ps_zcoht647-waers. "통화
WHEN 'B'. "고정금액
pt_zcoht648-vvopt = pt_zcoht648-zkbetr. "옵션가
pt_zcoht648-waers = pt_zcoht648-konwa. "통화
ENDCASE.
ps_zcoht647-vvopt = ps_zcoht647-vvopt + pt_zcoht648-vvopt. "옵션가 총액
pt_zcoht648-zernam = sy-uname. "생성자
pt_zcoht648-zerdat = sy-datum. "생성일
pt_zcoht648-zerzet = sy-uzeit. "입력시간
APPEND pt_zcoht648. CLEAR pt_zcoht648.
ENDLOOP.
IF sy-subrc <> 0.
RAISE no_data.
ENDIF.
* 총견적원가 계산 (표시가 + 옵션가 총액)
ps_zcoht647-vv800 = ps_zcoht647-netpr + ps_zcoht647-vvopt.
ENDFORM. " GET_OPTION_MASTER
'ERP-SAP > ABAP' 카테고리의 다른 글
<ABAP> Source 찾기, 특정 문자 개발코드에서 찾기, Source 코드 찾기 (0) | 2012.11.14 |
---|---|
<ABAP> Text Edit 만들기, 저장하기, 읽어오기 (0) | 2012.10.19 |
<ABAP> Native sql 프로시져 호출 및 db insert(RFC) (0) | 2012.09.11 |
<ABAP> 프로그램 강제 수정 프로그램. (0) | 2012.09.05 |
<ABAP> SALV 03. Normal Display 2탄 (0) | 2012.08.29 |