View previous topic :: View next topic
|
Author |
Message |
VivekKhanna
New User
Joined: 09 Feb 2009 Posts: 57 Location: India
|
|
|
|
Hi
I am facing problem with generating 3D Table with nested DEPENDING ON Clause. I need to generate the table with below requirement.
Code: |
01 TEST1-TBL.
05 TEST1-DATA1 PIC 99.
05 TEST2-TBL OCCURS 1 TO 10 TIMES DEPENDING ON TST-CNT1 INDEXED BY TST2-INDX.
10 TEST2-DATA1 PIC 99.
10 TEST3-TBL OCCURS 1 TO 10 TIMES DEPENDING ON TST-CNT2 INDEXED BY TST3-INDX.
15 TEST3-DATA1 PIC 99.
15 TEST4-TBL OCCURS 1 TO 5 TIEMS DEPENDING ON TST-CNT3 INDEXED BY TST4-INDX.
20 TEST4-DATA PIC 99. |
I have tried to execute the code, during execution the first occurance gets executed perfectly fine. But from next occurance onwards as soon as MOVE [NEW-VAL] TO TST-CNT1, JUNK gets populated in the TST3-INDX.
Once the whole table with variable length gets populated, my requirement is to generate the XML without empty tags (variable length>.
Please suggest. Thanks in advance. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Have you read the Enterprise COBOL Programming Guide Appendix 1.2.2.2 titled Preventing overlay when adding elements to a variable table ? If not, you need to read this carefully as it describes almost exactly what you are doing. And the statement is made that if you want to change TST-CNT1 or TST-CNT2, the process is to copy the rest of the table to a different location (not subordinate to TEST1-TBL), change the occurs count, then move the data back into TEST1-TBL. In other words, you need to do a good bit of coding -- it might be easier for you to define the tables as fixed (no DEPENDING ON), then after they are completely ready to go then move them to TEST1-TBL so there is no manipulation of TST-CNT1, TST-CNT2, or TST-CNT3. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Robert's idea is the best way to do it. Do all the manipulation you need in a fixed-length table of three dimensions. When everything is ready to generate the XML, only then set the ODO data-names and MOVE the group names (or loops with the individual names).
People often misunderstand what nested ODOs give them. Let's hope that doesn't include you. |
|
Back to top |
|
|
VivekKhanna
New User
Joined: 09 Feb 2009 Posts: 57 Location: India
|
|
|
|
Thanks a lot Robert and Bill.
Robert,
The manual-link was really informative, with a small correction. The information is available in Enterprise COBOL Programming Guide . The content was really helpful.
Since we need to generate dynamic XML, the which should not have any empty tags. Thus we cannot use static variables. We were successfully able to generate dynamic XML. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It was not suggested that you use "static variables" for your XML generation. It was suggested you use them until all table-manipulation was complete in your program, and at that point copy the data to the variable-length tables. Then generate the XML.
That would save you all the "messing about" to keep things in step when you change the ODO values, which is just technical clutter, not part of your business requirement.
The future readers of your program would appreciate that. |
|
Back to top |
|
|
vangeti
New User
Joined: 26 Apr 2014 Posts: 2 Location: bangalore
|
|
|
|
Actually we do have a way to suppress the empty tags in cobol5.
XML GENERATE XML-OUT FROM STRUCTURE
COUNT IN XML-LEN
SUPPRESS EVERY NUMERIC WHEN ZERO
EVERY NONNUMERIC WHEN SPACES
now it will suppress the tag generation when numeric fields having data zero or nonnumeric values having spaces.
( we should initialize our structure before moving data into these. so that we can check for default values and suppress in xml generation).
We can give individual field names also in suppress stement |
|
Back to top |
|
|
|