2008 Feb 29 4:00 AM
Hi all,
Zjob is a table with key fields ZZSYSTEMNAME and ZZJOBNAME.
Ztask is a table with key fields ZZSYSTEMNAME and ZZJOBNAME and field ZZDIRECTORY.
What I want to do is to search through Ztask and Zjob for a specified system name (GV_SYSTEMNAME) and populate their corresponding internal tables gt_task and gt_job.
After that, i will call a transformation into an xml which will loop through gt_job, posting the job name, and then loop through gt_task, and post the corresponding directory.
Example of xml output
<?xml version="1.0" encoding="utf-16" ?>
<Job name="test">
<Upload Dir="testdir"/>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
My code works when there is only 1 Job under the system name. However, when there are 2 or more jobs, the program hangs with the exception 'CX_ST_INVALID_XML' was not caught causing a runtime error.
Reason for the exception is: Executing operation "OpenAttribute" would lead to an invalid XML document and is therefore not allowed.
The error location is on line 11 of the simple transformation
<tt:attribute name="name" value-ref="$JOB.ZZJOBNAME" />
I will really appreciate it if anyone could help. Thanks!
ABAP code.
TABLES: ztask, zjob.
DATA: GV_SYSTEMNAME.
DATA: XML_OUT TYPE STRING.
DATA: gt_task LIKE TABLE OF ztask.
DATA: gt_job LIKE TABLE OF zjob.
DATA: fname(60).
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_task FROM
ZTASK
WHERE ZZSYSTEMNAME = GV_SYSTEMNAME.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_JOB FROM
ZJOB
WHERE ZZSYSTEMNAME = GV_SYSTEMNAME.
CALL TRANSFORMATION ('test')
SOURCE TABLE = GT_TASK
JOBLST = GT_JOB
RESULT XML xml_out.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
TRANSFER xml_out TO fname.
CLOSE DATASET fname.
Simple transformation code.
<?sap.transform simple?>
<tt:transform
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="TABLE"/>
<tt:root name="JOBLST"/>
<tt:template>
<Job>
<tt:loop ref=".JOBLST" name="JOB">
<tt:attribute name="name" value-ref="$JOB.ZZJOBNAME" />
<tt:text>
</tt:text>
<tt:loop ref=".TABLE" name="alias">
<tt:ref name="$alias.ZZJOBNAME">
<tt:s-cond check="$ref = ref('$JOB.ZZJOBNAME')">
<Upload>
<tt:attribute name="Dir" value-ref="$alias.ZZDIRECTORY" />
</Upload>
</tt:s-cond>
</tt:ref>
</tt:loop>
</tt:loop>
</Job>
</tt:template>
</tt:transform>
2008 Feb 29 6:01 AM
The xml is invalid because there is no root node.
<?xml version="1.0" encoding="utf-16" ?>
<Job name="test">
<Upload Dir="testdir"/>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
Specify a unique root node above the job node, for example, Jobs. Also, the first Job node is not closed.
<?xml version="1.0" encoding="utf-16" ?>
<Jobs>
<Job name="test">
<Upload Dir="testdir"/>
</Job>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
</Jobs>
Hi all,
Zjob is a table with key fields ZZSYSTEMNAME and ZZJOBNAME.
Ztask is a table with key fields ZZSYSTEMNAME and ZZJOBNAME and field ZZDIRECTORY.
What I want to do is to search through Ztask and Zjob for a specified system name (GV_SYSTEMNAME) and populate their corresponding internal tables gt_task and gt_job.
After that, i will call a transformation into an xml which will loop through gt_job, posting the job name, and then loop through gt_task, and post the corresponding directory.
Example of xml output
<?xml version="1.0" encoding="utf-16" ?>
<Job name="test">
<Upload Dir="testdir"/>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
My code works when there is only 1 Job under the system name. However, when there are 2 or more jobs, the program hangs with the exception 'CX_ST_INVALID_XML' was not caught causing a runtime error.
Reason for the exception is: Executing operation "OpenAttribute" would lead to an invalid XML document and is therefore not allowed.
The error location is on line 11 of the simple transformation
<tt:attribute name="name" value-ref="$JOB.ZZJOBNAME" />
I will really appreciate it if anyone could help. Thanks!
ABAP code.
TABLES: ztask, zjob.
DATA: GV_SYSTEMNAME.
DATA: XML_OUT TYPE STRING.
DATA: gt_task LIKE TABLE OF ztask.
DATA: gt_job LIKE TABLE OF zjob.
DATA: fname(60).
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_task FROM
ZTASK
WHERE ZZSYSTEMNAME = GV_SYSTEMNAME.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_JOB FROM
ZJOB
WHERE ZZSYSTEMNAME = GV_SYSTEMNAME.
CALL TRANSFORMATION ('test')
SOURCE TABLE = GT_TASK
JOBLST = GT_JOB
RESULT XML xml_out.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
TRANSFER xml_out TO fname.
CLOSE DATASET fname.
Simple transformation code.
<?sap.transform simple?>
<tt:transform
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="TABLE"/>
<tt:root name="JOBLST"/>
<tt:template>
<Job>
<tt:loop ref=".JOBLST" name="JOB">
<tt:attribute name="name" value-ref="$JOB.ZZJOBNAME" />
<tt:text>
</tt:text>
<tt:loop ref=".TABLE" name="alias">
<tt:ref name="$alias.ZZJOBNAME">
<tt:s-cond check="$ref = ref('$JOB.ZZJOBNAME')">
<Upload>
<tt:attribute name="Dir" value-ref="$alias.ZZDIRECTORY" />
</Upload>
</tt:s-cond>
</tt:ref>
</tt:loop>
</tt:loop>
</Job>
</tt:template>
</tt:transform>
2008 Feb 29 6:01 AM
The xml is invalid because there is no root node.
<?xml version="1.0" encoding="utf-16" ?>
<Job name="test">
<Upload Dir="testdir"/>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
Specify a unique root node above the job node, for example, Jobs. Also, the first Job node is not closed.
<?xml version="1.0" encoding="utf-16" ?>
<Jobs>
<Job name="test">
<Upload Dir="testdir"/>
</Job>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
</Jobs>
2008 Feb 29 6:33 AM
Hi Hermes, I editted the transformation files and the same error still exists.
new desired output
<?xml version="1.0" encoding="utf-16" ?>
<Jobs>
<Job name="test">
<Upload Dir="testdir"/>
</Job>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
</Jobs>
new transformation code
<?sap.transform simple?>
<tt:transform
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="TABLE"/>
<tt:root name="JOBLST"/>
<tt:template>
<Jobs>
<Job>
<tt:loop ref=".JOBLST" name="JOB">
<tt:attribute name="name" value-ref="$JOB.ZZJOBNAME" />
<tt:text>
</tt:text>
<tt:loop ref=".TABLE" name="alias">
<tt:ref name="$alias.ZZJOBNAME">
<tt:s-cond check="$ref = ref('$JOB.ZZJOBNAME')">
<Upload>
<tt:attribute name="Dir" value-ref="$alias.ZZDIRECTORY" />
</Upload>
</tt:s-cond>
</tt:ref>
</tt:loop>
</tt:loop>
</Job>
</Jobs>
</tt:template>
</tt:transform>
2008 Feb 29 7:58 AM
OK I missed something. The transform is creating something like this:
<Job>
name=
name=
name=
</Job>:
This is not allowed.
You need to put the Job node/element inside the JOBLST loop.
<Job>name=
</Job>
<Job>name=
</Job>
etc
2008 Feb 29 8:22 AM
Hi Hermes, thanks for your help.
I have already solved my own problem. Basically I placed my <job> node before the loop, instead of after it.
my xml output
<?xml version="1.0" encoding="utf-16" ?>
<Jobs>
<Job name="test">
<Upload Dir="testdir"/>
</Job>
<Job name="test2">
<Upload Dir="testdir2"/>
</Job>
</Jobs>
my transformation code
<?sap.transform simple?>
<tt:transform
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="TABLE"/>
<tt:root name="JOBLST"/>
<tt:template>
<Jobs>
<tt:loop ref=".JOBLST" name="JOB">
<Job>
<tt:attribute name="name" value-ref="$JOB.ZZJOBNAME" />
<tt:text>
</tt:text>
<tt:loop ref=".TABLE" name="alias">
<tt:ref name="$alias.ZZJOBNAME">
<tt:s-cond check="$ref = ref('$JOB.ZZJOBNAME')">
<Upload>
<tt:attribute name="Dir" value-ref="$alias.ZZDIRECTORY" />
</Upload>
</tt:s-cond>
</tt:ref>
</tt:loop>
</Job>
</tt:loop>
</Jobs>
</tt:template>
</tt:transform>
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |