생산라인에 자동재고 보충 하는 방법 ? Ways to replenish stock to production line?

SAP WM을 사용하는 환경에서 생산라인에 자동재고 보충하는 하려고 하는데 어떤 방안이 효율적일까요?

1. 생산 투입자재별로 Min/Max을 설정(WM view 2)하고 자동재고 보충 LP21 수행하면 TR 이 생성되고, 해당 TR은 background job(schedule program RLAUTA10 )을 통해 TO 생성된다. 생성된 TO에 있는 자재별로 RF scanner을 사용하여 확정(confirmation)을 한다

2. 생산 투입자재별로 Min/Max을 설정이 없는 경우에는 엑셀 등을 사용하여 생산 투입자재별로 보충량을 계산하여 LB01 에서 TR을 생성한다. 해당 TR은 background job을 통해 TR 생성된다. 생성된 TO에 있는 자재별로 RF scanner을 사용하여 확정(confirmation)을 한다.


- 엑셀에서 투입자재별로 보충 수량으로 TR을 생성하는 Macro는 아래 코드 참조한다.

Sub CreateTR_LB01()
    Dim SapGui
    Dim Application
    Dim connection
    Dim session
    Dim WSHShell
    Dim ObjR3
    Dim Grid
    Dim sap_message
    Dim lastRow As Long
    Dim i As Long
        
    ' Assuming you want to write the sap_message to cell A2 in "Sheet1"
    Dim DestinationSheet As Worksheet
    Set DestinationSheet = ThisWorkbook.Sheets("LB01")
        
    lastRow = ThisWorkbook.Sheets("LB01").Cells(ThisWorkbook.Sheets("LB01").Rows.Count, "D").End(xlUp).Row
    
    Set WSHShell = Nothing
    Set SapGui = GetObject("SAPGUI")
    Set Application = SapGui.GetScriptingEngine
    
    Set connection = Application.Children(0)
    Set session = connection.Children(0)
    
    ' Go to Menu of Direct_Replenishment
    session.findById("wnd[0]").resizeWorkingPane 130, 29, False
    
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/NLB01"
    session.findById("wnd[0]").sendVKey 0

    session.findById("wnd[0]/usr/ctxtLTBK-LGNUM").Text = "081"
    session.findById("wnd[0]/usr/ctxtLTBK-BWLVS").Text = "920"
    session.findById("wnd[0]/usr/ctxtLTBK-BETYP").Text = "P"
    session.findById("wnd[0]/usr/txtLTBK-BENUM").Text = ThisWorkbook.Sheets("LB01").Cells(2, 3).Value  ' TR reuirement Name
    session.findById("wnd[0]/usr/txtLTBK-BENUM").SetFocus
    session.findById("wnd[0]/usr/txtLTBK-BENUM").caretPosition = 11
    session.findById("wnd[0]").sendVKey 0
        
       
    ' Loop through each row in the Excel sheet
    For i = 2 To lastRow
    
        session.findById("wnd[0]/usr/tblSAPML02BD0105/ctxtLTBP-MATNR[1,0]").Text = ThisWorkbook.Sheets("LB01").Cells(i, 4).Value 'Material
        session.findById("wnd[0]/usr/tblSAPML02BD0105/txtLTBP-MENGA[2,0]").Text = ThisWorkbook.Sheets("LB01").Cells(i, 5).Value ' Qty
        session.findById("wnd[0]/usr/tblSAPML02BD0105/txtLTBP-MENGA[2,0]").SetFocus
        session.findById("wnd[0]/usr/tblSAPML02BD0105/txtLTBP-MENGA[2,0]").caretPosition = 4
        session.findById("wnd[0]").sendVKey 0 ' Next item

    Next i

    session.findById("wnd[0]/tbar[1]/btn[6]").press ' Go to Header
    session.findById("wnd[0]/usr/ctxtLTBK-NLTYP").Text = ThisWorkbook.Sheets("LB01").Cells(2, 1).Value ' Dest Stor. Type
    session.findById("wnd[0]/usr/txtLTBK-NLPLA").Text = ThisWorkbook.Sheets("LB01").Cells(2, 2).Value ' Dest Bin

    session.findById("wnd[0]/usr/ctxtLTBK-NLTYP").SetFocus
    session.findById("wnd[0]/usr/ctxtLTBK-NLTYP").caretPosition = 3
    session.findById("wnd[0]/tbar[0]/btn[11]").press ' Save

    sap_message = session.findById("wnd[0]/sbar").Text ' Transfer order No
     
    ThisWorkbook.Sheets("LB01").Cells(2, 6).Value = sap_message
        
    'End of Direct_Replen
End Sub

3. 대량의 SU를 생산 투입을 하지 않는다면 자재별로 TO를 생성한다. 아래와 같이 2가지 방법이 있다.

3.1 LT01에서 FIFO 전략으로 SU 자동으로 결정하여 TO를 생성한다.

- 엑셀에서 투입할 자재별 & 수량으로 TO을 생성하는 Macro는 아래 코드 참조한다.

Sub CreateTO_LT01() 'LT01

' Keyboard Shortcut: Ctrl+a
'
    Dim SapGui
    Dim Application
    Dim connection
    Dim session
    Dim WSHShell
    Dim ObjR3
    Dim Grid
    Dim sap_message
    Dim lastRow As Long
    Dim i As Long
        
    ' Assuming you want to write the sap_message to cell A2 in "Sheet1"
    Dim DestinationSheet As Worksheet
    
    Set SheetName = ThisWorkbook.Sheets("Sheet1")
        
    lastRow = ThisWorkbook.Sheets("Sheet1").Cells(ThisWorkbook.Sheets("Sheet1").Rows.Count, "A").End(xlUp).Row
    
    Set WSHShell = Nothing
    Set SapGui = GetObject("SAPGUI")
    Set Application = SapGui.GetScriptingEngine
    
    Set connection = Application.Children(0)
    Set session = connection.Children(0)


    ' Loop through each row in the Excel sheet
    For i = 2 To lastRow
        ' Start of LT01
        session.findById("wnd[0]").resizeWorkingPane 130, 29, False
        session.findById("wnd[0]/tbar[0]/okcd").Text = "/NLT01"
        session.findById("wnd[0]").sendVKey 0
        session.findById("wnd[0]/usr/ctxtLTAK-BWLVS").Text = "999"
        session.findById("wnd[0]/usr/ctxtLTAP-MATNR").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 1).Value
        session.findById("wnd[0]/usr/txtRL03T-ANFME").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 2).Value
        session.findById("wnd[0]/usr/ctxtLTAP-WERKS").Text = "8181"
        session.findById("wnd[0]/usr/ctxtLTAP-LGORT").Text = "1000"
        session.findById("wnd[0]/usr/ctxtLTAP-LGORT").SetFocus
        session.findById("wnd[0]/usr/ctxtLTAP-LGORT").caretPosition = 4
        session.findById("wnd[0]").sendVKey 0
        session.findById("wnd[0]/usr/ctxtLTAP-LETYP").Text = "00"
        session.findById("wnd[0]/usr/ctxtLTAP-VLTYP").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 3).Value 'Source S.type
        session.findById("wnd[0]/usr/ctxtLTAP-NLTYP").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 4).Value ''Dest.S.type
        session.findById("wnd[0]/usr/txtLTAP-NLPLA").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 5).Value 'Dest.Bin
        session.findById("wnd[0]/usr/txtLTAP-NLPLA").SetFocus
        session.findById("wnd[0]/usr/txtLTAP-NLPLA").caretPosition = 9
        session.findById("wnd[0]").sendVKey 0
        session.findById("wnd[0]").sendVKey 0

        
        ' Your existing code to perform LT01 transaction
        
        sap_message = session.findById("wnd[0]/sbar").Text ' Transfer order No
        SheetName.Cells(i, 6).Value = sap_message

        ' You can use sap_message or perform any other actions with it
        
        ' Insert code here to handle the next row of data or perform any other necessary actions
    Next i

    session.findById("wnd[0]/tbar[0]/okcd").Text = "/n"
    session.findById("wnd[0]").sendVKey 0
        
        ' End of LT01

End Sub


3.2 LT10에서 자재별 SU를 조회 및 선택하여 TO를 생성한다.

'Move Top'

'For English Readers'

What is the most efficient method for replenishing stock to production line (storage type 4xx) from SCM WM storage type (2xx) in SAP, considering that both the production line and SCM WM storage share the same IM storage location?


The initial and simplest approach is to utilize the auto-replenishment function:

1.1 Begin by setting Min and Max values (found in WM view 2 of the material master) for each raw material to enable auto-replenishment.

1.2 Execute LP21 for automatic inventory replenishment, which results in the creation of a Transfer Request (TR), followed by the corresponding Transfer Order (TO).

1.3 TOs are generated through a background job (scheduled program RLAUTA10).

1.4 Utilize an RF scanner to confirm the TO for each material.


Create TRs using LB01 for bulk raw materials through Excel:

2.1 If Min/Max cannot be configured for raw materials, calculate the replenishment quantity for each raw material using Excel.

2.2 Generate TRs using a Macro in Excel. TRs are created through the Macro, triggering LB01.

Sub CreateTR_LB01()
    Dim SapGui
    Dim Application
    Dim connection
    Dim session
    Dim WSHShell
    Dim ObjR3
    Dim Grid
    Dim sap_message
    Dim lastRow As Long
    Dim i As Long
        
    ' Assuming you want to write the sap_message to cell A2 in "Sheet1"
    Dim DestinationSheet As Worksheet
    Set DestinationSheet = ThisWorkbook.Sheets("LB01")
        
    lastRow = ThisWorkbook.Sheets("LB01").Cells(ThisWorkbook.Sheets("LB01").Rows.Count, "D").End(xlUp).Row
    
    Set WSHShell = Nothing
    Set SapGui = GetObject("SAPGUI")
    Set Application = SapGui.GetScriptingEngine
    
    Set connection = Application.Children(0)
    Set session = connection.Children(0)
    
    ' Go to Menu of Direct_Replenishment
    session.findById("wnd[0]").resizeWorkingPane 130, 29, False
    
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/NLB01"
    session.findById("wnd[0]").sendVKey 0

    session.findById("wnd[0]/usr/ctxtLTBK-LGNUM").Text = "081"
    session.findById("wnd[0]/usr/ctxtLTBK-BWLVS").Text = "920"
    session.findById("wnd[0]/usr/ctxtLTBK-BETYP").Text = "P"
    session.findById("wnd[0]/usr/txtLTBK-BENUM").Text = ThisWorkbook.Sheets("LB01").Cells(2, 3).Value  ' TR reuirement Name
    session.findById("wnd[0]/usr/txtLTBK-BENUM").SetFocus
    session.findById("wnd[0]/usr/txtLTBK-BENUM").caretPosition = 11
    session.findById("wnd[0]").sendVKey 0
        
       
    ' Loop through each row in the Excel sheet
    For i = 2 To lastRow
    
        session.findById("wnd[0]/usr/tblSAPML02BD0105/ctxtLTBP-MATNR[1,0]").Text = ThisWorkbook.Sheets("LB01").Cells(i, 4).Value 'Material
        session.findById("wnd[0]/usr/tblSAPML02BD0105/txtLTBP-MENGA[2,0]").Text = ThisWorkbook.Sheets("LB01").Cells(i, 5).Value ' Qty
        session.findById("wnd[0]/usr/tblSAPML02BD0105/txtLTBP-MENGA[2,0]").SetFocus
        session.findById("wnd[0]/usr/tblSAPML02BD0105/txtLTBP-MENGA[2,0]").caretPosition = 4
        session.findById("wnd[0]").sendVKey 0 ' Next item

    Next i

    session.findById("wnd[0]/tbar[1]/btn[6]").press ' Go to Header
    session.findById("wnd[0]/usr/ctxtLTBK-NLTYP").Text = ThisWorkbook.Sheets("LB01").Cells(2, 1).Value ' Dest Stor. Type
    session.findById("wnd[0]/usr/txtLTBK-NLPLA").Text = ThisWorkbook.Sheets("LB01").Cells(2, 2).Value ' Dest Bin

    session.findById("wnd[0]/usr/ctxtLTBK-NLTYP").SetFocus
    session.findById("wnd[0]/usr/ctxtLTBK-NLTYP").caretPosition = 3
    session.findById("wnd[0]/tbar[0]/btn[11]").press ' Save

    sap_message = session.findById("wnd[0]/sbar").Text ' Transfer order No
     
    ThisWorkbook.Sheets("LB01").Cells(2, 6).Value = sap_message
        
    'End of Direct_Replen
End Sub


2.3 TOs are generated through a background job (scheduled program RLAUTA10).

2.4 Utilize an RF scanner to confirm the TO for each material.


Please refer to the Macro code below for creating TRs for raw materials with specified quantities in Excel.

In cases where multiple Storage Units (SUs) are not input into production, a TO is created for each material. Two methods are available:

3.1 Execute a Macro to create LT01; SU is automatically determined using the FIFO strategy.

Please refer to the Macro code below for creating TOs for raw materials with specified quantities in Excel.

Sub CreateTO_LT01() 'LT01

' Keyboard Shortcut: Ctrl+a
'
    Dim SapGui
    Dim Application
    Dim connection
    Dim session
    Dim WSHShell
    Dim ObjR3
    Dim Grid
    Dim sap_message
    Dim lastRow As Long
    Dim i As Long
        
    ' Assuming you want to write the sap_message to cell A2 in "Sheet1"
    Dim DestinationSheet As Worksheet
    
    Set SheetName = ThisWorkbook.Sheets("Sheet1")
        
    lastRow = ThisWorkbook.Sheets("Sheet1").Cells(ThisWorkbook.Sheets("Sheet1").Rows.Count, "A").End(xlUp).Row
    
    Set WSHShell = Nothing
    Set SapGui = GetObject("SAPGUI")
    Set Application = SapGui.GetScriptingEngine
    
    Set connection = Application.Children(0)
    Set session = connection.Children(0)


    ' Loop through each row in the Excel sheet
    For i = 2 To lastRow
        ' Start of LT01
        session.findById("wnd[0]").resizeWorkingPane 130, 29, False
        session.findById("wnd[0]/tbar[0]/okcd").Text = "/NLT01"
        session.findById("wnd[0]").sendVKey 0
        session.findById("wnd[0]/usr/ctxtLTAK-BWLVS").Text = "999"
        session.findById("wnd[0]/usr/ctxtLTAP-MATNR").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 1).Value
        session.findById("wnd[0]/usr/txtRL03T-ANFME").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 2).Value
        session.findById("wnd[0]/usr/ctxtLTAP-WERKS").Text = "8181"
        session.findById("wnd[0]/usr/ctxtLTAP-LGORT").Text = "1000"
        session.findById("wnd[0]/usr/ctxtLTAP-LGORT").SetFocus
        session.findById("wnd[0]/usr/ctxtLTAP-LGORT").caretPosition = 4
        session.findById("wnd[0]").sendVKey 0
        session.findById("wnd[0]/usr/ctxtLTAP-LETYP").Text = "00"
        session.findById("wnd[0]/usr/ctxtLTAP-VLTYP").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 3).Value 'Source S.type
        session.findById("wnd[0]/usr/ctxtLTAP-NLTYP").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 4).Value ''Dest.S.type
        session.findById("wnd[0]/usr/txtLTAP-NLPLA").Text = ThisWorkbook.Sheets("Sheet1").Cells(i, 5).Value 'Dest.Bin
        session.findById("wnd[0]/usr/txtLTAP-NLPLA").SetFocus
        session.findById("wnd[0]/usr/txtLTAP-NLPLA").caretPosition = 9
        session.findById("wnd[0]").sendVKey 0
        session.findById("wnd[0]").sendVKey 0

        
        ' Your existing code to perform LT01 transaction
        
        sap_message = session.findById("wnd[0]/sbar").Text ' Transfer order No
        SheetName.Cells(i, 6).Value = sap_message

        ' You can use sap_message or perform any other actions with it
        
        ' Insert code here to handle the next row of data or perform any other necessary actions
    Next i

    session.findById("wnd[0]/tbar[0]/okcd").Text = "/n"
    session.findById("wnd[0]").sendVKey 0
        
        ' End of LT01

End Sub

3.2 Generate TOs by searching for and selecting the appropriate SU for each material in LT10.


Comments

Popular posts from this blog

How to automate how to process mass transaction without ABAP code (SAP ABAP coding 하지 않고 엑셀 매크로 VBA로 SAP 생산오더 만들기)

Material Label as a industry standard on traceability along the whole supply chain.

How to execute Transaction with mass data without ABAP coding using SAP Script Recording, 코딩없이 대량 데이타를 SAP 업로드 할 수 있나요?