I have included code I use to open a PDF that is saved in a blob. This will work the same with the Raw datatype.
string ls_access
string ls_READONLY = "R"
string ls_READWRITE = "RW"
string ls_template
datetime ldt_ackgt_date
long ll_emp_id
long ll_doc_id
long ll_temp
long ll_rows
long ll_row
int li_filenum
boolean lbl_null
boolean lbl_iblob
DWItemStatus dwi_status
SetPointer(HourGlass!)
//Makes sure we have a row
if (row > 0) then
//Sets highlighting style
This.SetRow(row)
//If the PDF button was clicked
if (dwo.name = "b_pdf" AND this.object.b_pdf.Enabled = '1') then
//Determines the User's access setting
ls_access = f_vo_command_access()
//Gets data values
ll_emp_id = this.GetItemNumber(row, "emp_id")
ll_doc_id = this.GetItemNumber(row, "doc_id")
ldt_ackgt_date = this.GetItemDateTime(row, "ackgt_date")
//Checks for NULL
if (isNull(ll_doc_id)) then
MessageBox("ERROR", "You must specify a Document Name before adding a PDF.", StopSign!)
this.SetItem(row, "ackgt_on_pdf", "N")
this.SetColumn("doc_id")
return
end if
//Checks for NULL
if (isNull(ldt_ackgt_date)) then
MessageBox("ERROR", "You must specify an Acknowledgement Date before adding a PDF.", StopSign!)
this.SetItem(row, "ackgt_on_pdf", "N")
this.SetColumn("ackgt_date")
return
end if
//Checks for a NULL blob
select count(*)
into :ll_temp
from tadtp_doc_ackgts
where emp_id = :ll_emp_id
and doc_id = :ll_doc_id
and ackgt_date = :ldt_ackgt_date
and pdf_file is null;
//Determines NULL and IBLOB value
if (ll_temp = 0) then
dwi_status = this.GetItemStatus(row, 0, Primary!)
if (dwi_status = New! OR dwi_status = NewModified!) then
lbl_null = true
lbl_iblob = true
else
lbl_null = false
lbl_iblob = false
end if
else
lbl_null = true
lbl_iblob = false
end if
//Opens the document in READ ONLY mode if the user only has READ access
if (ls_access = ls_READONLY) then
//Is the blob NULL
if (lbl_null) then
//Message to user
MessageBox("FYI", "A PDF has not been associated with this record yet.")
else
//Updates Blob DW if it has been modified
if (dw_rblob.RowCount() > 0) then
if (dw_rblob.GetItemStatus(1, 0, Primary!) <> NotModified!) then dw_rblob.Update()
end if
//Retreives data in the Blob DW
ll_rows = dw_rblob.Retrieve(ll_emp_id, ll_doc_id, ldt_ackgt_date)
//Opens the document and allow editing
dw_rblob.OLEActivate(ll_rows, "blob_1", 0)
end if
else
//Is the blob NULL
if (lbl_null AND NOT ibl_pdf_set[row]) then
//Opens window
open(w_acquire)
//User did not specify anything
if (Message.DoubleParm = -1) then return
//Gets the returned string
ls_template = Message.StringParm
//Determines what Blob DW to populate
if (lbl_iblob) then
ll_rows = dw_iblob.InsertRow(0)
dw_iblob.SetItem(ll_rows, "emp_id", ll_emp_id)
dw_iblob.SetItem(ll_rows, "doc_id", ll_doc_id)
dw_iblob.SetItem(ll_rows, "ackgt_date", ldt_ackgt_date)
dw_iblob.SetItemStatus(ll_rows, 0, Primary!, DataModified!)
else
ll_rows = dw_rblob.Retrieve(ll_emp_id, ll_doc_id, ldt_ackgt_date)
end if
//Sets the string as the PDF template
if (lbl_iblob) then
dw_iblob.object.blob_1.Template = ls_template
else
dw_rblob.object.blob_1.Template = ls_template
end if
//Changes flag
ibl_pdf_set[row] = true
//Opens the document and allow editing
if (lbl_iblob) then
dw_iblob.OLEActivate(ll_rows, "blob_1", 0)
else
dw_rblob.OLEActivate(ll_rows, "blob_1", 0)
end if
//Makes sure the DW knows there's modified data
this.SetItem(row, "emp_id", ll_emp_id)
else
//Determines what Blob DW to activate
if (lbl_iblob) then
//Initialize variable
ll_row = 1
//Goes through all the rows
do while(ll_row <= dw_iblob.RowCount())
//Finds the correct row in the Blob DW
ll_row = dw_iblob.Find("emp_id = " + string(ll_emp_id) + " and doc_id = " + string(ll_doc_id), ll_row, dw_iblob.RowCount())
//Makes sure its the right date
if (dw_iblob.GetItemDateTime(ll_row, "ackgt_date") = ldt_ackgt_date) then exit
//Increments
ll_row++
loop
//As long as we have a row
if (ll_row > 0) then
//Opens the document and allow editing
dw_iblob.OLEActivate(ll_row, "blob_1", 0)
//Makes sure the DW knows there's modified data
this.SetItem(row, "emp_id", ll_emp_id)
end if
else
//Updates Blob DW if it has been modified
if (dw_rblob.RowCount() > 0) then
if (dw_rblob.GetItemStatus(1, 0, Primary!) <> NotModified!) then dw_rblob.Update()
end if
//Retrieves data for Blob DW
ll_rows = dw_rblob.Retrieve(ll_emp_id, ll_doc_id, ldt_ackgt_date)
//Opens the document and allow editing
dw_rblob.OLEActivate(ll_rows, "blob_1", 0)
//Makes sure the DW knows there's modified data
this.SetItem(row, "emp_id", ll_emp_id)
end if
end if
end if
end if
end if