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: 

program to retrive data from table based on its name

Former Member
0 Kudos

hi all,

Is there any program that accepts input as table name and retrives all the data of a table .

thanks in advance

prasanna kumar

8 REPLIES 8

Sm1tje
Active Contributor
0 Kudos

No, accept for transaction SE11 and SE16, but you could create it yourself.


  DATA: dref TYPE REF TO data.
  FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
                 <line>  TYPE ANY.

  DATA: lr_reference TYPE REF TO cl_abap_typedescr.
  DATA: lr_tab       TYPE REF TO cl_abap_tabledescr.
  DATA: lr_data      TYPE REF TO cl_abap_datadescr.

  PARAMETERS: pa_tab TYPE tabname DEFAULT 'BUT000'.

  CREATE DATA dref TYPE STANDARD TABLE OF (pa_tab).
  ASSIGN dref->* TO <table>.

  SELECT * FROM but000 INTO TABLE <table>
           UP TO 10 ROWS.

Edited by: Micky Oestreich on Mar 23, 2009 11:57 AM

former_member222860
Active Contributor
0 Kudos

wrong

Edited by: Mahesh Reddy on Mar 23, 2009 11:57 AM

tarangini_katta
Active Contributor
0 Kudos

HI,

Y can't us this function module to get all the data of u r table.

TABLE_ENTRIES_GET_VIA_RFC

Pass u rtable name a sinput then it will give u all the table entries of this table.

Thanks

former_member585060
Active Contributor
0 Kudos

Hi,

Try below code

PARAMETERS : p_table(10) TYPE c.    " Give any table name
DATA: w_tabname TYPE w_tabname,
      w_dref TYPE REF TO data,
      w_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.

SELECT *
    FROM (w_tabname) UP TO 20 ROWS
    INTO TABLE <t_itab>.


*Double click on 100, to create a 100 screen, in flow logic uncomment both modules in PBO and PAI
* Create a GUI menu.

CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'BALA'.
*  SET TITLEBAR 'xxx'.

  CREATE OBJECT w_grid
      EXPORTING i_parent = cl_gui_container=>screen0.
  CALL METHOD w_grid->set_table_for_first_display
    EXPORTING
      i_structure_name = w_tabname
    CHANGING
      it_outtab        = <t_itab>.


ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE sy-ucomm.

    WHEN 'BACK'.

      LEAVE TO SCREEN 0.

  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

Regards

Bala Krishna

Edited by: Bala Krishna on Mar 23, 2009 4:37 PM

0 Kudos

thanks all,

for your quick response , my problem is solved.

thanks

prasanna kumar

Former Member
0 Kudos

Please see the below code for example.

parameters: p_tabname(16) type c.

data: gv_tabname TYPE w_tabname,

gv_dref TYPE REF TO data.

FIELD-SYMBOLS: <gf_itab> TYPE STANDARD TABLE.

gv_tabname = p_tabname.

CREATE DATA gv_dref TYPE TABLE OF (gv_tabname).

ASSIGN gv_dref->* TO <gf_itab>.

SELECT * FROM (gv_tabname)

INTO table <gf_itab>.

tarangini_katta
Active Contributor
0 Kudos

Hi Jaya,

IF your problem is solved make the question as Answered.

Thanks

Former Member
0 Kudos

HI ALL ,

thanks a lot for quick response