Enhancing SAP Module Pool Programs: Understanding Process on Value Request (POV)
1. Process Before Output :-
- This event calls before displaying a particular screen.
- Process Before Output" is what PBO stands for in SAP programming. In module pool programming, it's an event that takes place prior to the user seeing a screen. Just prior to the screen being transmitted to the presentation server for rendering, the PBO event is triggered.
- Usually, you create ABAP code to initialize screen fields, establish their attributes, and set their initial values during the PBO event. By making sure that the required data and UI elements are correctly set up and ready for display, this event is frequently used to get the screen ready for user interaction.
- For instance, you may specify default values for fields, hide or show certain fields based on circumstances, or populate dropdown lists with values from a database table in a sales order entry screen during the PBO event.
- Overall, the PBO event plays a crucial role in ensuring that the user interface is properly configured and ready for the user to interact with when the screen is presented.
2. Process After Input :-
- This event calls after performing some action on a particular screen.
- In SAP programming, PAI stands for "Process After Input." It's an event in module pool programming that occurs after the user interacts with a screen and provides input, such as entering data or pressing buttons.
- The PAI event is triggered when the user presses the Enter key or interacts with UI elements on the screen, such as buttons or input fields. After the user's input is provided, the system processes this input and triggers the PAI event.
- During the PAI event, you typically write ABAP code to handle the user's input, validate the data entered by the user, and determine the next steps in the program flow. This event allows you to respond to user actions and execute specific logic based on the input provided.
- For example, in a sales order entry screen, during the PAI event, you might validate the data entered by the user to ensure it meets certain criteria, perform calculations based on the entered data, and trigger actions such as saving the data to the database or navigating to another screen.
- Overall, the PAI event is essential for processing user input and driving the behavior of the application in response to user actions within the module pool framework.
3. Process On Value Request :-
- This event calls we click F4 on a field of a screen.
- In SAP terminology, "Process on Value Request" (POV) refers to an event that occurs when a user requests a list of possible values for a field. This typically happens when the user presses the F4 key or clicks a search help button next to an input field on a screen.
- You can specify your own custom logic to ascertain and present the list of values that are up for selection during the "Process on Value Request" event. This could entail running calculations, running queries against a database table, or carrying out any other tasks required to produce the values list.
- For instance, a user might hit F4 next to the customer field in a sales order entry screen to get a list of available clients in order to choose one. After that, the system would start the POV event, which would let you get a list of clients out of the database and show them to the user for selection.
- All things considered, the "Process on Value Request" event improves the application's usability by giving users an easy way to choose values for input fields and making sure they have access to accurate and pertinent data while entering data.
4. Process on help Request :-
- This event calls when we click F1 ( technical information ) on a field of screen.
- In SAP, "POH" typically refers to "Process on Help Request." It's an event in module pool programming that is triggered when the user requests help for a particular field on the screen.
- The POH event is started by the system when the user hits the F1 key or clicks the help symbol next to a field. You can specify unique help logic for the fields on the screen with this event.
- During the POH event, you can write ABAP code to provide context-sensitive help to the user based on the field they are requesting help for. This could involve displaying documentation, offering suggestions, or providing additional information to assist the user in understanding the purpose or usage of the field.
- Overall, the POH event enhances the usability of the application by providing users with helpful information and guidance when they require assistance while interacting with the module pool screens.
Practical Implementation of Process on Value Request :-
- We had created the program for multiple screens in previous parts.
- Please refer to previous blogs for the same.
- Now, Suppose the Customer wants that when he press F4 on order number then he should be getting help options.
- In Data Dictionary we use to created search helps to achieve the same requirement.
- Now, we will achieve the same to same requirement through Process on Value Request.
Solution :-
- Step 1 : Open the Program in change mode and navigate to SE80 by clicking on object list display.
- Step 2 :- Open the flow logic for screen 100 and write PROCESS ON VALUE REQUEST.
- Step 3 :- Double click on module and create a master program for the same and write the below logic.
- Step 4 :- Call function module F4IF_INT_TABLE_VALUE_REQUEST and write the below logic.
Code :-
*&---------------------------------------------------------------------*
*& Modulpool ZAR_MULTIPLE_SUB_SCREENS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
PROGRAM zar_multiple_sub_screens.
TABLES: ZAR_HEADER, ZAR_ITEM.
TYPES: BEGIN OF ty_header,
order_number TYPE zar_order_number,
order_date TYPE zar_order_date,
payment_mode TYPE zar_payment_mode,
total_amount TYPE zar_total_amount,
currency TYPE zar_curency,
END OF ty_header.
TYPES : BEGIN OF ty_item,
order_number TYPE zar_order_number,
order_item_number TYPE zar_order_item_number,
order_description TYPE zar_order_description,
item_cost TYPE zar_total_amount,
END OF ty_item.
DATA : lt_header type table of ty_header,
ls_header type ty_header,
lt_item type table of ty_item,
ls_item type ty_item.
DATA : lv_screen(4) type n value '0101'.
*&SPWIZARD: DECLARATION OF TABLECONTROL 'ZAR_TABLE_CONT' ITSELF
CONTROLS: ZAR_TABLE_CONT TYPE TABLEVIEW USING SCREEN 0102.
*&SPWIZARD: LINES OF TABLECONTROL 'ZAR_TABLE_CONT'
DATA: G_ZAR_TABLE_CONT_LINES LIKE SY-LOOPC.
DATA: OK_CODE LIKE SY-UCOMM.
*&SPWIZARD: OUTPUT MODULE FOR TC 'ZAR_TABLE_CONT'. DO NOT CHANGE THIS LI
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE ZAR_TABLE_CONT_CHANGE_TC_ATTR OUTPUT.
DESCRIBE TABLE LT_ITEM LINES ZAR_TABLE_CONT-lines.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'ZAR_TABLE_CONT'. DO NOT CHANGE THIS LI
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE ZAR_TABLE_CONT_GET_LINES OUTPUT.
G_ZAR_TABLE_CONT_LINES = SY-LOOPC.
ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'ZAR_TABLE_CONT'. DO NOT CHANGE THIS LIN
*&SPWIZARD: PROCESS USER COMMAND
MODULE ZAR_TABLE_CONT_USER_COMMAND INPUT.
OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'ZAR_TABLE_CONT'
'LT_ITEM'
' '
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.
*&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.
if sy-ucomm eq 'HEADER'.
lv_screen = '0101'.
else.
lv_screen = '0102'.
endif.
select order_number order_date
payment_mode total_amount currency
from ZAR_HEADER into table lt_header
where order_number = ZAR_HEADER-ORDER_NUMBER.
if lt_header is not INITIAL.
read TABLE lt_header into ls_header INDEX 1.
if sy-subrc eq 0.
ZAR_HEADER-ORDER_NUMBEr = ls_header-order_number.
ZAR_HEADER-ORDER_date = ls_header-order_date.
ZAR_HEADER-payment_mode = ls_header-payment_mode.
ZAR_HEADER-total_amount = ls_header-total_amount.
ZAR_HEADER-currency = ls_header-currency.
endif.
select order_number order_item_number
order_description item_cost
from ZAR_ITEM into table lt_item
for ALL ENTRIES IN lt_header
where order_number = lt_header-order_number.
endif.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module F4HELP INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE f4help INPUT.
types : begin of ty_order,
order_number type ZAR_ORDER_NUMBER,
end of ty_order.
DATA : lt_order type table of ty_order.
select order_number from ZAR_HEADER
into table lt_order.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ORDER_NUMBER'
DYNPPROG = sy-repid
DYNPNR = sy-dynnr
DYNPROFIELD = 'ZAR_HEADER-ORDER_NUMBER'
VALUE_ORG = 'S'
tables
value_tab = lt_order
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
.
ENDMODULE.
Execute the Code :-
- Now press F4 on order number.
Comments
Post a Comment