Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

Scan a PDF Document

Hi,


 Kindly let me know how I can scan a PDF document using Neptune and post in SAP under the documents repository as a reference.



Thanks and Regards,

Ashok Dhayalaraj


Hi


A mobile solution do not have OCR Scanner solution embedded, but you can use Camera to take pictures of the PDF and then upload to SAP as images and store in SAP Content Server.


Regards

Ole Andre 


Hi Ole-Andre,


 Yes. That's what I would exactly want. Kindly let me know how we can implement this feature in Neptune. Also, Kindly also let me know how we can use our own mime objects uploaded for icons.


Thanks and Regards,

Ashok Dhayalaraj

HI


1) The App you create must have access to Camera and File in the Bundle App in NAM

2) Use Javascript Helpers, rightclick in the javascript editor, and get Phonegap -> Device -> Camera. Includes javascript for using camera or filebrowser.

3) Bind the image data to a STRING field in a structure

4) Send data back to SAP and use SAP Content Server for storage. You can use this example coding as a basic.


   

*    Decode Base64
     call function 'SCMS_BASE64_DECODE_STR'
       exporting
         input          = gv_camera
       importing
         output         = lv_image
       exceptions
         failed         = 1
         others         = 2.

*    Make Binary
     call function 'SCMS_XSTRING_TO_BINARY'
       exporting
         buffer                = lv_image
       importing
         output_length         = lv_length
       tables
         binary_tab            = it_bin_data.


*    Upload to SAP Content Server
     lv_a_length = lv_length.
     lv_a_id     = gv_user-seqnr.
     call function 'ARCHIVOBJECT_CREATE_TABLE'
       exporting
         archiv_id                      = 'ZC'
         document_type                  = 'JPG'
         length                         = lv_a_length
         signature                      = space
       importing
         archiv_doc_id                  = lv_doc_id
       tables
         binarchivobject                = it_bin_data
       exceptions
         error_archiv                   = 1
         error_communicationtable       = 2
         error_kernel                   = 3
         others                         = 4.


     if lv_doc_id is not initial.

*       Delete old
        lv_obj_id = gv_user-seqnr.
        delete from toahr where sap_object eq 'PREL'
                            and object_id  eq lv_obj_id.

        commit work and wait.

*       Link object
        call function 'ARCHIV_CONNECTION_INSERT'
          exporting
            archiv_id                   = 'ZC'
            arc_doc_id                  = lv_doc_id
            ar_object                   = 'HRICOLFOTO'
            object_id                   = lv_obj_id
            sap_object                  = 'PREL'
          exceptions
            error_connectiontable       = 1
            others                      = 2.

     endif.

   

ABAP Code for sending data from SAP Content Server to the mobile Image data


 

* Image
  select single *
         from toahr
         into lv_toahr
         where sap_object eq 'PREL'
           and object_id  eq gv_user-seqnr.

  if sy-subrc ne 0.

  select single *
         from toahr
         into lv_toahr
         where sap_object eq 'PREL'
           and object_id  eq '999'.

  endif.

  if sy-subrc eq 0.

      lv_doc_type = lv_toahr-reserve.
      call function 'ARCHIVOBJECT_GET_TABLE'
        exporting
          archiv_id                      = lv_toahr-archiv_id
          document_type                  = lv_doc_type
          archiv_doc_id                  = lv_toahr-arc_doc_id
          signature                      = 'X'
        importing
*         LENGTH                         =
          binlength                      = lv_bin_length
        tables
          binarchivobject                = it_bin_data
        exceptions
          error_archiv                   = 1
          error_communicationtable       = 2
          error_kernel                   = 3
          others                         = 4.

      lv_length = lv_bin_length.
      call function 'SCMS_BINARY_TO_XSTRING'
        exporting
          input_length       = lv_length
        importing
          buffer             = lv_xstring
        tables
          binary_tab         = it_bin_data
        exceptions
          failed             = 1
          others             = 2.

      call function 'SCMS_BASE64_ENCODE_STR'
        exporting
          input         = lv_xstring
        importing
          output        = gv_image.

      concatenate 'data:image/jpeg;base64,'
                  gv_image
                  into gv_image.

  endif.

 




For the Icons, please use SAP Icons (fonts), but for Images objects you can use all MIME objects. Please set the Property src to the right URL. Check MIME Repository in NAD to manage MIME Objects and get the right URL.


Regards

Ole Andre 


Hi Ole-Andre,


 Thanks a lot for all your help and the code also. Regarding the icons, I do not find a icon for scan, rather mri-scan is available, which does not good. That's the reason, I was asking for the MIME objects.


Thanks and Regards,

Ashok Dhayalaraj

Hi


You can use the SAP Icon Font "bar-code". It's nice to use for the scan functionality


Regards

Ole Andre 

Hi Ole-Andre,


 Thanks a lot for your quick response.


Thanks and Regards,

Ashok Dhayalaraj

Hi Ole-Andre,


 Kindly let me know whether we can test the device capability, like the camera from the designer in SAP or the app should be imported in phone app to test the same.


Thanks and Regards,

Ashok Dhayalaraj

Hi


To test the device capability you need to install the App on the device. No good emulator available to simulate Camera etc.


In Chrome you can simulate offline + device sizes.


There is also possible to use a Chrome plugin like Ripple to test some phonegap events like geolocation, compass, touch events

https://chrome.google.com/webstore/detail/ripple-emulator-beta/geelfhphabnejjhdalkjhgipohgpdnoc


But none will be as good as testing on your own device.


Regards

Ole Andre 

Hi Ole-Andre,


 Thanks a lot for your good suggestions.


With regards,

Ashok

Hi Ole-Andre,


 I have one more small problem. When exporting to phone gap, the system takes a long time to download the package(especially in the export Openui5 Form). Kindly let me know if this is standard behaviour, or is it due to the performance of our SAP system.


With regards,

Ashok

Hi


Yes, the phonegap export will take some time, but is only needed when build the Mobile App once. No need to rebuild the App if you do changes to the content (NAD applications). One problem that might occur is the timeout of your ICF. 


Goto transaction SMICM and press on services



Then mark the service you are using, http/https and click menu service->change



Then adjust to a higher number than default 60 sec, in this case I changed to 500 seconds





Hi Ole-Andre,


 Thank you very much for the information. But, I do not get the point, that I need not rebuild the App when I change the content. Does it mean that I need not do the phone gap extract when I change it in Neptune?  I am very new to this development and that's why I am asking these questions. Hope you do not mind. Kindly advise.


Thanks and Regards,

Ashok Dhayalaraj

Hi Ashok


Neptune AppCache functionality (bundle app in NAM), will take care of all changes in the content (Application). When the Application is changed, our framework will check the application timestamp and download the new version. No need to update the mobile application by a new installation/upgrade. 


This is really great for maintaining mobile Apps. When importing the transport into the productive SAP server, all mobile users get the new version when they log on, all happens in the background on the device.


Regards

Ole Andre 



Hi Ole-Andre,


 I have downloaded the application from Neptune for Phonegap and trying to build it using Apache Cordova, since the build option given in the tutorial allows only one free app, where we can build multiple apps using the above. I am unable to buiild it successsfull and launch it in the emulator. Kindly let me know if this is possible and if so, what other additional steps I need to follow, since I am followiing the exact document to build the app for Android in the phonegap website.


Thanks and Regards,

Ashok Dhayalaraj

Login or Signup to post a comment