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: 

Internal Table

Former Member
0 Kudos

Hi,

How to modify data of internal table with user interface. How do i populate data of internal table on screen (tabular format) and then save the same.

Thanks in adavance.

Ravi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ravi,

Craete a module pool program and that create a table control. screen.

populate the data of internal table to table control and save that.

Please refer bolow code :

PROGRAM Z_TABLE_CONTROL .

DATA : OK_CODE_1000(20).

CONTROLS : TABlE_CONTROL TYPE TABLEVIEW USING SCREEN 1000.

DATA : BEGIN OF IT_TAB OCCURS 0 ,

MATNR TYPE MATNR,

MTART TYPE MTART,

MEINS TYPE MEINS,

END OF IT_TAB.

&----


*& Module USER_COMMAND_1000 INPUT

&----


  • text

----


module USER_COMMAND_1000 input.

case ok_code_1000.

when 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

endmodule. " USER_COMMAND_1000 INPUT

&----


*& Module fetching_data OUTPUT

&----


  • text

----


module fetching_data output.

REFRESH IT_TAB.

CLEAR IT_TAB.

SELECT MATNR

MTART

MEINS

INTO TABLE IT_TAB

FROM MARA

WHERE MTART = 'FERT'.

endmodule. " fetching_data OUTPUT

&----


*& Module ADD_ENTRIES OUTPUT

&----


  • text

----


module ADD_ENTRIES output.

READ TABLE IT_TAB INDEX TABle_CoNTRoL-CURRENT_LINE.

endmodule. " ADD_ENTRIES OUTPUT

&----


*& Module STATUS_1000 OUTPUT

&----


  • text

----


module STATUS_1000 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

Reward points if helpful.

Regards,

Hemant

10 REPLIES 10

Former Member
0 Kudos

create a table Control , populate the internal table data into it, modify and save

chk some demo programs

demo_dynpro_tabcont_loop

demo_dynpro_tabcont_loop_at

Message was edited by:

Chandrasekhar Jagarlamudi

Former Member
0 Kudos

hi

U can use the Table control in a Module pool program for this !!

regards,

sai ramesh

Former Member
0 Kudos

Hi

Get the data from Interface and try to modify the internal table

to populate data of internal table on screen (tabular format) and to save the same

you have to design the Module pool program or transaction.

Reward points if useful

Regards

Anji

Former Member
0 Kudos

use modify or update for save the data into data base.but ur internal table must be of type of some data base table after that use modify or update.

regds

anjali

Former Member
0 Kudos

You have to use editable table control in the screen for that.

Refer the following code:

REPORT demo_dynpro_tabcont_loop_at.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: cols LIKE LINE OF flights-cols,
      lines TYPE i.

DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn.
TABLES demo_conn.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT flights-cols INTO cols WHERE index GT 2.
  cols-screen-input = '0'.
  MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDLOOP.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE itab LINES lines.
  flights-lines = lines.
ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE read_table_control INPUT.
  MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'TOGGLE'.
      LOOP AT flights-cols INTO cols WHERE index GT 2.
        IF  cols-screen-input = '0'.
          cols-screen-input = '1'.
        ELSEIF  cols-screen-input = '1'.
          cols-screen-input = '0'.
        ENDIF.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDLOOP.
    WHEN 'SORT_UP'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) ASCENDING.
        cols-selected = ' '.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'SORT_DOWN'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) DESCENDING.
        cols-selected = ' '.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'DELETE'.
      READ TABLE flights-cols INTO cols WITH KEY screen-input = '1'.
      IF sy-subrc = 0.
        LOOP AT itab INTO demo_conn WHERE mark = 'X'.
          DELETE itab.
        ENDLOOP.
      ENDIF.
  ENDCASE.
ENDMODULE.

Former Member
0 Kudos

Hi,

The simplest way is OPEN SE38 and enter "<b>BCALVEDIT</b>" which will give you list of editable alv programs.

Use that and it will solve your problem.

Award points if it helps.

-Gaurang

former_member198270
Active Contributor
0 Kudos

Hi Ravi ,

If you want to chage data in internal table from User inter face , Suppose in module pool program , you can implement a logic to update data to internal table .

Regards,

Amber

Former Member
0 Kudos

hi

good

1-Use the subroutine to change the internal table data

2-using the module pool (table) you can populate the internal table data in tabular format and can save them

thanks

mrutyun^

Former Member
0 Kudos

HI,,

Why dont u try out module pool program this might solve ur problem.....just try it out.

if useful reward with points,

with regards,

madhuri.

Former Member
0 Kudos

Hi Ravi,

Craete a module pool program and that create a table control. screen.

populate the data of internal table to table control and save that.

Please refer bolow code :

PROGRAM Z_TABLE_CONTROL .

DATA : OK_CODE_1000(20).

CONTROLS : TABlE_CONTROL TYPE TABLEVIEW USING SCREEN 1000.

DATA : BEGIN OF IT_TAB OCCURS 0 ,

MATNR TYPE MATNR,

MTART TYPE MTART,

MEINS TYPE MEINS,

END OF IT_TAB.

&----


*& Module USER_COMMAND_1000 INPUT

&----


  • text

----


module USER_COMMAND_1000 input.

case ok_code_1000.

when 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

endmodule. " USER_COMMAND_1000 INPUT

&----


*& Module fetching_data OUTPUT

&----


  • text

----


module fetching_data output.

REFRESH IT_TAB.

CLEAR IT_TAB.

SELECT MATNR

MTART

MEINS

INTO TABLE IT_TAB

FROM MARA

WHERE MTART = 'FERT'.

endmodule. " fetching_data OUTPUT

&----


*& Module ADD_ENTRIES OUTPUT

&----


  • text

----


module ADD_ENTRIES output.

READ TABLE IT_TAB INDEX TABle_CoNTRoL-CURRENT_LINE.

endmodule. " ADD_ENTRIES OUTPUT

&----


*& Module STATUS_1000 OUTPUT

&----


  • text

----


module STATUS_1000 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

Reward points if helpful.

Regards,

Hemant