1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
Local File &fileLog; Local ApiObject &oSession, &oZlOrdercomCi; Local ApiObject &oZlOrderDetCollection, &oZlOrderDet;
Function errorHandler() Local ApiObject &oPSMessageCollection, &oPSMessage; Local number &i; Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType; &oPSMessageCollection = &oSession.PSMessages; For &i = 1 To &oPSMessageCollection.Count &oPSMessage = &oPSMessageCollection.Item(&i); &sErrMsgSetNum = &oPSMessage.MessageSetNumber; &sErrMsgNum = &oPSMessage.MessageNumber; &sErrMsgText = &oPSMessage.Text; rem &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText); MessageBox(0, "", 9999, 9999, "" | &sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText); End-For; rem ***** Delete the Messages from the collection *****; &oPSMessageCollection.DeleteAll(); End-Function;
try rem ***** Set the Log File *****; rem &fileLog = GetFile("C:\Users\zhaolong\AppData\Local\Temp\ZL_ORDERCOM_CI.log", "w", "a", %FilePath_Absolute); rem &fileLog.WriteLine("Begin"); rem ***** Get current PeopleSoft Session *****; &oSession = %Session; rem ***** Set the PeopleSoft Session Error Message Mode *****; rem ***** 0 - None *****; rem ***** 1 - PSMessage Collection only (default) *****; rem ***** 2 - Message Box only *****; rem ***** 3 - Both collection and message box *****; &oSession.PSMessagesMode = 1; rem ***** Get the Component Interface *****; &oZlOrdercomCi = &oSession.GetCompIntfc(CompIntfc.ZL_ORDERCOM_CI); If &oZlOrdercomCi = Null Then errorHandler(); throw CreateException(0, 0, " getCi faidled"); End-If; rem ***** Set the Component Interface Mode *****; &oZlOrdercomCi.InteractiveMode = True; &oZlOrdercomCi.GetHistoryItems = True; &oZlOrdercomCi.EditHistoryItems = True; rem ***** Set Component Interface Get/Create Keys *****; &oZlOrdercomCi.ZL_ORDERID = GetLevel0()(1).ZL_ORDER_HEL_1.ZL_ORDERID.Value; rem ***** Execute Get *****; If Not &oZlOrdercomCi.Get() Then MessageBox(0, "", 9999, 9999, "ci没有"); rem ***** Execute Create ******; If Not &oZlOrdercomCi.Create() Then; rem ***** Unable to Create Component Interface for the Add keys provided. *****; MessageBox(0, "", 9999, 9999, "ci对象创建失败"); errorHandler(); throw CreateException(0, 0, "Create failed"); End-If; End-If; rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; &oZlOrdercomCi.ZL_ORDERID = GetLevel0()(1).ZL_ORDER_HEL_1.ZL_ORDERID.Value; MessageBox(0, "", 9999, 9999, "id赋值"); &oZlOrdercomCi.ZL_ORDERDESC = GetLevel0()(1).ZL_ORDER_HEL_1.ZL_ORDERDESC.Value; MessageBox(0, "", 9999, 9999, "描述赋值"); &oZlOrderDetCollection = &oZlOrdercomCi.ZL_ORDER_DET; Local integer &i17; For &i17 = &oZlOrderDetCollection.count To 1 Step - 1 &oZlOrderDetCollection.deleteItem(&i17); End-For; MessageBox(0, "", 9999, 9999, "清空集合"); For &i17 = 1 To GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).ActiveRowCount; &oZlOrderDetCollection.insertItem(&oZlOrderDetCollection.count); &oZlOrderDet = &oZlOrderDetCollection.Item(&oZlOrderDetCollection.count); &oZlOrderDet.ZL_ORDER_SUBID = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDER_SUBID.Value; &oZlOrderDet.ZL_ORDER_SUBTYPE = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDER_SUBTYPE.Value; &oZlOrderDet.ZL_ORDER_SUBDESC_1 = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDER_SUBDESC.Value; &oZlOrderDet.ZL_ORDERQUAN = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDERQUAN.Value; &oZlOrderDet.ZL_ORDERPRI = GetLevel0()(1).GetRowset(Scroll.ZL_ORDER_DET_1).GetRow(&i17).ZL_ORDER_DET_1.ZL_ORDERPRI.Value; MessageBox(0, "", 9999, 9999, "完成第" | &i17 | "个record赋值"); End-For; rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; If Not &oZlOrdercomCi.Save() Then; MessageBox(0, "", 9999, 9999, "订单导入失败"); errorHandler(); throw CreateException(0, 0, "Save failed"); Else MessageBox(0, "", 9999, 9999, "订单导入成功"); End-If; rem ***** Execute Cancel *****; If Not &oZlOrdercomCi.Cancel() Then; errorHandler(); throw CreateException(0, 0, "Cancel failed"); End-If; catch Exception &ex MessageBox(0, "", 9999, 9999, "运行异常"); end-try;
|