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 controle

Former Member
0 Likes
587

hi

i want to display output on table control, how to do this.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
550

Hello,

Check this sample

.
**********      Trancsaction code-  ‘zrtc’ **********************
***********     Default Screen- ‘1000’   ************************
 
PROGRAM ZRAVI_TABLECONTROL message-id zrtc.
*Displaying data from VBAP,VBAK and VBKD tables using table control
tables : VBAP,VBAK,VBKD.
controls : tab_cntrl type tableview using screen '2000'.
data : begin of it_sales occurs 0,
       vbeln like VBAP-vbeln,
       matnr like VBAP-matnr,
       erdat like VBAK-erdat,
       ernam like VBAK-ernam,
       auart like VBAK-auart,
       konda like VBKD-konda,
       kdgrp like VBKD-kdgrp,
       end of it_sales.
 data : l_count type i.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1000 INPUT.
case sy-ucomm.
  when 'SHOW'.
    if VBAP-MATNR ne ''.
      select vp~vbeln vp~matnr vk~erdat vk~ernam vk~auart vd~konda
      vd~kdgrp into corresponding fields of table it_sales from
      ( ( VBAP as vp inner join VBAK as vk on vp~vbeln = vk~vbeln )
      inner join VBKD as vd on vk~vbeln = vd~vbeln )
      where vp~matnr = VBAP-MATNR.
   else.
       select vp~vbeln vp~matnr vk~erdat vk~ernam vk~auart vd~konda
      vd~kdgrp into corresponding fields of table it_sales from
      ( ( VBAP as vp inner join VBAK as vk on vp~vbeln = vk~vbeln )
      inner join VBKD as vd on vk~vbeln = vd~vbeln ).
   endif.
**   leave to list-processing.
**   *For testing the query
**   loop at it_sales.
**     write : / it_sales-matnr.
**   endloop.
**  *End testing of query
     call screen '2000'.
   when 'EXIT'.
     leave program.
endcase.
 
ENDMODULE.                 " USER_COMMAND_1000  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  STATUS_2000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_2000 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'Sales Document Information'.
 
ENDMODULE.                 " STATUS_2000  OUTPUT
 
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_2000 INPUT.
  case sy-ucomm.
    when 'BACK'.
      leave to screen '1000'.
    when 'P--'.
      perform paging using 'P--'.
    when 'P-'.
      perform paging using 'P-'.
    when 'P+'.
      perform paging using 'P+'.
    when 'P++'.
      perform paging using 'P++'.
  endcase.
ENDMODULE.                 " USER_COMMAND_2000  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  GET_CTRL_SALES  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_CTRL_SALES INPUT.
  case sy-ucomm.
    when 'SAVE'.
    data : line_count type i value 0.
        modify it_sales index tab_cntrl-current_line.
        line_count = line_count + 1.
*      *VBAP,VBAK and VBKD tables
*           vbeln like VBAP-vbeln,
*           matnr like VBAP-matnr,
*           erdat like VBAK-erdat,
*           ernam like VBAK-ernam,
*           auart like VBAK-auart,
*           konda like VBKD-konda,
*           kdgrp like VBKD-kdgrp,
*      update VBAP set vbeln = it_sales
*       if sy-subrc = 0.message i001.endif.
         IF SY-SUBRC = 0 AND SY-TABIX > LINE_COUNT.
         MESSAGE E001 WITH LINE_COUNT.
*         STOP.
         ENDIF.
*LEAVE TO LIST-PROCESSING.
*WRITE : 'TABIX',SY-INDEX,'LINE',LINE_COUNT.
  endcase.
ENDMODULE.                 " GET_CTRL_SALES  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  FILL_TAB_CNTRL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE FILL_TAB_CNTRL OUTPUT.
  read table it_sales index tab_cntrl-current_line.
  l_count = sy-loopc.
*  leave to list-processing.
*  write : l_count,tab_cntrl-top_line.
  if sy-subrc ne 0.exit from step-loop.endif.
ENDMODULE.                 " FILL_TAB_CNTRL  OUTPUT
 
*&---------------------------------------------------------------------*
*&      Module  GET_MESSAGE  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_MESSAGE INPUT.
*        if sy-subrc = 0.
*        message i001 with line_count.
*        endif.
 ENDMODULE.                 " GET_MESSAGE  INPUT
 
*&---------------------------------------------------------------------*
*&      Form  PAGING
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0189   text
*----------------------------------------------------------------------*
FORM PAGING USING    code.
  data : i type i,
         j type i.
  case code.
    when 'P--'.
      TAB_CNTRL-top_line = 1.
    when 'P-'.
      TAB_CNTRL-top_line = TAB_CNTRL-top_line - l_count.
      message i001.
      if TAB_CNTRL-top_line le 0.
        TAB_CNTRL-top_line = 1.
      endif.
    when 'P+'.
      i = TAB_CNTRL-top_line + l_count.
      j = TAB_CNTRL-lines - l_count + 1.
      if j le 0.j = 1.endif.
      if i le j.
        TAB_CNTRL-top_line = i.
      else.
        TAB_CNTRL-top_line = j.
      endif.
    when 'P++'.
      TAB_CNTRL-top_line  = TAB_CNTRL-lines - l_count + 1.
      if TAB_CNTRL-top_line le 0.
        TAB_CNTRL-top_line = 1.
      endif.
  endcase.
 
ENDFORM.                    " PAGING
 
*&---------------------------------------------------------------------*
*&      Module  INIT_CONTROL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE INIT_CONTROL OUTPUT.
  TAB_CNTRL-top_line = 1.
ENDMODULE.                 " INIT_CONTROL  OUTPUT
 
 
 
 
 
 
**********************    flow logic of  screen ‘2000’  ********************
 
PROCESS BEFORE OUTPUT.
MODULE STATUS_2000.
module init_control.
loop with control tab_cntrl.
  module fill_tab_cntrl.
endloop.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_2000.
loop with control tab_cntrl.
  field SEL module get_ctrl_sales on input.
endloop.
*module get_message.
 
******************** End of flow logic  ************************
 



If useful reward.

VAsanth 

4 REPLIES 4
Read only

Former Member
0 Likes
550

hi,

Refer to this related thread

Read only

Former Member
0 Likes
550

Create a table control and add the columns u want to display...

Declare the table control in your Top include as --

CONTROLS control name TYPE TABLE VIEW USING SCREEN screen number.

Then in PBO loop at your internal table and pass the contents to screen fields...

U need to write LOOP... ENDLOOP in PAI as well.

Reward points if useful.

Read only

Former Member
0 Likes
551

Hello,

Check this sample

.
**********      Trancsaction code-  ‘zrtc’ **********************
***********     Default Screen- ‘1000’   ************************
 
PROGRAM ZRAVI_TABLECONTROL message-id zrtc.
*Displaying data from VBAP,VBAK and VBKD tables using table control
tables : VBAP,VBAK,VBKD.
controls : tab_cntrl type tableview using screen '2000'.
data : begin of it_sales occurs 0,
       vbeln like VBAP-vbeln,
       matnr like VBAP-matnr,
       erdat like VBAK-erdat,
       ernam like VBAK-ernam,
       auart like VBAK-auart,
       konda like VBKD-konda,
       kdgrp like VBKD-kdgrp,
       end of it_sales.
 data : l_count type i.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1000 INPUT.
case sy-ucomm.
  when 'SHOW'.
    if VBAP-MATNR ne ''.
      select vp~vbeln vp~matnr vk~erdat vk~ernam vk~auart vd~konda
      vd~kdgrp into corresponding fields of table it_sales from
      ( ( VBAP as vp inner join VBAK as vk on vp~vbeln = vk~vbeln )
      inner join VBKD as vd on vk~vbeln = vd~vbeln )
      where vp~matnr = VBAP-MATNR.
   else.
       select vp~vbeln vp~matnr vk~erdat vk~ernam vk~auart vd~konda
      vd~kdgrp into corresponding fields of table it_sales from
      ( ( VBAP as vp inner join VBAK as vk on vp~vbeln = vk~vbeln )
      inner join VBKD as vd on vk~vbeln = vd~vbeln ).
   endif.
**   leave to list-processing.
**   *For testing the query
**   loop at it_sales.
**     write : / it_sales-matnr.
**   endloop.
**  *End testing of query
     call screen '2000'.
   when 'EXIT'.
     leave program.
endcase.
 
ENDMODULE.                 " USER_COMMAND_1000  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  STATUS_2000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_2000 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'Sales Document Information'.
 
ENDMODULE.                 " STATUS_2000  OUTPUT
 
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_2000 INPUT.
  case sy-ucomm.
    when 'BACK'.
      leave to screen '1000'.
    when 'P--'.
      perform paging using 'P--'.
    when 'P-'.
      perform paging using 'P-'.
    when 'P+'.
      perform paging using 'P+'.
    when 'P++'.
      perform paging using 'P++'.
  endcase.
ENDMODULE.                 " USER_COMMAND_2000  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  GET_CTRL_SALES  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_CTRL_SALES INPUT.
  case sy-ucomm.
    when 'SAVE'.
    data : line_count type i value 0.
        modify it_sales index tab_cntrl-current_line.
        line_count = line_count + 1.
*      *VBAP,VBAK and VBKD tables
*           vbeln like VBAP-vbeln,
*           matnr like VBAP-matnr,
*           erdat like VBAK-erdat,
*           ernam like VBAK-ernam,
*           auart like VBAK-auart,
*           konda like VBKD-konda,
*           kdgrp like VBKD-kdgrp,
*      update VBAP set vbeln = it_sales
*       if sy-subrc = 0.message i001.endif.
         IF SY-SUBRC = 0 AND SY-TABIX > LINE_COUNT.
         MESSAGE E001 WITH LINE_COUNT.
*         STOP.
         ENDIF.
*LEAVE TO LIST-PROCESSING.
*WRITE : 'TABIX',SY-INDEX,'LINE',LINE_COUNT.
  endcase.
ENDMODULE.                 " GET_CTRL_SALES  INPUT
 
*&---------------------------------------------------------------------*
*&      Module  FILL_TAB_CNTRL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE FILL_TAB_CNTRL OUTPUT.
  read table it_sales index tab_cntrl-current_line.
  l_count = sy-loopc.
*  leave to list-processing.
*  write : l_count,tab_cntrl-top_line.
  if sy-subrc ne 0.exit from step-loop.endif.
ENDMODULE.                 " FILL_TAB_CNTRL  OUTPUT
 
*&---------------------------------------------------------------------*
*&      Module  GET_MESSAGE  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_MESSAGE INPUT.
*        if sy-subrc = 0.
*        message i001 with line_count.
*        endif.
 ENDMODULE.                 " GET_MESSAGE  INPUT
 
*&---------------------------------------------------------------------*
*&      Form  PAGING
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0189   text
*----------------------------------------------------------------------*
FORM PAGING USING    code.
  data : i type i,
         j type i.
  case code.
    when 'P--'.
      TAB_CNTRL-top_line = 1.
    when 'P-'.
      TAB_CNTRL-top_line = TAB_CNTRL-top_line - l_count.
      message i001.
      if TAB_CNTRL-top_line le 0.
        TAB_CNTRL-top_line = 1.
      endif.
    when 'P+'.
      i = TAB_CNTRL-top_line + l_count.
      j = TAB_CNTRL-lines - l_count + 1.
      if j le 0.j = 1.endif.
      if i le j.
        TAB_CNTRL-top_line = i.
      else.
        TAB_CNTRL-top_line = j.
      endif.
    when 'P++'.
      TAB_CNTRL-top_line  = TAB_CNTRL-lines - l_count + 1.
      if TAB_CNTRL-top_line le 0.
        TAB_CNTRL-top_line = 1.
      endif.
  endcase.
 
ENDFORM.                    " PAGING
 
*&---------------------------------------------------------------------*
*&      Module  INIT_CONTROL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE INIT_CONTROL OUTPUT.
  TAB_CNTRL-top_line = 1.
ENDMODULE.                 " INIT_CONTROL  OUTPUT
 
 
 
 
 
 
**********************    flow logic of  screen ‘2000’  ********************
 
PROCESS BEFORE OUTPUT.
MODULE STATUS_2000.
module init_control.
loop with control tab_cntrl.
  module fill_tab_cntrl.
endloop.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_2000.
loop with control tab_cntrl.
  field SEL module get_ctrl_sales on input.
endloop.
*module get_message.
 
******************** End of flow logic  ************************
 



If useful reward.

VAsanth 

Read only

Former Member
0 Likes
550

THANKS A LOT.