OData getEntity method fetches only first entity - odata

I have a service with a working getEntitySet method. The output looks like this:
But when I try to get only a single entity with /ColumnSet(1) my Output fetches only the first entity which is ColumnSet(0)
method COLUMNSET_GET_ENTITY.
data: ls_key_tab type /iwbep/s_mgw_name_value_pair,
lv_columnid type string,
ls_column type zst_column.
loop at it_key_tab into ls_key_tab.
if ls_key_tab-name = 'COLUMNID'.
lv_columnid = ls_key_tab-value.
endif.
endloop.
select single * from zst_column into ls_column where id_num = lv_columnid.
er_entity-id_num = ls_column-id_num.
er_entity-id = ls_column-id.
er_entity-posi = ls_column-posi.
er_entity-data_id = ls_column-data_id.
er_entity-headertext = ls_column-headertext.
er_entity-ui_element_typ = ls_column-ui_element_typ.
er_entity-enable = ls_column-enable.
er_entity-enable_ref = ls_column-enable_ref.
endmethod.
I dont know, why it only shows the first entity.

Your Key field is IDNUM, not COLUMNID.
loop at it_key_tab into ls_key_tab.
if ls_key_tab-name = 'IdNum'.
lv_columnid = ls_key_tab-value.
endif.
endloop.

Related

Select particular listbox value on start of Dynpro?

I have a custom dialog dynpro including an input field named DYN_MATNR as listbox for which I have included a list of particular materials as selection.
How can I set a specific material (of that list) as selected when the dialog dynpro is opened?
PBO of dialog dynpro:
data lt_values type vrm_values.
select matnr,
maktx
into table #data(lt_materials)
from makt
where matnr in #so_matnr
and spras = 'D'
order by matnr.
loop at lt_materials assigning field-symbol(<material>).
append initial line to lt_values assigning field-symbol(<value>).
<value>-key = <material>-matnr.
<value>-text = <material>-maktx.
endloop.
call function 'VRM_SET_VALUES'
exporting
id = 'DYN_MATNR'
values = lt_values
exceptions
id_illegal_name = 1
others = 2.
if sy-subrc <> 0.
" ...
endif.
This works and it shows the list of materials as listbox values. To select a particular material I have included the FM DYNP_VALUES_UPDATE afterwards and also in PBO but this did not work:
data lv_stepl type syst-stepl.
call function 'DYNP_GET_STEPL'
importing
povstepl = lv_stepl
exceptions
stepl_not_found = 1
others = 2.
if sy-subrc <> 0.
" ...
endif.
data(lt_dynpfields) = value dynpread_tabtype(
( fieldname = 'DYN_MATNR'
stepl = lv_stepl
fieldvalue = gcl_helper->get_matnr( ) " matnr which should be selected is stored here
fieldinp = space )
).
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-repid
dynumb = sy-dynnr
tables
dynpfields = lt_dynpfields
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
others = 8.
if sy-subrc <> 0.
" ...
endif.
I am also not able to directly set DYN_MATNR as it is not available in PBO.
Any hints?
Got it:
You need to additionally define a global(!) variable with the name and (wished) type of the input field (e.g. in the top include of the report or in a separate include of the dynpro logic):
data dyn_matnr type matnr.
Then you can set the initial value of the dynpro field in PBO directly:
dyn_matnr = gcl_helper->get_matnr( ).
As this becomes rather irritating when using various dialog dynpros I recommend including the dynpro number in those variables and input fields.

Calling expand entity from SAP Gateway Client

I try to call a GET_EXPANDED_ENTITYSET method of SRA020_PO_TRACKING Project, po tracking project. The following is the method:
METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.
DATA: lv_ponumber TYPE bapiekko-po_number,
lv_leading_msg TYPE boolean.
DATA: lo_api TYPE REF TO cl_sra020_po_tracking_api.
DATA: ls_po_details TYPE cl_sra020_po_tracking_api=>ts_podetails,
lt_return TYPE bapirettab,
lo_msgcontainer TYPE REF TO /iwbep/if_message_container.
DATA: lt_poitem_details TYPE cl_sra020_po_tracking_api=>tt_poitemdetail.
FIELD-SYMBOLS: <fs_return> TYPE bapiret2,
<fs_key_tab> TYPE /iwbep/s_mgw_name_value_pair.
lo_api = cl_sra020_po_tracking_api=>get_instance( ).
*========================================================================================
* Read Entities key values within oData service URL
*========================================================================================
IF it_key_tab IS NOT INITIAL.
LOOP AT it_key_tab ASSIGNING <fs_key_tab>.
CASE <fs_key_tab>-name.
WHEN if_sra020_po_tracking_constant=>cc_po_number.
lv_ponumber = <fs_key_tab>-value.
ENDCASE.
ENDLOOP.
ENDIF.
TRY.
CASE iv_entity_set_name.
WHEN if_sra020_po_tracking_constant=>cc_podetaileddatas.
CALL METHOD lo_api->get_po_details
EXPORTING
iv_item_additional_data = 'X' "#EC NOTEXT
iv_po_number = lv_ponumber
IMPORTING
es_po_details = ls_po_details
et_return = lt_return.
IF NOT lt_return IS INITIAL.
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception.
ENDIF.
lt_poitem_details = ls_po_details-poitemdetaildatas.
no_cache( ).
* Return the expanded clauses
APPEND cl_sra020_po_tracking_mpc=>gc_poitemdocflow TO et_expanded_tech_clauses.
APPEND cl_sra020_po_tracking_mpc=>gc_accounting TO et_expanded_tech_clauses.
APPEND cl_sra020_po_tracking_mpc=>gc_pricingconditions TO et_expanded_tech_clauses.
APPEND cl_sra020_po_tracking_mpc=>gc_confirmation TO et_expanded_tech_clauses.
CALL METHOD copy_data_to_ref
EXPORTING
is_data = lt_poitem_details
CHANGING
cr_data = er_entityset.
ENDCASE.
CATCH /iwbep/cx_mgw_busi_exception.
lo_msgcontainer = me->mo_context->get_message_container( ).
LOOP AT lt_return ASSIGNING <fs_return> WHERE type EQ 'E' OR type EQ 'A'. "#EC NOTEXT
IF <fs_return>-id EQ 'SRA020'.
lv_leading_msg = abap_true.
ELSE.
lv_leading_msg = abap_false.
ENDIF.
lo_msgcontainer->add_message(
iv_msg_type = <fs_return>-type
iv_msg_id = <fs_return>-id
iv_msg_number = <fs_return>-number
iv_msg_text = <fs_return>-message
iv_msg_v1 = <fs_return>-message_v1
iv_msg_v2 = <fs_return>-message_v2
iv_msg_v3 = <fs_return>-message_v3
iv_msg_v4 = <fs_return>-message_v4
iv_is_leading_message = lv_leading_msg
).
ENDLOOP.
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
textid = /iwbep/cx_mgw_busi_exception=>business_error
message_container = lo_msgcontainer.
ENDTRY.
ENDMETHOD.
Where
if_sra020_po_tracking_constant=>cc_po_number = PONumber
if_sra020_po_tracking_constant=>cc_podetaileddatas = PODetailedDatas
and PODetailedData entity has navigation properties of POItemDetailDatas,POItems,and POList
I try to call the method from Gateway Service Client by executing
/sap/opu/odata/SAP/SRA020_PO_TRACKING_SRV/PODetailedDatas?$expand=POItemDetailDatas,POItems,POList
However I got status code 400 Bad Request instead. What did I miss?
regards
Edit:
The message in the Bad Request says: Error while reading Purchase Order
edit 2:
association screen shot:
navigation screen shot:
Turns out I have to provide PONumber, so that:
PODetailedDatas(PONumber='4500000039')?$expand=POItems
works fine

IfcOpenShell(Parse)_IFC PropertySet, printing issue

Hy, I am new to programming and I have problems with printing my property sets and values.
I have more elements in my IFC and want to Parse all Property Sets and values.
My current result is elements ID(for every element), but it takes the attributes(property sets and values) form the first one.
Sketch:
see image
My code:
import ifcopenshell
ifc_file = ifcopenshell.open('D:\PZI_9-1_1441_LIN_CES_1-17c-O_M-M3.ifc')
products = ifc_file.by_type('IFCPROPERTYSET')
for product in products:
print(product.is_a())
print(product) # Prints
Category_Name_1 = ifc_file.by_type('IFCBUILDINGELEMENTPROXY')[0]
for definition in Category_Name_1.IsDefinedBy:
property_set = definition.RelatingPropertyDefinition
headders_list = []
data_list = []
max_len = 0
for property in property_set.HasProperties:
if property.is_a('IfcPropertySingleValue'):
headers = (property.Name)
data= (property.NominalValue.wrappedValue)
#print(headders)
headders_list.append(headers)
if len(headers) > max_len: max_len = len(headers)
#print(data)
data_list.append(data)
if len(data) > max_len: max_len = len(data)
headders_list = [headers.ljust(max_len) for headers in headders_list]
data_list = [data.ljust(max_len) for data in data_list]
print(" ".join(headders_list))
print(" ".join(data_list))
Has somebody a solution?
Thanks and kind regards,
On line:
Category_Name_1 = ifc_file.by_type('IFCBUILDINGELEMENTPROXY')[0]
it seems that you are referring always to the first IfcBuildingElementProxy object (because of the 0-index). The index should be incremented for each product, I guess.

Creating method in ABAP OData service

I am currently working on an OData service for a SAP Fiori application.
When I try to code the BAPI for inserting notifications into database, it doesn't work & I don't know why. My colleague told me it's because of the missing mandatory parameters but I filled them as well and no result.
Here's the code :
METHOD avisset_create_entity.
DATA: ls_data TYPE zcl_zpm_avis_mpc=>ts_avis.
DATA: l_notif TYPE bapi2080_nothdre-notif_no,
l_notif_type TYPE bapi2080-notif_type,
l_notif_hd_exp TYPE bapi2080_nothdre,
l_notif_header TYPE bapi2080_nothdri,
i_return TYPE TABLE OF bapiret2.
io_data_provider->read_entry_data( IMPORTING es_data = ls_data ).
IF ls_data IS NOT INITIAL.
l_notif_type = 'S3'.
l_notif_header-equipment = ls_data-equnr.
l_notif_header-reportedby = sy-uname.
l_notif_header-short_text = ls_data-qmtxt.
* l_notif_header-notif_date = ls_data-qmdat.
l_notif_header-CODE_GROUP = 'MAINDIAG'.
l_notif_header-CODING = 'desi'.
* l_notif_header-CODING = ls_data-IWERK.
* FUNCT_LOC
CALL FUNCTION 'BAPI_ALM_NOTIF_CREATE'
EXPORTING
* EXTERNAL_NUMBER =
notif_type = l_notif_type
notifheader = l_notif_header
* SENDER =
* ORDERID =
IMPORTING
notifheader_export = l_notif_hd_exp
TABLES
* notitem = i_notitemi
* notifcaus = i_notcausi
* notifactv = i_notactvi
* notiftask = i_nottaski
* notifpartnr = i_notpartnri
* longtexts = i_notfulltxti
* key_relationships = i_notkeye
return = i_return.
l_notif = l_notif_hd_exp-notif_no.
CALL FUNCTION 'BAPI_ALM_NOTIF_SAVE'
EXPORTING
number = l_notif.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDMETHOD.

Why JAX-WS generates wrapper for all method arguments?

I am trying to generate web service interface using jax-ws, but i am getting a methods with wrapper class for all arguments instead of arguments list. For example:
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
#WebResult(name = "ResendControlsToDmiResponse", targetNamespace = "http://tempuri.org/", partName = "parameters")
#WebMethod(operationName = "ResendControlsToDmi", action = "http://tempuri.org/ResendControlsToDmi")
#Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "2014-01-30T16:01:26.266+02:00")
public ResendControlsToDmiResponse resendControlsToDmi(
#WebParam(partName = "parameters", name = "ResendControlsToDmiData", targetNamespace = "http://tempuri.org/")
ResendControlsToDmiData parameters
);
Can't understand why it's happening and how to generate method with corredct signature.
There rules about the naming of the part elements as they related to the operation name. In your case, it looks like the operation is named resendControlsToDmi, but the incoming data part/element is named ResendControlsToDmiData. Remove the Data off the end of that and it may change. The response element is properly ResendControlsToDmiResponse.

Resources