Filehelpers - 复杂的记录布局帮助

时间:2014-06-11 14:28:15

标签: edi filehelpers

我们正在尝试将filehelpers用于一些专门处理EDI的文件接口项目。以下样本定义使用EDI 858规范。像大多数接口规范一样,每个供应商都有自己的风格。您可以找到样本858 EDI规范here

我们的供应商有自己的味道;这是我们目前在转换之前使用的样本记录定义:

H1_Record_type      As String ' * 8  EDI858FF
H2_TRANS_DATE       As String ' * 8 yyyyMMdd
H3_Trans_type       As String ' * 2 00 = New, 01 = Cancel Carrier, 03 = Delete, 04 = Change
H4_Pay_type         As String ' * 2 PP = Prepaid, CC = Collect, TP = Third Party (our default is PP)
H5_Load             As String ' * 30 Authorization
H6_Load_Ready_date  As String ' * 12 yyyyMMddHHmm
H7_Commodity        As String ' * 10
H8_Customer_HQ_ID   As String ' * 20 hard coded '0000000001'
H9_Customer         As String
H10_Mill_ID         As String ' * 20 Shipping Perdue Location or Destination Perdue Location
H11_Tender_Method   As String ' * 10 blank for now
H12_Carrier_ID      As String ' * 10 blank for now
H13_Weight          As String ' * 7 estimated total load weight
H14_Weight_Qualifier As String ' * 2 blank for now
H15_Total_Miles     As String ' * 7 zero for now
H16_Total_quantity  As String ' * 7 blank for now
H17_Weight_Unit     As String ' * 1 L = pounds, K = Kilograms, L=default
H18_REF             As String ' * 3 REF
            HR1_Ref_qualifier   As String ' * 3 CO = Deliv Dest ref., P8 = Deliv Orig Ref.
            HR2_Ref_value       As String ' * 80
H19_END_REF                 As String ' * 7 END REF
H20_SPEC_INSTRUCTION        As String ' * 16 SPEC INSTRUCTION
            HS1_Qualifier           As String ' * 3  1 = Credit Hold, 7T = Export Order, HM = Hazmat, L = Load ready for pickup
                                ' PTS = Tarp, RO = Hot Load, TAR = Full Tarp, WTV = Weight Verification, DDN = Driver needs TWIC
                                ' PR = Prohibited
H21_END_SPEC                As String ' * 20 END SPEC INSTRUCTION
H22_NOTE                    As String ' * 4 NOTE
             HN1_Note_Qualifier      As String ' * 3 SPH = Special Handling, PRI = Load Priority, DEL = Transit Days
            HN2_Note                As String ' * 80
H23_END_NOTE                As String ' * 8 END NOTE
H24_EQUIPMENT               As String ' * 9 EQUIPMENT
H25_END                     As String ' * 13 END EQUIPMENT
H26_LOAD_CONTACT            As String ' * 12 LOAD CONTACT
             LC1_Contact_Name        As String ' * 60
             LC2_Contact_type        As String ' * 2  EM= E-mail, FX = Fax, TE = Telephone
             LC3_Contact_Data        As String ' * 80
H27_END_LOAD_CONTACT        As String ' * 16 END LOAD CONTACT
H28_STOP                    As String ' * 4 STOP  There will always be 2 - CL and CU
    S1_Stop_Number          As String ' * 2
    S2_Stop_Reason          As String ' * 2 CL = Complete Load, CU = Complete Unload (one of each required for every load)
    S3_LOCATION             As String ' * 8 LOCATION
        SL1_Location_ID     As String ' * 20
        SL2_Location_Name   As String ' * 60
        SL3_Location_Add1   As String ' * 55
        SL4_Location_Add2   As String ' * 55
        SL5_Location_City   As String ' * 30
        SL6_Location_State  As String ' * 2
        SL7_Location_Zip    As String ' * 10 (use only 5 digits)
        SL8_Location_Country As String ' * 3 USA, CAN, MEX
    S4_END_LOCATION         As String ' * 12 END LOCATION
    S5_STOP_DATE            As String ' * 9 STOP DATE
        SD1_Date_Qualifier  As String ' * 3 37 = No earlier than, 38 = No later than, 10 = Expected arrival time, 35 = Actual arrival
                                ' 11 = Actual departure
        SD2_Date_Time       As String ' * 12  yyyyMMddHHmm
    S6_END_STOP_DATE        As String ' * 13 END STOP DATE
    S7_STOP_REF             As String ' * 8 STOP REF
        SR1_Reference_Qualifier As String ' 3 72 = Transit Time, DK = Dock Number, OQ = Order Number
        SR2_Reference_Value As String ' * 80
    S8_END_STOP_REF         As String ' * 12 END STOP REF
H29_END_STOP                As String ' * 8 END STOP
H30_ORDER                   As String ' * 5 ORDER
    O1_Order_Number         As String ' * 80
H31_END_ORDER               As String ' * 9 END ORDER

这是一条通常在一条长行中的示例消息:

  

EDI858FF〜20140611〜04〜PP〜1266010982〜201406060700〜CANOLA   ML~0000001~商家名称~RICHLAND ~~~ 60000 ~~ 0 ~~ L~REF~SA~客户   名字~END REF~STOP~01~CL~LOCATION~RICHLAND ~~~~~~~~ END LOCATION~STOP   DATE~37~201406060000~END STOP DATE~STOP REF~OQ~5568~END STOP REF~END   停止〜停止~02~CU~LOCATION~261450 ~~~~~~~~ END LOCATION~STOP   DATE~37~201406060000~END STOP DATE~STOP REF~OQ~5568~END STOP REF~END   停止〜订单~5568~结束订单

我真的认为这对Filehelpers来说可能过于复杂,但我想把它放到社区,看看你们是否都可以提供帮助。

正如您所看到的,文件主要是波形分隔符,但定义中的某些字段也可用作分隔符。例如,REF或STOP都包含可能有很多记录深度的附加信息。您可以有多个STOP定义1到999位置记录。我真的在想这对Filehelpers来说太过分了......

如果您要为filehelpers尝试此配置,您将从哪里开始,以及如何处理所有子字段?

1 个答案:

答案 0 :(得分:0)

FileHelpers不是这种复杂格式的理想工具。原因如下:

  1. 在识别和报告错误方面没有足够的灵活性。
  2. 转义字符的困难(例如,当字段在字段内并且需要转义时)我对EDI格式不太熟悉,不知道这是否可能是个问题。
  3. FileHelpers提供的主/详细工具不足
  4. 对于(1),您不必提及您是导入还是导出EDI,或两者兼而有之。如果您只是导出EDI,则不需要错误报告。

    对于(2),您可以通过为问题字段提供own custom converters来解决转义问题,但您可能会发现每个字段都有自定义转换器。

    对于(3),有两种方法可以使用FileHelper处理主/详细记录,但如果没有严重的黑客攻击,它们都不可能满足您的要求

    一种方法是to use the MasterDetailEngine,但这只支持一种详细信息类型,只支持一种嵌套级别,因此您必须找到这两种方法的解决方法。

    另一种方法是使用to use the MultiRecordEngine。但是,它会将每一行视为不相关的记录,并且层次结构(即哪个S记录属于哪个H记录)很难确定。