Application Development 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: 

problem with table control

Former Member
0 Kudos

hii gurus.

i have made a table control which takes cus no and name and add no ,name, current date , and time to z table. if there is any rec in table it displays it and have empty lines to add data.

when i run my tcode first time after activation (making any changes be it just including a space) the table control works properly.but when i exit and run tcode again the empty lines are greying out.and i am unable to make new entry . pls help me with this. how to sort this problelm .

6 REPLIES 6

Former Member
0 Kudos

hi aditya,

this problem ocuurs when we dnt keep a track of the PAI and PBO. do 1 thing declare a variable that keeps a track of the PBO and PAi.

declare that initially 0 and den everytime when the PAI or PBO of that particular screen is called...change the value to 1.

when the fields get disabled..check the properties of that particular firld in the screen layout..

hope this helps

with best regards

kanika

0 Kudos

hii i could not get meaning of tracking PBO AND PAI . can u be some more descriptive .. a sampel code will be really helpfull...

thanks

0 Kudos

do u have describe statement..if so then clear the table control-lines.

0 Kudos

PROCeSS BEFORE OUTPUT.

MODULE status_0100.

LOOP AT it_modpool INTO zmodpool WITH CONT1ROL tabctrl .

ENDLOOP.

PROCESS AFTER INPUT.

MODULE user_command_0100 .

MODULE exit AT EXIT-COMMAND.

LOOP AT it_modpool .

MODULE save.

MODULE delete.

ENDLOOP.

THIS code i have used in my screen..

*************************************************************************************************************************

below is the program...

TABLES zmodpool .

  • Decleration of structure

TYPES: BEGIN OF st_modpool,

mandt TYPE zmodpool-mandt,

cus_no TYPE zmodpool-cus_no,

cus_name TYPE zmodpool-cus_name,

date TYPE zmodpool-date_of_entry,

time TYPE zmodpool-time,

END OF st_modpool.

  • Decleration of internal table

DATA: it_modpool TYPE TABLE OF st_modpool.

*Decleration of variables.

DATA: sel(1) TYPE c.

*Decleration of table control.

CONTROLS : tabctrl TYPE TABLEVIEW USING SCREEN '100'.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'MODPOOL'.

  • SET TITLEBAR 'xxx'.

*Fetching data from database

SELECT * FROM zmodpool INTO TABLE it_modpool.

IF sy-subrc NE 0.

MESSAGE i003(zmodpool).

ENDIF.

        • SELECT cus_no

        • cus_name

        • date_of_entry

        • time

        • FROM zmodpool

        • INTO TABLE it_modpool.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module EXIT INPUT

&----


  • text

----


MODULE exit INPUT.

CASE sy-ucomm.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " EXIT INPUT

&----


*& Module save INPUT

&----


  • text

----


MODULE save INPUT.

CASE sy-ucomm.

WHEN 'SAVE'.

IF sel = 'X'.

zmodpool-mandt = sy-mandt.

zmodpool-date_of_entry = sy-datum.

zmodpool-time = sy-uzeit.

INSERT zmodpool.

ENDIF.

ENDCASE.

ENDMODULE. " save INPUT

&----


*& Module delete INPUT

&----


  • text

----


MODULE delete INPUT.

CASE sy-ucomm.

WHEN 'DELETE'.

IF sel = 'X'.

DELETE zmodpool.

ENDIF.

ENDCASE.

ENDMODULE. " delete INPUT

Former Member
0 Kudos

Try making LINES parameter of your tablecontrol as zero '0' in PBO.

G@urav.

I355602
Advisor
Advisor
0 Kudos

Hi Aditya Shrivastava,

If you want to add new records into the table, and on the screen you have a table control which is not enabled (i.e., empty line are greying out).

I suppose in this case its better to have a button for edit mode, which enables the table control for accepting new entries (initially your table control is in output mode only).

Now, place a button 'EDIT' using a pf-status, and then use this code to enable your table control.

And a button 'SAVE' for saving the entries into the database.

Use this code:-

At screen flow logic.

************************************************************************************************************************

PROCESS BEFORE OUTPUT.

MODULE STATUS_8001. "For PF-Status

LOOP WITH CONTROL MOVIE.

MODULE PASS_DATA. "Selects the records and passes to the table control

MODULE MODIFY_SCREEN_8001. "Enables table control for accepting new entries

ENDLOOP.

PROCESS AFTER INPUT.

LOOP WITH CONTROL MOVIE.

MODULE DISPLAY_DATA. "Displays data in the table control

MODULE SAVE_DATA. "Save the modified entries or new entries.

ENDLOOP.

************************************************************************************************************************

Code for the module.

************************************************************************************************************************

MODULE MODIFY_SCREEN_8001 OUTPUT.

OK_CODE = SY-UCOMM.

CASE OK_CODE.

WHEN 'EDIT'.

LOOP AT SCREEN.

IF ( SCREEN-GROUP1 = 'XYZ' ).

SCREEN-ACTIVE = 1.

SCREEN-INPUT = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDCASE.

ENDMODULE. " MODIFY_SCREEN_8001 OUTPUT

************************************************************************************************************************

MODULE SAVE_DATA INPUT.

OK_CODE = SY-UCOMM.

CASE OK_CODE.

WHEN 'SAVE'.

MODIFY <internal_table> INDEX <table_control_name>-CURRENT_LINE.

UPDATE <database_table> FROM TABLE <internal_table>.

LOOP AT SCREEN.

IF ( SCREEN-GROUP1 = 'XYZ' ).

SCREEN-ACTIVE = 0.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDCASE.

ENDMODULE. " SAVE_DATA INPUT

************************************************************************************************************************

Now when you click EDIT button, your table control will be enabled to accept new entries.

When you click SAVE button, it will again disable the table control (output mode only) and the database will be modified.

Hope this solves your problem.

Regards.

Tarun Gambhir.