Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9041

Re: Remove draft when post the sale order

$
0
0

Hi Nandappa,

the tricky part is to determine whether it is a draft document that you are adding.

I know three ways to do so :

- Form title contains "Draft"

- field "draftKey" of 1st DBDatatsource is "-1" - I think this is not reliable

- the status field ( item 81 - combobox ) is set to value "6"

 

Now you can catch the before event of et_FORM_DATA_ADD, get the draft docentry -> in the afterevent remove the draft :

 

String DraftFormUID = "";
String DraftDocEntry = "";
void SBO_Application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
{    BubbleEvent = true;     if (BusinessObjectInfo.BeforeAction)        {            if (BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)            {                SAPbouiCOM.Form oForm = SBO_Application.Forms.Item(BusinessObjectInfo.FormUID);                try                {                    if (((SAPbouiCOM.ComboBox)oForm.Items.Item("81").Specific).Selected.Value == "6")//if status is "Draft"                     {                        DraftFormUID = BusinessObjectInfo.FormUID;                        DraftDocEntry = oForm.DataSources.DBDataSources.Item(0).GetValue("DocEntry", 0);                    }                }                catch                 {                    //form doesn't have an item 81 that is combobox -> no document form                    return;                }            }     }     else //After     {         if (BusinessObjectInfo.ActionSuccess && BusinessObjectInfo.FormUID == DraftFormUID && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)         {             DraftFormUID = "";             SAPbobsCOM.Documents oDraft = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);             if (oDraft.GetByKey(Convert.ToInt32(DraftDocEntry)))             {                 if (oDraft.Remove() != 0)                 {                     SBO_Application.SetStatusBarMessage("Draft could not be removed : " + SBO_Company.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Short, false);                 }                 else                     SBO_Application.SetStatusBarMessage("Draft removed.", SAPbouiCOM.BoMessageTime.bmt_Short, false);             }             else             {                 SBO_Application.SetStatusBarMessage("Draft could not be found. ( DocEntry : " + DraftDocEntry + ")");             }             oDraft = null;         }     }
}

regards,

Maik


Viewing all articles
Browse latest Browse all 9041

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>