Horse06Horse06 Member Posts: 496
I tried to create a dataport from two tables and export the data. I indent ed the second table (Drop Shipment) and doing the dataitem link with the first table(Sales Header), but the system gives an error. What I need to fo is to filter out the sales order in which the shipping date is not today and take all the data from the other table Drop shippment, in which the sales order no has relationship with No of Sales Header. Any hint? Thanks!


  • ara3nara3n Member Posts: 9,255
    you cannot indent in dataports.
    Initially MS was tried to implement this but then they changed their mind and implemented xmlports.

    I would write a Codeunit to create a file and write all the needed data.
    Ahmed Rashed Amini
    Independent Consultant/Developer

  • AlbertvhAlbertvh Member Posts: 516
    You will have to add code on the second dataitem in the OnPreDataItem trigger of the Drop Shipment
    "Sales Header".COPYFILTER("No.","Document No.");

    You cannot indent DataItems in a Dataport.

  • Horse06Horse06 Member Posts: 496
    Thank you for your advice and I will test it tomorrow!
    Here is what I am going to do on this and I don't know if it works.
    Drop Shipment( firstData Item) Since I need to export the fields from this Table.
    Sales Header(Second Dataitem) Since I need to filter out those records in which the shipment date is not today, no fields will be exported from this table.
    So based on Albertvh' advice, I will the code this in Drop Shipment:
    "Sales Header".COPYFILTER("No.","Order No.");
    I need to add another two lines as I want to filter out those records from Drop Shipment in which the shipment is not today:
    If "Sales Header". shipdate <>0D then
    But it seems that these two lines don't work.
    There is no shipment date in Sales Header table and that's why I want to link this table with Sales Header table. If copyfilter funtion has the same effect of dataitem link, perhaps it works. If it doesn't, how to filter out those records from Drop Shipment, in which shipment date is not today? Appreciate it!
  • AlbertvhAlbertvh Member Posts: 516

    Ok if you are not going to be exporting any fields from the sales header then I suggest you do this

    1) Only one DataItem Drop Shipment
    2) OnBeforeExportRecord
    IF  ("Drop Shipment"."Shipment Date" <> TODAY) THEN

    Hope this helps.

  • Horse06Horse06 Member Posts: 496
    Thank you for your reply, Albertvh! In My drop Shipment table there is no Shipment date field, If I don't link drop shipment with Sales header table, does this code work? If not, how to link these two tables together if I create a dataport with Drop Shipment as the first dataitem and Sales Header Table as a second Dataitem? Thanks!!!!
  • Horse06Horse06 Member Posts: 496
    Thanks for your advice! I tested it today, using copyfilter function. But there is still the same problem. When I code
    IF ("sales header"."Ship to Customer Date" <> TODAY) THEN
    and then export, no record was exported. Any suggestions? Thanks!
  • jversusjjversusj Member Posts: 489
    i once had trouble with multi-item dataports, and with the help of mibuso found a solution: ... highlight=

    i essentially turned a report into a dataport. it lets me indent and get the data out that i needed. i've used this trick half a dozen times already.

    good luck!
    kind of fell into this...
  • Horse06Horse06 Member Posts: 496
    Thanks, jversusj! So you still created from Dataport not from report, as it mentioned several times about report. From what I am understanding that you created two dataitems not indented from dataport and saved all the data into the temporate table and export them. I am still reading your notes and hopefully you can get me back. Thanks a lot!
  • jversusjjversusj Member Posts: 489
    i'm sorry, the thread starts off with talking about trying to get the dataport to do what i wanted, but at the end i took marcelo's advise to look into the WRITE function, which led me to look at the design of report 593 - Intrastat Make disc Tax Auth. So i stepped away from using a dataport and started with a report instead.

    I created a report indenting data items as needed, and defined variable values throughout. for the dataitem line i wanted to finally output (all variable values defined), i added the following code to the OnAfterGetRecord trigger. note that you have to manually build the flat file and the delimiters (**|** in my case).
    EDIOutstream.WRITETEXT('*' +
    OutPost + '*|*' +
    OutCust + '*|*' +
    OutPO + '*|*' +
    OutDocNo + '*|*' +
    OutVendID + '*|*' +
    OutOrder + '*|*' +
    OutVendName + '*|*' +
    OutVendAdd1 + '*|*' +
    OutVendCity + '*|*' +
    OutVendState + '*|*' +
    OutVendZip + '*|*' +
    OutShipToName + '*|*' +
    OutShipToAdd1 + '*|*' +
    OutShipToAdd2 + '*|*' +
    OutShipToCity + '*|*' +
    OutShipToState + '*|*' +
    OutShipToZip + '*|*' +
    OutAmtLessFrt + '*|*' +
    OutTotalQty + '*|*' +
    OutDiscPerc + '*|*' +
    OutDiscDate + '*|*' +
    OutDiscDateCalc + '*|*' +
    OutDueDateCalc + '*|*' +
    OutDueDate + '*|*' +
    OutAmount + '*|*' +
    OutEDIShipTo + '*|*' +
    OutShipDate + '*|*' +
    OutTermDesc + '*|*' +
    OutAmtLessFrt + '*|*' +
    OutDocType + '*|*' +
    OutNoLines + '*|*' +
    OutWeightUnit + '*|*' +
    OutFrtType + '*|*' +
    OutFrtAmt + '*|*' +
    OutLineNo + '*|*' +
    OutQty + '*|*' +
    OutItemNo + '*|*' +
    OutUOM + '*|*' +
    FORMAT(OutUnitPrice) + '*|*' +
    OutItemDesc + '*|*' +
    OutLineTotal + '*|*' +
    OutUPCCode + '*|*' +
    OutSKU + '*|*' +
    OutProdType + '*|*' +
    OutBarCode + '*|*' +
    OutDivID + '*|*' +
    OutAmtSbtDisc + '*|*' +
    OutDiscAmt + '*|*' +
    OutDCStatus + '*|*' +
    OutEDIShipTo + '*|*' +
    OutWeight + '*|*' +
    OutCartons + '*|*' +
    OutBOL + '*|*' +
    OutCarrier + '*|*' +
    OutPRONo + '*|*' +
    OutAmtB4DiscPlusFrt + '*|*' +
    OutTermsDate + '*|*' +
    OutDateCode + '*|*' +
    OutTermsType + '*|*' +
    OutDunsNo + '*|*' +
    OutSCACCode + '*|*' +
    OutMark4Store + '*'
    //Without following WRITETEXT, the text file that is created will be one continuous string. This breaks the line.

    i admittedly created a lot of variables where i could have just referenced the field data itself, but whatever...

    the EDIOutstream variable is a global of type Outstream. i also had to do some other stuff with defining the filepath to create, etc. all learned from searching this forum and looking at the intrastat report for hints and structure.
    kind of fell into this...
  • AlbertvhAlbertvh Member Posts: 516
    Sorry for the late reply

    My answer is the same as before but add a variable
    SalesHeader datatype record subrtpe Sales Header

    in the BeforeExport Trigger
    IF SalesHeader.GET(SalesHeader."Document Type"::Order,"Document No.") AND
       (Salesheader."Ship to Customer Date" <> TODAY) THEN 

  • Horse06Horse06 Member Posts: 496
    Thank you for all your reference and I will do more test and hopefully get what I want. Thanks again!
Sign In or Register to comment.