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

Former Member
0 Likes
1,016

Hi All,

Iam developing a table control.

i have a screen with 2 fields say for example empid and empname .if enter a value in empid and then if press enter then empname should be filled.

so please help me out how to do this.if possible plz send me a sample code .

with regards,

kiran i

12 REPLIES 12
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
990

These two fields are in a table control, right?

Regards,

Rich Heilman

Read only

0 Likes
990

Yes Rich.

Read only

0 Likes
990

If you used the table control wizard, then you probably have a module like this.



module itabcon_modify input.

<b>  if not itab-field1 is initial.
    concatenate 'This is the description for'
                 itab-field1 into itab-field2.
  endif.</b>

  modify itab
    index itabcon-current_line.

endmodule.

The code in BOLD is an example of how you would fill the other field. Here is where you would do it, whether it comes from the DB or not.

Regards,

RIch Heilman

Read only

0 Likes
990

iam not using wizard table control.send me some detailed code of this iam new to module poll programming

with regards,

krian.i

Read only

0 Likes
990

In the flow logic of your screen, you will need to have a loop like this, notice that it is executing the module that I described above.



  loop at ITAB.
    chain.
      field ITAB-FIELD1.
      field ITAB-FIELD2.
      module ITABCON_modify on chain-request.
    endchain.
  endloop.

Regards,

Rich Heilman

Read only

0 Likes
990

What i have to write for module itab_con_modify

Regards,

kirani

Read only

0 Likes
990

If you are writing a module pool, then put it in your include for PAI. It should probably end withh I01.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
990

Hi kiran,

Refer the below for a brief idea of how to code for a module pool program.

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

&----


*& Module pool ZTESTRAJ_TABLECONTROL *

*& *

&----


*& *

*& *

&----


PROGRAM ztestraj_tablecontrol .

TABLES mara.

CONTROLS : tc1 TYPE TABLEVIEW USING SCREEN 100.

TYPES : BEGIN OF t_mara,

matnr TYPE mara-matnr,

mtart TYPE mara-mtart,

mbrsh TYPE mara-mbrsh,

meins TYPE mara-meins,

lsel TYPE c,

END OF t_mara.

DATA : it_mara TYPE STANDARD TABLE OF t_mara WITH HEADER LINE,

it_mara1 TYPE STANDARD TABLE OF t_mara WITH HEADER LINE,

cols LIKE LINE OF tc1-cols.

DATA : v_lines TYPE i,

lsel,

v_fill TYPE i,

v_limit TYPE i.

DATA : fg_set TYPE c VALUE ''.

DATA : ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

CONSTANTS : c_mtart(4) TYPE c VALUE 'FERT'.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

SET TITLEBAR 'RAJ'.

IF fg_set = ''.

SELECT matnr

mtart

mbrsh

meins

FROM mara

INTO TABLE it_mara

WHERE mtart = c_mtart.

DESCRIBE TABLE it_mara LINES v_fill.

v_lines = v_fill.

fg_set = 'X'.

ENDIF.

IF fg_set = 'X'.

EXIT.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module fill_table_control OUTPUT

&----


  • text

----


MODULE fill_table_control OUTPUT.

READ TABLE it_mara INTO it_mara1 INDEX tc1-current_line.

ENDMODULE. " fill_table_control OUTPUT

&----


*& Module cancel INPUT

&----


  • text

----


MODULE cancel INPUT.

LEAVE PROGRAM.

ENDMODULE. " cancel INPUT

&----


*& Module read_table_control INPUT

&----


  • text

----


MODULE read_table_control INPUT.

v_lines = sy-loopc .

it_mara1-lsel = lsel.

MODIFY it_mara FROM it_mara1 INDEX tc1-current_line.

ENDMODULE. " read_table_control INPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

ok_code = sy-ucomm.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'NEXT_LINE'.

tc1-top_line = tc1-top_line + 1.

v_limit = v_fill - v_lines + 1.

IF tc1-top_line > v_limit.

tc1-top_line = v_limit.

ENDIF.

WHEN 'PREV_LINE'.

tc1-top_line = tc1-top_line - 1.

IF tc1-top_line < 0.

tc1-top_line = 0.

ENDIF.

WHEN 'NEXT_PAGE'.

tc1-top_line = tc1-top_line + v_lines.

v_limit = v_fill - v_lines + 1.

IF tc1-top_line > v_limit.

tc1-top_line = v_limit.

ENDIF.

WHEN 'PREV_PAGE'.

tc1-top_line = tc1-top_line - v_lines.

IF tc1-top_line < 0.

tc1-top_line = 0.

ENDIF.

WHEN 'LAST_PAGE'.

tc1-top_line = v_fill - v_lines + 1.

WHEN 'FIRST_PAGE'.

tc1-top_line = 0.

WHEN 'DELETE'.

READ TABLE tc1-cols INTO cols

WITH KEY screen-input = '1'.

IF sy-subrc = 0.

LOOP AT it_mara INTO it_mara1 WHERE lsel = 'X'.

DELETE it_mara.

fg_set = 'X'.

ENDLOOP.

ELSE.

fg_set = ''.

ENDIF.

WHEN 'INSERT'.

LOOP AT it_mara INTO it_mara1 WHERE lsel = 'X'.

INSERT INITIAL LINE INTO it_mara INDEX sy-tabix.

ENDLOOP.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

WHEN 'JADOO'.

READ TABLE tc1-cols INTO cols

WITH KEY selected = 'X'.

IF sy-subrc = 0.

cols-invisible = '1'.

MODIFY tc1-cols FROM cols INDEX sy-tabix.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

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

Regards,

Raj

Read only

0 Likes
990

Hi Rajasekhar,

Thanks for the reply.But my requirement is if i write in empid field and press enter then empid and emp name should be filled.

with regards,

kiran

Read only

Former Member
0 Likes
990

For enter,

case sy-ucomm.

when ' '.

Name = 'test'.

endcase.

Try this

Read only

0 Likes
990

Hi All,

Could any one of you help me out.In table control when iam enteringa value and pressing enter that is disappearing.how to restict that.

with regards,

kiran i

Read only

0 Likes
990

In the MODIFY module, do something like this.



  modify itab
    index itabcon-current_line.
if sy-subrc <> 0.
append itab.
endif.

Regards,

Rich Heilman