cancel
Showing results for 
Search instead for 
Did you mean: 

Error while executing function "ALSM_EXCEL_TO_INTERNAL_TABLE" in Netweaver Gateway Odata

Former Member
0 Kudos

Dear experts,

I am uploading the data from excel file using ALSM_EXCEL_TO_INTERNAL_TABLE function module in one of the report. The function goes well in the backend but

unfortunately, when I run the web, it throws an error: Error during import of clipboard contents,Have you guys ever met this problem? Please show me the the solution, or guide me how to fix this error.


Thanks in advance!!!!



Accepted Solutions (0)

Answers (3)

Answers (3)

sreehari_vpillai
Active Contributor
0 Kudos

Hi Zhiyu,

ALSM_EXCEL_TO_INTERNAL_TABLE will work only in foreground mode ( and only from SAPGUI ) as it is using front end services ( internally activex) . You can not use it in DPC class as no foreground execution is involved . No donuts

Sreehari

EkanshCapgemini
Active Contributor
0 Kudos

Hi,

Please explain your use case.

As per my understanding, you want to upload some excel sheet with data and data will be extracted from that sheet and processed afterwards. If this is the case, you can not use ALSM_EXCEL_TO_INTERNAL_TABLE to convert the excel into internal table because in the backend you will be getting the XSTRING of xls which can not be converted by this FM. For this scenario, CSV file will be helpful. Check this link


Regards,

Ekansh

AshwinDutt
Active Contributor
0 Kudos

Hello Cao,

Can you please explain little more about your scenario ?

You want to upload file through SAP Gateway to Back-End is it? i.e., Excel file ?

If yes then you need to correct your URL and need to pass few Headers and Token Value.

For uploading file ->

1. you need to set your Entity as Media Type and add the necessary properties.

2. implement Create_Stream method in DPC_EXT class and write logic inside it to save the media content in appropriate format.

3. Use Http POST method and send Key value in ' slug ' Header , Mime Type in the Content-Type Header and pass CSRF-Token value.

For detail info Please refer below ->

Regards,

Ashwin

Former Member
0 Kudos

Hello

          Thank you again for help me.I actually want to upload a excel/txt file through SAP Gateway to an internal table in the backend.So,I need a url to get the file. I read the two references you give to me and I can't find the FM YFILE_UPLOAD in the second reference 'How To Upload and Download Files Using SAP NW Gateway SP06'. and I really don't understand how to Redefine the "CREATE_STREAM".

Regards,

Cao

AshwinDutt
Active Contributor
0 Kudos

Hello Cao,

Redefine as below :

Select the method and click on the Icon as shown.

You will not find YFILE_UPLOAD FM as i think it is the custom FM and not a standard one.

Once you redefine you can get the Media Content value and the Mime Type from importing parameter IS_MEDIA_RESOURCE.

You need to write the logic which will take this content value and convert to an appropriate format and store it in the back-end.

OR you can use the already existing logic/FM which will store this.

Once you read the Media Content Value in Create_Stream method may be you can try converting into table as what Ekansh suggested and try saving it.

Regards,

Ashwin

Former Member
0 Kudos

HI,

          I read the blog again and write logic in the DPC.But when I test it by url it shows:

and this is my database for receive xsting value:

and this is my dpc logic:

AshwinDutt
Active Contributor
0 Kudos

Hello Cao,

You need to correct the URL and Headers.

Please refer the below for your reference which shows how you need to fire your POST operation :

slug is the Header in which you need to send the Key Value.

Same way fire your service.

Regards,

Ashwin

Former Member
0 Kudos

hello,

          Can you tell me where to set the 'csrf-token' in the gateway client? I can't find it in my system.........,thanks.

and this it my button"ADD HEADER"

AshwinDutt
Active Contributor
0 Kudos

Hello Cao,

You need not to set the CSRF Token value if you are using GW Client.

Regards,

Ashwin

Former Member
0 Kudos

hello,

          thanks for helping me so much....I have asked system administor and the url has been successed run.

but it still errors,there is no 'slug' when I add file and click 'post'.

  this is my MPC:

lo_entity_type = model->create_entity_type('File').

lo_entity_type->set_is_media( 'X' ).

lo_property = lo_entity_type->create_property( iv_property_name  = 'Mandt'

                                                iv_abap_fieldname = 'MANDT').

lo_property = lo_entity_type->create_property( iv_property_name  = 'Filename'

                                                iv_abap_fieldname = 'FILENAME').

lo_property->set_is_key( ).

lo_property = lo_entity_type->create_property( iv_property_name  = 'Sydate'

                                                iv_abap_fieldname = 'SYDATE').

lo_property = lo_entity_type->create_property( iv_property_name  = 'Sytime'

                                                iv_abap_fieldname = 'SYTIME').

lo_property = lo_entity_type->create_property( iv_property_name  = 'Value'

                                                iv_abap_fieldname = 'VALUE').

lo_property = lo_entity_type->create_property( iv_property_name  = 'Mimetype'

                                                iv_abap_fieldname = 'MIMETYPE').

lo_entity_type->bind_structure( 'Z_CL_MODEL_PROVIDER=>FILE' ).

lo_entity_type->create_entity_set( 'FILESET' ).


this is my DPC:


method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.


DATA: ls_key_tab                   TYPE /iwbep/s_mgw_name_value_pair,

        ls_excel                     TYPE ZEXCELDETAIL.

         ls_excel-mimetype = is_media_resource-mime_type.

         ls_excel-filename = iv_slug.

         ls_excel-value = is_media_resource-value.

         copy_data_to_ref( EXPORTING is_data = ls_excel

                           CHANGING  cr_data = er_entity ).

AshwinDutt
Active Contributor
0 Kudos

Hello Cao,

You need to manually add the slug parameter and send Key parameters inside that.

You need to redefine the Define method of the MPC_EXT class and add the few lines of code and set it as Media Content.

Please refer -> This should resolve the problem.

Regards,

Ashwin