cancel
Showing results for 
Search instead for 
Did you mean: 

Passing 2 parameters into Crystal Report from marketing document

Former Member
0 Kudos

Dear Gurus,

I am now working to design sales invoice, delivery note, return those related document in crystal report.

As I found that most of them are similar, and would like to find out can I use 1 crystal to fulfill all the documents.

Based on my understanding, print a form would only pass out a single parameter DocKey from SAP b1.

Can I add one more parameter that indicate the form is printed from sales order e.g. SO to the crystal report? As I would like to like where is the printing action comes from.

Or can I add a default parameter that will automatic pass to crystal report to perform the same behavior?

P.S. may not consider any add-on module to handle the problem but would like to have the idea

Many thanks.

Best Regards

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor

Hi Daniel,
Have you ever tried creating 1 crystal report, Add a table let's say OINV, show the DocNum and CardCode.
Import it into Invoice Layout. run the report, as expected, you will get the OINV DocNum and CardCode on the report.

Next, the same crystal report, Load it into Sales Order Layout, or even, Purchase Invoice layout.
Now run the report. You will notice that SAP will handle it for you. The report will give you the Data from ORDR or OPCH.

Regards
Edy

Former Member
0 Kudos

Hi Edy,

Sorry I can really get it.

Does the report using the same stored procedure to get the DocNum and CardCode?

If so, how should be the store procedure distinguish extracting from which table say OINV or ORDR?

Regards,

Daniel

edy_simon
Active Contributor

Hi Daniel,
SAP knows which standard table belongs to Documents, in runtime, ALL DOCUMENTS table will be replaced by the scope of the printing, ie when printing invoices, ALL DOCUMENT tables will be replaced by the 'INV' tables.
However, there are 2 catch here :

  1. If you use SP, the runtime can not detect, and will leave the SP intact. Thus, you need to handle the branching in the SP yourself. ie. This will work if you design your report using the Tables as the main source.
  2. If you are printing Invoice based on another document, ie Invoice based on Order, and you need to show information from ORDR table, you can not include the ORDR table in the CR as the runtime will replace this 'ORDR' to 'OINV' table (Because ORDR is a document table, and the scope of the report is an Invoice). In order to achieve this you need to include a VIEW from ORDR table.

Lastly, there are other parameters passed into the CR during runtime.ie.

  • 'ObjectId@' for the object Type
  • printbyusername@ for the current user name
  • UserCode@ for the current user code (Only available when you import your CR as layout.

There might be other parameters not included here.

Regards
Edy

    Answers (4)

    Answers (4)

    former_member244307
    Participant
    0 Kudos

    I think Crystal report itself can't give you the ability to switch tables during the runtime, but we can use store procedure to achieve it. Basically the SP will act as a Data Access Layer between DB and Crystal Report layout.


    Lan

    edy_simon
    Active Contributor
    0 Kudos

    Hi Lan,

    Crystal report API allows you to change the connection and tables on runtime. That is what SAP is doing.

    On the other hand, if your crystal report source is a SP then, you need to handle it yourself in the SP.


    Regards
    Edy

    julie_jamieson2
    Active Contributor
    0 Kudos

    Hi Daniel,

    If you use one of the SAP sample reports as your base, the SAP stored procedure will already be in there and will fulfill these requirements. The SAP sample reports can be downloaded from the documentation area if you do not already have them in your database

    kothandaraman_nagarajan
    Active Contributor
    0 Kudos

    Here object type details and used it as parameter,

    DECLARE @sTableID NVARCHAR(4)

    IF @ObjectId@ = '23' SELECT @sTableID = 'QUT'

    IF @ObjectId@ = '17' SELECT @sTableID = 'RDR'

    IF @ObjectId@ = '22' SELECT @sTableID = 'POR'

    IF @ObjectId@ = '13' SELECT @sTableID = 'INV'

    IF @ObjectId@ = '14' SELECT @sTableID = 'RIN'

    IF @ObjectId@ = '15' SELECT @sTableID = 'DLN'

    IF @ObjectId@ = '203' SELECT @sTableID = 'DPI'

    IF @ObjectId@ = '18' SELECT @sTableID = 'PCH'

    IF @ObjectId@ = '19' SELECT @sTableID = 'RPC'

    IF @ObjectId@ = '112'SELECT @sTableID = 'DRF'

    Former Member
    0 Kudos

    How about in crystal report?

    And can you give me an example say getting the BP code and Inv no. in stored procedure and in crystal report?

    Regards

    Daniel

    kothandaraman_nagarajan
    Active Contributor
    0 Kudos

    Hi,

    Find below answers to your question:-

    can I use 1 crystal to fulfill all the documents?

    Yes, you can use one crystal layout for all sales documents by creating single stored procedure. In this stored procedure, you have to add object type each document. Dockey should be docentry of the document.

    Regards,

    Nagarajan

    Former Member
    0 Kudos

    Hi,

    Could you please give me details of the object type?

    Should I use it as an parameter? Or something else?

    Regards,

    Daniel