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

Dynamic columns in table control

Former Member
0 Likes
2,234

hi,

I need to add some fields in table control in run time based on conditions given.I need to use CXTAB related ones.

Can anyone help me with some related codes with CXTAB.

Edited by: Ramya Ramya on Mar 8, 2011 11:21 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,252
PROCESS BEFORE OUTPUT.
module operation.
loop at i_vbap into wa_vbap with control tc.
 MODULE STATUS_0100.
 endloop.
module clear.


PROCESS AFTER INPUT.
loop at i_vbap.
module modify.

 endloop.
field VBAK-VBELN MODULE USER_COMMAND_0100 on request.
module sub.

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



include mzsanpracticetop                        .    " global Data

* INCLUDE MZSANPRACTICEO01                        .  " PBO-Modules
* INCLUDE MZSANPRACTICEI01                        .  " PAI-Modules
* INCLUDE MZSANPRACTICEF01                        .  " FORM-Routines

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

  move-corresponding wa_vbap to vbap.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

  case ok_code.
    when ''.

*if tc-lines ne tc-current_line.
      if  lv_lines  is initial.

        select vbeln
               erdat
               posnr
               matnr
               matwa
               matkl
               arktx
        from vbap
        into corresponding fields of table i_vbap
        where vbeln = vbak-vbeln.
*and  erdat = vbak-erdat.
        move : sy-dbcnt to tc-lines.

      endif.

    when 'SUB'.
      delete i_vbap where mark eq 'X'.
      tc-lines = tc-lines - tc-current_line.

  endcase.
endmodule.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  operation  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module operation output.
  describe table i_vbap lines lv_lines.
  if tc-lines eq 0.
    tc-lines = 1.
  endif.


endmodule.                 " operation  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  modify  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module modify input.

  clear lv_lines.
  describe table i_vbap lines lv_lines.
  if lv_lines ge tc-current_line.
    if wa_vbap-mark eq 'X'.
      v_index = tc-current_line .
    endif.
    modify i_vbap from wa_vbap index tc-current_line.
  else.
    if wa_vbap-mark eq 'X'.
      v_index = tc-current_line .
    endif.
    append wa_vbap to i_vbap.
    clear wa_vbap.
  endif.

endmodule.                 " modify  INPUT
*&---------------------------------------------------------------------*
*&      Module  clear  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module clear output.

  clear : ok_code,
          v_index.

endmodule.                 " clear  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  sub  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module sub input.
case ok_code.
 when 'SUB'.
      delete i_vbap where mark eq 'X'.
      tc-lines = tc-lines - tc-current_line.


            when 'ADD'.
*loop at i_vbap.
      if v_index is not initial.

        insert initial line into i_vbap index v_index.

      else.
        get cursor "  field v_fname
                   line  v_line
                   area  v_area.

        move : v_line to v_index.
        v_index = v_index + 1.
        insert initial line into i_vbap index v_index.

      endif.
*      endloop.

      tc-lines = lv_lines + 1.

  endcase.

endmodule.                 " sub  INPUT

understand and use it

hi,

I need to add some fields in table control in run time based on conditions given.I need to use CXTAB related ones.

Can anyone help me with some related codes with CXTAB.

Edited by: Ramya Ramya on Mar 8, 2011 11:21 AM

3 REPLIES 3
Read only

Former Member
0 Likes
1,253
PROCESS BEFORE OUTPUT.
module operation.
loop at i_vbap into wa_vbap with control tc.
 MODULE STATUS_0100.
 endloop.
module clear.


PROCESS AFTER INPUT.
loop at i_vbap.
module modify.

 endloop.
field VBAK-VBELN MODULE USER_COMMAND_0100 on request.
module sub.

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



include mzsanpracticetop                        .    " global Data

* INCLUDE MZSANPRACTICEO01                        .  " PBO-Modules
* INCLUDE MZSANPRACTICEI01                        .  " PAI-Modules
* INCLUDE MZSANPRACTICEF01                        .  " FORM-Routines

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

  move-corresponding wa_vbap to vbap.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

  case ok_code.
    when ''.

*if tc-lines ne tc-current_line.
      if  lv_lines  is initial.

        select vbeln
               erdat
               posnr
               matnr
               matwa
               matkl
               arktx
        from vbap
        into corresponding fields of table i_vbap
        where vbeln = vbak-vbeln.
*and  erdat = vbak-erdat.
        move : sy-dbcnt to tc-lines.

      endif.

    when 'SUB'.
      delete i_vbap where mark eq 'X'.
      tc-lines = tc-lines - tc-current_line.

  endcase.
endmodule.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  operation  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module operation output.
  describe table i_vbap lines lv_lines.
  if tc-lines eq 0.
    tc-lines = 1.
  endif.


endmodule.                 " operation  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  modify  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module modify input.

  clear lv_lines.
  describe table i_vbap lines lv_lines.
  if lv_lines ge tc-current_line.
    if wa_vbap-mark eq 'X'.
      v_index = tc-current_line .
    endif.
    modify i_vbap from wa_vbap index tc-current_line.
  else.
    if wa_vbap-mark eq 'X'.
      v_index = tc-current_line .
    endif.
    append wa_vbap to i_vbap.
    clear wa_vbap.
  endif.

endmodule.                 " modify  INPUT
*&---------------------------------------------------------------------*
*&      Module  clear  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module clear output.

  clear : ok_code,
          v_index.

endmodule.                 " clear  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  sub  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module sub input.
case ok_code.
 when 'SUB'.
      delete i_vbap where mark eq 'X'.
      tc-lines = tc-lines - tc-current_line.


            when 'ADD'.
*loop at i_vbap.
      if v_index is not initial.

        insert initial line into i_vbap index v_index.

      else.
        get cursor "  field v_fname
                   line  v_line
                   area  v_area.

        move : v_line to v_index.
        v_index = v_index + 1.
        insert initial line into i_vbap index v_index.

      endif.
*      endloop.

      tc-lines = lv_lines + 1.

  endcase.

endmodule.                 " sub  INPUT

understand and use it

Read only

anilsonesar
Explorer
0 Likes
1,252

Hi,

TC-COLS-VISLENGTH = 0 -- allows you to hide a column.

TC-COLS-INVISIBLE = 1 appears to have the same effect as VISLENGTH.

OR Try Following Steps..

u can have dynamic columns in an internal table.

declare as many columns as u like initially.

u can hide the display of the columns as and when u wish..

it is possible with the use of TYPE-POOLS cxtab.

declare TYPE-POOLS cxtab.

DATA v_tccols TYPE cxtab_column .

FIELD-SYMBOLS: <tc_cols> TYPE cxtab_control .

data tcname(25) type c.

assign table control name to tcname and assign tcname to tc_cols.

with this u can manipulate what ever columns u want to display or hide.

Thanks,

Regards,

Anil Sonesar.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,252

Hi,

It will be more easy for you if you use ALV for this purpose.

in se38 check for BCALVEDIT*