Question Status

Suggested Answer
Mirza Mujib Ur Rahman Baig asked a question on 11 Nov 2013 11:37 PM

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,

 

Reply
Suggested Answer
Vlad Brisan responded on 12 Nov 2013 1:10 AM

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

}

}

Reply
Suggested Answer
Vlad Brisan responded on 12 Nov 2013 2:28 AM

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?

Reply
Suggested Answer
Jesper Kehlet responded on 12 Nov 2013 3:04 AM

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;

Reply
Suggested Answer
Vlad Brisan responded on 12 Nov 2013 1:10 AM

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

}

}

Reply
Mirza Mujib Ur Rahman Baig responded on 12 Nov 2013 2:01 AM

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

Reply
Suggested Answer
Vlad Brisan responded on 12 Nov 2013 2:28 AM

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?

Reply
Suggested Answer
Jesper Kehlet responded on 12 Nov 2013 3:04 AM

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;

Reply
Mirza Mujib Ur Rahman Baig responded on 12 Nov 2013 5:44 AM

Thanks Brison,

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

Reply
Mirza Mujib Ur Rahman Baig responded on 12 Nov 2013 5:53 AM

Hi Kehlet,

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

Thanks

Reply
Jesper Kehlet responded on 12 Nov 2013 5:56 AM

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;

Reply