‎2007 Aug 23 1:59 PM
‎2007 Aug 24 1:58 PM
This is a real time code.....
&----
*& Module Pool ZBAL_POOL_TEST
*&
&----
*&
*&
&----
PROGRAM zbal_pool_test.
TABLES pa0001.
DATA : tx_name(10) TYPE c.
TYPES : BEGIN OF ty_marks,
language1 TYPE p DECIMALS 2,
language2 TYPE p DECIMALS 2,
maths TYPE p DECIMALS 2,
science TYPE p DECIMALS 2,
ss TYPE p DECIMALS 2,
END OF ty_marks.
DATA : it_marks TYPE TABLE OF ty_marks.
DATA : wa_marks TYPE ty_marks.
START-OF-SELECTION.
CALL SCREEN 100..
&----
*& Module tx_name_validate INPUT
&----
text
----
MODULE tx_name_validate INPUT.
IF tx_name ='Balaji'.
" message 'Hi' type 'I'.
ENDIF.
ENDMODULE. " tx_name_validate INPUT
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_MARKS' ITSELF
CONTROLS: tc_marks TYPE TABLEVIEW USING SCREEN 0100.
*&SPWIZARD: LINES OF TABLECONTROL 'TC_MARKS'
DATA: g_tc_marks_lines LIKE sy-loopc.
DATA: ok_code LIKE sy-ucomm.
*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE tc_marks_change_tc_attr OUTPUT.
DESCRIBE TABLE it_marks LINES tc_marks-lines.
ENDMODULE. "TC_MARKS_CHANGE_TC_ATTR OUTPUT
*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE tc_marks_get_lines OUTPUT.
g_tc_marks_lines = sy-loopc.
ENDMODULE. "TC_MARKS_GET_LINES OUTPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MODIFY TABLE
MODULE tc_marks_modify INPUT.
MODIFY it_marks
FROM wa_marks
INDEX tc_marks-current_line.
ENDMODULE. "TC_MARKS_MODIFY INPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE tc_marks_user_command INPUT.
ok_code = sy-ucomm.
PERFORM user_ok_tc USING 'TC_MARKS'
'IT_MARKS'
' '
CHANGING ok_code.
sy-ucomm = ok_code.
ENDMODULE. "TC_MARKS_USER_COMMAND INPUT
----
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.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA: l_ok TYPE sy-ucomm,
l_offset TYPE i.
&SPWIZARD: END OF LOCAL DATA----
*&SPWIZARD: Table control specific operations *
*&SPWIZARD: 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.
*&SPWIZARD: 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 .
&SPWIZARD: 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.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' p_tc_name '_LINES' INTO l_lines_name.
ASSIGN (l_lines_name) TO <lines>.
*&SPWIZARD: 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 *
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.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <table> INDEX l_selline.
<tc>-lines = <tc>-lines + 1.
*&SPWIZARD: 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 .
&SPWIZARD: 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>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <table> LINES <tc>-lines.
LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: 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.
&SPWIZARD: 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.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' p_tc_name '_LINES' INTO l_tc_lines_name.
ASSIGN (l_tc_lines_name) TO <lines>.
*&SPWIZARD: is no line filled? *
IF <tc>-lines = 0.
*&SPWIZARD: yes, ... *
l_tc_new_top_line = 1.
ELSE.
*&SPWIZARD: 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.
*&SPWIZARD: 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.
*&SPWIZARD: et actual column *
SET CURSOR FIELD l_tc_field_name LINE 1.
ENDIF.
ENDIF.
*&SPWIZARD: 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.
&SPWIZARD: EGIN 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>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: mark all filled lines *
LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: 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 .
&SPWIZARD: 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>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: demark all filled lines *
LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: 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 USER_COMMAND_0100 INPUT
&----
text
----
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'CANC' OR 'EXIT'.
LEAVE TO SCREEN 0.
when 'SAVE' .
MESSAGE 'Record saved..' type 'I'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module validate_mark INPUT
&----
text
----
MODULE validate_mark INPUT.
IF wa_marks-language1 GT '100'.
wa_marks-language1 = 0.
MESSAGE 'marks cannot be more than 100.' TYPE 'S'.
ENDIF.
ENDMODULE. " validate_mark INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MARKS'.
SET TITLEBAR 'Marks Entries'.
ENDMODULE. " STATUS_0100 OUTPUT
reward if helpful
‎2007 Aug 23 2:01 PM
hi,
module pool programming works like this. screens[layout] + flow logic [code] = dynpro
screens: the layout structure for screens in module pool is done here. while designing screens we ll give function codes for all screen fields so that that items can be recognized by system at runtime because of function codes only.
flow logic: all actual code for module pool programs are written here. it mainly contains two events.
1. PBO [process before output.]
2. PAI [ process after input ]
PBO: in this event all validations are done are displaying o/p screen to the user. we can done validations in two levels.
1. in screen level validations [ while designing screens we have some options like only for input, mandatory fields,....................]
2. in flow logic also same valdations can be done.
for ex: a screen has a field name suresh which should not be empty then in flow logic we write as
PBO
if screen-name = 'suresh'.
screen-required = 1.
modify screen.
endif.
for no. of fields we ll use loop ......end loop st.
screen is table which contains fields like name of field, input required, for o/p only...............
u can see this screen table while debugging module pool program as put a break point in screen and check it in tables part of debugging. then u can see all fields of screen
PAI: generally in this event we ll write code for screen after the screen is displayed for user. generally navigations from one screen to another , displaying info to user all done in this event only.
for ex:
case sy-ucomm.
when 'disp' .
select * . ........................
when 'call'.
call screeen 200.
when 'exit'.
leave program.
.......................
endcase.
POV: it is triggered when user clicks on F4 button on a screen field.
POH: it is triggered when user clicks on F1 button on a screen field..
if useful reward some points.
with regards,
Sankar
‎2007 Aug 23 2:04 PM
hi, module pool programming works like this. screens[layout] + flow logic [code] = dynpro
screens: the layout structure for screens in module pool is done here. while designing screens we ll give function codes for all screen fields so that that items can be recognized by system at runtime because of function codes only.
flow logic: all actual code for module pool programs are written here. it mainly contains two events.
1. PBO [process before output.]
2. PAI [ process after input ]
PBO: in this event all validations are done are displaying o/p screen to the user. we can done validations in two levels.
1. in screen level validations [ while designing screens we have some options like only for input, mandatory fields,....................]
2. in flow logic also same valdations can be done.
for ex: a screen has a field name suresh which should not be empty then in flow logic we write as
PBO
if screen-name = 'suresh'.
screen-required = 1.
modify screen.
endif.
for no. of fields we ll use loop ......end loop st.
screen is table which contains fields like name of field, input required, for o/p only...............
u can see this screen table while debugging module pool program as put a break point in screen and check it in tables part of debugging. then u can see all fields of screen
PAI: generally in this event we ll write code for screen after the screen is displayed for user. generally navigations from one screen to another , displaying info to user all done in this event only.
for ex:
case sy-ucomm.
when 'disp' .
select * . ........................
when 'call'.
call screeen 200.
when 'exit'.
leave program.
.......................
endcase.
POV: it is triggered when user clicks on F4 button on a screen field.
POH: it is triggered when user clicks on F1 button on a screen field..
and also in module pools some events like AT SELECTION-SCREEN ON OUTPUT CAN BE USED for PBO event.
and in PAI event AT SELECTION-SCREEN ON INPUT
AT SELECTION-SCREEN ON VALUE-REQUEST
AT SELECTION-SCREEN ON FILED-REQUEST
AT SELECTION-SCREEN
are used.
if useful reward some points.
with regards,
Suresh Aluri.
‎2007 Aug 24 1:53 PM
thanks for the explanation but i need real time scenario on SD & MM modules
‎2007 Aug 23 2:11 PM
suppose u have a student information database.
Now you can add new record / update /delete an existing record or display a record.
Depending on the logic you can go to the 2nd screen.
From 2nd screen u can also go to anoyther screen.
this can be a scenerio.
‎2007 Aug 24 1:50 PM
thanks for reply, but i need some business scenario in SD & MM modules plz give me a real time scenario.
‎2007 Aug 24 1:58 PM
This is a real time code.....
&----
*& Module Pool ZBAL_POOL_TEST
*&
&----
*&
*&
&----
PROGRAM zbal_pool_test.
TABLES pa0001.
DATA : tx_name(10) TYPE c.
TYPES : BEGIN OF ty_marks,
language1 TYPE p DECIMALS 2,
language2 TYPE p DECIMALS 2,
maths TYPE p DECIMALS 2,
science TYPE p DECIMALS 2,
ss TYPE p DECIMALS 2,
END OF ty_marks.
DATA : it_marks TYPE TABLE OF ty_marks.
DATA : wa_marks TYPE ty_marks.
START-OF-SELECTION.
CALL SCREEN 100..
&----
*& Module tx_name_validate INPUT
&----
text
----
MODULE tx_name_validate INPUT.
IF tx_name ='Balaji'.
" message 'Hi' type 'I'.
ENDIF.
ENDMODULE. " tx_name_validate INPUT
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_MARKS' ITSELF
CONTROLS: tc_marks TYPE TABLEVIEW USING SCREEN 0100.
*&SPWIZARD: LINES OF TABLECONTROL 'TC_MARKS'
DATA: g_tc_marks_lines LIKE sy-loopc.
DATA: ok_code LIKE sy-ucomm.
*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE tc_marks_change_tc_attr OUTPUT.
DESCRIBE TABLE it_marks LINES tc_marks-lines.
ENDMODULE. "TC_MARKS_CHANGE_TC_ATTR OUTPUT
*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE tc_marks_get_lines OUTPUT.
g_tc_marks_lines = sy-loopc.
ENDMODULE. "TC_MARKS_GET_LINES OUTPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MODIFY TABLE
MODULE tc_marks_modify INPUT.
MODIFY it_marks
FROM wa_marks
INDEX tc_marks-current_line.
ENDMODULE. "TC_MARKS_MODIFY INPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TC_MARKS'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE tc_marks_user_command INPUT.
ok_code = sy-ucomm.
PERFORM user_ok_tc USING 'TC_MARKS'
'IT_MARKS'
' '
CHANGING ok_code.
sy-ucomm = ok_code.
ENDMODULE. "TC_MARKS_USER_COMMAND INPUT
----
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.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA: l_ok TYPE sy-ucomm,
l_offset TYPE i.
&SPWIZARD: END OF LOCAL DATA----
*&SPWIZARD: Table control specific operations *
*&SPWIZARD: 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.
*&SPWIZARD: 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 .
&SPWIZARD: 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.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' p_tc_name '_LINES' INTO l_lines_name.
ASSIGN (l_lines_name) TO <lines>.
*&SPWIZARD: 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 *
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.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <table> INDEX l_selline.
<tc>-lines = <tc>-lines + 1.
*&SPWIZARD: 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 .
&SPWIZARD: 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>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <table> LINES <tc>-lines.
LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: 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.
&SPWIZARD: 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.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' p_tc_name '_LINES' INTO l_tc_lines_name.
ASSIGN (l_tc_lines_name) TO <lines>.
*&SPWIZARD: is no line filled? *
IF <tc>-lines = 0.
*&SPWIZARD: yes, ... *
l_tc_new_top_line = 1.
ELSE.
*&SPWIZARD: 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.
*&SPWIZARD: 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.
*&SPWIZARD: et actual column *
SET CURSOR FIELD l_tc_field_name LINE 1.
ENDIF.
ENDIF.
*&SPWIZARD: 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.
&SPWIZARD: EGIN 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>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: mark all filled lines *
LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: 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 .
&SPWIZARD: 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>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: 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
*&SPWIZARD: demark all filled lines *
LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: 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 USER_COMMAND_0100 INPUT
&----
text
----
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'CANC' OR 'EXIT'.
LEAVE TO SCREEN 0.
when 'SAVE' .
MESSAGE 'Record saved..' type 'I'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module validate_mark INPUT
&----
text
----
MODULE validate_mark INPUT.
IF wa_marks-language1 GT '100'.
wa_marks-language1 = 0.
MESSAGE 'marks cannot be more than 100.' TYPE 'S'.
ENDIF.
ENDMODULE. " validate_mark INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MARKS'.
SET TITLEBAR 'Marks Entries'.
ENDMODULE. " STATUS_0100 OUTPUT
reward if helpful
‎2007 Aug 25 8:13 AM
thanks kaushik for the code, can you give me some overview of this actually what is the requirement,and the way it is solved?
‎2007 Aug 25 8:22 AM
Hi Ram.
Its a small part of a big Object. N i have done it long back. U go through this SDN site or other site ,,,u will fine notes on module pool. Read it and for example c what i have sent. Its just to tell u how coding is done in realtime.If u go through thyis code u will understand..i hope so.!!!
Regards
‎2007 Aug 25 8:48 AM
ok kaushik thanks i go through the sites and try to understand my self bye