Step 2. Create Business Object Detailer.
VFW084 – A Business Object Browser and Detailer
In this step you will create a reusable part which will be displayed on the RIGHT_PANEL in iiiVFW18.
This is the Business Object Detailer for an employee skill, which will be referred to as the BOD.
The BOB will invoke the BOD to display details or create a new employee skill.
The BOD will signal
when an employee skill has been updated, created or deleted.When an item in the SKILL_LIST is selected, the BOB will invoke the BOD's
method, passing employee number and skill code.When displaying an employee skill the BOD will enable a
button.The BOB will have a
on the employee skills list, which will invoke the BOD's method passing the employee number..1. Create a new Reusable Part / Panel:
iiiVFW19
Employee Skill Detailer
Note: This component does not interact directly with Framework components. It therefore does not need to have VF_AC010 as its ancestor.
2. In the 350 and = 370.
view resize the panel to approximately =Use the
ribbon to give iiiVFW19 an layout manager.3. Drop a Panel at the bottom of the main panel. Change its BUTTON_PANEL.
to4. Select BUTTON_PANEL and give it a
layout manager.5. With the BUTTON_PANEL selected, use the Margins and set and = 10 pixels.
tab and select =6. Drag and drop two
onto BUTTON_PANEL. Set up their properties as:
Caption |
Name |
Save |
PHBN_SAVE |
Delete |
PHBN_DELETE |
7. Create a
event routine for each button.8. Drop a DETAIL_PANEL.
into the center of the main Panel and change its to9. Give DETAIL_PANEL a Margins and use the setting to set margins of 7 pixels.
layout manager. On the tab, select =10. On the
tab, find the file PSLSKL and drop fields SKILCODE, GRADE, COMMENT and DATEACQ onto DETAIL_PANEL.11. Save your component.
12. Create a
method routine, with input parameters based on EMPNO and SKILCODE.Mthroutine Name(uShow)
Define_Map For(*input) Class(#empno) Name(#i_empno)
Define_Map For(*input) Class(#skilcode) Name(#i_skill)
Endroutine
13. Define a character work field, REQUEST, 3.
Define Field(#request) Type(*char) Length(3)
14. Complete the
routine, which should:a. Set Request to DET
b. Set EMPNO and SKILCODE from the values input to this method
c. Fetch all employee skills from file PSLSKL.
Your code should look like the following. Changes are highlighted in red.
Mthroutine Name(uShow)
Define_Map For(*input) Class(#empno) Name(#i_empno)
Define_Map For(*input) Class(#skilcode) Name(#i_skill)
#request := DET
#empno := #i_empno
#SKILCODE := #i_skill
Fetch Fields(*all) From_File(pslskl) With_Key(#empno #SKILCODE) Val_Error(*next)
If_Status Is_Not(*OKAY)
Message Msgtxt('Employee skill not found')
Endif
Endroutine
15. Create a
method routine with an input parameter i_empno, based on EMPNO.Mthroutine Name(uNew)
Define_Map For(*input) Class(#empno) Name(#i_empno)
Endroutine
16. Define a Group_by, named SKILDATA for fields SKILCODE, GRADE, COMMENT and DATEACQ, at component level.
17. Complete the
method routine which should:a. Set request to NEW
b. Set EMPNO to the value input to this method
c. Set SKILDATA to *null
Mthroutine Name(uNew)
Define_Map For(*input) Class(#empno) Name(#i_empno)
#empno := #i_empno
#request := NEW
#skildata := *default
Endroutine
18. Define an event
.define_evt NAME(uSkillChanged)
19. Complete the
push button event routine, which should:a. Handle a request of DET or NEW using a CASE/ENDCASE.
b. When request is DET, UPDATE all fields in PSLSKL
c. Check status code and signal
d. When request is NEW, INSERT all fields to PSLSKL
e. Check status code and signal
.Your code should look like the following:
Evtroutine Handling(#PHBN_SAVE.Click)
Case (#request)
When (= DET)
Update Fields(*all) In_File(pslskl) Val_Error(*next)
If_Status Is(*okay)
Signal Event(uSkillChanged)
Else
Message Msgtxt('Employee skill update failed')
Endif
When (= NEW)
Insert Fields(*all) To_File(pslskl) Val_Error(*next)
If_Status Is(*okay)
Signal Event(uSkillChanged)
Else
Message Msgtxt('Add Employee skill failed')
Endif
Endcase
Endroutine
20. Complete the
push button event routine, which should:a. Delete from the file PSKSKL
b. Check status and signal
and issue an error message:Evtroutine Handling(#PHBN_DELETE.Click)
Delete From_File(pslskl) Val_Error(*next)
If_Status Is(*okay)
Signal Event(uSkillChanged)
Else
Message Msgtxt('Employee skill deletion failed')
Endif
Endroutine
21. Compile reusable part iiiVFW19.