IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

XML Parsing in COBOL creating "hex." prefix in new tags


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

New User


Joined: 10 Nov 2015
Posts: 26
Location: USA

PostPosted: Sat Oct 31, 2020 7:19 am
Reply with quote

There are 4 copybooks, and 3 COBOL programs that create an XML file sent to the downstream process. Already existing tags are getting generated correctly but the two new tags which I want to add comes with 2 problems,
Problem 1 - "hex." is prefixed before the XML tag.
Problem 2 - Has value of 64 zeroes.

Snippet of those 4 copybooks, and 3 COBOL programs below,
Copybooks,
Database-copybook-1
Copy1
Copy2
Database-copybook-3 ( has a dump of formatted XML from BPGM)
Copy3

Programs
APGM (uses Database-copybook-1 & Copy1)
BPGM (uses Copy1 & Copy2)
CPGM (uses Database-copybook-3 & Copy 3)

Database-copybook-1
Code:

10 DB-A-ID PIC S9(18)       COMP-3.
10 DB-B-ID PIC S9(18)       COMP-3.


Copy1
Code:

10 CP1-ID-A PIC S9(18)       COMP-3.
10 CP1-ID-B PIC S9(18)       COMP-3.


APGM
Code:
MOVE DB-A-ID TO CP1-ID-A.
MOVE DB-B-ID TO CP1-ID-B.


Copy2
Code:
10 CP2-ID-A PIC S9(18).
10 CP2-ID-B PIC S9(18).


BPGM
Code:
MOVE CP1-ID-A TO CP2-ID-A.
MOVE CP1-ID-B TO CP2-ID-B.


Copy3
Code:
15 NewTag1    occurs 0 to 1 times
         depending on NewTag1Sub
                         PIC X(32).
15 NewTag2                  occurs 0 to 1 times
         depending on NewTag2Sub               
                         PIC X(32).


CPGM
Code:

03  NewTag1Sub           
                            PIC S9(4) COMP.
03  NewTag2Sub           PIC S9(4) COMP.

03  WS-NewTag1    PIC 9(18).
03  WS-NewTag2        PIC 9(18).

MOVE ZERO              TO NewTag1Sub.
MOVE ZERO              TO NewTag2Sub.             

IF WS-NewTag1 IS EQUAL TO ALL ZEROES       
    MOVE 0             TO NewTag1Sub
ELSE                                                 
    MOVE 1             TO NewTag1Sub
    PERFORM XYZ-NewTag1               
END-IF.                                             
IF WS-NewTag2     IS EQUAL TO ALL ZEROES       
    MOVE 0             TO NewTag2Sub             
ELSE                                                 
    MOVE 1             TO NewTag2Sub             
    PERFORM XYZ-NewTag2                       
END-IF.                                             


XYZ-NewTag1.                                 
    MOVE WS-NewTag1                               
                           TO NewTag1       
                               (NewTag1Sub).
XYZ-NewTag2.                                           
    MOVE WS-NewTag2                                   
                           TO NewTag2(NewTag2Sub).     
                                       
(value from Database-copybook-3)
PARS-X.                                                   
    XML PARSE DATABASE-3-COLUMN (1:DATABASE-3-COLUMN-LENGTH)
        PROCESSING PROCEDURE IS PARSE-M                   
    END-XML.                                                 


PARS-M.
...
 EVALUATE
     WHEN 'CP2-ID-A'                             
         MOVE XML-TEXT         TO WS-NewTag1
     WHEN 'CP2-ID-B'                                   
         MOVE XML-TEXT         TO WS-NewTag2   
 END-EVALUATE.
....



Expected Output

Code:
<NewTag1>123456789123456789</NewTag1>
<NewTag2>987654321123456789</NewTag2>


Actual Output
Code:
<hex.NewTag1>0000000000000000000000000000000000000000000000000000000000000000</hex.NewTag1>
<hex.NewTag2>0000000000000000000000000000000000000000000000000000000000000000</hex.NewTag2>



Any constructive feedback would be appreciated! Thanks for reading!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> COBOL Programming
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts JCL for replacing code in Cobol JCL & VSAM 8
No new posts COBOL VS SORT Utility for file format... COBOL Programming 6
No new posts Calling Rexx program from Cobol CLIST & REXX 12
No new posts Creating additional seqnum/Literal wh... DFSORT/ICETOOL 4
No new posts Creating a single-record file with CO... DFSORT/ICETOOL 8

Back to Top