abas-ERP: Copy TN field into another TN field with edp/epi

196 views Asked by At

I want to create an invoice and fill the field pftext (TN2) with the content of another TN2 field called ytdescription.

My problem is, that I always have the path of my textfield in pftext but not the content of my textfield.

1st try of edp header:

kunde;artex;pftext;mge
'M|ytkdnr';'M|ytartnr';'M|ytdescription';'M|ytmge'

2nd try:

kunde;artex;*pftext;mge;
'M|ytkdnr';'M|ytartnr';'M|ytdescription';'M|ytmge'

Of course I could create a T254 field and store the content of M|ytdescription in the new field, but then I am stuck to max 3000 chars for the content.

Many other tries followed but with no success :-(
Any help is highly appreciated!

1

There are 1 answers

1
Frank On

I Don't know the options to do this per EDP, but there is a solution to do this per AJO:

    public int run(DbContext dbContext, String[] args) {        

    /*
     * Get the object to copy data from, in this case a customer with idno 70001
     */

    String idno = "70001";

    SelectionBuilder<Customer> selectionBuilder = SelectionBuilder.create(Customer.class);
    selectionBuilder.add(Conditions.eq(Customer.META.idno, idno));
    Customer customer = QueryUtil.getFirst(dbContext, selectionBuilder.build());
    VendorEditor vendorEditor = null;

    // Read the original content to a StringWriter
    StringWriter originalFreeText = new StringWriter();
    try {           
        customer.getFreeText(originalFreeText);

        // Create a new object to write the values to. In example a Supplier

        vendorEditor = dbContext.newObject(VendorEditor.class);
        vendorEditor.setSwd("Searchword");
        vendorEditor.setAddr("Vendor Name");


        if (!originalFreeText.toString().equals("")) {
            vendorEditor.setFreeText(new StringReader(originalFreeText.toString()));
        }   

        vendorEditor.commit();

    } catch (IOException e) {
        dbContext.out().println(e.getMessage());
    } finally {
        if (vendorEditor != null) {                 
            if (vendorEditor.active()) {
                vendorEditor.abort();
            }
        }
    }       
    return 0;
}