ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Test for Occurances in COBOL

Post new topic  Reply to topic
 Test for Occurances in COBOL « View previous topic :: View next topic » 
Author Message
EricCox
PostPosted: Wed Sep 19, 2012 7:02 am    Post subject: Test for Occurances in COBOL Reply with quote

Master

Joined: 08 Apr 2011
Posts: 292

To all,

I know how to test for the CARDINALITY of instances of a COBOL structure.

However, it looks like the service I'm working on sends back 75 instances with only one or several potentially filled in.

How do I test the CARDINALITY or existence of instances based on the population of a single FIELD in the COBOL response structure?

I would like to count the instances based on something like this:
InputBody.RESPONSE_MESSAGE.INSTANCES[].FIELD1 <> ' ';

Is there an elegant way to do this without looping and adding to a variable when the condition is met?

Thanks
Back to top
View user's profile Send private message
wbi_telecom
PostPosted: Wed Sep 19, 2012 7:32 am    Post subject: Reply with quote

Disciple

Joined: 15 Feb 2006
Posts: 188
Location: Harrisburg, PA

We use OCCURS DEPENDING ON in our copybooks which sends back a variable length COMMAREA based on number of occurences. It sends the number of occurences in one of the fields in the fixed length section of the copybook. So we do not have to send back the entire COMMAREA containing 75 instances when only one of them is populated.
In ESQL, you can access the field to find out the number of occurences so no need for using CARDINALITY or a loop.
The COBOL importer in broker understands OCCURS DEPENDING ON clause so your message set also parses the message without any issues.

Cheers,
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Sep 19, 2012 7:57 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

wbi_telecom is correct - that is the usual way to handle variable-length arrays in COBOL. If possible, obtain the copybook and import it, and everything will be done for you by the COBOL importer. If the copybook is not available then it's not hard to adjust the message definition yourself. Of course, that approach only works if there is a COUNT field somewhere in the input data.

Quote:
Is there an elegant way to do this without looping and adding to a variable when the condition is met?
If you cannot change the message set then you can use ESQL's SELECT function to create a ROW and then using CARDINALITY on the row.
But before you choose that solution, you may want to ask yourself why you need to know the number of non-empty occurrences. If it's only to control some later loop in your ESQL then you should use a REFERENCE variable instead.
Back to top
View user's profile Send private message
NealM
PostPosted: Wed Sep 19, 2012 8:08 am    Post subject: Reply with quote

Master

Joined: 22 Feb 2011
Posts: 230
Location: NC or Utah (depends)

wbi_telecom is pointing out the standard way of dealing with this. Even in a fixed length Host response, there usually is a counter field that tells you how many of those 75 arrayed structures actually contain pertinent data. Look for it.
If it doesn't have a counter field, you need to know what the Host is padding the "empty" part of the structure with. Hopefully not X'00' s as that will mess you up (if they are, raise a flag and force them to send a valid char like X'40' back). And then do your loop processing, stopping at the first occurance of that padding in a field in your array that would never have that value if it contains data.
(Note: I just saw kimbert's response. What I am suggesting above is for handling a fixed length response.)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Test for Occurances in COBOL
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.