FUNCTION WS_DELIVERY_UPDATE_2 with NO_MESSAGES_UPDATE_1 = 'X' - abap

When using function module WS_DELIVERY_UPDATE_2, the delivery note is being printed even though we cleared the printer, copies and also the 'Print inmediately' check in tx NACE for message LD00 for a selected shipping point.
The configuration works for VL02N but it doesn't in our Z program where we manage some delivery notes.
This is the code:
call function 'WS_DELIVERY_UPDATE_2'
exporting
vbkok_wa = vbkok_wa
commit = 'X'
delivery = lv_vbeln
update_picking = 'X'
nicht_sperren_1 = 'Y'
if_database_update_1 = '1'
if_error_messages_send = ' '
tables
vbpok_tab = vbpok_tab.
Ok, checking the import parameters of the function I can see NO_MESSAGES_UPDATE_1 which, I can relate or imagine what could do but, has anybody tried this parameter?
Will this parameter avoid the printing of the message?

Well, tried the parameter NO_MESSAGES_UPDATE_1 but didn't work.
We managed to literally delete the record in NACE for the shipping point and that made it.
Originally we just cleared the printer, the copies and the 'Print immediately' check.

Related

Make Text Box visible with condition

I am new at VBA and I am trying some code and I could not find a solution or where I am doing wrong.
What I want: The combination of two different text boxes make another text box visible(so it starts in useform not visible). With one condition I could do it using select case(LLL) but when I try it with another variant it does not work(XXX). There is no error message, the code runs but does not show the text box.
Sub Visible()
If userform.TextBox5.Value = "XXX" And userform.TextBox10.Value = "245" Then
userform.TextBox1.Visible = True
userform.T_1.Visible = True
Else
GoTo LLL
End If
LLL:
Select Case True
Case userform.TextBox5.Value = "LLL", userform.TextBox10.Value >= "145"
If userform.Option000.Value = True Then
userform.TextBox1.Visible = True
userform.T_1.Visible = True
Else
userform.TextBox1.Visible = False
userform.T_1.Visible = False
End If
End Select
I understand some of your questions I must say that my code is quite big one cause it is linked to SAP in order to get some values from there and due to its size the complete code is splitted in modules and I am only sharing the module where I am facing problems.
There is one case for select case statement cause it was the only way that it worked close for what I need. I have a lot of variables for the fields TextBox5 and TextBox10 the values of these textboxes come from SAP and when I combine them, other Text Boxes shall be visible depending on the variables given. The problem is that for just one combination (this one is the one that I applied the select case statement) I need another variable (option000) so that TextBox1 and T_1 become visible. When I tried to do it only with if statements it did not worked.

Having issues using Select Case/Case Else logic to produce certain outcomes

What I'm trying to achieve in my Windows form is to make my button compute a label output depending on calculated variables, but if the variable given in the textbox doesn't match what is listed in the code, a message box appears showing an error, and the label has a different output because of the failed match.
Here's some code to help further explain what I'm working with, and a description of the errors I'm receiving.
I have code that makes a variable, which finds the textbox that has numbers to substring the input and find the output:
Dim var1 As String
Dim Sb As String
Sb = Textbox1.Text
var1 = Sb.Substring(0, 3)
Then I'm placing that result to a label and trying to use it again to create the next label OR to show the messagebox saying there was an error using this code:
Select Case var1
Case var1 = "(result1)" Or "(result2)" Or "(result3)"
Dim var2 As String
var2 = "(Value)"
varlabel.Text = var2.ToString
Case Else
Messagebox.Show("Error occured, input not found.")
End Select
The issue I'm running into is that when I run the button's code, the first label will compute and publish successfully, but the second label will not publish correctly and will still show the message box even though I am giving it the correct input for the code to run. Can anyone shed light as to what I'm missing here?
This does not do what you want it to do:
Case var1 = "(result1)" Or "(result2)" Or "(result3)"
I can only assume that you haven't bothered to read the documentation for Select Case to even try that. It should be:
Case "(result1)", "(result2)", "(result3)"
ALWAYS read the documentation first if you have an issue.
https://msdn.microsoft.com/EN-US/library/cy37t14y(v=VS.140,d=hv.2).aspx

Functions give error only in macro-called dialog

I am writing and re-writing Excel VBA code to make some engineering analysis easier for myself and the others at my company. So the goal is to make it easy for others, not to be integrated into other code or purposes outside our own Excel work.
The problem: a few of the macros will add a custom function to a worksheet cell, bring up the function dialog for inputs, but then when completed, come up with a Value error, stating A value used in the formula is of the wrong data type. Based on this, I believe the issue arises when my function uses a Variant or Range type variable. Some of these functions only give this error via certain input types.
HOWEVER, in every single case, using the function dialog Not in the macro works fine, as does typing the formula in manually. Additionally, all you have to do is double-click on the error cell to edit it, change nothing, press enter, and it's fine!
My macros themselves are as simple as:
Sub NewSTC_dialog()
ActiveCell.FormulaR1C1 = "=sheetname.xlsm!NewSTC()"
Application.Dialogs(xlDialogFunctionWizard).Show
End Sub
My functions have more to them, but the situation is different for different functions, and the functions themselves work fine, so it is preferable to have a solution that applies to the macros rather than within the functions. If I must, I can go through each situation individually or come up with a simplified function that has the same issue to give as an example.
My best workaround so far (I cannot re-find the website were I found this particular solution):
Sub Recalculate()
ActiveCell.Replace What:="=", Replacement:="="
End Sub
Set to a convenient shortcut, and it works great. However, as mentioned above, the goal is to make this easy for everyone else, which would mean not requiring anything additional to have the formula work. Unfortunately, calling this from within the initial macro will not work. In fact, nothing located after the dialog call will run. I tried using On Error Resume Next and it still won't run anything after the dialog call.
Some options searched and tried:
How to refresh cells in Excel 2010 using VBA? and links within that - as mentioned, nothing located after the dialog call will run, thus won't reach these adjustments. Putting before the dialog call also doesn't help. Putting the dialog call in between the false and true statements makes the false apply, then never runs the true statement.
http://www.excelforum.com/excel-general/471632-formula-do-not-work-until-edited.html - Excel is not set to manual
http://blog.contextures.com/archives/2012/02/16/excel-formulas-not-calculating/ - SUMIF is not involved
This is all on Excel 2010, Windows 7 Professional.
EDIT:
Here is an example that creates this behavior. This is similar to the behavior of two of my functions, but not to all of them, so again, I would much prefer the solution be in the macro, not the function. This is just for anybody else's testing purposes.
Function LetNum(input1 As Variant, input2 As Variant) As Integer
If input1 = "A" Or input1 = "a" Then
input1 = 100
ElseIf input1 = 10 Then
input1 = -10
End If
If input2 = "B" Or input2 = "b" Then
input2 = 200
ElseIf input2 = 10 Then
input2 = -1000
End If
LetNum = input1 + input2
End Function
Sub LetNum_dialog()
ActiveCell.FormulaR1C1 = "=LetNum()"
Application.Dialogs(xlDialogFunctionWizard).Show
End Sub
In this situation, typing A and 2 into the dialog box in that order works, but 2 into the second then A into the first doesn't. Additionally, typing B in the second box never works. In all situations, clicking to edit, changing nothing, and hitting enter, fixes it. Additionally, any situation in the dialog box if you bring it up without the macro works fine.
Also, I'm aware this case works better if you input it with quotes, but excel automatically changes it correctly, and not all my functions are string issues.
EDIT 2:
Tim's answer is a great step in the right direction! However, if anybody can come up with a solution that doesn't involve ignoring all errors, that would be more ideal due to some desired error-throwing being ignored. I will look into handling errors differently in the meantime.
The issue seems to be that any error triggered in your UDF effectively "disables" the Function Wizard: note that in cases where you get #VALUE! error, the Show() method never returns any value, and any lines following the call to Show() are not executed.
The only thing which resolved this in my testing was to add a line to the function which skips any errors when the Function Wizard is open:
Dim bSettingUp As Boolean
Function LetNum(input1 As Variant, input2 As Variant) As Integer
If bSettingUp Then On Error Resume Next
If input1 = "A" Or input1 = "a" Then
input1 = 100
ElseIf input1 = 10 Then
input1 = -10
End If
If input2 = "B" Or input2 = "b" Then
input2 = 200
ElseIf input2 = 10 Then
input2 = -1000
End If
LetNum = input1 + input2
End Function
Sub LetNum_dialog()
ActiveCell.Formula = "=LetNum()"
bSettingUp = True
Debug.Print Application.Dialogs(xlDialogFunctionWizard).Show()
bSettingUp = False
End Sub
I'm aware that you'd rather not alter your functions ,but this was the only work-around I could find.

Enable/Disable Fields with certain criteria MS Access

I have a form in MS Access that I'm trying to create for insurance claims. I have all the fields that I need to be filled in but what I'd like to be able to do is enable or disable those fields depending on certain actions of the users. So the flow of the form is like this: I have a Frame at the top with two radio buttons, one for a single-claim incident and one for a multi-claim incident. If the user clicks the single-claim button everything continues with no problem. If the user clicks the multi-claim incident button, a combo box appears to the side with a dropdown list of MultiClaim_Incident_ID numbers that they need to select from. What I'm trying to do is if the user selects the Multi-Claim Incident button AND does not select an Incident ID number from the dropdown down list (i.e. leaves it at default value) then the rest of the form is disabled until corrected as well as clear all the fields...
It seems like it should be pretty straightforward but I can't seem to get it to work, I'm not sure if my logic is flawed or what. Here's an abridged version of my VBA code:
Private Sub Form_Load()
Me.SM_Frame.Value = 1
Me.MultiClaim_Drpdwn.Value = Null
End Sub
Private Sub SM_Frame_AfterUpdate()
If SM_Frame.Value = 1 Then
Me.MultiClaim_Incident_ID_Label.Visible = False
Me.MultiClaim_Drpdwn.Visible = False
ElseIf SM_Frame.Value = 2 Then
Me.MultiClaim_Incident_ID_Label.Visible = True
Me.MultiClaim_Drpdwn.Visible = True
ElseIf SM_Frame.Value = 2 & MultiClaim_Drpdwn.Value = Null Then
Me.Incident_Date = Null
Me.Incident_Date.Enabled = False
Me.Claimant_Name.Value = ""
Me.Claimant_Name.Enabled = False
//PATTERN CONTINUES FOR REST OF FIELDS//
MsgBox ("CLEAR EVERYTHING!!")
ElseIf SM_Frame.Value = 1 Then
Me.Incident_Date.Value = ""
Me.Incident_Date.Enabled = True
Me.Claimant_Name.Value = ""
Me.Claimant_Name.Enabled = True
//PATTERN CONTINUES FOR REST OF FIELDS//
MsgBox ("Everything can continue as is")
End If
End Sub
Let me just say that getting sequences like these right is NOT straightforward AT ALL! So don't feel bad about not getting it right on the first try. I have to create things like that about once a month and still need a lot of tries until it works in all situations.
Try to seperate to concerns:
You already have SM_Frame_AfterUpdate(). Do in it what you must to handle changing from Value 1 to 2, namely making the Combobox visible, but STOP there. You dont know what will happen to the fields with information from SM_Frame alone, you need to wait for MultiClaim_Drpdwn. Also, do what is needed to go from 2 to 1, namely hide the Combobox.
Next, create an AfterUpdate-handler MultiClaim_Drpdwn_AfterUpdate(). Use THAT to deal with the fields (enable/disable, set empty) according to its value.
Once you have that in place, you only have some edge cases remaining. For example, you want the fields to behave like MultiClaim_Drpdwn_AfterUpdate() states right after you change the SM_Frame. Thats easy once you understand that you can just happily CALL MultiClaim_Drpdwn_AfterUpdate() from within SM_Frame_AfterUpdate(), best done at the very end. These eventhandlers are still just normal functions, already public and available for anyone. This will make things chain nicely when you come from the radiobutton or not when you come from the Combobox.
In an "elseif" series, once a condition is true, the rest is ignored.
So, your
ElseIf SM_Frame.Value = 2 & MultiClaim_Drpdwn.Value = Null Then
is never reached, because you've got
ElseIf SM_Frame.Value = 2 Then
before.
In the same idea, the "ElseIf SM_Frame.Value = 1 Then" after the MsgBox is totally useless, because it's hidden by "If SM_Frame.Value = 1 Then"
Try to use the step-by-step debug mode to see that.

Recalculate a variable on change event without duplicate code

I'm making a small app that handles pricing and quotes for cloud services.
On one of my forms, I work out some pricing info in the 'me.shown' bit.
The prices for various items are read in from a mysql database on app launch, so i've already got all that info.
My price working out code is as follows:
calc_vmCPUprice = vmcpuprice * cpuslider.Value
calc_vmHDDprice = vmhddprice * hddslider.Value
calc_vmRAMprice = vmRAMprice * memoryslider.Value
If requirebackup.Checked = True Then
calc_backupsetupfee = vmbackupsetupfeecost
calc_backupfee = vmbackupcostperGB * sliderbackup.Value
End If
If supportcheck.Checked = True Then
calc_supportfee = vmsupportfee
End If
vmmonthlycost = calc_vmCPUprice + calc_vmHDDprice + calc_vmRAMprice + calc_backupfee + calc_backupsetupfee + calc_supportfee
vm_monthlycost.Text = "£" & vmmonthlycost
I need to make my program re-calculate the 'vmmonthlycost' variable each time an item is changed.
So for example if you change the slider for cpu (cpuslider.value) then the price will obviously change as the 'calc_vmCPUprice' variable will now be different.
I dont want to copy and paste the calculation code into the change event of each item, as this will be messy and any future changes will need to be mirrored across all items etc.
What would you guys recommend as the best way of achieving this recalculation of price?
I would ideally like to take that bit of code and seperate it then call it from each change event, but as I tinker with vb as a hobbyist more than anything else, my knowledge is still limited.
Thanks in advance!!