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: 

Table Control

Former Member
0 Kudos

Hi,

I have a Table control in a subscreen which is a part of the screen exit. I am trying to populate the table control with values from a table in the PBO. But the values do not get displayed in the table control. I have used

LOOP AT i_data WITH CONTROL TC1_TAB

CURSOR TC1_TAB-CURRENT_LINE.

Module transfer_data.

ENDLOOP.

in the PBO.

Any tips ??

Thanks,

Reshmi

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Have you "refreshed" your control using REFRESH keyword.

Regards,

Rich Heilman

0 Kudos

REFRESH Table Control (TC1_TAB) gives a syntax error.

When i write the logic in PBO and PAI of the subscreen there is no syntax error but nothing gets displayed in the table control.

If i write the same logic in PBO and PAI of the main screen through function exits i get a syntax at

"loop at itab with cursor tc1_tab" = it says cannot identify WITH but one blank line gets displayed in the table control as my Z table has one entry for that order number.

0 Kudos

Hi Reshmi,

I have had no problems whatsoever in getting to display the contents of a database table in a table control in the screen exit that you're talking about.

Just cross-check if this is what you're doing in your program -

1. Screen flow Logic for your subscreen (the screen-exit)

PROCESS BEFORE OUTPUT.
  LOOP AT ITAB WITH CONTROL TC.
    MODULE TRANSFER.
  ENDLOOP.

PROCESS AFTER INPUT.
  LOOP AT ITAB.
  ENDLOOP.
  MODULE USER_COMMAND_0900.

2. Data Declarations for the above (I'm using SPFLI for the purpose of this example, but any other table should do as well)-

CONTROLS TC TYPE TABLEVIEW USING SCREEN 0900.
DATA ITAB TYPE TABLE OF SPFLI <b>WITH HEADER LINE</b>.

3. Let's suppose that on the screen layout, the table control has two fields (both of them disabled for input) - ITAB-CARRID and ITAB-CONNID.

4. If you have declared the fields in the table control with the same name as the internal table, then your TRANSFER module would be something like this -

MODULE TRANSFER <b>OUTPUT</b>.
  IF ITAB[] IS INITIAL.
    SELECT * FROM SPFLI INTO TABLE ITAB.
  ENDIF.
ENDMODULE.

If instead, you have directly referred to the database table in your table control, then you will explicitly have to transfer the data from the internal table to the table control's table. something like this -

MODULE TRANSFER <b>OUTPUT</b>.
  IF ITAB[] IS INITIAL.
    SELECT * FROM SPFLI INTO TABLE ITAB.
  ENDIF.
  READ TABLE ITAB INDEX TC-CURRENT_LINE INTO SPFLI.
ENDMODULE.

But there's one small point here that is likely to be overlooked sometimes - when you write the code for the MODULE TRANSFER, it is important that you specify the OUTPUT addition. Otherwise, the MODULE will be considered as a PAI Module and the system will never execute it. And worse, you will not even get a syntax error.

If you have created the MODULE by double clicking in the screen flow logic, then you're safe. But if you have manually coded this module without the system-supplied skeleton for it, then you may have forgotten this addtion. Please check this out, too.

If you have any problems on this one, then please get back with the logic you are using for the PBO and PAI modules, the data declarations and also the screen-flow logic.

Regards,

Anand Mandalika.

0 Kudos

Hi Jayanthi and Anand,

I have used table controls in other Z transactions and they have worked fine. I went through the flow logic carefully.

I tried to display the contents of my internal table in text boxes. When i write the logic to transfer the contents to text boxes in the PBO of the main screen then it writes the values to the text boxes but if i write the logic in the PBO of the subscreen it's blank.

So if i try to replicate the logic of transferring the contents of internal table to table control in PBO of the main screen i get an error. I have tried several times but all in vain. Any suggestions ??

Thanks

0 Kudos

My code for table control is as follows :

************************

PROCESS BEFORE OUTPUT.

MODULE STATUS_0900.

LOOP AT i_data WITH CONTROL TC1_TAB.

CURSOR TC1_TAB-CURRENT_LINE.

MODULE TRANSFER_DATA.

ENDLOOP.

PROCESS AFTER INPUT.

LOOP.

ENDLOOP.

MODULE USER_COMMAND_0900.

*****************

MODULE STATUS_0900 OUTPUT.

perform populate_table.

describe table i_data lines v_lines.

tc1_tab-lines = v_lines.

ENDMODULE. " STATUS_0900 OUTPUT

****************

MODULE TRANSFER_DATA OUTPUT.

    • Module to transfer data into the screen.

ZZSMSTATUS-ZCODE = I_DATA-ZCODE.

ZZSMSTATUS-ZUSER = I_DATA-ZUSER.

ZZSMSTATUS-ZDETAIL = I_DATA-ZDETAIL.

ZZSMSTATUS-ZDATE = I_DATA-ZDATE.

ZZSMSTATUS-ZTIME = I_DATA-ZTIME.

V_LOOPLINES_NB = SY-LOOPC.

ENDMODULE. " TRANSFER_DATA OUTPUT

**********************************

FORM populate_table .

select zcode zuser zdetail zdate ztime from zzsmstatus

into corresponding fields of table i_data

where aufnr = aufk-aufnr.

ENDFORM. " populate_table

0 Kudos

I was able to get this working. Some of the objects in the activation list were not required and hence the PAI and PBO modules were not getting activated completely.

Such a simple thing but i spent hours trying to figure out the error. Hard lesson.

Thanks.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check this sample coding.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table control in abap.pdf

If it is not clear, get back to me.

Rgds,

J.Jayanthi