Recreating the Get Shipment Lines Form

tompynationtompynation Member Posts: 398
Hi,

I am recreating the Get Shipment Lines form so that you can just run this form from the Object designer or the Menu...
So you do not have to create the Invoice first before you can use this form.

Now this is all easy but i have a question.

i created a new Form "Shipped not Invoiced". This form has the table view set to:
WHERE(Qty. Shipped Not Invoiced=FILTER(<>0))

The form just contains a tablebox to display the "Sales Shipment Lines", and a button to create the Invoice(s) for the Selected Shipment Lines.

Now my question is, how can i get all the Lines that the User has Selected, when he presses the button to create the Invoices?

Comments

  • MBergerMBerger Member Posts: 413
    Lookup SetSelectionFilter in the helpfile
  • tompynationtompynation Member Posts: 398
    Well, i see how it works but how can i use this?

    I am showing all Sales Shipment Lines, not filtered on the "Bill-to Customer No."
    So the user can select from Multiple Shipments, and for different Customers

    So will need two fields from the Filter:

    1. The Document No.
    2. The Line No.


    How can i do this? So that i get the "Line No." filter per "Document No." ?
  • MBergerMBerger Member Posts: 413
    Make a new variable of the same type as the record ( let's call it NewRec ) , then with the following code, you can loop through all the selected lines the user has selected :
    currform.setselectionfilter(NewRec) ;
    if newrec.find('-') then //Replace with FindSet if your version supports it
      repeat
        // do something with Newrec."Document No.",NewRec."Line No."
      until NewRec.next = 0
    
  • tompynationtompynation Member Posts: 398
    allright, thanks, that was what i needed...
  • tompynationtompynation Member Posts: 398
    I allmost got it working entirely... But still there is a problem:

    When i select a Sales Shipment Line with "Bill-to Customer No." = 12345
    and a Sales Shipment Line with "Bill-to Customer No." = 54321

    Then i receive following error:

    The Bill-to Customer No. on the Sales Header 1036 and the Sales Shipment Header 102049 must be the Same

    The first Invoice gets correctly created. This has the no. 1036
    But when it should generate the new Invoice for the 2nd selected
    Sales Shipment Line then it gives the error. The 2nd selected Sales Shipment Line, comes from the Sales Shipment Header 102049

    Following code creates the Sales Header(s) and Invoice Line(s) on a button Click:
    [b]<Control1000000021> - OnPush()[/b]
    lv_BillTo := '';
    CurrForm.SETSELECTIONFILTER(lv_SalesShptLine);
    
    lv_SalesShptLine.SETCURRENTKEY("Bill-to Customer No.");
    IF lv_SalesShptLine.FINDSET THEN BEGIN
       REPEAT
          CLEAR(ShptMgmnt);
          //Indien "Bill-to Customer No." wijzigt nieuwe SalesHeader aanmaken
          IF lv_BillTo = '' THEN BEGIN
             CreateSalesHeader(lv_SalesShptLine."Bill-to Customer No.",lv_SalesShptLine."Sell-to Customer No.");
             ShptMgmnt.SetSalesHeader(gv_InvoiceHeader);
             ShptMgmnt.CreateInvLines(lv_SalesShptLine);
             lv_BillTo := lv_SalesShptLine."Bill-to Customer No.";
          END
          ELSE IF lv_BillTo <> '' THEN BEGIN
              IF lv_BillTo <> lv_SalesShptLine."Bill-to Customer No." THEN BEGIN
                  CreateSalesHeader(lv_SalesShptLine."Bill-to Customer No.",lv_SalesShptLine."Sell-to Customer No.");
                  ShptMgmnt.SetSalesHeader(gv_InvoiceHeader);
                  ShptMgmnt.CreateInvLines(lv_SalesShptLine);
              END
              ELSE IF lv_BillTo = lv_SalesShptLine."Bill-to Customer No." THEN BEGIN
                  ShptMgmnt.SetSalesHeader(gv_InvoiceHeader);
                  ShptMgmnt.CreateInvLines(lv_SalesShptLine);
             END;
          END;  
    
    
         // IF CONFIRM(Text001) THEN BEGIN
         //    FORM.RUNMODAL(43,gv_InvoiceHeader);
         // END;
       UNTIL lv_SalesShptLine.NEXT = 0;    
    END;
    
    As you can see i create New Sales Header, every time the "Bill-to Customer No." switches.


    CreateSalesHeader(varBillToCust : Code[20];varSellToCust : Code[20])
    gv_InvoiceHeader.RESET;
    gv_InvoiceHeader.INIT;
    gv_InvoiceHeader.VALIDATE("Document Type",gv_InvoiceHeader."Document Type"::Invoice);
    gv_InvoiceHeader.VALIDATE("No.",'');
    gv_InvoiceHeader.INSERT(TRUE);

    gv_InvoiceHeader.VALIDATE("Sell-to Customer No.",varSellToCust);
    gv_InvoiceHeader.VALIDATE("Bill-to Customer No.",varBillToCust);
    gv_InvoiceHeader.MODIFY(TRUE);

    Somebody who see's something wrong with my code/logic ??
Sign In or Register to comment.