cancel
Showing results for 
Search instead for 
Did you mean: 

From my addon to Advanced Layout Designer

Former Member
0 Kudos

Hi!

I've a big problem:

-I created a layout with ALD;

-i wrote an add-on

now my add-on has to print a layout, the layout that I created, passing to it values/variables.

How can I do it from my add-on code??

Please help me!

PS: I think it's possible because i've seen another add-on that do it.

Thanks!

Giuseppe

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

It is possible to call the ALD from add-on screens. It isn't very elegant, but one way of calling it is as follows:-

1) Create a user table for storing the parameters. Include a column for 'host_name'

2) Create a query that returns the correct data based on linking to the user table for the parameters. Record selection can be based on the host name column = the sql server function 'host_name()'.

3) Create and save an ALD layout based on the query

4) In your SDK screen intercept the Print & Print Preview menu events. Over-ride these buttons with code that does the following.

- Deletes any records on the user table for the current host_name.

- Inserts the parameters into the user table ensuring the host_name column is also populated

- Opens the Queries Manager

- Expands the Query Group containing the relevant query

- Highlights the query you created in step 2 (click)

- Activates the Print or Print Preview buttons on the query manager (click).

- Closes the Queries Manager

This technique can be used to effectively give you customisable 'print' and 'print preview' capabilities for SDK screens based on UDO's or other data. The end result for users is much the same as printing from standard document screens. They simply hit the print or print preview and the matching document appears.

For info: Above is running on V2004 P21 system. Haven't had time to check it with V2005 yet.

Regards,

John.

Former Member
0 Kudos

John, could you please include a code snipit

or could you please...... send me an example to

domino1352@gmail.com

Former Member
0 Kudos

Below is a code snippet outlining the basic steps needed in the menu event to launch an ALD report.

The code snippet doesn't include proper error handling or UDT updating and has hardcoded report names, you should amend as appropriate to your requirements.


If (pVal.MenuUID = "519" Or pVal.MenuUID = "520") And pVal.BeforeAction = True Then
  
    'Delete Record(s) from User Table used by Query
    Set sboRecordset = sboCompany.GetBusinessObject(BoRecordset)
    strQuery = "delete from [@azu_spc_jobprint] where u_azu_host = host_name()"
    sboRecordset.DoQuery strQuery

    'Insert Record(s) into User Table used by reports
    strQuery = "insert into [@azu_spc_jobprint] (code, name, u_azu_rord, u_azu_host)" & _
               " values ('Code', 'Name', 'Key Field for Report', host_name())"
    sboRecordset.DoQuery strQuery
        
    'Launch the query manager
    sboApp.ActivateMenuItem "4865"
        
    'Reduces screen flickering
    sboApp.Forms.ActiveForm.Left = 10000

    'Expand the query group, and click on the query name
    Set sboCells = sboApp.Forms.ActiveForm.Items("6").Specific.Columns("1").Cells
    On Error Resume Next
    For lngCount = 1 To sboCells.Count
        If sboCells(lngCount).Specific.Value = "My Query Group" Then
            sboCells(lngCount).Click ct_Collapsed
            Exit For
        End If
    Next
    For lngCount = 1 To sboCells.Count
        If sboCells(lngCount).Specific.Value = "My Query Name" Then
            sboCells(lngCount).Click
            Exit For
        End If
    Next
    
    'Click on the Preview or Print button
    If pVal.MenuUID = AZU_MNU_PRINT_PREVIEW Then
        sboApp.Forms.ActiveForm.Items("402").Click
    Else
        sboApp.Forms.ActiveForm.Items("401").Click
    End If
            
    'Close the form
    sboApp.Forms.ActiveForm.Left = 1
    sboApp.Forms.ActiveForm.Close
    On Error GoTo ErrorHandler
    BubbleEvent = False
End If

An example of a simple SQL query to go with the above:-

Select U_AZU_BCOD

from [@azu_spc_jobprint] t0

inner join [@azu_spc_grn_1] t1

on t0.u_azu_rord = t1.u_azu_rord

where t0.u_azu_host = host_name()

The query uses host_name() to identify the correct record(s), and then uses any other fields provided to link to the appropriate tables for data retrieval.

Regards,

John.

Former Member
0 Kudos

I am testing by doing this manually. as I cannot seem to get this to work from code properly.

Process I am using is to bring up the query manager

select a query (single click)

then click print preview (but both print prev and print are greyed out),

But if i double click then click print prev.

only get the option of printing screen dump,table or selections within table, Does not use the layout.

NB. I am launching from a menu though not from intercepting print preview. as I am printing a manifest there is no existing form. Should I be creating a new form and intercepting a print command (this would then add extra steps to what should be a single click from menu.)

Former Member
0 Kudos

If the print / print preview buttons are greyed out then that indicates that there is no ALD layout associated with that query (ie. you missed stage 3 - Create and save an ALD layout based on the query)

Go to the query manager

Highlight the query you want

Click on the 'Create Report' button

In the Select Editing Tool dialog pick 'Advanced Layout Designer'

Proceed to create and save an ALD template.

NB. Only queries which don't have prompts can be used with the ALD, make sure that any the prompts you want are in an SDK screen and written to the database table as per the instructions above.

Regards,

John.

Former Member
0 Kudos

Thanks for the Code have it working nicely now (was a bit of a newbie with the PLD though)

RamBilasYadav
Participant
0 Kudos

Hi John,

This article was very helpful. This is very close in solving my problem.

There are some doubts. Whats the meaning of the below code. Whats 402 & 401 ?

'Click on the Preview or Print button

If pVal.MenuUID = AZU_MNU_PRINT_PREVIEW Then

sboApp.Forms.ActiveForm.Items("402").Click

Else

sboApp.Forms.ActiveForm.Items("401").Click

End If

I tried this but nothing is happening. The query manager is coming and disappearing. Nothing else is happening. then I tried replacing 402 & 401 with 519 & 520 respectively but of no use. What could be the problem?

Another issue is, this method I will be using to show my own report from the PickList Window. When I trigger the report from the query manager as demonstrated by your code how should I pass the document number so that only the report for that document number is shown.

Given below is the query for which I have developed a PLD. This report generally will return all the picklist documents. But when I want it to be printed when a particular document number is open in picklist window, only that document number needs to appear in the report. How this can be handled?

<b>SELECT T0.DocEntry, T0.DocNum, T1.CardCode, T1.CardName, T0.DocDate, T0.ReqDate, T2.ShipDate, T0.CancelDate,

T1.Priority, T3.ItemCode, T3.WhsCode, T2.Dscription, T2.Quantity, T2.PickOty, T2.OpenQty, T3.OnHand / T5.NumInSale,

T2.PickStatus, T2.PickIdNo, T2.LineNum, T0.PartSupply, T2.BackOrdr, T2.ReleasQtty, T4.WhsName, T2.LineNum,T1.U_BEATDESC, T1.U_DELSEQNO

FROM [dbo].[ORDR] T0 INNER JOIN [dbo].[OCRD] T1 ON T1.CardCode = T0.CardCode INNER JOIN [dbo].[RDR1] T2 ON T2.DocEntry = T0.DocEntry

INNER JOIN [dbo].[OITW] T3 ON T2.ItemCode = T3.ItemCode AND T2.WhsCode = T3.WhsCode INNER JOIN [dbo].[OWHS] T4 ON T4.WhsCode = T2.WhsCode

INNER JOIN [dbo].[OITM] T5 ON T5.ItemCode = T2.ItemCode ORDER BY T1.U_BEATNO, T1.U_DELSEQNO DESC</b>

Thanx in advance.

With Regards,

Ram.

Former Member
0 Kudos

Hi Giuseppe

It is not possible to print it directly from the SDK. The SDK simply does not support print methods.

What you can do (If you run SBO 2005), is saving the print layout as XML from the service objects, then loading this XML into a crystal repport, a pdf document or some third kind of print handler.

The XML file contains information about where the different items is placed, and which data it shows. You manually have to read the data from SBO and putting it into your custom repport.

Hope it helps

-Thomas

Former Member
0 Kudos

Thank you Thomas

Giuseppe

Former Member
0 Kudos

Hi!

And about the <b>standard</b> layout? Is it possible, from sdk, open e populate it with my values? Without start the print, I mean.

Thanks.

Giuseppe

Former Member
0 Kudos

Hi again.

As far as I know ... no. It is not possible to get the layout with values.

If you find a way, I would very much like to know how :]

- Thomas

Former Member
0 Kudos

OK! Thank you again!

Giuseppe