SO in company A look for Shipment in company B

to experts,

i’m new in development in c/al, so i need help.

i hv 2 companies, AA is trading company and receiving order from end customer and give PO to company BB. BB is a manufacturing site and shipping the prod.output to company AA.

in AA company, i need to add in certain empty area in Sales Order form about the status of order, by jumping to company BB and see if it’s shipped or not.

the PO No. (table: purchase header) of company=AA is always transferred to External Document No. (table: sales header) of company=BB. External Document No. (table: sales header) in SO is always transferred to the same field in Sales Shipment Header.External Document No.

lineExtDoc, aassh, aaso, aapostdt, aacont are Global var.

the code:

lineExtDoc := “Purchase Order No.”;
//i use breakpoint on this to make sure what “lineExtDoc” contains.

aassh.CHANGECOMPANY(‘AA’);
aassh.SETFILTER(“External Document No.”,lineExtDoc);
aassh.CHANGECOMPANY(‘AA’);
IF aassh.FIND(’=’) THEN BEGIN
aaso := aassh.“Order No.”;
aapostdt := aassh.“Posting Date”;
aacont := aassh.“Package Tracking No.”;
END ELSE BEGIN

//if now found (why it can not find???)
//I want to grab whats actually these var’s contain

aaso := COMPANYNAME;
aapostdt := 0D;
aacont := aassh.GETFILTER(“Order No.”);
MESSAGE(‘The filter of aassh.Order No. :’,aacont);
END;

when I open SO in company=AA, the text box of aaso, aapostdt and aacont are still not showing the related Shipment information. in fact, I check there’s actually a shipment from company=BB to AA.

what’s wrong in my code.

thank you.

I wrongly mention the company … please disregard previous message, and read this.

to experts,

i hv 2 companies, BB is trading company and receiving order from end customer and give PO to company AA. AA is a manufacturing site and shipping the prod.output to company BB.

in BB company, i need to add in certain empty area in Sales Order form about the status of order, by jumping to company AA and see if it’s shipped or not.

the PO No. (table: purchase header) of company=BB is always transferred to External Document No. (table: sales header) of company=AA. External Document No. (table: sales header) in SO is always transferred to the same field in Sales Shipment Header.External Document No.

lineExtDoc, aassh, aaso, aapostdt, aacont are Global var.

the code:

lineExtDoc := “Purchase Order No.”;
//i use breakpoint on this to make sure what “lineExtDoc” contains.

aassh.CHANGECOMPANY(‘AA’);
aassh.SETFILTER(“External Document No.”,lineExtDoc);
aassh.CHANGECOMPANY(‘AA’);
IF aassh.FIND(’=’) THEN BEGIN
aaso := aassh.“Order No.”;
aapostdt := aassh.“Posting Date”;
aacont := aassh.“Package Tracking No.”;
END ELSE BEGIN

//if now found (why it can not find???)
//I want to grab whats actually these var’s contain

aaso := COMPANYNAME;
aapostdt := 0D;
aacont := aassh.GETFILTER(“Order No.”);
MESSAGE(‘The filter of aassh.Order No. :’,aacont);
END;

when I open SO in company=BB, the text box of aaso, aapostdt and aacont are still not showing the related Shipment information. in fact, I check there’s actually a shipment from company=AA to BB.

what’s wrong in my code.
thank you.

The first thing to do is to go company AA and manually set a filter on the external document no. you are looking for. Make sure you can find the record just using the client.

If you can find the record that way, then it is a problem with the code.

My guess is that it is because you are using find(’=’) instead of find(’-’).

My first thought was that it was because you are calling CHANGECOMPANY twice, but according to the documentation, CHANGECOMPANY maintains filters.

the CHANGECOMPANY command is no problem.

the problem lies on the returned record on: aassh.SETFILTER(“External Document No.”,lineExtDoc);
the results are more than 1 lines.

next thing is FIND ; i think i have ranged the records to follow my criteria on filters command in lines above.
but seems, the FIND (’-’) command still reach the 1st record in the table (not in the range of record based on my filter commands).
and, the FIND(’+’) command reaches the last record in the table.

i’m really clueless. need to meditate, contemplate and concentrate with these texts and manuals.

so, i changed everything!

I made new form: 50005 - AA Shipments, based on Posted Shipments (Form:142), and at Form - OnInit(), i wrote: CHANGECOMPANY(‘AA’); it works!
the form can open and show AA company’s shipment header list.

my quest now is to find how to do a passing parameter. i need to open this form:AA shipments from Sales Order form. I will add 1 more Menu Items : Line - “Check AA shipment”.

the passing parameter / filter that i need to make is, on Sales Order Subfom (inside Sale Order form) : Purchase Order No. ; to match with AA shipments . External Document No.
I cannot use Menu Item properites: RunFormLink ; the datatype is not suitable, one is Code20, the other is Text30.

How to deal with this?
how to easily create a control to open other form and immediately giving filter based on a value in certain part of the current form?
how to convert data type: Code to Text, or vice versa? (is this necessary ?)
please enlight me and show me the way

Use the RunFormView property instead. You will be able to set filters there.

There are a few other ways to accomplish the same thing, however. You may want to search here and on mibuso for how to pass parameters.

Finally, I decide to do a/f:
I create a new form, and put changecompany(‘AA’) in form - oninit()

in the Sales Order subform, i add a check shipment sub, basically looked like a/f:

*aash is Form based on Form:Posted Sales Shipments

  • ssh is Record, Sales Shipment Header

ssh.CHANGECOMPANY(‘AA’);
ssh.SETFILTER(“External Document No.”, Rec.“Purchase Order No.”);
aassh.SETTABLEVIEW(ssh);
aassh.EDITABLE := FALSE;
aassh.RUNMODAL;

in finishing touch, i put if… to check and message(…) to humanize the interaction.

Thanx a lot for your supports

Change this line of code:

ssh.SETFILTER(“External Document No.”, Rec.“Purchase Order No.”);

to

ssh.SETFILTER(“External Document No.”, ‘%1’, Rec.“Purchase Order No.”);

if Rec.“Purchase Order No.” was blank then you would remove the filter and you would pull the first record from your table. You might want to check whether Rec.“Purchase Order No.” has a value before proceeding.

Also, as your dataset comes larger your .SETFILTER will take longer unless you make use of an existing Key that starts with “External Document No.”.

Regards,

Django