Application Development 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: 

table control

Former Member
0 Kudos
134

hi,

i have a requirement in which i hav to design 2 screens in table control..the first screen has an input field for material group and the second screen has the table control in which the all material numbers related to the material group(which has to be given in first screen) should be displayed.......now the issue is if the material group has no materials coressponding to it the table control should be input disabled and we need to insert initial line and we hav to enter record by record, so that v can add new material number for that material group.......

can anyone explain how to do it.....

4 REPLIES 4

I355602
Product and Topic Expert
Product and Topic Expert
0 Kudos
99

Hi,

When there is no material found for the specified material group, then the table control in displayed as input disabled.

Now as you need to add an editable line so that the user can add a material to the group.

So when you click ADD button on screen to add a single line which is editable then use:-

Keep all the field in table control as non-editable and also take group1 for all columns as ABC

So use code in PBO of the screen:-


DATA : line_count TYPE i,
       line_index TYPE i.

DESCRIBE TABLE itab
LINES line_count.

line_index = line_count + 1.

READ TABLE itab INDEX tab_ctrl-current_line.
  IF sy-subrc NE 0. " no record found then when user click ADD button add a new line
    IF sy-ucomm = 'ADD'.
      READ TABLE itab INDEX line_index.
        IF sy-subrc NE 0.
          LOOP AT SCREEN.
            IF screen-group1 = 'ABC'.
              screen-input = 1. "edit field for values
              screen-active = 1.
            ENDIF.
          ENDLOOP.
        ENDIF.
    ENDIF.
  ELSE.  "if record found then display as non-editable
    LOOP AT SCREEN.
      IF screen-group1 = 'ABC'.
        screen-input = 0. "display only
      ENDIF.
    ENDLOOP.    
  ENDIF.

Hope this helps you.

Regards,

Tarun

Mohamed_Mukhtar
Active Contributor
0 Kudos
99

hi,

Lets say you have screen number 100 (first screen for material group) and 101(screen for table control).

In Screen 100, define a input/output field that accepts material group( MGP)

in the flow logic of screen 100.

PROCESS BEFORE OUTPUT.
 *  MODULE status_100.

PROCESS AFTER INPUT.
 MODULE USER_COMMAND_100.

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

"here write a select query and fetch the data in a internal table (it_itab).
if ok_code = 'FCODE'
select * from <DBtable> into table it_itab where materialgroup = MGP.

" then call the screen which contains table control
Call Screen 101.
endif.

Define a table control in the screen 101.

in the flow logic of screen 101.

PROCESS BEFORE OUTPUT.
  MODULE status_101.
LOOP AT it_itab INTO wa_itab WITH CONTROL <Tablecontrol name>
                         
MODULE map_fields.
  ENDLOOP.

PROCESS AFTER INPUT.


*&---------------------------------------------------------------------*
*&      Module  status_101  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
" if it_itab is inital

if it_itab is inital.
" this will make ur table contol input disable
 LOOP AT SCREEN.
    CASE screen-name.
      WHEN <nameoftable control fields>.
        screen-input = 0.
       when 
        '
        '      
 ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.
endif.

*&---------------------------------------------------------------------*
*&      Module  map_fields  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
" if your internal table is not intial, display the values of internal table on to the table control

if it_itab is not initial.
Screenname = wa_itab-<f1>
'
'
'
endif.

" to insert the intial line
Go through the standard program ' RSDEMO02'

Hope it helps you.

Thanks & REgards

Former Member
0 Kudos
99

hi

for example

screen100

SE51 flow logic

process before output.

module status_100.

process after input.

loop with control control.

module read_table_control.

endloop.

module user_command_100.

process on value-request.

field wk_smatgrp module valuerequest_help.

&----


*& Module VALUEREQUEST_HELP INPUT

&----


  • text

----


module valuerequest_help input.

data : begin of it_tmp occurs 0,

mtgrp like mara-mtgrp,

end of it_tmp.

data: progname like sy-repid,

dynnum like sy-dynnr.

data : t_return like ddshretval occurs 0 with header line.

refresh it_tmp.

select mtgrp from mara client specified into it_tmp

where mandt = sy-mandt.

append it_tmp.

endselect.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'

exporting

retfield = 'MARA-MTGRP'

dynpprog = progname

dynpnr = dynnum

dynprofield = 'WK_SMATGRP'

value = 'MARA-MTGRP'

value_org = 'S'

tables

value_tab = it_tmp

return_tab = t_return.

if sy-subrc = 0.

read table t_return index 1.

condense t_return-fieldval.

wk_smatgrp = t_return-fieldval.

endif.

endmodule. " VALUEREQUEST_HELP INPUT

module read_table_control input.

IF wk_smatgrp IS NOT INITIAL.

select matnr mtart maktx from mara into table i_mara

where mtgrp = wk_smatgrp.

LEAVE TO SCREEN 200.

ELSE.

Error Message.

ENDIF.

endmodule. " READ_TABLE_CONTROL INPUT

screen200

SE51 flow logic

process before output.

module status_200.

loop with control control.

module fill_table_control.

endloop.

process after input.

loop with control control.

module read_table_control.

endloop.

module user_command_200.

&----


*& Module FILL_TABLE_CONTROL OUTPUT

&----


  • text

----


module fill_table_control output.

IF i_mara[ ] IS INITIAL.

loop at screen.

if screen-name = 'I_MARA-MATNR'.

screen-input = '0'.

modify screen.

endif.

if screen-name = 'I_MARA-MTART.

screen-input = '0'.

modify screen.

endif.

if screen-name = 'I_MARA-MAKTX.

screen-input = '0'.

modify screen.

endif.

endloop.

ELSE.

ENDIF.

describe table i_mara lines wk_no.

if wk_no is not initial.

read table i_mara into i_mara1 index control-current_line.

endif.

endmodule. " FILL_TABLE_CONTROL OUTPUT

Regards

Former Member
0 Kudos
99

hi

try this u will get surely

screen100

SE51 flow logic

process before output.

module status_100.

process after input.

loop with control control.

module read_table_control.

endloop.

module user_command_100.

process on value-request.

field wk_smatgrp module valuerequest_help.

&----


*& Module VALUEREQUEST_HELP INPUT

&----


text

-


module valuerequest_help input.

data : begin of it_tmp occurs 0,

mtgrp like mara-mtgrp,

end of it_tmp.

data: progname like sy-repid,

dynnum like sy-dynnr.

data : t_return like ddshretval occurs 0 with header line.

refresh it_tmp.

select mtgrp from mara client specified into it_tmp

where mandt = sy-mandt.

append it_tmp.

endselect.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'

exporting

retfield = 'MARA-MTGRP'

dynpprog = progname

dynpnr = dynnum

dynprofield = 'WK_SMATGRP'

value = 'MARA-MTGRP'

value_org = 'S'

tables

value_tab = it_tmp

return_tab = t_return.

if sy-subrc = 0.

read table t_return index 1.

condense t_return-fieldval.

wk_smatgrp = t_return-fieldval.

endif.

endmodule. " VALUEREQUEST_HELP INPUT

module read_table_control input.

IF wk_smatgrp IS NOT INITIAL.

select matnr mtart maktx from mara into table i_mara

where mtgrp = wk_smatgrp.

LEAVE TO SCREEN 200.

ELSE.

Error Message.

ENDIF.

endmodule. " READ_TABLE_CONTROL INPUT

screen200

SE51 flow logic

process before output.

module status_200.

loop with control control.

module fill_table_control.

endloop.

process after input.

loop with control control.

module read_table_control.

endloop.

module user_command_200.

&----


*& Module FILL_TABLE_CONTROL OUTPUT

&----


text

-


module fill_table_control output.

IF i_mara[ ] IS INITIAL.

loop at screen.

if screen-name = 'I_MARA-MATNR'.

screen-input = '0'.

modify screen.

endif.

if screen-name = 'I_MARA-MTART.

screen-input = '0'.

modify screen.

endif.

if screen-name = 'I_MARA-MAKTX.

screen-input = '0'.

modify screen.

endif.

endloop.

ELSE.

ENDIF.

if sy-ucomm = 'ADD'.

loop at screen.

if flag is initial.

screen-input = 0.

elseif ( flag eq 'Y' ).

if ( ( screen-name = 'I_MARA-MATNR' or

screen-name = 'I_MARA-MTART' or

screen-name

= 'I_MARA-MAKTX)

and control-current_line le lines ).

screen-input = 1.

else.

endif.

endif.

modify screen.

endloop.

ENDIF.

describe table i_mara lines wk_no.

if wk_no is not initial.

read table i_mara into i_mara1 index control-current_line.

endif.

endmodule. " FILL_TABLE_CONTROL OUTPUT

module user_command_200 input.

case sy-ucomm.

when 'ADD'.

flag = 'Y'.

endcase.

endmodule. " USER_COMMAND_200 INPUT