Parameters
iiSessionId | input | integer | |
iiCompanyId | input | integer | |
icImportFolder | input | character | |
icExportFolder | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tconvertinstalnetxml.p)
assign viSessionId = iiSessionId
viCompanyId = iiCompanyId
vcFcComponentName = "BCInvoice":U
vcSlash = if index("UNIX":U, opsys) <> 0
then "/":U
else "~\":U
icImportFolder = replace(icImportFolder, if index("UNIX":U, opsys) <> 0 then "~\":U else "/":U, vcSlash)
icExportFolder = replace(icExportFolder, if index("UNIX":U, opsys) <> 0 then "~\":U else "/":U, vcSlash).
/* Once the Stadard log file is not reachable, we try to put the log in Temp Dir */
assign vcConvertLogFile = icImportFolder + "TConvertInstalNetXML.log":U.
assign file-info:file-name = vcConvertLogFile no-error.
if error-status:error or
file-info:file-type = ? or
index(file-info:file-type,"FRW":U) = 0
then assign vcConvertLogFile = session:temp-dir + "TConvertInstalNetXML.log":U.
assign file-info:file-name = vcConvertLogFile no-error.
if error-status:error or
file-info:file-type = ? or
index(file-info:file-type,"FRW":U) = 0
then do:
assign vcConvertLogFile = session:temp-dir + "TConvertInstalNetXML-":U + string(today,'99999999':U) + '-':U + replace(string(time,'hh:mm:ss':U),':':U,'':U) + ".log":U
vcMessage = trim(substitute(#T-19'Cannot write data to the log file in the &1 or in the &2 folders. Log file &3 has been created.':255(16072)t-19#, icImportFolder, session:temp-dir, vcConvertLogFile)).
<M-18 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
end.
<M-20 run CreatetFcDynRelForCInvoice
(output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
input from os-dir(icImportFolder) no-echo.
repeat:
import vcFileName vcFileNameFull vcFileType.
if (vcFileName = ".":U or
vcFileName = "..":U) and
vcFileType = "D":U
then next.
assign vcMessage = trim(substitute(#T-24'----------------------------------------- START XML Conversion of file &1 at &2 ---------------------------------------------':200(16216)T-24#, vcFileNameFull, string(today,'99/99/9999':U) + ' ':U + string(time,'hh:mm:ss':U))).
<M-23 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
/* The file is not a XML */
if not vcFileName matches '*.xml':U
then do:
assign vcMessage = trim(substitute(#T-5'&1 is not a file to be loaded.':100(16042)T-5#, vcFileNameFull)).
<M-6 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
next.
end.
/* ======================================== */
/* Check if the file realy exists as a file */
/* ======================================== */
assign file-info:file-name = vcFileNameFull no-error.
if error-status:error or
file-info:file-name = ? or
file-info:file-type = ? or
index(file-info:file-type,"F":U) = 0
then do :
assign vcMessage = trim(#T-10'The XML file to be converted was not found.':150(16045)t-10#) + chr(10) +
trim(substitute(#T-11'File name: &1.':255(16034)T-11#,file-info:file-name)) + chr(10) +
trim(substitute(#T-12'File type: &1.':255(16035)T-12#,file-info:file-type)) + chr(10) +
trim(substitute(#T-13'Internal error: &1.':255(16036)T-13#,(if error-status:error then #T-14'yes':4(16037)T-14# else #T-15'no':4(16038)T-15#))) + chr(10) +
(if error-status:error = true
then trim(substitute(#T-16'Internal error number: &1.':255(16039)T-16#,string(ERROR-STATUS:GET-NUMBER(1)))) + chr(10)
else "":U)
oiReturnStatus = +1.
<M-17 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
next.
end. /* if error-status:error or */
/* Set memptr */
file-info:file-name = vcFileNameFull.
set-size(vmDocument) = file-info:file-size.
/* Load the File */
<M-8 run LoadXMLRepresentation (input vcFileNameFull (icFile),
input vmDocument (imDocument),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper >= 0
then do:
/* Complete the Output */
<M-7 run SetOutputData (output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper >= 0
then do:
/* rename converted file */
os-rename value(vcFileNameFull) value(session:temp-dir + replace(vcFileName, '.xml':U, '-':U + string(today,'99999999':U) + '-':U + replace(string(time,'hh:mm:ss':U),':':U,'':U) + '.cnv':U)).
if os-error <> 0
then do:
assign vcMessage = trim(substitute(#T-28'Cannot rename the imported file from &1 to &2.':255(16100)t-28#, vcFileNameFull, session:temp-dir + replace(vcFileName, '.xml':U, '-':U + string(today,'99999999':U) + '-':U + replace(string(time,'hh:mm:ss':U),':':U,'':U) + '.cnv':U))).
<M-27 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
end.
else do:
/* And finaly dump */
<M-1 run DumpXMLRepresentation (input icExportFolder + vcFileName (icFile),
input ? (icObjectRowid),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
assign vcMessage = trim(substitute(#T-30'XML Conversion on file &1.':255(16219)t-30#, vcFileNameFull)) + ' ':U +
(if oiReturnStatus = 0
then trim(#T-31'succeeded.':255(16097)T-31#)
else trim(#T-32'The action did not succeed.':255(16098)t-32#)).
<M-29 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
assign vcMessage = trim(substitute(#T-21'File renamed from &1 to &2.':255(16221)t-21#, vcFileNameFull, session:temp-dir + replace(vcFileName, '.xml':U, '-':U + string(today,'99999999':U) + '-':U + replace(string(time,'hh:mm:ss':U),':':U,'':U) + '.cnv':U))).
<M-33 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
end.
end.
end.
assign vcMessage = trim(substitute(#T-26'------------------------------------------ END XML Conversion of file &1 at &2 ----------------------------------------------':200(16217)T-26#, vcFileNameFull, string(today,'99/99/9999':U) + ' ':U + string(time,'hh:mm:ss':U))).
<M-25 run SetMessageInLog (input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in TConvertInstalNETXML>
end.
finally:
set-size (vmDocument) = 0.
end finally.
/* In order to be able to run queries on Technical Component following lines has to be added */
END PROCEDURE.
PROCEDURE XmlTableDetail:
define input parameter icTableName as character no-undo.
define input parameter ihBuffer as handle no-undo.
define input parameter ihParentNode as handle no-undo.
define output parameter oiReturnStatus as integer no-undo.
END PROCEDURE.
PROCEDURE XmlColumnDetail:
define input parameter icTableName as character no-undo.
define input parameter icColumnName as character no-undo.
define input parameter ihBuffer as handle no-undo.
define input parameter ihParentNode as handle no-undo.
define output parameter oiReturnStatus as integer no-undo.