1

我编写了在 SRM 服务器中显示购物车 (SC) 详细信息的程序。在我的程序中,我对 select -options 进行了验证。它工作正常,但如果我为 sc 提供任何随机范围,例如 9990000000 到 9999999999,则应该显示此范围之间的所有 SC,但它会抛出错误消息,因为我保持对低值和高值进行验证。因此,我的教练说对选择选项进行验证是不可取的。他给了我新的任务,除了进行验证之外,我还应该限制用户只在输入字段中输入有效值。我怎样才能做到这一点?请给我完整的代码。

DATA : lv_shc TYPE crmd_orderadm_h-object_id .
*DATA : lv_shc TYPE z_obj_id.

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-111.
*SELECT-OPTIONS : s_shc FOR crmd_orderadm_h-object_id VALUE-REQUEST.
SELECT-OPTIONS : s_shc FOR lv_shc .
SELECTION-SCREEN END OF BLOCK a1.

INCLUDE zsrmi_declarations1.

*validations.
AT SELECTION-SCREEN ON s_shc .


  IF s_shc IS NOT INITIAL.
    IF s_shc-low IS NOT INITIAL.
      SELECT SINGLE object_id FROM crmd_orderadm_h INTO lv_shc WHERE object_id = s_shc-low AND object_type = 'BUS2121'.
      IF sy-subrc <> 0.
        MESSAGE text-001 TYPE 'E'.
        EXIT.
      ENDIF.
    ENDIF.
    IF s_shc-high IS NOT INITIAL.
      SELECT SINGLE object_id FROM crmd_orderadm_h INTO lv_shc WHERE object_id = s_shc-high AND object_type = 'BUS2121'.
      IF sy-subrc <> 0.
        MESSAGE text-001 TYPE 'E'.
        EXIT.
      ENDIF.
    ENDIF.
  ENDIF.
4

1 回答 1

0

您应该针对一个范围进行验证,而不是针对谨慎的值:

AT SELECTION-SCREEN ON s_shc.

    IF s_shc[] IS NOT INITIAL.

        SELECT COUNT( * )
        FROM crmd_orderadm_h 
        WHERE object_id IN s_shc[] AND object_type = 'BUS2121'.

        IF SY-SUBRC NE 0.
            MESSAGE e000 WITH 'Enter Valid SC Number'.
            EXIT.
        ENDIF.

    ENDIF.

应该使用相同的查询来获取记录。

于 2019-10-05T19:42:01.697 回答