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

Module Pool

Former Member
0 Likes
1,272

Hi Guru,

I am facing one problem in module pool. I am giving on e table control at selection screen. When I am filling the rows in that and pressing ENTER all values disappear. So please help me how i have to proceed. I am using table control.

Maximum point will be rewarded.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,235

Hi,

what is your requirement.

In the flow logic, write loop endloop for table control. In that loop write module and in that module you can get the values.

regards,

mahantesh

12 REPLIES 12
Read only

Former Member
0 Likes
1,236

Hi,

what is your requirement.

In the flow logic, write loop endloop for table control. In that loop write module and in that module you can get the values.

regards,

mahantesh

Read only

0 Likes
1,235

Hi,

My requirement is this I am crating one table control. This table control contains multiple rows. So if I am filling one row and press ENTER the values which I have filled disappear.

So for that how to do coding.

So please help me.

Read only

0 Likes
1,235

Hi,

Have you defined the internal table of the same structure of table control?

Define the internal table of the same structure of table control and then use this internal table to display on screen. At initial as no values in the table, then no values will be displayed on screen.

And after changing on the screen and pressing the enter keys you will get the entered values in the same internal table. Again control will go to PBO and the updated internal table will be displayed i.e. the alues those you have entered n the screen will not be disappeared.

And do not clear the internal table in the PBO or PAI.

Feel free to ask if you any more queris.

regards,

mahantesh.

Read only

0 Likes
1,235

Hi,

Thanks a lot for your reply.

I have done accordingly as you suggested. For table contril I defined one internal table and I used that internal table in my table control. In my table control PAI module I am moving the values of internal table into table control table. I am not clearing any table. But when I enter the row gets disappear.

Please sugest me.

Read only

0 Likes
1,235

hi,

have u created ur table control from internal table?

write like this

In PAI make one module

PROCESS AFTER INPUT.

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

LOOP AT itab.

CHAIN.

FIELD itab-matnr.

FIELD itab-meins.

MODULE tab1_modify ON CHAIN-REQUEST.

ENDCHAIN.

ENDLOOP.

and write this in that module...

MODULE tab1_modify INPUT.

APPEND itab.

ENDMODULE. "TAB1_MODIFY INPUT

here itab is my internal table from which i created table control named tab1

reward if usefull

Read only

0 Likes
1,235

Hi,

You just need to define the internal table of the same as table control.

Don't move the data from anywhere to anywhere.

In PBO you just use the loop end loop for the internal table with table control.

In PAI you will get the input values in the internal table automatically.

Don't clear this table. In PBO this table will be displayed because of loop endloop with table control.

If you are still getting the problem, i will give code for the same.

regards,

mahantesh

Read only

0 Likes
1,235

Hi ,

I am doing like this.

PROCESS AFTER INPUT.

loop at ITAB_CRHD.

chain.

field WA_CRHD-ARBPL.

field WA_CRHD-VERSN.

field WA_CRHD-DATUV.

field WA_CRHD-DATUB.

field WA_CRHD-BEGZT.

field WA_CRHD-ENDZT.

field WA_CRHD-PAUSE.

field WA_CRHD-NGRAD.

field WA_CRHD-ANZHL.

module ZTBL2_GARG_modify on chain-request.

endchain.

endloop.

MODULE ztbl2_garg_modify INPUT.

MOVE-CORRESPONDING wa_crhd TO g_ztbl2_garg_wa.

APPEND g_ztbl2_garg_wa TO g_ztbl2_garg_itab.

ENDMODULE.

Thanks.

Read only

0 Likes
1,235

Hi,

Let me know the PBO code with module logic.

Also let me know the code that you used for module ZTBL2_GARG_modify.

regards,

mahantesh

Read only

0 Likes
1,235

Hi ,

This code is for ztbl_garg_modify.

MODULE ztbl2_garg_modify INPUT.

MOVE-CORRESPONDING wa_crhd TO g_ztbl2_garg_wa.

APPEND g_ztbl2_garg_wa TO g_ztbl2_garg_itab.

  • modify ITAB_CRHD

  • from WA_CRHD

  • index ZTBL2_GARG-current_line.

ENDMODULE.

This code is for PBO MODULE.

Report ztest_cro2 message-id z01.

INCLUDE ztest_cr02_top.

CALL SCREEN '200'.

*&spwizard: declaration of tablecontrol 'ZTBL2_GARG' itself

CONTROLS: ztbl2_garg TYPE TABLEVIEW USING SCREEN 0200.

*&spwizard: lines of tablecontrol 'ZTBL2_GARG'

DATA: g_ztbl2_garg_lines LIKE sy-loopc.

DATA: ok_code LIKE sy-ucomm.

*&spwizard: output module for tc 'ZTBL2_GARG'. do not change this line!

*&spwizard: update lines for equivalent scrollbar

MODULE ztbl2_garg_change_tc_attr OUTPUT.

DESCRIBE TABLE itab_crhd LINES ztbl2_garg-lines.

  • *********

ztbl2_garg-lines = ztbl2_garg-lines + 50.

**********

ENDMODULE.

*&spwizard: output module for tc 'ZTBL2_GARG'. do not change this line!

*&spwizard: get lines of tablecontrol

MODULE ztbl2_garg_get_lines OUTPUT.

  • ****insertion SGARG

SET PF-STATUS 'MENU'.

        • end sgarg insertion

g_ztbl2_garg_lines = sy-loopc.

ENDMODULE.

*&spwizard: input module for tc 'ZTBL2_GARG'. do not change this line!

*&spwizard: modify table

MODULE ztbl2_garg_modify INPUT.

MOVE-CORRESPONDING wa_crhd TO g_ztbl2_garg_wa.

APPEND g_ztbl2_garg_wa TO g_ztbl2_garg_itab.

  • modify ITAB_CRHD

  • from WA_CRHD

  • index ZTBL2_GARG-current_line.

ENDMODULE.

*&spwizard: input module for tc 'ZTBL2_GARG'. do not change this line!

*&spwizard: process user command

MODULE ztbl2_garg_user_command INPUT.

ok_code = sy-ucomm.

PERFORM user_ok_tc USING 'ZTBL2_GARG'

'ITAB_CRHD'

' '

CHANGING ok_code.

sy-ucomm = ok_code.

ENDMODULE.

----


  • INCLUDE TABLECONTROL_FORMS *

----


&----


*& Form USER_OK_TC *

&----


FORM user_ok_tc USING p_tc_name TYPE dynfnam

p_table_name

p_mark_name

CHANGING p_ok LIKE sy-ucomm.

-BEGIN OF LOCAL DATA----


DATA: l_ok TYPE sy-ucomm,

l_offset TYPE i.

-END OF LOCAL DATA----


  • Table control specific operations *

  • evaluate TC name and operations *

SEARCH p_ok FOR p_tc_name.

IF sy-subrc <> 0.

EXIT.

ENDIF.

l_offset = strlen( p_tc_name ) + 1.

l_ok = p_ok+l_offset.

  • execute general and TC specific operations *

CASE l_ok.

WHEN 'INSR'. "insert row

PERFORM fcode_insert_row USING p_tc_name

p_table_name.

CLEAR p_ok.

WHEN 'DELE'. "delete row

PERFORM fcode_delete_row USING p_tc_name

p_table_name

p_mark_name.

CLEAR p_ok.

WHEN 'P--' OR "top of list

'P-' OR "previous page

'P+' OR "next page

'P++'. "bottom of list

PERFORM compute_scrolling_in_tc USING p_tc_name

l_ok.

CLEAR p_ok.

  • WHEN 'L--'. "total left

  • PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.

*

  • WHEN 'L-'. "column left

  • PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.

*

  • WHEN 'R+'. "column right

  • PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.

*

  • WHEN 'R++'. "total right

  • PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.

*

WHEN 'MARK'. "mark all filled lines

PERFORM fcode_tc_mark_lines USING p_tc_name

p_table_name

p_mark_name .

CLEAR p_ok.

WHEN 'DMRK'. "demark all filled lines

PERFORM fcode_tc_demark_lines USING p_tc_name

p_table_name

p_mark_name .

CLEAR p_ok.

  • WHEN 'SASCEND' OR

  • 'SDESCEND'. "sort column

  • PERFORM FCODE_SORT_TC USING P_TC_NAME

  • l_ok.

ENDCASE.

ENDFORM. " USER_OK_TC

&----


*& Form FCODE_INSERT_ROW *

&----


FORM fcode_insert_row

USING p_tc_name TYPE dynfnam

p_table_name .

-BEGIN OF LOCAL DATA----


DATA l_lines_name LIKE feld-name.

DATA l_selline LIKE sy-stepl.

DATA l_lastline TYPE i.

DATA l_line TYPE i.

DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <lines> TYPE i.

-END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

  • get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

  • get looplines of TableControl

CONCATENATE 'G_' p_tc_name '_LINES' INTO l_lines_name.

ASSIGN (l_lines_name) TO <lines>.

  • get current line

GET CURSOR LINE l_selline.

IF sy-subrc <> 0. " append line to table

l_selline = <tc>-lines + 1.

*&SPWIZARD: set top line and new cursor line *

IF l_selline > <lines>.

<tc>-top_line = l_selline - <lines> + 1 .

ELSE.

<tc>-top_line = 1.

ENDIF.

ELSE. " insert line into table

l_selline = <tc>-top_line + l_selline - 1.

l_lastline = <tc>-top_line + <lines> - 1.

ENDIF.

*&SPWIZARD: set new cursor line *

l_line = l_selline - <tc>-top_line + 1.

  • insert initial line

INSERT INITIAL LINE INTO <table> INDEX l_selline.

<tc>-lines = <tc>-lines + 1.

  • set cursor

SET CURSOR LINE l_line.

ENDFORM. " FCODE_INSERT_ROW

&----


*& Form FCODE_DELETE_ROW *

&----


FORM fcode_delete_row

USING p_tc_name TYPE dynfnam

p_table_name

p_mark_name .

-BEGIN OF LOCAL DATA----


DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <wa>.

FIELD-SYMBOLS <mark_field>.

-END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

  • get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

  • delete marked lines *

DESCRIBE TABLE <table> LINES <tc>-lines.

LOOP AT <table> ASSIGNING <wa>.

  • access to the component 'FLAG' of the table header *

ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.

IF <mark_field> = 'X'.

DELETE <table> INDEX syst-tabix.

IF sy-subrc = 0.

<tc>-lines = <tc>-lines - 1.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " FCODE_DELETE_ROW

&----


*& Form COMPUTE_SCROLLING_IN_TC

&----


  • text

----


  • -->P_TC_NAME name of tablecontrol

  • -->P_OK ok code

----


FORM compute_scrolling_in_tc USING p_tc_name

p_ok.

-BEGIN OF LOCAL DATA----


DATA l_tc_new_top_line TYPE i.

DATA l_tc_name LIKE feld-name.

DATA l_tc_lines_name LIKE feld-name.

DATA l_tc_field_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <lines> TYPE i.

-END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

  • get looplines of TableControl

CONCATENATE 'G_' p_tc_name '_LINES' INTO l_tc_lines_name.

ASSIGN (l_tc_lines_name) TO <lines>.

  • is no line filled? *

IF <tc>-lines = 0.

  • yes, ... *

l_tc_new_top_line = 1.

ELSE.

  • no, ... *

CALL FUNCTION 'SCROLLING_IN_TABLE'

EXPORTING

entry_act = <tc>-top_line

entry_from = 1

entry_to = <tc>-lines

last_page_full = 'X'

loops = <lines>

ok_code = p_ok

overlapping = 'X'

IMPORTING

entry_new = l_tc_new_top_line

EXCEPTIONS

  • NO_ENTRY_OR_PAGE_ACT = 01

  • NO_ENTRY_TO = 02

  • NO_OK_CODE_OR_PAGE_GO = 03

OTHERS = 0.

ENDIF.

  • get actual tc and column *

GET CURSOR FIELD l_tc_field_name

AREA l_tc_name.

IF syst-subrc = 0.

IF l_tc_name = p_tc_name.

  • set actual column *

SET CURSOR FIELD l_tc_field_name LINE 1.

ENDIF.

ENDIF.

  • set the new top line *

<tc>-top_line = l_tc_new_top_line.

ENDFORM. " COMPUTE_SCROLLING_IN_TC

&----


*& Form FCODE_TC_MARK_LINES

&----


  • marks all TableControl lines

----


  • -->P_TC_NAME name of tablecontrol

----


FORM fcode_tc_mark_lines USING p_tc_name

p_table_name

p_mark_name.

-BEGIN OF LOCAL DATA----


DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <wa>.

FIELD-SYMBOLS <mark_field>.

-END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

  • get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

  • mark all filled lines *

LOOP AT <table> ASSIGNING <wa>.

  • access to the component 'FLAG' of the table header *

ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.

<mark_field> = 'X'.

ENDLOOP.

ENDFORM. "fcode_tc_mark_lines

&----


*& Form FCODE_TC_DEMARK_LINES

&----


  • demarks all TableControl lines

----


  • -->P_TC_NAME name of tablecontrol

----


FORM fcode_tc_demark_lines USING p_tc_name

p_table_name

p_mark_name .

-BEGIN OF LOCAL DATA----


DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <wa>.

FIELD-SYMBOLS <mark_field>.

-END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

  • get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

  • demark all filled lines *

LOOP AT <table> ASSIGNING <wa>.

  • access to the component 'FLAG' of the table header *

ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.

<mark_field> = space.

ENDLOOP.

ENDFORM. "fcode_tc_mark_lines

&----


*& Module itab_refresh INPUT

&----


  • text

----


MODULE itab_refresh INPUT.

REFRESH itab_crhd.

ENDMODULE. " itab_refresh INPUT

INCLUDE ztest_cro2_user_command.

INCLUDE ztest_perform.

&----


*& Module validation INPUT

&----


  • Validation

----


*MODULE validation INPUT.

*

  • DATA: lv_werks TYPE t001w-werks.

*

  • SELECT SINGLE werks FROM t001w INTO lv_werks

  • WHERE werks = p_werks.

*

  • IF sy-subrc NE 0.

*

  • MESSAGE e121.

*

  • endif.

*

  • ENDMODULE. " validation INPUT

&----


*& Module validation INPUT

&----


  • text

----


*module validation input.

*SELECT SINGLE werks FROM t001w INTO l_werks

  • WHERE werks = p_werks.

*

  • IF sy-subrc NE 0.

*

  • MESSAGE e121.

*

  • endif.

*

*endmodule. " validation INPUT

Edited by: Sandeep Garg on May 9, 2008 11:16 AM

Read only

0 Likes
1,235

Hi,

no need to modify ITAB_CRHD in the PAI.

Is this the table you have been displayed on the screen.

Do not make any changes to the internal table that is being displayed on the table control.

In PAI loop endloop use debugger, and check whether are you getting the table control changed data to the ITAB_CRHD.

remove his code and check the same.

modify ITAB_CRHD

from WA_CRHD

index ZTBL2_GARG-current_line.

regards,

mahantesh.

Read only

0 Likes
1,235

Whatever you have suggested that code we are already commenting.

Read only

0 Likes
1,235

Hi,

I have coded the requirement.

In the code,

there are two tables, itab & itab2.

in pbo, itab is looped with table control.

in pai loop endloop,

use the code append itab to itab2.

Using this will give you the screen table control into the itab2.

In the module change_tab i.e. after endloop in PAI, there is logic to clear and refresh itab. And itab2 ia copied to itab.

now you can have the itab same as table control content.

go through following code, you will get the idea.

PROGRAM ZMPREPORT4.

**********DATA Declaration

data : itab type standard table of z48_emp WITH HEADER LINE.

data : itab2 type standard table of z48_emp WITH HEADER LINE.

CONTROLS: tc1 TYPE TABLEVIEW USING SCREEN 100.

*************PBO Module logics

module STATUS_0100 output.

*itab-EMPNO = '22'.

*itab-DEPTNO = 12.

*append itab.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0100 OUTPUT

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

module USER_COMMAND_0100 input.

append itab to itab2.

endmodule. " USER_COMMAND_0100 INPUT

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

module change_tab input.

clear : itab.

refresh : itab.

itab[] = itab2[].

clear : itab2.

refresh : itab2.

endmodule. " change_tab INPUT