Can progress 9x version read XML data??

Can progress 9x version read XML data?? Yes

If so how can we cim xml data to QAD MFG/PRO??Yes

I used PROGRESS user guide to do it.
 

king_kong

New Member
Can progress 9x version read XML data?? Yes

If so how can we cim xml data to QAD MFG/PRO??Yes

I used PROGRESS user guide to do it.


Can you please give me a sample cim program (like for Generalized code_mstr) reads xml data and load into mfgpro tables.....

Please its really urgent ....

Thanks !!
 
/* e-outcus.p - Export the Customer table to an xml file*/
DEFINE VARIABLE hDoc AS HANDLE.
DEFINE VARIABLE hRoot AS HANDLE.
DEFINE VARIABLE hRow AS HANDLE.
DEFINE VARIABLE hField AS HANDLE.
DEFINE VARIABLE hText AS HANDLE.
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE hDBFld AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
CREATE X-DOCUMENT hDoc.
CREATE X-NODEREF hRoot.
CREATE X-NODEREF hRow.
CREATE X-NODEREF hField.
CREATE X-NODEREF hText.
hBuf = BUFFER code_mstr:HANDLE.
/*set up a root node*/
hDoc:CREATE-NODE(hRoot,"CODEMSTR","ELEMENT").
hDoc:APPEND-CHILD(hRoot).

FOR EACH CODE_mstr WHERE CODE_fldname MATCHES "pt_part_type":
hDoc:CREATE-NODE(hRow,"CODEMSTR","ELEMENT"). /*create a row node*/
hRoot:APPEND-CHILD(hRow). /*put the row in the tree*/
hRow:SET-ATTRIBUTE("CODE_FLDNAME",STRING(CODE_fldname)).
/*hRow:SET-ATTRIBUTE("Code_Value",CODE_value).*/
/*Add the other fields as tags in the xml*/

REPEAT i = 1 TO hBuf:NUM-FIELDS:
hDBFld = hBuf:BUFFER-FIELD(i).
IF hDBFld:NAME = "code_fldname" THEN NEXT.
/*create a tag with the field name*/
hDoc:CREATE-NODE(hField, hDBFld:NAME, "ELEMENT").
/*put the new field as next child of row*/
hRow:APPEND-CHILD(hField).
/*add a node to hold field value*/
hDoc:CREATE-NODE(hText, "", "TEXT").

/*attach the text to the field*/
hField:APPEND-CHILD(hText).
hText:NODE-VALUE = STRING(hDBFld:BUFFER-VALUE).
END.
END.
/*write the XML node tree to an xml file*/
hDoc:SAVE("file","d:\code.xml").
DELETE OBJECT hDoc.
DELETE OBJECT hRoot.
DELETE OBJECT hRow.
DELETE OBJECT hField.
DELETE OBJECT hText.
 
/* e-incus.p - Import the Customer table from an xml file*/
DEFINE VARIABLE hDoc AS HANDLE.
DEFINE VARIABLE hRoot AS HANDLE.
DEFINE VARIABLE hTable AS HANDLE.
DEFINE VARIABLE hField AS HANDLE.
DEFINE VARIABLE hText AS HANDLE.
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE hDBFld AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE j AS INTEGER.

/*so we can create new recs*/
DEFINE TEMP-TABLE CODEMSTR LIKE CODE_mstr.
CREATE X-DOCUMENT hDoc.
CREATE X-NODEREF hRoot.
CREATE X-NODEREF hTable.
CREATE X-NODEREF hField.
CREATE X-NODEREF hText.

hBuf = BUFFER Codemstr:HANDLE.

/*read in the file created in the last example*/
hDoc:LOAD("file", "d:\code.xml", FALSE).
hDoc:GET-DOCUMENT-ELEMENT(hRoot).
/*read each CodeMstr from the root*/

REPEAT i = 1 TO hRoot:NUM-CHILDREN:
hRoot:GET-CHILD(hTable,i).
CREATE Codemstr.
/*get the fields given as attributes*/
CODE_fldname = hTable:GET-ATTRIBUTE("CODE_FLDNAME").

/*get the remaining fields given as elements with text*/
REPEAT j = 1 TO hTable:NUM-CHILDREN:
hTable:GET-CHILD(hField,j).
IF hField:NUM-CHILDREN < 1 THEN NEXT.
/*skip any null value*/
hDBFld = hBuf:BUFFER-FIELD(hField:NAME).
hField:GET-CHILD(hText,1).
/*get the text value of the field*/
hDBFld:BUFFER-VALUE = hTEXT:NODE-VALUE.
END.
END.
DELETE OBJECT hDoc.
DELETE OBJECT hRoot.
DELETE OBJECT hTable.
DELETE OBJECT hField.
DELETE OBJECT hText.
/* show data made it by displaying temp-table */
FOR EACH codemstr:
DISPLAY codemstr.
END.
 
Now the logic;

Read XML file
Create a Work File
Use Work File to create cim file
Load CIM file

The e.g i sent you is direct update.
 

king_kong

New Member
/* e-incus.p - Import the Customer table from an xml file*/
DEFINE VARIABLE hDoc AS HANDLE.
DEFINE VARIABLE hRoot AS HANDLE.
DEFINE VARIABLE hTable AS HANDLE.
DEFINE VARIABLE hField AS HANDLE.
DEFINE VARIABLE hText AS HANDLE.
DEFINE VARIABLE hBuf AS HANDLE.
DEFINE VARIABLE hDBFld AS HANDLE.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE j AS INTEGER.

/*so we can create new recs*/
DEFINE TEMP-TABLE CODEMSTR LIKE CODE_mstr.
CREATE X-DOCUMENT hDoc.
CREATE X-NODEREF hRoot.
CREATE X-NODEREF hTable.
CREATE X-NODEREF hField.
CREATE X-NODEREF hText.

hBuf = BUFFER Codemstr:HANDLE.

/*read in the file created in the last example*/
hDoc:LOAD("file", "d:\code.xml", FALSE).
hDoc:GET-DOCUMENT-ELEMENT(hRoot).
/*read each CodeMstr from the root*/

REPEAT i = 1 TO hRoot:NUM-CHILDREN:
hRoot:GET-CHILD(hTable,i).
CREATE Codemstr.
/*get the fields given as attributes*/
CODE_fldname = hTable:GET-ATTRIBUTE("CODE_FLDNAME").

/*get the remaining fields given as elements with text*/
REPEAT j = 1 TO hTable:NUM-CHILDREN:
hTable:GET-CHILD(hField,j).
IF hField:NUM-CHILDREN < 1 THEN NEXT.
/*skip any null value*/
hDBFld = hBuf:BUFFER-FIELD(hField:NAME).
hField:GET-CHILD(hText,1).
/*get the text value of the field*/
hDBFld:BUFFER-VALUE = hTEXT:NODE-VALUE.
END.
END.
DELETE OBJECT hDoc.
DELETE OBJECT hRoot.
DELETE OBJECT hTable.
DELETE OBJECT hField.
DELETE OBJECT hText.
/* show data made it by displaying temp-table */
FOR EACH codemstr:
DISPLAY codemstr.
END.

Excellent... this code is working, But i have a problem,

Seems like this code is specific to mfgpro tables..

If i get the xml data from .net application based on their tables(not mfgpro tables) then how will i solve this issue....

Please guide me...

Thanks !!
 
Top