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: 1722
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: 685
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: 6966
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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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