cancel
Showing results for 
Search instead for 
Did you mean: 

Attachment Viewer in HWC for viewing photo from Archive

Former Member
0 Kudos

Hi,

I'm using attachment viewer to get images from SAP R/3 Archive and show it on the device.

After going through few posts in SCN. I've created an RFC to export base64 xstring type data, MIME type, size, file name and employee number.

Then I created a MBO with object query to have employee number as parameter.

While using this MBO in a HWC attachment viewer I'm getting "Download attachment gets empty response" as alert message.

In the logs it is having NullPointerException. I've attached screen caps of attachment viewer properties.

Please let me know your valuable suggestions.

Thanks in advance,

Vinoth Kumar

Accepted Solutions (0)

Answers (1)

Answers (1)

midhun_vp
Active Contributor
0 Kudos

One of the binary, mimetype, or filename values is empty. Check your WorkflowClient debug trace logs, or diagnose it on the client, to determine what values are showing up on the client for those fields.

The easiest way to figure out the issue is to look into the logs in the SUP server.

D:\Sybase\UnwiredPlatform\Servers\UnwiredServer\logs\WorkflowClient

Inside the folder WorkflowClient you can find a file with a name similar to ...__OBMO_WorkflowClient_user...... Where the user is the one you are registered in the SCC.

In it the IMAGE_Binary_attribKey key have the string equivalent to the attachment in binay form. It will be very big string containing 100's of line (depending on image size).

ex:

<M><H></H><S>Expense_Details</S><A>_S75fAELZEeKGztQmKHFOAA</A><VS><V k="Expense_List_TRIPNO_attribKey" t="T">0000000074</V><V k="_old.Expense_List.TRIPNO" t="T">0000000074</V><V k="Expense_List_EMPNO_attribKey" t="T">00999101</V><V k="_old.Expense_List.EMPNO" t="T">00999101</V><V k="_surrogateKey" t="T">420038</V><V k="Expense_Attachment_FILESIZE_attribKey" t="N">463082</V><V k="Expense_Attachment_FILENAME_attribKey" t="T">certified_mail_receipt.png</V><V k="Expense_Attachment_MIMETYPE_attribKey" t="T">image/png</V><V k="Expense_Attachment_PERNR_attribKey" t="T">00999101</V><Vk="Expense_Attachment_LS_OUTPUTX_attribKey" t="T">iVBORw0KGgoAAAANSUhEUgAAAhAAAAHdCAIAAADD/NcpAAAC8WlDQ1BJQ0MgUHJvZmlsZQAAeAGFVE1oE0EY/RJbUrDopWoPKkMPRbQtiwVvFZo0LbUlhqSttSiymd00abe7y+wmavGkghfBHzx4tRYvKqIHrTcVQVA0h1q9FFEUBEUoFHqpJb7ZpNmk/k3Y3bffvO9775vJLFH9oGrbRpAROdwUib4wGz06xkLzFKIAeUPljt0djw/KF8ktRavvK+9K3Pl2Od/1NDRz+1H03tePx/etTnQdqGb+AW8WECQKNGCuabyEd0qcKmFF4pOu7YLTIzHPqBrwKHCbGEpEgM8DbxmvwqkqrOkOJ6pbBMfitkCduuvA3ZrDp5B7jWhTUPaMGIY7QHRwF2Kv/NiYQ3TnFtGOVj+2p5lo2xGiuU4/

.........

Check whether you are getting the data in the logs or not.

If you are getting that there are binary to image converters in the internet. Provide the string from logs as an input in the converter and check whether you can see the image that you are passing from SAP.

- Midhun VP



Former Member
0 Kudos

Hi Midhun,

Here is my logs :

20130913T095228.660|3|Attachment:1 -- loading meta data from: C:\Sybase\UnwiredPlatform\Servers\MessagingServer\Bin\Mobile Workflow\64_1\workflowclient.xml

20130913T095228.662|3|Attachment:1 -- loading meta data for screen: Start and action: _mAsmEBuoEeOfQv_ppu0Mbw

20130913T095228.662|3|Attachment:1 -- executing operation 'findByParameter' of type 'search' on mbo 'IMAGE' in package 'Attachment:1.0'

20130913T095228.662|3|Attachment:1 -- using username and password value from server context variables

20130913T095228.663|3|Attachment:1 -- username: supAdmin

20130913T095228.663|3|Attachment:1 -- password: [xxxxxxxx]

20130913T095229.070|1|Attachment:1 -- Request failed

20130913T095229.070|1|Attachment:1 -- Request: <M><H></H><S>Start</S><A>_mAsmEBuoEeOfQv_ppu0Mbw</A><VS><V k="Number" t="T">1234567890</V></VS></M>

20130913T095229.071|1|Attachment:1 -- ResponseHeader: {"id":"f0d1fd74557c4eea8304c70b96088b0b","cid":"5#Attachment:1","pv":"3","sig":"3506f29045de42f4b6108c8c9bd84011","loginFailed":false,"method":"searchFailed","log":"[{\"_op\":\"N\",\"level\":\"ERROR\",\"code\":500,\"eisCode\":\"\",\"message\":\"java.lang.NullPointerException:null\",\"component\":\"IMAGE\",\"entityKey\":null,\"operation\":\"search\",\"requestId\":\"f0d1fd74557c4eea8304c70b96088b0b\",\"timestamp\":\"2013-09-13 06:52:29.004\",\"cvpOperationLobsLength\":0,\"messageId\":100001,\"_rc\":0}]","mbo":"IMAGE","app":"Attachment:1","pkg":"attachment:1.0"}

I'm not sure why I'm getting empty response from server, I even changed my RFC to return data without inputs, but it worked well in the MBO preview.

Is there anything I'm missing out here.

midhun_vp
Active Contributor
0 Kudos

The request from the device is failing. Make sure the query findByParameter is working. Is this a custom query ?

Keep an external break point in the RFC (login with same device user) and debug and check where the error occurs/whether RFC is triggering.

- Midhun VP

Former Member
0 Kudos

Hi Midhun,

Yes, It is a custom query. Even I tried with the PrimaryKey Query which is automatically generated

but it was same result. And with the external break point the RFC is triggering & I debugged it didn't had any error in it.

After changing the debug trace level to 5 I'm getting the below log :

20130913T172828.944|3|Attachment:1 -- loading meta data from: C:\Sybase\UnwiredPlatform\Servers\MessagingServer\Bin\Mobile Workflow\67_1\workflowclient.xml

20130913T172829.012|3|Attachment:1 -- loading meta data for screen: Start and action: _QlSzYBx3EeOfQv_ppu0Mbw

20130913T172829.020|3|Attachment:1 -- executing operation 'findByPrimaryKey' of type 'search' on mbo 'IMAGE' in package 'Attachment:1.0'

20130913T172829.031|3|Attachment:1 -- using username and password value from server context variables

20130913T172829.031|3|Attachment:1 -- username: supAdmin

20130913T172829.032|3|Attachment:1 -- password: [xxxxxxxx]

20130913T172859.388|1|Attachment:1 -- SupMessageChannel.Execute->Exception: com.sybase.djc.transaction.TransactionRolledbackSystemException: com.sybase.sup.server.msgchannel.internal.MessageChannelInternal.dispatch(com.sybase.sup.server.msgchannel.internal.InternalContext, com.sybase.sup.server.msgchannel.internal.Request, com.sybase.sup.server.msgchannel.internal.Response)

20130913T172859.393|1|System.ArgumentNullException: Array cannot be null.

20130913T172859.393|1|Parameter name: bytes

20130913T172859.393|1|   at System.Text.Encoding.GetString(Byte[] bytes)

20130913T172859.393|1|   at Sybase.UnwiredPlatform.WorkflowClient.Utils.CallMMSViaMessageChannel(String sUserName, Workflow oWorkflow, ContextData oContextData, XmlWorkflowMessage oxmlMessage, JsonObject ojsonHeaders, JsonObject ojsonContent, Boolean bUsingFlowSpecificCreds, methodType oMethod)

20130913T172859.393|1|   at Sybase.UnwiredPlatform.WorkflowClient.Utils.ExecuteMethod(Workflow workflow, String sUser, String sPassword, String sDomain, methodType method, XmlWorkflowMessage& msg, ContextData oContextData, Boolean fromResponder, Boolean usingFlowSpecificCreds)

20130913T172859.393|1|   at Sybase.UnwiredPlatform.WorkflowClient.Utils.ExecuteRequest(ContextData oContextData, XmlWorkflowMessage& msg, methodType[] methodsToExecute, Workflow workflow, String targetScreen, String errorScreen, String errorLogs, String errorLogMessage, String errorLogMessageAsList, Boolean fromResponder, Boolean isSynchronous, String asyncRequestErrorScreen, String errorNotificationSubject, String errorNotificationFromLine, String asyncRequestErrorLogs, String asyncRequestErrorLogMessage, String asyncRequestErrorLogMessageAsList, Boolean& bSentAsyncRequestErrorNotification)

20130913T172859.393|1|   at Sybase.UnwiredPlatform.WorkflowClient.Responder.ProcessMessageFromDevice(ContextData oContextData, String sData, Boolean isSynchronous)

20130913T172859.393|1|   at Sybase.UnwiredPlatform.WorkflowClient.Responder.ProcessSyncRequest(ContextData oContextData, String sData)

Now getting little suspect on my RFC. Please see my below code :

DATA : ORG_ASSIGNMENT TYPE TABLE OF BAPIP0001B,
          PERSONAL_DATA TYPE TABLE OF BAPIP0002B,
          INTERNAL_CONTROL TYPE TABLE OF BAPIP0032B,
          COMMUNICATION TYPE TABLE OF BAPIP0105B,
          ARCHIVELINK TYPE TABLE OF BAPITOAV0 WITH HEADER LINE,
          LV_PERNR TYPE BAPIEMPLB-PERNO VALUE '90000018'.

   CALL FUNCTION 'BAPI_EMPLOYEE_GETDATA'
     EXPORTING
       EMPLOYEE_ID      = LV_PERNR
       DATE             = SY-DATUM
     TABLES
       ORG_ASSIGNMENT   = ORG_ASSIGNMENT
       PERSONAL_DATA    = PERSONAL_DATA
       INTERNAL_CONTROL = INTERNAL_CONTROL
       COMMUNICATION    = COMMUNICATION
       ARCHIVELINK      = ARCHIVELINK[].
   SORT ARCHIVELINK BY AR_DATE DESCENDING.
   READ TABLE ARCHIVELINK INDEX 1.
   DATA : lt_content_info type table of SCMS_ACINF WITH HEADER LINE,
          lt_content_txt type TABLE OF SDOKCNTASC,
          lt_content_bin type TABLE OF SDOKCNTBIN WITH HEADER LINE.
   CALL FUNCTION 'SCMS_R3DB_IMPORT'
   EXPORTING
     mandt        = sy-mandt
     crep_id      = ARCHIVELINK-archiv_id
     doc_id       = ARCHIVELINK-arc_doc_id
   TABLES
     content_info = lt_content_info
     content_txt  = lt_content_txt
     content_bin  = lt_content_bin[]
   EXCEPTIONS
     error_import = 1
     error_config = 2
     OTHERS       = 3.

   DATA :LV_INPUT TYPE STRING,
         LV_DATA TYPE STRING,
          LV_OUTPUT TYPE STRING.

   DATA : l_fs type i,
          l_fl type i,
          l_ll type i,
          lv_input_buffer type xstring,
          lv_output_buf type string.
   READ TABLE lt_content_info INDEX 1.
   l_fl = lt_content_info-first_line.
   l_ll = lt_content_info-last_line.
   l_fs = lt_content_info-comp_size.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
     EXPORTING
       input_length = l_fs
       first_line   = l_fl
       last_line    = l_ll
     IMPORTING
       buffer       = lv_input_buffer
     TABLES
       binary_tab   = lt_content_bin
     EXCEPTIONS
       failed       = 1
       OTHERS       = 2.


  CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
      EXPORTING
        input  = lv_input_buffer
      IMPORTING
        output = lv_output_buf.

  call function 'SCMS_STRING_TO_XSTRING'
     exporting
       text           = lv_output_buf 
     importing
       buffer         = binary.
* Export parameters
   mime_type = LT_CONTENT_INFO-mimetype.
   SIZE = LT_CONTENT_INFO-comp_size.
   filename = 'TEST.JPEG'.
   NUMBER = EMP_NUMBER.

Am I doing anything wrong in the RFC?

And the object query is :

midhun_vp
Active Contributor
0 Kudos

I can't comment on ABAP code since it is not my expert area. In the logs it says a null pointer exception. That means the value you are sending to SAP is empty.

What is the input of this RFC? Are you passing paramters/PKs correctly? When the RFC is triggering are you able to see the i/p coming from device? What is the result after triggering ? In the output are you able to see the binary values?

Attach a screen of MBO and its preview.

Make sure RFC is working properly. For that upload a very small image to SAP and execute the RFC and copy the base64 value and try converting it to image using web (ex: http://webcodertools.com/imagetobase64converter). Since we are using the smallest image the length of the base64 string will be small else it comes some 1000s and you cannot see this in SAP. If you are able to see the image back the RFC will work. The output of the RFC have to be as a Raw data.

- Midhun VP

Former Member
0 Kudos

I'm passing Employee number as input string(10) type and for time being I've programed RFC in such a way to result me with a valid output irrespective of input.

MBO :

Preview :

Parameter Mapping :

From the string that I'm getting on the preview and used it on web converter which is working fine the image is getting converted from the string.

And the input that are being passed to the personalization key is appearing while debugging the RFC with external break point.

Former Member
0 Kudos

Hi Midhun,

Finally I'm able to see small size images, after changing the data type from xstring to string in the RFC and re-binding the MBO,

When I keep xstring in the RFC the data type appears in MBO modeling is BIGBINARY

and if I change during modelling the "Next" button disables in the screen which doesn't allow me to complete the action. Which Data Type will be suitable for the Binary data in RFC and MBO?

midhun_vp
Active Contributor
0 Kudos

If you change the RFC datatype from Xsting to string and you are trying to change the datatype of the MBO to bigbinary it will not work.

What happens is that the string you are sending from SAP is capable to get only of small size, hence when you are passing small images it works. Even now if you try to send big image it will not work since RFC is not sending the whole string (1000s of length).

You need to keep the data type of the RFC as Xstring and MBO will automatically get the datatype equivalent to it (bigbinary).

- Midhun VP