cancel
Showing results for 
Search instead for 
Did you mean: 

​how to modify and add values to template SalesReceiptPrintTemplate80MM from java?

Dear: I would like to know in what way I can add data to the print template from my Java backend, since I have data that I would like to add to the template XML.

But I do not know in what way I can from my JAVA backend fill data to those fields. I was seeing something with @ListenToExit (exitName = "BasePrintJobBuilder.mergeTemplateWithData") but I still do not see it clearly, also is for JPOS Template.

Does anyone know how to do the solution?

Thanks! Isaac

Accepted Solutions (1)

Accepted Solutions (1)

JoergAldinger
Active Contributor

Hello all,

I got it now. For future reference and other readers, this is how we managed to pull the right value into the receipt:

<xsl:value-of select="/map/entry[./string/text()='CUSTOM_VALUE']/string[2]"/>

Please do let me know if there's a better way to do this, but at least this is working.

Thanks!

Joerg.

Answers (3)

Answers (3)

Hello Joerg,

there is no difference in providing data from the Plugin to the print template. The only difference is how Apache FOP and Freemarker internally wants to have these data.

Apache FOP needs the data in XML format and Freemarker likes to have a Java Map.

For Apache FOP, SAP Customer Checkouts transforms the Java Map to XML. To see the result you can start the application with the system paramter "-DFOP=true". With this parameter the generated XML file will be saved to disk (c:/temp/root.xml).

I think this should help to see if your data is in the XML and what the path is.

Regards,
Martin

JoergAldinger
Active Contributor
0 Kudos

Hello Martin,

Thank you very much for this suggestion. We were able to verify that indeed our custom value is in the root.xml file that was generated. Now we only need to be able to figure out how to reference the new field correctly in the xsl file. Can you give us a pointer from the following screenshot? I added the XML path for reference.

Thanks in advance!

Joerg.

R_Zieschang
Contributor

Hi isaacceo ,

have a look at the comments in my blogpost https://blogs.sap.com/2018/10/22/sap-customer-checkout-plugin-development-part-ii/

In the comments I described, how to add new data that is transmitted to the print template. Hope this helps.

Regards

Robert

Already saw the answer, but would work for template xml?, look like is focus for jpos template

JoergAldinger
Active Contributor
0 Kudos

Hello rzieschang ,

Your method works perfectly for JPOS templates, but we haven't managed to do it the same way in the 80mm Windows printer templates. Is there anything else we have to take into account?

Thanks!

Joerg.