1. 程式人生 > >T100——XML介面程式碼記錄

T100——XML介面程式碼記錄

  1 PRIVATE FUNCTION cwssp002_process()
  2    #add-point: 服務邏輯主要處理段的ADP
  3     DEFINE l_node xml.DomNode
  4     DEFINE l_node2 xml.DomNode
  5     DEFINE l_cnt1      LIKE type_t.num5
  6     DEFINE l_cnt2      LIKE type_t.num5
  7     DEFINE l_j    INTEGER
  8     DEFINE l_i    INTEGER
  9     DEFINE l_success   LIKE type_t.num5
10 11 DEFINE l_pmaa096 LIKE pmaa_t.pmaa096 12 DEFINE l_pmaa097 LIKE pmaa_t.pmaa097 13 14 CALL s_transaction_begin() 15 LET l_cnt1 = awsp900_01_getMasterRecordLength("xmdk_t") 16 FOR l_j=1 TO l_cnt1 17 INITIALIZE g_xmdk_m.* TO NULL 18 ##########一般欄位給值 19
LET g_xmdk_m.xmdkent = g_enterprise 20 LET g_xmdk_m.xmdksite = g_site 21 LET g_xmdk_m.xmdkownid = g_user 22 LET g_xmdk_m.xmdkowndp = g_dept 23 LET g_xmdk_m.xmdkcrtid = g_user 24 LET g_xmdk_m.xmdkcrtdp = g_dept 25 LET g_xmdk_m.xmdkcrtdt = cl_get_current()
26 LET g_xmdk_m.xmdkmodid = g_user 27 LET g_xmdk_m.xmdkmoddt = cl_get_current() 28 LET g_xmdk_m.xmdkstus = 'N' 29 LET g_xmdk_m.xmdk000 = '6' 30 LET g_xmdk_m.xmdkud008 = 'N' 31 LET g_xmdk_m.xmdkud009 = 'N' 32 LET g_xmdk_m.xmdkud005 = 'N' 33 LET g_xmdk_m.xmdk045 = '1' 34 LET g_xmdk_m.xmdk082 = '1' 35 LET g_xmdk_m.xmdk014 = 'N' 36 LET g_xmdk_m.xmdk084 = '1' 37 LET g_xmdk_m.xmdk042 = '1' 38 LET g_xmdk_m.xmdk043 = '1' 39 LET g_xmdk_m.xmdk085 = '1' 40 LET g_xmdk_m.xmdk046 = '1' 41 LET g_xmdk_m.xmdk083 = 'N' 42 LET g_xmdk_m.xmdkud011 = '100' 43 LET g_xmdk_m.xmdkstus = 'N' 44 # LET g_xmdk_m.xmdk003 = g_user 45 # LET g_xmdk_m.xmdk004 = g_dept 46 LET g_xmdk_m.xmdk030 = '10' 47 ########## 48 LET l_node = awsp900_01_getMasterRecord(l_j,"xmdk_t") 49 LET g_xmdk_m.xmdkdocno = awsp900_01_getRecordField(l_node,"xmdkdocno") 50 LET g_xmdk_m.xmdkdocdt = awsp900_01_getRecordField(l_node,"xmdkdocdt") 51 LET g_xmdk_m.xmdk001 = g_xmdk_m.xmdkdocdt 52 LET g_xmdk_m.xmdk007 = awsp900_01_getRecordField(l_node,"xmdk007") 53 LET g_xmdk_m.xmdk054 = awsp900_01_getRecordField(l_node,"xmdk054") 54 LET g_xmdk_m.xmdkua001 = awsp900_01_getRecordField(l_node,"xmdkua001") 55 # 56 SELECT pmaa096,pmaa097 INTO l_pmaa096,l_pmaa097 FROM pmaa_t WHERE pmaaent = g_enterprise AND pmaa001 = g_xmdk_m.xmdk007 57 LET g_xmdk_m.xmdk003 = l_pmaa096 58 LET g_xmdk_m.xmdk004 = l_pmaa097 59 IF cl_null(g_xmdk_m.xmdk003) THEN 60 LET g_xmdk_m.xmdk003 = g_user 61 LET g_xmdk_m.xmdk004 = g_dept 62 END IF 63 # 64 IF NOT s_aooi200_chk_slip(g_site,'',g_xmdk_m.xmdkdocno,'axmt600') THEN #檢查單據別 65 LET g_status.code = "aoo-00291" 66 LET g_status.sqlcode = 'aoo-00291' 67 LET g_status.description='單據別:',g_xmdk_m.xmdkdocno,'不存在' 68 LET l_success = FALSE 69 CALL s_transaction_end('N','0') 70 LET l_return.timestamp=cl_get_current() 71 LET l_return.result=g_xmdk_m.xmdkdocno 72 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 73 RETURN 74 END IF 75 76 IF NOT cl_null(g_xmdk_m.xmdk007) THEN #檢查客戶編號是否存在 77 INITIALIZE g_chkparam.* TO NULL 78 LET g_chkparam.arg1 = g_xmdk_m.xmdk007 79 LET g_chkparam.arg2 = g_site 80 IF NOT cl_chk_exist("v_pmaa001_3") THEN 81 LET g_status.code = "sub-00416" 82 LET g_status.sqlcode = "sub-00416" 83 LET g_status.description = g_xmdk_m.xmdk007 84 LET l_return.timestamp = cl_get_current() 85 LET l_return.result = g_xmdk_m.xmdkdocno 86 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 87 CALL s_transaction_end('N','0') 88 LET l_success = FALSE 89 RETURN 90 END IF 91 END IF 92 93 CALL s_aooi200_gen_docno(g_site,g_xmdk_m.xmdkdocno,g_today,'axmt600') #生成銷退單號 94 RETURNING l_success,g_xmdk_m.xmdkdocno 95 96 IF l_success THEN 97 CALL s_axmt540_client_partner(g_xmdk_m.xmdkdocno,g_xmdk_m.xmdk007,'1') RETURNING g_xmdk_m.xmdk008 #帶出收款客戶 98 CALL s_axmt540_client_partner(g_xmdk_m.xmdkdocno,g_xmdk_m.xmdk007,'2') RETURNING g_xmdk_m.xmdk009 #帶出收貨客戶 99 CALL s_axmt540_client_partner(g_xmdk_m.xmdkdocno,g_xmdk_m.xmdk007,'3') RETURNING g_xmdk_m.xmdk202 #帶出發票客戶 100 CALL cwssp002__xmdk007_default() #帶出客戶預設資料 101 ELSE 102 CALL s_transaction_end('N','0') 103 LET g_status.code = "cwssp002" 104 LET g_status.sqlcode = "cwssp002" 105 LET g_status.description= "生成銷退單號出錯!" 106 LET l_success = FALSE 107 LET l_return.timestamp=cl_get_current() 108 LET l_return.result=g_xmdk_m.xmdkdocno 109 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 110 RETURN 111 END IF 112 113 INSERT INTO xmdk_t VALUES g_xmdk_m.* 114 115 IF SQLCA.sqlcode THEN 116 LET g_status.code = "cwssp002" 117 LET g_status.sqlcode = SQLCA.sqlcode 118 LET g_status.description='INSERT INTO xmdk_t 出錯!' 119 LET l_success = FALSE 120 CALL s_transaction_end('N','0') 121 LET l_return.timestamp=cl_get_current() 122 LET l_return.result=g_xmdk_m.xmdkdocno 123 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 124 RETURN 125 END IF 126 127 LET l_cnt2 = awsp900_01_getDetailRecordLength(l_node,"xmdl_t") #單身開始 128 FOR l_i=1 TO l_cnt2 129 INITIALIZE g_xmdl_d.* TO NULL 130 LET g_xmdl_d.xmdlent = g_enterprise 131 LET g_xmdl_d.xmdlsite = g_site 132 LET g_xmdl_d.xmdl007 = '1' 133 LET g_xmdl_d.xmdl013 = 'N' 134 LET g_xmdl_d.xmdl023 = 'Y' 135 LET g_xmdl_d.xmdl041 = 'N' 136 #171201 LJR ADD S 137 LET g_xmdl_d.xmdl025 = g_xmdk_m.xmdk012 #稅種 138 LET g_xmdl_d.xmdl026 = g_xmdk_m.xmdk013 #稅率 139 LET g_xmdl_d.xmdl087 = 'Y' #需自立應收否 140 LET g_xmdl_d.xmdlud011 = 0 #結算單價 141 LET g_xmdl_d.xmdlud012 = 0 #結算金額 142 LET g_xmdl_d.xmdlud013 = 0 #結算未稅金額 143 LET g_xmdl_d.xmdlud014 = 0 #結算稅額 144 #171201 LJR ADD E 145 146 LET g_xmdl_d.xmdl038 = 0 #主賬套已立賬數量 147 LET g_xmdl_d.xmdl039 = 0 #賬套二已立賬數量 148 LET g_xmdl_d.xmdl040 = 0 #賬套三已立賬數量 149 150 LET l_node2 = awsp900_01_getDetailRecord(l_node,l_i,"xmdl_t") 151 LET g_xmdl_d.xmdlseq = awsp900_01_getRecordField(l_node2,"xmdlseq") 152 LET g_xmdl_d.xmdlud001 = awsp900_01_getRecordField(l_node2,"xmdlud001") 153 LET g_xmdl_d.xmdl008 = awsp900_01_getRecordField(l_node2,"xmdl008") 154 LET g_xmdl_d.xmdl018 = awsp900_01_getRecordField(l_node2,"xmdl018") 155 LET g_xmdl_d.xmdl051 = awsp900_01_getRecordField(l_node2,"xmdl051") 156 IF NOT cl_null(g_xmdk_m.xmdkdocno) THEN 157 LET g_xmdl_d.xmdldocno=g_xmdk_m.xmdkdocno 158 END IF 159 160 IF NOT cwssp002__xmdl008_chk(g_xmdl_d.xmdl008) THEN #料號檢測 161 LET g_status.code = "cwssp002" 162 LET g_status.sqlcode = SQLCA.sqlcode 163 LET g_status.description='料號',g_xmdl_d.xmdl008,'檢測不通過!' 164 LET l_success = FALSE 165 LET l_return.timestamp=cl_get_current() 166 LET l_return.result=g_xmdk_m.xmdkdocno 167 CALL s_transaction_end('N','0') 168 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 169 RETURN 170 END IF 171 172 CALL cwssp002__xmdl008_default() #料號帶出其他項 173 174 INSERT INTO xmdl_t VALUES g_xmdl_d.* 175 176 IF SQLCA.sqlcode THEN 177 LET g_status.code = "cwssp002" 178 LET g_status.sqlcode = SQLCA.sqlcode 179 LET g_status.description='INSERT INTO xmdl_t 出錯!' 180 LET l_success = FALSE 181 LET l_return.timestamp=cl_get_current() 182 LET l_return.result=g_xmdk_m.xmdkdocno 183 CALL s_transaction_end('N','0') 184 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 185 RETURN 186 END IF 187 188 INITIALIZE g_xmdm_d.* TO NULL #多庫儲批出貨明細 189 LET g_xmdm_d.xmdment = g_enterprise 190 LET g_xmdm_d.xmdmsite = g_site 191 LET g_xmdm_d.xmdmdocno = g_xmdk_m.xmdkdocno 192 LET g_xmdm_d.xmdmseq = g_xmdl_d.xmdlseq 193 LET g_xmdm_d.xmdmseq1 = 1 194 LET g_xmdm_d.xmdm001 = g_xmdl_d.xmdl008 195 LET g_xmdm_d.xmdm005 = g_xmdl_d.xmdl014 196 LET g_xmdm_d.xmdm008 = g_xmdl_d.xmdl017 197 LET g_xmdm_d.xmdm009 = g_xmdl_d.xmdl018 198 LET g_xmdm_d.xmdm010 = g_xmdl_d.xmdl019 199 LET g_xmdm_d.xmdm011 = g_xmdl_d.xmdl020 200 201 INSERT INTO xmdm_t VALUES g_xmdm_d.* 202 203 IF SQLCA.sqlcode THEN 204 LET g_status.code = "cwssp002" 205 LET g_status.sqlcode = SQLCA.sqlcode 206 LET g_status.description='INSERT INTO xmdm_t 出錯!' 207 LET l_success = FALSE 208 LET l_return.timestamp=cl_get_current() 209 LET l_return.result=g_xmdk_m.xmdkdocno 210 CALL s_transaction_end('N','0') 211 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 212 RETURN 213 END IF 214 215 END FOR 216 217 END FOR 218 219 IF l_success THEN 220 LET l_return.timestamp=cl_get_current() 221 LET l_return.result=g_xmdk_m.xmdkdocno 222 CALL s_transaction_end('Y','0') 223 ELSE 224 LET g_status.code = "wss-00199" 225 LET g_status.description = "銷退單生成出錯!" 226 LET l_return.timestamp=cl_get_current() 227 CALL s_transaction_end('N','0') 228 END IF 229 CALL awsp900_01_addParameterRecord(util.JSONObject.fromFGL(l_return)) 230 231 #end add-point 232 END FUNCTION

 

 

XML

 1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 2 <request type="sync" key="d7cd4a500f2d7563313681298995c97f">
 3     <host prod="XSEB" ver="1.0" ip="172.18.22.8" lang="zh_CN" timezone="+8" timestamp="20151201131129815" acct="tiptop"/>
 4     <service prod="T100" name="Axmt600Update" srvver="1.0" id="topprd"/>
 5     <datakey type="FOM">
 6         <key name="EntId">60</key>
 7         <key name="CompanyId">D</key>
 8     </datakey>
 9     <payload>
10         <param key="data" type="XML">
11         <![CDATA[
12          <Request>
13             <RequestContent>
14                <Document>
15                   <RecordSet id="1">
16                      <Master name="xmdk_t">
17                         <Record>
18                            <Field name="xmdkdocno" value="8901"/>
19                            <Field name="xmdkdocdt" value="2017/12/01"/>
20                            <Field name="xmdk007" value="A0120004"/>
21                            <Field name="xmdk054" value="測試單"/>
22                            <Detail name="xmdl_t">
23                               <Record>
24                                  <Field name="xmdlseq" value="1"/>
25                                  <Field name="xmdlud001" value="BX057-03"/>
26                                  <Field name="xmdl008" value="3151220003"/>
27                                  <Field name="xmdl018" value="20"/>
28                                  <Field name="xmdl051" value="測試1"/>
29                               </Record>
30                              <Record>
31                                  <Field name="xmdlseq" value="2"/>
32                                  <Field name="xmdlud001" value="BAA32-4"/>
33                                  <Field name="xmdl008" value="3101010001"/>
34                                  <Field name="xmdl018" value="10"/>
35                                  <Field name="xmdl051" value="測試2"/>
36                               </Record>
37                            </Detail>
38                         </Record>
39                      </Master>
40                  </RecordSet>
41              </Document>
42          </RequestContent>
43       </Request>
44       ]]>
45      </param>
46     </payload>
47 </request>