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

  • 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.
  • 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
  • 0
    SUGGESTED

    Hi
    you can't delete more than one line at one time using this method.
    as far I understand the reason is that once you delete a line (LIN) the object has changed the rows are resorted.
    for example if you have 5 lines and you delete line #3 then now LIN #5 become LIN #4 and LIN #4 bcome LIN# 3. (1 and 2 does not change in this case).
    X3 web service delete each line in a loop and the LINs get resorted).
    so if you have more then one line to delete , you have to read after each delete to get the right LIN.

    another approche to delete more than 1 line is to read the SOH object and then recreate the XML by deleteing from it the lines you want to delete,( and reordering by yourself the LIN NUM ,) and then use the Modify method with the new XML
    remember that LIN NUM must be 1,2,3,4... no gaps as these correspond to the nolign grid variable.
    (the SOPLIN in the table can have gaps. i.e : 1000, 2000, 4000 etc..)

    hope that helps
    Barak

  • 0 in reply to Barak
    For the modify command, I tried removing two lines (of five), changing the LIN NUM of remaining lines to 1-2-3, with and without the size="3" on the TAB line, and I got the following error:

    BLOK,Ordered qty smaller than delivered/picked/allocated total!
    BLOK,Field error [M:SOH4]QTY

    In this case the sales order lines are globally allocated (we globally allocate pretty much everything on the SOs). The lines are not picked or delivered.

    I also tried tinkering with the quantities on the lines, like if the quantity was 4 changing it to 0 or -4. That would either give the same error or it would complete the save, but do nothing.

    It seems that I'll have to read and delete one-by-one, but I can't help but think that there's a more efficient way.


    Thanks
    - Jim
  • 0 in reply to JamesG-ACD

    hi
    more efficient way will be import template, same idea - create the templeate only with the lines you want to keep.
    you can run it with code, let me know if you want some instructions how,
    I think that the error BLOK you get is related to the SOH object, check what happens if you do the same manually.

    I just checked it and t seems that Modify is not doing the right thing, so try to delete line by line

    one more thing: did you manage to work with insertLines method?

    It never worked for me...

    if yes please share an example

    thanks

  • 0 in reply to Barak
    I'm not sure what you mean by 'manually'. I'm doing the modification experiments in the web service tester.