cancel
Showing results for 
Search instead for 
Did you mean: 

How to Populate Internal table data to Table Control in a Report Program

Former Member
0 Kudos

Dear All,

How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.

Thanks in Advance,

Joseph Reddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Joseph,

Try creating a custom screen, and calling it in your report using the statement CALL SCREEN <xxxx>.

Sudha

Answers (3)

Answers (3)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If you want to use a table control, you will need to create a screen.

In your report....



start-of-selection.

perform get_data.  " Get all your data here
call screen 100. " Now present to the user.


Double click on the "100" in your call screen statement. This will forward navigate you to the screen. If you have not created it yet, it will ask you if you want to create it, say yes. Go into screen painter or layout of the screen. Use the table control wizard to help you along the process. It will write the code for you. Since it is an output only table control, it will be really easy with not a lot of code.

A better way to present the data to the user would be to give it in a ALV grid. If you want to go that way, it is a lot easier. Here is a sample of the ALV function module. You don't even have to create a screen.



report zrich_0004
       no standard page heading.

type-pools slis.

data: fieldcat type slis_t_fieldcat_alv.

data: begin of imara occurs 0,
      matnr type mara-matnr,
      maktx type makt-maktx,
      end of imara.

* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.

start-of-selection.

  perform get_data.
  perform write_report.


************************************************************************
*  Get_Data
************************************************************************
form get_data.

  select  mara~matnr makt~maktx
            into corresponding fields of table imara
              from mara
               inner join makt
                 on mara~matnr = makt~matnr
                    where mara~matnr in s_matnr
                      and makt~spras = sy-langu.

endform.

************************************************************************
*  WRITE_REPORT
************************************************************************
form write_report.

  perform build_field_catalog.

* CALL ABAP LIST VIEWER (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_fieldcat = fieldcat
       tables
            t_outtab    = imara.

endform.

************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.

  data: fc_tmp type slis_t_fieldcat_alv with header line.
  clear: fieldcat. refresh: fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material Number'.
  fc_tmp-fieldname  = 'MATNR'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '18'.
  fc_tmp-col_pos    = 2.
  append fc_tmp to fieldcat.


  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material'.
  fc_tmp-fieldname  = 'MAKTX'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '40'.
  fc_tmp-col_pos    = 3.
  append fc_tmp to fieldcat.

endform.

Regards,

Rich Heilman

former_member181962
Active Contributor
0 Kudos

Hi Joseph,

Can you be a bit more clear on what exactly you mean by Table control?

If you are talking about a Grid sort of display, with options to edit the report, then we can use REUSE_ALV_GRID_DISPLAY function module, by passing the internal table to be displayed.

Thanks,

Ravi

Former Member
0 Kudos

In your report call a screen like call screen 100.

Go to that screen.

create table control.

do the requires loop at itab etc at PBO and PBI of that screen.

tat's it.

Regards

Asit