F1307UpdateAssetStatus

F1307 Update Asset Status

Major Business Rule

Object Name: B1300020

Parent DLL: CMFG

Location: Client/Server

Language: C

Functional Description

Purpose

The purpose of F1307 Edit Asset Status is to insert a record in the Equipment Status Table 
(F1307) and change the Status on the Current record within the Location Tracking Table (F1204) when 

a record is added to the Asset Master Table (F1201) or when a change is made to the Status 

(EQST) on the Asset Master.  Additionally, the program should optionally change the Asset Status of 

Children Assets when changing the Asset Status of the Parent Asset. The Location Tracking table 

is only updated with the new status when there is only a single location for the Asset.


Setup Notes and Prerequisites


Special Logic


This function has the following special logic which differs from X1307 in the World A8.1 code.

• 
The Asset Master table (F1201) provides a relationship between parent and child assets. This 
function will (optionally) build an Asset Master tree which defines all children of the given 

asset number and update the status of the children assets as well.

• The ONLY Type of Record that this business function can handle is type '1' for Equipment 
Status updates.  The X1307 in the World A8.1 code was designed to handle type '1' and '2' status 

updates. To handle type '2' updates in OneWorld, please use B1300030.

• 
This business function returns all errors in the Error Code parameter. It will not set  errors 
in OneWorld.




Technical Specification


1.// Set Defaults for Input Parameters
2.If Record Type (TREC) <> '1'
3. Record Type (TREC) = '1'

4.End If

5.If Remark (RMK) = "" 

6. Remark (RMK) = " "

7.End If

8.If Processing Mode (EV01) <> '1' And <> '2' And <> '3'

9. Processing Mode (EV01) = '1'

10.End If

11.If Update Children (EV01) <> '1' And <> '0'

12. Update Children (EV01) = '0'

13.End If

14.// Initialize Error Code

15.Error Code (ERRC) = '0'

16.Error Code (wf) = '0'

17.//

18.// Open Tables

19.Open F1201, F1307 and F1204.

20.

21.// 

22.// Validate Input Date and Time for Input Asset Number (NUMR)

23.Call Internal Function Check Date Overlap (Asset Number(NUMR))

24.

25.If Error Code (wf) <> '0' And Processing Mode (EV01) = '1'

26. Error Code (ERRC) = Error Code (wf)

27.End If

28.//

29.If Error Code (ERRC) = '0' And Processing Mode (EV01) <> '1' And Write (wf) = '1'

30. // Build Asset Tree if Needed

31. If Update Children (EV01) = '1' 

32. Call F1201 Create Parent Child Asset Cache (B1200050) to build  Asset Tree.

33. 'C' 'e0 Mode 

34. Asset Number (NUMR)'e0 Asset Number

35. End If

36.

37. // Update Status for Input Asset Item Number (NUMR)

38. Call Internal Function Update Asset Status (Asset Number(NUMR))

39. //

40. If Update Children (EV01) = '1' And Process Mode (EV01) <> '1'

41. Call Cache Process Asset Tree (B1200100) to retrieve first  record 

(which is the Asset Item Number (NUMR).

42. While Cache Error = '0'

43. Call Cache Process Asset Tree (B1200100) to retrieve next 

record.

44. If Cache Error = '0'

45. Call Internal Function Check Date Overlap (Cache Asset 

Item Number)

46. If Processing Mode (EV01) <> '1'

47. Call Internal Function Update Asset Status (Cache Asset 

Item Number)

48. End If

49. End If

50. End While

51. End If

52.End If

53.

54.If Processing Mode (EV01) = '3' And Record Type (TREC) = '1' And Write (wf) = '1' And 

Error Code (ERRC) = '0'

55.// Update Location Tracking Table F1204 ONLY when ONE 'C' type record  is found.

56. Select from F1204 using FMNUMB=Asset Item Number (NUMR), FMAL='C'.

57. Fetch from F1204

58. If Found

59. Fetch Next from F1204

60. If Not Found

61. FMEQST = New Status of Equipment(EWST)

62. Update F1204.

63. End If

64. End If

65.End If

66.If Asset Tree was Created 

67. Call F1201 Create Parent Child Asset Cache (B1200050) to Destroy  Asset Tree.

68. 'D' 'e0 Mode 

69. Asset Number (NUMR)'e0 Asset Number

70. End If

71.End If



Internal Function Check Date Overlap(Input Asset Number)

1.// Check for Date Overlap with Any History Record in F1307
2.Write (wf) = '1'

3.Fetch the record from F1307 with the highest EFTB and BEGT value and matches F1NUMR=Input 

Asset Number, F1TREC=Record Type (TREC). Save this record in DS_OPENHISTORYRECORD (wf)

4.If Fetch is Successful

5. If F1EFTB > Input Begin Date of Status (EFTB)

6. Error Code (wf) = '1'

7. Else

8. If F1EFTB = Begin Date of Status (EFTB) And F1BEGT > Begin Time of 

Status(BEGT)

9. Error Code (wf) = '1'

10. End If 

11. End If

12. // Determine if the F1307 record is the same status as the new 

status.

13. If F1EWST = New Status of Equipment(EWST)

14. Write (wf)  = '0'

15. End If

16. // Determine if Previous History Record before has same status.

17. Previous_Hist_STHR (wf) = 0

18. Previous_Hist_CUMH (wf) = 0

19. Select Records from F1307 using F1TREC='1', F1NUMR=Input Asset  Number, And 

(F1EFTB< Begin Date if Status (BEGT) Or F1EFTB=Begin  Date of Status(EFTB) And F1BEGT < 

Begin Time of Status(BEGT))

20. Fetch Record

21. If Fetch Was Successful

22. If F1EWST = New Status of Equipment(EWST)

23. Write (wf) = '0'

24. Copy F1CUMH to Previous_Hist_CUMH (wf)

25. Copy F1STHR to Previous_Hist_STHR (wf)

26. Else

27. While Fetch is Successful

28. If F1EWST = New Status of Equipment (EWST)

29. Copy F1CUMH to Previous_Hist_CUMH (wf)

30. Copy F1STHR to Previous_Hist_STHR (wf)

31. Break out from while loop.

32. End If

33. End While

34. End If

35. End If

36. // Check if there is a direct match on EFTB and BEGT

37. Fetch the record from F1307 using keys: F1NUMR=Input Asset Number, 

F1TREC=Record Type (TREC), F1EFTB= Begin Date of Status (EFTB),  F1BEGT= Begin Time of Status (BEGT)

38. If Fetch is Successful

39. // Overlap on same date/time on different status.

40. If F1EWST <> New Status of Equipment (EWST)

41. Error Code (wf) = '2'

42. End If

43. Save this record in DS_HISTORYRECORDWITHSAMESTART (wf).

44. End If

45.End If


Internal Function Update Asset Status(Input Asset Number To Update)


1.Update Old (wf) = '0'
2.// Calculate Cumulative Hours

3.Cum Hours (wf) = Previous_Hist_CUMH (wf) + Previous_Hist_STHR (wf)

4.//

5.// Calculate Meter Readings

6.Meter (wf) = ' '

7.If Record Type (TREC) = '1' And Processing Mode (EV01) <> '1'

8. HBAL (wf) = 0

9. MBAL (wf) = 0

10. FBAL (wf) = 0

11. Fetch Record from F1201 using FANUMB=Input Asset Number To Update

12.

13. Call Accumulate Date Sensitive Balances (B1200007 ) to calculate  HBAL(wf).

14. Call Accumulate Date Sensitive Balances (B1200007 ) to calculate  MBAL(wf).

15. Call Accumulate Date Sensitive Balances (B1200007 ) to calculate  FBAL(wf).

16.End If

17.//

18.If Error Code (wf) = '0'

19. // Normal Status Update and Insert with no Date Overlap Conditions.

20. // Update Open History record to close it.

21. If DS_OPENHISTORYRECORD.F1NUMR <> 0

22. Call Internal Function Calculate Hours  (DS_OPENHISTORYRECORD.F1EFTB, 

Begin Date of Status (EFTB),  DS_OPENHISTORYRECORD.F1BEGT, Begin Time of Status 

(BEGT),  Elapsed Hrs(wf)).

23. DS_OPENHISTORYRECORD.F1EFTE = Begin Date of Status (EFTB)

24. DS_OPENHISTORYRECORD.F1BEGT = Begin Time of Status (BEGT)

25. DS_OPENHISTORYRECORD.F1STHR = Elapsed Hrs(wf)

26. DS_OPENHISTORYRECORD.Audit Information fields.

27. Update F1307 using DS_OPENHISTORYRECORD. 

28. End If

29. // Insert new history record.

30. F1TREC = Record Type (TREC)

31. F1NUMR = Input Asset Number to Update

32. F1DOCO = 0

33. F1LHR = HBAL(wf)

34. F1LMR = MBAL (wf)

35. F1LFR = FBAL (wf)

36. F1EWST = New Status of Equipment (EWST)

37. F1EFTB = Begin Date of Status (EFTB)

38. F1BEGT = Begin Time of Status (BEGT)

39. F1EFTE = Null

40. F1ENDT = 0

41. F1STHR = 0

42. F1CUMH = Cum Hours (wf)

43. F1RMK = Remark (RMK)

44. Audit Information Fields.

45. Insert to F1307 

46.End If

47.//

48.If Error Code (wf) <> '0'(B1)

49.// If History Record with Same Start date and time Exists, Update it.

50. Adjust Hrs (wf) = 0

51. If DS_HISTORYRECORDWITHSAMESTART.F1NUMR <> 0(B2)

52. // It Exists

53. Update Old(wf) = '1'

54. Old Status (wf) = DS_HISTORYRECORDWITHSAMESTART.F1EWST

55. Adjust Hrs(wf) = DS_HISTORYRECORDWITHSAMESTART.F1STHR

56. DS_HISTORYRECORDWITHSAMESTART.F1EWST = New Status of Equipment 

(EWST)

57. DS_HISTORYRECORDWITHSAMESTART.F1CUMH = Cum Hours (wf)

58. DS_HISTORYRECORDWITHSAMESTART.F1RMK = Remark (RMK)

59. DS_HISTORYRECORDWITHSAMESTART.Audit Information fields.

60. Update F1307 using DS_HISTORYRECORDWITHSAMESTART

61. //

62. // Get the next record with higher EFTB and BEGT value and same 

status.

63. Select on F1307 using F1TREC= Record Type (TREC), F1NUMR= 

F1NUMR=Input Asset Number To Update, F1EFTB > Begin Date of  Status (EFTB) OR F1EFTB = 

Begin Date of Status (EFTB) And F1BEGT  > Begin Time of Status (BEGT), Order by EFTB 

Asc and BEGT Asc.

64. Fetch the F1307 record

65. If Fetch Succeeds And F1EWST = New Status of Equipment (EWST)

66. Delete from F1307 using keys in record fetched.

67. DS_HISTORYRECORDWITHSAMESTART.F1EFTE = F1EFTE(deleted rec)

68. DS_HISTORYRECORDWITHSAMESTART.F1ENDT = F1ENDT(deleted rec)

69. DS_HISTORYRECORDWITHSAMESTART.F1STHR = F1STHR(deleted rec)

70. DS_HISTORYRECORDWITHSAMESTART.Audit Information fields.

71. Update F1307 using DS_HISTORYRECORDWITHSAMESTART.

72. End If

73. //

74. // Get record next record with lower EFTB and BEGT value and 

same status.

75. Select on F1307 using F1TREC= Record Type (TREC), F1NUMR= 

F1NUMR=Input Asset Number To Update, F1EFTB < Begin Date of  Status (EFTB) OR F1EFTB = 

Begin Date of Status (EFTB) And F1BEGT  < Begin Time of Status (BEGT), Order by EFTB 

Dsc and BEGT Dsc.

76. Fetch the F1307 record

7'1a'1a

Data Structure

D1300020 - F1307, Update Asset Status

Parameter NameData ItemData TypeReq/OptI/O/Both
cRecordTypeTRECcharOPTNONE

A code that indicates whether a particular record represents a change in equipment status or a change in work order status. Valid values 
are: 1  Equipment Status Change record 2  Work Order Status Change record

mnAssetNumberNUMRMATH_NUMERICOPTNONE

The equipment number or work order number associated with a change of status.

szNewStatusOfEquipmentEWSTcharOPTNONE

The status associated with either a piece of equipment or a work order.

jdBeginDateOfStatusEFTBJDEDATEOPTNONE

The date that an address, item, transaction, or table record becomes active.  The meaning of this field differs, depending on the program.  
For example, the effective date could represent the following:    o When a change of address becomes effective.   o When a lease becomes 
effective.   o When a price becomes effective.   o When the currency exchange rate becomes effective.   o When a tax rate becomes effective. 

mnBeginTimeOfStatusBEGTMATH_NUMERICOPTNONE

The time at which the status of a piece of equipment or a work order changes. Use the HH:MM format (for example, 12:35).

szProgramIdPIDcharOPTNONE

The number that identifies the batch or interactive program (batch or interactive object). For example, the number of the Sales Order Entry 
interactive program is P4210, and the number of the Print Invoices batch process report is R42565. The program ID is a variable length value. 
It is assigned according to a structured syntax in the form TSSXXX, where: T The first character of the number is alphabetic and identifies the 
type, such as P for Program, R for Report, and so on. For example, the value P in the number P4210 indicates that the object is a 
program. SS The second and third characters of the number are numeric and identify the system code. For example, the value 42 in the number P4210 
indicates that this program belongs to system 42, which is the Sales Order Processing system. XXX The remaining characters of the numer are 
numeric and identify a unique program or report. For example, the value 10 in the number P4210 indicates that this is the Sales Order Entry 
program.

szStatusRemarkRMKcharOPTNONE

A generic field that you use for a remark, description, name, or address.

cProcessingModeEV01charOPTNONE

An option that specifies the type of processing for an event.

cUpdateChildrenStatusEV01charOPTNONE

An option that specifies the type of processing for an event.

cErrorCodeERRCcharOPTNONE

This error code indicates if any errors occurred during the creation of the Trip Document Detail (F4914) records by the Delivery Document 
Set Server program (XT4914).

Related Functions

B1200007 F1202 Accumulate Date Sensitive Balances
B1200050 F1201, Create Parent Child Asset Cache
B1200100 Cache, Process Asset Tree
B9800100 Get Audit Information

Related Tables

F1201 Asset Master File
F1204 Location Tracking Table
F1307 Status History File