我写了程序,以在SRM服务器中显示购物车(SC)详细信息。在我的程序中,我对选项进行了验证。它工作正常,但是如果我提供任何随机范围,例如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.
您应该在一个范围内进行验证,而不是针对谨慎值:
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.
应使用相同的查询来获取记录。