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

Display internal table on screen.

Former Member
49,255

Hi expert,

I want to display an internal table on screen. I had developed the program and got all the values in internal table. now i want to display this internal table on screen.

how can i do this?

Thanks in advance.

Abhishek

18 REPLIES 18
Read only

Former Member
13,378

Hi,

Use the loop statement.

loop at itab into fs_itab.

write: / fs_itab-carrid,fs_itab-connid.

endloop.

Regards,

jaya

Read only

0 Likes
13,378

Thanks for reply.

but i want to display the internal table on customize screen which i developed by using screen painter.

Read only

0 Likes
13,378

I think you can make use of ALV which will be developed by using OO ALV

Read only

faisalatsap
Active Contributor
0 Likes
13,378

HI,

Test the Sample Code Bellow.

TYPES: BEGIN OF ty_it,
  mm(10),
  amount TYPE i,
  END OF ty_it.

DATA: it_mm1 TYPE STANDARD TABLE OF ty_it WITH HEADER LINE.

it_mm1-mm = 'AAA'.
it_mm1-amount = 10.
APPEND it_mm1 TO it_mm1.

it_mm1-mm = 'BBB'.
it_mm1-amount = 10.
APPEND it_mm1 TO it_mm1.

it_mm1-mm = 'AAA'.
it_mm1-amount = 10.
APPEND it_mm1 TO it_mm1.

SORT it_mm1 BY mm DESCENDING.
  WRITE: 'Heading1', 20 'Heading2'.
LOOP AT it_mm1.
  WRITE: / it_mm1-mm, it_mm1-amount.
ENDLOOP.

Kind Regards,

Faisal

Read only

0 Likes
13,378

Thanks for reply.

but i want to display the internal table on customize screen which i developed by using screen painter.

Read only

jyothi_anagani
Active Contributor
13,378

Hi,

Use this loop statement

LOOP AT <tablename> INTO <workarea>.

WRITE <workarea-fieldname>.

ENDLOOP>.

Thanks.

Read only

faisalatsap
Active Contributor
0 Likes
13,378

Hmm,

Than you have to use Table Control.

Best Regards,

Faisal

Read only

0 Likes
13,378

Hi Faisal Altaf ,

I tried it by using table control but not able to call selection screen. do you have any code for reference.

Read only

0 Likes
13,378

Hi,

PROCESS BEFORE OUTPUT.
  MODULE set_cursor_field.
  MODULE zfsl_stinfo_tc_init.
  MODULE zfsl_stinfo_disable_key.

  LOOP AT it_zfsl_stinfo INTO it_zfsl_stinfo "Use This Loop 
       WITH CONTROL tc_for_zfsl_stinfo " here tc_for_zfsl_stinfo is table Control name.
       CURSOR tc_for_zfsl_stinfo-current_line.
  ENDLOOP.

your table Control Fields name must be IT_ZFSL_STINFO-F1, IT_ZFSL_STINFO-f2 so on.

in your driver program also write the following.

CONTROLS: tc_for_zfsl_stinfo TYPE TABLEVIEW USING SCREEN 1. " here tc_for_zfsl_stinfo is Table Control name and 1 is Screen number of screen painter

Please Reply if any Issue,

Best Regards,

Faisal

Edited by: Faisal Altaf on Mar 14, 2009 1:22 PM

Read only

Former Member
0 Likes
13,378

Hi,

Try with this.

First create the container on your screen.

In your program,

data: w_container TYPE REF TO cl_gui_custom_container,

it_fieldcat TYPE TABLE OF lvc_s_fcat,

wa_fieldcat TYPE lvc_s_fcat,

is_layout TYPE lvc_s_layo,

w_grid TYPE REF TO cl_gui_alv_grid.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'F!'.

wa_fieldcat-coltext = 'F!.'.

wa_fieldcat-outputlen = 10.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'F2'.

wa_fieldcat-coltext = 'F2.'.

wa_fieldcat-outputlen = 10.

APPEND wa_fieldcat TO it_fieldcat.

CREATE OBJECT w_container

EXPORTING

  • parent =

container_name = 'CONTAINER'

  • style =

  • lifetime = lifetime_default

  • repid =

  • dynnr =

  • no_autodef_progid_dynnr =

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CREATE OBJECT w_grid

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = w_container

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name =

  • i_fcat_complete = space

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

w_grid->set_table_for_first_display(

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

  • i_structure_name =

is_variant = w_variant

i_save = 'A'

  • i_default = 'X'

is_layout = is_layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = it_output

it_fieldcatalog = it_fieldcat

  • it_sort =

  • it_filter =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4

).

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL SCREEN 200.

Hope this will resolve your problem.

Thanks & Regards,

Anagha Deshmukh

Edited by: Anagha Deshmukh on Mar 14, 2009 8:36 AM

Read only

former_member203501
Active Contributor
13,378

hi look at this beautiful code.....

REPORT ztest line-size 1023.

data itab type standard table of mara.

parameters: p_matnr type matnr.

SELECTION-SCREEN: BEGIN OF BLOCK blk3 WITH FRAME TITLE blk3.

select * from mara into table itab.

CALL FUNCTION 'SRTT_TABLE_DISPLAY'

EXPORTING

table = 'MARA'

IV_TITLE = 'User List'

tables

table_content = itab.

SELECTION-SCREEN: END OF BLOCK blk3.

regards,

venkat

Read only

0 Likes
13,378

Thank you Venkateswararao Appikonda for the function module!! Worked wonders for me after lot of struggle to attain the required output

BR,

Debugger

Read only

0 Likes
13,378

what if i wanted to make the program able to search a table and display it, what should i do ?

Read only

0 Likes
13,378

demaauliansyah

While we're happy that you've come to SAP Community to get an answer to your question, you posted your question as a comment in an old thread.

If you're looking for help, you should ask a new question: https://answers.sap.com/questions/ask.html.

Here are some tips to help you craft an effective question for our community: https://community.sap.com/resources/questions-and-answers, https://developers.sap.com/tutorials/community-qa.html, https://groups.community.sap.com/t5/welcome-corner-discussions/advice-from-sap-champions-questions-a....

I encourage you to follow this guidance, as I'd really like to see you get a solution to your problem.

I hope you find this advice useful!

Read only

Former Member
0 Likes
13,378

Hi

To Display an internal Table in the Screen use Write Statement

For more than one record in the internal table use Loop At Internal Name .

Sample Code

tables : ekko.

data : begin of struc,

EBELN like ekko-ebeln,

lifnr like ekko-lifnr,

end of struc.

data : itab like struc occurs 0 with header line.

select ebeln lifnr from ekko

into corresponding fields of itab up to 80 rows.

append itab.

endselect.

write :/5 'purchase document',

30 'vendor no'.

loop at itab.

write : /5 itab-ebeln,

30 itab-lifnr.

endloop.

Read only

former_member873340
Active Participant
0 Likes
13,378

@ Venkat,

Man that was an awesome info. thanks for that function module

Yeah you are right it was a awesome piece of code indeed.

GS

Read only

Former Member
0 Likes
13,378

Thanks to all.............

Read only

guido_s
Participant
0 Likes
13,378

IMHO the easiest way is to use an ALV grid:

REPORT z_test.
...
DATA: lo_alv TYPE REF TO cl_salv_table.
cl_salv_table=>factory(
  IMPORTING
    r_salv_table = lo_alv
  CHANGING
    t_table      = itab
).
lo_alv->display( ).