‎2012 Feb 28 2:32 PM
Hello,
I am trying to make my very first table control object. I have read several tutorials and lured through sdn, however there still must be a catch that I cant see. The aim is to display attributes of a class given in a previous screen. Here is a part of my code:
Flow logic of a screen:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0200.
loop at iklvmera into wa_klvmera with control TC200.
module populate_screen.
endloop.
*
PROCESS AFTER INPUT.
loop at iklvmera.
endloop.
MODULE USER_COMMAND_0200.
PBO module for screen 0200
*&---------------------------------------------------------------------*
*& Include ZZTRIDY_003
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
IF ZTRIDA IS NOT INITIAL.
SELECT single KSCHL FROM SWOR JOIN KLAH ON SWOR~CLINT = KLAH~CLINT INTO text_004 WHERE KLAH~CLASS = ZTRIDA.
MOVE ztrida TO text_003.
SELECT single KLART FROM KLAH INTO zklart WHERE CLASS = ztrida.
CALL FUNCTION 'CLME_FEATURE_ATTR_OF_CLASS_ALL'
EXPORTING
CLASS = ZTRIDA
CLASSTYPE = ZKLART
LANGUAGE = SY-LANGU
KEY_DATE = SY-DATUM
TABLES
TFEATURES = IKLVMERA
EXCEPTIONS
CLASS_NOT_FOUND = 1
NO_AUTHORITY = 2.
SORT IKLVMERA.
ENDIF.
ENDMODULE. " STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*& Module POPULATE_SCREEN OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE POPULATE_SCREEN OUTPUT.
DATA ld_line TYPE i.
* Set which line of table is a top of displayed table control
IF sy-stepl = 1.
TC200-lines =
TC200-top_line + sy-loopc - 1.
endif.
* move fields from work area to scrren fields
MOVE-CORRESPONDING wa_klvmera TO klvmera.
ENDMODULE. " POPULATE_SCREEN OUTPUT
After the function module call the IKLVMERA is filled (checked in debug) so the data from the previous screen (ZTRIDA) is handled well.
and of course, here is my declaration
*&---------------------------------------------------------------------*
*& Include ZZTRIDY_TOP
*&---------------------------------------------------------------------*
TABLES: KLAH, CABN, CABNT, SWOR, KLVMERA.
controls: TC200 type tableview using screen 0200.
DATA: ztrida LIKE KLAH-CLASS,
text_003(40) type c,
text_004(40) type c,
zklart like klah-klart,
wa_klvmera type klvmera.
DATA: iklvmera type standard table of klvmera with header line.
for the program ZZTRIDY
PROGRAM ZZTRIDY.
INCLUDE ZZTRIDY_TOP.
INCLUDE ZZTRIDY_001.
INCLUDE ZZTRIDY_002.
INCLUDE ZZTRIDY_003.
INCLUDE ZZTRIDY_004.
Also I think I have made the table control in the screen painter all according the manual (with the reference to the given structure klmvera from which I am taking only first four fields - columns).
Any tips what might be the problem are welcome.
‎2012 Feb 28 4:06 PM
Hi,
How are your TC fields defined ? They should be named 'wa_klvmera-xxx'. The move-corresponding in the populate_screen module is useless. Also, before the LOOP/ENDLOOP in your PBO, you should initiate TC200-lines with the total number of lines...
Either create a new module, or add the following line at the end of your module STATUS_0200:
DESCRIBE TABLE iklvmera LINES TC200-lines.
Kr,
Manu.
‎2012 Feb 28 4:06 PM
Hi,
How are your TC fields defined ? They should be named 'wa_klvmera-xxx'. The move-corresponding in the populate_screen module is useless. Also, before the LOOP/ENDLOOP in your PBO, you should initiate TC200-lines with the total number of lines...
Either create a new module, or add the following line at the end of your module STATUS_0200:
DESCRIBE TABLE iklvmera LINES TC200-lines.
Kr,
Manu.
‎2012 Feb 28 5:55 PM
Hi,
Please tell what problem you are getting with the code.
Aswath.
‎2012 Feb 29 5:12 AM
Hi Peter,
The field names in layout of table control should be like 'klvmera-fieldname'.
Also before LOOP/ENDLOOP in PBO you are required to fill table control lines in following manner:
describe table iklvmera lines TC200-lines.
also you can add lines to TC200-lines like:
TC200-lines = TC200-lines + 20.
Hope this would work.
Regards,
Gaurav.
‎2012 Feb 29 7:24 AM
Morning is wiser then evening. Editing the code itself didnt do however deleting the TC in the layout editor and putting it back again did the job and the TC is suddenly on the screen. I have probably messed the TC when I was trying to solve the problem so questioning my fields definition actually helped me.
MOVE-CORRESPONDING wa_klvmera TO klvmera.
Is a must be. If I omit this line the TC comes out empty. I guess its because I use the wa in flow logic loop. Also TC field are defined as klvmera-xxx since I refer them to DD.
Thanx for all the tips