on 12-23-2014 5:42 AM
Hello experts:
I want to use http method 'post' to upload file to internal table,and after I redefine 'create_stream' in my DPC and test it in Client,It shows "Invalid or no mapping to system data types found".
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_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 ).
Is anyone knows how to fix with it?
Thanks!!!!!!!
Regards,
Cao
Hi Zhiyu,
Please Cross verify the Ashwin Last reply and verify one more time MPC_EXT code you placed it correctly or not..max this error will come based on MPC coded bounded .
Let me know if you need more info on this.
Thanks,
Syam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Cao,
After you add code in MPC_EXT class of Define method,
I see that your URL is wrong now.
You are using GET method instead of POST.
You have not attached any attachment to fire the Create Stream method.
You are not specifying the entity set name in the URL.
You are not passing Key in slug parameter.
So its expected that you are bound to get errors.
Pleas check the highlighted as below :
Please check the above points.
Regards,
Ashwin
Hi Zhiyu,
To trigger CREARE_STREAM, the URL should be like:
/sap/opu/odata/sap/ZTEMP_SRV/ET_USERSSet('TEST_USER')/ET_PHOTOSSet
Where ET_PHOTOSSet is the navigation property name. The ET_USERSSet is the principal entity.
SLUG is nothing but the filename that you would like to pass it your backend system if needed.
Regards,
Aashika Agarwal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Aashika,
Thank you for help me.Can you help me cheak my MPC?I refer to & , I find something different with mine and artical's MPC. It says:
METHOD define.
super->define( ).
DATA: lo_entity TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
lo_property TYPE REF TO /iwbep/if_mgw_odata_property.
lo_entity = model->get_entity_type( iv_entity_name = 'UserPhoto' ).
IF lo_entity IS BOUND.
lo_property = lo_entity->get_property( iv_property_name = 'Mimetype' ).
lo_property->set_as_content_type( ).
ENDIF.
ENDMETHOD.
But in my MPC as it shows above,I don't know how to fix/add with my MPC.
Thanks!
Regards,
Cao
Hi Cao,
The MPC class code that you have shown above must have been auto generated while creating the project through SEGW.
We need to redefine the DEFINE method of MPC_EXT class and include the piece of code as you noticed in the blog.
Important pointers:
1. Include MIMETYPE field in principal entity.
2. The entity which hold the file content should be marked as media collection as shown in the blog referred by you in last post.
Regards,
Aashika
Hi,
Please redefine the DEFINE method in MPC_EXT Class.
The reference code can be found in
The slug value is passed as shown below:
In the HTTP header the slug is added to give file name.
Click on + sign which is right above the HTTP Request and put the value of slug in pop up that comes.
Regards,
Aashika
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.