1

I wrote program to display shopping cart (SC) details in SRM server. In my program I put validations on select -options. It's working fine but if I provide any random range for example 9990000000 to 9999999999 for sc ,all SCs between this range should display but it’s throwing error message as I kept validation on low and high value. Because of this my trainer said putting validation on select-options is not preferable. He gave me new assignment that Apart from doing validation I should restrict user to enter only valid value to input field. How can I achieve this? Please give me full code.

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.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
pari
  • 31
  • 1
  • 5
  • 3
    At least for me, "solve my training assignments for me and give me full code" is not a huge motivation... – vwegert Nov 25 '16 at 19:54
  • 1
    @ VWegert I already completed my full assignment . my program is giving all sc details properly. Validations also I kept. How to restrict user to enter only valid i/p in classical report I am not getting. I tried different ways but my program is ending up in dump. I shown my efforts to trainer. He only told me that I should achieve this he is least bother. I am doing this by myself or taking someones help.He just want solution. I asked code because I want to know where I am going wrong. My trainer also know all my efforts. – pari Nov 26 '16 at 07:53

1 Answers1

0

You should validate against a range, not against discreet values:

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.

The same query should be used for fetching records.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90