‎2005 May 31 8:22 AM
Hi,
in dialog programming, i want to add a blank row to table control in which some fields are input enabled and some or not. the which i wrote, one row is adding in to the internal table(in debugging, i could see) but not to the table control. can a ny one say might be the probable reason here i'm attaching the code i wrote.
WHEN 'BULKGOODS'.
i_itab10-lifnr = ''.
i_itab10-name1 = ''.
i_itab10-ebeln = ''.
i_itab10-ebelp = ''.
i_itab10-matnr = ''.
i_itab10-zmmwmdesadv = ''.
i_itab10-menge = ''.
i_itab10-meins = ''.
i_itab10-vbeln = ''.
i_itab10-v_pallet = ''.
i_itab10-sobkz = ''.
i_itab10-lfsnr = ''.
i_itab10-lsmng = ''.
i_itab10-nltyp = ''.
i_itab10-nlber = ''.
i_itab10-nlpla = ''.
i_itab10-bktxt = ''.
APPEND I_ITAB10.
clear i_itab10.
one blank row is added to i_itab10, but no row to table control which also uses the same table, i.e., i_itab10. can u help me in this. earlier MATNR, MENGE,MEINS are not input enabled but now these have to be. how can i make the some of the fields of the added row input enabled?
Regards,
swapna
‎2005 May 31 8:34 AM
in the pbo, try to call the refresh control command, where ctrlname is the name of table control:
"REFRESH CONTROL ctrlname FROM SCREEN scr."
Gianluca
‎2005 May 31 9:16 AM
Hi,
Check this sample programhttps://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=/library/webas/abap/abapCodeSamples/TableControlin+ABAP.pdf
Thanks & Regards,
Judith.
‎2005 May 31 9:24 AM
Hi,
Here I am giving my sample code.I initially set flag.I made the bold the part which you asked[some fields as editable.like that try for input enabled]
PROCESS BEFORE OUTPUT.
MODULE set_status.
MODULE get_t_ctrl_lines.
LOOP AT i_makt WITH CONTROL t_ctrl CURSOR t_ctrl-current_line.
Dynamic screen modifications
MODULE set_screen_fields.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT i_makt.
FIELD i_makt-pick MODULE check.
FIELD i_makt-zmatnr MODULE zmatnr .
ENDLOOP.
MODULE user_command_9000.
In the program, write the following code.
PROGRAM SAPMZTC MESSAGE-ID zz.
***********************************************************************
Tables Declaration
***********************************************************************
TABLES: zzz_makt.
***********************************************************************
Internal table Declaration
***********************************************************************
DATA : i_makt TYPE STANDARD TABLE OF zzz_makt WITH HEADER LINE.
***********************************************************************
Table control Declaration
***********************************************************************
CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9000'.
***********************************************************************
Variable Declaration
***********************************************************************
DATA : flg, "Flag to set the change mode
ln TYPE i. "No. of records
&----
*& Module get_T_CTRL_lines OUTPUT
&----
Populating data
----
MODULE get_t_ctrl_lines OUTPUT.
SELECT zmatnr zmaktx
INTO CORRESPONDING FIELDS OF TABLE i_makt
FROM zzz_makt.
DESCRIBE TABLE i_makt LINES ln.
To make the vertical scroll bar to come on runtime
t_ctrl-lines = ln + 100.
ENDMODULE. " get_T_CTRL_lines OUTPUT
&----
*& Module USER_COMMAND_9000 INPUT
&----
Triggering event according to the user command
----
MODULE user_command_9000 INPUT.
DATA :lv_fcode LIKE sy-ucomm, "Function Code
lv_answer(1) type c. "Storing the answer
lv_fcode = sy-ucomm.
CASE lv_fcode.
WHEN 'CHANGE'.
Setting the flag to make the table control in editable mode[excluding
primary key].
flg = 'Y'.
WHEN 'DELETE'.
Setting the flag to make the table control in editable mode after
deleting the selected line
flg = 'Y'.
Confirmation of delete
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Confirm'
text_question = 'Are you sure to delete from database?'
TEXT_BUTTON_1 = 'Yes'(001)
TEXT_BUTTON_2 = 'No'(002)
IMPORTING
ANSWER = lv_answer.
if lv_answer eq '1'.
Updating the database table from the internal table
UPDATE zzz_makt FROM TABLE i_makt.
Deleting the selected row from the internal table
DELETE i_makt WHERE pick = 'X'.
Deleting the selected row from the database table
DELETE FROM zzz_makt WHERE pick = 'X'.
MESSAGE s005 WITH 'Deleted Successfully'.
ENDIF.
WHEN 'SAVE'.
Inserting new record or updating existing record in database table
from the internal table
MODIFY zzz_makt FROM TABLE i_makt.
MESSAGE s005 WITH 'Saved Successfully'.
WHEN 'BACK'.
SET SCREEN '0'.
WHEN 'EXIT' OR 'CANCEL'.
Leaving the program
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
&----
*& Module set_screen_fields OUTPUT
&----
Setting the screen fields
----
MODULE set_screen_fields OUTPUT.
LOOP AT SCREEN.
IF flg IS INITIAL.
screen-input = 0.
ELSEIF ( flg EQ 'Y' ).
<b>IF ( ( screen-name = 'I_MAKT-ZMAKTX'
OR screen-name = 'I_MAKT-CHECK1' )
AND t_ctrl-current_line LE ln ) .</b>* Making the screen fields as editable
screen-input = 1.
<b>ELSEIF ( ( screen-name = 'I_MAKT-ZMATNR' )
AND t_ctrl-current_line LE ln ).</b>
Making the screen field as uneditable
screen-input = 0.
ENDIF.
ENDIF.
Modifying the screen after making changes
MODIFY SCREEN.
ENDLOOP.
ENDMODULE. " set_screen_fields OUTPUT
&----
*& Module zmatnr INPUT
&----
Appending records to the internal table
----
MODULE zmatnr INPUT.
MODIFY i_makt INDEX t_ctrl-current_line.
IF t_ctrl-current_line GT ln.
READ TABLE i_makt WITH KEY zmatnr = i_makt-zmatnr.
IF sy-subrc NE 0.
Inserting record if it does not exist in database
APPEND i_makt.
ELSE.
MESSAGE i005 WITH 'Material Number' i_makt-zmatnr 'already exists'.
ENDIF.
ENDIF.
ENDMODULE. " zmatnr INPUT
&----
*& Module set_status OUTPUT
&----
Setting the GUI status
----
MODULE set_status OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'ZTITLE'.
ENDMODULE. " set_status OUTPUT
*&----
*& Module CHECK INPUT
*&----
Modify the internal table using the current line in table control
*----
MODULE check INPUT.
MODIFY i_makt INDEX t_ctrl-current_line.
ENDMODULE. " CHECK INPUT
‎2005 May 31 1:08 PM
hi jayanthi,
the code was very helpful, can u tell me why u kept 'OR' command in the highlighted code.
‎2005 May 31 1:17 PM
Hi,
IF ( ( screen-name = 'I_MAKT-ZMAKTX'
OR screen-name = 'I_MAKT-ZMAKTX')
AND t_ctrl-current_line LE ln ) .
This is the code you asked.
In table control,I am having three fields 'I_MAKT-ZMAKTX','I_MAKT-CHECK1' and 'I_MAKT-ZMATNR'.Since I want if the screen field is 'I_MAKT-ZMAKTX' or 'I_MAKT-ZMAKTX' , I want to make the corresponding cell as editable/non-editable.Since it is on loop,it will keep on checking for all the rows in the table control.
Could you edit your question as a thread and reward points if the answer is useful?
Message was edited by: Jayanthi Jayaraman
‎2005 May 31 1:38 PM
no jayanthi,
why that 'or' command you kept in the code which u sent it just now. i got some fields MATNR MENGE MEINS etc which are non editable earlier but in the added row i have to make it editable.
thanks and Regards,
swapna