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: 

change modes

Former Member
0 Kudos

HI!!!

I am creating one table control in module pool..

In selection screen i give 3 pushbuttons like display, insert, exit... When i give input and click display it will display the table control with the values in display mode.. There i give one more button named change.. When i select the particular row and press change button i should be change to edit mode.. I dont know the code for the program.... Can anyone help me......Pls its very urgent........

8 REPLIES 8

Former Member
0 Kudos

Hello Rajkumar,

There are more possibilities to achieve this. Here I try to describe one alternative in pseudo code:

Case Pushbutton:

when Display.

call transaction 'SE38'.

when insert/change:

call transaction 'SM30'.

when Exit.

EXIT.

endcase.

The when insert/change case can only be performed properly when the Table Maintenence Generation (SE55) was performed for the relevant table.

I hope this helps,

Heinz

0 Kudos

Hi heinz!!!

I tried wht u said.... but i was not able to get the output.... Can u give some more ideassss.....

Former Member
0 Kudos

HI,

Use SCREEN VARIENT TCODE SHD0.

here u can give ur tcode Click Screen varient

give Screen varient name

program name

Screen name

Save .Now one popup will be display here u can select wich one display mode and invisible mode whatever u want u can give and save.

Regards,

Brown.

0 Kudos

Hi!!

Brown!!!

Thanks for ur reply. But it also not helping for me... Can u tell me some other ways without using any tcode only with the use of coding.

0 Kudos

hey in which format u are displaying your report

alv or list display

and what you have to after changing the data,you need it just for display purpose or you need to store it some where

Edited by: ashish pandey on Apr 1, 2008 10:25 AM

0 Kudos

Hi!!!

I am doing it in normal report program. I dont know how to change it???? Is it possible???

Former Member
0 Kudos

first u design a table control with one fixed column in the first positon.

This can be done using w/sel column. Assign one name here eg: CHOOSE.

Now choose acts as a check box.(ie it returns X if particular row is selected in Table control)

Now when u click on suppose 2nd row in TC,

it places X.

supppose ur table contrl is like this

Kunnr-kna1 kunnr-name1 kunnr-land1.

Now

Loop at screen.

If Choose = 'X'.

IF Screen-Name = Kunnr-kna1 or

Screen-Name = kunnr-name1 or

Screen-Name = kunnr-land1.

Screen-input = 1.

Modify screen.

EndIF.

Endif.

End loop.

Hope this helps u.

Former Member
0 Kudos

Hi ,

See the following code. It codes for the same requirement as yours.

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.

Hope this helps.

Reward if helpful.

Regards,

Sipra