Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Supress Field to print as XML Tag using XML GENERATE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
naveenkumars

New User


Joined: 17 Jun 2010
Posts: 3
Location: India

PostPosted: Wed Feb 29, 2012 5:18 pm    Post subject: Supress Field to print as XML Tag using XML GENERATE
Reply with quote

Hi,

How can I supress to print Field in XML using XML GENERATE?

Example,
Code:
01 Books
      05  Book               OCCURS 2.
           05 Category                        PIC X(10).
           05 Name            OCCURS 1 PIC X(10).
           05 Aurthor         OCCURS 1 PIC X(10).
           05 Price             OCCURS 1 PIC X(10).

Move 'Buy' TO Category(1).
Move 'ABC' TO Name(1 1).
Move 'XXXX' TO Aurthor(1 1).
Move 434.34 TO Price(1 1).

Move 'Free' TO Category(2).
Move 'XYZ' TO Name(2 1).
Move 'XXXX' TO Aurthor(2 1).

XML GENERATE XMLOUT FROM Books
      WITH ATTRIBUTES
END-XML.


The above code will display XML as
<Books>
<Book Category="Buy">
<Name>ABC</Name>
<Aurthor>XXXX</Aurthor>
<Price>434.34</Price>
</Book>
<Book Category="Free">
<Name>XYZ</Name>
<Aurthor>XXXX</Aurthor>
<Price> </Price>
</Book>
</Books>

I do not want to print <Price> Tag in XML for attribute 'Category=Free'.

Is there anyway to do this using XML GENERATE?
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1788
Location: UK

PostPosted: Thu Mar 01, 2012 12:02 am    Post subject:
Reply with quote

No idea but surely the price is 0.00. By specifying a value it shows that you have not forgotten to code for price in this instance.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Mar 01, 2012 1:24 am    Post subject:
Reply with quote

I agree with Nic. However, if you are hung up on doing this, consider declaring another structure named Free-Books without the price and if price is zero, use this structure instead of the Books.
Back to top
View user's profile Send private message
naveenkumars

New User


Joined: 17 Jun 2010
Posts: 3
Location: India

PostPosted: Thu Mar 01, 2012 8:49 pm    Post subject:
Reply with quote

Thank you for your replies.

In some cases, few tags shouldnt be displayed in XML. But unfotunately, whatever we define in the Working sotrage structure, the same format is genreated as XML tags using XML Generator in Cobol.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Fri Mar 02, 2012 2:03 am    Post subject:
Reply with quote

naveenkumars wrote:

In some cases, few tags shouldnt be displayed in XML. But unfotunately, whatever we define in the Working sotrage structure, the same format is genreated as XML tags using XML Generator in Cobol.



maybe that is why agkshirsagar suggested defining different structures in Working-Storage.......

which IMUHO is clever.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us