Tuesday 7 May 2024

Program to create a custom screen where in field input it will check whether the number is odd or the number is even

 PROGRAM:  


REPORT ZSM_SCREEN2.

DATAnumber TYPE i.

DATAlv_number TYPE char10.

DATAlv_check TYPE char10.

DATAit_dynpfields TYPE TABLE OF dynpread,
      wa_dynpfields TYPE dynpread.

CALL SCREEN 500.

MODULE user_command_0500 INPUT.

  IF sy-ucomm 'F_CALC'.

    wa_dynpfields-fieldname 'LV_NUMBER'.
    APPEND wa_dynpfields TO it_dynpfields.

    wa_dynpfields-fieldname 'LV_CHECK'.
    APPEND wa_dynpfields TO it_dynpfields.


    CALL FUNCTION 'DYNP_VALUES_READ'
      EXPORTING
        dyname               sy-cprog
        dynumb               sy-dynnr
*       TRANSLATE_TO_UPPER   = ' '
*       REQUEST              = ' '
*       PERFORM_CONVERSION_EXITS             = ' '
*       PERFORM_INPUT_CONVERSION             = ' '
*       DETERMINE_LOOP_INDEX = ' '
*       START_SEARCH_IN_CURRENT_SCREEN       = ' '
*       START_SEARCH_IN_MAIN_SCREEN          = ' '
*       START_SEARCH_IN_STACKED_SCREEN       = ' '
*       START_SEARCH_ON_SCR_STACKPOS         = ' '
*       SEARCH_OWN_SUBSCREENS_FIRST          = ' '
*       SEARCHPATH_OF_SUBSCREEN_AREAS        = ' '
      TABLES
        dynpfields           it_dynpfields
      EXCEPTIONS
        invalid_abapworkarea 1
        invalid_dynprofield  2
        invalid_dynproname   3
        invalid_dynpronummer 4
        invalid_request      5
        no_fielddescription  6
        invalid_parameter    7
        undefind_error       8
        double_conversion    9
        stepl_not_found      10
        OTHERS               11.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

    READ TABLE it_dynpfields INTO  DATA(wa_oneWITH KEY fieldname 'LV_NUMBER'.

     IF lv_number 'X'.
      number lv_number.
    IF number MOD 0.
       lv_check 'Even'.
    ELSE.
      lv_check 'Odd'.
    ENDIF.

ENDIF.

ENDIF.

ENDMODULE.

No comments:

Post a Comment