cancel
Showing results for 
Search instead for 
Did you mean: 

Attach File to EH with BAPI_EH_ADDEVENTMSG_02 and display in TM 9.0

jmattfeld
Participant
0 Kudos

I am using function module BAPI_EH_ADDEVENTMSG_02 as web service to update event handler for freight units in TM 9.0, which is working perfectly fine.

Next step would be the attachment of images to the message (digital signature (POD) or photo of damaged goods).

According to http://help.sap.com/saphelp_em70/helpdata/en/4a/01356d540f2fe9e10000000a42189b/frameset.htm it is possible to insert base64 coded binary files.

The following sample updates an existing freight unit as expected without any error:

<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style">

   <soapenv:Header/>

   <soapenv:Body>

      <urn:EventHandlerAddEventMessages02>           

          <Trackfilebin>

            <item>

               <Evtcnt>1</Evtcnt>

               <Filename>Signature.png</Filename>

               <LineCounter>1</LineCounter>

               <Line>First part of Base64-coded image data</Line>

            <//item>

           <item>

               ...

            <//item>

            <item>

               <Evtcnt>1</Evtcnt>

               <Filename>Signature.png</Filename>

               <LineCounter>92</LineCounter>

               <Line>Last part of Base64-coded image data</Line>

            <//item>        

         </Trackfilebin>

         <Trackfileheader>

            <item>

               <Evtcnt>1</Evtcnt>

               <Filename>Signature.png</Filename>            

               <Fileclass>BIN</Fileclass>

               <Mimetype>image/png</Mimetype>

               <Numlines>92<Numlines>

            </item>

         </Trackfileheader>

         <Trackingheader>

            <item>

               <Evtcnt>1</Evtcnt>

               <Evtid>UNLOAD_END</Evtid>

               <Trxcod>FU</Trxcod>

               <Trxid>00000000004100000251</Trxid>

               <Evtdat>2013-07-27</Evtdat>

               <Evttim>14:59:00</Evttim>

            </item>

         </Trackingheader>

         <Tracklocation>

            <item>

               <Evtcnt>1</Evtcnt>

               <Locid1>SP1000</Locid1>

            </item>

         </Tracklocation>

      </urn:EventHandlerAddEventMessages02>

   </soapenv:Body>

</soapenv:Envelope>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style">

   <soapenv:Header/>

   <soapenv:Body>

     <urn:BapiServiceTransactionCommit/>

   </soapenv:Body>

</soapenv:Envelope>

But the file is not visible in the TM transportation cockpit via attached FU files. Why?

Kind regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I'm not familiar with EM 9, but I'm guessing that it is the same as the previous release.

I don't have a system in front of me, so from memory..

you need to fill the table TRACKFILEBIN and the corresponding fields LINE_COUNTER and LINE with the binary data of the png file you are trying to attach to your event update - which I do not see in your attachment.

However the limitation is that each line cannot be longer then a certain length (255 or 512 characters can't remember).

As the name indicates, you need to pass the binary data of your file to the BAPI

Hope that helps

~p

jmattfeld
Participant
0 Kudos

Hi,

thanks for your reply. You are absolutely right. Please consider the beginning of the attached xml, I already included the binary data in TRACKFILEBIN, following the guide I linked. Maximum of each line is 255 characters.

I also updated the settings mentioned here and made sure a png file upload via web ui is possible, see attached pictures.

Here I can upload attachments via web ui to specific TO or FU (Detail view in TM 9.0):

But the ones send via BAPI are not visible.

I am not sure what to specify here in /SPRO/ for files attached to specific events, is my choice correct?

Kind regards

former_member190756
Active Contributor
0 Kudos

Hello Jan,

attachments are currently only possible to be displayed in the EM Web UI but not from the TM Execution tab.

Best regards,

Steffen

jmattfeld
Participant
0 Kudos

Hi Steffen,

thanks for your answer. I am not sure which place in the EM Web UI you refer to. The only place I know is shown in the second screenshot (post above yours)

Best regards

former_member190756
Active Contributor
0 Kudos

Hi Jan,

your second screenshot shows the Attachment tab in the TM Web UI. Just saw that they have also an attachment functionality which makes it confusing.

Attachments that you send with Event Messages to EM can only be displayed with transaction /n/saptrx/em_start in your EM system(if you have a separate one, otherwise it would be your TM system). They can currently not displayed in any tab of the TM Web UI.

To enable display in the EM Web UI you have to use a special configured field described here:

http://help.sap.com/saphelp_em70/helpdata/en/4a/01356d540f2fe9e10000000a42189b/content.htm

Best regards,

Steffen

jmattfeld
Participant
0 Kudos

Thanks very much. That was actually very helpful. I followed that guide once again and finally understood how to add the corresponding fields for attachments.

I am now able to upload and view attachments via web ui:

I marked the icon which indicates an attached file at UNLOAD_END event.

When I send a new status via BAPI (xml in first post) the status is set correctly, there is no error and the marked icon above indicates the attached file. BUT, unlike after a file is uploaded via web ui, the download attachment button has no effect.

What could be the cause of that behaviour? Is there a place I can check the transmitted data (db)?

Best regards

former_member190756
Active Contributor
0 Kudos

Hello Jan,

maybe check if you have under Windows a program assigned to display XML files.

I just tried it and my XML Editor opened the file.

I used Internet Explorer 8.

The file is retrieved with function module /SAPTRX/BAPI_EH_GET_FILES.

If you set an external breakpoint there you should see if somethings is returned here.

Best regards,

Steffen

jmattfeld
Participant
0 Kudos

As I don't have the corresponding archive keys of my attached files (EH GUID is not enough) I did not figure out how to use /SAPTRX/BAPI_EH_GET_FILES.

Nevertheless it's code revealed the attached file header table. I tracked the entries of my files send via BAPI and realised I forgot to set the <Filesize> attribute.

So I marked your answer as correct, it led to the final solution. Thanks very much

former_member190756
Active Contributor
0 Kudos

I think you must provide in table REQUESTGUIDS EH_GUID and EVT_GUID. This function module is normally called when you display Event Messages in the UI. A icon indicates the that there is an attachment and after clicking on the icon EH_GUID and EVT_GUID are passed to it.

Best regards,

Steffen

Answers (0)