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

table control query

Former Member
0 Likes
566

Hi experts,

I want a sample code for to display the data into table control

from internal table , please help me.

4 REPLIES 4
Read only

Former Member
0 Likes
540

Hi,

1. Define a table control.

2. In PBO write select query.

select * from <dbtable> into corresponding fields of <itab>.

3.And give the table control field names as internal table fields.

Regards,

Sathish reddy.

Read only

Former Member
0 Likes
540

PROCESS BEFORE OUTPUT.

MODULE STATUS_0300.

LOOP AT I_BGDET WITH CONTROL D_TABLECONTROL.

MODULE FILL_TABLE_CONTROL.

ENDLOOP.

*

PROCESS AFTER INPUT.

LOOP AT I_BGDET.

module save_line.

ENDLOOP.

      • module fill table control

MODULE fill_table_control OUTPUT.

DESCRIBE TABLE i_bgdet LINES d_tablecontrol-lines.

ENDMODULE. " FILL_TABLE_CONTROL OUTPUT

      • save line

MODULE SAVE_LINE INPUT.

MODIFY I_BGDET INDEX D_TABLECONTROL-CURRENT_LINE.

ENDMODULE. " save_line INPUT

Read only

Former Member
0 Likes
540

This is a sample code which you can write in the flowlogic of your screen..

PROCESS BEFORE OUTPUT.

  • Module for displaying the table control...

MODULE status_0101.

  • This is to change the displaying way of the table control like editable,non-editable etc.

LOOP AT it_create INTO wa_create

WITH CONTROL acm_create.

ENDLOOP.

PROCESS AFTER INPUT.

LOOP AT it_create.

  • For validation of the table control contents.

CHAIN.

FIELD wa_create-userid.

FIELD wa_create-custno.

FIELD wa_create-partfun.

FIELD wa_create-category.

MODULE validate_screen ON CHAIN-REQUEST.

ENDCHAIN.

  • Module which updates the internal table(table control output table) with all the

  • dynamic screen modifications done by the user.

MODULE update_create_table.

ENDLOOP.

  • Module to handle all the exit commands..

MODULE exit_command_0101 AT EXIT-COMMAND.

  • Module to handle all the user commands.

MODULE user_command_0101.

PROCESS ON VALUE-REQUEST.

  • This provides the F4 help for the fields-

FIELD wa_create-partfun MODULE f4help_partfun.

FIELD wa_create-category MODULE f4help_category.

Regards,

Kaushik

Read only

Former Member
0 Likes
540

hi,

Check the below code


*&---------------------------------------------------------------------*
*& Module pool       Z_TABLE_CONTROL_TEST                              *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

PROGRAM  z_table_control_test                    .

DATA: BEGIN OF lt_vbak OCCURS 0,
      flag TYPE c,
      vbeln TYPE vbak-vbeln,
      ernam TYPE vbak-ernam,
      kunnr TYPE vbak-kunnr,
      END OF lt_vbak.

DATA: sfkunnr TYPE kunnr,
      tw_vbak TYPE vbak.

CONTROLS: tabctrl TYPE TABLEVIEW USING SCREEN '9000'.


*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
  SET PF-STATUS 'S9000'.
  SET TITLEBAR 'T9000'.

ENDMODULE.                 " STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.

  CASE sy-ucomm.
    WHEN 'DISP'.
      SELECT vbeln ernam kunnr FROM vbak
      INTO CORRESPONDING FIELDS OF table lt_vbak
      WHERE kunnr = sfkunnr.
      WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
        LEAVE PROGRAM.
      WHEN 'REFR'.
        REFRESH lt_vbak[].
    ENDCASE.
  ENDMODULE.                 " USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*&      Module  assign_data  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module assign_data output.
tw_vbak-vbeln = lt_vbak-vbeln.
tw_vbak-ernam = lt_vbak-ernam.
tw_vbak-kunnr = lt_vbak-kunnr.

endmodule.                 " assign_data  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  delete_rows  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module delete_rows input.
case sy-ucomm.
when 'DELE'.
if lt_vbak-flag eq 'X'.
tw_vbak-vbeln = lt_vbak-vbeln.
tw_vbak-ernam = lt_vbak-ernam.
tw_vbak-kunnr = lt_vbak-kunnr.

delete lt_vbak where vbeln eq tw_vbak-vbeln.
endif.
endcase.
endmodule.                 " delete_rows  INPUT



************************************************************************
                  SE51 CODE
************************************************************************

PROCESS BEFORE OUTPUT.
* Set the Status of the screen 9000.
  MODULE STATUS_9000.
* The LOOP statement ,LOOP AT lt_vbak WITH CONTROL tcontrol starts a
* loop through the screen table, and reads the line of the internal
* table corresponding to the current line of the screen table and
* populate the Table Control.
  LOOP AT LT_VBAK WITH CONTROL TCONTROL CURSOR TCONTROL-TOP_LINE.
    MODULE ASSIGN_DATA.
  ENDLOOP.

PROCESS AFTER INPUT.
*The PAI processing block is triggered when you scroll vertically in
*the table control or save the user configuration.
  MODULE USER_COMMAND_9000.
  LOOP AT LT_VBAK.
* Delete the selected rows from the Table Control
    MODULE DELETE_ROWS.
  ENDLOOP.

regards

padma