Web Services DeleteLines

SUGGESTED

Hello. I'm looking for advice on using the DeleteLines method in web services to delete sales order lines as part of an application that moves open SO lines. (It creates lines on a new or current sales order, then deletes them from the source order.)

I can get DeleteLines to delete a single line, but I can't get it do delete multiple lines at once.

         This works fine:

         Dim tLineKey(0) As String
         tLineKey(0) = "1"

         r = ws.deleteLines(cc, "ZSOH", pk, "SOH4~NBLIG", tLineKey)

         This causes a webservice error:

         Dim tLineKey(1) As String
         tLineKey(0) = "1"
         tLineKey(1) = "2"
         
         r = ws.deleteLines(cc, "ZSOH", pk, "SOH4~NBLIG", tLineKey)

The server says: ErrNum=[8] ErrLine=[0] ErrPgm=[] ErrTyp=[1] ErrMess=[ARGUMENT10(1) : Index Incorrect]
The server says: **Exception** - Class[CCommException] ErrNum=[8] ErrLine=[0] ErrPgm=[] ErrTyp=[1] ErrMess=[ARGUMENT10(1) : Index Incorrect]

 

The "Line Keys" is a string array, so I'd expect it to take more than one value at a time. Or I'm totally wrong and there's a better way to go about this.


Thanks

Parents
  • 0
    SUGGESTED
    Yes, the key parameter, your third parameter is an array of keys. However, does the sales order have multiple lines for which to delete? Your code doesn't perform a read on the ZSOH object to discover the number of lines before attempting to delete. I can appreciate that's likely because you wanted to keep the example short here, but I wonder, if you perform a read first, which you can do using the web services tester, then check the max of the line numbers, then build those line numbers in your tLineKey what would happen?

    Also consider, perhaps the line number key is not monotonically increasing.
Reply
  • 0
    SUGGESTED
    Yes, the key parameter, your third parameter is an array of keys. However, does the sales order have multiple lines for which to delete? Your code doesn't perform a read on the ZSOH object to discover the number of lines before attempting to delete. I can appreciate that's likely because you wanted to keep the example short here, but I wonder, if you perform a read first, which you can do using the web services tester, then check the max of the line numbers, then build those line numbers in your tLineKey what would happen?

    Also consider, perhaps the line number key is not monotonically increasing.
Children
  • 0 in reply to Delamater
    I have a method that does a read on ZSOH to get the order, then I go through the lines so I can pick which ones to delete. In the webservice tester they do go 1-2-3-4-5. (I also wanted to know if it kept that order after inserting and in the middle using the regular sales order function, and that seems to be the case so far.) I see that in the page too as I put the read XML into a text box to verify I'm reading the correct sales order. This SO has five lines, and assuming the LIN NUM is the field I should be working with, "1" and "2" should be safe to delete.

    <TAB DIM="500" ID="SOH4_1" SIZE="5" >
    <LIN NUM="1" >
    <FLD NAME="NUMLIG" TYPE="Integer" >0</FLD>
    <FLD NAME="ITMREF" TYPE="Char" >MYPART1</FLD>
    <lots of FLDs>
    </LIN>
    <LIN NUM="2" >
    <FLD NAME="NUMLIG" TYPE="Integer" >0</FLD>
    <FLD NAME="ITMREF" TYPE="Char" >MYPART2</FLD>
    <lots of FLDs>
    </LIN>
    - through -
    <LIN NUM="5" >
    <FLD NAME="NUMLIG" TYPE="Integer" >0</FLD>
    <FLD NAME="ITMREF" TYPE="Char" >MYPART5</FLD>
    < lots of FLDs>
    </LIN>
    </TAB>


    Thanks