Dynamically update row contents via dialog screen

1.5k views Asked by At

I need some help with the following problem. I currently have one dialog screen with a field in which a user can type a number. This number corresponds with an ID field in a database table I've made (using se/11). I want to display the contents of all fields (so only one row of the table) with the corresponding ID on a second screen. The user should also be able to edit the information in the fields and, after saving, those changes should be visible in the table itself. What it comes down to is that I want to dynamically change the contents of the returned row through the dialog screen. I know I have to use a Table Control, but apart from that I'm at a loss (I'm pretty new to ABAP).

Here's the table

Screen 1 where a user can input a number that corresponds to SEQNR in the table

When pressing F8 on Screen 1, I want to go to a second screen with the information of the person with SEQNR = 1, in other words, only this row should appear:

The user should be able to edit the information in this row. When he clicks "Save", the edited information should be updated in the table itself.

So far, I only made a standard second screen in which I added a Table Control for the above table in Screen Painter. I added this control to my DIALOG_TOP:

PROGRAM TAAK1.

DATA: OK_CODE TYPE sy-ucomm,
      ls_table TYPE TABEL1,
      SEQNR_TEXTFIELD TYPE i,
      TXT_STATUS(25) TYPE c,
      it_table LIKE TABEL1 OCCURS 0 WITH HEADER LINE.

TABLES: TABEL1.

CONTROLS: TABLE_CONTROL TYPE TABLEVIEW USING SCREEN 200.

I have no code for screen 2, other than the standard PBO and PAI Modules. The code for screen 1 looks like this.

MODULE USER_COMMAND_0100 INPUT.

  CASE OK_CODE.

WHEN 'CHECKID'.
  SELECT SINGLE * FROM TABEL1 WHERE SEQNR EQ SEQNR_TEXTFIELD.
    IF sy-subrc EQ 0.
      TXT_STATUS = 'ID BESTAAT'.
    ELSE.
      TXT_STATUS = 'ID BESTAAT NIET'.
    ENDIF.
    IF TXT_STATUS = 'ID BESTAAT'.
      SELECT * FROM TABEL1 INTO ls_table WHERE SEQNR EQ SEQNR_TEXTFIELD.
      ENDSELECT.
    ENDIF.

WHEN 'EXEC'.
  CLEAR OK_CODE.
  SET SCREEN 200.
  LEAVE SCREEN.

WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
  LEAVE PROGRAM.



 ENDCASE.

ENDMODULE.

I basically check if the Seqnr exists in the table. If it does, I store the corresponding row in a local structure which I've defined in the DIALOG_TOP.

1

There are 1 answers

0
Koen Schouten On BEST ANSWER

It's probably easier and less time consuming to use an SM30 view. You can create a custom transaction to maintain the correct authorizations. Additionally you can adjust the screens (see the code of the generated function group) to your liking's.

More info here: