0
votes

I'm new in ABAP. I want my code to create a selection where I can enter a number and it shows me the list of my previously created customers.

this is the code:

REPORT ZBSP_CODING.

DATA: ls_ZBSPCUSTOMERS TYPE ZBSPCUSTOMERS,
  lt_ZBSPCUSTOMERS TYPE TABLE OF ZBSPCUSTOMERS,
  lv_KUNNR TYPE KUNNR.


SELECT-OPTIONS p_KUNNR FOR lv_KUNNR NO INTERVALS.


SELECT * FROM ZBSPCUSTOMERS INTO ls_ZBSPCUSTOMERS WHERE KUNNR IN p_KUNNR.
  WRITE: / ls_ZBSPCUSTOMERS-KUNNR,
         / ls_ZBSPCUSTOMERS-NAME_FIRST, ls_ZBSPCUSTOMERS-NAME_LAST,
         / ls_ZBSPCUSTOMERS-STREET, ls_ZBSPCUSTOMERS-HOUSE_NUM1,
         / ls_ZBSPCUSTOMERS-POST_CODE1, ls_ZBSPCUSTOMERS-CITY1.
ENDSELECT.

the problem is, it won't show me any customers. What am I doing wrong?

2
Is there any data in table ZBSPCUSTOMERS? Any data with the same selection you use in your program (p_kunnr)? You can check in transaction SE16 (or SE16N). - József Szikszai
Yes I added the data before. - Sanako-yan
OK, than check if there is any conversion for field KUNNR in table ZBSPCUSTOMERS? What is the data element /domain behind this field? How the data is saved into the table? - József Szikszai

2 Answers

0
votes

There will be two cases.-

  1. Either ZBSPCUSTOMERS table doesn't contains any data.

  2. or might be data mismatch for leading 0's in data value for KUNNR field. So, Add these line-

SELECT-OPTIONS p_KUNNR FOR lv_KUNNR NO INTERVALS.

  "-------add below lines-----
 LOOP AT p_KUNNR.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = p_KUNNR-low
        IMPORTING
          output = p_KUNNR-low.
      MODIFY p_KUNNR.
    ENDLOOP.
  "-------End of addition-------------

 SELECT * FROM ZBSPCUSTOMERS INTO ls_ZBSPCUSTOMERS WHERE KUNNR IN p_KUNNR.
    WRITE: / ls_ZBSPCUSTOMERS-KUNNR,
           / ls_ZBSPCUSTOMERS-NAME_FIRST, ls_ZBSPCUSTOMERS-NAME_LAST,
           / ls_ZBSPCUSTOMERS-STREET, ls_ZBSPCUSTOMERS-HOUSE_NUM1,
           / ls_ZBSPCUSTOMERS-POST_CODE1, ls_ZBSPCUSTOMERS-CITY1.
  ENDSELECT.

CONVERSION_EXIT_ALPHA_INPUT Function module adds leading 0's in value. for ex- if DE size is 10 digit than if you enter 102, then it'll convert fron 102 to 0000000102.

0
votes

Thanks everybody it was as @divScorp mentioned it the F8 button instead of the Enter-Key