Showing results for 
Search instead for 
Did you mean: 

Add Table Control Check For Repeated User Input Values

0 Kudos

Hi experts! Can you please help me at my project. I have a task for containers data and was doing great till i realised I need a check in moment of save.

1. Enter edit mode as picture 1 below.

2.Add new rows and fil them with matnr , quantity and shift. the other fields will automaticly fill from program in the moment of save.

Now I need a check in table control wich when user press Save , the program will check fields of table control . If a matnr is repeated one ore more times  the program should appear a pop up to as user if want to keep the first record or the newest one. And based on user answer the program should eleminate the unwanted row .


Below is the code for Save buton function.



FORM fill_database .
  DATA:ls_inoutab  TYPE zrd_finaldt,
       ls_temptab  TYPE zrd_finaldt,
       lt_inoutab  TYPE TABLE OF zrd_finaldt,
       lt_temptab  TYPE TABLE OF zrd_finaldt,
       lv_maktx    TYPE maktx,
       lv_continue TYPE abap_bool VALUE abap_true,
       lv_matnr    TYPE matnr,
       lv_matnr2   TYPE matnr,
       lv_answ(1)  TYPE c,
       lv_count    TYPE i,
       lv_cn       TYPE zrd_cn.

  LOOP AT gt_inoutab INTO gs_inoutab .
    lv_matnr2 = gs_inoutab-matnr.
    lv_matnr = |{ gs_inoutab-matnr ALPHA = IN }|.
    SELECT SINGLE matnr FROM makt
    INTO lv_matnr
    WHERE  matnr = lv_matnr.
    IF sy-subrc <> 0.
      lv_continue = abap_false.
      MESSAGE |Insertion Failed. We can not find material with code number: { lv_matnr2 }| TYPE 'I'.

  IF lv_continue = abap_true.
    LOOP AT gt_inoutab INTO gs_inoutab.
      if gs_inoutab IS NOT INITIAL.
      lv_matnr = |{ gs_inoutab-matnr ALPHA = IN }|.
      ls_inoutab-cn = gs_screen01-cn.
      ls_inoutab-mandt = sy-mandt.
      ls_inoutab-matnr = gs_inoutab-matnr.
      ls_inoutab-shift = gs_inoutab-shift.
      ls_inoutab-quant = gs_inoutab-quant.
      ls_inoutab-del = gs_inoutab-del.
      ls_inoutab-dats = sy-datum.
      ls_inoutab-usern = sy-uname.

      SELECT SINGLE maktx FROM makt
      INTO lv_maktx
      WHERE matnr = lv_matnr
      AND spras = sy-langu.
      ls_inoutab-maktx = lv_maktx.

      APPEND ls_inoutab TO lt_inoutab.

    MODIFY zrd_finaldt FROM TABLE lt_inoutab.
    SELECT * FROM zrd_finaldt
    INTO TABLE gt_inoutab
    WHERE cn = gs_screen01-cn
    AND del = abap_false.
    MESSAGE 'Data modified successfully.' TYPE 'S'.





Accepted Solutions (0)

Answers (0)