动态读取COBOL重新定义与C# [英] Dynamically Reading COBOL Redefines with C#

查看:687
本文介绍了动态读取COBOL重新定义与C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个C#程序,将能够动态读取IBM主机字帖COBOL编写并生成SQL表关闭它。一旦生成的表,我可以上传文件到我的程序,它会读取,从IMB-37转换和文件插入到该SQL表。到目前为止我可以处理几乎所有的东西,虽然我正在与重新定义了一些问题。

I'm making a C# program that will be able to dynamically read an IBM HOST Copybook written in COBOL and generate an SQL table off of it. Once the table is generated I can upload a file into my program and it will read, convert from IMB-37 and insert the file into that sql table. So far I can handle almost anything, although I'm running into some issues with REDEFINES.

例如:

           10   SOME-FIELD        PIC 9(3)      COMP-3.     SCRRB205
4117       10   SOME-OTHER-FIELD REDEFINES                  3041-17
4117              SOME-FIELD      PIC X(2).                 3041-17



据我了解,需要重新定义的字段的位置上面在这种情况下,虽然我不明白的是,编译器是如何知道它是否应该使用重新定义与否。我假设,在这种情况下,这将是因为第一个是一个数,其中第二个是一个字符,但在下面的例子中它们都使用的字符。

I understand that the redefine takes the place of the field above it in this case, although what i don't understand is how the compiler knows if it should use the redefine on it or not. I'm assuming that in this case it will be because the first one is a number where the second one is a character, although in the example below they are all using characters.

 05  STREET-ADDRESS.
       10  ADDRESS-LINE-1               PIC X(20).
       10  ADDRESS-LINE-2               PIC X(20).
   05  PO-BOX REDEFINES STREET-ADDRESS  PIC X(40). 



我曾尝试只是忽略了重新定义,因为它总是会采取相同的空间量,但在情况下原始字段被包装和重新定义一个不是我需要知道什么时候来解压领域。

I have tried just ignoring the redefines since it will always take the same amount of space, but in the case where the original field is packed and the redefined one is not I need to know when to unpack the field.

任何帮助,这将是惊人的家伙!

Any help with this would be amazing guys!

推荐答案

我也许可以帮你,因为2年前我已经完成了你现在正在做什么。

I can maybe help you, as 2 years ago I have accomplished exactly what you are doing now.

我要设计一个MySQL数据仓库,包括ETL系统,专门的文件根据从 RM COBOL ERP在Linux上运行的应用程序。
中的应用已超过600文件,但仍不清楚有多少人最终会在数据库中结束。最重要的文件被编入索引,在COMP字段使其更难,并且有明显的需求之一是,文件和它们的索引键之间的所有关系可以在数据库上被再现。所以我可能用到的每一个文件的每一个领域。

I had to design a MySQL Datawarehouse, including the ETL system, based exclusively on files from a RM COBOL ERP application running on Linux. The application had more than 600 files, and it was still unclear how much of them would finally end up in the database. Most of the important files were indexed, on COMP fields to make it harder, and one of the obvious requirement was that all relationships between files and their indexed keys could be reproduced on the database. So I potentially needed every field of every file.

捐赠文件的数量,这是毫无疑问的把所有的文件,手动,一个接一个。

Giving the number of files, it was out of question to treat all the files, manually and one by one.

所以我的想法是代码采取COBOL习字输入和VB.NET应用程序:

So my idea was to code a VB.NET application that take the COBOL copybooks in input and :


  1. 生成的数据转换的东西利用,通过读取原始的索引文件并在一个连续的文本文件中写入记录COBOL程序。

  2. 生成的所有代码VBA模块从MS访问这些数据文件导入到MySQL(包括CREATE TABLE和索引)

在项目开始时需要的,我跑成比你现在完全一样的问题,特别是那些该死的重新定义。我发现,上市和编码都字帖的可能性,如果不是不可能的,至少危险的任务。
所以我看着另一种方式,并且发现这一点:

At the beginning of the project, I ran into exactly the same issues than you now, notably those damn REDEFINES. I found the task of listing and coding all copybook possibilities, if not impossible, at least hazardous. So I looked into another way, and found this :

COBOL字帖,以XML转换器 SourceForge上

这救了我的辛勤工作周的字帖分析和解释。
它可以解析COBOL习字将它们转变成完全描述了很多有用的属性所有图片的XML文件,如长度键入的。它完全支持COBOL'86标准

This saved me weeks of hard work on copybook parsing and interpreting. It can parse COBOL copybooks to change them into an XML file describing perfectly all PICTURE with a lot of useful attributes, like length or type. It fully support COBOL'86 standards.

例如:

000001 FD  FACTURE.                                                     
000006 01  REC-FACTURE.                                                 
000011     03  FS1                  PIC X.                              
000016     03  FS2.                                                     
000021         05  FS2A            PIC 9.                               
               05  RFS2B           PIC X(8).
000026         05  FS2B REDEFINES RFS2B  PIC 9(8).
000031     03  FS3.                                                     
000036         05  FS3A            PIC 9.                               
000041         05  FS3B            PIC X(10).                            
000046     03  FS4.                                                     
000051         05  FS4A            PIC 99.                              
000056         05  FS4B            PIC 99.                              
000061         05  FS4C            PIC 99.                              
000066     03  FS5                 PIC X(5).                              
000071     03  FS6                 PIC X(20).                           
000076     03  FS7                 PIC 9.                               
000081     03  FS8                 PIC S9(9)V99    COMP-3.              
000086     03  FS9                 PIC S9(9)V99    COMP-3.              
000091     03  FS10                PIC 9.                               
000096     03  FS11                PIC S9(9)V99    COMP-3.              
000101     03  FS12                PIC S9(9)V99    COMP-3.              
000106     03  FS13                PIC S9(9)V99    COMP-3.              
000111     03  FS14-15 OCCURS 10.                                       
000116         05  FS14            PIC 9.                               
000121         05  FS15            PIC S9(9)V99    COMP-3.              
000126         05  FS16            PIC S9(9)V99    COMP-3.              
000131     03  FS17 OCCURS 10       PIC S9(9)V99    COMP-3.              
000136     03 FS18                 PIC 9(6).                            
000141     03  FS19                PIC 9.                               
000241     03  FILLER              PIC X.    



匝这个:

Turns into this :

<copybook filename="FD8.COP.CLEAN">
    <item display-length="428" level="01" name="REC-FACTURE" position="1" storage-length="428">
        <item display-length="1" level="03" name="FS1" picture="X" position="1" storage-length="1"/>
        <item display-length="9" level="03" name="FS2" position="2" storage-length="9">
            <item display-length="1" level="05" name="FS2A" numeric="true" picture="9" position="2" storage-length="1"/>
            <item display-length="8" level="05" name="RFS2B" picture="X(8)" position="3" redefined="true" storage-length="8"/>
            <item display-length="8" level="05" name="FS2B" numeric="true" picture="9(8)" position="3" redefines="RFS2B" storage-length="8"/>
        </item>
        <item display-length="11" level="03" name="FS3" position="11" storage-length="11">
            <item display-length="1" level="05" name="FS3A" numeric="true" picture="9" position="11" storage-length="1"/>
            <item display-length="10" level="05" name="FS3B" picture="X(10)" position="12" storage-length="10"/>
        </item>
        <item display-length="6" level="03" name="FS4" position="22" storage-length="6">
            <item display-length="2" level="05" name="FS4A" numeric="true" picture="99" position="22" storage-length="2"/>
            <item display-length="2" level="05" name="FS4B" numeric="true" picture="99" position="24" storage-length="2"/>
            <item display-length="2" level="05" name="FS4C" numeric="true" picture="99" position="26" storage-length="2"/>
        </item>
        <item display-length="5" level="03" name="FS5" picture="X(5)" position="28" storage-length="5"/>
        <item display-length="20" level="03" name="FS6" picture="X(20)" position="33" storage-length="20"/>
        <item display-length="1" level="03" name="FS7" numeric="true" picture="9" position="53" storage-length="1"/>
        <item display-length="11" level="03" name="FS8" numeric="true" picture="S9(9)V99" position="54" scale="2" signed="true" storage-length="6" usage="computational-3"/>
        <item display-length="11" level="03" name="FS9" numeric="true" picture="S9(9)V99" position="60" scale="2" signed="true" storage-length="6" usage="computational-3"/>
        <item display-length="1" level="03" name="FS10" numeric="true" picture="9" position="66" storage-length="1"/>
        <item display-length="11" level="03" name="FS11" numeric="true" picture="S9(9)V99" position="67" scale="2" signed="true" storage-length="6" usage="computational-3"/>
        <item display-length="11" level="03" name="FS12" numeric="true" picture="S9(9)V99" position="73" scale="2" signed="true" storage-length="6" usage="computational-3"/>
        <item display-length="11" level="03" name="FS13" numeric="true" picture="S9(9)V99" position="79" scale="2" signed="true" storage-length="6" usage="computational-3"/>
        <item display-length="13" level="03" name="FS14-15" occurs="10" position="85" storage-length="13">
            <item display-length="1" level="05" name="FS14" numeric="true" picture="9" position="85" storage-length="1"/>
            <item display-length="11" level="05" name="FS15" numeric="true" picture="S9(9)V99" position="86" scale="2" signed="true" storage-length="6" usage="computational-3"/>
            <item display-length="11" level="05" name="FS16" numeric="true" picture="S9(9)V99" position="92" scale="2" signed="true" storage-length="6" usage="computational-3"/>
        </item>
        <item display-length="11" level="03" name="FS17" numeric="true" occurs="10" picture="S9(9)V99" position="215" scale="2" signed="true" storage-length="6" usage="computational-3"/>
        <item display-length="6" level="03" name="FS18" numeric="true" picture="9(6)" position="275" storage-length="6"/>
        <item display-length="1" level="03" name="FS19" numeric="true" picture="9" position="281" storage-length="1"/>



所有的XML属性列表

      For Each Attribute As Xml.XmlAttribute In itemNode.Attributes

            Select Case Attribute.Name

                Case "name" ' FIeld name

                Case "level" ' PICTURE level

                Case "numeric"  ' True if numeric data type

                Case "picture" ' COmplete PICTURE string

                Case "storage-length" ' Variable storage lenght

                Case "usage" ' If COMP field, give the original COMP type ("computational-x")

                Case "signed" true if PIC S...

                Case "scale" ' Give number of digits afeter decimal point

                Case "redefined" ' true if the field is redifined afterwards

                Case "redefines" ' If REDEFINES : give the name of the redefined field

                Case "occurs" ' give the number of occurences if it's an ARRAY

                Case "position" ' Give the line position in the original copybook

                Case "display-length" ' Give the display size

                Case "filename" ' Give the FD name

通过这种XML结构的帮助下,我已经实现所有的目标和超越。

With the help of this XML structure I have achieved all the goals and beyond.

这转换的索引的文件生成的COBOL程序的(可读仅RM COBOL运行时)进入的平。文件的涉及各个领域,数组和重新定义包含

The generated COBOL programs that convert the indexed files (readable only with RM cobol runtime) into flat files deals with every field, ARRAYS and REDEFINES included.


  • 对于重新定义了:我创建一个字段为主图片,它重新定义了变更,它们的类型相匹配的COBOL图片

  • 对于数组,我创建一个字段为每个元素,也包含整个阵列行的巨大领域

  • 对于计算领域,我只是移动原COMP到完全相同的显示图片

不是所有的场有一个目的,当他们在数据库中,但至少一切可用的所有时间

Not all the fields have a purpose when they are in the database but at least everything is available all the time

通过上面的文件,顺序文本文件字帖变成这样:

With the file above, the SEQUENTIAL text file copybook becomes this :

  FILE SECTION. 

  * ----------------------------------------------------------- 
  * INPUT FILE                                                
       COPY "FD8.COP" . 

  * -----------------------------------------------------------
  * OUTPUT FILE
   FD FACTURE-DWH.
   01 REC-FACTURE-DWH.      
       03 FS1-DWH           PIC X.
       03 FS2-DWH           PIC X(9).
       03 FS2A-DWH           PIC 9.
       03 RFS2B-DWH           PIC X(8).
       03 FS2B-DWH           PIC 9(8).
       03 FS3-DWH           PIC X(11).
       03 FS3A-DWH           PIC 9.
       03 FS3B-DWH           PIC X(10).
       03 FS4-DWH           PIC X(6).
       03 FS4A-DWH           PIC 99.
       03 FS4B-DWH           PIC 99.
       03 FS4C-DWH           PIC 99.
       03 FS5-DWH           PIC X(5).
       03 FS6-DWH           PIC X(20).
       03 FS7-DWH           PIC 9.
       03 FS8-DWH           PIC -9(9)V99.
       03 FS9-DWH           PIC -9(9)V99.
       03 FS10-DWH           PIC 9.
       03 FS11-DWH           PIC -9(9)V99.
       03 FS12-DWH           PIC -9(9)V99.
       03 FS13-DWH           PIC -9(9)V99.
       03 FS14-15-1-DWH           PIC X(13).
       03 FS14-15-2-DWH           PIC X(13).
       03 FS14-15-3-DWH           PIC X(13).
       03 FS14-15-4-DWH           PIC X(13).
       03 FS14-15-5-DWH           PIC X(13).
       03 FS14-15-6-DWH           PIC X(13).
       03 FS14-15-7-DWH           PIC X(13).
       03 FS14-15-8-DWH           PIC X(13).
       03 FS14-15-9-DWH           PIC X(13).
       03 FS14-15-10-DWH           PIC X(13).
       03 FS14-1-DWH           PIC 9.
       03 FS14-2-DWH           PIC 9.
       03 FS14-3-DWH           PIC 9.
       03 FS14-4-DWH           PIC 9.
       03 FS14-5-DWH           PIC 9.
       03 FS14-6-DWH           PIC 9.
       03 FS14-7-DWH           PIC 9.
       03 FS14-8-DWH           PIC 9.
       03 FS14-9-DWH           PIC 9.
       03 FS14-10-DWH           PIC 9.
       03 FS15-1-DWH           PIC -9(9)V99.
       03 FS15-2-DWH           PIC -9(9)V99.
       03 FS15-3-DWH           PIC -9(9)V99.
       03 FS15-4-DWH           PIC -9(9)V99.
       03 FS15-5-DWH           PIC -9(9)V99.
       03 FS15-6-DWH           PIC -9(9)V99.
       03 FS15-7-DWH           PIC -9(9)V99.
       03 FS15-8-DWH           PIC -9(9)V99.
       03 FS15-9-DWH           PIC -9(9)V99.
       03 FS15-10-DWH           PIC -9(9)V99.
       03 FS16-1-DWH           PIC -9(9)V99.
       03 FS16-2-DWH           PIC -9(9)V99.
       03 FS16-3-DWH           PIC -9(9)V99.
       03 FS16-4-DWH           PIC -9(9)V99.
       03 FS16-5-DWH           PIC -9(9)V99.
       03 FS16-6-DWH           PIC -9(9)V99.
       03 FS16-7-DWH           PIC -9(9)V99.
       03 FS16-8-DWH           PIC -9(9)V99.
       03 FS16-9-DWH           PIC -9(9)V99.
       03 FS16-10-DWH           PIC -9(9)V99.
       03 FS17-1-DWH           PIC -9(9)V99.
       03 FS17-2-DWH           PIC -9(9)V99.
       03 FS17-3-DWH           PIC -9(9)V99.
       03 FS17-4-DWH           PIC -9(9)V99.
       03 FS17-5-DWH           PIC -9(9)V99.
       03 FS17-6-DWH           PIC -9(9)V99.
       03 FS17-7-DWH           PIC -9(9)V99.
       03 FS17-8-DWH           PIC -9(9)V99.
       03 FS17-9-DWH           PIC -9(9)V99.
       03 FS17-10-DWH           PIC -9(9)V99.
       03 FS18-DWH           PIC 9(6).
       03 FS19-DWH           PIC 9.



MOVE说明

  * ============================================================   
   PROG.                                                             
       MOVE FS1  TO FS1-DWH
       MOVE FS2  TO FS2-DWH
       MOVE FS2A  TO FS2A-DWH
       MOVE RFS2B  TO RFS2B-DWH
       MOVE FS2B  TO FS2B-DWH
       MOVE FS3  TO FS3-DWH
       MOVE FS3A  TO FS3A-DWH
       MOVE FS3B  TO FS3B-DWH
       MOVE FS4  TO FS4-DWH
       MOVE FS4A  TO FS4A-DWH
       MOVE FS4B  TO FS4B-DWH
       MOVE FS4C  TO FS4C-DWH
       MOVE FS5  TO FS5-DWH
       MOVE FS6  TO FS6-DWH
       MOVE FS7  TO FS7-DWH
       MOVE FS8  TO FS8-DWH
       MOVE FS9  TO FS9-DWH
       MOVE FS10  TO FS10-DWH
       MOVE FS11  TO FS11-DWH
       MOVE FS12  TO FS12-DWH
       MOVE FS13  TO FS13-DWH
       MOVE FS14-15(1)  TO FS14-15-1-DWH
       MOVE FS14-15(2)  TO FS14-15-2-DWH
       MOVE FS14-15(3)  TO FS14-15-3-DWH
       MOVE FS14-15(4)  TO FS14-15-4-DWH
       MOVE FS14-15(5)  TO FS14-15-5-DWH
       MOVE FS14-15(6)  TO FS14-15-6-DWH
       MOVE FS14-15(7)  TO FS14-15-7-DWH
       MOVE FS14-15(8)  TO FS14-15-8-DWH
       MOVE FS14-15(9)  TO FS14-15-9-DWH
       MOVE FS14-15(10)  TO FS14-15-10-DWH
       MOVE FS14(1)  TO FS14-1-DWH
       MOVE FS14(2)  TO FS14-2-DWH
       MOVE FS14(3)  TO FS14-3-DWH
       MOVE FS14(4)  TO FS14-4-DWH
       MOVE FS14(5)  TO FS14-5-DWH
       MOVE FS14(6)  TO FS14-6-DWH
       MOVE FS14(7)  TO FS14-7-DWH
       MOVE FS14(8)  TO FS14-8-DWH
       MOVE FS14(9)  TO FS14-9-DWH
       MOVE FS14(10)  TO FS14-10-DWH
       MOVE FS15(1)  TO FS15-1-DWH
       MOVE FS15(2)  TO FS15-2-DWH
       MOVE FS15(3)  TO FS15-3-DWH
       MOVE FS15(4)  TO FS15-4-DWH
       MOVE FS15(5)  TO FS15-5-DWH
       MOVE FS15(6)  TO FS15-6-DWH
       MOVE FS15(7)  TO FS15-7-DWH
       MOVE FS15(8)  TO FS15-8-DWH
       MOVE FS15(9)  TO FS15-9-DWH
       MOVE FS15(10)  TO FS15-10-DWH
       MOVE FS16(1)  TO FS16-1-DWH
       MOVE FS16(2)  TO FS16-2-DWH
       MOVE FS16(3)  TO FS16-3-DWH
       MOVE FS16(4)  TO FS16-4-DWH
       MOVE FS16(5)  TO FS16-5-DWH
       MOVE FS16(6)  TO FS16-6-DWH
       MOVE FS16(7)  TO FS16-7-DWH
       MOVE FS16(8)  TO FS16-8-DWH
       MOVE FS16(9)  TO FS16-9-DWH
       MOVE FS16(10)  TO FS16-10-DWH
       MOVE FS17(1)  TO FS17-1-DWH
       MOVE FS17(2)  TO FS17-2-DWH
       MOVE FS17(3)  TO FS17-3-DWH
       MOVE FS17(4)  TO FS17-4-DWH
       MOVE FS17(5)  TO FS17-5-DWH
       MOVE FS17(6)  TO FS17-6-DWH
       MOVE FS17(7)  TO FS17-7-DWH
       MOVE FS17(8)  TO FS17-8-DWH
       MOVE FS17(9)  TO FS17-9-DWH
       MOVE FS17(10)  TO FS17-10-DWH
       MOVE FS18  TO FS18-DWH
       MOVE FS19  TO FS19-DWH

在平面文件被写入,它们可通过VBA代码,也由VB.NET应用生成被处理到MySQL

Once the flat files are written, they can be processed to MySQL by the VBA code, also generated by the VB.NET application.

类型定义声明,以应对文本文件导入

Type def declaration to deal with the text file importation

请注意在注释原始图片旁边的每个字段

Note the original PICTURE in comments next to each field

'-------------------------------------------------------------
' REC_FC8 Record
'-------------------------------------------------------------
Private Type REC_FC8 
   FS1 as string*1  '  03 FS1  PIC X  
   FS2 as string*9  '  03 FS2  PIC   
   FS2A as string*1  '  05 FS2A  PIC 9  
   RFS2B as string*8  '  05 RFS2B  PIC X(8)  
   FS2B as string*8  '  05 FS2B  PIC 9(8)  
   FS3 as string*11  '  03 FS3  PIC   
   FS3A as string*1  '  05 FS3A  PIC 9  
   FS3B as string*10  '  05 FS3B  PIC X(10)  
   FS4 as string*6  '  03 FS4  PIC   
   FS4A as string*2  '  05 FS4A  PIC 99  
   FS4B as string*2  '  05 FS4B  PIC 99  
   FS4C as string*2  '  05 FS4C  PIC 99  
   FS5 as string*5  '  03 FS5  PIC X(5)  
   FS6 as string*20  '  03 FS6  PIC X(20)  
   FS7 as string*1  '  03 FS7  PIC 9  
   FS8 as string*12  '  03 FS8  PIC S9(9)V99 computational-3 
   FS9 as string*12  '  03 FS9  PIC S9(9)V99 computational-3 
   FS10 as string*1  '  03 FS10  PIC 9  
   FS11 as string*12  '  03 FS11  PIC S9(9)V99 computational-3 
   FS12 as string*12  '  03 FS12  PIC S9(9)V99 computational-3 
   FS13 as string*12  '  03 FS13  PIC S9(9)V99 computational-3 
   FS14_15_1 as string*13  '  03 FS14-15  PIC   
   FS14_15_2 as string*13  '  03 FS14-15  PIC   
   FS14_15_3 as string*13  '  03 FS14-15  PIC   
   FS14_15_4 as string*13  '  03 FS14-15  PIC   
   FS14_15_5 as string*13  '  03 FS14-15  PIC   
   FS14_15_6 as string*13  '  03 FS14-15  PIC   
   FS14_15_7 as string*13  '  03 FS14-15  PIC   
   FS14_15_8 as string*13  '  03 FS14-15  PIC   
   FS14_15_9 as string*13  '  03 FS14-15  PIC   
   FS14_15_10 as string*13  '  03 FS14-15  PIC   
   FS14_1 as string*1  '  05 FS14  PIC 9  
   FS14_2 as string*1  '  05 FS14  PIC 9  
   FS14_3 as string*1  '  05 FS14  PIC 9  
   FS14_4 as string*1  '  05 FS14  PIC 9  
   FS14_5 as string*1  '  05 FS14  PIC 9  
   FS14_6 as string*1  '  05 FS14  PIC 9  
   FS14_7 as string*1  '  05 FS14  PIC 9  
   FS14_8 as string*1  '  05 FS14  PIC 9  
   FS14_9 as string*1  '  05 FS14  PIC 9  
   FS14_10 as string*1  '  05 FS14  PIC 9  
   FS15_1 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
   FS15_2 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
   FS15_3 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
   FS15_4 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
   FS15_5 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
   FS15_6 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
   FS15_7 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
   FS15_8 as string*12  '  05 FS15  PIC S9(9)V99 computational-3 
...
   FS17_8 as string*12  '  03 FS17  PIC S9(9)V99 computational-3 
   FS17_9 as string*12  '  03 FS17  PIC S9(9)V99 computational-3 
   FS17_10 as string*12  '  03 FS17  PIC S9(9)V99 computational-3 
   FS18 as string*6  '  03 FS18  PIC 9(6)  
   FS19 as string*1  '  03 FS19  PIC 9      
        FC8LF As String * 2 ' LF 11
End Type

创建表过程

每个领域已成为一个对象(从我创建了一个自定义类),该方法 SQLtypeFull 下面使用返回每个字段

Each field has become an object (from a custom class I created), and the method SQLtypeFull used below returns the MySQL datatype of each field

'========================================================================
Private Function Create_Table_MySQL() As Boolean
    On Error GoTo Erreur

    Dim Rs As Recordset
    Dim SQL As String

    SQL = "CREATE TABLE IF NOT EXISTS `TBL_DAT_FACTURE` ( `ID` INT(11) NOT NULL auto_increment, `RECID` INT(11)"
           SQL = SQL &  ", `FS1` " & FS1.SQLtypeFull
           SQL = SQL &  ", `FS2` " & FS2.SQLtypeFull
           SQL = SQL &  ", `FS2A` " & FS2A.SQLtypeFull
           SQL = SQL &  ", `RFS2B` " & RFS2B.SQLtypeFull
           SQL = SQL &  ", `FS2B` " & FS2B.SQLtypeFull
           SQL = SQL &  ", `FS3` " & FS3.SQLtypeFull
           SQL = SQL &  ", `FS3A` " & FS3A.SQLtypeFull
           SQL = SQL &  ", `FS3B` " & FS3B.SQLtypeFull
           SQL = SQL &  ", `FS4` " & FS4.SQLtypeFull
           SQL = SQL &  ", `FS4A` " & FS4A.SQLtypeFull
           SQL = SQL &  ", `FS4B` " & FS4B.SQLtypeFull
           SQL = SQL &  ", `FS4C` " & FS4C.SQLtypeFull
           SQL = SQL &  ", `FS5` " & FS5.SQLtypeFull
           SQL = SQL &  ", `FS6` " & FS6.SQLtypeFull
           SQL = SQL &  ", `FS7` " & FS7.SQLtypeFull
           SQL = SQL &  ", `FS8` " & FS8.SQLtypeFull
           SQL = SQL &  ", `FS9` " & FS9.SQLtypeFull
           SQL = SQL &  ", `FS10` " & FS10.SQLtypeFull
           SQL = SQL &  ", `FS11` " & FS11.SQLtypeFull
           SQL = SQL &  ", `FS12` " & FS12.SQLtypeFull
           SQL = SQL &  ", `FS13` " & FS13.SQLtypeFull
           SQL = SQL &  ", `FS14_15_1` " & FS14_15_1.SQLtypeFull
           SQL = SQL &  ", `FS14_15_2` " & FS14_15_2.SQLtypeFull
           SQL = SQL &  ", `FS14_15_3` " & FS14_15_3.SQLtypeFull
           SQL = SQL &  ", `FS14_15_4` " & FS14_15_4.SQLtypeFull
           SQL = SQL &  ", `FS14_15_5` " & FS14_15_5.SQLtypeFull
           SQL = SQL &  ", `FS14_15_6` " & FS14_15_6.SQLtypeFull
           SQL = SQL &  ", `FS14_15_7` " & FS14_15_7.SQLtypeFull
           SQL = SQL &  ", `FS14_15_8` " & FS14_15_8.SQLtypeFull
           SQL = SQL &  ", `FS14_15_9` " & FS14_15_9.SQLtypeFull
           SQL = SQL &  ", `FS14_15_10` " & FS14_15_10.SQLtypeFull
           SQL = SQL &  ", `FS14_1` " & FS14_1.SQLtypeFull
           SQL = SQL &  ", `FS14_2` " & FS14_2.SQLtypeFull
           SQL = SQL &  ", `FS14_3` " & FS14_3.SQLtypeFull
           SQL = SQL &  ", `FS14_4` " & FS14_4.SQLtypeFull
           SQL = SQL &  ", `FS14_5` " & FS14_5.SQLtypeFull
           SQL = SQL &  ", `FS14_6` " & FS14_6.SQLtypeFull
           SQL = SQL &  ", `FS14_7` " & FS14_7.SQLtypeFull
           SQL = SQL &  ", `FS14_8` " & FS14_8.SQLtypeFull
           SQL = SQL &  ", `FS14_9` " & FS14_9.SQLtypeFull
           SQL = SQL &  ", `FS14_10` " & FS14_10.SQLtypeFull
           SQL = SQL &  ", `FS15_1` " & FS15_1.SQLtypeFull
           SQL = SQL &  ", `FS15_2` " & FS15_2.SQLtypeFull
           SQL = SQL &  ", `FS15_3` " & FS15_3.SQLtypeFull
           SQL = SQL &  ", `FS15_4` " & FS15_4.SQLtypeFull
           SQL = SQL &  ", `FS15_5` " & FS15_5.SQLtypeFull
...
           SQL = SQL &  ", `FS17_9` " & FS17_9.SQLtypeFull
           SQL = SQL &  ", `FS17_10` " & FS17_10.SQLtypeFull
           SQL = SQL &  ", `FS18` " & FS18.SQLtypeFull
           SQL = SQL &  ", `FS19` " & FS19.SQLtypeFull


    SQL = SQL & ", PRIMARY KEY (`ID`)"
    SQL = SQL & ") ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE utf8_bin;"
    MySQLcon.Execute (SQL)      

    Create_Table_MySQL = True

Exit_Sub:
    Exit Function

Erreur:
    Create_Table_MySQL = False
    Resume Exit_Sub

End Function

决赛SQL语句

CREATE TABLE IF NOT EXISTS `FACTURE` 
( `ID` INT(11) NOT NULL auto_increment, `RECID` INT(11), `FS1` CHAR(1), `FS2` CHAR(9), `FS2A` TINYINT(1) UNSIGNED, `RFS2B` CHAR(8), `FS2B` INT(8) UNSIGNED, `FS3` CHAR(11), `FS3A` TINYINT(1) UNSIGNED, `FS3B` CHAR(10), `FS4` CHAR(6), `FS4A` TINYINT(2) UNSIGNED, `FS4B` TINYINT(2) UNSIGNED, `FS4C` TINYINT(2) UNSIGNED, `FS5` CHAR(5), `FS6` CHAR(20), `FS7` TINYINT(1) UNSIGNED, `FS8` DECIMAL(11,2), `FS9` DECIMAL(11,2), `FS10` TINYINT(1) UNSIGNED, `FS11` DECIMAL(11,2), `FS12` DECIMAL(11,2), `FS13` DECIMAL(11,2), `FS14_15_1` CHAR(13), `FS14_15_2` CHAR(13), `FS14_15_3` CHAR(13), `FS14_15_4` CHAR(13), `FS14_15_5` CHAR(13), `FS14_15_6` CHAR(13), `FS14_15_7` CHAR(13), `FS14_15_8` CHAR(13), `FS14_15_9` CHAR(13), `FS14_15_10` CHAR(13), `FS14_1` TINYINT(1) UNSIGNED, `FS14_2` TINYINT(1) UNSIGNED, `FS14_3` TINYINT(1) UNSIGNED, `FS14_4` TINYINT(1) UNSIGNED, `FS14_5` TINYINT(1) UNSIGNED, `FS14_6` TINYINT(1) UNSIGNED, `FS14_7` TINYINT(1) UNSIGNED, `FS14_8` TINYINT(1) UNSIGNED, `FS14_9` TINYIN
T(1) UNSIGNED, `FS14_10` TINYINT(1) UNSIGNED, `FS15_1` DECIMAL(11,2), `FS15_2` DECIMAL(11,2), `FS15_3` DECIMAL(11,2), `FS15_4` DECIMAL(11,2), `FS15_5` DECIMAL(11,2), `FS15_6` DECIMAL(11,2), `FS15_7` DECIMAL(11,2), `FS15_8` 
...
DECIMAL(11,2), `FS17_10` DECIMAL(11,2), `FS18` DATE, `FS19` TINYINT(1) UNSIGNED, 
 PRIMARY KEY (`ID`)) ENGINE=MyISAM  
 DEFAULT CHARSET=utf8 COLLATE utf8_bin;



我有在生成的VBA模块得多,产生的XML的细节和精确度的水平帮助了很多为所有这些:

I have much more in the generated VBA modules, and the level of detail and accuracy of the generated xml helped a lot for all of them:


  • 我创建了管理领域的方方面面,特别是一类采取转换的照顾VBA / MySQL的下列原始图片和VBA类型(日期,长,双打,货币等),并有一个钩的情况下,要强制另一种类型。

  • 这完全涉及与元数据创建(也是MySQL的)

  • 它与错误涉及导入数据时,记录在文件中的一切,场平

我可能已经显示出足够的给你一些想法,所以我会停在那里。

I have probably shown enough to give you some ideas so I will stop there.

最重要的:在几十万条记录,我还没有计算一个数字的损失。当我SUM()对数据库使用SQL的所有行,我有相同的数字比原来的COBOL应用程序

The most important: On several hundred thousands of records, I have not a single digit loss on computations. When I SUM() on all rows using SQL in the Database, I have the exact same numbers than returned by the original COBOL application

如果你想知道为什么我用访问/ VBA和.NET不为进口:这是一个不可争辩的前提-_-

If you wonder why I used Access/VBA and not .NET for the importation: it was a non-negotiable requirement -_-

在最后一个音符:我无论如何也不能隶属于 CB2XML ,这是不是它的广告。这只是一个伟大的和有益的软件,值得爱和关注。

On a last note : I am not affiliated in anyway with CB2XML and this is not an advertisement for it. It's just a great and helpful piece of software, and deserves love and attention.

这篇关于动态读取COBOL重新定义与C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆