Skip to main content

I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

Hi SteveC, you can update the size of the array by using the SET SIZE statement, and then access array elements using standard COBOL subscripting.  So for instance:

01 string-array string occurs any.

   set size of string-array to 4

   set string-array(3) to "Hello"

The current compiler also supports zero-based indexing using square brackets, so that:

   set string-array[2] to "Hello"

...is equivalent to the above.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

The array is described in the Service references file as 01 Itemsfield type royalmail.Item occurs any and I can't set the size in the way you advised. I get the message COBCH0848 : Can only be used with managed array.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

The array is described in the Service references file as 01 Itemsfield type royalmail.Item occurs any and I can't set the size in the way you advised. I get the message COBCH0848 : Can only be used with managed array.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

That's strange, I tried copying the field into a local item to form part of a cut-down:

      class-id a.

      method-id main static.

      01 ItemsField type royalmail.Item occurs any                                                                                                                                                        

          attribute System.Runtime.Serialization.OptionalField().                                                                                                                                        

          set size of ItemsField to 5

      end method.

      end class.

      class-id royalmail.Item.

      end class.

...and that seems to compile fine.

Looks like there must be something different in your program...


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

Hi Robert. Thanks for your help. I tried copying it into a local item as well and it compiled ok.

So I'm still looking for a solution. In the Word doc I attached to this subject I have highlighted the array and the fields I want to populate.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

Steve,

Can you please open up a support incident with Customer Care for this problem?

We will also need the actual Visual Studio solution that you are using zipped up and attached to the incident so that we may try to reproduce the problem in house.

Thanks.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

Hi Chris

Thanks for your reply. A support incident has been opened for this with Customer Care, and I have supplied the solution to them. Customer Care suggested posing the question on this forum as they considered it to be a "How to" question on coding.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

Sorry, I forgot to tell you to add my name to the request.

What is the support incident number?


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

Thanks Chris. The incident number is 2785415.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

Thanks Chris. The incident number is 2785415.


I have just started using Visual Cobol in Microfocus Visual Studio 2012.

My code needs to read records and update an array named 'ItemsField' in a web service reference file(See attached Word file for layout of the input file and the web service references file). The array I want to populate is described as having  'occurs any' and is named 'ItemsField' in the web service references file.

My question is: How do I add data to this array and update the number of occurs?

This problem has now been resolved through the support incident.
This was the response:

I have taken a look at your sample and I believe that the following is the code that you need to add to form4 in order to move the contents of your arrays to the ItemArray array.

The problem with the way you were doing it is you were never instantiating the actual ReturnedItem object as you were varying through an empty array.

The following creates a new instance of ReturnedItem for each element in the array and then adds that ReturnedItem to ItemArray at the bottom of the perform loop.

Thanks.

                  subtract 1 from ws-input-record-count giving ws-in-count  
                  set size of itemArray to ws-in-count

                  perform varying sub-1 from 1 by 1
                     until sub-1 > ws-in-count
                     declare ReturnedItem as type royalmail.Item = new royalmail.Item
                     set ReturnedItem::AddressLine1 to tabAddressLine1(sub-1)
                     set ReturnedItem::AddressLine2 to tabAddressLine2(sub-1)
                     set ReturnedItem::AddressLine3 to tabAddressLine3(sub-1)
                     set ReturnedItem::AddressLine4 to tabAddressLine4(sub-1)
                     set ReturnedItem::AddressLine5 to tabAddressLine5(sub-1)
                     set ReturnedItem::AddressLine6 to tabAddressLine6(sub-1)
                     set ReturnedItem::AddressLine7 to tabAddressLine7(sub-1)
                     set ReturnedItem::AddressLine8 to tabAddressLine8(sub-1)
                     set ReturnedItem::AddressLine9 to tabAddressLine9(sub-1)
                     set ReturnedItem::CampaignName to tabCampaignName(sub-1)
                     set ReturnedItem::Class to tabClass(sub-1)
                     set ReturnedItem::DPS to tabDPS(sub-1)
                     set ReturnedItem::Department to tabDepartment(sub-1)
                     set ReturnedItem::EIBItemId to tabItemId(sub-1)
                     set ReturnedItem::Format to tabFormat(sub-1)
                     set ReturnedItem::MailOriginatorSubDivisionName to tabMailOriginatorSubDivisionName(sub-1)
                     set ReturnedItem::MailType to tabMailType(sub-1)
                     set ReturnedItem::NumberOfAddressLines to tabNumberOfAddressLines(sub-1)
                     set ReturnedItem::PostCode to tabPostcode(sub-1)
                     set ReturnedItem::Weight to tabWeight(sub-1)
                     set ReturnedItem::AdvertisingAttribute1 to tabAdvertAttribute1(sub-1)        
                     set ReturnedItem::AdvertisingAttribute2 to tabAdvertAttribute2(sub-1)        
                     set ReturnedItem::AdvertisingAttribute3 to tabAdvertAttribute3(sub-1)        
                     set ReturnedItem::AdvertisingAttribute4 to tabAdvertAttribute4(sub-1)        
                     set ReturnedItem::Machinable to tabMachinable(sub-1)          
                     set ReturnedItem::MailerId to tabMailerId(sub-1)          
                     set ReturnedItem::PAFResellerProduct to tabPAFResellerProduct(sub-1)          
                     set ReturnedItem::PAFResellerProductVersion to tabPAFResellerProductVersion(sub-1)          
                     set ReturnedItem::PAFVersion to tabPAFVersion(sub-1)          
                     set ReturnedItem::Product to tabProduct(sub-1)          
                     set ReturnedItem::RTSDPS to tabRTSDPS(sub-1)                  
                     set ReturnedItem::RTSPostCode to tabRTSPostcode(sub-1)          
                     set ReturnedItem::RTSService to tabRTSService(sub-1)          
                     set ReturnedItem::ResellerUsed to tabResellerUsed(sub-1)          
                     set ReturnedItem::ResponseClass to tabResponseClass(sub-1)          
                     set ReturnedItem::ResponseDPS to tabResponseDPS(sub-1)          
                     set ReturnedItem::ResponseFormat to tabResponseFormat(sub-1)          
                     set ReturnedItem::ResponseItemId to tabResponseEIBItemId(sub-1)          
                     set ReturnedItem::ResponseLicenceNo to tabResponseLicenceNo(sub-1)          
                     set ReturnedItem::ResponseMailType to tabResponseMailType(sub-1)          
                     set ReturnedItem::ResponsePostCode to tabResponsePostcode(sub-1)          
                     set ReturnedItem::ResponseSupplyChain to tabResponseEIBSupplyChainId(sub-1)  
                     set ReturnedItem::MailSubType1 to tabMailSubType1(sub-1)    
                     set ReturnedItem::MailSubType2 to tabMailSubType2(sub-1)    
                     set ReturnedItem::MailSubType3 to tabMailSubType3(sub-1)    
                     set ReturnedItem::MailSubType4 to tabMailSubType4(sub-1)    
                     set ReturnedItem::Spare1 to tabSpare1(sub-1)          
                     set ReturnedItem::Spare10 to tabSpare10(sub-1)          
                     set ReturnedItem::Spare2 to tabSpare2(sub-1)          
                     set ReturnedItem::Spare3 to tabSpare3(sub-1)          
                     set ReturnedItem::Spare4 to tabSpare4(sub-1)          
                     set ReturnedItem::Spare5 to tabSpare5(sub-1)          
                     set ReturnedItem::Spare6 to tabSpare6(sub-1)          
                     set ReturnedItem::Spare7 to tabSpare7(sub-1)          
                     set ReturnedItem::Spare8 to tabSpare8(sub-1)          
                     set ReturnedItem::Spare9 to tabSpare9(sub-1)          
                     set ReturnedItem::SpecialServiceBarcode to tabSpecialServiceBarcode(sub-1)        
                     set ReturnedItem::SpecialServiceFlag to tabSpecialServiceFlag(sub-1)
                     set ItemArray(sub-1) to ReturnedItem
                  end-perform