위탁보충 오더 를 생성하려고 합니다.
아래와 같의 BAPI에 값을 넣었는데
BAPI_SALESORDER_CREATEFROMDAT2 에서 가격조건(세금부분, 정가) 부분의 값을 가져오지 못합니다.
하루종일 찾아봐도 잘 모르겠네요.;;
선배님들 도와주세요!
DATA : ls_list_line LIKE LINE OF gt_list.
DATA : lv_posnr TYPE vbap-posnr,
lv_cond_value TYPE konp-kbetr.
CLEAR : lv_posnr.
*.. Internal control parameter
gt_logic_switch-pricing = 'G'.
APPEND gt_logic_switch.
*.. Conversion of Partner Function + Order Type
gv_convert = 'X'.
SORT gt_list BY division req_date_h.
LOOP AT gt_list.
MOVE gt_list TO ls_list_line.
ADD 10 TO lv_posnr.
PERFORM get_currency_amount USING ls_list_line-currency
ls_list_line-cond_value
CHANGING lv_cond_value.
AT NEW req_date_h.
*.. Order Header
gs_order_header_in-refobjtype = 'VBBK'.
gs_order_header_in-doc_type = 'ZKB'. " 영업문서유형 (ZKB:위탁보충 오더, ZKE:위탁출고 오더)
gs_order_header_in-sales_org = p_vkorg. " 영업조직
gs_order_header_in-distr_chan = p_vtweg. " 유통경로
gs_order_header_in-division = ls_list_line-division. " 제품군
gs_order_header_in-req_date_h = ls_list_line-req_date_h. " 납품요청일
*.. Document Partner
PERFORM conversion_exit_alpha_input CHANGING gt_list-partn_numb.
gt_order_partners-partn_role = 'SH'. " 파트너기능 (SP:판매처, SH:인도처)
gt_order_partners-partn_numb = ls_list_line-partn_numb. " 인도처 사업장코드
APPEND gt_order_partners.
gt_order_partners-partn_role = 'SP'.
gt_order_partners-partn_numb = p_kunnr. " 판매처
APPEND gt_order_partners.
ENDAT.
*.. Item Data
gt_order_items_in-itm_number = lv_posnr. " 영업문서품목
TRANSLATE gt_list-material TO UPPER CASE.
IF NOT gt_list-material IS INITIAL.
PERFORM conversion_exit_alpha_input CHANGING ls_list_line-material.
gt_order_items_in-material = gt_list-material. " 자재코드
ENDIF.
gt_order_items_in-cust_mat35 = ls_list_line-cust_mat35. " 고객자재코드
* gt_order_items_in-purch_no_s = ls_list_line-purch_no_s. " 품목발주번호
* gt_order_items_in-po_meth_s = ls_list_line-po_meth_s. " 발주유형
APPEND gt_order_items_in.
*.. Schedule Line Data
gt_order_schedules_in-itm_number = lv_posnr. " 영업문서품목
gt_order_schedules_in-req_qty = ls_list_line-req_qty. " 오더수량
gt_order_schedules_in-req_date = ls_list_line-req_date. " 납기일
APPEND gt_order_schedules_in.
*.. Conditions
gt_order_conditions_in-itm_number = lv_posnr. " 영업문서품목
gt_order_conditions_in-cond_type = 'ZPR0'. " 조건유형
gt_order_conditions_in-cond_value = lv_cond_value. " 단가
gt_order_conditions_in-currency = 'KRW'. " 통화단위
gt_order_conditions_in-COND_UNIT = 'EA'.
gt_order_conditions_in-COND_P_UNT = '1'.
gt_order_conditions_in-APPLICATIO = 'V'.
APPEND gt_order_conditions_in.
AT END OF req_date_h.
PERFORM execute_bapi CHANGING ls_list_line.
MODIFY gt_list FROM ls_list_line TRANSPORTING icon message
WHERE division = ls_list_line-division
AND req_date_h = ls_list_line-req_date_h.
CLEAR : gs_order_header_in, gt_order_partners, gt_return,
gt_order_items_in, gt_order_schedules_in, gt_order_conditions_in.
REFRESH : gt_order_partners, gt_return,
gt_order_items_in, gt_order_schedules_in, gt_order_conditions_in.
ENDAT.
CLEAR : ls_list_line, lv_posnr,
gt_order_items_in, gt_order_schedules_in, gt_order_conditions_in.
ENDLOOP.
################### Form
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = gs_order_header_in
logic_switch = gt_logic_switch
convert = gv_convert
IMPORTING
salesdocument = gv_salesdocument
TABLES
return = gt_return
order_items_in = gt_order_items_in
order_conditions_in = gt_order_conditions_in
* ORDER_TEXT =
order_partners = gt_order_partners
order_schedules_in = gt_order_schedules_in.
댓글 2
-
띵호아빠
2008.12.20 00:40
-
기빵
2008.12.20 00:55
제가 사용했던...경우입니다..비교하시면 답을 찻을수 있을것으로 사료 됩니다...(저도 워낙 오래 돼서..설명은..그렇네요..)
DATA: order_header_in LIKE bapisdhd1,
order_header_inx LIKE bapisdhd1x,
convert_parvw_auart LIKE bapiflag-bapiflag,
bapiflag-bapiflag LIKE bapiflag-bapiflag,
salesdocument LIKE bapivbeln-vbeln,
return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
order_partners LIKE bapiparnr OCCURS 0 WITH HEADER LINE,
order_items_in LIKE bapisditm OCCURS 0 WITH HEADER LINE,
order_conditions_in LIKE bapicond OCCURS 0 WITH HEADER LINE,
order_schedules_in LIKE bapischdl OCCURS 0 WITH HEADER LINE,
order_items_inx LIKE bapisditmx OCCURS 0 WITH HEADER LINE,
order_conditions_inx LIKE bapicondx OCCURS 0 WITH HEADER LINE,
order_schedules_inx LIKE bapischdlx OCCURS 0 WITH HEADER LINE,
order_text LIKE bapisdtext OCCURS 0 WITH HEADER LINE,
logic_switch LIKE TABLE OF bapisdls WITH HEADER LINE.
***** ORDER_HEADER_IN-REFOBJKEY = 'VBBK'. "Object key
order_header_in-doc_type = gt_header-auart. "ZMES
order_header_inx-doc_type = 'X'. "Sales Document type
order_header_in-sales_org = gt_header-vkorg. "1000
order_header_inx-sales_org = 'X'. "Sales Organization
order_header_in-distr_chan = gt_header-vtweg. "01
order_header_inx-distr_chan = 'X'. "유통채널
order_header_in-division = gt_header-spart. "02
order_header_inx-division = 'X'. "Division
order_header_in-sales_grp = gt_header-vkgrp. "Sales group
order_header_in-sales_off = gt_header-vkbur. "Sales office
order_header_in-req_date_h = sy-datum. "Requested delivery date
order_header_inx-req_date_h = 'X'. "Proposed date type
order_header_in-date_type = '1'. "Proposed date type
order_header_inx-date_type = 'X'. "Proposed date type
order_header_in-purch_no_c = gt_header-ponumb.
"Customer purchase order number
order_header_inx-purch_no_c = 'X'. "Customer purchase order number
order_header_in-purch_date = gt_header-podate.
"Customer purchase order date
order_header_inx-purch_date = 'X'. "Customer purchase order date
***** ORDER_HEADER_IN-CUST_GROUP = '01'. "고객그룹
***** ORDER_HEADER_INX-CUST_GROUP = 'X'. "고객그룹
order_header_in-price_date = sy-datum.
"Date for pricing and exchange rate
order_header_inx-price_date = 'X'.
"Date for pricing and exchange rate
order_header_in-pmnttrms = gt_header-zterm. "1T30
order_header_inx-pmnttrms = 'X'. "Terms of payment key
order_header_in-incoterms1 = gt_header-inco1. "Incoterms (part 1)
order_header_inx-incoterms1 = 'X'. "Incoterms (part 1)
order_header_in-incoterms2 = gt_header-inco2. "Incoterms (part 2)
order_header_inx-incoterms2 = 'X'. "Incoterms (part 2)
order_header_in-s_proc_ind = gt_header-sdabw.
"Special processing indicator
order_header_inx-s_proc_ind = 'X'.
"Special processing indicator
order_header_in-collect_no = gt_header-submi_sd. "Collective number
order_header_inx-collect_no = 'X'. "Collective number
* CONVERT FLAG (중요)
convert_parvw_auart = 'X'.
*&---------------------------------------------------------------------*
*& LGOIC_SWITCH (중요)
*& G: Copy pricing elements unchanged and redetermine taxes
*& G:가격수동입력 SPACE 는 R/3가격을 참조함.
*&---------------------------------------------------------------------*
logic_switch-pricing = 'G'. " Pricing type
APPEND logic_switch.
DATA: l_num TYPE i,
l_docno LIKE salesdocument.
*-- Text Proc.
IF gt_zssddrtext[] IS NOT INITIAL.
REFRESH: order_text.
LOOP AT gt_zssddrtext.
CLEAR: order_text.
order_text-text_id = gt_zssddrtext-code.
order_text-text_line = gt_zssddrtext-text.
APPEND order_text.
ENDLOOP.
ENDIF.
*-- Item
DATA: l_matnr TYPE matnr,
l_cmatnr like gt_item-cmatnr.
LOOP AT gt_item. " WHERE MENGEC <> 0.
l_num = l_num + 1.
* ITEM
CLEAR: order_items_in, l_matnr.
* Material
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gt_item-matnr
IMPORTING
output = l_matnr.
* Customer Material Group
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gt_item-cmatnr
IMPORTING
output = l_cmatnr.
order_items_in-itm_number = l_num * 10.
order_items_in-material = l_matnr.
order_items_in-plant = gt_item-werks.
order_items_in-store_loc = gt_item-lgort.
order_items_in-batch = gt_item-charg.
order_items_in-mat_pr_grp = gt_item-kondm.
order_items_in-prc_group5 = gt_item-mvgr5.
order_items_in-cust_mat22 = l_cmatnr.
APPEND order_items_in.
* SCHEDULE
CLEAR order_schedules_in.
order_schedules_in-itm_number = l_num * 10.
order_schedules_in-req_qty = gt_item-lfimg.
order_schedules_in-req_date = sy-datum.
APPEND order_schedules_in.
* CONDITION
CLEAR order_conditions_in.
IF gt_item-kbetr IS NOT INITIAL.
order_conditions_in-itm_number = l_num * 10.
order_conditions_in-cond_type = 'PR00'.
order_conditions_in-cond_value = gt_item-kbetr.
order_conditions_in-conpricdat = sy-datum.
ORDER_CONDITIONS_IN-CURRENCY = 'KRW'.
APPEND order_conditions_in.
ENDIF.
ENDLOOP.
* 고객정보등록
DATA: l_kunnr TYPE kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gt_header-kunnr
IMPORTING
output = l_kunnr.
order_partners-partn_role = 'AG'. "SOLD-TO-PARTY
order_partners-partn_numb = l_kunnr.
APPEND order_partners.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = order_header_in
logic_switch = logic_switch
convert = convert_parvw_auart
IMPORTING
salesdocument = salesdocument
TABLES
return = return
order_items_in = order_items_in
order_partners = order_partners
order_schedules_in = order_schedules_in
order_conditions_in = order_conditions_in
order_text = order_text.
p_docunum = salesdocument.
* 문서번호가 없으면 오류
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT return WHERE type EQ 'E'.
***** MESSAGE e002 WITH '오류발생' return-message return-log_no.
p_g = 'E'.
LEAVE LIST-PROCESSING.
ENDLOOP.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = ' '
* IMPORTING
* RETURN =
.
ENDIF.
*--위의 Commit 에서 Wait 가 안먹서서 아래 wait 쓴것임.
wait UP TO 2 SECONDS.
*