主要原因是第一張訂單核准後,自動發生產通知單而設計
#josh
#GLOBALS "../../aws/4gl/aws_efgw.inc"
function postEF()
DEFINE l_status LIKE type_file.num10,
l_Result STRING,
l_strXMLInput STRING,
SenderIP STRING,
EFLogonID STRING,
OrgUnitID STRING,
PlantID STRING,
ProgramID STRING,
SourceFormID STRING,
SourceFormNum STRING,
FormCreatorID STRING,
FormOwnerID STRING,
head STRING,
body STRING
DEFINE sr_head RECORD
oea01 LIKE oea_file.oea01,
oea02 LIKE oea_file.oea02,
oea03 LIKE oea_file.oea03
END RECORD
DEFINE sr_body RECORD
oeb03 LIKE oeb_file.oeb03,
oeb04 LIKE oeb_file.oeb04,
oeb06 LIKE oeb_file.oeb06,
ima021 LIKE ima_file.ima021,
oeb11 LIKE oeb_file.oeb11,
oeb906 LIKE oeb_file.oeb906,
oeb05 LIKE oeb_file.oeb05,
oeb12 LIKE oeb_file.oeb12,
oeb16 LIKE oeb_file.oeb16
END RECORD
LET EFGateWay_soapServerLocation = "http://10.3.1.1/EFGateWayofTP/EFTPService.asmx"
let l_strXMLInput = "<Request><RequestMethod>CreateForm</RequestMethod><LogOnInfo><SenderIP>@SenderIP</SenderIP><ReceiverIP>10.3.1.1</ReceiverIP><EFSiteName>EFNET</EFSiteName><EFLogonID>@EFLogonID</EFLogonID><OrgUnitID>@OrgUnitID</OrgUnitID><TPServerIP>10.3.1.2</TPServerIP><TPServerEnv>topprod</TPServerEnv></LogOnInfo><RequestContent><Form><PlantID>@PlantID</PlantID><ProgramID>@ProgramID</ProgramID><SourceFormID>@SourceFormID</SourceFormID><SourceFormNum>@SourceFormNum</SourceFormNum><FormCreatorID>@FormCreatorID</FormCreatorID><FormOwnerID>@FormOwnerID</FormOwnerID><ContentText><title>title_xml</title><head>@head</head><body>@body</body><attachment>0</attachment></ContentText></Form></RequestContent></Request>"
#LogOnInfo start
let SenderIP = fgl_getenv("FGLSERVER") #取得登入者IP EX:10.3.1.102
CALL cl_replace_str( l_strXMLInput, "@SenderIP", SenderIP) RETURNING l_strXMLInput
let EFLogonID = g_oea.oeauser #登入者帳號 g_user EX:P00282 #填表人
CALL cl_replace_str( l_strXMLInput, "@EFLogonID", EFLogonID) RETURNING l_strXMLInput
let OrgUnitID = g_grup #登入者部門 EX:M720
CALL cl_replace_str( l_strXMLInput, "@OrgUnitID", OrgUnitID) RETURNING l_strXMLInput
#LogOnInfo end
#RequestContent start
let PlantID = g_plant #工廠代碼 Ex:TSC
CALL cl_replace_str( l_strXMLInput, "@PlantID", PlantID) RETURNING l_strXMLInput
let ProgramID = "axmt410_ef" #程式代號Ex:axmt410 g_prog
CALL cl_replace_str( l_strXMLInput, "@ProgramID", ProgramID) RETURNING l_strXMLInput
let SourceFormID = g_oea.oea01[1,5] #表單單別Ex: B101,本來是[1,4],但因同時訂單自動確認又發生產通知會lock,所以故意錯開抓不到自動確認才不卡彈
CALL cl_replace_str( l_strXMLInput, "@SourceFormID", SourceFormID) RETURNING l_strXMLInput
let SourceFormNum = g_oea.oea01 #表單單號Ex:B101-21110001
CALL cl_replace_str( l_strXMLInput, "@SourceFormNum", SourceFormNum) RETURNING l_strXMLInput
let FormCreatorID = g_user #Ex:P00282
CALL cl_replace_str( l_strXMLInput, "@FormCreatorID", FormCreatorID) RETURNING l_strXMLInput
let FormOwnerID = g_oea.oea14 #表單關係人Ex:P00282
CALL cl_replace_str( l_strXMLInput, "@FormOwnerID", FormOwnerID) RETURNING l_strXMLInput
#RequestContent end
#head start
let g_sql = "select oea01,oea02,oea032 from oea_file where oea01=?"
PREPARE ef_head_pre FROM g_sql
DECLARE ef_head_cur CURSOR FOR ef_head_pre
FOREACH ef_head_cur USING g_oea.oea01 INTO sr_head.*
let head = "<oea01>", sr_head.oea01 CLIPPED, "</oea01>", ASCII 10,
"<oea02>", sr_head.oea02 CLIPPED, "</oea02>", ASCII 10,
"<oea03>", sr_head.oea03 CLIPPED, "</oea03>", ASCII 10
END FOREACH
CALL cl_replace_str( l_strXMLInput, "@head", head) RETURNING l_strXMLInput
#head end
#body start
let g_sql = "select oeb03, oeb04, oeb06, (select ima021 from ima_file where ima01=oeb04) ima021, oeb11, oeb906, oeb05, oeb12, oeb16 from oeb_file where oeb01=?"
PREPARE ef_body_pre FROM g_sql
DECLARE ef_body_cur CURSOR FOR ef_body_pre
let body = ""
FOREACH ef_body_cur USING g_oea.oea01 INTO sr_body.*
let body = body ,
"<record>", ASCII 10,
"<oeb03>", sr_body.oeb03 CLIPPED, "</oeb03>", ASCII 10,
"<oeb04>", sr_body.oeb04 CLIPPED, "</oeb04>", ASCII 10,
"<oeb06>", sr_body.oeb06 CLIPPED, "</oeb06>", ASCII 10,
"<ima021>", sr_body.ima021 CLIPPED, "</ima021>", ASCII 10,
"<oeb11>", sr_body.oeb11 CLIPPED, "</oeb11>", ASCII 10,
"<oeb906>", sr_body.oeb906 CLIPPED, "</oeb906>", ASCII 10,
"<oeb05>", sr_body.oeb05 CLIPPED, "</oeb05>", ASCII 10,
"<oeb12>", sr_body.oeb12 CLIPPED, "</oeb12>", ASCII 10,
"<oeb16>", sr_body.oeb16 CLIPPED, "</oeb16>", ASCII 10,
"</record>", ASCII 10
END FOREACH
CALL cl_replace_str( l_strXMLInput, "@body", body) RETURNING l_strXMLInput
#body end
call EFGateWay_TipTopCoordinator(l_strXMLInput)
RETURNING l_status, l_Result
#display l_status
#display l_Result
end function
#DEBUG
#let l_strXMLInput = "<Request><RequestMethod>CreateForm</RequestMethod><LogOnInfo><SenderIP>10.3.1.102</SenderIP><ReceiverIP>10.3.1.1</ReceiverIP><EFSiteName>EFNET</EFSiteName><EFLogonID>P00282</EFLogonID><OrgUnitID>M720</OrgUnitID><TPServerIP>10.3.1.2</TPServerIP><TPServerEnv>topprod</TPServerEnv></LogOnInfo><RequestContent><Form><PlantID>TSC_TEST07</PlantID><ProgramID>axmt410_ef</ProgramID><SourceFormID>B101</SourceFormID><SourceFormNum>B101-21110001@</SourceFormNum><FormCreatorID>tiptop</FormCreatorID><FormOwnerID>P00282</FormOwnerID><ContentText><title>title_xml</title><head><oea01>B101-21110001</oea01>\n<oea02>21/11/02</oea02>\n<oea03>台積電</oea03>\n</head><body><record>\n<oeb03> 1</oeb03>\n<oeb04>MISC</oeb04>\n<oeb06>TT</oeb06>\n<ima021></ima021>\n<oeb11></oeb11>\n<oeb906>N</oeb906>\n<oeb05>PCS</oeb05>\n<oeb12> 1.000</oeb12>\n<oeb16>21/11/02</oeb16>\n</record>\n<record>\n<oeb03> 2</oeb03>\n<oeb04>MISC</oeb04>\n<oeb06>PP</oeb06>\n<ima021></ima021>\n<oeb11></oeb11>\n<oeb906>N</oeb906>\n<oeb05>PCS</oeb05>\n<oeb12> 5.000</oeb12>\n<oeb16>21/11/02</oeb16>\n</record>\n</body><attachment>0</attachment></ContentText></Form></RequestContent></Request>"