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 basic

Former Member
0 Likes
907

I have a table control with input enabled fields. When I enter some values and press ENTER, the values just disppear. How do I code in PAI to keep the values?

Thank You all,

Chandni

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
876

You need to modify the line when it has changed. Your flow logic should look something like this. Noice the code in BOLD. This is actually modifying your itab from the table control.




PROCESS BEFORE OUTPUT.

* PBO FLOW LOGIC FOR TABLECONTROL 'TABCON102'
* MODULE TABCON102_CHANGE_TC_ATTR.
* MODULE TABCON102_CHANGE_COL_ATTR.
  LOOP AT   PLT_ITAB
       WITH CONTROL TABCON102
       CURSOR TABCON102-CURRENT_LINE.
*   MODULE TABCON102_CHANGE_FIELD_ATTR
  ENDLOOP.
* MODULE STATUS_0102.
  MODULE MODIFY_SCREEN_102.

PROCESS AFTER INPUT.

* PAI FLOW LOGIC FOR TABLECONTROL 'TABCON102'
<b>  LOOP AT PLT_ITAB.
    CHAIN.
      FIELD  PLT_ITAB-CHECK.
      FIELD  PLT_ITAB-WERKS.
      FIELD  PLT_ITAB-LGORT.
      FIELD  PLT_ITAB-TEXT.

      MODULE TABCON102_MODIFY ON CHAIN-REQUEST.
    ENDCHAIN.
  ENDLOOP.</b>
* MODULE TABCON102_CHANGE_TC_ATTR.
* MODULE TABCON102_CHANGE_COL_ATTR.
 MODULE USER_COMMAND_0102.


The TABCON102_MODIFY module looks like this.



MODULE TABCON102_MODIFY INPUT.

  MODIFY PLT_ITAB INDEX TABCON102-CURRENT_LINE.

ENDMODULE.



Here PLT_ITAB is the internal table associated with the table control and TABCON102 is the name of the table control.

Regards,

Rich Heilman

8 REPLIES 8
Read only

Former Member
0 Likes
876

In the PAI, you have to modify the internal table which u r using in the table control with the data entered.

Check the sample code:

PROCESS AFTER INPUT.

*pai flow logic for tablecontrol 'MPRN'

LOOP AT i_mprn.

CHAIN.

FIELD: i_mprn-select,

i_mprn-mprn,

i_mprn-post_code,

i_mprn-dm_ndm

MODULE validate_mprn.

ENDCHAIN.

MODULE tabctrl_modify.

ENDLOOP.

&----


*& Module tabctrl_modify INPUT

&----


  • text

----


MODULE tabctrl_modify INPUT.

MODIFY i_mprn INDEX mprn-current_line

TRANSPORTING mprn post_code dm_ndm

select.

IF sy-subrc EQ 4.

APPEND i_mprn.

ENDIF.

ENDMODULE. " tabctrl_modify INPUT

Prakash.

Message was edited by: Prakash Ramu

Read only

Former Member
0 Likes
876

In the PAI while you loop the table control move data in your table control to an internal table.

In the PBO while you loop the table control move data in the internal table to the table control.

I hope his helps,

Aubin

Read only

Former Member
0 Likes
876

Hi,

Whenever you insert the records into the table control, you need to pass these values to the related internal table and append it, this internal table should be used in the PBO and PAI event as loop, i mean Loop at ITAB controls <Control name>, so the internal table will have the valuse intered in table control, so whenever you press the enter button the PBO and PAI will be triggerd and show them in the Table control

mark all the helpful answers

Regards

Sudheer

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
877

You need to modify the line when it has changed. Your flow logic should look something like this. Noice the code in BOLD. This is actually modifying your itab from the table control.




PROCESS BEFORE OUTPUT.

* PBO FLOW LOGIC FOR TABLECONTROL 'TABCON102'
* MODULE TABCON102_CHANGE_TC_ATTR.
* MODULE TABCON102_CHANGE_COL_ATTR.
  LOOP AT   PLT_ITAB
       WITH CONTROL TABCON102
       CURSOR TABCON102-CURRENT_LINE.
*   MODULE TABCON102_CHANGE_FIELD_ATTR
  ENDLOOP.
* MODULE STATUS_0102.
  MODULE MODIFY_SCREEN_102.

PROCESS AFTER INPUT.

* PAI FLOW LOGIC FOR TABLECONTROL 'TABCON102'
<b>  LOOP AT PLT_ITAB.
    CHAIN.
      FIELD  PLT_ITAB-CHECK.
      FIELD  PLT_ITAB-WERKS.
      FIELD  PLT_ITAB-LGORT.
      FIELD  PLT_ITAB-TEXT.

      MODULE TABCON102_MODIFY ON CHAIN-REQUEST.
    ENDCHAIN.
  ENDLOOP.</b>
* MODULE TABCON102_CHANGE_TC_ATTR.
* MODULE TABCON102_CHANGE_COL_ATTR.
 MODULE USER_COMMAND_0102.


The TABCON102_MODIFY module looks like this.



MODULE TABCON102_MODIFY INPUT.

  MODIFY PLT_ITAB INDEX TABCON102-CURRENT_LINE.

ENDMODULE.



Here PLT_ITAB is the internal table associated with the table control and TABCON102 is the name of the table control.

Regards,

Rich Heilman

Read only

0 Likes
876

Hi Rich,

My code looks very similar ro your code, I guess. But, it aint doing the thing I want. When I press ENTER, the values are gone from table control. Do I need to write any code for Function code ENTR ( ok_code = ENTR)?

Here is my code:

<b>PROCESS BEFORE OUTPUT.</b>

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TC1'

  • MODULE TC1_CHANGE_TC_ATTR.

*&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.

LOOP AT IT_TC

WITH CONTROL TC1

CURSOR TC1-CURRENT_LINE.

  • MODULE TC1_GET_LINES.

*&SPWIZARD: MODULE TC1_CHANGE_FIELD_ATTR

ENDLOOP.

MODULE STATUS_0100.

*

<b>PROCESS AFTER INPUT.</b>

*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC1'

LOOP AT IT_TC.

CHAIN.

FIELD IT_TC-QMNUM.

FIELD IT_TC-AUFNR.

FIELD IT_TC-EQUNR.

FIELD IT_TC-KTEXT.

FIELD IT_TC-PRIOKX.

FIELD IT_TC-GSUZS.

FIELD IT_TC-GSTRS.

FIELD IT_TC-KURZTEXT.

FIELD IT_TC-TXT30.

FIELD IT_TC-ERNAM.

FIELD IT_TC-EQKTX.

FIELD IT_TC-NAME.

MODULE TC1_MODIFY ON CHAIN-REQUEST.

endchain.

  • FIELD IT_TC-SNO

  • MODULE TC1_MARK ON REQUEST.

ENDLOOP.

MODULE TC1_USER_COMMAND.

*&SPWIZARD: MODULE TC1_CHANGE_TC_ATTR.

*&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.

MODULE USER_COMMAND_0100.

<b><u>Here is the Code for MODULE modify:</u></b>

*&SPWIZARD: INPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: MODIFY TABLE

MODULE tc1_modify INPUT.

MODIFY it_tc

INDEX tc1-current_line.

ENDMODULE. "TC1_MODIFY INPUT

Read only

0 Likes
876

You shouldn't need to code anything for enter. Are you doing a refresh in the PAI anywhere?

REgards,

RIch Heilman

Read only

0 Likes
876

I'm sorry, I was looking at the wrong program in my system. You need to do what Prakash has suggested above, in the MODIFY module, if the modify statement fails, you need to APPEND the line.

For example, you can see here, first I'm trying to modify the line, this will be good for when a line already exists but the user has changed something on the line, also notice the next code, if the plant doesn't exist in the table control already, it APPENDs the line to the table.

module i_brcapcon_modify input.

  modify i_brcap index i_brcapcon-current_line.

  if i_brcap-werks is initial.
    delete i_brcap index i_brcapcon-current_line.
  else.
    select single * from t001w
                 where werks = i_brcap-werks.
    if sy-subrc <> 0.
      message e006.
    else.
<b>      read table i_brcap with key werks = i_brcap-werks.
      if sy-subrc = 0.
*        MESSAGE E007.
      else.
        append i_brcap.
      endif.</b>
    endif.
  endif.

endmodule.

Regards,

RIch Heilman

Read only

0 Likes
876

Thanks Rich. This surely helps!!