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

table control problem..??

Former Member
0 Likes
1,256

HI guys,

I am using table control i am having 2 problems


PROCESS BEFORE OUTPUT.
  MODULE status_9000.
  LOOP at it_rbd INTO wa_rbd WITH CONTROL ctrl.
    MODULE display_data2.
  ENDLOOP.
 

its giving me an error message the addition with control ctrl is missing in a loop in PBO.

but if i write


PROCESS BEFORE OUTPUT.
  MODULE status_9000.

  LOOP  WITH CONTROL ctrl.
    MODULE display_data2.
  ENDLOOP.

 MODULE scroll.
 

i dont get any error.

Secondly when i scroll down the table control i am able to do that and enter the data but when i scroll back i am

unable to see the initial data


MODULE scroll OUTPUT.

  DESCRIBE TABLE it_rpmno LINES vlines.
  ctrl-lines = vlines + 1.

ENDMODULE.                 " scroll  OUTPUT

PLZ HELP.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,041

Hi try this...


  MODULE check_rpno INPUT.
  SELECT SINGLE
              zrpmno
                    FROM zivl_rpm
                    INTO z_rpmno
                    WHERE zrpmno = wa_rpmno-zrpmno1
                    AND   zpkey  = key.
  IF sy-subrc  0.
    MESSAGE e000 WITH text-003 wa_rpmno-zrpmno1.
  ELSEif ctrl-current_line < line_count and sy-cubrc = 0.                                                  
   MODIFY it_rpmno FROM wa_rpmno INDEX ctrl-current_line.  
elseif ctrl-current_line > line_count and sy-subrc = 0.
APPEND wa_rpmno TO it_rpmno.
  ENDIF.
 

cheers,

Mayank

9 REPLIES 9
Read only

Former Member
0 Likes
1,041

Hi

Your code seems to be right, how you've written the PAI?

Probably

LOOP  WITH CONTROL ctrl.
ENDLOOP.

If it's so the PAI should be:

LOOP AT ITAB.
ENDLOOP.

so the PBO:

LOOP AT   ITAB INTO WA WITH CONTROL CTRL.
ENDLOOP.

Max

Read only

0 Likes
1,041

Hi Max,

Thanks it worked out....i need a little more help how do i scroll my table control.... i am able to

scroll down but when i scroll up the data which gets hidden gets deleted ....

thanks again ...

Read only

0 Likes
1,041

Hi,

When you scroll up or down, your PAI gets triggered but there is no SY-UCOMM value associated with scrolling in the table control.

What you can do is, restrict the portion of code in the PAI that you have written to populate your table control between



if sy-ucomm eq 'F_ENTER'. "Or whatever is the Function code for the event you are using
   "Populate your table control
endif.

When you do this, you are essentially asking the code to get executed only for certain sy-ucomm values. Since scrolling does not have any function code, it wouldnt execute this portion.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,041

Hi,

Refer:-

it_zekpo is my internal table w/o header line,

wa_zekpo is work area.

Name of input/output fields on screen are:-

wa_zekpo-field1,

wa_zekpo-field2, and so on...

Use code:-

At screen logic:-


PROCESS BEFORE OUTPUT.
*  MODULE status_8003.
 
  LOOP WITH CONTROL po_tab. "po_tab is table control on screen 8003
    MODULE read_data.
  ENDLOOP.
 
PROCESS AFTER INPUT.
*  MODULE user_command_8003.
 
  LOOP WITH CONTROL po_tab.
    MODULE modify_data.
  ENDLOOP.

In PBO:-


*&---------------------------------------------------------------------*
*&      Module  READ_DATA  OUTPUT
*&---------------------------------------------------------------------*
MODULE read_data OUTPUT.
  READ TABLE it_zekpo INTO wa_zekpo INDEX po_tab-current_line. "po_tab is table control name
 
  DATA : line_count type i.
  DESCRIBE it_zekpo LINES line_count.
   po_tab-lines = line_count + 10.
  "to increase the number of lines in table control dynamically
 ENDMODULE.                 " READ_DATA  OUTPUT

In PAI:-


*&---------------------------------------------------------------------*
*&      Module  MODIFY_DATA  INPUT
*&---------------------------------------------------------------------*
MODULE MODIFY_DATA INPUT.
  MODIFY IT_ZEKPO FROM WA_ZEKPO INDEX po_tab-currentline.
  "this will modify the contents of existing line
ENDMODULE.                 " MODIFY_DATA  INPUT

Hope this helps you.

Regards,

Tarun

Read only

0 Likes
1,041

Dear Tarun,

Thanks a lot for the reply i am able to scroll and the data doesn't go when i scroll but another problem arises...

ie data gets duplicated when i scroll... here is my code...


PROCESS BEFORE OUTPUT.
  MODULE status_9001.
    LOOP at it_rpmno INTO wa_rpmno WITH CONTROL ctrl
                                           CURSOR ctrl-current_line.
    MODULE display_data2.
  ENDLOOP.

PROCESS AFTER INPUT.
  MODULE user_command_9001.
  MODULE clear_itab.                              "  if i dont clear my internal table data gets replicated in internal table and 
                                                                "  duplicate data is displayed in table control. if i clear my internal table 
                                                                " after i scroll the data which is not displayed gets deleted  

  LOOP AT it_rpmno.
    CHAIN.
      FIELD wa_rpmno-zrpmno1 MODULE check_rpno.
    ENDCHAIN.
  ENDLOOP.
  MODULE save.


MODULE display_data2 OUTPUT.
  DATA vline TYPE i.
   READ TABLE it_rpmno INTO wa_rpmno INDEX ctrl-current_line.
  DESCRIBE TABLE it_rpmno LINES vline.
  ctrl-lines = vline + 5.
ENDMODULE.                 " display_data2  OUTPUT


MODULE clear_itab INPUT.
*  CLEAR : it_rpmno.
ENDMODULE.                 " clear_itab  INPUT


MODULE check_rpno INPUT.
  SELECT SINGLE
              zrpmno
                    FROM zivl_rpm
                    INTO z_rpmno
                    WHERE zrpmno = wa_rpmno-zrpmno1
                    AND   zpkey  = key.
  IF sy-subrc <> 0.
    MESSAGE e000 WITH text-003 wa_rpmno-zrpmno1.
  ELSE.
    APPEND wa_rpmno TO it_rpmno.                                                "  i append my data from screen to internal table here. 
  *  MODIFY it_rpmno FROM wa_rpmno INDEX ctrl-current_line.     "  if i use modify instead of append then when ever there is an event in the screen the internal table gets refreshed. 
  ENDIF.

Thanks in advance.

Read only

0 Likes
1,041

Hi,

I already mentioned that it is neccessary to restrict your code in the PAI between some function code.

if sy-ucomm eq 'F_FUNC'.

-


endif.

When you scroll, the PAI gets triggered and the scroll event does not have any function code associated with it. So whatever code that you write gets triggered which essentially means. your data gets duplicated because the code is getting executed once more when you scroll. So restrict it between an event.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,041

Hi,

I guess the problem arises as you are using LOOP at it_rpmno INTO wa_rpmno WITH CONTROL ctrl CURSOR ctrl-current_line and READ statement as well inside the loop.

Try and use the way I mentioned in my earlier post.

Using:-


LOOP WITH CONTROL ctrl.

ENDLOOP.

I guess this will solve the problem for data duplication.

For the next issues (clear internal table one), I am not clear on that part. Could you please explain a bit more on it.

I guess you are not fetching the data in USER_COMMAND_9001. The internal table is filled from the previous screen or it is populated on some user action associated with some function code.

Hope you get my point. Let me know in case of any confusion.

Regards,

Tarun

Read only

Former Member
0 Likes
1,041

Hi Sneha,

In PAI

Loop at itab.

module modify_Tc.

endloop.

*---> Try to use the Module User Command after the Loop statement in PAI, Ofcourse it depends on the Requrement.

In program

module modify_tc.

DESCRIBE TABLE itab LINES lin.

IF tc-current_line > lin.

APPEND itab.

ELSE.

MODIFY itab INDEX tc-current_line.

ENDIF.

endmodule.

By the way what is in there in Module display Data2. ---> Check it out.

Cheers

Ram

Read only

Former Member
0 Likes
1,042

Hi try this...


  MODULE check_rpno INPUT.
  SELECT SINGLE
              zrpmno
                    FROM zivl_rpm
                    INTO z_rpmno
                    WHERE zrpmno = wa_rpmno-zrpmno1
                    AND   zpkey  = key.
  IF sy-subrc  0.
    MESSAGE e000 WITH text-003 wa_rpmno-zrpmno1.
  ELSEif ctrl-current_line < line_count and sy-cubrc = 0.                                                  
   MODIFY it_rpmno FROM wa_rpmno INDEX ctrl-current_line.  
elseif ctrl-current_line > line_count and sy-subrc = 0.
APPEND wa_rpmno TO it_rpmno.
  ENDIF.
 

cheers,

Mayank