Work order structure window: In the following example we create a button on the right side with "Close".
If you click on the button, the program will close the current and all marked work orders and work order rows.
You can see
- Create Button
- work with SQL
- work with BSL GET and POST
- read selected lines

see BeasServiceLayer DataWindow setvar functions
global function form_loaded
// create button on right side with text "Close"
create=button=name=CloseOrder,text=Close order,position=1
end global
global function dw_master_item_closeorder_click
for ll_row=1 to <dw_1.rowcount>
if <dw_1.isselect:[ll_row]> = true then
if <dw_1.item.zeilentyp.value> n= 0 then
closeworkorder()
end if
if <dw_1.item.zeilentyp.value> n= 10 then
closeworkorderpos()
end if
if <return> n= -1 then
return -1
end if
end if
next
retrieve
function closeworkorder
// read work order number from defined row
setvar=ll_DocEntry=<dw_1.item.belnr_id:[ll_row].value>
// Work with SQL: with into you can define the target Variable
// in bracket you can define the number. #0 => no decimal places
//select coalesce("ABGKZ",'N') into :ls_closed from "BEAS_FTHAUPT" where "BELNR_ID"=<ll_DocEntry,#0>
//if <ls_closed> = J then
// return 1
//end if
// Better way: BSL- check close flag. is 1 or 0
instance bsl b
b.get=Workorder(<ll_DocEntry,#0>)/Closed/$value
if <b.ret_value> = 1 then
return 1
end if
// Close work order
b.get=Workorder/Close(<ll_DocEntry,#0>)
if <b.ret_code> = -1 then
messagebox=error$<b.ret_text>
return -1
end if
// Close return separate status. If -1, then error.
if <b.ret_status> n= -1 then
messagebox=error$<b.error>
return -1
end if
dw_1.item.abgkz:[ll_row].value=J
end function
function closeworkorderpos
instance bsl b
// read work order pos number from defined row
setvar=ll_DocEntry=<dw_1.item.belnr_id:[ll_row].value>
setvar=ll_LineNumber=<dw_1.item.belpos_id:[ll_row].value>
// if position closed, then ignore
b.get=Workorder(<ll_DocEntry,#0>)/Closed/$value
if <b.ret_value> = 1 then
return 1
end if
// Close work order Position
b.get=WorkorderPos/Close(<ll_DocEntry,#0>,<ll_LineNumber,#0>)
if <b.ret_code> = -1 then
messagebox=error$<b.ret_text>
return -1
end if
// Close return separate status. If -1, then error.
if <b.ret_status> n= -1 then
messagebox=error$<b.error>
return -1
end if
dw_1.item.abgkz:[ll_row].value=J
end function
end global
|
Example Notes