2003 Dec 18 2:29 PM
It has been a good while since I had to write a dialog program (past 4 yrs or so have been outside SAP via RFCs/BAPIs). Anyways, I am playing with a simple 1 screen dialog that uses a tableview. I have the flu right now so banging my head against the desk as I fight to resolve these simple issues is not an option. 😃 Anyways, here goes:
(1) How can I make a single selected row editbale (input='1' ?) while all others are display only?
(2) How can I reference individual cells for a selected row? I see how to reference columns, but not rows/lines.
That's it. See....simple....but not when sick and unable to think straight. haha...ughh.
CSolomon
aka.HERC
www.abapcentral.com (RIP)
www.sapwired.com (RIP)
2003 Dec 22 5:03 PM
Well, got over the flu and in the meantime, came up with my own solution.....just going to handle this problem as it is.....presentation handled on the web side where I can easily create my own tableview-esque table and make it work however I like....backend will handle fetching data and doing the actual inserts/updates as needed. Just wish I coulda figured out the SAP tableview. In the end, I just had it doing as I have seen all around.....if in update mode, all columns become editable. Oh well....back to billing.
CSolomon
aka.HERC
2004 Jan 12 3:20 PM
Hi HERC,
Try this: cut/paste the code below into a new executable program, and activate. Then you need to create screen 100, with table control tabview1, and add wa-fname, wa-lname as fields in the control (make them output only), by using add fields "from program". Make the field wa-sel_col the selection column. Only one row to be selected at a time. Finally copy the flow logic from the commented section at the bottom into your real flow logic...
The only problem is that after you select a row, you must hit enter to make that row changeable, and after you change data in the field, hit enter again to update the internal table before selecting another line. Well, that's the difficulties of dynpro programmming. Type EXIT in the command line to exit the program!
REPORT zdynpro.
CONTROLS tabview1 TYPE TABLEVIEW USING SCREEN 0100.
DATA: BEGIN OF wa,
fname(30) TYPE c,
lname(30) TYPE c,
sel_col(1) TYPE c,
END OF wa,
itab LIKE TABLE OF wa.
LOAD-OF-PROGRAM.
CLEAR wa.
wa-fname = 'Paul'.
wa-lname = 'McCartney'.
APPEND wa TO itab.
CLEAR wa.
wa-fname = 'John'.
wa-lname = 'Lennon'.
APPEND wa TO itab.
CLEAR wa.
wa-fname = 'Ringo'.
wa-lname = 'Starr'.
APPEND wa TO itab.
CLEAR wa.
wa-fname = 'George'.
wa-lname = 'Harrison'.
APPEND wa TO itab.
START-OF-SELECTION.
CALL SCREEN 100.
*&----
*
*& Module chg_screen OUTPUT
*&----
*
* text
*----
*
MODULE chg_screen OUTPUT.
READ table itab INTO wa INDEX tabview1-current_line.
IF wa-sel_col = 'X'.
LOOP AT SCREEN.
IF screen-name = 'WA-FNAME' OR
screen-name = 'WA-LNAME'.
screen-input = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDMODULE. " chg_screen OUTPUT
*&----
*
*& Module upd_table INPUT
*&----
*
* text
*----
*
MODULE upd_table INPUT.
CASE wa-sel_col.
WHEN ' '.
MODIFY itab INDEX tabview1-current_line
FROM wa TRANSPORTING sel_col.
WHEN 'X'.
MODIFY itab INDEX tabview1-current_line
FROM wa.
ENDCASE.
ENDMODULE. " upd_table INPUT
*&----
*
*& Module USER_COMMAND_0100 INPUT
*&----
*
* text
*----
*
MODULE user_command_0100 INPUT.
IF sy-ucomm = 'EXIT'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
*
*Copy this flow logic as well...
*
*PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
* LOOP AT itab INTO wa WITH CONTROL tabview1.
* MODULE chg_screen.
* ENDLOOP.
**
*PROCESS AFTER INPUT.
*
* LOOP AT itab.
*
* CHAIN.
* FIELD: wa-sel_col, wa-lname, wa-fname
* MODULE upd_table ON CHAIN-REQUEST.
* ENDCHAIN.
* ENDLOOP.
* MODULE user_command_0100.
*