on 02-13-2014 12:52 PM
Hi
please I need some help in order to query a weighing scale on ECC using PCo.
I did everything that the document below say to do, taking into account that my RFC System is a SAP ECC instead of EWM:
* SAP Plant Connectivity (PCo) Meets EWM SAP Plant Connectivity (PCo) Meets EWM Easy Guide for Connecting External Devices to SAP MFS Using PCo Socket Agents
After completing the instructions I did the tests and no issues here.
But this document doesn´t guide us to the complete process, it doesn´t show how to query the weighing scale in the RFC side.
How should I call the RFC that will give me the weighing scale value ?
Michel,
Please find attached the code I have used to read back values from the scale, this goes on the assumption that scale is setup correctly and that the agent instance has been setup correctly also.
You also might want to check it with a SAP_ALL profile in your dev system first because there are strange authorisation checks that happen, once you get it working you can identify the roles you need to run the scale.
*&---------------------------------------------------------------------*
**& Report ZPCO_AGENT_COMMANDS *&
**&---------------------------------------------------------------------
REPORT zpco_agent_commands.
TYPES: BEGIN OF lty_result,
func_name TYPE string,
par_name TYPE s_pco_cust_par_name,
par_value TYPE s_pco_cust_par_val,
par_dt TYPE s_pco_sql_data_type,
par_dt_c TYPE s_pco_sql_data_type_c,
tableset TYPE int4,
rowset TYPE s_pco_row_set,
col_name TYPE s_pco_db_col_name,
cell_value TYPE s_pco_value_ref,
cell_val_s TYPE string,
cell_dt TYPE s_pco_sql_data_type,
cell_dt_c TYPE s_pco_sql_data_type_c,
END OF lty_result,
lty_t_result TYPE STANDARD TABLE OF lty_result.
SELECTION-SCREEN BEGIN OF BLOCK pco WITH FRAME TITLE text-pco.
PARAMETERS:
p_rfcdes TYPE rfcdest MATCHCODE OBJECT f4_rfcdest OBLIGATORY,
p_appl TYPE s_pco_application DEFAULT 'CUST_AGENT' OBLIGATORY,
p_handle TYPE s_pco_application_handle DEFAULT 'PCO_COMMANDS' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK pco.
* Testing Options
SELECTION-SCREEN BEGIN OF BLOCK sel WITH FRAME TITLE text-sel.
PARAMETERS: p_getfun RADIOBUTTON GROUP selc DEFAULT 'X' USER-COMMAND selc,
p_getpar RADIOBUTTON GROUP selc,
p_calfun RADIOBUTTON GROUP selc.
SELECTION-SCREEN END OF BLOCK sel.
* input field for name of custom function
SELECTION-SCREEN BEGIN OF BLOCK db WITH FRAME TITLE text-fun.
PARAMETERS: p_fctnam TYPE s_pco_cust_func_name LOWER CASE.
SELECTION-SCREEN END OF BLOCK db.
*input fields for first set of parameter/name/sql data type
SELECTION-SCREEN BEGIN OF BLOCK par1 WITH FRAME TITLE text-pa1.
PARAMETERS: p_parna1 TYPE string LOWER CASE,
p_parvl1 TYPE string LOWER CASE,
p_sqldt1 TYPE s_pco_sql_data_type_c.
SELECTION-SCREEN END OF BLOCK par1.
* input fields for second set of parameter/name/sql data type
SELECTION-SCREEN BEGIN OF BLOCK par2 WITH FRAME TITLE text-pa2.
PARAMETERS: p_parna2 TYPE string LOWER CASE,
p_parvl2 TYPE string LOWER CASE,
p_sqldt2 TYPE s_pco_sql_data_type_c.
SELECTION-SCREEN END OF BLOCK par2.
* input fields for third set of parameter/name/sql data type
SELECTION-SCREEN BEGIN OF BLOCK par3 WITH FRAME TITLE text-pa3.
PARAMETERS: p_parna3 TYPE string LOWER CASE,
p_parvl3 TYPE string LOWER CASE,
p_sqldt3 TYPE s_pco_sql_data_type_c.
SELECTION-SCREEN END OF BLOCK par3.
* input fields for fourth set of parameter/name/sql data type
SELECTION-SCREEN BEGIN OF BLOCK par4 WITH FRAME TITLE text-pa4.
PARAMETERS: p_parna4 TYPE string LOWER CASE,
p_parvl4 TYPE string LOWER CASE,
p_sqldt4 TYPE s_pco_sql_data_type_c.
SELECTION-SCREEN END OF BLOCK par4.
DATA: lt_all_msg_obj TYPE pco_t_query_message_obj, "#EC NEEDED
lt_comm_result TYPE pco_t_query_result_comm_data, "#EC NEEDED
lt_fcat TYPE slis_t_fieldcat_alv, "#EC NEEDED
lt_func_names TYPE pco_t_cust_func_name, "#EC NEEDED
lt_func_para TYPE pco_t_cust_func_par, "#EC NEEDED
lt_pco_msg_obj TYPE pco_t_query_message_obj, "#EC NEEDED
lt_results TYPE lty_t_result. "#EC NEEDED
DATA: ls_appl_handle TYPE pco_s_appl_handle, "#EC NEEDED
ls_bal_msg_context TYPE bal_s_cont, "#EC NEEDED
ls_comm_result TYPE pco_s_query_result_comm_data, "#EC NEEDED
ls_fcat TYPE slis_fieldcat_alv, "#EC NEEDED
ls_func_para TYPE pco_s_cust_func_par, "#EC NEEDED
ls_layout TYPE slis_layout_alv, "#EC NEEDED
ls_result TYPE lty_result. "#EC NEEDED
DATA: lv_bal_log_handle TYPE balloghndl, "#EC needed
lv_counter TYPE i, "#EC NEEDED
lv_func_name TYPE s_pco_cust_func_name, "#EC NEEDED
lv_grid_title TYPE lvc_title, "#EC needed
lv_msg_txt TYPE string, "#EC NEEDED
lv_struct_name TYPE dd02l-tabname. "#EC NEEDED
DATA: lo_cl_tag_query TYPE REF TO cl_pco_tag_query, "#EC NEEDED
lo_pco_exc TYPE REF TO cx_pco_bs_int, "#EC NEEDED
lo_pco_pac TYPE REF TO cl_pco_pac, "#EC NEEDED
lo_pco_util TYPE REF TO cl_pco_utility, "#EC NEEDED
lo_tag_query TYPE REF TO if_pco_tag_query. "#EC NEEDED
**********************************************************************
AT SELECTION-SCREEN OUTPUT.
***********************************************************************
* Hide fields depending on selected radio button
LOOP AT SCREEN.
CASE screen-name.
WHEN 'P_FCTNAM' OR '%_P_FCTNAM_%_APP_%-TEXT'.
* hide input field for customer function name in case user
* selects option for displaying function names for connected
* customer agent
IF p_getfun = abap_false.
screen-input = '1'.
screen-invisible = '0'.
ELSE.
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
MODIFY SCREEN.
WHEN 'P_PARNA1' OR '%_P_PARNA1_%_APP_%-TEXT' OR
'P_PARVL1' OR '%_P_PARVL1_%_APP_%-TEXT' OR
'P_SQLDT1' OR '%_P_SQLDT1_%_APP_%-TEXT' OR
'P_PARNA2' OR '%_P_PARNA2_%_APP_%-TEXT' OR
'P_PARVL2' OR '%_P_PARVL2_%_APP_%-TEXT' OR
'P_SQLDT2' OR '%_P_SQLDT2_%_APP_%-TEXT' OR
'P_PARNA3' OR '%_P_PARNA3_%_APP_%-TEXT' OR
'P_PARVL3' OR '%_P_PARVL3_%_APP_%-TEXT' OR
'P_SQLDT3' OR '%_P_SQLDT3_%_APP_%-TEXT' OR
'P_PARNA4' OR '%_P_PARNA4_%_APP_%-TEXT' OR
'P_PARVL4' OR '%_P_PARVL4_%_APP_%-TEXT' OR
'P_SQLDT4' OR '%_P_SQLDT4_%_APP_%-TEXT'.
* Show/hide input field for custom function parameters
IF p_calfun = abap_true.
screen-input = '1'.
screen-invisible = '0'.
ELSE.
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
MODIFY SCREEN.
WHEN OTHERS.
CONTINUE.
ENDCASE.
ENDLOOP.
***********************************************************************
START-OF-SELECTION.
***********************************************************************
* PCo integration part
ls_appl_handle-appl = p_appl.
* Create application handle:
ls_appl_handle-handle = p_handle.
TRY.
* prepare message and exception processing
CREATE OBJECT lo_pco_util.
lo_pco_util->create_log_handle(
EXPORTING is_appl_handle = ls_appl_handle
iv_activity = lo_pco_util->gc_act_command
iv_bal_subobj = lo_pco_util->gc_bal_subobj_tag
iv_req_type = cl_pco_query=>gc_tag_req_type
IMPORTING
ev_log_handle = lv_bal_log_handle ).
lo_pco_util->create_msg_context(
EXPORTING
is_appl_handle = ls_appl_handle
iv_activity = lo_pco_util->gc_act_command
iv_req_type = cl_pco_query=>gc_tag_req_type
IMPORTING es_msg_context = ls_bal_msg_context ).
* initiate custom agent data exchange
CREATE OBJECT lo_pco_pac
EXPORTING
is_appl_handle = ls_appl_handle
iv_check_dest = abap_false
iv_load_feat = abap_false
iv_log_active = abap_true
iv_rfc_dest = p_rfcdes.
* custom agents need to implement handling of tags/ data points
lo_tag_query = lo_pco_pac->get_tag_query_obj( ).
lo_cl_tag_query ?= lo_tag_query.
IF p_getfun = abap_true.
* list custom commands of pco agent instance
lo_cl_tag_query->list_func(
IMPORTING
et_func_names = lt_func_names
et_pco_msg_obj = lt_pco_msg_obj ).
IF NOT lt_func_names[] IS INITIAL.
LOOP AT lt_func_names INTO lv_func_name.
CLEAR: ls_result. ls_result-func_name = lv_func_name.
INSERT ls_result INTO TABLE lt_results.
ENDLOOP.
lv_grid_title = text-fun.
ELSE.
lv_msg_txt = text-nor.
MESSAGE lv_msg_txt TYPE cl_pco_utility=>gc_msgty_error.
ENDIF.
ENDIF.
IF p_getpar = abap_true.
* List parameter for custom command of PCo agent instance
lo_cl_tag_query->list_para(
EXPORTING iv_func_name = p_fctnam
IMPORTING
et_func_par = lt_func_para
et_pco_msg_obj = lt_pco_msg_obj ).
IF NOT lt_func_para[] IS INITIAL.
LOOP AT lt_func_para INTO ls_func_para.
CLEAR: ls_result.
ls_result-func_name = p_fctnam.
ls_result-par_name = ls_func_para-par_name.
ls_result-par_value = ls_func_para-par_value.
ls_result-par_dt = ls_func_para-datatype.
*get domain value for sql data type of parameter
ls_result-par_dt_c = lo_pco_util->get_sql_dt_txt(
iv_sql_dt = ls_result-par_dt ).
INSERT ls_result INTO TABLE lt_results.
ENDLOOP.
lv_grid_title = text-dpa.
ENDIF.
ENDIF.
IF p_calfun = abap_true.
* call custom command of pco agent instance and display results
* first transfer parameter values
ls_func_para-par_name = p_parna1.
ls_func_para-par_value = p_parvl1.
ls_func_para-datatype = p_sqldt1.
IF NOT ls_func_para IS INITIAL.
INSERT ls_func_para INTO TABLE lt_func_para.
CLEAR ls_func_para.
ENDIF.
ls_func_para-par_name = p_parna2.
ls_func_para-par_value = p_parvl2.
ls_func_para-datatype = p_sqldt2.
CONSTANTS: lc_cr_lf TYPE abap_cr_lf VALUE cl_abap_char_utilities=>cr_lf.
* REPLACE '<CR><LF>' WITH lc_cr_lf INTO ls_func_para-par_value.
REPLACE '<CR>' WITH ' ' INTO ls_func_para-par_value.
REPLACE '<LF>' WITH ' ' INTO ls_func_para-par_value.
IF NOT ls_func_para IS INITIAL.
INSERT ls_func_para INTO TABLE lt_func_para.
CLEAR ls_func_para.
ENDIF.
ls_func_para-par_name = p_parna3.
ls_func_para-par_value = p_parvl3.
ls_func_para-datatype = p_sqldt3.
IF NOT ls_func_para IS INITIAL.
INSERT ls_func_para INTO TABLE lt_func_para.
CLEAR ls_func_para.
ENDIF.
ls_func_para-par_name = p_parna4.
ls_func_para-par_value = p_parvl4.
ls_func_para-datatype = p_sqldt4.
IF NOT ls_func_para IS INITIAL.
INSERT ls_func_para INTO TABLE lt_func_para.
CLEAR ls_func_para.
ENDIF.
IF NOT lt_func_para[] IS INITIAL AND NOT p_fctnam IS INITIAL.
lo_cl_tag_query->call_func(
EXPORTING it_func_par = lt_func_para
iv_func_name = p_fctnam
IMPORTING et_comm_result = lt_comm_result
et_pco_msg_obj = lt_all_msg_obj ).
IF NOT lt_comm_result IS INITIAL.
* transfer result information of custom command query
* execution into buffer table for alv grid
LOOP AT lt_comm_result INTO ls_comm_result.
CLEAR: ls_result.
MOVE-CORRESPONDING ls_comm_result TO ls_result.
ls_result-cell_dt = ls_comm_result-cell_datatype.
ls_result-func_name = p_fctnam.
*convert data reference value into string value so it
* can be displayed in alv grid list
TRY.
lo_pco_util->convert_dref_to_string(
EXPORTING iv_conv_float = abap_true iv_round_decimals = ''
iv_sql_data_type = ls_result-cell_dt ir_data_ref =
ls_result-cell_value IMPORTING ev_data_string = ls_result-cell_val_s )
.
CATCH cx_pco_bs_int.
ls_result-cell_val_s = text-ndc.
ENDTRY.
* getdomain value for sql data type of parameter
ls_result-cell_dt_c = lo_pco_util->get_sql_dt_txt(
iv_sql_dt = ls_result-cell_dt ).
INSERT ls_result INTO TABLE lt_results.
ENDLOOP.
lv_grid_title = text-dcr.
ENDIF.
ENDIF.
ENDIF.
CATCH cx_pco_bs_int INTO lo_pco_exc.
* error occurred
IF lo_pco_exc->previous IS BOUND.
lv_msg_txt = lo_pco_exc->previous->get_longtext( ).
MESSAGE lv_msg_txt TYPE cl_pco_utility=>gc_msgty_error.
ELSE.
lv_msg_txt = lo_pco_exc->get_longtext( ).
MESSAGE lv_msg_txt TYPE cl_pco_utility=>gc_msgty_error.
ENDIF.
ENDTRY.
* display log messages
IF NOT lt_all_msg_obj[] IS INITIAL.
lo_pco_util->add_msg_obj_to_log(
EXPORTING it_msg_obj = lt_all_msg_obj[]
is_msg_context = ls_bal_msg_context iv_log_handle =
lv_bal_log_handle ).
lo_pco_util->display_msg_obj_as_log( EXPORTING
iv_appl_log_handle = lv_bal_log_handle iv_end_col = 120 iv_end_row =
10 iv_start_row = 1 iv_start_col = 1 ).
ENDIF.
ls_layout-colwidth_optimize = abap_true.
IF NOT lt_results IS INITIAL.
lv_counter = 1.
* build field catalog
* custom command name
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'FUNC_NAME'.
ls_fcat-tabname = 'LT_RESULTS'. ls_fcat-seltext_m = text-fun. INSERT
ls_fcat INTO TABLE lt_fcat.
ADD 1 TO lv_counter. CLEAR ls_fcat.
IF
p_getpar = abap_true.
* display parameters of selected command function
* parameter name
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'PAR_NAME'. ls_fcat-tabname = 'LT_RESULTS'.
ls_fcat-seltext_m = text-pan. INSERT ls_fcat INTO TABLE lt_fcat. ADD 1
TO lv_counter.
CLEAR ls_fcat.
* parameter value
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'PAR_VALUE'. ls_fcat-tabname =
'LT_RESULTS'.
ls_fcat-seltext_m = text-pav. INSERT ls_fcat INTO TABLE
lt_fcat.
ADD 1 TO lv_counter. CLEAR ls_fcat.
* sql data type of parameter (domain value)
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'PAR_DT_C'. ls_fcat-tabname = 'LT_RESULTS'.
ls_fcat-seltext_m = text-sdt. INSERT ls_fcat INTO TABLE lt_fcat. ADD 1
TO lv_counter.
CLEAR ls_fcat.
ENDIF.
IF p_calfun = abap_true.
*display result table of executed command function
* table set
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'TABLESET'.
ls_fcat-tabname = 'LT_RESULTS'.
ls_fcat-seltext_m = text-tst. INSERT ls_fcat INTO TABLE lt_fcat. ADD
1 TO lv_counter.
CLEAR ls_fcat.
* row set
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'ROWSET'. ls_fcat-tabname =
'LT_RESULTS'.
ls_fcat-seltext_m = text-rst. INSERT ls_fcat INTO TABLE
lt_fcat.
ADD 1 TO lv_counter. CLEAR ls_fcat.
* column name
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'COL_NAME'.
ls_fcat-tabname = 'LT_RESULTS'. ls_fcat-seltext_m = text-cna. INSERT
ls_fcat INTO TABLE lt_fcat.
ADD 1 TO lv_counter. CLEAR ls_fcat.
* cell value (as string)
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname =
'CELL_VAL_S'.
ls_fcat-tabname = 'LT_RESULTS'. ls_fcat-seltext_m =
text-cva.
INSERT ls_fcat INTO TABLE lt_fcat. ADD 1 TO lv_counter.
CLEAR ls_fcat.
* sql data type of cell
ls_fcat-col_pos = lv_counter.
ls_fcat-fieldname = 'CELL_DT_C'. ls_fcat-tabname = 'LT_RESULTS'.
ls_fcat-seltext_m = text-sdt. INSERT ls_fcat INTO TABLE lt_fcat. ADD 1
TO lv_counter.
CLEAR ls_fcat.
ENDIF.
* start alv grid and display results
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = lv_struct_name
i_grid_title = lv_grid_title
it_fieldcat = lt_fcat
is_layout = ls_layout
TABLES
t_outtab = lt_results.
ELSE.
lv_msg_txt = text-nor. MESSAGE lv_msg_txt TYPE
cl_pco_utility=>gc_msgty_error.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Colm Gavin, now this program ran. But I still don´t have the results that I would like to see. Could you please help me with the Agent Instance configuration ?
We don´t have PCo custom agents here, I am using just the standard objects of PCo, taking into account that we don´t have Visual Studio, we don´t have a source repository for new code sources in .NET, I cannot use custom agents for PCo.
Instead of using custom agents for PCo we prefer to use custom action (java) in SAP MII. But we are believing that a standard agent instance with a socket source could query a weighing scale, so I am trying to use PCo.
In our scenário, just ECC will call PCo, so I don´t need Subscription Items, isn't ?
I am sending some screens with our configurations, and I will be very pleased if you or someone else could help me.
Hi,
I am not sure if you have had any success connecting your scale to SAP.
ERP-Scale from Pocket Programs supports integrating scales with EWM/SCWM. It use the standard RFC's provided by SAP and does not require PCo. Further it is SAP certified. Its unique configuration import function, means that set-up is quick and easy. Just configure the RFC destination, scale and work-center in EWM and import the settings into ERP-Scale.
Many of our customers are using it to integrate weigh scales with their EWM systems.
You can get more information here.
Contact us if you require more assistance.
Pocket Programs
unfortunately ended my time to configure the query the weighing scale with PCo, as it did not work and I have more time, I'll have to create custom actions in MII.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dambros,
Go through below link for Connecting Socket type.
And for more information, go through below threat
http://scn.sap.com/thread/3386064
Regards,
Praveen Reddy
Hi Michel,
Go through below document
on 13th page, its clearly mentioned how to retrive data from Pco to ECC system.
Once all connection successful
1. Goto Tcode SE38, provide program name "RPCO_BS_INT_TEST" and press F8
2. Provide selection screen properties and execute (F8).
hope it may fulfil your requirement.
Regards,
Praveen Reddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you Praveen Reddy.
I did exactly like this document say in page 13 and 14, but the program threw the error message: "No Read Access Implemented for Agent"
This document teach us how to test an Agent Instance that has a source system of type OPC DA.
My source system is of the Socket type, could the program RPCO_BS_INT_TEST does not work with this type of source system ?
The message "No Read Access Implemented for Agent" made me think... what is a read access for an agent ? Is it a notification ? I have already created a notification like you can see in the image below.
(The image shows all tabs of the Notification TESTE3_NOT)
I will be very pleased if you or somebody else could analyse the screen shots of this thread and say to me if there is something that I should change or create in order to make it work.
User | Count |
---|---|
11 | |
6 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.