Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

regrding table control

Former Member
0 Likes
644

Hi,

Can anyone help me in tellin the code for making one field input enabled in table control in abap.

actaully first one screen will be displayed containg some values in the lines of table control and they will all be in display mode.after pressing one button one line must become input enabled keeping all other lines in display mode only.I tried a lot but m not gettin it.

This is my code.can someone suggest modifications to this one?please...


PROCESS BEFORE OUTPUT.

  MODULE INC_LINES.

  LOOP AT I_ZBLEND1 WITH CONTROL TAB_CREATE.

  ENDLOOP.


PROCESS AFTER INPUT.

  MODULE PERFORM_WORK.

   LOOP AT I_ZBLEND1.

   ENDLOOP.

in module inc_lines

first m inc lines using describe stmt m gettin the lines and then


 IF FLAG = '1'.

    DESCRIBE TABLE I_ZBLEND1 LINES NO1.

    NO2 = NO1 + 1.

    INSERT INITIAL LINE INTO I_ZBLEND1 INDEX NO2.

    LOOP AT I_ZBLEND1.

      IF SY-TABIX = no2.

        LOOP AT SCREEN.

          SCREEN-INPUT = '1'.

          modify screen.

        ENDLOOP.

      ENDIF.

    ENDLOOP.

  ENDIF.

and in pai modukle after pressing that button m settin flag = 1.

<REMOVED BY MODERATOR>

thankyou

subhashini.akella

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 25, 2008 5:09 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
623

HI, This is the sample program... it might be useful for u.

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' ).

IF ( ( screen-name = 'I_MAKT-ZMAKTX'

OR screen-name = 'I_MAKT-CHECK1' )

AND t_ctrl-current_line LE ln ) .

  • Making the screen fields as editable

screen-input = 1.

ELSEIF ( ( screen-name = 'I_MAKT-ZMATNR' )

AND t_ctrl-current_line LE ln ).

  • 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

Regards,

Priya.

6 REPLIES 6
Read only

Former Member
0 Likes
623

hi,

do u want to make any perticular line input enable?

Read only

0 Likes
623

ya i want 1 particular line to become input enabled.say if 3 lines r baing dipslayed.i want 4th line to be input enabled.it shld b blank and user must be able to enter the values

Read only

0 Likes
623

ok,

means u want that ur table control should be greyed at first output but when u press some button, last row should be input enable.....

Read only

0 Likes
623

ya right

Read only

Former Member
0 Likes
623

you do one thing that in your PBO where you are setting lines in display or active mode and make a condition there on basis of that condition only lines are in display or active.

remeber all this should be inside loop of your PBO.

e.g. when you press button 'PUSH'


case ok_code .

WHEN 'PUSH'.

if quantity < 20.

loop at screen.
if group = g1.
screen-input = 1.
endif.
endloop.

endcase.

<REMOVED BY MODERATOR>

vivek

Edited by: Alvaro Tejada Galindo on Feb 25, 2008 5:10 PM

Read only

Former Member
0 Likes
624

HI, This is the sample program... it might be useful for u.

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' ).

IF ( ( screen-name = 'I_MAKT-ZMAKTX'

OR screen-name = 'I_MAKT-CHECK1' )

AND t_ctrl-current_line LE ln ) .

  • Making the screen fields as editable

screen-input = 1.

ELSEIF ( ( screen-name = 'I_MAKT-ZMATNR' )

AND t_ctrl-current_line LE ln ).

  • 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

Regards,

Priya.