BC ABAP Programming PHẦN 5 potx

153 447 0
BC ABAP Programming PHẦN 5 potx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

SAP AG BC - ABAP Programming Dropdown Boxes December 1999 615 DEMOF4HELP-CONNID. ENDIF. ENDMODULE. The next screen (statically defined) for screen 100 is 200. It has the following layout: Cancel Airline Air Canada Air France Alitalia American Airlines British Airways Continental Airways The component CARRIER2 of the ABAP Dictionary structure DEMOF4HELP is assigned to the input field. Its Dropdown attribute is set to L, and it has the output length 15. The Value list attribute is empty, and it has the function code CARRIER. The pushbutton has the function code CANCEL with function type E. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. PROCESS AFTER INPUT. MODULE CANCEL AT EXIT-COMMAND. MODULE USER_COMMAND_100. The next screen (statically defined) for screen 200 is 100. It has the following layout: Cancel Flight number 13:30:00 NEW YORK SAN FRANCISCO 09:00:00 SAN FRANCISCO NEW YORK 12:00:00 FRANKFURT MIAMI 13:30:00 NEW YORK SAN FRANCISCO 09:00:00 SAN FRANCISCO NEW YORK 12:00:00 FRANKFURT MIAMI The component CONNID of the ABAP Dictionary structure DEMOF4HELP is assigned to the input field. Its Dropdown attribute is set to L, and it has the output BC - ABAP Programming SAP AG Dropdown Boxes 616 December 1999 length 30. The Value list attribute is set to A, and it has the function code SELECTED. The pushbutton has the function code CANCEL with function type E. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. MODULE INIT_LISTBOX. PROCESS AFTER INPUT. MODULE CANCEL AT EXIT-COMMAND. MODULE USER_COMMAND_200. The user cannot type any values into the screen fields. When he or she chooses the input field on screen 100, a value list appears in the list box, compiled from the input help for the field DEMOF4HELP-CARRIER2. This is the search help H_SCARR, which is assigned to the check table SCARR. The value list contains the names of the airlines. When the user chooses an entry, the screen field is filled with the airline code, and the PAI event is triggered. The module USER_COMMAND_100 checks the OK_CODE field and calls screen 200. In the PBO event of screen 200, an internal table LIST is filled with values from the database table SPFLI. The KEY field is filled with the flight numbers, and other relevant information is placed in the TEXT field. The table LIST is then passed to the function module VRM_SET_VALUES. When the user chooses the input field on screen 200, the TEXT column of the internal table is displayed in the list box. When the user chooses an entry, the screen field is filled with the corresponding entry from the KEY field, and the PAI event is triggered. The module USER_COMMAND_200 checks and processes the OK_CODE field. SAP AG BC - ABAP Programming Modifying Screens Dynamically December 1999 617 Modifying Screens Dynamically The attributes of screen elements are set statically in the Screen Painter when you define them. However, it is possible to override some of these attributes in ABAP programs with the help of a special internal table. The R/3 System contains a function called field selection, which allows you to change the attributes of screens dynamically. It is also possible to set the cursor on a screen to a particular position dynamically from your program. Setting Attributes Dynamically [Page 618] The Field Selection Function [Page 626] Setting the Cursor Position [Page 637] BC - ABAP Programming SAP AG Setting Attributes Dynamically 618 December 1999 Setting Attributes Dynamically Each field on a screen has a set of attributes that are fixed when you define the screen in the Screen Painter. When an ABAP program is running, a subset of the attributes of each screen field can be addressed using the system table SCREEN. The SCREEN Table SCREEN is like an internal table with a header line. However, you do not have to declare it in your program. You cannot display it in the Debugger, and cannot use any work area other than its header line to address it. It has the following structure: Component Length Type Description Attribute NAME 30 C Name of the screen field Name GROUP1 3 C Modification group 1 Group 1 GROUP2 3 C Modification group 2 Group2 GROUP3 3 C Modification group 3 Group3 GROUP4 3 C Modification group 4 Group4 REQUIRED 1 C Field input is mandatory Mandatory field INPUT 1 C Field is ready for input Input OUTPUT 1 C Field is for display only Output INTENSIFIED 1 C Field is highlighted Highlighted INVISIBLE 1 C Field is suppressed Invisible LENGTH 1 X Field length VisLg ACTIVE 1 C Field is active Input/Output/Invisible DISPLAY_3D 1 C Three-dimensional box Two-dimensional VALUE_HELP 1 C Input help button display Input help REQUEST 1 C Input exists - The final column contains the corresponding attributes of the screen fields in the Screen Painter. You can modify SCREEN in your ABAP program during the PBO event of a screen. Its contents override the static attributes of the screen fields for a single screen call. The only statements that you can use with SCREEN are: LOOP AT SCREEN. MODIFY SCREEN. ENDLOOP. You cannot use any further additions in the LOOP AT SCREEN statement. The component NAME contains the name of the screen field. The components GROUP1 to GROUP4 can contain any three-character code. These codes allow you to include screen fields in up to four modification groups. Modification groups are like an extra key field for the table SCREEN that allow you to change the attributes of all of the elements in a group simultaneously. You assign elements to modification groups statically in the Screen Painter, although you can overwrite them dynamically in a program. The remaining components are for reading and activating or deactivating the display attributes of screen fields. For all components other than LENGTH, 1 means active and 0 means inactive. SAP AG BC - ABAP Programming Setting Attributes Dynamically December 1999 619 ACTIVE, INPUT, OUTPUT, and INVISIBLE There are certain hierarchy rules between the components ACTIVE, INPUT, OUTPUT, and INVISIBLE. They also have different effects depending on their respective static settings. The ACTIVE component has no equivalent in the element attributes. Instead, it changes the components INPUT, OUTPUT, and INVISIBLE. At the beginning of the PBO, ACTIVE is always set to 1, regardless of the static attribute settings. Setting ACTIVE to 0 automatically sets INPUT = 0, OUTPUT = 0, and INVISIBLE = 1. Any other changes to the settings of INPUT; OUTPUT, and INVISIBLE for the same table row are ignored. Conversely, setting INPUT = 0, OUTPUT = 0, and INVISIBLE = 1 sets ACTIVE to 0, and any further assignment to ACTIVE for the same table row will also be ignored. The setting ACTIVE = 1 has no other effect on the attributes. The only purpose of the ACTIVE component is to allow you to make a screen field inactive through a single assignment. You should particularly note that a module call linked to a FIELD statement in the screen flow logic is always executed, even when SCREEN-ACTIVE = 0 for the field in question. If you want to prevent a module from being processed for an inactive field, you must specify the FIELD and MODULE statements separately. There are eight possible combinations of ACTIVE, INPUT, OUTPUT, and INVISIBLE, that have the following effect on screen fields: ACTIVE INPUT OUTPUT INVISIBLE Effect 11 1 0 Screen field is displayed, even if Invisible is set statically. Field contents are displayed. Ready for input, even if Input is not set statically. However, not ready for input if the Output only is set statically. 11 0 0 Screen field is displayed, even if Invisible is set statically, except when Output only is set statically. Field contents are not displayed. Ready for input, even if Input is not set statically. 10 1 0 Screen field is displayed, even if Invisible is set statically. Field contents are displayed. Not ready for input, even if Input is set statically. 10 0 0 Screen field is displayed, even if Invisible is set statically, except when Output only is set statically. Field contents are not displayed. Not ready for input, even if Input is set statically. BC - ABAP Programming SAP AG Setting Attributes Dynamically 620 December 1999 11 1 1 Screen field is displayed, even if Invisible is set statically, except when Output only is set statically. Field contents are not displayed. Ready for input, even if Input is not set statically. User input is masked by asterisks (*). 11 0 1 Screen field is displayed, even if Invisible is set statically, except when Output only is set statically. Output is masked by asterisks (*). Ready for input, even if Input is not set statically. User input is masked by asterisks (*). 1 0 1 1 Screen field inactive. Screen field is not displayed, regardless of the static attributes. 0 0 0 1 Screen field inactive. Screen field is not displayed, regardless of the static attributes. If a field is statically-defined as Output only, setting INPUT = 1 has no effect. INPUT is always 0 for these fields. Masking user input by asterisks can be used for entering user passwords. If a whole line becomes invisible when you make fields invisible, the screen is automatically made smaller. You can, however, switch off this attribute in the static screen attributes by selecting Switch off runtime compression. REQUIRED When you set REQUIRED = 1, a field that is ready for input is made mandatory. Users can only leave the screen when all mandatory fields contain an entry. Exception: Function codes with type E and modules with the AT EXIT-COMMAND addition. DISPLAY_3D When you set DISPLAY_3D = 0, the three-dimensional frame for input/output fields is removed. You cannot use DISPLAY_3D = 1 to create a three-dimensional effect for text fields or screen fields with the Output only attribute. VALUE_HELP Setting VALUE_HELP to 0 or 1 switches the input help button off and on respectively. INTENSIFIED If you set INTENSIFIED = 1, the field contents of input fields are changed from black to red. The contents of output fields are changed from black to blue. SAP AG BC - ABAP Programming Setting Attributes Dynamically December 1999 621 LENGTH You can set the LENGTH component to a value shorter than the statically-defined output length (vislength) for input/output fields and Output only fields. This allows you to shorten their output length. You cannot shorten other screen elements, or lengthen any screen elements. REQUEST Setting REQUEST = 1 for a field that is ready for input has the same effect in the PAI event as if the user had changed the field contents. This means that a conditional module call [Page 578] using ON REQUEST or ON CHAIN-REQUEST would be executed regardless of whether the user really changed the field. REQUEST is automatically reset to 0. Dynamic screen modifications. REPORT DEMO_DYNPRO_MODIFY_SCREEN. INCLUDE DEMO_DYNPRO_MODIFY_SCREEN_SEL. DATA: FIELD1(10), FIELD2(10), FIELD3(10), FIELD4(10), FIELD5(10), FIELD6(10). DATA: OK_CODE LIKE SY-UCOMM, SAVE_OK LIKE SY-UCOMM. DATA: ITAB LIKE TABLE OF SCREEN WITH HEADER LINE. DATA LENGTH(2) TYPE C. FIELD1 = FIELD2 = FIELD3 = '0123456789'. CALL SCREEN 100. MODULE STATUS_0100 OUTPUT. CLEAR: ITAB, ITAB[]. SET PF-STATUS 'SCREEN_100'. IF SAVE_OK = 'MODIFY'. ITAB-NAME = TEXT-001. APPEND ITAB. LOOP AT SCREEN. IF SCREEN-GROUP1 = 'MOD'. MOVE-CORRESPONDING SCREEN TO ITAB. APPEND ITAB. ENDIF. ENDLOOP. PERFORM CHANGE_INPUT USING: ACT, INP, OUT, INV, REQ, INT, D3D, HLP, RQS. CALL SELECTION-SCREEN 1100 STARTING AT 45 5. PERFORM CHANGE_INPUT USING: ACT, INP, OUT, INV, REQ, INT, D3D, HLP, RQS. MESSAGE S159(AT) WITH ACT INP OUT INV. CLEAR ITAB. APPEND ITAB. LOOP AT SCREEN. IF SCREEN-GROUP1 = 'MOD'. SCREEN-ACTIVE = ACT. SCREEN-INPUT = INP. BC - ABAP Programming SAP AG Setting Attributes Dynamically 622 December 1999 SCREEN-OUTPUT = OUT. SCREEN-INVISIBLE = INV. SCREEN-REQUIRED = REQ. SCREEN-INTENSIFIED = INT. SCREEN-DISPLAY_3D = D3D. SCREEN-VALUE_HELP = HLP. SCREEN-REQUEST = RQS. SCREEN-LENGTH = LEN. MODIFY SCREEN. ENDIF. ENDLOOP. CLEAR ITAB. ITAB-NAME = TEXT-002. ITAB-ACTIVE = ACT. ITAB-INPUT = INP. ITAB-OUTPUT = OUT. ITAB-INVISIBLE = INV. ITAB-REQUIRED = REQ. ITAB-INTENSIFIED = INT. ITAB-DISPLAY_3D = D3D. ITAB-VALUE_HELP = HLP. ITAB-REQUEST = RQS. ITAB-LENGTH = LEN. APPEND ITAB. CLEAR ITAB. APPEND ITAB. ENDIF. ENDMODULE. MODULE CANCEL INPUT. LEAVE PROGRAM. ENDMODULE. MODULE USER_COMMAND_0100 INPUT. SAVE_OK = OK_CODE. CLEAR OK_CODE. CASE SAVE_OK. WHEN 'MODIFY'. LEAVE TO SCREEN 100. WHEN 'LIST'. CLEAR ITAB. ITAB-NAME = TEXT-003. APPEND ITAB. LOOP AT SCREEN. IF SCREEN-GROUP1 = 'MOD'. MOVE-CORRESPONDING SCREEN TO ITAB. APPEND ITAB. ENDIF. ENDLOOP. CALL SCREEN 200 STARTING AT 45 5 ENDING AT 95 22. ENDCASE. ENDMODULE. SAP AG BC - ABAP Programming Setting Attributes Dynamically December 1999 623 MODULE REQUESTED INPUT. MESSAGE S888(SABAPDOCU) WITH TEXT-004. ENDMODULE. MODULE STATUS_0200 OUTPUT. SET PF-STATUS 'SCREEN_200'. SUPPRESS DIALOG. LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0. FORMAT COLOR COL_HEADING ON. WRITE: 10 'ACT', 14 'INP', 18 'OUT', 22 'INV', 26 'REQ', 30 'INT', 34 'D3D', 38 'HLP', 42 'RQS', 46 'LEN'. FORMAT COLOR COL_HEADING OFF. ULINE. LOOP AT ITAB. IF ITAB-NAME=''. ULINE. ELSEIF ITAB-NAME = TEXT-001 OR ITAB-NAME = TEXT-003. FORMAT COLOR COL_NORMAL ON. ELSE. FORMAT COLOR COL_NORMAL OFF. ENDIF. LEN = ITAB-LENGTH. LENGTH=''. IF LEN NE 0. LENGTH = LEN. ENDIF. WRITE: /(8) ITAB-NAME, 11 ITAB-ACTIVE, 15 ITAB-INPUT, 19 ITAB-OUTPUT, 23 ITAB-INVISIBLE, 27 ITAB-REQUIRED, 31 ITAB-INTENSIFIED, 35 ITAB-DISPLAY_3D, 39 ITAB-VALUE_HELP, 43 ITAB-REQUEST, 47 LENGTH. ENDLOOP. ENDMODULE. FORM CHANGE_INPUT CHANGING VAL. IF VAL = 'X'. VAL = '1'. ELSEIF VAL=''. VAL = '0'. ELSEIF VAL = '1'. VAL = 'X'. ELSEIF VAL = '0'. VAL=''. ENDIF. ENDFORM. The next screen (statically defined) for screen 100 is itself, and it has the following layout: BC - ABAP Programming SAP AG Setting Attributes Dynamically 624 December 1999 Demonstration of dynamic screen modifications List Visible input/output field Visible output field Visible output only field Invisible input/output field Invisible output field Invisible output only field Modification Refresh The input/output fields are assigned to the fields FIELD1 to FIELD6 in the ABAP program. These fields, along with the text field TEXT in the top line, are assigned to the modification group MOD. The remaining screen elements are not assigned to a modification group. The function codes of the pushbuttons are MODIFY, UNDO, and LIST. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. MODULE STATUS_0100. PROCESS AFTER INPUT. FIELD FIELD1 MODULE REQUESTED ON REQUEST. MODULE USER_COMMAND_0100. MODULE CANCEL AT EXIT-COMMAND. If you choose Modification, a selection screen appears, on which you can select which of the components of the SCREEN table should be set to active or inactive. In the subroutine CHANGE_INPUT, the user input from the checkboxes is converted into the digits 0 and 1. Selection screen 1100 is defined in the following include program: * * * INCLUDE DEMO_DYNPRO_MODIFY_SCREEN_SEL * * * SELECTION-SCREEN BEGIN OF SCREEN 1100. SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME NO INTERVALS. PARAMETERS: ACT AS CHECKBOX DEFAULT '1', INP AS CHECKBOX DEFAULT '1', OUT AS CHECKBOX DEFAULT '1', [...]... This overwrites any value assigned to the field FIELD in the ABAP program 640 December 1999 SAP AG BC - ABAP Programming Complex Screen Elements Complex Screen Elements Kontextmenüs [Page 6 45] Custom Controls [Page 668] Status Icons [Page 642] Subscreens [Page 653 ] Tabstrip Contols [Page 660] Table Controls [Page 676] December 1999 641 BC - ABAP Programming SAP AG Status Icons Status Icons Status icons... MESSAGE E888(BCTRAIN) WITH TEXT-004 WHEN 2 MESSAGE E888(BCTRAIN) WITH TEXT-0 05 WHEN 3 MESSAGE E888(BCTRAIN) WITH TEXT-006 ENDCASE ENDMODULE MODULE CANCEL INPUT LEAVE PROGRAM ENDMODULE MODULE CHANGE CASE VALUE WHEN 1 VALUE = 2 WHEN 2 VALUE = 3 WHEN 3 VALUE = 1 ENDCASE ENDMODULE The next screen (statically defined) for screen 100 is itself, and it has the following layout: December 1999 643 BC - ABAP Programming. .. December 1999 SAP AG BC - ABAP Programming The Field Selection Function Calling Field Selection To call field selection, choose Tools → ABAP Workbench → Development → Other tools → Field selection Maintenance is by program and screen group Module pool ? Screen group Selection Influencing fields Modified fields Assignment of tables to field groups Display Change First, you must declare the ABAP Dictionary... event The following icons and texts are displayed: Low Middle High The quickinfo text is ‘Status’ for all of the icons 644 December 1999 SAP AG BC - ABAP Programming Context Menus Context Menus The user interface of a screen is defined by a GUI status [Page 55 3], which you define in the Menu Painter and assign the type Dialog status For each dialog status, the system automatically creates a standard... December 1999 SAP AG BC - ABAP Programming Context Menus When the object is passed it is initial – the context menu contains no entries In the subroutine, you can work with the methods of the object (as listed above) to construct the context menu dynamically Using Predefined Context Menus As well as dialog statuses and dialog box statuses, there is a third kind of GUI status [Page 55 3] that you can define... otherwise on the header or one of the input fields The position POS is only taken into account for the input fields 638 December 1999 SAP AG BC - ABAP Programming Switching on Hold Data Dynamically Switching on Hold Data Dynamically In the attributes of a screen [Page 53 1], you can enable the following standard menu entries by setting the Hold data attribute: • System → User profile → Hold data Hold data... displayed before and after modification This makes it possible to compare directly the effects of the input on the individual components and the dependencies between the entries December 1999 6 25 BC - ABAP Programming SAP AG The Field Selection Function The Field Selection Function This topic describes how a special function Field selection (transaction SFAW and some function modules) support you in... your ABAP program In order to define the icon in your ABAP program, you must create a field with the same name as the status field on the screen and the ABAP Dictionary type ICONS-TEXT You can then fill this field with the required technical information in the PBO event When the screen is displayed, the information is transferred to the status field and the icon appears To fill the field in your ABAP. .. because the value '_' (blank) prevents any field modification Let us consider an ABAP program in which the second screen contains the following module call in its PBO event: PROCESS BEFORE OUTPUT MODULE MODIFY_SCREEN Suppose the module MODIFY_SCREEN contains the following function call: 632 December 1999 SAP AG BC - ABAP Programming The Field Selection Function MODULE MODIFY_SCREEN OUTPUT CALL FUNCTION... 1999 FRANKFURT KM 633 BC - ABAP Programming SAP AG The Field Selection Function However, if instead of 'LH' as airline carrier 'AA' is entered, the following screen appears: Airline AA Flight number 17 AMERICAN AIRLINES Flight data From NEW YORK Departure airport JFK To SAN FRANCISCO Arrival airport SFO Flight time 06:01:00 Departure time 13:30:00 Arrival time 16:31:00 Distance 2 .57 2 In MLS When entering . 200 STARTING AT 45 5 ENDING AT 95 22. ENDCASE. ENDMODULE. SAP AG BC - ABAP Programming Setting Attributes Dynamically December 1999 623 MODULE REQUESTED INPUT. MESSAGE S888(SABAPDOCU) WITH TEXT-004. ENDMODULE. MODULE. MIAMI The component CONNID of the ABAP Dictionary structure DEMOF4HELP is assigned to the input field. Its Dropdown attribute is set to L, and it has the output BC - ABAP Programming SAP AG Dropdown. SAP AG BC - ABAP Programming Dropdown Boxes December 1999 6 15 DEMOF4HELP-CONNID. ENDIF. ENDMODULE. The next screen (statically

Ngày đăng: 09/08/2014, 14:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan