Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Cannot amend the field value in class object.

Former Member
0 Likes
462

Dear Guru,

My program should able to validate the textfield

P_SCAN

. After the validation, it should clear the field.

I have created a interface and class. However, I cannot clear the field and a error message "The field 'P_SCAN' cannot be changed" keep on prompting when I try to activate it.

Anyone has any idea what is not right here and why I cannot change field value?


method ZIF_TESTWONG8~CHECK_2D.
*The '#' between 'A' and 'B' is the identifier for 2D label
    SEARCH P_SCAN FOR 'A#B'.
    IF sy-subrc = 0.
      MESSAGE e208(00) WITH 'This is 2D label.'.
      CLEAR: P_SCAN.
    ENDIF.
endmethod.

THanks in advance.

1 ACCEPTED SOLUTION
Read only

former_member480923
Active Contributor
0 Likes
441

Check this piece of code:



*&---------------------------------------------------------------------*
*& Report  ZTEST_READ_CLUSTER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztest_read_cluster.

PARAMETERS: p_scan TYPE string.
** CLASS
CLASS: cl_verification DEFINITION DEFERRED.

DATA: gcl_verify TYPE REF TO cl_verification.

*----------------------------------------------------------------------*
*       CLASS cl_verification  DEFINITIOAN
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_verification DEFINITION.

  PUBLIC SECTION.

    METHODS: lcm_check CHANGING p_scan TYPE string.


ENDCLASS.                    "cl_verification DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_verfication IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_verification IMPLEMENTATION.

  METHOD: lcm_check.

    PERFORM sub_check CHANGING p_scan.


  ENDMETHOD.                    "lcm_check

ENDCLASS.                    "cl_verfication IMPLEMENTATION
*&---------------------------------------------------------------------*
*&      Form  SUB_CHECK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_P_CHECK  text
*----------------------------------------------------------------------*
FORM sub_check  CHANGING cw_check TYPE string.

  SEARCH p_scan FOR 'G#S'.
  IF sy-subrc = 0.
    MESSAGE w208(00) WITH 'This is 2D label. Please scan data matrix!'
.
    CLEAR: p_scan.
  ENDIF.

ENDFORM.                    " SUB_CHECK



AT SELECTION-SCREEN ON p_scan.

  CREATE OBJECT gcl_verify.

  CALL METHOD gcl_verify->lcm_check
    CHANGING
      p_scan = p_scan.

Hope That Helps

Anirban M.

Dear Guru,

My program should able to validate the textfield

P_SCAN

. After the validation, it should clear the field.

I have created a interface and class. However, I cannot clear the field and a error message "The field 'P_SCAN' cannot be changed" keep on prompting when I try to activate it.

Anyone has any idea what is not right here and why I cannot change field value?


method ZIF_TESTWONG8~CHECK_2D.
*The '#' between 'A' and 'B' is the identifier for 2D label
    SEARCH P_SCAN FOR 'A#B'.
    IF sy-subrc = 0.
      MESSAGE e208(00) WITH 'This is 2D label.'.
      CLEAR: P_SCAN.
    ENDIF.
endmethod.

THanks in advance.

2 REPLIES 2
Read only

former_member480923
Active Contributor
0 Likes
442

Check this piece of code:



*&---------------------------------------------------------------------*
*& Report  ZTEST_READ_CLUSTER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztest_read_cluster.

PARAMETERS: p_scan TYPE string.
** CLASS
CLASS: cl_verification DEFINITION DEFERRED.

DATA: gcl_verify TYPE REF TO cl_verification.

*----------------------------------------------------------------------*
*       CLASS cl_verification  DEFINITIOAN
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_verification DEFINITION.

  PUBLIC SECTION.

    METHODS: lcm_check CHANGING p_scan TYPE string.


ENDCLASS.                    "cl_verification DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_verfication IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_verification IMPLEMENTATION.

  METHOD: lcm_check.

    PERFORM sub_check CHANGING p_scan.


  ENDMETHOD.                    "lcm_check

ENDCLASS.                    "cl_verfication IMPLEMENTATION
*&---------------------------------------------------------------------*
*&      Form  SUB_CHECK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_P_CHECK  text
*----------------------------------------------------------------------*
FORM sub_check  CHANGING cw_check TYPE string.

  SEARCH p_scan FOR 'G#S'.
  IF sy-subrc = 0.
    MESSAGE w208(00) WITH 'This is 2D label. Please scan data matrix!'
.
    CLEAR: p_scan.
  ENDIF.

ENDFORM.                    " SUB_CHECK



AT SELECTION-SCREEN ON p_scan.

  CREATE OBJECT gcl_verify.

  CALL METHOD gcl_verify->lcm_check
    CHANGING
      p_scan = p_scan.

Hope That Helps

Anirban M.

Read only

Former Member
0 Likes
441

Thanks for the tips. I found that I have actually used the wrong type. I should use CHANGING instead of EXPORTING.

Appreciate it.