I think I have this figured out, but wanted to post here in case others are struggling with it as well. The SOP10100 Flags column stores various on/off switches for the following settings of a sales document (order, invoice, etc.):
1 = SOPFLAGS_ADDREDITED (Address Edited)
2 = SOPFLAGS_COMMENTEDITED (Comment Edited)
3 = SOPFLAGS_PACKINGSLIPPRINTED (Packing Slip Printed)
4 = SOPFLAGS_PICKINGTICKETPRINTED (Picking Ticket Printed)
So here is how I was able to query whether the setting was active or not, using SQL server and the bitwise function (& position):
SELECT SOPNUMBE, Flags,
CASE WHEN Flags & 1 > 0 Then 1 Else 0 END AS Address_Modified,
CASE WHEN Flags & 2 > 0 Then 1 Else 0 END AS Comment_Modified,
CASE WHEN Flags & 3 > 0 Then 1 Else 0 END AS PackingSlip_Printed,CASE WHEN Flags & 4 > 0 Then 1 Else 0 END AS PickingList_Printed
FROM SOP10100
WHERE NOT Flags=0
You could also search for documents that have a certain setting enabled, however it will be slow (table scan), so you should limit the results down in other ways first.
SELECT RTRIM(SOPNUMBE), Flags FROM SOP10100 WHERE SOPTYPE=2 Flags & 1 = 0 --Returns orders with non-modified addresses
SELECT RTRIM(SOPNUMBE), Flags FROM SOP10100 WHERE Flags & 3 > 0 --Returns orders with packing slips printed
Credit to these other posts helping to clarify this issue:
https://groups.google.com/forum/#!topic/microsoft.public.greatplains/InhOur9pMvk
https://improve.dk/converting-between-base-2-10-and-16-in-t-sql/
(Comments)
*This post is locked for comments