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

List Box in Table control

Former Member
7,168

Hi Friends,

             

I have a requirement where i have to display the list box in table control for a particular field.

I am able to display the filed as list box in TC with the help of list box option in property option for the field based on the dictionary values in Screen Painter.

Table control is in edit mode.

when i select the list box and add values to the other fields in the table control  and press enter values has to be updated in internal table of that table control.

BUT, Issue is that i am not able to update the values in the ITAB of table control with the selected list box. If i press enter the values gets vanished.

I tried several SCN discussion but cannot find the correct answer for the issue above.

Or else is there any other way to populate the list box in table control without using option in Screen painter property.

That is by populating list box using VRM and also issue of handling data in table control.

Please help me in this issue.

With Thanks & Regards,

Kishan Raj K

1 ACCEPTED SOLUTION
Read only

Former Member
5,500

Hi krishna ,

*&---------------------------------------------------------------------*

*&      Module  MODIFY  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

module MODIFY input.

  

  MODIFY lt_mara FROM zsample_s_list INDEX tc1-current_line.

   if sy-subrc <> 0 .

       append zsample_s_list to  lt_mara .

    endif .

endmodule.                 " MODIFY  INPUT

Add this line to your code and check whether its working fine .

Hi Friends,

             

I have a requirement where i have to display the list box in table control for a particular field.

I am able to display the filed as list box in TC with the help of list box option in property option for the field based on the dictionary values in Screen Painter.

Table control is in edit mode.

when i select the list box and add values to the other fields in the table control  and press enter values has to be updated in internal table of that table control.

BUT, Issue is that i am not able to update the values in the ITAB of table control with the selected list box. If i press enter the values gets vanished.

I tried several SCN discussion but cannot find the correct answer for the issue above.

Or else is there any other way to populate the list box in table control without using option in Screen painter property.

That is by populating list box using VRM and also issue of handling data in table control.

Please help me in this issue.

With Thanks & Regards,

Kishan Raj K

24 REPLIES 24
Read only

Former Member
Read only

Former Member
0 Likes
5,500

Hi kishan raj k,

Please make sure that you have modified your internal table in the PAI inside the table control loop.

Ex.

LOOP AT <itab>.

     MODIFY <itab> FROM <wa> INDEX tablecontrol-current_line.


ENDLOOP.

Regards,

Anoop

Read only

0 Likes
5,500

I tried adding modify itab in the PAI. Even so same problem exist.

I have not used the VRM methods instead generated listbox using the option in screen painter is that the problem.

Read only

former_member209120
Active Contributor
0 Likes
5,500

Hi kishan,

See this demo program

RSDEMO_TABLE_CONTROL

Read only

0 Likes
5,500

Hi Ramesh i have generated the list box in the table control based on the program you have said.

In the above mentioned program which you gave they are just displaying values in TC.

In my requirement TC is in Editable mode those data in the internal Table ( used for Table Control ) has to be updated in the Custom ZTable later once internal table is filled.

Read only

0 Likes
5,500

Hi Kishan,

VALUE-KEY = '1'.

VALUE-TEXT = 'Name'.

APPEND VALUE TO LIST.

VALUE-KEY = '2'.

VALUE-TEXT = 'Country'.

APPEND VALUE TO LIST.

in your final table it saves as 1 or 2 not like Name or Country.

Can you share your code to find wht's your problem.

Read only

0 Likes
5,500

Below is the code which i have used.

*&---------------------------------------------------------------------*

*& Module Pool       ZTEST_LIST_TC

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

PROGRAM  ztest_list_tc.

CONTROLS : tc1 TYPE TABLEVIEW USING SCREEN 9000 .

TABLES : zsample_s_list.

DATA : lt_mara LIKE TABLE OF zsample_s_list.

*&---------------------------------------------------------------------*

*&      Module  MODIFY  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

module MODIFY input.

  

  MODIFY lt_mara FROM zsample_s_list INDEX tc1-current_line.

 

endmodule.                 " MODIFY  INPUT

Below code in Screen flow.

PROCESS BEFORE OUTPUT.

   MODULE status_9000.

   LOOP AT lt_mara INTO ZSAMPLE_S_LIST WITH CONTROL tc1.

   ENDLOOP.

  

PROCESS AFTER INPUT.

   LOOP AT lt_mara .

  MODULE MODIFY.

   ENDLOOP.

   MODULE user_command_9000.

With Regards,

Kishan Raj. K

Read only

0 Likes
5,500

Hi Krishna ,

Check what you are getting here zsample_s_list  during debug

*&---------------------------------------------------------------------*

*&      Module  MODIFY  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

module MODIFY input.

  

  MODIFY lt_mara FROM zsample_s_list INDEX tc1-current_line.

 

endmodule.                 " MODIFY  INPUT

Read only

0 Likes
5,500

Hi Ramesh, this is the output i get. But when i press enter the value vanish. Matnr in the TC contains the Custom data element where i have created domain with some fixed values and created one global structure zsample_s_list where it contains all the 4 fields. List box displays only the values present in the fixed value of that domain.

With Regards,

Kishan Raj. K

Read only

0 Likes
5,500

Hi Ramesh,

I checked in debugger i get value in the zsample_s_list in the PAI.

But it does not update the values into the ITAB.

With Regards,

Kishan Raj. K

Read only

0 Likes
5,500

Hi Kishan,

How did you populate the listbox?

Make sure that you gave quotes when you populated the list box. This problem happens when you assign the key without quotes.

      ls_value-key = '1'.
       ls_value-text = 'Mat 1'.
       append ls_value to lt_list.
       ls_value-key = '2'.
       ls_value-text = 'Mat 2'.
       append ls_value to lt_list.


Read only

0 Likes
5,500

Hi Susmitha,

I don't populate the list box using VRM Function Module.

Instead i used the listbox option in the property window of that particular field in Screen Painter.

Please see the below image i have rounded it with red rectangle

With Regards,

Kishan Raj. K

Read only

0 Likes
5,500

So you

  • did not check ddic box
  • did not manage the listbox in program

So

  • What did you set in block "Attributes" tab "Program" for field "value list" (space/A) ?
  • Did you define your structure with a TABLES statement in TOP include of program ?
  • Which behavior were you expecting ?

Regards,

Raymond

Read only

0 Likes
5,500
  • did not check ddic box - i tried setting ddic box it becomes black when i click that checkbox.

  • did not manage the listbox in program - i don't understand what you mean here

  • What did you set in tab "Program" for field "value list" (space/A) ? - It is set as SPACE
Read only

Former Member
0 Likes
5,500

Hi krishna ,

Is the whole table control line is getting vanished or just the value you filled using the list box is getting disappeared.

Read only

0 Likes
5,500

Hi Juneed,

I tried filling values in one row for all the fileds and press enter then whole row gets blank.

Read only

0 Likes
5,500

Hi krishna ,

 

Since the whole row is getting disappeared problem is not with the list box ,problem is with your table control .. do 2 things

         .  enter atleast  three lines in table control and press enter .

         . if you get values in table control then ,jus press an enter .

update me with your output 

Read only

0 Likes
5,500

Hi Juneed,

     i tried with 3 row values as you said then also same problem. All the values got blank including the list box values

Read only

Former Member
5,501

Hi krishna ,

*&---------------------------------------------------------------------*

*&      Module  MODIFY  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

module MODIFY input.

  

  MODIFY lt_mara FROM zsample_s_list INDEX tc1-current_line.

   if sy-subrc <> 0 .

       append zsample_s_list to  lt_mara .

    endif .

endmodule.                 " MODIFY  INPUT

Add this line to your code and check whether its working fine .

Read only

0 Likes
5,500

Hi Juneed,

                  

               Thank for your help it is working fine now, Is it the correct way to do this.

With Regards,

Kishan Raj. K

Read only

0 Likes
5,500

Hi Juneed,

             Why the modify statement is not working in this case. It should be inserting new records to the internal table. Why it has not worked in this case.

Can you explain why modify is not working so.

With Regards,

Kishan Raj. K


Read only

0 Likes
5,500

Modify statement is not working since the internal table is empty .

Another way of dealing this problem is appending initial line to the internal table ,then without append statement you can add lines to the internal table .

Modify statement in internal table and database table is different ,in internal table it wont insert new records ,it just changes  already existing records ..

check out help.sap for more details

Regards,

Juneed K Manha

Read only

0 Likes
5,500

Hi Kishan,

You have to use the modify or the append statements depending on the condition

MODULE UPDATE_TABLE INPUT.

    case tc_wa-col2.
     when '1'.
           tc_wa-col3 = 'FR'.
     when '2'.
          tc_wa-col3 = 'FL'.
     when '3'.
         tc_wa-col3 = 'VG'.
   endcase.
   read table tc_tab into tc_wa1 index tc-current_line.
   if sy-subrc = 0.
     modify tc_tab from tc_wa INDEX tc-current_line.
  else.
    append tc_wa to tc_tab.
  endif.
ENDMODULE.

In the above example tc_wa-col2 was a drop down and tc_wa-col3 is populated based on the value in col3.

Now coming to the append and modify statements. If there was some field already populated in that row in the table in table control (from the PBO or earlier in the program), you can use the modify statement. But if its a new row that is being populated in table control, that row does not exist in the table. So modify will not work, since modify just changes an existing row in the table. In such a case, its the append statement that works.

Read only

Former Member
0 Likes
5,500

Hi Friends,

             Thanks for your help and efforts.

With Regards,

Kishan Raj. K