Tuesday, September 24, 2019

System should not allow to delete PO line Item after GR/IR

Standard SAP will not allowed the PO to be deleted once it was GR done. The controlled is on the attributes of message to set as "E"
Message no. 06115
But if invoiced takes place, the is the point that PO can be deleted.
You have to do have a Enhancement using MM06E005, insert you logic here to check PO history tables like EKBE, then check if invoice " Q" (BEWTP) exist, the PO cannot be deleted once the user delete the PO line and SAVE it. Ask you developer to help you on the following coding.
Use MM06E005 and EXIT_SAPMM06E_012
IF SY-TCODE = 'ME22N'.
IF sy-ucomm = 'MESAVE' OR SY-UCOMM = 'YES'..
LOOP AT TEKPO.
IF TEKPO-LOEKZ = 'L'.
SELECT SINGLE BELNR FROM EKBE INTO BELNR1 WHERE EBELN = TEKPO-EBELN AND EBELP = TEKPO-EBELP AND BEWTP = 'E'.
IF SY-SUBRC = 0.
SELECT SINGLE BELNR FROM EKBE INTO BELNR2 WHERE EBELN = TEKPO-EBELN AND EBELP = TEKPO-EBELP AND BEWTP = 'Q'.
IF SY-SUBRC = 0.

Thursday, September 19, 2019

How to set up an easy Material Master creation Workflow



This Blog describes how to create a very simple SAP Business Workflow with a single decision step that can be used for Duet or Alloy.
The Workflow will be triggered by the creation of a new material in the ERP Backend (transaction MM01). The sample workflow just consists of a single decision step which is to approve or reject the new material. The work item will be visible in the Business Workplace.
In this easy example we do not focus on a complex agent determination – therefore the creator of the material also receives the work item himself (which is fine for this example – but may not be the case in a real environment).
In order to enhance the work item with some Material specific values we create a new Business Object (inherited from the standard Material Business Object) with some new attributes.
As a first step we create a new Business Object Subtype, inherited from the Material Master Object Type. Then we define the Event Linkage, and finally we create a new Workflow in the workflow builder that uses the event to initiate the workflow.

1. Create a new Business Object Subtype
Start Transaction SWO1 to launch the Business Object Builder. Enter Standard Business Object Type BUS1001006 (Standard Material). From the menu choose Object Type –> Inheritance –> Create Subtype, and provide the attributes required in the popup-menu:
.
The subtype has inherited all Attributes, Methods etc. from the superior object. In order to create own attributes place the cursor on “Attributes” and press the create button. As we want to create attributes that are coming from the Material Master table MARA, we select “Yes” in the “Create with ABAP Dictionary field proposals” dialog. Enter “MARA” as table name and scroll down to the fields “Size / Dimensions“, “EAN/UPC” and “EAN Category” and select them. Press Enter to close the dialog. For each newly selected line there will be a popup with the attribute properties. You can confirm the default values.
.
Set Object Type to “Implemented” by selecting Edit –> Change Release Status –> Object Type –> To Implemented. Generate the Object Type by pressing the generate button, or by CTRL+F3.
2. Define Event Linkage
Call Transaction SWEC to define the Event Linkage. Otherwise the event on the new Business Object Subtype won’t be executed and thus no consumer will be called. Press “New Entries” button, and specify the attributes as follows:
.
Press Save.
Ensure that the event trace (Transaction SWELS is turned on). If you now create a Material via Transaction MM01, you can see the event in the event log (Transaction SWEL):
.
3. Define Sample Workflow
Start the Workflow Builder with transaction SWDD and press the Create button. Switch to the Workflow Container view in the lower left corner. Double click to create a new container element. Perform this step for the following attributes. Define all of them with “ABAP Dictionary Reference“.
 Element  Name  Short Description  Structure  Field
 ZMaterialNumber  ZMaterialNumber  Material Number   MARA  MATNR 
 ZMaterialText  ZMaterialText   Material Text   MAKT   MAKTX 
 ZMaterialSizeDimensions  ZMaterialSizeDimensions  Material Size Dimensions   MARA   GROES 
 ZMaterialEAN   ZMaterialEAN   Material EAN   MARA   EAN11 
 ZMaterialEANCategory   ZMaterialEANCategory   Material EAN Category   MARA   NUMTP 









.
Switch back to the “Step Types that can be inserted” view in the lower left corner. Drag & Drop a “User Decision” step from the toolbox into the Graphical Model:
.
Provide a Title with placeholders to immediately see the attributes, set “&_WF_INITIATOR&” as the Agent for execution and specify the Approve and Reject decisions:
.
Go to the 2nd tab strip (Details) and de-activate “Advance with dialog“. Click the green check-mark button in the upper left corner of the Task screen to transfer the definition to the graphics. Press the “Hat” button or CTRL+F8 to access the basic data. Specify an abbreviation and a description. Navigate to the “Start Events” tab strip, specify the above created Object Type as triggering event and select “CREATED” as the triggering event. Save the Workflow.
Click on the button in the first column to activate the triggering event. Click on the second Button in the table to define the binding. Define the mapping for all 5 attributes via Drag&Drop:
.
Confirm the dialog, press Save and back to go to the initial screen. Press the “Generate and activate runtime version” button or CTRL+F3.
Create another material to verify settings. Go to the Event log (Transaction SWEL), and you should see the triggered event, which has been consumed by the new workflow:
.
Go to the Business Workplace and you should also see the new work item:
.
Via the Workflow log you can navigate into the container to verify if the Z-attributes have been handed over correctly:
.
That’s it.

Wednesday, September 4, 2019

Movement 311 Function module BAPI BAPI_GOODSMVT_CREATE

Pstng_Date : system date
Doc_Date: System Date
(is anything required to fill in the column?)
GOODSMVT_CODE: 04
GOODSMVT_ITEM :
Material : Material-A
Plant: 1000
Stg_Loc: ST01
Batch: BATCH01
Move Type: 311
ENTRY_Qty: 175
Entry UOM: EA
Entry UOM_ISO: EA
Move_Mat : Material-A
Move_Plant: 1000
Move stlock: ST02
Move Batch: BATCH01



BAPI_GOODSMVT_CREATE

BAPI_TRANSACTION_COMMIT