Step 2 Create Business Object Detailer

VLF Windows Application Development

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 uSkillChanged 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 uShow method, passing employee number and skill code.

When displaying an employee skill the BOD will enable a Delete button.

The BOB will have a Pop-Up Menu on the employee skills list, which will invoke the BOD's uNew method passing the employee number..

1.  Create a new Reusable Part / Panel:

     Name: iiiVFW19

     Description: 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 Design view resize the panel to approximately Height = 350 and Width = 370.

     Use the Design ribbon to give iiiVFW19 an Attachment layout manager.

3.  Drop a Panel at the bottom of the main panel. Change its Name to BUTTON_PANEL.

4.  Select BUTTON_PANEL and give it a Flow Across layout manager.

5.  With the BUTTON_PANEL selected, use the Layout Helper / Layout Manager Details tab and select Category = Margins and set Left and Top = 10 pixels.

6.  Drag and drop two Push Buttons onto BUTTON_PANEL. Set up their properties as:

Caption

Name

Save

PHBN_SAVE

Delete

PHBN_DELETE

 

7.  Create a Click event routine for each button.

8.  Drop a Panel into the center of the main Panel and change its Name to DETAIL_PANEL.

9.  Give DETAIL_PANEL a Flow Down layout manager. On the Layout Helper / Layout Manager Details tab, select Category = Margins and use the All setting to set margins of 7 pixels.

10. On the Repository tab, find the file PSLSKL and drop fields SKILCODE, GRADE, COMMENT and DATEACQ onto DETAIL_PANEL.

11. Save your component.

12. Create a uShow 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, Length 3.

Define Field(#request) Type(*char) Length(3)

14. Complete the uShow 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 uNew 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 uNew 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 uSkillChanged.

define_evt NAME(uSkillChanged)

19. Complete the Save push button Click 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 uSkillChanged

d.  When request is NEW, INSERT all fields to PSLSKL

e.  Check status code and signal uSkillChanged.

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 Delete push button Click event routine, which should:

a.  Delete from the file PSKSKL

b.  Check status and signal uSkillChanged 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.