We use cookie to ensure that we give you best experience on our website. With further use of this website you accept the application of cookies.  mehr...  I agree  reject

Sample ABAP Code for calling the BEMACON Scales-Web-Service

The following ABAP Code demonstrates, how the BEMACON Scales-Dispatcher can be called as Web-Service via SOAP (RPC-Style)
to retrieve weight and unit from a scale.
The interface is specified in WSDL-definition http://bemacon.de/zscale/soap_scale_server.php?wsdl=1.

The Web-Service-Client-Proxy-Class zbema_co_get_weight_port_type and both structures zbema_get_weight and zbema_get_weight_response
can be generated via transaction SE80 (create Enterprise Service) using WSDL-Definition and
Web Service Creation Wizard (prefix zbema_ to avoid naming conflicts).

The calling-URL (Runtime-Feature) of the Web-Service is defined in logical Port ZP1, which can be defined using transaction LPCONFIG or SOAMANAGER.

When calling the Proxy-Method get_weight all possible system and application errors (e.g. Web-Server not reachable) are caught using exception classes.
All error messages of the BEMACON Scales-Dispatcher (e.g. no stable weight) are returned as error text in field error of structure zbema_get_weight_response. If the field is empty, the weighing process was successful. Weight and unit are stored in fields weight and unit.
If the alibi memory ( internal / external ) is used, the weighing number is stored in field id.

DATA:
  gro_exc    TYPE REF TO cx_root,
  gf_errtxt  TYPE string,
  gs_input   TYPE zbema_get_weight,
  gs_output  TYPE zbema_get_weight_response,
  gro_weight TYPE REF TO zbema_co_get_weight_port_type.

CREATE OBJECT gro_weight
  EXPORTING
    logical_port_name = 'ZP1'.

gs_input-protocol  = 'SYSTEC'.
gs_input-host      = '10.10.5.5'.
gs_input-port      = '8000'.
gs_input-scalid    = 'R1'.
gs_input-scale     = '1'.
gs_input-plug      = ' '.
gs_input-conf      = ' '.
gs_input-linefeed  = 'CL'.
gs_input-cleartara = '0'.
gs_input-tweight   = '0'.
gs_input-tunit     = 'kg'.
gs_input-alibi     = '1'.
gs_input-wtest     = '0'.

CLEAR gro_exc.
TRY.
    CALL METHOD gro_weight->get_weight
      EXPORTING
        input  = gs_input
      IMPORTING
        output = gs_output.

  CATCH cx_ai_system_fault INTO gro_exc.
  CATCH cx_ai_application_fault INTO gro_exc.
ENDTRY.

IF ( gro_exc IS INITIAL ).
  IF ( gs_output-error IS INITIAL ).
    WRITE: / gs_output-weight.
    WRITE: / gs_output-unit.
    WRITE: / gs_output-id.
    WRITE: / gs_output-data.
  ELSE.
    WRITE: / 'SCALE-Error:' , gs_output-error.
  ENDIF.
ELSE.
  gf_errtxt = gro_exc->if_message~get_text( ).
  WRITE: / 'SOAP-Error:' , gf_errtxt.
ENDIF.