How to insert Line table in JAVA using NAV web services ?

sagesage Member Posts: 29
edited 2015-05-22 in NAV Three Tier
Hi,
I'm not sure is it ok to post this question in here. If not, please move this topic to somewhere else. :roll:

Now I developing application using JAVA consumes NAV2015's web services but stuck in insert data to the SalesLine table for many days. :(

Before JAVA, I used C# and can completely inserted the SalesLine like this...
using WebService;

SalesOrder_Service salesOrder;
SalesOrder_Service_Service service;
salesOrder = new SalesOrder_Service();
service = new SalesOrder_Service_Service();
service.UseDefaultCredentials = true;

service.Create(ref salesOrder);

Sales_Order_Line[] salesOrderLine = new Sales_Order_Line[1];
salesOrderLine[0] = new Sales_Order_Line();
salesOrderLine[0].Type = WebService.Type.Item;
salesOrderLine[0].Document_No = salesOrder.No;

// put SalesOrderLine into Header like this
salesOrder.SalesLines = salesOrderLine;

service.Update(ref salesOrder);

But now in JAVA I have no idea of how to insert the SalesLine into Header. I tried the same way as I did in .NET but look like there are no method for me to put and set data from Line to Header. Actually it has one method named setSalesLines(SaleOrderLineList arg0); but the problem is SalesOrderLineList has only GET method. :-k
SalesOrder soHeader = soPort.read(docNo);

//method for set SalesLines requires SalesOrderLineList variable
soHeader.setSalesLines(SaleOrderLineList arg);

// So, I created the SalesOrderLineList 
SalesOrderLineList lineList = new SalesOrderLineList();

// But.. lineList has only get method. 
lineList.getSalesOrderLine();  

// More information
// This is another class for set data to SalesLine
SalesOrderLine saleOrderline = new SalesOrderLine();
saleOrderline.setNo(docNo);
saleOrderline.setDescription("zzZ");

How can I combine all of this things together ? :-k
Thank you In advance for your attention.

Comments

  • sagesage Member Posts: 29
    Thanks team.

    We finally found. \:D/
    SalesOrder soHeader = soPort.read(docNo);
    
    SalesOrderLineList lineList = new SalesOrderLineList();
    
    SalesOrderLine saleOrderline = new SalesOrderLine();
    saleOrderline.setNo(docNo);
    saleOrderline.setDescription("zzZ");
    
    lineList.getSalesOrderLine().add(saleOrderline);
    soHeader.setSalesLines(lineList);
    
Sign In or Register to comment.