To use RFC /SCWM/HU_WEIGHT_FROM_SCALE from your own ABAP’s, firstly create a scale in transaction /SCWM/SCALE.
*&---------------------------------------------------------------------* *& Report ZTESTSCALE *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Report ZTESTSCALE * *& * *&---------------------------------------------------------------------* *& Author: Pocket Programs 2013 * *& ============================= * *& Example ABAP for use with ERP-Scale see www.pocketprograms.com * *& * *& * *&---------------------------------------------------------------------* REPORT ZPP_TEST_ERPSCALE . TABLES: sscrfields. parameter: p_lgnum type /SCWM/LGNUM." default 'TEST'. parameter: p_packst type /SCWM/DE_SCALE_ID." default 'TEST'. * Declaration of sel screen buttons SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN PUSHBUTTON (30) w_button USER-COMMAND BUT1. SELECTION-SCREEN END OF LINE. parameter: p_weight(20). "MODIF ID DSP. parameter: p_unit(20) DEFAULT 'KG' lower case. "MODIF ID DSP. parameter: p_text(20) lower case."MODIF ID DSP. parameter: p_dummy1(20) lower case. "MODIF ID DSP . parameter: p_dummy2(20) lower case."MODIF ID DSP. selection-screen SKIP. parameter: p_rc(6) MODIF ID DSP. parameter: p_msg(220) lower case MODIF ID DSP. data: gs_profile type /SCWM/TWORKST. data gs_scale type /scwm/scale. data: lt_weight type table of /scwm/s_hu_scale, ls_weight type /scwm/s_hu_scale, MSG_TEXT(120) TYPE C, "Message text L_RFC_DESTINATION LIKE RFCDISPLAY-RFCDEST. data: l_weight type /SCWM/BRGEW. *================================================= initialization. * Make result fields read-only LOOP AT SCREEN. IF SCREEN-GROUP1 = 'DSP'. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. * Add displayed text string to buttons w_button = 'Get weight using ERP-Scale'. * Determine packing station profile from PC hostname perform read_workstation. p_packst = gs_profile-workstation. p_lgnum = gs_profile-lgnum. *================================================ AT SELECTION-SCREEN. * Check if button has been pressed if sscrfields-ucomm eq 'BUT1'. perform do_weighing. endif. *================================================= FORM do_weighing. perform read_profile using p_lgnum p_packst. * rfc-destination aus Customizing: l_rfc_destination = gs_scale-SCALE_RFC. ls_weight-scale_name = gs_scale-SCALE. if l_rfc_destination is initial. clear: p_weight, p_unit, p_text, p_dummy1, p_dummy2. message e203(hudialog) with l_rfc_destination. endif. * Function module must be called with at least one * entry in the table ls_weight-g_weight = p_weight. ls_weight-unit_gw = p_unit. ls_weight-text = p_text. ls_weight-scale_id = p_dummy1. ls_weight-weight_cnt = p_dummy2. refresh lt_weight. append ls_weight to lt_weight. clear: p_msg, p_rc. CALL FUNCTION '/SCWM/HU_WEIGHT_FROM_SCALE' destination l_rfc_destination TABLES ET_WEIGHT = lt_weight EXCEPTIONS "<< begin note 205878 COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT SYSTEM_FAILURE = 2 MESSAGE MSG_TEXT OTHERS = 5. p_rc = sy-subrc. if not sy-subrc is initial. p_msg = msg_text. endif. if not sy-subrc is initial. concatenate text-040 l_rfc_destination msg_text into msg_text separated by space. message s001(vl) with msg_text. clear: p_weight, p_unit, p_text, p_dummy1, p_dummy2. return. endif. clear ls_weight. read table lt_weight into ls_weight index 1. if ls_weight-g_weight is initial. message e203(hudialog) with l_rfc_destination. endif. catch system-exceptions CONVT_NO_NUMBER = 9 . p_weight = ls_weight-g_weight. endcatch. if sy-subrc = 9. message s000(zz) with ls_weight. endif. "concatenate p_weight ls_weight-g_weight into p_msg separated by space. * message s000(zz) with p_msg. p_unit = ls_weight-unit_gw. p_text = ls_weight-text. p_dummy1 = ls_weight-scale_id. p_dummy2 = ls_weight-scale_name. ENDFORM. *============================================================== at SELECTION-SCREEN OUTPUT. * Make result fields read-only LOOP AT SCREEN. IF SCREEN-GROUP1 = 'DSP'. SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. ENDLOOP. *============================================================== START-OF-SELECTION. if sy-batch ne SPACE. perform do_weighing. concatenate p_weight ls_weight-unit_gw into p_msg separated by space. message s000(zld_conv) with 'ERP-Scale' 'returned' p_msg. exit. endif. *&---------------------------------------------------------------------* *& Form READ_PROFILE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM read_workstation. statics sf_terminal(20). DATA: lt_profile TYPE TABLE OF /SCWM/TWORKST. * Get hostname from PC CALL FUNCTION 'TH_USER_INFO' IMPORTING terminal = sf_terminal. * prerequisite there is only one profile per PC SELECT * FROM /SCWM/TWORKST CLIENT SPECIFIED INTO TABLE lt_profile WHERE terminal = sf_terminal AND mandt = sy-mandt. IF NOT sy-subrc IS INITIAL. EXIT. ENDIF. READ TABLE lt_profile TRANSPORTING NO FIELDS INDEX 2. IF sy-subrc IS INITIAL. EXIT. ENDIF. READ TABLE lt_profile INTO gs_profile INDEX 1. * PERFORM set_profile. ENDFORM. "read_packstation *&---------------------------------------------------------------------* *& Form READ_PROFILE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM read_profile using p_lg p_st. DATA: lt_profile TYPE TABLE OF /SCWM/TWORKST. * prerequisite there is only one profile per PC SELECT * FROM /SCWM/TWORKST CLIENT SPECIFIED INTO TABLE lt_profile WHERE LGNUM = p_lg AND WORKSTATION = p_st AND mandt = sy-mandt. IF NOT sy-subrc IS INITIAL. EXIT. ENDIF. READ TABLE lt_profile TRANSPORTING NO FIELDS INDEX 2. IF sy-subrc IS INITIAL. EXIT. ENDIF. READ TABLE lt_profile INTO gs_profile INDEX 1. * PERFORM set_profile. * Read scale SELECT single * FROM /SCWM/SCALE CLIENT SPECIFIED INTO gs_scale WHERE scale = gs_profile-scale AND client = sy-mandt. ENDFORM. "read_profile