您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“SAP SD實際應(yīng)用的方法有哪些”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!
1.SD-如何讀取文本訂單的抬頭文本
在最近一次修改訂單跟蹤表,用戶提出需要讀取抬頭文本。由于用戶輸入文本時存在多種語言,如果根據(jù)用戶的語言或者在條件界面設(shè)置語言條件來提取文本,發(fā)現(xiàn)都會漏取文本。后來經(jīng)過思索,用先從STXH表中獲取抬頭文本的語言,再使用該語言傳入read_text函數(shù)讀取文本,這樣就確保文本讀取,不會出現(xiàn)遺漏。代碼摘抄如下:
CLEAR lV_text.
select single TDSPRAS into (w_LANG ) from STXH
where TDOBJECT = 'VBBK' and TDNAME = CS_TAB-vbeln and TDID = 'YOD1'.
if sy-subrc = 0.
w_tdid = 'YOD1'.
w_tdspras = w_LANG .
w_tdname = CS_TAB-vbeln.
w_tdobject = 'VBBK'.
REFRESH w_lines.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = w_tdid
LANGUAGE = w_tdspras
NAME = w_tdname
OBJECT = w_tdobject
TABLES
LINES = w_lines
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
2.SD-如何增強VF04顯示交貨單相關(guān)的發(fā)票金額
sap給我們留好了增強的出口:EXIT_SAPLV60P_008,我們可以修改 ZXV6PU08,來顯示出庫相關(guān)的Billing的金額。
方法如下:
1、在VKDFIF中添加字段YYNETWR,用于顯示價格。
2、修改 ZXV6PU08,填寫YYNETWR字段。
代碼照抄如下:
PERFORM y0000sd_0000_fill_vkdfif
TABLES
lt_vkdfif[]
USING lt_vkdfif-vkorg.
* we store the final result
c_vkdfif[] = lt_vkdfif[].
FORM y0000sd_0000_fill_vkdfif
TABLES tt_vkdfif STRUCTURE vkdfif
USING uv_vkorg TYPE vkorg.
DATA ls_vkdfif TYPE vkdfif.
DATA lv_tabix LIKE sy-tabix.
DATA: BEGIN OF t_vbap OCCURS 0,
vbeln TYPE vbeln,
kbmeng TYPE kbmeng,
netwr TYPE netwr,
waerk TYPE waerk,
lfimg TYPE lfimg,
END OF t_vbap.
***********************************
LOOP AT tt_vkdfif INTO ls_vkdfif WHERE vkorg = uv_vkorg.
lv_tabix = sy-tabix.
SELECT SINGLE vbfa~vbelv
vbfa~waers
FROM vbfa AS vbfa
JOIN lips AS lips
ON lips~vbeln = vbfa~vbeln AND
lips~posnr = vbfa~posnn
INTO ( ls_vkdfif-yyvbeln_order,
ls_vkdfif-yywaers )
WHERE vbfa~vbeln = ls_vkdfif-vbeln
AND vbfa~vbtyp_n = 'J' "delivery
AND vbfa~vbtyp_v <> 'B'. "quotation
CHECK sy-subrc = 0.
** Confirmed qty value - CT115262 *************
if ls_vkdfif-fkart = 'F2'.
clear ls_vkdfif-yynetwr .
SELECT vp~vbeln vp~kbmeng vp~netwr vp~waerk lp~lfimg
INTO CORRESPONDING FIELDS OF TABLE t_vbap
FROM vbap as vp
INNER JOIN lips AS lp ON lp~vgbel = vp~vbeln AND
lp~vgpos = vp~posnr
WHERE vp~vbeln = LS_VKDFIF-YYVBELN_ORDER.
LOOP AT t_vbap.
if t_vbap-kbmeng <> 0.
ls_vkdfif-yynetwr = ls_vkdfif-yynetwr +
t_vbap-netwr * t_vbap-lfimg / t_vbap-kbmeng .
ls_vkdfif-waerk = t_vbap-waerk.
endif.
ENDLOOP.
endif.
*************************************************
SELECT SINGLE vdatu
FROM vbak
INTO ls_vkdfif-yyvdatu
WHERE vbeln = ls_vkdfif-yyvbeln_order.
MODIFY tt_vkdfif INDEX lv_tabix FROM ls_vkdfif.
ENDLOOP.
ENDFORM.
3.SD--如何增強是同一類出庫單使用不同號碼段
在現(xiàn)實的業(yè)務(wù)中,一個公司有多個銷售組織,它們使用同一個出庫類型,業(yè)務(wù)往往希望它們創(chuàng)建的出庫單的號碼采用不同號碼范圍。但在sap里出庫單號碼范圍是在出庫單類型里設(shè)置,也就是使用相同的出庫單類型,也就使用相同的號碼范圍。如果要達到上需業(yè)務(wù)需求,我們可以使用增強實現(xiàn)。具體實現(xiàn)參見下面的步驟:
步驟1:創(chuàng)建多個號碼段:
path: Spro->Sales and Distribution->Sales->Sales Documents->Sales Document Header->Define Number Ranges For Sales Documents
or
path: Spro->Logistics Execution->Shipping->Deliveries->Define Number Ranges for Deliveries
TCODE: VN01
步驟二:設(shè)置出庫單類型的號碼范圍
path: Spro->Logistics Execution->Shipping->Deliveries->Define Delivery Types
TCODE: 0VLK
步驟三:修改SAP增強代碼
modify the source code to control use different number range for different sale organiztion
3.1 you can use se38 to open source code MV50AFZ1 and find the form userexit_number_range.
*---------------------------------------------------------------------*
* FORM USEREXIT_NUMBER_RANGE *
*---------------------------------------------------------------------*
* This userexit can be used to determine the numberranges for *
* the internal document number. *
* *
* US_RANGE_INTERN - internal number range *
* *
* This form is called from form BELEG_SICHERN *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_NUMBER_RANGE USING US_RANGE_INTERN.
* Example: Numer range from TVLK like in standard
* US_RANGE_INTERN = TVLK-NUMKI.
*{ INSERT DEVK943692 1
DATA: z_werks TYPE lips-werks,
z_vkorg TYPE likp-vkorg,
z_nrnr TYPE nrnr,
z_vbtyp TYPE likp-vbtyp.
DATA: wa_xlikp LIKE likpvb,
wa_xlips LIKE lipsvb.
US_RANGE_INTERN = TVLK-NUMKI.
data t(1).
t = TVLK-LFART(1).
if t = 'Z'.
LOOP AT xlikp INTO wa_xlikp.
LOOP AT xlips INTO wa_xlips.
CASE wa_xlikp-vbtyp.
WHEN OTHERS.
MOVE: wa_xlikp-vbtyp TO z_vbtyp.
ENDCASE.
IF z_vbtyp EQ 'J' or "outbound del.
z_vbtyp eq 'T'. "return del. "V003
MOVE: wa_xlips-werks TO z_werks, "V002 "SBr16072007
wa_xlikp-vkorg TO z_vkorg.
ELSEIF z_vbtyp EQ '7'. "shipp.notification
MOVE: space TO z_vkorg,
wa_xlips-werks TO z_werks.
ENDIF.
if z_vkorg = '6001'.
if z_vbtyp eq 'J'.
Case z_werks.
WHEN '6255'.
US_RANGE_INTERN = 'D1'.
WHEN '6245'.
US_RANGE_INTERN = 'D2'.
WHEN '6254'.
US_RANGE_INTERN = 'D3'.
WHEN '6234'.
US_RANGE_INTERN = 'D4'.
WHEN '6101'.
US_RANGE_INTERN = 'D5'.
endcase.
elseif z_vbtyp EQ 'T' .
Case z_werks.
WHEN '6255'.
US_RANGE_INTERN = 'R1'.
WHEN '6245'.
US_RANGE_INTERN = 'R2'.
WHEN '6254'.
US_RANGE_INTERN = 'R3'.
WHEN '6234'.
US_RANGE_INTERN = 'R4'.
WHEN '6101'.
US_RANGE_INTERN = 'R5'.
endcase.
endif.
endif.
EXIT.
ENDLOOP.
EXIT.
ENDLOOP.
endif.
*} INSERT
ENDFORM.
4.SD--如何在輸出控制中增加自定義字段
在sap的輸出控制中,我們有時需要增加系統(tǒng)未定義的字段作為條件表的字段,為了實現(xiàn)該需求我們就需要修改增強。
輸出控制用到的通訊結(jié)構(gòu)
KOMKBK1 (Output Determination Communication Area CAS Appl. K1)
KOMKBV1 (Output Determination Communication Area Header Appl. V1)
KOMKBV2 (Output Determination Communication Area Header Appl. V2)
KOMKBV3 (Output Determination Communication Area Header Appl. V3)
KOMKBV5 (Communication Structure for Output Control Groups Appl. V5)
KOMPBV1 (Output Determination Communication Area Item Appl. V1)
KOMPBV2 (Output Determination Communication Area Item Appl. V2)
KOMPBV3 (Output Determination Communication Area Item Appl. V3)
SAP在這些結(jié)構(gòu)中預(yù)留了INCLUDEs,用戶可以向這些結(jié)構(gòu)添加新的字段
Sales activities: KOMKBZ1 (in KOMKBK1)
Sales document header: KOMKBZ3 (in KOMKBV1)
Delivery header: KOMKBZ4 (in KOMKBV2)
Groups header: KOMKBZF (in KOMKBV5)
Billing document header: KOMKBZ5 (in KOMKBV3)
Sales document item: KOMPBZ1 (in KOMPBV1)
Delivery item: KOMPBZ3 (in KOMPBV2)
Billing document item: KOMKBZ5 (in KOMPBV3)
如果需要用新增字段創(chuàng)建條件表,我們就需要同時向KOMBZ結(jié)構(gòu)添加該字段 (KOMBZ包含在通訊結(jié)構(gòu)KOMB中).
完成以上兩部后,我們還需要增強sap的代碼,對通訊結(jié)構(gòu)的字段進行賦值。sap在RVCOMFZZ, RVCOMFZ1 和RVCOMFZ4單元預(yù)留了很多的出口。
RVCOMFZ1中的出口如下:
USEREXIT_KOMPBV2_FILL (item fields in delivery)
USEREXIT_KOMPBV2_PARTNER (item fields for partners in delivery)
USEREXIT_KOMPBV3_FILL (item fields in billing document)
USEREXIT_KOMPBV3_PARTNER (item fields for partners in billing document)
RVCOMFZZ中的出口如下:
USEREXIT_KOMKBK1_FILL (header fields in sales activities)
USEREXIT_KOMKBK1_PARTNER (header fields for partners in sales activ.)
USEREXIT_KOMKBV1_FILL (header fields for sales documents)
USEREXIT_KOMKBV1_PARTNER (header fields for partners in sales documents)
USEREXIT_KOMKBV2_FILL (header fields in delivery)
USEREXIT_KOMKBV2_PARTNER (header fields for partners in delivery)
USEREXIT_KOMKBV3_FILL (header fields in billing document)
USEREXIT_KOMKBV3_PARTNER (header fields for partners in billing doc.)
RVCOMFZ4中的出口如下:
USEREXIT_KOMKBV5_FILL (header field for groups)
In output determination, communication table KOMB contains all key fields that can be used for conditions for output determination.
When you create new fields for output determination, you can distinguish between two types of fields:
Fields that are used in condition tables
Fields which are only used to query conditions.
Both types of field have to be included in KOMKBV1. Fields which are only used to query conditions do not have to be included in KOMB and T681F or in the field catalog.
對訂單輸出控制增加自定義字段的詳細步驟如下;
1、用SE11向KOMKBV1中的KOMKBZ3增加自定義字段;
2、用SE11向KOMB中的KOMBZ增加自定義字段;
3、用V/86將自定義字段添加到允許字段中(字段必須來自KOMB,否則在建表時不可見);
4、用V/57定義條件表;
5、定義條件存儲順序;
6、將條件存儲順序賦值給條件類型;
7、修改代碼RVCOMFZZ中的子過程USEREXIT_KOMKBV1_FILL
5.SD--批量刪除訂單
在sap應(yīng)用中常常會需要批量刪除一些錯誤錄入的單據(jù),為此開發(fā)了一個小程序。該程序為了安全,程序做了一下控制
1、限制用戶只能刪除自己的訂單,不能刪除別人輸入的訂單,如果需要修改一下查詢條件;
2、系統(tǒng)默認為"測試運行",方便用戶在刪除訂單前要核實一下訂單,確認不要誤操作;
程序代碼如下,供大家參考!
REPORT zsde0099.
TYPE-POOLS: slis.
*----------------------------------------------------------------------*
* data Declarations
*----------------------------------------------------------------------*
TABLES: vbak. " Sales Document: Header Data
*----------------------------------------------------------------------*
* table control Output Declarations
*----------------------------------------------------------------------*
TYPES: BEGIN OF tc_0100,
sel(1), " Check box
vbeln LIKE vbak-vbeln, " Sales Order Number
erdat LIKE vbak-erdat, " Sales order creation date
ernam LIKE vbak-ernam,
kunnr LIKE likp-kunag, " Sold-to Party
name1 LIKE kna1-name1, " Sold-to Company Name
text(200),
END OF tc_0100.
DATA: wa_tc_0100 TYPE tc_0100,
it_tc_0100 TYPE tc_0100 OCCURS 0 WITH HEADER LINE.
DATA g_fieldcat TYPE slis_t_fieldcat_alv.
*----------------------------------------------------------------------*
* Selection Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK params1 WITH FRAME TITLE text-001.
PARAMETER: s_vkorg LIKE vbak-vkorg DEFAULT '6001' OBLIGATORY MODIF ID s1. " " Sales Org.
SELECT-OPTIONS:
s_vtweg FOR vbak-vtweg OBLIGATORY, " Distribution Channel
s_spart FOR vbak-spart OBLIGATORY DEFAULT '10', " Division
s_auart FOR vbak-auart OBLIGATORY, " Order type
s_erdat FOR vbak-erdat OBLIGATORY, " Sales order creation date
* s_ERNAM FOR vbak-ERNAM OBLIGATORY , " Sales order creation date
s_kunnr FOR vbak-kunnr , " Sold-to party
s_vbeln FOR vbak-vbeln . " Sales Order
PARAMETER p_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK params1.
***********************************************************************
*INITIALIZATION.
***********************************************************************
INITIALIZATION.
s_auart-sign = 'I'.
s_auart-option = 'EQ'.
s_auart-low = 'ZC01'.
APPEND s_auart.
s_auart-low = 'ZC03'.
APPEND s_auart.
s_auart-low = 'ZC06'.
APPEND s_auart.
s_auart-low = 'ZC20'.
APPEND s_auart.
s_vtweg-sign = 'I'.
s_vtweg-option = 'EQ'.
s_vtweg-low = '10'.
APPEND s_vtweg.
s_vtweg-low = '20'.
APPEND s_vtweg.
s_vtweg-low = '30'.
APPEND s_vtweg.
s_vtweg-low = '40'.
APPEND s_vtweg.
*----------------------------------------------------------------------*
* Selection Events Processing
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
PERFORM screen_check.
AT SELECTION-SCREEN.
CLEAR: it_tc_0100, wa_tc_0100.
REFRESH: it_tc_0100.
START-OF-SELECTION.
PERFORM extract_data.
END-OF-SELECTION.
PERFORM change_sales_orders.
PERFORM display_mes.
*&---------------------------------------------------------------------*
*& Form SCREEN_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM screen_check.
DATA: l_line TYPE i .
DESCRIBE TABLE s_erdat LINES l_line.
IF l_line EQ 0.
s_erdat-sign = 'I'.
s_erdat-option = 'BT'.
s_erdat-high = sy-datum.
s_erdat-low = sy-datum.
APPEND s_erdat.
ENDIF.
DESCRIBE TABLE s_vtweg LINES l_line.
IF l_line EQ 0.
ENDIF.
ENDFORM. "SCREEN_CHECK
*&---------------------------------------------------------------------*
*& Form extract_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM extract_data.
DATA: lt_it1 LIKE it_tc_0100 OCCURS 0 WITH HEADER LINE,
l_chk(1). " for exclude incomplete SO
SELECT a~vbeln a~erdat a~ernam a~kunnr INTO CORRESPONDING FIELDS OF TABLE lt_it1
FROM vbak AS a
WHERE a~vbeln IN s_vbeln
AND a~auart IN s_auart
AND a~vkorg EQ s_vkorg
AND a~vtweg IN s_vtweg
AND a~spart IN s_spart
AND a~erdat IN s_erdat
AND a~ernam = sy-uname
AND a~kunnr IN s_kunnr.
LOOP AT lt_it1.
* get sold-to party company name
PERFORM get_customer_company_name USING lt_it1-kunnr CHANGING lt_it1-name1.
MODIFY lt_it1.
ENDLOOP.
it_tc_0100[] = lt_it1[].
ENDFORM. "extract_data
*&---------------------------------------------------------------------*
*& Form GET_CUSTOMER_COMPANY_NAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->F_KUNNR text
* -->F_NAME text
*----------------------------------------------------------------------*
FORM get_customer_company_name USING f_kunnr CHANGING f_name.
CLEAR f_name.
SELECT SINGLE name1 INTO f_name
FROM kna1
WHERE kunnr = f_kunnr.
ENDFORM. "GET_CUSTOMER_COMPANY_NAME
*&---------------------------------------------------------------------*
*& Form change_sales_orders
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM change_sales_orders.
DATA: lt_order_header_in LIKE bapisdh2,
lt_order_header_inx LIKE bapisdh2x,
lt_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
lt_order_item_in LIKE bapisditm OCCURS 0 WITH HEADER LINE,
lt_order_item_inx LIKE bapisditmx OCCURS 0 WITH HEADER LINE,
cp_eind(1).
SORT it_tc_0100 BY vbeln.
DELETE ADJACENT DUPLICATES FROM it_tc_0100.
LOOP AT it_tc_0100.
CLEAR: lt_order_header_inx,lt_order_item_in, lt_order_item_inx, lt_return,cp_eind.
REFRESH: lt_order_item_in, lt_order_item_inx, lt_return.
lt_order_header_inx-updateflag = 'D'.
IF p_test NE 'X'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = it_tc_0100-vbeln
* ORDER_HEADER_IN = LT_ORDER_HEADER_IN
order_header_inx = lt_order_header_inx
TABLES
return = lt_return.
* 處理錯誤消息:通過判斷消息的類型,來判斷BAPI是否成功
LOOP AT lt_return .
IF lt_return-type EQ 'E' OR
lt_return-type = 'A' OR
lt_return = 'X'.
cp_eind = 'X'. "失敗
it_tc_0100-text = lt_return-message.
ENDIF.
ENDLOOP.
IF cp_eind NE 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ENDIF.
IF cp_eind NE 'X' AND sy-subrc = 0.
IF p_test = 'X'.
it_tc_0100-text = 'Test successfully.'.
ELSE.
it_tc_0100-text = 'Delete successfully.'.
ENDIF.
ELSE.
CONCATENATE it_tc_0100-text '---' 'Delete error.' into it_tc_0100-text.
ENDIF.
MODIFY it_tc_0100.
ENDLOOP.
ENDFORM. "change_sales_orders
*&---------------------------------------------------------------------*
*& Form init_fieldedi
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_FIELDTAB text
*----------------------------------------------------------------------*
FORM init_fieldedi USING p_p_fieldtab TYPE slis_t_fieldcat_alv.
DATA: l_fieldcat TYPE slis_fieldcat_alv.
REFRESH p_p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-fieldname = 'VBELN'.
l_fieldcat-seltext_m = 'ORDER NUMBER'.
l_fieldcat-outputlen = 10.
APPEND l_fieldcat TO p_p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-fieldname = 'ERDAT'.
l_fieldcat-seltext_m = 'Create Date'.
l_fieldcat-ref_fieldname = 'ERDAT'.
l_fieldcat-ref_tabname = 'VBAK'.
l_fieldcat-outputlen = 10.
APPEND l_fieldcat TO p_p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-fieldname = 'ERNAM'.
l_fieldcat-seltext_m = 'Input Person'.
l_fieldcat-ref_fieldname = 'ERDAT'.
l_fieldcat-ref_tabname = 'VBAK'.
l_fieldcat-outputlen = 10.
APPEND l_fieldcat TO p_p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-fieldname = 'KUNNR'.
l_fieldcat-seltext_m = 'Sold Code'.
l_fieldcat-ref_fieldname = 'KUNNR'.
l_fieldcat-ref_tabname = 'VBAK'.
l_fieldcat-outputlen = 10.
APPEND l_fieldcat TO p_p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-fieldname = 'NAME1'.
l_fieldcat-seltext_m = 'Sold Name1'.
l_fieldcat-outputlen = 35.
APPEND l_fieldcat TO p_p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-fieldname = 'TEXT'.
l_fieldcat-seltext_m = 'Message'.
l_fieldcat-outputlen = 120.
APPEND l_fieldcat TO p_p_fieldtab.
ENDFORM. " INITIALIZE_FIELDEDI
*&---------------------------------------------------------------------*
*& Form display_mes
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_mes .
PERFORM init_fieldedi USING g_fieldcat[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = g_fieldcat[]
i_save = 'A'
i_default = 'A'
TABLES
t_outtab = it_tc_0100.
ENDFORM. " display_mes
6.如何使用SE16N進行數(shù)據(jù)批量修改和輸入?
1、run SE16N;input table name and filter criteria;Go to the command field and type '/h' and press enter. This would activate the normal debugging session.
2、Execute (F8) to enter in debugging session.
This would activate the normal debugging session. Execute (F8) to enter in debugging session. Just make the below two variables as checked (X) .GD-SAPEDIT = XGD-EDIT=X3、Press F8 to continue the program, enter modify screen. After edit data, you need to click "save" button to save data into database.
7.SD-如何根據(jù)銷售單位確認數(shù)量,避免出現(xiàn)小數(shù)確認數(shù)量
在銷售單中,我們可能按大包裝進行銷售,單有時庫存不夠,系統(tǒng)出現(xiàn)帶小數(shù)的確認數(shù)量。為了避免這個出現(xiàn),我們可以使用增強進行避免。在單元ZXATPU02添加代碼如下:
data: w_av_vrkme like atpcc-atpm1,
w_av_vrkme_n like atpcc-atpm1,
w_av_pc like atpcc-atpm1.
* only if more ordered the available
check: T_ATPCSX-bdmng > p_atpcc-atpm1.
* available only partial ? via MOD
w_av_vrkme = p_atpcc-atpm1 mod ( T_ATPCSX-umrez * T_ATPCSX-umren ).
* rounded up in KAR (via DIV)
w_av_vrkme_n = ( p_atpcc-atpm1 div T_ATPCSX-umrez ) * T_ATPCSX-umren.
* rounded up quanitity in PC
w_av_pc = w_av_vrkme_n * T_ATPCSX-umrez / T_ATPCSX-umren.
* only if we have one line otherwise too complex
read table T_MDVEX index 2.
if sy-subrc > 0.
read table T_MDVEX index 1.
if sy-subrc = 0.
if w_av_vrkme <> 0.
if p_atpcc-atpm1 < ( T_ATPCSX-umrez / T_ATPCSX-umren ).
T_MDVEX-mng02 = 0.
else.
T_MDVEX-mng02 = w_av_pc.
endif.
MODIFY t_mdvex index 1.
endif.
endif.
endif.
8.如何控制同一一個訂單類型的使用多個號碼范圍
在現(xiàn)實的業(yè)務(wù)中,一個公司有多個銷售組織,它們使用同一個訂單類型,業(yè)務(wù)往往希望它們創(chuàng)建的訂單的號碼采用不同號碼范圍。但在sap里訂單號碼范圍是在訂單類型里設(shè)置,也就是使用相同的訂單類型,也就使用相同的號碼范圍。如果要達到上需業(yè)務(wù)需求,我們可以使用增強實現(xiàn)。
具體實現(xiàn)參見下面的步驟:
步驟1:創(chuàng)建多個號碼段:path: Spro->Sales and Distribution->Sales->Sales Documents->Sales Document Header->Define Number Ranges For Sales Documents TCODE: VN01
步驟二:設(shè)置訂單類型的號碼范圍path: Spro->Sales and Distribution->Sales->Sales Documents->Sales Document Header->Define Sales Document TypesTCODE: VOV8
步驟三:修改SAP增強代碼
modify the source code to control use different number range for different sale organiztion
3.1 you can use se38 to open source code MV45AFZZ and find the form userexit_number_range.
*---------------------------------------------------------------------*
* FORM USEREXIT_NUMBER_RANGE *
*---------------------------------------------------------------------*
* This userexit can be used to determine the numberranges for *
* the internal document number. *
* *
* US_RANGE_INTERN - internal number range *
* *
* This form is called from form BELEG_SICHERN *
* *
*---------------------------------------------------------------------*
form userexit_number_range using us_range_intern.
* Example: Numer range from TVAK like in standard
* US_RANGE_INTERN = TVAK-NUMKI.
endform.
3.2 change the source code as the following
*---------------------------------------------------------------------*
* FORM USEREXIT_NUMBER_RANGE *
*---------------------------------------------------------------------*
* This userexit can be used to determine the numberranges for *
* the internal document number. *
* *
* US_RANGE_INTERN - internal number range *
* *
* This form is called from form BELEG_SICHERN *
* *
*---------------------------------------------------------------------*
form userexit_number_range using us_range_intern.
* Example: Numer range from TVAK like in standard
* US_RANGE_INTERN = TVAK-NUMKI.
*{ INSERT TASK912652 1
IF us_range_intern = '13'.
CASE vbak-vkorg.
WHEN '0029'.
us_range_intern = '13'.
WHEN '0143'.
us_range_intern = '14'.
ENDCASE.
ENDIF.
*} INSERT
endform.
9 SD--訂單最小量限制的增強
在現(xiàn)實的銷售活動中考慮到配送成本,需要限制小額訂單的開具,為了達到該目的,我們可以對出口USEREXIT_SAVE_DOCUMENT_PREPARE 進行增強,具體步驟如下.一、設(shè)計訂單起定量設(shè)置表,自定義(銷售公司+訂單類型)具體定義參見下圖建立通過sap表維護工具來維護自定義表程序和事務(wù)媽。 二、設(shè)計訂單起定量設(shè)置(客戶)表,自定義(客戶)具體定義參見下圖建立通過sap表維護工具來維護自定義表程序和事務(wù)媽。 三、增強代碼
se38打開單元MV45AFZZ,修改USEREXIT_SAVE_DOCUMENT_PREPARE過程,代碼如下
*---------------------------------------------------------------------*
* FORM USEREXIT_SAVE_DOCUMENT_PREPARE *
*---------------------------------------------------------------------*
* This userexit can be used for changes or checks, before a *
* document is saved. *
* *
* If field T180-TRTYP contents 'H', the document will be *
* created, else it will be changed. *
* *
* This form is called at the beginning of form BELEG_SICHERN *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_SAVE_DOCUMENT_PREPARE.
*{ INSERT DEVK938281 1
DATA: zzamount LIKE vbak-netwr.
DATA: zmin LIKE vbak-netwr.
IF vbak-waerk NE tvko-waers. "
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = sy-datum
foreign_amount = vbak-netwr
foreign_currency = vbak-waerk
local_currency = sy-waers
IMPORTING
local_amount = zzamount
EXCEPTIONS
no_rate_found = 01
overflow + 02.
IF sy-subrc NE 0.
zzamount = vbak-netwr.
ENDIF.
ELSE.
zzamount = vbak-netwr.
ENDIF.
*minimum order value check in local currency
TABLES: zorderlimit, zorder_limit.
DATA minvalue LIKE vbak-netwr.
DATA difference LIKE vbak-netwr.
SELECT SINGLE * FROM zorder_limit
WHERE vkorg EQ vbak-vkorg
and auart EQ vbak-auart.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM zorderlimit
WHERE KUNNR EQ vbak-KUNNR.
IF sy-subrc EQ 0.
zmin = zorderlimit-ZZNETWR * 100.
IF zzamount < zmin.
MESSAGE '單據(jù)小于公司規(guī)定的訂單起定量,系統(tǒng)不能保存!' TYPE 'E'.
sy-subrc = 4.
exit.
ENDIF.
ELSE.
zmin = zorder_limit-ZZNETWR * 100.
IF zzamount < zmin.
MESSAGE '單據(jù)小于公司規(guī)定的訂單起定量,系統(tǒng)不能保存!' TYPE 'E'.
sy-subrc = 4.
exit.
ENDIF.
ENDIF.
ENDIF.
*
*} INSERT
ENDFORM.
*eject
四、結(jié)果如下圖
“SAP SD實際應(yīng)用的方法有哪些”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。