我在下面编写了一个执行换行行为的脚本(参见附图作为参考输出)。但是当我通过 FTP 传输文本文件时,却导致反馈错误“文件的分隔符不正确。仍然是回车和换行。应该只是换行。”
希望得到任何人的回应......
脚本:
Long ll_row
ll_row = dw_Outbound.InsertRow(0)
dw_Outbound.SetITem(ll_row,'message',as_message)
as_message = ""
文件写入函数脚本:
//Retrieve Transaction Set Header
ids_TSH = CREATE DataStore
ids_TSH.DataObject = 'd_inventory_advice_transetheader'
ids_TSH.SetTransObject( SQLCA )
ids_TSH.Retrieve()
IF ids_TSH.ROwCount() = 1 THEN
ls_Msg += Trim(ids_TSH.Object.headerid[1])
ls_Msg += "*" + Trim(ids_TSH.Object.setidcode[1])
ls_Msg += "*" + Trim(ids_TSH.Object.setctrlnum[1])
ls_Msg += "|"
//Set LineFeed
//ls_Msg += "~n"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
END IF
//Retrieve Beginning Segment
ids_BIA = CREATE DataStore
ids_BIA.DataObject = 'd_inventory_advice_begsegment'
ids_BIA.SetTransObject(SQLCA)
ids_BIA.Retrieve()
IF ids_BIA.RowCount() = 1 THEN
ls_Msg += Trim(ids_BIA.Object.biaid[1])
ls_Msg += "*" + Trim(ids_BIA.Object.trnsetpcode[1])
ls_Msg += "*" + Trim(ids_BIA.Object.reptypecode[1])
ls_Msg += "*" + Trim(ids_BIA.Object.refid[1])
ls_Msg += "*" + is_BIADATE
ls_Msg += "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
END IF
//Assigned DateTime Reference
ls_Msg += "DTM"
ls_Msg += "*" + "007"
ls_Msg += "*" + is_BIADATE
ls_Msg += "*" + is_Time
ls_Msg += "*" + "UT"
ls_Msg += "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
//Assigned Reference Identification
ls_Msg += "REF"
ls_Msg += "*" + "EO"
ls_Msg += "*" + "SAPMBT01" //ISA06 SENDERID : SPI818TEST
ls_Msg += "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
lds_Data = CREATE DataStore
lds_Data.DataObject = 'd_inventory_advice_subinv_phldef'
lds_Data.SetTransObject(SQLCA)
lds_Data.Retrieve()
lds_Name = CREATE DAtaStore
lds_Name.DataObject = 'd_inventory_advice_nameheader'
lds_Name.SetTransObject(SQLCA)
lds_Name.Retrieve()
IF lds_Name.RowCount() = 1 THEN
ls_Msg += Trim(lds_Name.Object.nameid[1])
ls_Msg += "*" + Trim(lds_Name.Object.entityidcode[1])
ls_Msg += "*" + Trim(lds_Name.Object.entityname[1])
ls_Msg += "*" + Trim(lds_Name.Object.idcodequal[1])
ls_Msg += "*" + Trim(lds_Data.Object.subinv[1])
ls_Msg += "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
ls_Msg += Trim(lds_Name.Object.addressid[1])
ls_Msg += "*" + Trim(lds_Name.Object.addressinfo[1])
ls_Msg += "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
ls_Msg += Trim(lds_Name.Object.glid[1])
ls_Msg += "*" + Trim(lds_Name.Object.cityname[1])
ls_Msg += "*" + 'ML' //STATE OR PROVINCE CODE
ls_Msg += "*" + Trim(lds_Name.Object.postalcode[1])
ls_Msg += "*" + Trim(lds_Name.Object.countrycode[1])
ls_Msg += "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
END IF
//Administration Communication Contact
/*lds_Contact = CREATE DataStore
lds_Contact.DataObject = 'd_inventory_advice_contact'
lds_Contact.SetTransObject(SQLCA)
lds_Contact.Retrieve()
IF lds_Contact.RowCOunt() = 1 THEN
ls_Msg += Trim(lds_Contact.Object.accid[1])
ls_Msg += "*" + Trim(lds_Contact.Object.fnccode[1])
ls_Msg += "*" + Trim(lds_Contact.Object.name[1])
ls_Msg += "*" + Trim(lds_Contact.Object.numqual[1])
ls_Msg += "*" + Trim(lds_Contact.Object.telnum[1])
ls_Msg += "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
END IF*/
//Initialize DataStore To Handle Line Item RowCount
ids_ITem = CREATE DAtaStore
ids_ITem.DataObject = 'd_edi_outbound_message_external'
ids_ITem.SetTransObject( SQLCA )
IF lds_Data.RowCOunt() > 0 THEN
FOR ll_Data = 1 To lds_Data.RowCOunt()
ls_item = lds_Data.getitemString(ll_Data, 'itemcode')
ls_qtyonhand = String(lds_Data.getItemNumber(ll_Data,'sohqty'))
ls_qtyavailable = String(lds_Data.getItemNumber(ll_Data,'availableqty'))
ls_subinv = lds_Data.getItemString(ll_Data,'subinv')
ls_Msg = "LIN**MG*" + ls_item + "|"
of_ReturnOutboundMessage(ls_Msg)
of_getItemCodeRowCount(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
ls_Msg = "QTY*17*" + ls_qtyonhand + "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
ls_Msg = "QTY*33*" + ls_qtyavailable + "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
ls_Msg = "UIT*EA|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
NEXT
END IF
ll_Filter = ids_ITem.RowCount()
//Transaction Total
ls_Msg += "CTT*" + String(ll_Filter) + "|"
of_ReturnOutboundMessage(ls_Msg)
of_getInventoryAdviceTranRowCount(ls_Msg)
//Retrieve Set Trailer
ids_TST = CREATE DataStore
ids_TST.DataObject = 'd_inventory_advice_transettrailer'
ids_TST.SetTRansObject(SQLCA)
ids_TST.Retrieve()
IF ids_TST.RowCount() = 1 THEN
of_getInventoryAdviceTranRowCount(ls_Msg)
//Get the DataStore RowCount For Trasaction Set Trailer
is_SetTrailer = String(ids_InvTranTrailer.RowCount())
ls_Msg += Trim(ids_TST.Object.trailerid[1])+ "*" + is_SetTrailer + "*"
ls_Msg += Trim(ids_TSH.Object.setctrlnum[1]) + "|"
END IF
of_ReturnOutboundMessage(ls_Msg)
//Note: Function below should not be remove.
//of_getInventoryAdviceGroupTrailer()
//of_getInventoryAdviceControlTrailer()
GETDATETIME:
ls_ServerDate = gnv_app.of_getServerDateTime()
IF is_ServerDateNull = ls_ServerDate THEN GOTO GETDATETIME
is_ServerDateNull = ls_ServerDate
FilePath = String(dw_path.Object.outboundfilepath[1])
FileName = 'EDI_846_' + ls_ServerDate + '.TXT'
FileDir = FilePath + '/' + FileName
dw_Outbound.SaveAs(FileDir, TEXT!, FALSE)
dw_Outbound.Reset()