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

How to display a table data on Screen having a Table control

Former Member
0 Likes
3,738

Hi ,

I am new to ABAP.I would like to display a table data (Eg: ZDemo) on a screen at run time.I have defined a Table control in screen. Now I want to populate data from ZDemo to table control.How can I do that?Please help moving forward in this regard.

1 ACCEPTED SOLUTION
Read only

former_member229729
Active Participant
0 Likes
2,058

Hi Gayatri,

There are very good examples available on your subject from the T/Code: ABAPDOCU.

Please execute this tcode.

Rgds,

Ramani N.

Hi ,

I am new to ABAP.I would like to display a table data (Eg: ZDemo) on a screen at run time.I have defined a Table control in screen. Now I want to populate data from ZDemo to table control.How can I do that?Please help moving forward in this regard.

5 REPLIES 5
Read only

Former Member
0 Likes
2,058

Hi Gayatri,

After creating table control do the following steps.

1. In the flow logic section write the following code:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0200.

LOOP AT I_LIKP WITH CONTROL LIKP_DATA CURSOR LIKP_DATA-CURRENT_LINE.

MODULE ASSIGN_DATA.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0200.

LOOP AT I_LIKP.

ENDLOOP.

I_LIKP is the internal table which is used to display table data in the table control.

2. In Process Before Output, in the module STATUS_0200 write the following code:

DESCRIBE TABLE I_LIKP LINES FILL.

LIKP_DATA-LINES = FILL.

In Process After Input, in the module USER_COMMAND_0200 write the following code:

CASE SY-UCOMM.

WHEN 'LIPS'.

READ TABLE I_LIKP WITH KEY MARK = 'X'.

SELECT VBELN

POSNR

WERKS

LGORT

FROM LIPS

INTO TABLE I_LIPS

WHERE VBELN = I_LIKP-VBELN.

IF SY-SUBRC = 0.

CALL SCREEN 200.

ENDIF.

WHEN 'BACK'.

SET SCREEN 200.

ENDCASE.

In Process Before Output and in the module ASSIGN_DATA which is there inside the loop write the following code:

MOVE-CORRESPONDING I_LIKP TO LIKP.

So, Totally your flow logic code should be like this.

TABLES: LIKP, LIPS.

DATA: BEGIN OF I_LIKP OCCURS 0,

VBELN LIKE LIKP-VBELN,

ERNAM LIKE LIKP-ERNAM,

ERZET LIKE LIKP-ERZET,

ERDAT LIKE LIKP-ERDAT,

MARK TYPE C VALUE 'X',

END OF I_LIKP,

BEGIN OF I_LIPS OCCURS 0,

VBELN LIKE LIPS-VBELN,

POSNR LIKE LIPS-POSNR,

WERKS LIKE LIPS-WERKS,

LGORT LIKE LIPS-LGORT,

END OF I_LIPS,

FILL TYPE I.

CONTROLS: LIKP_DATA TYPE TABLEVIEW USING SCREEN 200,

LIPS_DATA TYPE TABLEVIEW USING SCREEN 300.

DATA: COLS LIKE LINE OF LIKP_DATA-COLS.

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'LIKP'.

SELECT VBELN

ERNAM

ERZET

ERDAT

FROM LIKP

INTO TABLE I_LIKP

WHERE VBELN = LIKP-VBELN.

IF I_LIKP[] IS INITIAL.

CALL SCREEN 200.

ENDIF.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module assign_data OUTPUT

&----


  • text

----


MODULE ASSIGN_DATA OUTPUT.

MOVE-CORRESPONDING I_LIKP TO LIKP.

ENDMODULE. " assign_data OUTPUT

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


MODULE STATUS_0200 OUTPUT.

DESCRIBE TABLE I_LIKP LINES FILL.

LIKP_DATA-LINES = FILL.

ENDMODULE. " STATUS_0200 OUTPUT

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


MODULE USER_COMMAND_0200 INPUT.

CASE SY-UCOMM.

WHEN 'LIPS'.

READ TABLE I_LIKP WITH KEY MARK = 'X'.

SELECT VBELN

POSNR

WERKS

LGORT

FROM LIPS

INTO TABLE I_LIPS

WHERE VBELN = I_LIKP-VBELN.

IF SY-SUBRC = 0.

CALL SCREEN 200.

ENDIF.

WHEN 'BACK'.

SET SCREEN 200.

ENDCASE.

ENDMODULE. " USER_COMMAND_0200 INPUT

Save and Activate the program along with the screen in which you have included table control.

Hope this will help you.

Regards

Haritha.

Read only

0 Likes
2,058

Haritha,

When I use the " loop at itab with control " , an error is dispalyed stating : Unable to interpret 'With' .Possible causes : Incorrect spelling or comma error.

So, I just commented it and took a reference from an example in ABAPDOCU.

Hi All,

Thanks for your help .

When I execute the report , a runtime error is displayed stating : Illegal value when compressing screen.Error Analysis says :

When compressing the next screen, one of the variables had an illegal value.What could be the reason for this error? Please check my report program given below and help me on this.

REPORT Z03_DYNPRO4IDOC.

Tables : z15sttab.

DATA : Z03_RB1 type button,

Z03_RB2 type button.

Controls : Z03_TAB1 type tableview using screen '0100'.

data : OK_CODE type sy-ucomm,

save_ok type sy-ucomm,

cols LIKE LINE OF Z03_TAB1-cols,

fill type i.

data : itab type standard table of z15sttab initial size 0.

SELECT * FROM z15sttab INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT Z03_TAB1-cols INTO cols WHERE index GT 2.

cols-screen-input = '0'.

MODIFY Z03_TAB1-cols FROM cols INDEX sy-tabix.

ENDLOOP.

call screen 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

SET TITLEBAR 'TIT_100'.

DESCRIBE TABLE itab LINES fill.

Z03_TAB1-lines = fill.

  • loop at itab with control Z03_TAB1 cursor Z03_TAB1-current_line.

  • MODULE fill_table_control.

  • endloop.

ENDMODULE. " STATUS_0100 OUTPUT

MODULE fill_table_control OUTPUT.

READ TABLE itab INTO z15sttab INDEX Z03_TAB1-current_line.

ENDMODULE.

MODULE read_table_control INPUT.

MODIFY itab FROM z15sttab INDEX Z03_TAB1-current_line.

ENDMODULE.

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

save_ok = ok_code.

clear ok_code.

CASE save_ok.

WHEN 'BACK'.

set screen 0.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'CANCEL'.

LEAVE PROGRAM.

when 'SUBMIT'.

if Z03_RB1 = 'X'. "'List Display'.

Include Z03_ALVLIST.

  • write /'List Display checked'.

elseif Z03_RB2 = 'X'. "'Grid Display'.

Include Z03_ALVGRID.

  • write / 'Grid Display checked'.

endif.

when others.

set screen 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

Thanks,

Prasuna

Read only

former_member229729
Active Participant
0 Likes
2,059

Hi Gayatri,

There are very good examples available on your subject from the T/Code: ABAPDOCU.

Please execute this tcode.

Rgds,

Ramani N.

Read only

Former Member
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,058

link: [example|http://sap.niraj.tripod.com/id29.html]