IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

3-D Table with nested DEPENDING ON Clause


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
VivekKhanna

New User


Joined: 09 Feb 2009
Posts: 57
Location: India

PostPosted: Sat Aug 08, 2015 11:18 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Aug 08, 2015 11:33 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Aug 09, 2015 3:51 am
Reply with quote

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
View user's profile Send private message
VivekKhanna

New User


Joined: 09 Feb 2009
Posts: 57
Location: India

PostPosted: Tue Aug 11, 2015 4:00 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Aug 11, 2015 5:09 pm
Reply with quote

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
View user's profile Send private message
vangeti

New User


Joined: 26 Apr 2014
Posts: 2
Location: bangalore

PostPosted: Wed Aug 19, 2015 11:11 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top