Skip to main content

Good Morning,

Iam trying to migrate some dat files to another format and after that merging them to one file.
The number of the dat files i have to merge differs in size.

I use the .NET directoryInfo::GetFiles method to get all files with a specific name.

After that I am migrating the files to the new format and then save them to a temp folder.

Then Iam trying to merge all files in this tmp folder by recursively looping through them.

After the first merge I get the following error 'File locked (Closed Last Status: 9/65)'.

Is there a possibility to close the work-file, because it seems to stay open after merging the first datasets.

Thank you very much.

Here is the method iam using:

procedure division using by value sourceFile as string
                                         fileList as type String[] counter as binary-long.
           invoke ProgressUpdated(counter + 1).

           set NBL-SO-PATH to sourceFile.
           set NBL-SOURCE-MERGE-PATH to fileList[counter].
           set NBL-WORK-FILE-PATH to type System.IO.Path::Combine(type System.IO.Path::GetDirectoryName(NBL-SOURCE-MERGE-PATH), "WORK" & counter & ".TMP").

           MERGE WORK-FILE
           ON ascending KEY NBL-RECORD-INDEX-WORK USING NBLDAT-SO,
                                                        NBLDAT-MERGE
                                                 GIVING NBLDAT-DEST.


           IF counter < fileList::Length - 1
               add 1 to counter
               invoke MergeFiles(NBL-DESTINATION-PATH, fileList, counter)
           END-IF
       end method.


#Other
#VisualCOBOL
#Merge
#SupportTips/KnowledgeDocs
#SupportTips/SupportTips/KnowledgeDocs
#.net

Good Morning,

Iam trying to migrate some dat files to another format and after that merging them to one file.
The number of the dat files i have to merge differs in size.

I use the .NET directoryInfo::GetFiles method to get all files with a specific name.

After that I am migrating the files to the new format and then save them to a temp folder.

Then Iam trying to merge all files in this tmp folder by recursively looping through them.

After the first merge I get the following error 'File locked (Closed Last Status: 9/65)'.

Is there a possibility to close the work-file, because it seems to stay open after merging the first datasets.

Thank you very much.

Here is the method iam using:

procedure division using by value sourceFile as string
                                         fileList as type String[] counter as binary-long.
           invoke ProgressUpdated(counter + 1).

           set NBL-SO-PATH to sourceFile.
           set NBL-SOURCE-MERGE-PATH to fileList[counter].
           set NBL-WORK-FILE-PATH to type System.IO.Path::Combine(type System.IO.Path::GetDirectoryName(NBL-SOURCE-MERGE-PATH), "WORK" & counter & ".TMP").

           MERGE WORK-FILE
           ON ascending KEY NBL-RECORD-INDEX-WORK USING NBLDAT-SO,
                                                        NBLDAT-MERGE
                                                 GIVING NBLDAT-DEST.


           IF counter < fileList::Length - 1
               add 1 to counter
               invoke MergeFiles(NBL-DESTINATION-PATH, fileList, counter)
           END-IF
       end method.


#Other
#VisualCOBOL
#Merge
#SupportTips/KnowledgeDocs
#SupportTips/SupportTips/KnowledgeDocs
#.net

Hi Mario,

You posted this to the wrong section of the forum. This is the Tips and Info section. Could you please post this under the Discussions tab and then I will have a look at it?

Thanks.