Thursday, April 26, 2018

[SAP TM] 02. Master data requirements


 SAP   Transportation Management   Master data  


▌Introduction


SAP TM是個獨立的模組,因此在主檔的設置上可考慮以下方式:

1.  不建立特定的主檔
2.  整合SAP ERP的主檔資訊
3.  直接建立主檔在SAP TM


▌Environment


▋SAP TM 9.3 SP06
▋NetWeaver 7.4


▌Features



▋ERP主檔關連至SAP TM

▋國內/國際出境運輸 Domestic/International outbound transportation

此出貨需求將由SAP ERP初始(例如Sales order)再整合TM的運輸需求。 因此ERP需將主檔資料拋轉至TM。

▋國內/國際進港運輸Domestic/International inbound transportation

由整合SAP ERP及TM的Purchase order來觸發運輸流程,因此對應的供應商、工廠、送貨點主檔資料需雙向同步。

▋外包運輸Outsourced transportation

與第一點相同,由ERP的訂單觸發後續的運輸流程,因此主檔皆建立於ERP上。



▋直接在SAP TM建立主檔

然而SAP TM 做為一個獨立的模組,可直接建立在其上建立主檔並觸發後續的運輸需求。



▋如何整合SAP ERP及SAP TM主檔

Integration models為傳輸ERP主檔的第一步,必須透過SAP ERP的CFM1(Create Integration Model)來建立連結。


▋SAP TM的額外主檔

▋Business Partner

Business Partner簡稱BP,BP可為組織、個人或團體 。






定義BP時,需先從IMG設定Business Partner Role 或使用預設值 000000 Business Partner(Gen.);

(SAP GUI → TCode: SPRO → 【Cross-Application Components】→ 【SAP Business Partner】→ 【Business Partner】→ 【Basic Settings】→ 【Business Partner Roles】→ 【Define BP Roles】)





而每個BP可設定屬於多個BP Roles 。


提供以下幾個BP預設的BP Roles供參考:

Organization

l   Carrier
l   Ship-to-Party
l   Sold-to-Party
l   Vendor
l   Organization Unit


Person

l   Employee
l   Internet User
l   Contact Person
l   Driver



▋Carrier Profiles

定義運送者(Carrier)具備的運輸能力,所謂的運輸者是指定義BP Role為Carrier的BP。

設定Carrier Profiles的前提:

1.  一個BP Role為Carrier的BP
2.  已定義Transportation Lane
3.  已定義Product Freight Groups
4.  已定義Transportation Group
6.  已定義Means of Transport


▋Products

可從SAP ERP同步過來或在SAP TM獨立維護。





▌Reference

▋SAP TM100 Process In Transportatin Management class




[SAP TM] 01. NetWeaver Business Client(NWBC)


 SAP   Transportation Management   NWBC  


▌Introduction


SAP TM主要的使用介面為 NetWeaver Business Client (NWBC)。
它是基於Web Dynpro for ABAP開發的Web base用戶介面。

PS.
大部分的主檔仍可以透過SAP GUI來做設定


▌Environment


▋SAP TM 9.3 SP06
▋NetWeaver 7.4


▌Features


▋User Interface


SAP NWBC的商業目標:
1.  直觀、一致和統一的用戶互動介面。
2.  高性能的專家操作行為。
3.  B2B, B2C客戶不需額外設定瀏覽器。
4.  即時的使用者資料和伺服器端資料交換。



▋Open NWBC

在SAP GUI (for Windows)輸入TCode: NWBC 即可開啟。




▌Reference


▋SAP TM100 Process In Transportatin Management class




Wednesday, April 25, 2018

[Web API] Custom http header in request or response


 ASP.NET    Web API  


▌Introduction


How to receive custom http header from http request or append a new one on http response in ASP.NET Web API 2.



▌Environment


▋Visual Studio 2017 community 15.3.3
▋ASP.NET Web API2



▌Implement


▋In Action

▋Get custom http header’s value from http request

var headers = Request.Headers;
IEnumerable<string> values = null;
if (headers.TryGetValues("my-token", out values))
{
    var token = values.FirstOrDefault();
}


However, you can use this extension: Raz.HeaderAttribute, to get the custom header like this,

public async Task<Something> Get([FromHeader("my-token")] string token)
{

}

PS. This feature is available on ASP.NET Core now.

▋Append custom http header’s value to http response

// Create response
var response = Request.CreateResponse(HttpStatusCode.OK, myContent);
response.Headers.Add("my-token", "xxxxxxxxxxxx");



▋ActionFilter Attribute

Also we can implement an ActionFilterAttribute to apply the custom http header handling to actions.

public class MyFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
        {
            // Current request headers
            var headers = actionContext.Request.Headers;
            IEnumerable<string> values = null;
            if (headers.TryGetValues("my-token", out values))
            {
                var token = values.FirstOrDefault();

                
//Optional: Set the custom value to BaseController's public property
var baseController = actionContext.ControllerContext.Controller as BaseController;
if (baseController != null)
{
baseController.MyToken = token;
}
            }
        }

        public override void OnActionExecuted(HttpActionExecutedContext actionContext)
        {
            actionContext.Response.Headers.Add("my-token", "xxxxxxxxx");
        }
}




▌Reference