select and compare packing slip id from tables custPackingSlipTrans and salesParmSubLine is not working.

select and compare packing slip id from tables custPackingSlipTrans and salesParmSubLine is not working.

This question has suggested answer(s)

Hi,

select firstonly _sl where _sl.SalesId == custInvoiceTrans.OrigSalesId && _sl.ItemId == custInvoiceTrans.ItemId &&       

     _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.LineNum == custInvoiceTrans.LineNum && _sl.PackingSlipId == salesParmSubLine.DocumentId;

    return _sl.CIT_Smg_BlockPcs;

 

Note: 1.  _sl = custPackingslipTrans

         2.  DocumentId referes to packing slip Id in table 'SalesParmSubLine'

 

When i debug above code it takes values for all fields except for salesParmSubLine.DocumentId and not returns any value. If I remove _sl.PackingSlipId == salesParmSubLine.DocumentId then it returns first record of the _sl (custPackingslipTrans) table.

 

Need help,

 

Thanks,

 

All Replies
  • Hi,

    Did you preselected salesParmSubLine.DocumentId? Also, it is normal just to bring you the first record considering you used firstonly. Can you tell me what do you want to do in your code? you could try to use it like:  

    while select _sl where _sl.SalesId == custInvoiceTrans.OrigSalesId && _sl.ItemId == custInvoiceTrans.ItemId &&      

        _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.LineNum == custInvoiceTrans.LineNum {

    if( _sl.PackingSlipId == salesParmSubLine.DocumentId)

    {

    return _sl.CIT_Smg_BlockPcs

    }

    else

    {

    //your code

    }

    }

  • Hi Brisan,

    What I want is

    if _sl.PackingSlipId == salesParmSubLine.DocumentId then I'll retreive the value _sl.CIT_Smg_BlockPcs and print it on report (sales invoice report).

    Note: 1. _sl = custPackingSlipTrans

    If I write the above code without if condition i.e. _sl.PackingSlipId == salesParmSubLine.DocumentId

    then I'm getting the value of first record from table _sl.

    So i tried to put the if condition i.e. _sl.PackingSlipId == salesParmSubLine.DocumentId

    I hope it is clear,

    Thanks again

  • Ok. then you should have something like this:

    select  firstonly _sl where _sl.SalesId == custInvoiceTrans.OrigSalesId && _sl.ItemId == custInvoiceTrans.ItemId &&      

       _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.LineNum == custInvoiceTrans.LineNum ;

    //here you get the value of the packing slip coresponding with the custInvoiceTrans in the report

    select firstonly salesParmSubLine where salesParmSubLine.DocumentId == _sl.PackingSlipId ;

    //here you check if a salesParmSubLine  exists for that packing slip

    if( salesParmSubLine)

    {

    return _sl.CIT_Smg_BlockPcs ;

    }

    else

    {

    //do nothing

    }

    Do you try to modify a custom or a standard report?

  • The LineNum could be inconsistent, also the InventTransId is unique, and for _sl you used SaiesId, not OrigSalesId (although it may be irrelevant, it could still be different from CustInvoiceTrans.OrigSalesId) so try rewriting it as:

    select firstonly _sl where _sl.OrigSalesId == custInvoiceTrans.OrigSalesId && _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.PackingSlipId == salesParmSubLine.DocumentId;

       return _sl.CIT_Smg_BlockPcs;

  • Thanks Brison,

    Above code just brings the first record. It is not validating/checking particular packing slip number.

  • Hi Kehlet,

    I tried the above code, it didn't work.

    Thanks

  • Can you post some values from the tables?  Turn on the debugger and let us know these values:

    _sl.OrigSalesId

    _sl.InventTransId

    _sl.PackingSlipId

    custInvoiceTrans.OrigSalesId

    ustInvoiceTrans.InventTransId

    salesParmSubLine.DocumentId;