cancel
Showing results for 
Search instead for 
Did you mean: 

Agentry Command Line File Path issue

Former Member
0 Kudos

Hi Friends

We have a requirement to Print file by using Jasper Report. To achvieve this

I followed these steps

1. Add a Edit Service order transaction to get  all the values from service order object

2. Then in Transaction update steps.we added a steplet to get values from Transaction and then write the contents to a file called as

Print.txt [ This file reside in local machine [c:\testxxx\Print.txt

3. Then call the Transmit to Service order Fetch, in this fetch operation, above transaction will run and java code will write the value in text file

4. Then call Command Line to read the contents in Print.txt and then call Jasper Report

[ This sequence works fine in Local SMP Server ]

After deployed application to Remote Machine [central server], Applcation is correctly writing the values in Print.txt file in Remote machine, but when Application call command line, it is reading the contents in Print.txt in local not in Remote machine.

How to set Agentry command line will look only Remote machine Path. for example currently i set c:\testxxx\Print.txt

Accepted Solutions (0)

Answers (2)

Answers (2)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Vignesh,

I think you will need to modify your approach depending on what your intent is

1) Printing and generation of the report will occur on the client machine only.  This means it could run offline.

2) Client will transmit to the server where the report will be generated and returned to the client for viewing / printing

3) Client will transmit to the server where the report will be generated and printed

Which of these scenarios fits your requirements?  That will determine what your steps need to be and we can provide more suggestions.

--Bill

Former Member
0 Kudos

Thanks Bill,

I have few doubts

1) Printing and generation of the report will occur on the client machine only.  This means it could run offline.

In my approach, i added a Edit Transaction of Service order, in Update steps added a step-let [java code] which will get all values from Service order object like below

String RequestedStart=_user.getString("transaction.RequestedStart");

after getting this values, i am writing the values as multi map and store in a file called as Print.txt

[ here how do we instruct step let to write in Client machine, since the application runs from server ?]

After this transaction, i added a transmit and then Command line object. This command line object will read the file and pass value to jasper report for printing

I dont want to change entire design since we are in end phase, is there any other alternative way to Read/write should happen in Client machine ?

I attached the screenshots for reference.

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

Vignesh,

"In my approach, i added a Edit Transaction of Service order, in Update steps added a step-let [java code] which will get all values from Service order object like below

String RequestedStart=_user.getString("transaction.RequestedStart");

after getting this values, i am writing the values as multi map and store in a file called as Print.txt

[ here how do we instruct step let to write in Client machine, since the application runs from server ?]"

The short answer is you don't.  The transaction update setps do not run on the client device.  They run on the SMP server and as such have no knowledge of or access to the client device file system.  The transaction cannot write to a client file system.

"After this transaction, i added a transmit and then Command line object. This command line object will read the file and pass value to jasper report for printing

I dont want to change entire design since we are in end phase, is there any other alternative way to Read/write should happen in Client machine ?"

This is why I was asking what scenario you are trying to achieve.  If you want to run this on the client you will need to make some changes in your design.  Since you mention command steps I am assuming you are using a WPF client.

It is possible to create the Print.txt file locally on the client but I would recommend against using transaction update steps for it.

There are some options here but in essentially you need to do the following.

  1. Create a temporary print_output String property on the Main Object to hold your file contents while you build it.
  2. Have a transaction to reset the print_output to an empty string
  3. Use local transactions (no update steps) to edit and populate your print_output property.
  4. In your Windows Command step map the print_output property to a text file
  5. You command step will still call your print generation / output program passing in the Print.txt file created in step 3.

--Bill

Former Member
0 Kudos

Thanks Bill Froelich

Yes am using WPF client 7.05 version

I need to get custom object values [ Service order ] to pass to Jasper Report for Printing

I am not able to understand from below points, Can you please guide me

1. I have created a Print_output string in MAin Object. What is local transaction, how we can edit and populate the values to print_output string propert ?

My question how to get values without using Transaction update step ?

Can you please tell me the steps ?

[

It is possible to create the Print.txt file locally on the client but I would recommend against using transaction update steps for it.

There are some options here but in essentially you need to do the following.

  1. Create a temporary print_output String property on the Main Object to hold your file contents while you build it.
  2. Have a transaction to reset the print_output to an empty string
  3. Use local transactions (no update steps) to edit and populate your print_output property.
  4. In your Windows Command step map the print_output property to a text file
  5. You command step will still call your print generation / output program passing in the Print.txt file created in step 3.

]

former_member208808
Active Participant
0 Kudos

Hi Vignesh,

1) Action is executed on client side so it will always see local machine for resources.

Client------------------------->Server  

                 |                                   }Here server and client are on same machine

         Repository(HDD)

Client------------------------->Server  

    |                                   |            }Here server and client are different machine

Repo.(HDD)               Repo.(HDD)

2) Reports usually are printed on client side but in your case it seems to happen on server side.

So in command line give a path for that server using IP of that server and then its directory path.use a shared folder in server machine where you can keep a file after transmit and use same share folder path in command line when printing.

3) Or in your transaction processing (Steplet,Stephandler etc) when writing to file is done use java code to print same file.

Regards,

AK

Former Member
0 Kudos

Thanks AK K,

I already tried this approach

3. Or in your transaction processing (Steplet,Stephandler etc) when writing to file is done use java code to print same file.


I already tis approach by call the Report from Steplet itself. But  it is throwing javax.awt.headless exception, so that only we are writing the data in file and then read the file and pass it to jasper report


Now i am trying to pass Server url in Command line file path. I have attached the screenshot for reference.

Former Member
0 Kudos

Hi AK K,

I have one more query, If i pass Server url in command line like below

java -Dfile.encoding=UTF-8 -jar "\\xx.xx.xx.xx\\C:\\TestPrint\\OnlineJasperReport.jar"


It will work in One Server, But what about other Servers[ for example if we have two servers Prod1 and Prod2 )


Is it possible to call jasper from Steplet itself, but am getting javax.awx.Headless exception.


How to instruct steplet to write the file in Client side ?, Here Client is lot of users are testing from there machine.



former_member208808
Active Participant
0 Kudos

Hi,

Instead of jasper i am suggesting to call command line print from there or use shell script depending upon your os.

You can use following in your java code when writing to file is finished.

On windows os :

Runtime rt = Runtime.getRuntime();

rt.exec(new String[]{"E:\\PrintJob.bat","/c","start"});

"PrintJob.bat" ->batch file content look like following

print E:\\TestPrint.pdf

On Unix os:

write a shell script to print a file

and use same to execute that shell.

%lpr -h TestPrint

where TestPrint if file to print

Regards,

AK

Former Member
0 Kudos

Thanks AK K

I tried as per mentioned like below

Runtime.getRuntime().exec("cmd /c start C:\\TestPrint\\test.bat");

test.bat :

java -Dfile.encoding=UTF-8 -jar "C:\\TestPrint\\OnlineJasperReport.jar"


when i run standalone java program, it works fine.

But when calling this in Steplet, jar is not executing. Do you have any idea ?

Steplet - get values from Transaction and write in File,

test.bat - it execute jar, that jar will read file and pass values to jasper report for printing.

for(int i=0;i<size;i++)

  {

  String prefix="transaction.ZFieldServiceForm.";

  String Date=_user.getString(prefix+i+".Date");

  log.info("Date is"+Date);

  multiMap.put("Date", Date);

  }

  log.info("Parameter values are"+multiMap);

  File file = new File("C:\\TestPrint\\Print.txt");

  file.setExecutable(true);

  file.setReadable(true);

  file.setWritable(true);

  PrintWriter pw = new PrintWriter(file,"UTF-8");

  pw.println(multiMap);

  pw.close();

  try {

  Runtime.getRuntime().exec("cmd /c start C:\\TestPrint\\test.bat");

  } catch (IOException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  return true;

Former Member
0 Kudos

see the screenshot [ standalone program to execute batch file ]

former_member208808
Active Participant
0 Kudos

Hi Vignesh,

You said jar is not executing,

so what is happening in steplet.

Is that throwing some exception while executing this ?

Also make sure file is available before you execute bat command.

For testing this write data to your normal file "Print.txt" but while printing use different file which is already available.Like "C:\\TestPrint\\Temptest.txt"


If this gets succeeded then it has to be handled by using threading where second thread will wait till first thread has written its all content to a file.

Regards,

AK

Former Member
0 Kudos

Thanks AK K

I checked the logs and found that Jar is executing and Reports.pdf file is updated with current service order values. but jasper viewer is not opening. [ am currently analyzing why it is not running ]


JRMapCollectionDataSource ds=new JRMapCollectionDataSource(maincol);

JasperPrint jasperPrint=JasperFillManager.fillReport(jasperReport,new HashMap<String, Object>(),ds);
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\TestPrint\\Reports.pdf");

JasperViewer.viewReport(jasperPrint);

I think JasperViewer is an external program, so it should not run from Transaction steplet, [ But this jar works perfectly in Command line, But command line will always look out Client machine ]