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

    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

Reply
  • 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

Children