This commit is contained in:
danrega
2024-01-04 17:12:05 +01:00
parent 743c5630cf
commit 4e086b5b5f
156 changed files with 38507 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DEVC" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DEVC>
<CTEXT>ABAP Cheat Sheets: Classic ABAP</CTEXT>
</DEVC>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,139 @@
CLASS zcl_demo_abap_sap_luw_helper DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES log_type TYPE SORTED TABLE OF zdemo_abap_logt WITH UNIQUE KEY id.
CLASS-DATA: itab TYPE STANDARD TABLE OF zdemo_abap_luw_t,
log_entries TYPE STANDARD TABLE OF zdemo_abap_logt.
CLASS-METHODS: get_work_process_info RETURNING VALUE(id_no) TYPE string,
create_log_entries IMPORTING log TYPE log_type,
checking_transaction_state RETURNING VALUE(tx_state) TYPE string,
cc_alv_display IMPORTING container TYPE c
log TYPE abap_bool DEFAULT abap_false,
subr_delete,
subr_insert IMPORTING values TYPE zdemo_abap_luw_t,
subr_update_log IMPORTING log TYPE log_type.
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-DATA: wp_pid TYPE wppid,
wp_index TYPE wpindex.
ENDCLASS.
CLASS ZCL_DEMO_ABAP_SAP_LUW_HELPER IMPLEMENTATION.
METHOD cc_alv_display.
DATA(cont) = NEW cl_gui_custom_container( container_name = container ).
IF log = abap_false.
SELECT key_field, ch, num, time_stamp
FROM zdemo_abap_luw_t
INTO CORRESPONDING FIELDS OF TABLE @Itab
ORDER BY key_field.
TRY.
cl_salv_table=>factory( EXPORTING r_container = cont
container_name = CONV string( container )
IMPORTING r_salv_table = DATA(alv)
CHANGING t_table = itab ).
DATA(columns) = alv->get_columns( ).
DATA(col_tab) = columns->get( ).
LOOP AT col_tab ASSIGNING FIELD-SYMBOL(<column>).
DATA(column) = columns->get_column( <column>-columnname ).
column->set_medium_text( CONV scrtext_m( <column>-columnname ) ).
IF <column>-columnname = 'CLIENT'.
<column>-r_column->set_visible( abap_false ).
ELSE.
<column>-r_column->set_visible( abap_true ).
ENDIF.
ENDLOOP.
alv->display( ).
CATCH cx_salv_msg cx_salv_not_found.
MESSAGE 'ALV display not possible' TYPE 'I'
DISPLAY LIKE 'E'.
ENDTRY.
ELSE.
SELECT id, context, name, details, timestamp
FROM zdemo_abap_logt
INTO CORRESPONDING FIELDS OF TABLE @log_entries
ORDER BY id.
TRY.
cl_salv_table=>factory( EXPORTING r_container = cont
container_name = CONV string( container )
IMPORTING r_salv_table = alv
CHANGING t_table = log_entries ).
columns = alv->get_columns( ).
col_tab = columns->get( ).
LOOP AT col_tab ASSIGNING FIELD-SYMBOL(<col>).
column = columns->get_column( <col>-columnname ).
column->set_medium_text( CONV scrtext_m( <col>-columnname ) ).
IF <col>-columnname = `DETAILS`.
column->set_output_length( 70 ).
ENDIF.
IF <col>-columnname = 'CLIENT'.
<col>-r_column->set_visible( abap_false ).
ELSE.
<col>-r_column->set_visible( abap_true ).
ENDIF.
ENDLOOP.
alv->display( ).
CATCH cx_salv_msg cx_salv_not_found.
MESSAGE 'ALV display not possible' TYPE 'I'
DISPLAY LIKE 'E'.
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD checking_transaction_state.
tx_state = `Tx state: ` &&
`Update task (` && SWITCH #( cl_system_transaction_state=>get_in_update_task( ) WHEN 1 THEN `1)` ELSE `0)` ) &&
` Local update (` && SWITCH #( cl_system_transaction_state=>get_update_task_local( ) WHEN 1 THEN `1)` ELSE `0)` ) &&
` Perf. on commit (` && SWITCH #( cl_system_transaction_state=>get_on_commit( ) WHEN 1 THEN `1)` ELSE `0)` ) &&
` Perf. on rollback (` && SWITCH #( cl_system_transaction_state=>get_on_rollback( ) WHEN 1 THEN `1)` ELSE `0)` ).
ENDMETHOD.
METHOD create_log_entries.
INSERT zdemo_abap_logt FROM TABLE @log.
ENDMETHOD.
METHOD get_work_process_info.
CALL FUNCTION 'TH_GET_OWN_WP_NO'
IMPORTING
wp_pid = wp_pid
wp_index = wp_index.
id_no = |Work process ID: { wp_pid } / work process index: { wp_index }|.
ENDMETHOD.
METHOD subr_delete.
DELETE FROM zdemo_abap_luw_t.
ENDMETHOD.
METHOD subr_insert.
INSERT zdemo_abap_luw_t FROM @values.
ENDMETHOD.
METHOD subr_update_log.
INSERT zdemo_abap_logt FROM TABLE @log.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>ZCL_DEMO_ABAP_SAP_LUW_HELPER</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Helper class for SAP LUW example</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,741 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
* Example: SAP List Viewer (ALV)
*
* -------------------------- PURPOSE ----------------------------------
* Example that demonstrates a selection of SAP List Viewer (ALV)-related
* options:
* - Layout-related options
* - Setting the header title
* - Optimizing column width
* - Setting filter
* - Setting short, medium and long texts of particular columns
* - Setting the text alignment of a particular column
* - Setting the visibility of a particular column
* - Setting the color of table columns
* - Setting the color of table cells
* - Setting the color of table rows
* - Setting table rows to a striped pattern
* - Setting text properties such as alignment and blanks (not zeroes)
* - Displaying horizontal and vertical grid lines
* - Displaying as popup
* - Functionality
* - Single click events/hotspots
* - Double click events
* - Custom functions
* - Generic functions
* - Adding aggregations
* - Sepcifying selection types
* - Specifying tooltips
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
PROGRAM.
SELECTION-SCREEN: COMMENT 1(70) intro1,
COMMENT /1(70) intro2,
COMMENT /1(70) intro3,
SKIP.
SELECTION-SCREEN BEGIN OF BLOCK layout WITH FRAME TITLE t2.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS setheadr TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t4,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS opt TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t6,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS sort TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t7,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS colheadr TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t8,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS selct TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t10,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS colors TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t11,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS filter TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t12,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS txtprop TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t13,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS lines TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t14,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS tool TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t15,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS popup TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t16,
END OF LINE.
SELECTION-SCREEN END OF BLOCK layout.
SELECTION-SCREEN BEGIN OF BLOCK ev_fu WITH FRAME TITLE t17.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS aggreg TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t18,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS hotspots TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t19,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS doublecl TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t20,
END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS func TYPE c AS CHECKBOX.
SELECTION-SCREEN: COMMENT 3(70) t21,
END OF LINE.
SELECTION-SCREEN END OF BLOCK ev_fu.
"Adding a pushbutton in the application toolbar
TABLES sscrfields.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
TYPES: BEGIN OF flight_struc,
carrid TYPE zdemo_abap_fli-carrid,
connid TYPE zdemo_abap_fli-connid,
fldate TYPE zdemo_abap_fli-fldate,
price TYPE zdemo_abap_fli-price,
currency TYPE zdemo_abap_fli-currency,
planetype TYPE zdemo_abap_fli-planetype,
text TYPE string,
seatsmax TYPE zdemo_abap_fli-seatsmax,
seatsocc TYPE zdemo_abap_fli-seatsocc,
seatsfree TYPE i,
occrate TYPE p LENGTH 5 DECIMALS 2,
seatstat TYPE icon_d,
colored TYPE lvc_t_scol,
hotspot TYPE icon_d,
END OF flight_struc.
DATA itab4alv TYPE TABLE OF flight_struc WITH EMPTY KEY.
DATA alv TYPE REF TO cl_salv_table.
DATA already_updated TYPE abap_bool.
**********************************************************************
"Local classes for modularization purposes
"Class to handle events
CLASS lcl_events DEFINITION.
PUBLIC SECTION.
CLASS-METHODS click_hotspot
FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
CLASS-METHODS double_click
FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column.
CLASS-METHODS func_click
FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function.
ENDCLASS.
CLASS lcl_events IMPLEMENTATION.
METHOD click_hotspot.
READ TABLE itab4alv INDEX row REFERENCE INTO DATA(sc_ref).
IF sy-subrc = 0.
ASSIGN sc_ref->(column) TO FIELD-SYMBOL(<fs_sc>).
MESSAGE `Single click event. ` &&
|Row: { row } { COND #( WHEN column IS NOT INITIAL THEN `Column: ` && column ) } | &&
|{ COND #( WHEN <fs_sc> IS ASSIGNED THEN `Value: ` && <fs_sc> ) }| TYPE 'I'.
ELSE.
MESSAGE `Single click event` TYPE 'I'.
ENDIF.
ENDMETHOD.
METHOD double_click.
READ TABLE itab4alv INDEX row REFERENCE INTO DATA(dc_ref).
IF sy-subrc = 0.
ASSIGN dc_ref->(column) TO FIELD-SYMBOL(<fs_dc>).
MESSAGE `Double click event. ` &&
|Row: { row } { COND #( WHEN column IS NOT INITIAL THEN `Column: ` && column ) } | &&
|{ COND #( WHEN <fs_dc> IS ASSIGNED THEN `Value: ` && <fs_dc> ) }| TYPE 'I'.
ELSE.
MESSAGE `Double click event` TYPE 'I'.
ENDIF.
ENDMETHOD.
METHOD func_click.
"Handling custom functions
CASE e_salv_function.
WHEN 'GET_SELECT'.
"This function gets the selected table rows. A message is displayed
"listing the selected rows, if any.
DATA(selections) = alv->get_selections( ).
DATA(selected_rows) = selections->get_selected_rows( ).
IF lines( selected_rows ) IS INITIAL.
MESSAGE 'None of the rows of the displayed internal table have been selected.' TYPE 'I'.
ELSE.
DATA acc_rows TYPE string.
LOOP AT selected_rows REFERENCE INTO DATA(line).
IF sy-tabix = 1.
acc_rows = line->*.
ELSE.
acc_rows = acc_rows && `,` && line->*.
ENDIF.
ENDLOOP.
CONDENSE acc_rows NO-GAPS.
MESSAGE |Selected row{ COND #( WHEN lines( selected_rows ) > 1 THEN `s` ) }: { acc_rows }| TYPE 'I'.
ENDIF.
WHEN 'CALC'.
"This function performs a calculation. It calculates the number of free seats
"and the occupancy rate of the seats.
"Using the 'refresh' method, the table is refreshed, and the calculated values
"are diplayed in the respective columns.
IF already_updated = abap_true.
MESSAGE 'The values have already been calculated.' TYPE 'I'.
ELSE.
LOOP AT itab4alv REFERENCE INTO DATA(calc).
calc->seatsfree = calc->seatsmax - calc->seatsocc.
TRY.
calc->occrate = |{ CONV decfloat34( ( calc->seatsocc / calc->seatsmax ) * 100 ) DECIMALS = 2 }|.
IF calc->occrate >= 95.
calc->seatstat = icon_red_light.
ELSEIF calc->occrate < 95 AND calc->occrate > 75.
calc->seatstat = icon_yellow_light.
ELSE.
calc->seatstat = icon_green_light.
ENDIF.
CATCH cx_sy_arithmetic_error.
ENDTRY.
ENDLOOP.
MESSAGE 'Values for the SEATSFREE and OCCRATE columns have been calculated and are updated. The SEATSTAT column is updated accordingly.' TYPE 'I'.
already_updated = abap_true.
alv->refresh( ).
ENDIF.
WHEN 'HIDE'.
"This function hides and shows a specific table column.
TRY.
DATA(col) = alv->get_columns( )->get_column( 'HOTSPOT' ).
IF col->is_visible( ).
col->set_visible( abap_false ).
ELSE.
col->set_visible( abap_true ).
ENDIF.
CATCH cx_salv_not_found.
ENDTRY.
ENDCASE.
ENDMETHOD.
ENDCLASS.
**********************************************************************
"Local class to handle the selected checkboxes
CLASS lcl_alv_demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS set_header
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS optimize
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS sort
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS misc_column
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS set_filter
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS selection
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS coloring
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS aggregate
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS set_text_properties
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS display_grid_lines
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS display_as_popup
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS use_functions
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS enable_hotspots
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS handle_double_click
IMPORTING checkbox TYPE abap_bool.
CLASS-METHODS tooltips
IMPORTING checkbox TYPE abap_bool.
ENDCLASS.
CLASS lcl_alv_demo IMPLEMENTATION.
METHOD set_header.
IF checkbox = abap_true.
alv->get_display_settings( )->set_list_header( 'Flight Overview' ).
ENDIF.
ENDMETHOD.
METHOD optimize.
IF checkbox = abap_true.
alv->get_columns( )->set_optimize( abap_true ).
ELSE.
alv->get_columns( )->set_optimize( abap_false ).
ENDIF.
ENDMETHOD.
METHOD sort.
IF checkbox = abap_true.
"In this example, a particular column is sorted downwards.
TRY.
alv->get_sorts( )->add_sort( 'CARRID' )->set_sequence( if_salv_c_sort=>sort_down ).
CATCH cx_root.
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD misc_column.
"In this example, several column-related options are covered:
"- Setting short, medium and long texts of particular columns
"- Setting the text alignment of a particular column
"- Setting the visibility of a particular column (here, a column is hidden)
IF checkbox = abap_true.
DATA(columns) = alv->get_columns( )->get( ).
LOOP AT columns REFERENCE INTO DATA(colref).
DATA(column) = colref->r_column.
"Setting short, medium and long texts
column->set_long_text( |{ colref->columnname }| ).
"For testing purposes, you can manually increase the column width for the
"two columns and see how the name changes depending on the column size.
"If optimize is also flagged, all column names are fully displayed.
"In the case of the following two columns, the short text is displayed
"because the values in the column consist of 3 characters only in the example.
IF colref->columnname = 'SEATSMAX'.
column->set_short_text( 'MAX' ).
column->set_medium_text( 'STMAX' ).
ENDIF.
IF colref->columnname = 'SEATSOCC'.
column->set_short_text( 'OCC' ).
column->set_medium_text( 'STOCC' ).
ENDIF.
"Setting the text alignment
IF colref->columnname = 'CURRENCY'.
"Without this setting, the values of the CURRENCY column would be left-aligned by default.
column->set_alignment( if_salv_c_alignment=>right ).
ENDIF.
"Setting the visibility
IF colref->columnname = 'TEXT'.
"without this setting the values of currency column would be left-aligned by default
"left is the default
column->set_visible( abap_false ).
ENDIF.
"Change Position of the Column within the ALV Output
IF colref->columnname = 'SEATSOCC'.
TRY.
DATA(pos) = alv->get_columns( )->get_column_position( 'SEATSMAX' ).
alv->get_columns( )->set_column_position( columnname = 'SEATSOCC' position = pos ).
CATCH cx_salv_not_found.
ENDTRY.
ENDIF.
"The following statements are intended for demonstration purposes. They showcase other
"available methods in this context. You can, for example, set a breakpoint here and
"check the values of the variables in the debugger. Many more methods are available for
"different use cases. The following statements show a selection.
IF colref->columnname = 'CURRENCY'.
DATA(alignm) = column->get_alignment( ).
DATA(col_name) = column->get_columnname( ).
DATA(long_text) = column->get_long_text( ).
DATA(medium_text) = column->get_medium_text( ).
DATA(short_text) = column->get_short_text( ).
DATA(ouput_length) = column->get_output_length( ).
DATA(ddictype) = column->get_ddic_inttype( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.
METHOD set_filter.
IF checkbox = abap_true.
"In this example, a filter is applied on a particular column. Depending on the
"filter setting, table rows are displayed or not.
TRY.
alv->get_filters( )->add_filter( 'PRICE' )->add_selopt( sign = 'I' option = 'BT' low = '0' high = '1100' ).
CATCH cx_salv_existing cx_salv_data_error cx_salv_not_found.
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD aggregate.
IF checkbox = abap_true.
"In this example, an aggregation is added for a particular column.
"In tis case, the average price is calculated. It is displayed in a row added
"to the bottom of the table.
TRY.
alv->get_aggregations( )->add_aggregation( columnname = 'PRICE'
aggregation = if_salv_c_aggregation=>average ).
CATCH cx_salv_data_error cx_salv_not_found cx_salv_existing.
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD selection.
"In this example, the selection type is specified.
DATA(sel) = alv->get_selections( ).
IF checkbox = abap_true.
"Mutliple rows/columns can be selected
sel->set_selection_mode( if_salv_c_selection_mode=>row_column ).
ELSE.
"Individual selection
sel->set_selection_mode( if_salv_c_selection_mode=>single ).
ENDIF.
ENDMETHOD.
METHOD coloring.
"In this example, multiple options are demonstrated to provide color settings:
"- Setting the color of table columns
"- Setting the color of table cells
"- Setting the color of table rows
"- Setting table rows to a striped pattern
IF checkbox = abap_true.
"Setting the color of table columns
TRY.
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'CURRENCY' ) )->set_color( VALUE lvc_s_colo( col = 3 ) ).
CATCH cx_salv_not_found.
ENDTRY.
"Setting the color of table cells
"For this purpose, the internal table has a component of type
"lvc_t_scol, which is used for cell coloring here.
"In the example, the color for cells in a particular column are set
"based on a condition. Intensified and inverse values are explicitly
"set to 'off'.
LOOP AT itab4alv REFERENCE INTO DATA(coloredcell) WHERE price < 300.
APPEND VALUE #( fname = 'PRICE'
color-col = col_positive
color-int = 0
color-inv = 0 ) TO coloredcell->colored.
ENDLOOP.
"Setting the color of table rows
"Also here, the component of type lvc_t_scol is used. When the internal
"table row is added, the name of the field is omitted so that the color is
"set for the entire table row.
LOOP AT itab4alv REFERENCE INTO DATA(coloredrow) WHERE carrid = 'LH'.
APPEND VALUE #( color-col = col_group ) TO coloredrow->colored.
ENDLOOP.
"Applying the color settings
TRY.
alv->get_columns( )->set_color_column( 'COLORED' ).
CATCH cx_salv_data_error.
ENDTRY.
"Setting table rows to a striped pattern
alv->get_display_settings( )->set_striped_pattern( abap_true ).
ENDIF.
ENDMETHOD.
METHOD set_text_properties.
IF checkbox = abap_true.
"In this example, a selection of text property-specific options is demonstrated.
TRY.
"Setting the text alignment of table rows
CAST cl_salv_column( alv->get_columns( )->get_column( 'SEATSOCC' ) )->set_alignment( if_salv_c_alignment=>left ).
"Setting blanks instead of zeroes
CAST cl_salv_column( alv->get_columns( )->get_column( 'SEATSFREE' ) )->set_zero( abap_false ).
CAST cl_salv_column( alv->get_columns( )->get_column( 'OCCRATE' ) )->set_zero( abap_false ).
CATCH cx_salv_not_found.
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD display_grid_lines.
"In this example, horizontal and vertical ALV grid lines are set to be either displayed
"or not.
IF checkbox = abap_true.
alv->get_display_settings( )->set_horizontal_lines( abap_true ).
alv->get_display_settings( )->set_vertical_lines( abap_true ).
ELSE.
alv->get_display_settings( )->set_horizontal_lines( abap_false ).
alv->get_display_settings( )->set_vertical_lines( abap_false ).
ENDIF.
ENDMETHOD.
METHOD display_as_popup.
"In this example, the ALV output is displayed in a dialog box. Demo coordinates
"are provided.
IF checkbox = abap_true.
alv->set_screen_popup( start_column = 10
end_column = 100
start_line = 4
end_line = 15 ).
ENDIF.
ENDMETHOD.
METHOD use_functions.
"In this example, a custom GUI status is set. All functions are set.
"The custom GUI status is included in the cheat sheet example program.
"If the checkbox is not selected, the generic ALV functions are set.
IF checkbox = abap_true.
alv->set_screen_status(
pfstatus = 'DEMO_STATUS_ALV'
report = sy-repid
set_functions = alv->c_functions_all ).
"You can check the results of the following method calls in the debugger.
DATA(getfunc) = alv->get_functions( ).
"Checking the activation status
DATA(is_enabled) = getfunc->is_enabled( 'GET_SELECT' ).
"Checking the visibility
DATA(is_visible) = getfunc->is_visible( 'GET_SELECT' ).
"Registering an event handler for the custom functions
SET HANDLER lcl_events=>func_click FOR alv->get_event( ).
ELSE.
alv->get_functions( )->set_default( abap_true ).
ENDIF.
ENDMETHOD.
METHOD enable_hotspots.
"This example demonstrates hotspots/single click events. Here,
"the cell type of a particular column is set as hotspot. Plus,
"an event handler is registered to handle the hotspot click event.
IF checkbox = abap_true.
TRY.
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'CONNID' ) )->set_cell_type( if_salv_c_cell_type=>hotspot ).
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'HOTSPOT' ) )->set_cell_type( if_salv_c_cell_type=>hotspot ).
SET HANDLER lcl_events=>click_hotspot FOR alv->get_event( ).
CATCH cx_salv_not_found.
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD handle_double_click.
"This example demonstrates the double click event. See the implementation
"in the local class for events. The implementation simlpy raises a
"message.
IF checkbox = abap_true.
SET HANDLER lcl_events=>double_click FOR alv->get_event( ).
ENDIF.
ENDMETHOD.
METHOD tooltips.
"This example demonstrates tooltips for the following use cases:
"- A tooltip is added to a particular column. This column is set as icon column.
" When you hover over the icon in the column, the tooltip is diplayed.
"- Tooltips are added for particular column headers.
IF checkbox = abap_true.
TRY.
"Tooltip for icons
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'HOTSPOT' ) )->set_icon( if_salv_c_bool_sap=>true ).
alv->get_functional_settings( )->get_tooltips( )->add_tooltip( type = cl_salv_tooltip=>c_type_icon
value = CONV lvc_value( icon_abap )
tooltip = `This is a tooltip for an icon` ).
"Tooltips for column headers
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'CARRID' ) )->set_tooltip( 'Tooltip 1' ).
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'CONNID' ) )->set_tooltip( 'Tooltip 2' ).
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'FLDATE' ) )->set_tooltip( 'Tooltip 3' ).
CAST cl_salv_column_table( alv->get_columns( )->get_column( 'PRICE' ) )->set_tooltip( 'Tooltip 4' ).
CATCH cx_salv_not_found cx_salv_existing.
ENDTRY.
ENDIF.
ENDMETHOD.
ENDCLASS.
**********************************************************************
INITIALIZATION.
"Filling demo database tables to select from
zcl_demo_abap_aux=>fill_dbtabs( ).
"Providing text
intro1 = 'This example demonstrates the SAP List Viewer (ALV).'.
intro2 = 'Select checkboxes to determine ALV-related aspects and functionality.'.
intro3 = 'After you have selected checkboxes of your choice, choose Execute/F8.'.
t2 = 'ALV layout-related options'.
t4 = 'Set title'.
t6 = 'Optimize column width'.
t7 = 'Sort a column'.
t8 = 'Misc settings (column names, visibility, positioning)'.
t10 = 'Selection options'.
t11 = 'Set colors'.
t12 = 'Set filter'.
t13 = 'Set text properties'.
t14 = 'Display grid lines'.
t15 = 'Tooltips'.
t16 = 'Display as popup'.
t17 = 'Functions and events'.
t18 = 'Aggregate'.
t19 = 'Hotspots (single-click events)'.
t20 = 'Handle double clicks'.
t21 = 'Use custom functions (else generic functions)'.
sscrfields-functxt_01 = 'Select all checkboxes (no popup)'.
sscrfields-functxt_02 = 'Deselect all checkboxes'.
**********************************************************************
AT SELECTION-SCREEN.
"For convenience, buttons are included that select most checkboxes and
"deselect all checkboxes when clicked.
CASE sscrfields-ucomm.
WHEN 'FC01'.
setheadr = abap_true.
opt = abap_true.
sort = abap_true.
filter = abap_true.
colheadr = abap_true.
selct = abap_true.
colors = abap_true.
filter = abap_true.
txtprop = abap_true.
lines = abap_true.
tool = abap_true.
popup = abap_false.
aggreg = abap_true.
hotspots = abap_true.
doublecl = abap_true.
func = abap_true.
WHEN 'FC02'.
setheadr = abap_false.
opt = abap_false.
sort = abap_false.
filter = abap_false.
colheadr = abap_false.
selct = abap_false.
colors = abap_false.
filter = abap_false.
txtprop = abap_false.
lines = abap_false.
tool = abap_false.
popup = abap_false.
aggreg = abap_false.
hotspots = abap_false.
doublecl = abap_false.
func = abap_false.
ENDCASE.
**********************************************************************
START-OF-SELECTION.
CLEAR alv.
"Populating internal table
SELECT carrid, connid, fldate, price, currency, planetype, seatsmax, seatsocc
FROM zdemo_abap_fli
ORDER BY carrid, connid
INTO CORRESPONDING FIELDS OF TABLE @itab4alv.
"Providing values for a particular column for demo purposes
LOOP AT itab4alv REFERENCE INTO DATA(ref).
ref->hotspot = icon_abap.
ENDLOOP.
"Instantiating an ALV table object
"Note: In this example, the ALV is not included in a container. Therefore,
"the other exporting parameters are irrelevant. The list_display parameter is
"used to set the display type, which is set here based on user input.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = itab4alv ).
"The following methods include the actual implementations for the ALV display and functionality.
"Based on the selection of the checkboxes on the selection screen, the implementation is either
"used or not. See comments in the method implementations.
lcl_alv_demo=>set_header( setheadr ).
lcl_alv_demo=>optimize( opt ).
lcl_alv_demo=>sort( sort ).
lcl_alv_demo=>misc_column( colheadr ).
lcl_alv_demo=>set_filter( filter ).
lcl_alv_demo=>aggregate( aggreg ).
lcl_alv_demo=>selection( selct ).
lcl_alv_demo=>coloring( colors ).
lcl_alv_demo=>set_text_properties( txtprop ).
lcl_alv_demo=>display_grid_lines( lines ).
lcl_alv_demo=>display_as_popup( popup ).
lcl_alv_demo=>use_functions( func ).
lcl_alv_demo=>enable_hotspots( hotspots ).
lcl_alv_demo=>handle_double_click( doublecl ).
lcl_alv_demo=>tooltips( tool ).
"Displaying the ALV
alv->display( ).
CATCH cx_root INTO DATA(error).
"Note: For simplicity, this example uses the root exception class. Always make
"sure that you use appropriate exception classes.
MESSAGE error->get_text( ) TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.

View File

@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_ALV</NAME>
<DBAPL>S</DBAPL>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<CUA>
<ADM>
<ACTCODE>000001</ACTCODE>
<PFKCODE>000001</PFKCODE>
</ADM>
<STA>
<RSMPE_STAT>
<CODE>DEMO_STATUS_ALV</CODE>
<MODAL>D</MODAL>
<ACTCODE>000001</ACTCODE>
<PFKCODE>000001</PFKCODE>
<BUTCODE>0001</BUTCODE>
<INT_NOTE>Demo Status</INT_NOTE>
</RSMPE_STAT>
</STA>
<FUN>
<RSMPE_FUNT>
<CODE>&amp;F03</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<FUN_TEXT>Back</FUN_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>&amp;F12</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<TEXT_NAME>ICON_CANCEL</TEXT_NAME>
<ICON_ID>@0W@</ICON_ID>
<FUN_TEXT>Cancel</FUN_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>&amp;F15</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<FUN_TEXT>Exit</FUN_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>CALC</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<TEXT_NAME>ICON_CALCULATION</TEXT_NAME>
<ICON_ID>@0M@</ICON_ID>
<FUN_TEXT>Calculations</FUN_TEXT>
<ICON_TEXT>Calculate values</ICON_TEXT>
<INFO_TEXT>Perform calculations</INFO_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>GET_SELECT</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<TEXT_NAME>ICON_ABAP_LOCAL</TEXT_NAME>
<ICON_ID>@9V@</ICON_ID>
<FUN_TEXT>Selected rows</FUN_TEXT>
<ICON_TEXT>Get selected rows</ICON_TEXT>
<INFO_TEXT>Get selected rows</INFO_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>HIDE</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<TEXT_NAME>ICON_VIEW_TABLE</TEXT_NAME>
<ICON_ID>@XD@</ICON_ID>
<FUN_TEXT>Hide/Show column</FUN_TEXT>
<ICON_TEXT>Hide/Show column</ICON_TEXT>
<INFO_TEXT>Hide/Show HOTSPOT column</INFO_TEXT>
</RSMPE_FUNT>
</FUN>
<BUT>
<RSMPE_BUT>
<PFK_CODE>000001</PFK_CODE>
<CODE>0001</CODE>
<NO>01</NO>
<PFNO>05</PFNO>
</RSMPE_BUT>
<RSMPE_BUT>
<PFK_CODE>000001</PFK_CODE>
<CODE>0001</CODE>
<NO>02</NO>
<PFNO>06</PFNO>
</RSMPE_BUT>
<RSMPE_BUT>
<PFK_CODE>000001</PFK_CODE>
<CODE>0001</CODE>
<NO>03</NO>
<PFNO>07</PFNO>
</RSMPE_BUT>
</BUT>
<PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>03</PFNO>
<FUNCODE>&amp;F03</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>05</PFNO>
<FUNCODE>GET_SELECT</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>06</PFNO>
<FUNCODE>CALC</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>07</PFNO>
<FUNCODE>HIDE</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>12</PFNO>
<FUNCODE>&amp;F12</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>15</PFNO>
<FUNCODE>&amp;F15</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
</PFK>
<SET>
<RSMPE_STAF>
<STATUS>DEMO_STATUS_ALV</STATUS>
<FUNCTION>&amp;F03</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>DEMO_STATUS_ALV</STATUS>
<FUNCTION>&amp;F12</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>DEMO_STATUS_ALV</STATUS>
<FUNCTION>&amp;F15</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>DEMO_STATUS_ALV</STATUS>
<FUNCTION>CALC</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>DEMO_STATUS_ALV</STATUS>
<FUNCTION>GET_SELECT</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>DEMO_STATUS_ALV</STATUS>
<FUNCTION>HIDE</FUNCTION>
</RSMPE_STAF>
</SET>
<DOC>
<RSMPE_ATRT>
<OBJ_TYPE>A</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Demo Status</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>P</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Demo Status</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>B</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<SUB_CODE>0001</SUB_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Demo Status</INT_NOTE>
</RSMPE_ATRT>
</DOC>
</CUA>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>ABAP Cheat Sheet Example: ALV</ENTRY>
<LENGTH>29</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_TABL" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DD02V>
<TABNAME>ZDEMO_ABAP_DBLUW</TABNAME>
<DDLANGUAGE>E</DDLANGUAGE>
<TABCLASS>TRANSP</TABCLASS>
<CLIDEP>X</CLIDEP>
<DDTEXT>Demo database table</DDTEXT>
<MASTERLANG>E</MASTERLANG>
<MAINFLAG>X</MAINFLAG>
<CONTFLAG>A</CONTFLAG>
<EXCLASS>1</EXCLASS>
</DD02V>
<DD09L>
<TABNAME>ZDEMO_ABAP_DBLUW</TABNAME>
<AS4LOCAL>A</AS4LOCAL>
<TABKAT>0</TABKAT>
<TABART>APPL0</TABART>
<BUFALLOW>N</BUFALLOW>
</DD09L>
<DD03P_TABLE>
<DD03P>
<FIELDNAME>CLIENT</FIELDNAME>
<KEYFLAG>X</KEYFLAG>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>C</INTTYPE>
<INTLEN>000006</INTLEN>
<NOTNULL>X</NOTNULL>
<DATATYPE>CLNT</DATATYPE>
<LENG>000003</LENG>
<MASK> CLNT</MASK>
</DD03P>
<DD03P>
<FIELDNAME>KEY_FIELD</FIELDNAME>
<KEYFLAG>X</KEYFLAG>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>X</INTTYPE>
<INTLEN>000004</INTLEN>
<NOTNULL>X</NOTNULL>
<DATATYPE>INT4</DATATYPE>
<LENG>000010</LENG>
<MASK> INT4</MASK>
</DD03P>
<DD03P>
<FIELDNAME>CH</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>C</INTTYPE>
<INTLEN>000020</INTLEN>
<DATATYPE>CHAR</DATATYPE>
<LENG>000010</LENG>
<MASK> CHAR</MASK>
</DD03P>
<DD03P>
<FIELDNAME>NUM</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>X</INTTYPE>
<INTLEN>000004</INTLEN>
<DATATYPE>INT4</DATATYPE>
<LENG>000010</LENG>
<MASK> INT4</MASK>
</DD03P>
<DD03P>
<FIELDNAME>TIME_STAMP</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>p</INTTYPE>
<INTLEN>000008</INTLEN>
<DATATYPE>UTCL</DATATYPE>
<LENG>000027</LENG>
<MASK> UTCL</MASK>
</DD03P>
</DD03P_TABLE>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,826 @@
*&---------------------------------------------------------------------*
*& ABAP cheat sheet: Dynpro
*&
*&-------------------------- PURPOSE ----------------------------------*
*& - Example to demonstrate dynpro-related statements
*& - Topics covered: Dynpro flow logic and related statements (MODULE,
*& FIELD, CHAIN/ENDCHAIN, LOOP/ENDLOOP, CALL SUBSCREEN), ABAP statements
*& for calling and leaving dynpros (SET SCREEN, CALL SCREEN, LEAVE
*& SCREEN), modifying static attributes (LOOP AT SCREEN, MODIFY SCREEN),
*& statements related to the GUI status and title (GET/SET PF-STATUS,
*& SET TITLEBAR), controls (table and tabstrip controls)
*&
*&----------------------- GETTING STARTED -----------------------------*
*& - Open the program with the ABAP development tools for Eclipse (ADT).
*& - Choose F8 to run the program.
*& - Select the radio buttons and/or provide input in input fields etc.
*& to check out dynpro-related syntax in action.
*&
*&----------------------------- NOTE -----------------------------------*
*& The code presented in this class is intended only to support the ABAP
*& cheat sheets. It is not intended for direct use in a production system
*& environment. The code examples in the ABAP cheat sheets are primarily
*& intended to provide a better explanation and visualization of the
*& syntax and semantics of ABAP statements, not to solve concrete
*& programming tasks. For production application programs, you should
*& always work out your own solution for each individual case. There is
*& no guarantee for the correctness or completeness of the code.
*& Furthermore, there is no legal responsibility or liability for any
*& errors or their consequences that may occur when using the the example
*& code.
*&---------------------------------------------------------------------*
REPORT zdemo_abap_dynpro.
DATA:
"OK field
ok_code LIKE sy-ucomm,
"Auxiliary variable for storing the value of the OK field
save_ok LIKE ok_code,
dyn_num LIKE sy-dynnr,
dyn_title LIKE sy-title.
"Note: This demo database table does not have any semantic information
"that may be used for input helps etc.
TABLES zdemo_abap_flsch.
"----- Related to dynpro 9850 (Home page) -----
DATA: screen_elements TYPE abap_bool,
stmts TYPE abap_bool,
stmts2 TYPE abap_bool,
controls TYPE abap_bool.
"----- Related to dynpro 9860 (Screen elements) -----
DATA: "Icons
icon TYPE icons-text,
icon_name TYPE c LENGTH 20,
icon_text TYPE c LENGTH 10,
"check boxes
ch_a TYPE abap_bool,
ch_b TYPE abap_bool,
ch_c TYPE abap_bool,
checkbox_msg TYPE c LENGTH 4,
input_field TYPE c LENGTH 20,
"radio buttons
rb_x TYPE abap_bool,
rb_y TYPE abap_bool,
rb_z TYPE abap_bool,
radiobutton_msg TYPE c LENGTH 1.
"----- Related to dynpro 9870 (Statements I) -----
DATA: call_screen TYPE abap_bool,
call_screen_starting TYPE abap_bool,
call_screen_st_end TYPE abap_bool,
set_screen TYPE abap_bool,
leave_screen_next TYPE abap_bool,
leave_screen_set TYPE abap_bool,
leave_to_screen TYPE abap_bool,
set_pfstatus TYPE abap_bool,
set_pf_excluding TYPE abap_bool,
get_pfstatus TYPE abap_bool,
get_pfstatsus_excl TYPE abap_bool,
set_titlebar TYPE abap_bool,
set_titlebar_with TYPE abap_bool,
with_title TYPE c LENGTH 15,
col1 TYPE i,
lin1 TYPE i,
col2 TYPE i,
lin2 TYPE i,
col3 TYPE i,
lin3 TYPE i,
pf TYPE c LENGTH 1,
pfkey TYPE syst_pfkey,
title TYPE c LENGTH 1.
"Data type and objects for the EXCLUDING addition of GET/SET PF-STATUS
"statements
TYPES fu_key_tab TYPE TABLE OF sy-ucomm WITH NON-UNIQUE KEY table_line.
DATA: excl_list1 TYPE fu_key_tab,
excl_list2 TYPE fu_key_tab,
excl_list3 TYPE fu_key_tab.
"----- Related to dynpro 9880 (Statements II) -----
DATA: loop_modify TYPE abap_bool,
field_stmt TYPE abap_bool,
mod_at_exit TYPE abap_bool,
selected TYPE abap_bool,
set TYPE abap_bool,
field_a TYPE c LENGTH 1,
field_b TYPE c LENGTH 1,
field_c TYPE c LENGTH 1,
field_d TYPE c LENGTH 1,
field_e TYPE c LENGTH 1,
field_f TYPE c LENGTH 1,
output_field_1 TYPE c LENGTH 100,
output_field_2 TYPE c LENGTH 100,
output_field_3 TYPE c LENGTH 100,
field_help TYPE c LENGTH 30,
input_help TYPE c LENGTH 30,
"For GET/SET CURSOR statements
fld TYPE c LENGTH 20,
off TYPE i,
val TYPE string,
len TYPE i.
"For field and input help
TYPES: BEGIN OF values,
carrid TYPE zdemo_abap_flsch-carrid,
connid TYPE zdemo_abap_flsch-connid,
END OF values.
DATA: progname TYPE sy-repid,
dynnum TYPE sy-dynnr,
dynpro_values TYPE TABLE OF dynpread,
field_value LIKE LINE OF dynpro_values,
values_tab TYPE TABLE OF values,
tab TYPE TABLE OF zdemo_abap_flsch-carrid,
carr TYPE zdemo_abap_flsch-carrid,
conn TYPE zdemo_abap_flsch-connid.
DATA itab_flsch TYPE TABLE OF zdemo_abap_flsch-carrid.
TYPES: BEGIN OF carrid_line,
carrid TYPE zdemo_abap_flsch-carrid,
END OF carrid_line.
DATA carrid_list TYPE STANDARD TABLE OF carrid_line.
"----- Related to dynpro 9890 (Exit command) -----
"For demonstration purposes, implementations for the
"related dialog modules are done in methods of a local
"class.
"----- Related to dynpro 9990 (Controls) -----
"For table controls
DATA lines TYPE i.
DATA fill TYPE i.
CONTROLS flights TYPE TABLEVIEW USING SCREEN 9900.
"Internal table to hold data that is to be displayed.
DATA itab_flights TYPE TABLE OF zdemo_abap_flsch WITH EMPTY KEY.
"Filling the internal table
SELECT *
FROM zdemo_abap_flsch
ORDER BY carrid, connid
INTO TABLE @itab_flights.
"For tabstrip controls
CONTROLS tabstr TYPE TABSTRIP.
DATA number LIKE sy-dynnr.
"For ALV Grid control
TYPES: BEGIN OF flight_struc,
carrid TYPE zdemo_abap_flsch-carrid,
connid TYPE zdemo_abap_flsch-connid,
countryfr TYPE zdemo_abap_flsch-countryfr,
cityfrom TYPE zdemo_abap_flsch-cityfrom,
airpfrom TYPE zdemo_abap_flsch-airpfrom,
countryto TYPE zdemo_abap_flsch-countryto,
cityto TYPE zdemo_abap_flsch-cityto,
airpto TYPE zdemo_abap_flsch-airpto,
fltime TYPE zdemo_abap_flsch-fltime,
END OF flight_struc.
DATA itab4alv TYPE TABLE OF flight_struc WITH EMPTY KEY.
"----- For other dialog modules -----
DATA: links TYPE TABLE OF tline,
field_tab TYPE TABLE OF dfies WITH EMPTY KEY.
"----- Local class -----
CLASS local_class DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: provide_fu_keys IMPORTING example TYPE i
RETURNING VALUE(fu_keys) TYPE fu_key_tab,
cc_alv_display IMPORTING container TYPE c,
"Implementations for dialog modules for dynpro 9890
pbo9890,
pai9890,
cancel.
"Variable declarations for dialog modules for dynpro 9890
CLASS-DATA: mandatory_field TYPE c LENGTH 20,
btn_exit_1 TYPE abap_bool,
btn_exit_2 TYPE abap_bool.
ENDCLASS.
CLASS local_class IMPLEMENTATION.
METHOD provide_fu_keys.
CASE example.
WHEN 1.
fu_keys = VALUE #( ( 'CANCEL' ) ( 'SAP' ) ).
WHEN 2.
fu_keys = VALUE #( ( 'CANCEL' ) ).
WHEN OTHERS.
ENDCASE.
ENDMETHOD.
METHOD cc_alv_display.
DATA(cont) = NEW cl_gui_custom_container( container_name = container ).
SELECT carrid, connid, countryfr, cityfrom, airpfrom, countryto, cityto, airpto, fltime
FROM zdemo_abap_flsch
ORDER BY carrid, connid
INTO CORRESPONDING FIELDS OF TABLE @itab4alv.
TRY.
cl_salv_table=>factory( EXPORTING r_container = cont
container_name = CONV string( container )
IMPORTING r_salv_table = DATA(alv)
CHANGING t_table = itab4alv ).
alv->get_columns( )->set_optimize( abap_true ).
alv->get_display_settings( )->set_list_header( 'Flights' ).
LOOP AT alv->get_columns( )->get( ) ASSIGNING FIELD-SYMBOL(<col>).
DATA(column) = <col>-r_column.
column->set_long_text( |{ column->get_columnname( ) }| ).
ENDLOOP.
alv->display( ).
CATCH cx_salv_msg cx_salv_not_found.
MESSAGE `ALV display not possible` TYPE 'I'
DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
METHOD pai9890.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'CLOSE1'.
MESSAGE `Processing continues. It does so only after the input field is filled.` TYPE 'I'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'CLOSE2'.
MESSAGE `Superfluouse message :)` TYPE 'I'.
WHEN OTHERS.
MESSAGE `Processing continues. It does so only after the input field is filled.` TYPE 'I'.
LEAVE PROGRAM.
ENDCASE.
ENDMETHOD.
METHOD pbo9890.
SET PF-STATUS 'STATUS9890'.
SET TITLEBAR 'TITLE9890'.
dyn_num = sy-dynnr.
ENDMETHOD.
METHOD cancel.
MESSAGE `Module "cancel" was called. The dynpro will be left without the need to fill in the mandatory input field.` TYPE 'I'.
IF ok_code = 'CLOSE2'.
CLEAR: ok_code, mandatory_field.
SET SCREEN 0.
LEAVE SCREEN.
ENDIF.
ENDMETHOD.
ENDCLASS.
END-OF-SELECTION.
"Filling demo database tables
zcl_demo_abap_aux=>fill_dbtabs( ).
CALL SCREEN 9850.
**********************************************************************
***************** Dialog modules for 9850 ****************************
MODULE status_9850 OUTPUT.
SET PF-STATUS 'STATUS9850'.
SET TITLEBAR 'TITLE9850'.
CLEAR: screen_elements, stmts, stmts2.
dyn_num = sy-dynnr.
ENDMODULE.
MODULE user_command_9850 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'ENTER' OR 'GO'.
CASE abap_true.
WHEN screen_elements.
CALL SCREEN 9860.
WHEN stmts.
CALL SCREEN 9870.
WHEN stmts2.
CALL SCREEN 9880.
WHEN controls.
CALL SCREEN 9900.
ENDCASE.
WHEN OTHERS.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
***************** Dialog modules for 9860 ****************************
MODULE status_9860 OUTPUT.
SET PF-STATUS 'STATUS9860'.
SET TITLEBAR 'TITLE9860'.
"Modifying static attributes
IF loop_modify = 'X'.
LOOP AT SCREEN INTO DATA(scr).
IF scr-name = 'ICON3'.
scr-invisible = '1'.
MODIFY SCREEN FROM scr.
ENDIF.
IF scr-name = 'INPUT_FIELD'.
scr-length = 10.
scr-intensified = '1'.
"scr-required = '1'.
MODIFY SCREEN FROM scr.
ENDIF.
IF scr-name = 'RB_Z'.
scr-active = '0'.
MODIFY SCREEN FROM scr.
ENDIF.
IF scr-name = 'CH_B'.
scr-input = '0'.
MODIFY SCREEN FROM scr.
ENDIF.
ENDLOOP.
ENDIF.
dyn_num = sy-dynnr.
ENDMODULE.
MODULE user_command_9860 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
"Icons
WHEN 'ICON1'.
icon_name = 'ICON_GREEN_LIGHT'.
icon_text = `green`.
WHEN 'ICON2'.
icon_name = 'ICON_YELLOW_LIGHT'.
icon_text = `yellow`.
WHEN 'ICON3'.
icon_name = 'ICON_RED_LIGHT'.
icon_text = `red`.
"Input field
WHEN 'BTN_NO'.
MESSAGE |The text "{ input_field }" in the input field has { numofchar( input_field ) } characters. Trailing blanks are ignored.| TYPE 'I'.
"Check boxes
WHEN 'CH_BTN'.
IF ch_a = abap_true.
checkbox_msg = 'A'.
ENDIF.
IF ch_b = abap_true.
checkbox_msg = checkbox_msg && 'B'.
ENDIF.
IF ch_c = abap_true.
checkbox_msg = checkbox_msg && 'C'.
ENDIF.
IF checkbox_msg IS INITIAL.
checkbox_msg = 'None'.
ENDIF.
checkbox_msg = checkbox_msg.
MESSAGE checkbox_msg TYPE 'I'.
CLEAR checkbox_msg.
"Radio buttons
WHEN 'RB_BTN'.
CASE abap_true.
WHEN rb_x.
radiobutton_msg = 'X'.
WHEN rb_y.
radiobutton_msg = 'Y'.
WHEN rb_z.
radiobutton_msg = 'Z'.
WHEN OTHERS.
radiobutton_msg = ' '.
ENDCASE.
MESSAGE radiobutton_msg TYPE 'I'.
CLEAR radiobutton_msg.
WHEN 'HOME'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN OTHERS.
LEAVE PROGRAM.
ENDCASE.
IF save_ok = 'ICON1' OR save_ok = 'ICON2' OR save_ok = 'ICON3'.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = icon_name
text = icon_text
info = 'Status'
add_stdinf = 'X'
IMPORTING
result = icon
EXCEPTIONS
icon_not_found = 1
outputfield_too_short = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE `Issue.` TYPE 'I' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
ENDMODULE.
***************** Dialog modules for 9870 ****************************
MODULE status_9870 OUTPUT.
"Control structures in case of calling the dynpro again
IF set_pfstatus IS NOT INITIAL AND pfkey = 'STATUS9870'.
SET PF-STATUS 'DEMOSTATUS'.
ELSEIF set_pfstatus IS NOT INITIAL AND pfkey = 'DEMOSTATUS'.
SET PF-STATUS 'STATUS9870'.
ELSEIF set_pf_excluding IS NOT INITIAL AND pfkey = 'STATUS9870'.
excl_list1 = local_class=>provide_fu_keys( 1 ).
SET PF-STATUS 'DEMOSTATUS' EXCLUDING excl_list1.
ELSEIF set_pf_excluding IS NOT INITIAL AND pfkey = 'DEMOSTATUS'.
excl_list2 = local_class=>provide_fu_keys( 2 ).
SET PF-STATUS 'STATUS9870' EXCLUDING excl_list2.
ELSE.
SET PF-STATUS 'STATUS9870'.
ENDIF.
IF set_titlebar IS NOT INITIAL.
IF dyn_title CS 'Demo title'.
SET TITLEBAR 'TITLE9870'.
ELSE.
SET TITLEBAR 'DEMOTITLE'.
ENDIF.
ELSEIF SET_TITLEBAR_with IS NOT INITIAL.
SET TITLEBAR 'DEMOTITLE' WITH '"' with_title '"'.
ELSE.
SET TITLEBAR 'TITLE9870'.
ENDIF.
"Prepopulating values
col1 = 5.
lin1 = 10.
col2 = 1.
lin2 = 1.
col3 = 80.
lin3 = 20.
dyn_num = sy-dynnr.
dyn_title = sy-title.
ENDMODULE.
MODULE user_command_9870 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'ENTER' OR 'GO'.
CASE abap_true.
WHEN set_screen.
MESSAGE |A SET SCREEN statement is about to get called. The static next dynpro of dynpro { sy-dynnr } is 0.| &&
` It is dynamically overwritten. Another dynpro will be displayed. A new dynpro sequence is not started.` TYPE 'I'.
SET SCREEN 9860.
WHEN call_screen.
MESSAGE `A CALL SCREEN statement is about to get called. You will switch to another dynpro. A new dynpro sequence is started.` TYPE 'I'.
CALL SCREEN 9860.
WHEN call_screen_starting.
IF col1 < 0 OR lin1 < 0.
MESSAGE `Only positive integers can be specified.` TYPE 'E'.
ELSE.
MESSAGE |The statement "CALL SCREEN ... STARTING AT { col1 } { lin1 }." is about to get called. | &&
`Note: In the dialog box that opens, click the icon in the popup footer to remain in the program. Clicking the X leaves the program.` TYPE 'I'.
CALL SCREEN 9860 STARTING AT col1 lin1.
ENDIF.
WHEN call_screen_st_end.
IF col2 < 0 OR lin2 < 0
OR col3 < 0 OR lin3 < 0.
MESSAGE `Only positive integers can be specified.`
TYPE 'E'.
ELSE.
MESSAGE |The statement "CALL SCREEN ... STARTING AT { col2 } { lin2 } ENDING AT { col3 } { lin3 }| &&
`." is about to get called. Note: In the dialog box that opens, click the icon in the popup footer ` &&
`to remain in the program. Clicking the X leaves the program.` TYPE 'I'.
CALL SCREEN 9860 STARTING AT col2 lin2 ENDING AT col3 lin3.
ENDIF.
WHEN leave_screen_next.
MESSAGE `A LEAVE SCREEN statement is about to get called. The current dynpro is exited, and the statically ` &&
`defined next dynpro is called, which is 0 in this case. Hence, the current dynpro sequence is terminated. ` &&
`Since the dynpro sequence is nested, you return to the home page and the parent dynpro sequence.` TYPE 'I'.
LEAVE SCREEN.
WHEN leave_screen_set.
MESSAGE `A LEAVE SCREEN statement is about to get called. In this case, a SET SCREEN statement before the LEAVE ` &&
`SCREEN statement overwrites the next dynpro (0 here). A new dynpro sequence is not started, instead the statement ` &&
`branches to another dynpro in the same sequence.` TYPE 'I'.
SET SCREEN 9900.
LEAVE SCREEN.
WHEN leave_to_screen.
MESSAGE `A LEAVE TO SCREEN statement is about to get called. A new dynpro sequence is not started, instead the ` &&
`statement branches to another dynpro in the same sequence. It has the same effect as the previous example.` TYPE 'I'.
LEAVE TO SCREEN 9900.
WHEN set_pfstatus.
pfkey = sy-pfkey.
MESSAGE |The current GUI status is { pfkey }. The current dynpro { sy-dynnr } will be set as the next dynpro.| &&
` It will have a different GUI status.` TYPE 'I'.
SET SCREEN 9870.
WHEN set_pf_excluding.
GET PF-STATUS pfkey.
MESSAGE |The current GUI status is { pfkey }. The current dynpro will be set as the next dynpro.| &&
` It will have a different GUI status (set at PBO) but excluding function codes (for example, the CANCEL button).` TYPE 'I'.
SET SCREEN 9870.
WHEN get_pfstatus.
GET PF-STATUS pfkey.
MESSAGE |The current GUI status is { pfkey }, which was retrieved using GET-PF-STATUS. Value of sy-pfkey: { sy-pfkey }.| TYPE 'I'.
SET SCREEN 9870.
WHEN get_pfstatsus_excl.
GET PF-STATUS pfkey EXCLUDING excl_list3.
MESSAGE |The current GUI status is { pfkey }. The exluded function codes are: {
COND #( WHEN excl_list3 IS INITIAL THEN `None are excluded. Try to run SET PF-STATUS ... EXCLUDING ... first before this one.`
ELSE concat_lines_of( table = excl_list3 sep = `, ` ) ) }| TYPE 'I'.
SET SCREEN 9870.
CLEAR excl_list3.
WHEN set_titlebar.
MESSAGE |The current title is "{ dyn_title }". The current dynpro is set as the next dynpro.| &&
`The text in the title bar should change.` TYPE 'I'.
SET SCREEN 9870.
WHEN set_titlebar_with.
MESSAGE |The current title is "{ dyn_title }". The current dynpro is set as the next dynpro.| &&
`The text in the title bar should change according to your input in the input field.` TYPE 'I'.
SET SCREEN 9870.
ENDCASE.
WHEN 'SAP'.
cl_gui_frontend_services=>execute( document = 'https://www.sap.com' ).
SET SCREEN 9870.
WHEN 'SAYHI'.
MESSAGE `Hallo ` && sy-uname && `.` TYPE 'I'.
SET SCREEN 9870.
WHEN 'HOME'.
LEAVE TO SCREEN 9850.
WHEN 'LEAVE' OR 'CANCEL'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
***************** Dialog modules for 9880 ****************************
MODULE status_9880 OUTPUT.
SET PF-STATUS 'STATUS9880'.
SET TITLEBAR 'TITLE9880'.
"Clearing variables in case the dynpro is called again
IF field_stmt IS INITIAL.
CLEAR: output_field_1, output_field_2, output_field_3,
field_a, field_b, field_c, field_d, field_e, field_f.
ENDIF.
IF field_d IS INITIAL.
CLEAR output_field_2.
ENDIF.
IF field_e IS INITIAL OR field_f IS INITIAL.
CLEAR output_field_3.
ENDIF.
"Prepopulating fields for input help
progname = sy-repid.
dynnum = sy-dynnr.
CLEAR: field_value, dynpro_values.
field_value-fieldname = 'CARR'.
APPEND field_value TO dynpro_values.
"Setting the cursor field
IF set = abap_true.
SET CURSOR FIELD 'CONN'.
CLEAR set.
ENDIF.
dyn_num = sy-dynnr.
ENDMODULE.
MODULE user_command_9880 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'ENTER' OR 'GO'.
CASE abap_true.
WHEN loop_modify.
MESSAGE `Another dynpro will be set as the next dynpro. This dynpro includes a LOOP AT SCREEN ` &&
` and MODIFY SCREEN statements in the PBO dialog module. Some screen elements have their static ` &&
`attributes changed. For example, they are made invisible or inactive, or the length is changed.` TYPE 'I'.
SET SCREEN 9860.
LEAVE SCREEN.
WHEN field_stmt.
MESSAGE `The current dynpro will be set as the next dynpro. Depending on which checkboxes you ` &&
`have selected, text is displayed in the fields below showing the effect of FIELD statements.` TYPE 'I'.
SET SCREEN 9880.
WHEN mod_at_exit.
SET SCREEN 9890.
ENDCASE.
WHEN 'SELECTED'.
CLEAR conn.
SET SCREEN 9880.
WHEN 'GET'.
GET CURSOR FIELD fld OFFSET off VALUE val LENGTH len.
MESSAGE |Current position of cursor: Field: "{ fld }", value: "{ val }", offset: "{ off }", length "{ len }"| TYPE 'I'.
SET SCREEN 9880.
WHEN 'SET'.
set = abap_true.
MESSAGE `Clicking the pushbutton triggers a SET CURSOR statement to be called at PBO. This sets the cursor on ` &&
`a specific input field (the one in the lower left corner).` TYPE 'I'.
SET SCREEN 9880.
WHEN 'HOME'.
LEAVE TO SCREEN 9850.
WHEN 'LEAVE' OR 'CANCEL'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
***************** Dialog modules for 9890 ****************************
"For demonstration purposes, the dialog module implementations are
"done in methods of a local class.
MODULE status_9890 OUTPUT.
local_class=>pbo9890( ).
ENDMODULE.
MODULE user_command_9890 INPUT.
local_class=>pai9890( ).
ENDMODULE.
***************** Dialog modules for 9900 ****************************
MODULE status_9900 OUTPUT.
SET PF-STATUS 'STATUS9900'.
SET TITLEBAR 'TITLE9900'.
"For vertically scrolling in the table control
"To do this, the LINES component of the scxtab_control structure is set
"to the correct line number. Each time the scroll bar is scrolled, the
"PAI event is triggered with an empty function code, and the top_line
"component of the cxtab_control structure is automatically set to the
"new top line before PBO.
flights-lines = lines( itab_flights ).
"Setting a tab to be active by default in case of calling the
"dynpro again after leaving it.
IF tabstr-activetab IS INITIAL
OR number IS INITIAL.
number = '9920'.
tabstr-activetab = 'TAB2'.
ENDIF.
local_class=>cc_alv_display( 'ALVCONT' ).
dyn_num = sy-dynnr.
ENDMODULE.
MODULE user_command_9900 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'TAB1'.
number = '9910'.
tabstr-activetab = save_ok.
WHEN 'TAB2'.
number = '9920'.
tabstr-activetab = save_ok.
WHEN 'HOME'.
"REFRESH statement: You can check out the effect, for example, by setting
"the vertical scroll bar somewhere. If you then go back and call the dynpro
"again, the control is refreshed (the scroll bar is again at the top).
REFRESH CONTROL 'FLIGHTS' FROM SCREEN sy-dynnr.
CLEAR: number, tabstr-activetab.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'CANCEL' OR 'LEAVE'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
***************** Further dialog modules to support the example ****************************
MODULE module_1 INPUT.
output_field_1 = 'Available in module_1:' && ` ` &&
COND #( WHEN field_a = abap_true THEN 'A' ELSE '' ) &&
COND #( WHEN field_b = abap_true THEN 'B' ELSE '' ) &&
COND #( WHEN field_c = abap_true THEN 'C' ELSE '' ) &&
' /'.
ENDMODULE.
MODULE module_2 INPUT.
output_field_1 = output_field_1 &&
' Available in module_2:' && ` ` &&
COND #( WHEN field_a = abap_true THEN 'A' ELSE '' ) &&
COND #( WHEN field_b = abap_true THEN 'B' ELSE '' ) &&
COND #( WHEN field_c = abap_true THEN 'C' ELSE '' ) &&
' /'.
ENDMODULE.
MODULE module_3 INPUT.
output_field_1 = output_field_1 &&
' Available in module_3:' && ` ` &&
COND #( WHEN field_a = abap_true THEN 'A' ELSE '' ) &&
COND #( WHEN field_b = abap_true THEN 'B' ELSE '' ) &&
COND #( WHEN field_c = abap_true THEN 'C' ELSE '' ).
CLEAR: field_a, field_b, field_c.
ENDMODULE.
MODULE module_4 INPUT.
output_field_2 = 'module_4 was called because field_d was selected.'.
ENDMODULE.
MODULE module_5 INPUT.
output_field_3 = 'module_5 was called because field_e and field_f were selected.'.
ENDMODULE.
MODULE module_f1 INPUT.
"In this example, a demo object from the ABAP Keyword
"Documentation examples is used.
CALL FUNCTION 'HELP_OBJECT_SHOW'
EXPORTING
dokclass = 'TX'
doklangu = sy-langu
dokname = 'DEMO_FOR_F1_HELP'
TABLES
links = links.
ENDMODULE.
MODULE module_f4 INPUT.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = progname
dynumb = dynnum
translate_to_upper = 'X'
TABLES
dynpfields = dynpro_values.
field_value = dynpro_values[ 1 ].
SELECT carrid, connid
FROM zdemo_abap_flsch
WHERE carrid = @( CONV #( field_value-fieldvalue ) )
INTO CORRESPONDING FIELDS OF TABLE @values_tab.
"Note: To save extra artifacts, this example goes without a dedicated DDIC
"structure with which input help can be created comfortably. Hence, creating
"a table manually for the field_tab parameter of the function module below.
field_tab = VALUE #(
( tabname = 'ZDEMO_ABAP_FLSCH' fieldname = 'CARRID' langu = 'E' position = '1'
offset = '0' leng = '3' intlen = '6' outputlen = '3' datatype = 'CHAR' inttype = 'C' )
( tabname = 'ZDEMO_ABAP_FLSCH' fieldname = 'CONNID' langu = 'E' position = '2'
offset = '6' leng = '4' intlen = '8' outputlen = '4' datatype = 'NUMC' inttype = 'N' ) ).
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CONNID'
dynpprog = progname
dynpnr = dynnum
dynprofield = 'CONN'
value_org = 'S'
window_title = 'Selection'
TABLES
value_tab = values_tab
field_tab = field_tab.
ENDMODULE.
MODULE module_dropdown INPUT.
SELECT DISTINCT carrid
FROM zdemo_abap_flsch
INTO CORRESPONDING FIELDS OF TABLE @carrid_list.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CARRID'
value_org = 'S'
TABLES
value_tab = carrid_list
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
carr = 'LH'.
ENDIF.
ENDMODULE.
MODULE module_fill_table OUTPUT.
TRY.
zdemo_abap_flsch = itab_flights[ flights-current_line ].
CATCH cx_sy_itab_line_not_found.
RETURN.
ENDTRY.
ENDMODULE.
MODULE module_read_table INPUT.
lines = sy-loopc.
MODIFY itab_flights FROM zdemo_abap_flsch INDEX flights-current_line.
ENDMODULE.
MODULE cancel INPUT.
local_class=>cancel( ).
ENDMODULE.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,403 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
* Example: Event blocks
*
* -------------------------- PURPOSE ----------------------------------
* - Example that demonstrates event blocks
* - The main purpose of the example to visualize the calling of the
* events. Internal tables are filled during the events to log the
* event name and the time stamp when it is called. The tables
* are then output. It is implemented in such a way that it consists
* only of a basic list and a details list. Note the selection screen
* comments displayed.
* Includes:
* - Program constructor: LOAD-OF-PROGRAM
* - Reporting events: INITIALIZATION, START-OF-SELECTION
* - Selection screen events: AT SELECTION-SCREEN ...
* - List events: AT LINE-SELECTION, AT USER-COMMAND, TOP-OF-PAGE,
* END-OF-PAGE
*
* Notes:
* A selection of additions is used. For more additions and details,
* see the ABAP Keyword Documentation.
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
"LINE-COUNT: Specifies the page length for the basic list
"Number in parentheses: Lines that are reserved for the page footer,
"which can be specified in the END-OF-PAGE event block.
PROGRAM LINE-COUNT 20(3).
TYPES: BEGIN OF st,
id TYPE c LENGTH 3,
event_block TYPE c LENGTH 50,
time TYPE utclong,
END OF st.
DATA: counter_line TYPE i,
reporting_and_selscr_log TYPE TABLE OF st WITH EMPTY KEY,
list_log TYPE TABLE OF st WITH EMPTY KEY,
counter TYPE i,
tstmp TYPE utclong.
SELECTION-SCREEN COMMENT /1(70) intro.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK blk.
PARAMETERS: number1 TYPE string DEFAULT `1` VISIBLE LENGTH 5 .
PARAMETERS: number2 TYPE string DEFAULT `2` VISIBLE LENGTH 5 .
SELECTION-SCREEN END OF BLOCK blk.
PARAMETERS: plus RADIOBUTTON GROUP grp DEFAULT 'X',
minus RADIOBUTTON GROUP grp,
multiply RADIOBUTTON GROUP grp,
divide RADIOBUTTON GROUP grp.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT /1(70) note.
"Local class with methods used in the example in various places
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
sel_screen_evt IMPORTING evt TYPE string,
write_line IMPORTING evt TYPE string
utc TYPE utclong,
counter,
list_evt IMPORTING evt TYPE string,
write_rep_sel_log,
write_list_log.
CLASS-DATA: li_wa LIKE LINE OF list_log,
sel_wa LIKE LINE OF reporting_and_selscr_log.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD counter.
IF counter = 0.
counter = 1.
ELSE.
counter += 1.
ENDIF.
ENDMETHOD.
METHOD sel_screen_evt.
counter( ).
APPEND VALUE #( id = counter event_block = evt time = utclong_current( ) ) TO reporting_and_selscr_log.
ENDMETHOD.
METHOD list_evt.
counter( ).
APPEND VALUE #( id = counter event_block = evt time = utclong_current( ) ) TO list_log.
ENDMETHOD.
METHOD write_line.
counter( ).
WRITE: /3(*) counter,
15 evt,
60 utc.
ENDMETHOD.
METHOD write_rep_sel_log.
SKIP.
WRITE / '********** Log entries for reporting and selection screen events **********' COLOR 2.
FORMAT COLOR 2.
WRITE: /3 'ID', 15 'Event Block', 60 'Time' .
FORMAT COLOR OFF.
LOOP AT reporting_and_selscr_log INTO sel_wa.
WRITE: / sel_wa-id UNDER 'ID',
sel_wa-event_block UNDER 'Event Block',
sel_wa-time UNDER 'Time'.
ENDLOOP.
ENDMETHOD.
METHOD write_list_log.
WRITE / '********** Log entries for list events **********' COLOR 2.
FORMAT COLOR 2.
WRITE: /3 'ID', 15 'Event Block', 60 'Time' .
FORMAT COLOR OFF.
LOOP AT list_log INTO li_wa.
WRITE: / li_wa-id UNDER 'ID',
li_wa-event_block UNDER 'Event Block',
li_wa-time UNDER 'Time'.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
**********************************************************************
LOAD-OF-PROGRAM.
"Called when a program is loaded into the internal session
"When you call an executable programs with SUBMIT, it is recommended that
"you use the INITIALIZATION event for initializing data objects, since the
"initial values for parameters and selection criteria are set after LOAD-OF-PROGRAM.
demo=>sel_screen_evt( `LOAD-OF-PROGRAM` ).
**********************************************************************
INITIALIZATION.
"Called immediately after LOAD-OF-PROGRAM and before the selection
"screen processing of an existing standard selection screen.
"You can initialize the input fields of the selection screen here.
demo=>sel_screen_evt( `INITIALIZATION` ).
intro = 'Enter two integers and select a radio button for a calculation.'.
note = 'The Back/Exit/Cancel buttons raise the ON EXIT-COMMAND event.'.
**********************************************************************
AT SELECTION-SCREEN OUTPUT.
"Called by the dynpro event PBO of a selection screen
"Can be used for screen modifications.
demo=>sel_screen_evt( `AT SELECTION-SCREEN OUTPUT` ).
LOOP AT SCREEN INTO DATA(wa).
IF wa-name = 'INTRO'.
wa-intensified = '1'.
MODIFY SCREEN FROM wa.
ENDIF.
ENDLOOP.
**********************************************************************
AT SELECTION-SCREEN ON RADIOBUTTON GROUP grp.
"Called when the values for a radio button group was passed
demo=>sel_screen_evt( `AT SELECTION-SCREEN ON RADIOBUTTON GROUP` ).
CASE 'X'.
WHEN plus.
MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be +' TYPE 'I'.
WHEN minus.
MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be -' TYPE 'I'.
WHEN multiply.
MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be *' TYPE 'I'.
WHEN divide.
MESSAGE 'Event AT SELECTION-SCREEN ON RADIOBUTTON GROUP is called. The operator will be /' TYPE 'I'.
ENDCASE.
**********************************************************************
AT SELECTION-SCREEN ON BLOCK blk.
"Called when all input for a block is passed to the program
demo=>sel_screen_evt( `AT SELECTION-SCREEN ON BLOCK blk` ).
CONDENSE number1 NO-GAPS.
CONDENSE number2 NO-GAPS.
FIND PCRE `\D` IN number1.
DATA(subrc) = sy-subrc.
FIND PCRE `\D` IN number2.
IF subrc = 0
OR sy-subrc = 0.
MESSAGE 'Event AT SELECTION-SCREEN ON BLOCK is called. Provide correct integer values.' TYPE 'E'.
ENDIF.
**********************************************************************
AT SELECTION-SCREEN ON number1.
"Called when values for a parameter (which is the case here) or selection criteria were passed to the program
demo=>sel_screen_evt( `AT SELECTION-SCREEN ON number1.` ).
IF number1 IS INITIAL.
MESSAGE 'Event AT SELECTION-SCREEN ON is called. Please make an entry for number1' TYPE 'E'.
ENDIF.
**********************************************************************
AT SELECTION-SCREEN ON number2.
"Called when values for a parameter (which is the case here) or selection criteria were passed to the program
demo=>sel_screen_evt( `AT SELECTION-SCREEN ON number2.` ).
IF number2 IS INITIAL.
MESSAGE 'Please make an entry for number2' TYPE 'E'.
ENDIF.
**********************************************************************
AT SELECTION-SCREEN ON EXIT-COMMAND.
"Called in case of Back, Exit, or Cancel
MESSAGE 'Event AT SELECTION-SCREEN ON EXIT-COMMAND is called. See you.' TYPE 'I'.
**********************************************************************
AT SELECTION-SCREEN.
"Called as last event in the selection screen processing when all
"input values are passed to the program
demo=>sel_screen_evt( `AT SELECTION-SCREEN` ).
IF number2 = 0 AND
divide = 'X'.
MESSAGE 'Event AT SELECTION-SCREEN is called. Zero division is not possible.' TYPE 'E'.
ENDIF.
**********************************************************************
START-OF-SELECTION.
"Called during the processing of an executable program after selection
"screen processing
"SET USER-COMMAND: The following statement is included for demonstration
"purposes. It programmatically raises a list event with a specified function
"code.
"Such a statement can be used when creating a list. After the list has been
"created, but before the current list is displayed, the runtime
"framework responds as if a user action had been performed in the
"displayed list with the specified function code.
SET USER-COMMAND 'START'.
demo=>sel_screen_evt( `START-OF-SELECTION` ).
WRITE / 'This is the basic list showing the content of a log table (mostly reporting and selection screen events). Double-click a line in this list to display more events in a details list.' COLOR 4.
SKIP.
WRITE / '************************** Calculation result **************************' COLOR 2.
IF plus = 'X'.
WRITE / |{ number1 } + { number2 } = { number1 + number2 }|.
ENDIF.
IF minus = 'X'.
WRITE / |{ number1 } - { number2 } = { number1 - number2 }|.
ENDIF.
IF multiply = 'X'.
TRY.
WRITE / |{ number1 } * { number2 } = { number1 * number2 }|.
CATCH cx_sy_arithmetic_error INTO DATA(error).
WRITE / |{ number1 } * { number2 } = ??? Error in multiplication: { error->get_text( ) }| COLOR COL_NEGATIVE.
ENDTRY.
ENDIF.
IF divide = 'X'.
TRY.
WRITE / |{ number1 } / { number2 } = { CONV decfloat34( number1 / number2 ) DECIMALS = 3 }|.
IF number1 = 0 AND number2 = 0.
WRITE / `No zero division error? Note that ABAP "allows" zero division if the first number is also 0 :)` COLOR COL_NEGATIVE.
ENDIF.
CATCH cx_sy_zerodivide INTO error.
WRITE / |{ number1 } / { number2 } = ??? Error in division: { error->get_text( ) }| COLOR COL_NEGATIVE.
ENDTRY.
ENDIF.
IF reporting_and_selscr_log IS NOT INITIAL.
demo=>write_rep_sel_log( ).
ENDIF.
**********************************************************************
AT LINE-SELECTION.
"Called when
"- a screen list is displayed and
"- the screen cursor is on a list line and
"- a function is selected using the function code PICK
demo=>list_evt( evt = `AT LINE-SELECTION` ).
"SET USER-COMMAND: The following statement is included for demonstration
"purposes. It programmatically raises a list event with a specified function
"code.
SET USER-COMMAND 'LINE'.
IF sy-lsind <= 1.
WRITE / 'This is a details list. It shows the content of another log table (mostly list events). Clicking in this list does nothing meaningful.' COLOR 4.
WRITE / 'You may want to go back to the basic list, double-click a line there to come back here, and see more log entries added for list events.' COLOR 4.
WRITE / 'When the counter reaches 40, the program is restarted :)' COLOR 4.
SKIP.
WRITE / `************** Some sy Components **************` COLOR 2.
WRITE / |Content of clicked line (sy-lisel): "{ sy-lisel }"|.
WRITE / |Number of clicked line (sy-lilli): "{ sy-lilli }"|.
WRITE / |List level of the current list (sy-lsind): "{ sy-lsind }"|.
SKIP.
IF list_log IS NOT INITIAL.
demo=>write_list_log( ).
ENDIF.
ENDIF.
**********************************************************************
AT USER-COMMAND.
"Called when a function with a user-defined function code is selected when a screen list is displayed
"Note: PICK does not raised the AT USER-COMMAND event. Instead, it raises the AT LINE-SELECTION event.
CASE sy-ucomm.
WHEN 'START'.
demo=>list_evt( `AT USER-COMMAND (Function code: START)` ).
MESSAGE |AT USER-COMMAND event raised (Function code: START). Counter value: { counter }.| TYPE 'I'.
WHEN 'LINE'.
demo=>list_evt( `AT USER-COMMAND (Function code: LINE)` ).
MESSAGE |AT USER-COMMAND event raised (Function code: LINE). Counter value: { counter }.| TYPE 'I'.
IF counter >= 40.
MESSAGE |The counter has reached the threshold. The program will be started again using a SUBMIT statement.| TYPE 'I'.
SUBMIT (sy-repid) VIA SELECTION-SCREEN.
ENDIF.
ENDCASE.
**********************************************************************
TOP-OF-PAGE.
"Called when a basic list is created and when a new page begins
tstmp = utclong_current( ).
demo=>counter( ).
APPEND VALUE #( id = counter event_block = |TOP-OF-PAGE| time = tstmp ) TO list_log.
WRITE: / |********************* Title inserted at TOP-OF-PAGE event ({ counter }) *********************|.
**********************************************************************
TOP-OF-PAGE DURING LINE-SELECTION.
"Called when details lists are created
tstmp = utclong_current( ).
demo=>counter( ).
APPEND VALUE #( id = counter event_block = |TOP-OF-PAGE DURING LINE-SELECTION| time = tstmp ) TO list_log.
WRITE: / |********************* Title inserted at TOP-OF-PAGE DURING LINE-SELECTION event ({ counter }) *********************|.
**********************************************************************
END-OF-PAGE.
"Called when the end of a page is reached, for example, if the specified number of lines in the
"LINE-COUNT addition has been reached
tstmp = utclong_current( ).
demo=>counter( ).
APPEND VALUE #( id = counter event_block = |END-OF-PAGE| time = tstmp ) TO list_log.
WRITE: / |********************* Footer inserted at END-OF-PAGE event ({ counter }) *********************|.

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_EVENT_BLOCKS</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>Event blocks (ABAP cheat sheet: Selection Screens/Classic Lists)</ENTRY>
<LENGTH>64</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,3 @@
FUNCTION-POOL ZDEMO_ABAP_FUGR. "MESSAGE-ID ..
* INCLUDE LZDEMO_ABAP_FUGRD... " Local class definition

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>LZDEMO_ABAP_FUGRTOP</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>I</SUBC>
<APPL>S</APPL>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,15 @@
*******************************************************************
* System-defined Include-files. *
*******************************************************************
INCLUDE LZDEMO_ABAP_FUGRTOP. " Global Declarations
INCLUDE LZDEMO_ABAP_FUGRUXX. " Function Modules
*******************************************************************
* User-defined Include-files (if necessary). *
*******************************************************************
* INCLUDE LZDEMO_ABAP_FUGRF... " Subroutines
* INCLUDE LZDEMO_ABAP_FUGRO... " PBO-Modules
* INCLUDE LZDEMO_ABAP_FUGRI... " PAI-Modules
* INCLUDE LZDEMO_ABAP_FUGRE... " Events
* INCLUDE LZDEMO_ABAP_FUGRP... " Local class implement.
* INCLUDE LZDEMO_ABAP_FUGRT99. " ABAP Unit tests

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>SAPLZDEMO_ABAP_FUGR</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>F</SUBC>
<APPL>S</APPL>
<RLOAD>E</RLOAD>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_FUGR" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<AREAT>Demo function group</AREAT>
<INCLUDES>
<SOBJ_NAME>LZDEMO_ABAP_FUGRTOP</SOBJ_NAME>
<SOBJ_NAME>SAPLZDEMO_ABAP_FUGR</SOBJ_NAME>
</INCLUDES>
<FUNCTIONS>
<item>
<FUNCNAME>ZDEMO_ABAP_DELETE_FU</FUNCNAME>
<UPDATE_TASK>1</UPDATE_TASK>
<SHORT_TEXT>Demo update function module</SHORT_TEXT>
</item>
<item>
<FUNCNAME>ZDEMO_ABAP_LOG_FU</FUNCNAME>
<UPDATE_TASK>1</UPDATE_TASK>
<SHORT_TEXT>Demo update function module</SHORT_TEXT>
<IMPORT>
<RSIMP>
<PARAMETER>LOG</PARAMETER>
<TYP>ZCL_DEMO_ABAP_SAP_LUW_HELPER=&gt;LOG_TYPE</TYP>
</RSIMP>
<RSIMP>
<PARAMETER>CAUSE_ERROR</PARAMETER>
<DEFAULT>ABAP_FALSE</DEFAULT>
<OPTIONAL>X</OPTIONAL>
<TYP>ABAP_BOOL</TYP>
</RSIMP>
</IMPORT>
<DOCUMENTATION>
<RSFDO>
<PARAMETER>LOG</PARAMETER>
<KIND>P</KIND>
</RSFDO>
<RSFDO>
<PARAMETER>CAUSE_ERROR</PARAMETER>
<KIND>P</KIND>
</RSFDO>
</DOCUMENTATION>
</item>
<item>
<FUNCNAME>ZDEMO_ABAP_MODIFY_FU</FUNCNAME>
<UPDATE_TASK>1</UPDATE_TASK>
<SHORT_TEXT>Demo update function module</SHORT_TEXT>
<IMPORT>
<RSIMP>
<PARAMETER>VALUES</PARAMETER>
<TYP>ZDEMO_ABAP_LUW_T</TYP>
</RSIMP>
</IMPORT>
<DOCUMENTATION>
<RSFDO>
<PARAMETER>VALUES</PARAMETER>
<KIND>P</KIND>
</RSFDO>
</DOCUMENTATION>
</item>
</FUNCTIONS>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,34 @@
FUNCTION zdemo_abap_delete_fu.
*"----------------------------------------------------------------------
*"*"Update Function Module:
*"
*"*"Local Interface:
*"----------------------------------------------------------------------
DELETE FROM zdemo_abap_luw_t.
zcl_demo_abap_sap_luw_helper=>create_log_entries(
VALUE #( ( id = 70
context = 'Function module'
name = 'zdemo_abap_delete_fu'
details = `Function module called`
timestamp = utclong_current( ) )
( id = 71
context = 'Function module'
name = 'zdemo_abap_delete_fu'
details = zcl_demo_abap_sap_luw_helper=>get_work_process_info( )
timestamp = utclong_current( ) )
( id = 72
context = 'Function module'
name = 'zdemo_abap_delete_fu'
details = `SAP LUW Key: ` && cl_system_transaction_state=>get_sap_luw_key( )
timestamp = utclong_current( ) )
( id = 73
context = 'Function module'
name = 'zdemo_abap_delete_fu'
details = zcl_demo_abap_sap_luw_helper=>checking_transaction_state( )
timestamp = utclong_current( ) ) ) ).
ENDFUNCTION.

View File

@@ -0,0 +1,41 @@
FUNCTION ZDEMO_ABAP_LOG_FU.
*"----------------------------------------------------------------------
*"*"Update Function Module:
*"
*"*"Local Interface:
*" IMPORTING
*" VALUE(LOG) TYPE ZCL_DEMO_ABAP_SAP_LUW_HELPER=>LOG_TYPE
*" VALUE(CAUSE_ERROR) TYPE ABAP_BOOL DEFAULT ABAP_FALSE
*"----------------------------------------------------------------------
MODIFY zdemo_abap_logt FROM TABLE @log.
zcl_demo_abap_sap_luw_helper=>create_log_entries(
VALUE #( ( id = 90
context = `Function module`
name = `zdemo_abap_log_fu`
details = `Function module called`
timestamp = utclong_current( ) )
( id = 91
context = `Function module`
name = `zdemo_abap_log_fu`
details = zcl_demo_abap_sap_luw_helper=>get_work_process_info( )
timestamp = utclong_current( ) )
( id = 92
context = `Function module`
name = `zdemo_abap_log_fu`
details = `SAP LUW Key: ` && cl_system_transaction_state=>get_sap_luw_key( )
timestamp = utclong_current( ) )
( id = 93
context = `Function module`
name = `zdemo_abap_log_fu`
details = zcl_demo_abap_sap_luw_helper=>checking_transaction_state( )
timestamp = utclong_current( ) ) ) ).
IF cause_error = abap_true.
DATA(error_not_caught) = 1 / 0.
ENDIF.
ENDFUNCTION.

View File

@@ -0,0 +1,38 @@
FUNCTION ZDEMO_ABAP_MODIFY_FU.
*"----------------------------------------------------------------------
*"*"Update Function Module:
*"
*"*"Local Interface:
*" IMPORTING
*" VALUE(VALUES) TYPE ZDEMO_ABAP_LUW_T
*"----------------------------------------------------------------------
values-time_stamp = utclong_current( ).
MODIFY zdemo_abap_luw_t FROM @values.
zcl_demo_abap_sap_luw_helper=>create_log_entries(
VALUE #( ( id = 80
context = 'Function module'
name = 'zdemo_abap_modify_fu'
details = `Function module called`
timestamp = utclong_current( ) )
( id = 81
context = 'Function module'
name = 'zdemo_abap_modify_fu'
details = zcl_demo_abap_sap_luw_helper=>get_work_process_info( )
timestamp = utclong_current( ) )
( id = 82
context = 'Function module'
name = 'zdemo_abap_modify_fu'
details = `SAP LUW Key: ` && cl_system_transaction_state=>get_sap_luw_key( )
timestamp = utclong_current( ) )
( id = 83
context = 'Function module'
name = 'zdemo_abap_modify_fu'
details = zcl_demo_abap_sap_luw_helper=>checking_transaction_state( )
timestamp = utclong_current( ) ) ) ).
ENDFUNCTION.

View File

@@ -0,0 +1,515 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
* Example: Classic lists
*
* -------------------------- PURPOSE ----------------------------------
* Example that demonstrates various ABAP statements in the context of
* classic lists
* Includes:
* - Creating lists: WRITE, FORMAT, ULINE, SET BLANK LINES, SKIP,
* NEW-LINE, HIDE, HOTSPOT, RESERVE/BACK
* - Reading and modifying in lists: READ LINE, MODIFY LINE
*
* Notes:
* - A selection of additions is used. For more additions and details,
* see the ABAP Keyword Documentation.
* - See the ABAP cheat sheet for other statements used here, for example,
* the ones related to event blocks such as START-OF-SELECTION.
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
PROGRAM.
TYPES: BEGIN OF str,
statement TYPE string,
line_content TYPE string,
END OF str.
DATA: count TYPE i,
line LIKE sy-linno,
linno1 LIKE sy-linno,
linno2 LIKE sy-linno,
linno_int LIKE sy-linno,
linno_copy LIKE sy-linno,
linno_mod1 LIKE sy-linno,
linno_mod2 LIKE sy-linno,
linno_input LIKE sy-linno,
lisel_copy LIKE sy-lisel,
square TYPE i,
cube TYPE i,
int_for_back LIKE sy-colno,
itab TYPE string_table,
str_tab TYPE string_table,
lisel_tab TYPE string_table,
str TYPE string,
input_int TYPE c LENGTH 3 VALUE 3,
read_line TYPE c LENGTH 1,
num TYPE i,
char TYPE c LENGTH 10,
tab TYPE TABLE OF str WITH EMPTY KEY,
var LIKE input_int,
int TYPE i,
li LIKE LINE OF tab,
chck1 TYPE c LENGTH 1 VALUE 'X',
chck2 TYPE c LENGTH 1 VALUE ' ',
input TYPE c LENGTH 20 VALUE 'Make an entry here',
dc34 TYPE decfloat34 VALUE ' 1.2345 ',
txt TYPE string VALUE `abap`,
some_text TYPE string VALUE `Hi, `,
abc TYPE c LENGTH 5 VALUE 'abcde',
dc TYPE decfloat34 VALUE '1.2345'.
**********************************************************************
INITIALIZATION.
itab = VALUE #( ( `a` ) ( `b` ) ( `` ) ( `` ) ( `c` ) ).
**********************************************************************
START-OF-SELECTION.
"WRITE using an unnamed data object
WRITE 'Hello ABAP.'.
"Named data objects
"Note: The text is written right after the previous text in one line.
WRITE some_text && sy-uname.
WRITE / '****************** WRITE: Positioning output ******************'.
"/: Writes to a new line
WRITE / 'new line'.
"Specifying the output position (and output in new line)
WRITE /5 'positioned'.
"Specifying the length, no position specified means the output is
"written from the first column on
WRITE /(3) 'not displayed completely'.
"Specifying both length and position
WRITE /5(30) 'this is displayed completely'.
"Position/length only specified as numeric literals as above, then the
"addition AT can be omitted
WRITE AT /3(12) 'lorem ipsum'.
"Length specifications with * or **. In that case, the output length
"depends on the data type of the data object. There are special rules.
"See the ABAP Kwyword Documentation for the details.
WRITE /(*) dc34.
WRITE /1(**) dc34.
WRITE / '****************** WRITE: Further specification options ******************'.
"There are many further specification options, among them function calls, string
"expressions, method calls to be specified after WRITE.
"String template
WRITE / |{ txt WIDTH = 20 ALIGN = RIGHT CASE = UPPER }|.
"The following statement uses a chained statement with colon.
WRITE: / |{ 1 + 2 }|, "String template includes an arithmetic calculation
/ to_upper( txt ). "Function call
"Concatenation using &&
WRITE / `conc` && `atenated`.
"Method call (returns a random integer between 1 and 10)
"Note the * specification. The returned value is of type i. Specifying *
"for the length means the length required to output the current value
"is used. You may want to try the following code snippet by removing (*).
WRITE /(*) cl_abap_random_int=>create(
seed = cl_abap_random=>seed( )
min = 1
max = 10 )->get_next( ).
WRITE / '****************** WRITE: UNDER addition ******************'.
"UNDER: Puts the output in the position of previous output
"Note: If the output is written in the same line in which the previous output
"is displayed, this output is overwritten.
WRITE /5(5) abc.
WRITE / 'fghij' UNDER abc.
WRITE / '****************** WRITE: NO-GAP addition ******************'.
WRITE / 'g'.
WRITE 'ap1'. "Output: g ap1
WRITE: / 'g' NO-GAP, 'ap2'. "Output: gap2
WRITE / '****************** WRITE: QUICKINFO addition ******************'.
"QUICKINFO: Creates a tooltip for the output
WRITE / 'Hover over the following output and check the tooltip:'.
WRITE: (*) sy-uname QUICKINFO 'User name',
'/',
(*) sy-datum QUICKINFO 'Current date',
'/',
(*) sy-uzeit QUICKINFO 'Current time'.
WRITE / '****************** WRITE: Special list elements ******************'.
"INPUT
WRITE / input INPUT.
linno_input = sy-linno.
"AS CHECKBOX
"The value (blank, X) is stored in the list buffer and can be evaluated during
"a list event.
WRITE: / chck1 AS CHECKBOX, 'Checkbox 1',
/ chck2 AS CHECKBOX, 'Checkbox 2'.
"AS ICON: Outputting icons
"Check the type pool ICON for names of predefined icons.
WRITE / icon_green_light AS ICON.
WRITE / icon_red_light AS ICON.
WRITE / icon_yellow_light AS ICON.
WRITE / icon_activate AS ICON.
"AS SYMBOL: Outputting symbols
"Check the type pool SYM for names of predefined icons.
WRITE / sym_left_hand AS SYMBOL.
WRITE / sym_caution AS SYMBOL.
"AS LINE: Outputting corners, crosses, lines, and T sections
"Check the type pool LINE for names of predefined icons.
WRITE: /10 line_horizontal_line AS LINE NO-GAP,
line_space AS LINE NO-GAP,
line_vertical_line AS LINE NO-GAP.
WRITE / '****************** WRITE: Formatting options ******************'.
"The following examples show a selection. Various other additions are
"available that deal with currency, unit, date and time-related formatting,
"among others. See the ABAP Keyword Documentation.
WRITE /(10) 'X' RIGHT-JUSTIFIED.
WRITE /(10) 'X' CENTERED.
WRITE /(10) ` X`.
WRITE /(10) ` X` LEFT-JUSTIFIED.
WRITE /(*) dc DECIMALS 2.
"Colors
"The commented out value stands for the value that can also be directly
"specified in the syntax (except 0) or contained in a data object.
"There are several additions with many options.
WRITE / 'COL_BACKGROUND (0)' COLOR COL_BACKGROUND. "0 (GUI dependent)
WRITE / 'COL_HEADING (1)' COLOR COL_HEADING. "1 (gray-blue)
WRITE / 'COL_HEADING (1)' COLOR 1.
WRITE / 'COL_NORMAL (2)' COLOR COL_NORMAL. "2 (light gray)
WRITE / 'COL_TOTAL (3)' COLOR COL_TOTAL. "3 (yellow)
WRITE / 'COL_KEY (4)' COLOR COL_KEY. "4 (blue-green)
WRITE / 'COL_POSITIVE (5)' COLOR COL_POSITIVE. "5 (green)
WRITE / 'COL_NEGATIVE (6)' COLOR COL_NEGATIVE. "6 (red)
WRITE / 'COL_GROUP (7)' COLOR COL_GROUP. "7 (purple/orange)
WRITE / 'COLOR 7 OFF' COLOR 7 OFF. "default color
"Setting the intensity of the background color.
WRITE / 'COLOR 7 INTENSIFIED OFF' COLOR 7 INTENSIFIED OFF.
"INVERSE: When ON, the foreground, i.e. the output is displayed
"in the selected color.
WRITE / 'COLOR 7 INVERSE ON' COLOR 7 INVERSE ON.
WRITE / '****************** FORMAT ******************'.
"FORMAT: For applying settings (COLOR, INTENSIFIED, INVERSE ...)
"on all of the following output statements up to a definition
"with new settings
WRITE / '****************** FORMAT: FRAMES addition ******************'.
"FRAMES: Defines whether the - and | characters are converted to line elements,
"producing continuous lines.
FORMAT FRAMES ON.
WRITE: / '----',
/ '| |',
/ '----'.
FORMAT FRAMES OFF.
WRITE / '****************** FORMAT: COLOR addition ******************'.
"This example shows the already covered COLOR addition with FORMAT
"statements.
FORMAT COLOR COL_POSITIVE.
WRITE / 'ABC'.
WRITE / 'DEF'.
WRITE / 'GHI'.
FORMAT COLOR OFF.
WRITE / 'This is the first WRITE after a new setting with FORMAT ... OFF'.
WRITE / '****************** FORMAT: RESET addition ******************'.
"This addition sets all formatting settings for which the corresponding addition is
"not specified in the same FORMAT statement to the state OFF (exception: FRAMES).
"In the following example, note the effect of the RESET addition (apart from
"resetting the previously set COLOR and INVERSE addition:
"- INTENSIFIED ON is the state after the program start by default.
"- Now, with the reset, the state is INTENSIFIED OFF.
"- See the effect for all the WRITE statements that follow and that have
" the COLOR addition specified.
FORMAT COLOR 7 INVERSE ON.
WRITE / 'ABC'.
WRITE / 'DEF'.
FORMAT RESET.
WRITE / 'GHI'.
WRITE / 'JKL'.
WRITE / '****************** ULINE ******************'.
"ULINE: Creating a horizontal line
ULINE.
"More additions are available such as for the position and length.
ULINE AT 5(20).
WRITE / '****************** SET BLANK LINES ******************'.
"SET BLANK LINES: Specifying if blank lines created using WRITE are displayed
WRITE / 'SET BLANK LINES OFF.' COLOR 2.
SET BLANK LINES OFF.
LOOP AT itab INTO DATA(wa).
WRITE / wa.
ENDLOOP.
WRITE / 'SET BLANK LINES ON.' COLOR 3.
SET BLANK LINES ON.
LOOP AT itab INTO wa.
WRITE / wa.
ENDLOOP.
ULINE.
WRITE / '****************** SKIP ******************'.
"SKIP: Positions the list cursor explicitly
WRITE / 'SKIP' COLOR 4.
SKIP.
WRITE / 'SKIP 3' COLOR 5.
SKIP 3.
ULINE.
WRITE / 'SKIP TO LINE' COLOR 6.
WRITE / 'Text A'.
WRITE / 'Text B'.
line = sy-linno. "The line number of the previous output is retrieved.
WRITE / 'Text C'.
SKIP TO LINE line.
WRITE / 'Text D' COLOR 7.
WRITE / 'Text E'.
ULINE.
WRITE / '****************** NEW-LINE ******************'.
"NEW-LINE: Setting list cursor to the first position of the next line.
"Additions are available to affect the scrolling behavior.
WRITE / 'Next statement is NEW-LINE'.
NEW-LINE.
WRITE 'WRITE statement without /'.
ULINE.
WRITE / '****************** HIDE/HOTSPOT ******************'.
"The example contains a DO loop. In this loop, WRITE statements output
"the sy-index value (1 to 10). Based on the sy-index value, calculations
"are performed. The result is hidden using HIDE. When you click a line
"in the basic list in this very section, the hidden values are displayed
"in the details list.
WRITE / 'For the values of square and cube, click a line in this section.'.
linno1 = sy-linno.
FORMAT HOTSPOT ON.
DO 10 TIMES.
square = sy-index ** 2.
cube = sy-index ** 3.
WRITE / sy-index.
"Storing the content of a the variables together with the current list line.
HIDE: square, cube.
ENDDO.
FORMAT HOTSPOT OFF.
linno2 = sy-linno.
WRITE / '****************** RESERVE/BACK ******************'.
"RESERVE is demonstrated here with BACK.
"Consider the RESERVE 5 LINES statements as defining a block of
"5 lines. When using BACK after RESERVE, e.g. after a loop, you
"can put the suqsequent output to the first line of this block of lines.
WRITE / 'RESERVE without BACK:'.
int_for_back = sy-colno.
ULINE AT /(int_for_back).
RESERVE 5 LINES.
DO 5 TIMES.
WRITE / sy-index.
ENDDO.
int_for_back = sy-colno.
WRITE AT int_for_back ' <- This is not number 1.'.
SKIP.
WRITE / 'RESERVE with BACK:'.
int_for_back = sy-colno.
ULINE AT /(int_for_back).
RESERVE 5 LINES.
DO 5 TIMES.
WRITE / sy-index.
ENDDO.
int_for_back = sy-colno.
BACK.
WRITE AT int_for_back ' <- This should be number 1.'.
SKIP 5.
WRITE / '****************** READ LINE ******************'.
"READ LINE: Assigning the content of a line stored in the
"list buffer to the system field sy-lisel. Plus, it allows
"other target fields to be specified.
"In the example, you can provide an integer in an input field
"on whose basis a READ LINE statement is executed.
WRITE / 'Insert a number representing a line number from which to read: '.
FORMAT INPUT.
WRITE / input_int.
linno_int = sy-linno.
FORMAT INPUT OFF.
WRITE / '****************** MODIFY LINE ******************'.
"MODIFY LINE: Overwrites a line stored in the list buffer with the
"content of the sy-lisel system field Plus, it allows additional
"modifications.
"In the example, you can click 7 times in the very section on whose
"basis a MODIFY LINE statement is executed.
WRITE / 'Click 7 times on any line in this section starting from "1 A" to explore the effect of MODIFY LINE statements.'.
SKIP.
linno_mod1 = sy-linno.
DO 10 TIMES.
num += 1.
char &&= 'A'.
WRITE /10(*) num.
WRITE 15 char.
ENDDO.
linno_mod2 = sy-linno.
**********************************************************************
AT LINE-SELECTION.
"The purpose of the following implementation is to avoid multiple
"details lists when clicking lines.
IF sy-lsind = 1
AND sy-lilli BETWEEN linno_mod1 AND linno_mod2.
CASE count.
WHEN 0.
MODIFY CURRENT LINE LINE VALUE FROM 'Overwritten'.
WHEN 1.
MODIFY CURRENT LINE FIELD VALUE char FROM 'BBBB'.
WHEN 2.
MODIFY CURRENT LINE FIELD VALUE num FROM '#' char FROM 'CCCC'.
WHEN 3.
MODIFY CURRENT LINE FIELD FORMAT char COLOR 3.
WHEN 4.
MODIFY CURRENT LINE LINE FORMAT COLOR 4.
WHEN 5.
MODIFY CURRENT LINE FIELD FORMAT num COLOR 5 char COLOR 6
LINE FORMAT COLOR 7.
WHEN 6.
linno_copy = linno_mod1.
WHILE linno_copy <= linno_mod2.
MODIFY LINE linno_copy LINE VALUE FROM ':)' LINE FORMAT COLOR 3.
linno_copy += 1.
IF sy-index = 11.
EXIT.
ENDIF.
ENDWHILE.
WHEN OTHERS.
EXIT.
ENDCASE.
count += 1.
ELSEIF sy-lsind = 1
AND sy-lilli NOT BETWEEN linno_mod1 AND linno_mod2.
WRITE / `************************ Information about the line you clicked ************************` COLOR 7 INTENSIFIED OFF.
SKIP.
WRITE / |Line content (sy-lisel): "{ sy-lisel }"|.
WRITE / |Line number (sy-lilli): "{ sy-lilli }"|.
SKIP.
ULINE.
SKIP.
WRITE / `************************ HIDE statements ************************` COLOR 7 INTENSIFIED OFF.
SKIP.
IF sy-lilli NOT BETWEEN linno1 + 1 AND linno2.
WRITE / |You have clicked on line { sy-lilli } and not on a line between line { linno1 + 1 } and line { linno2 }.|.
WRITE / `For exploring the effect of HIDE and displaying the values of 'square' and 'cube', click a line in the HIDE/HOTSPOT section of the basic list.`.
ELSE.
WRITE: / |square: { square }|.
WRITE: / |cube: { cube }|.
ENDIF.
"READ LINE
CLEAR str_tab.
CLEAR lisel_tab.
SKIP.
ULINE.
SKIP.
WRITE / `************************ READ LINE statements ************************` COLOR 7 INTENSIFIED OFF.
SKIP.
READ CURRENT LINE.
IF sy-subrc <> 0.
lisel_copy = sy-lisel.
APPEND VALUE #( statement = |READ CURRENT LINE. (sy-lisel contains line content)| line_content = |ERROR: Line does not exist| ) TO tab.
ELSE.
lisel_copy = sy-lisel.
APPEND VALUE #( statement = |READ CURRENT LINE. (sy-lisel contains line content)| line_content = |sy-lisel: "{ lisel_copy }"| ) TO tab.
ENDIF.
"Put the entire line content (current line) of the read result in a data object
READ CURRENT LINE LINE VALUE INTO str.
IF sy-subrc <> 0.
APPEND VALUE #( statement = `READ CURRENT LINE LINE VALUE INTO ...` line_content = `ERROR: Line does not exist` ) TO tab.
ELSE.
APPEND VALUE #( statement = `READ CURRENT LINE LINE VALUE INTO ...` line_content = |str: "{ lisel_copy }"| ) TO tab.
ENDIF.
"Specific line
TRY.
"Put concrete field values (specified line) of the read result in data objects
READ LINE linno_int FIELD VALUE input_int INTO var.
APPEND VALUE #( statement = |READ LINE { linno_int } FIELD VALUE ... INTO var. (Line of the input field)| line_content = |var: "{ var }"| ) TO tab.
int = var.
"Read entire line content
READ LINE int.
IF sy-subrc = 0.
lisel_copy = sy-lisel.
APPEND VALUE #( statement = |READ LINE { int }. (sy-lisel contains line content)| line_content = |sy-lisel: "{ lisel_copy }"| ) TO tab.
ELSE.
APPEND VALUE #( statement = |READ LINE { int }.| line_content = |ERROR: Line { int } does not exist| ) TO tab.
ENDIF.
CATCH cx_root.
APPEND VALUE #( statement = |READ LINE { var }.| line_content = |ERROR: That statement does not work. Insert an integer value.| ) TO tab.
ENDTRY.
IF tab IS NOT INITIAL.
LOOP AT tab INTO li.
WRITE: / li-statement COLOR 2,
/ li-line_content.
SKIP.
ENDLOOP.
ENDIF.
CLEAR: tab, input, str.
ULINE.
SKIP.
WRITE / `************************ MODIFY LINE statements ************************` COLOR 7 INTENSIFIED OFF.
SKIP.
WRITE / `To explore MODIFY LINE statements, click the lines in the MODIFY LINE section of the basic list.`.
SKIP.
ENDIF.

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_LISTS</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>Classic Lists (ABAP Cheat Sheet: Selection Screens/Classic Lists)</ENTRY>
<LENGTH>65</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_TABL" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DD02V>
<TABNAME>ZDEMO_ABAP_LOGT</TABNAME>
<DDLANGUAGE>E</DDLANGUAGE>
<TABCLASS>TRANSP</TABCLASS>
<CLIDEP>X</CLIDEP>
<DDTEXT>Log table</DDTEXT>
<MASTERLANG>E</MASTERLANG>
<CONTFLAG>A</CONTFLAG>
<EXCLASS>1</EXCLASS>
</DD02V>
<DD09L>
<TABNAME>ZDEMO_ABAP_LOGT</TABNAME>
<AS4LOCAL>A</AS4LOCAL>
<TABKAT>0</TABKAT>
<TABART>APPL0</TABART>
<BUFALLOW>N</BUFALLOW>
</DD09L>
<DD03P_TABLE>
<DD03P>
<FIELDNAME>CLIENT</FIELDNAME>
<KEYFLAG>X</KEYFLAG>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>C</INTTYPE>
<INTLEN>000006</INTLEN>
<NOTNULL>X</NOTNULL>
<DATATYPE>CLNT</DATATYPE>
<LENG>000003</LENG>
<MASK> CLNT</MASK>
</DD03P>
<DD03P>
<FIELDNAME>ID</FIELDNAME>
<KEYFLAG>X</KEYFLAG>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>X</INTTYPE>
<INTLEN>000004</INTLEN>
<NOTNULL>X</NOTNULL>
<DATATYPE>INT4</DATATYPE>
<LENG>000010</LENG>
<MASK> INT4</MASK>
</DD03P>
<DD03P>
<FIELDNAME>CONTEXT</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>C</INTTYPE>
<INTLEN>000030</INTLEN>
<DATATYPE>CHAR</DATATYPE>
<LENG>000015</LENG>
<MASK> CHAR</MASK>
</DD03P>
<DD03P>
<FIELDNAME>NAME</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>C</INTTYPE>
<INTLEN>000040</INTLEN>
<DATATYPE>CHAR</DATATYPE>
<LENG>000020</LENG>
<MASK> CHAR</MASK>
</DD03P>
<DD03P>
<FIELDNAME>DETAILS</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>g</INTTYPE>
<INTLEN>000008</INTLEN>
<DATATYPE>STRG</DATATYPE>
<MASK> STRG</MASK>
</DD03P>
<DD03P>
<FIELDNAME>TIMESTAMP</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>p</INTTYPE>
<INTLEN>000008</INTLEN>
<DATATYPE>UTCL</DATATYPE>
<LENG>000027</LENG>
<MASK> UTCL</MASK>
</DD03P>
</DD03P_TABLE>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_TABL" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DD02V>
<TABNAME>ZDEMO_ABAP_LUW_T</TABNAME>
<DDLANGUAGE>E</DDLANGUAGE>
<TABCLASS>TRANSP</TABCLASS>
<CLIDEP>X</CLIDEP>
<DDTEXT>Demo database table</DDTEXT>
<MASTERLANG>E</MASTERLANG>
<CONTFLAG>A</CONTFLAG>
<EXCLASS>1</EXCLASS>
</DD02V>
<DD09L>
<TABNAME>ZDEMO_ABAP_LUW_T</TABNAME>
<AS4LOCAL>A</AS4LOCAL>
<TABKAT>0</TABKAT>
<TABART>APPL0</TABART>
<BUFALLOW>N</BUFALLOW>
</DD09L>
<DD03P_TABLE>
<DD03P>
<FIELDNAME>CLIENT</FIELDNAME>
<KEYFLAG>X</KEYFLAG>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>C</INTTYPE>
<INTLEN>000006</INTLEN>
<NOTNULL>X</NOTNULL>
<DATATYPE>CLNT</DATATYPE>
<LENG>000003</LENG>
<MASK> CLNT</MASK>
</DD03P>
<DD03P>
<FIELDNAME>KEY_FIELD</FIELDNAME>
<KEYFLAG>X</KEYFLAG>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>X</INTTYPE>
<INTLEN>000004</INTLEN>
<NOTNULL>X</NOTNULL>
<DATATYPE>INT4</DATATYPE>
<LENG>000010</LENG>
<MASK> INT4</MASK>
</DD03P>
<DD03P>
<FIELDNAME>CH</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>C</INTTYPE>
<INTLEN>000020</INTLEN>
<DATATYPE>CHAR</DATATYPE>
<LENG>000010</LENG>
<MASK> CHAR</MASK>
</DD03P>
<DD03P>
<FIELDNAME>NUM</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>X</INTTYPE>
<INTLEN>000004</INTLEN>
<DATATYPE>INT4</DATATYPE>
<LENG>000010</LENG>
<MASK> INT4</MASK>
</DD03P>
<DD03P>
<FIELDNAME>TIME_STAMP</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>p</INTTYPE>
<INTLEN>000008</INTLEN>
<DATATYPE>UTCL</DATATYPE>
<LENG>000027</LENG>
<MASK> UTCL</MASK>
</DD03P>
</DD03P_TABLE>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,513 @@
*&---------------------------------------------------------------------*
*& ABAP cheat sheet: SAP LUW
*&
*&-------------------------- PURPOSE ----------------------------------*
*& - Example to demonstrate ABAP syntax in the context of the SAP LUW.
*& - Topics covered: Using update function modules and subroutines as
*& bundling techniques, synchronous/asynchronous/local updates
*&
*&----------------------- GETTING STARTED -----------------------------*
*& - Open the program with the ABAP development tools for Eclipse (ADT).
*& - Choose F8 to run the program.
*& - Select the radio buttons and choose 'Go' to progress with the program.
*&
*&----------------------------- NOTE -----------------------------------*
*&* The code presented in this class is intended only to support the ABAP
*&* cheat sheets. It is not intended for direct use in a production system
*&* environment. The code examples in the ABAP cheat sheets are primarily
*&* intended to provide a better explanation and visualization of the
*&* syntax and semantics of ABAP statements, not to solve concrete
*&* programming tasks. For production application programs, you should
*&* always work out your own solution for each individual case. There is
*&* no guarantee for the correctness or completeness of the code.
*&* Furthermore, there is no legal responsibility or liability for any
*&* errors or their consequences that may occur when using the the example
*&* code.
*&---------------------------------------------------------------------*
REPORT zdemo_abap_sap_luw.
DATA: tab_struc TYPE zdemo_abap_luw_t,
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
del_insert TYPE abap_bool,
perform TYPE abap_bool,
commit TYPE abap_bool,
commit_wait TYPE abap_bool,
local_update TYPE abap_bool,
err TYPE abap_bool,
rollback TYPE abap_bool,
terminate TYPE abap_bool,
dynnr TYPE sy-dynnr,
counter TYPE i,
log_itab TYPE zcl_demo_abap_sap_luw_helper=>log_type.
CLASS lcl DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF request4log,
log TYPE zdemo_abap_logt,
called TYPE abap_bool,
wp_info TYPE abap_bool,
luw_key TYPE abap_bool,
tx_state TYPE abap_bool,
END OF request4log.
CLASS-METHODS: prep,
create_log_entries IMPORTING req TYPE request4log.
ENDCLASS.
CLASS lcl IMPLEMENTATION.
METHOD prep.
DELETE FROM zdemo_abap_luw_t.
INSERT zdemo_abap_luw_t FROM TABLE @( VALUE #(
( key_field = 1
ch = 'DEMO DATA'
num = 11
time_stamp = utclong_current( ) )
( key_field = 2
ch = 'THAT WAS'
num = 22
time_stamp = utclong_current( ) )
( key_field = 3
ch = 'CREATED'
num = 33
time_stamp = utclong_current( ) )
( key_field = 4
ch = 'IN ADVANCE'
num = 44
time_stamp = utclong_current( ) ) ) ).
DELETE FROM zdemo_abap_logt.
ENDMETHOD.
METHOD create_log_entries.
IF req-called = abap_true.
counter += 1.
INSERT VALUE #( id = counter
context = req-log-context
name = req-log-name
details = `Called!`
timestamp = utclong_current( )
) INTO TABLE log_itab.
ENDIF.
IF req-luw_key = abap_true.
counter += 1.
INSERT VALUE #( id = counter
context = req-log-context
name = req-log-name
details = `SAP LUW key: ` &&
cl_system_transaction_state=>get_sap_luw_key( )
timestamp = utclong_current( )
) INTO TABLE log_itab.
ENDIF.
IF req-wp_info = abap_true.
counter += 1.
INSERT VALUE #( id = counter
context = req-log-context
name = req-log-name
details =
zcl_demo_abap_sap_luw_helper=>get_work_process_info( )
timestamp = utclong_current( )
) INTO TABLE log_itab.
ENDIF.
IF req-tx_state = abap_true.
counter += 1.
INSERT VALUE #(
id = counter
context = req-log-context
name = req-log-name
details =
zcl_demo_abap_sap_luw_helper=>checking_transaction_state( )
timestamp = utclong_current( )
) INTO TABLE log_itab.
ENDIF.
ENDMETHOD.
ENDCLASS.
FORM delete.
zcl_demo_abap_sap_luw_helper=>subr_delete( ).
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'Subroutine'
name = 'delete' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
ENDFORM.
FORM insert.
DATA values TYPE zdemo_abap_luw_t.
IMPORT values = values FROM MEMORY ID 'DEMO_INSERT'.
IF sy-subrc = 0.
values-time_stamp = utclong_current( ).
zcl_demo_abap_sap_luw_helper=>subr_insert( values ).
ENDIF.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'Subroutine'
name = 'insert' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
ENDFORM.
FORM update_log.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'Subroutine'
name = 'update_log' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
zcl_demo_abap_sap_luw_helper=>subr_update_log( log_itab ).
ENDFORM.
FORM call_on_rollback.
"No implementation here. Only to demonstrate that the
"subroutine is called in the event of triggering a
"rollback.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'Subroutine'
name = 'call_on_rollback' )
called = abap_true
luw_key = abap_true
tx_state = abap_true ) ).
ENDFORM.
END-OF-SELECTION.
lcl=>prep( ).
counter += 1.
INSERT VALUE #(
id = counter
context = '-'
name = '-'
details = |Program { sy-repid } has been started.| &&
`The first dynpro is about to be called.`
timestamp = utclong_current( )
) INTO TABLE log_itab.
counter += 1.
INSERT VALUE #( id = counter
context = '-'
name = '-'
details = `SAP LUW Key: ` &&
cl_system_transaction_state=>get_sap_luw_key( )
timestamp = utclong_current( )
) INTO TABLE log_itab.
CALL SCREEN 9750.
**********************************************************************
***************** Dialog modules for 9750 ****************************
MODULE status_9750 OUTPUT.
SET PF-STATUS 'STATUS9750'.
SET TITLEBAR 'TITLE9750'.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PBO'
name = 'status_9750' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
zcl_demo_abap_sap_luw_helper=>cc_alv_display( 'DBENTRIES' ).
dynnr = sy-dynnr.
ENDMODULE.
MODULE user_command_9750 INPUT.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PAI'
name = 'user_command_9750' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'GO' OR 'ENTER'.
IF del_insert = abap_true.
CALL FUNCTION 'ZDEMO_ABAP_DELETE_FU' IN UPDATE TASK.
MESSAGE `A function module has been registered ` &&
`that clears the database table.` TYPE 'I'.
ELSEIF local_update = abap_true.
SET UPDATE TASK LOCAL.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PAI'
name = 'user_command_9750' )
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
CALL FUNCTION 'ZDEMO_ABAP_DELETE_FU' IN UPDATE TASK.
MESSAGE `Local update has been activated. A function ` &&
`module has been registered that clears the database table.` &&
` No matter if you choose COMMIT WORK or COMMIT WORK AND ` &&
`WAIT in the next step, it will be a synchronous update.` TYPE 'I'.
ELSEIF perform = abap_true.
PERFORM delete ON COMMIT.
PERFORM call_on_rollback ON ROLLBACK.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PAI'
name = 'user_command_9750' )
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
MESSAGE `Subroutines have been registered for commit ` &&
`and rollback.` TYPE 'I'.
ENDIF.
WHEN OTHERS.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
***************** Dialog modules for 9760 ****************************
MODULE status_9760 OUTPUT.
SET PF-STATUS 'STATUS9760'.
SET TITLEBAR 'TITLE9760'.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PBO'
name = 'status_9760' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
dynnr = sy-dynnr.
ENDMODULE.
MODULE user_command_9760 INPUT.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PAI'
name = 'user_command_9760' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'GO' OR 'ENTER'.
IF perform = abap_true.
"Registered subroutines cannot have any parameter interface.
"Therefore, data can only be passed through external interfaces,
"for example, the ABAP memory.
EXPORT values = tab_struc TO MEMORY ID 'DEMO_INSERT'.
PERFORM insert ON COMMIT.
MESSAGE `A subroutine that inserts the entries in the ` &&
`database table has been registered. ` &&
`When you select a commit option in the next step, ` &&
`COMMIT WORK and COMMIT WORK AND WAIT have ` &&
`the same effect. The subroutines are executed in ` &&
`the current work process in this case.` TYPE 'I'.
ELSE.
CALL FUNCTION 'ZDEMO_ABAP_MODIFY_FU' IN UPDATE TASK
EXPORTING
values = tab_struc.
MESSAGE `An update function module that inserts the ` &&
`entries in the database table has ` &&
`been registered.` TYPE 'I'.
ENDIF.
WHEN OTHERS.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
***************** Dialog modules for 9770 ****************************
MODULE status_9770 OUTPUT.
SET PF-STATUS 'STATUS9770'.
SET TITLEBAR 'TITLE9770'.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PBO'
name = 'status_9770' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
dynnr = sy-dynnr.
IF perform = 'X'.
LOOP AT SCREEN INTO DATA(scr).
IF scr-name = 'EXCURSION_WP'
OR scr-name = 'WAIT'
OR scr-name = 'FAIL_LUW'
OR scr-name = 'ERR'
OR scr-name = 'TERMINATE'
OR scr-name = 'ERROR_A'.
scr-invisible = '1'.
MODIFY SCREEN FROM scr.
ENDIF.
ENDLOOP.
ENDIF.
ENDMODULE.
MODULE user_command_9770 INPUT.
lcl=>create_log_entries(
VALUE #( log = VALUE #( context = 'PAI'
name = 'user_command_9770' )
called = abap_true
luw_key = abap_true
tx_state = abap_true
wp_info = abap_true ) ).
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'GO' OR 'ENTER' OR 'OK'.
CASE 'X'.
WHEN commit.
IF perform = abap_false.
CALL FUNCTION 'ZDEMO_ABAP_LOG_FU' IN UPDATE TASK
EXPORTING
log = log_itab.
MESSAGE `An update function module that inserts ` &&
`entries for the log has been registered. ` &&
`COMMIT WORK is about to be executed.` TYPE 'I'.
ELSE.
PERFORM update_log ON COMMIT.
MESSAGE `A subroutine that inserts entries for the ` &&
`log has been registered ` &&
`COMMIT WORK is about to be executed.` TYPE 'I'.
ENDIF.
COMMIT WORK.
SELECT COUNT(*) FROM zdemo_abap_luw_t INTO @DATA(entries).
MESSAGE `COMMIT WORK has been executed. Current ` &&
`number of database table entries: ` &&
entries &&
`. If it is 4 and not 1, the update will be done ` &&
`asynchronously.` TYPE 'I'.
WHEN commit_wait.
IF perform = abap_false.
CALL FUNCTION 'ZDEMO_ABAP_LOG_FU' IN UPDATE TASK
EXPORTING
log = log_itab.
MESSAGE `An update function module that inserts ` &&
`entries for the log has been registered. ` &&
`COMMIT WORK AND WAIT is about to be executed.` TYPE 'I'.
ELSE.
PERFORM update_log ON COMMIT.
MESSAGE `A subroutine that inserts entries for the ` &&
`log has been registered ` &&
`COMMIT WORK AND WAIT is about to be executed.` TYPE 'I'.
ENDIF.
COMMIT WORK AND WAIT.
SELECT COUNT(*) FROM zdemo_abap_luw_t INTO @entries.
MESSAGE `COMMIT WORK AND WAIT has been executed. Current ` &&
`number of database table entries: ` &&
entries &&
`. If it is 1, the update has been done synchronously.` TYPE 'I'.
WHEN rollback.
ROLLBACK WORK.
MESSAGE `ROLLBACK WORK has been executed. A rollback has ` &&
`been triggered. The original database table content ` &&
`should be displayed.`
TYPE 'I'.
MESSAGE `Note: As an exception, and only for this demo ` &&
`example, the sample implementation includes a ` &&
`database update to the log table after the ` &&
`table after the rollback, just to show the progress of the ` &&
`execution up to that point.` TYPE 'I' DISPLAY LIKE 'E'.
"Update log table
zcl_demo_abap_sap_luw_helper=>create_log_entries( log_itab ).
"Log information for triggering a rollback
zcl_demo_abap_sap_luw_helper=>create_log_entries(
VALUE #( ( id = 99
context = '-'
name = '-'
details = `Rollback triggered`
timestamp = utclong_current( ) ) ) ).
WHEN err.
CALL FUNCTION 'ZDEMO_ABAP_LOG_FU' IN UPDATE TASK
EXPORTING
log = log_itab
cause_error = abap_true.
IF local_update = abap_true.
MESSAGE `A function module has been registered that ` &&
`causes an error (zero division). COMMIT WORK AND WAIT ` &&
`is about to be executed. You are directly informed ` &&
`about the error and the program is terminated. All ` &&
`changes are implicitly rolled back. You can check ` &&
`transaction ST22 for the error caused.` TYPE 'I'.
ELSE.
MESSAGE `Function module was registered that ` &&
`causes an error (zero division). COMMIT WORK AND WAIT` &&
` will be excetued. All changes are implicitly rolled back.` &&
` When you start over or leave the example in the next dynpro, ` &&
`you should be informed about the issue in the Business Workplace. ` &&
`Also check ST22.` TYPE 'I'.
ENDIF.
COMMIT WORK AND WAIT.
WHEN terminate.
MESSAGE `This is an error message of type A. ` &&
`It termiantes the program. All changes are ` &&
`implicitly rolled back. ` &&
`You may want to check the database table entries of ` &&
`the example that remain unchanged.` TYPE 'A'.
ENDCASE.
WHEN OTHERS.
LEAVE PROGRAM.
ENDCASE.
SUBMIT ('ZDEMO_ABAP_SAP_LUW_DISPL').
ENDMODULE.

View File

@@ -0,0 +1,864 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_SAP_LUW</NAME>
<DBAPL>S</DBAPL>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<DYNPROS>
<item>
<HEADER>
<PROGRAM>ZDEMO_ABAP_SAP_LUW</PROGRAM>
<SCREEN>9750</SCREEN>
<LANGUAGE>E</LANGUAGE>
<DESCRIPT>Delete database table entries</DESCRIPT>
<TYPE>N</TYPE>
<NEXTSCREEN>9760</NEXTSCREEN>
<LINES>027</LINES>
<COLUMNS>121</COLUMNS>
</HEADER>
<CONTAINERS>
<RPY_DYCATT>
<TYPE>SCREEN</TYPE>
<NAME>SCREEN</NAME>
</RPY_DYCATT>
<RPY_DYCATT>
<TYPE>RADIOGROUP</TYPE>
<NAME>%A_DEL_INSERT</NAME>
<ELEMENT_OF>SCREEN</ELEMENT_OF>
<LINE>006</LINE>
<COLUMN>004</COLUMN>
<LENGTH>076</LENGTH>
<HEIGHT>003</HEIGHT>
</RPY_DYCATT>
<RPY_DYCATT>
<TYPE>CUST_CTRL</TYPE>
<NAME>DBENTRIES</NAME>
<ELEMENT_OF>SCREEN</ELEMENT_OF>
<LINE>012</LINE>
<COLUMN>005</COLUMN>
<LENGTH>068</LENGTH>
<HEIGHT>007</HEIGHT>
</RPY_DYCATT>
</CONTAINERS>
<FIELDS>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX1</NAME>
<TEXT>The_SAP_LUW_is_started._In_this_example,_all_the_entries_in_a_database_table_(see_below)_are_to_be_deleted.</TEXT>
<LINE>002</LINE>
<COLUMN>004</COLUMN>
<LENGTH>107</LENGTH>
<VISLENGTH>107</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX2</NAME>
<TEXT>The_ABAP_SQL_statement_is_implemented_in_an_update_function_module_and_a_subroutine._</TEXT>
<LINE>003</LINE>
<COLUMN>004</COLUMN>
<LENGTH>085</LENGTH>
<VISLENGTH>085</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX3</NAME>
<TEXT>Choose_one_of_the_following_options:</TEXT>
<LINE>004</LINE>
<COLUMN>004</COLUMN>
<LENGTH>036</LENGTH>
<VISLENGTH>036</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX4</NAME>
<TEXT>Current_database_table_entries:</TEXT>
<LINE>010</LINE>
<COLUMN>004</COLUMN>
<LENGTH>031</LENGTH>
<VISLENGTH>031</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX5</NAME>
<TEXT>Dynpro_number:</TEXT>
<LINE>021</LINE>
<COLUMN>005</COLUMN>
<LENGTH>014</LENGTH>
<VISLENGTH>014</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEMPLATE</TYPE>
<NAME>DYNNR</NAME>
<TEXT>___________</TEXT>
<LINE>021</LINE>
<COLUMN>021</COLUMN>
<LENGTH>011</LENGTH>
<VISLENGTH>011</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<OUTPUT_FLD>X</OUTPUT_FLD>
<OUTPUTONLY>X</OUTPUTONLY>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>OKCODE</TYPE>
<NAME>OK_CODE</NAME>
<TEXT>____________________</TEXT>
<LENGTH>020</LENGTH>
<VISLENGTH>020</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_DEL_INSERT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>DEL_INSERT</NAME>
<TEXT>Use_update_task_(CALL_FUNCTION_..._IN_UPDATE_TASK_statement)</TEXT>
<LINE>006</LINE>
<COLUMN>004</COLUMN>
<LENGTH>062</LENGTH>
<VISLENGTH>062</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_DEL_INSERT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>LOCAL_UPDATE</NAME>
<TEXT>Use_update_task_and_perform_local_update_(SET_UPDATE_TASK_LOCAL_statement)</TEXT>
<LINE>007</LINE>
<COLUMN>004</COLUMN>
<LENGTH>076</LENGTH>
<VISLENGTH>076</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_DEL_INSERT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>PERFORM</NAME>
<TEXT>Use_subroutines_(PERFORM_statement)</TEXT>
<LINE>008</LINE>
<COLUMN>004</COLUMN>
<LENGTH>037</LENGTH>
<VISLENGTH>037</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
</FIELDS>
<FLOW_LOGIC>
<RPY_DYFLOW>
<LINE>PROCESS BEFORE OUTPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE STATUS_9750.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW/>
<RPY_DYFLOW>
<LINE>PROCESS AFTER INPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE USER_COMMAND_9750.</LINE>
</RPY_DYFLOW>
</FLOW_LOGIC>
</item>
<item>
<HEADER>
<PROGRAM>ZDEMO_ABAP_SAP_LUW</PROGRAM>
<SCREEN>9760</SCREEN>
<LANGUAGE>E</LANGUAGE>
<DESCRIPT>Create database table entry</DESCRIPT>
<TYPE>N</TYPE>
<NEXTSCREEN>9770</NEXTSCREEN>
<LINES>027</LINES>
<COLUMNS>121</COLUMNS>
</HEADER>
<CONTAINERS>
<RPY_DYCATT>
<TYPE>SCREEN</TYPE>
<NAME>SCREEN</NAME>
</RPY_DYCATT>
</CONTAINERS>
<FIELDS>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX7</NAME>
<TEXT>To_create_a_database_table_entry,_make_entries_in_the_following_input_fields:</TEXT>
<LINE>002</LINE>
<COLUMN>003</COLUMN>
<LENGTH>077</LENGTH>
<VISLENGTH>077</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX8</NAME>
<TEXT>KEY_FIELD</TEXT>
<LINE>004</LINE>
<COLUMN>003</COLUMN>
<LENGTH>009</LENGTH>
<VISLENGTH>009</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
<LABELLEFT>X</LABELLEFT>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEMPLATE</TYPE>
<NAME>TAB_STRUC-KEY_FIELD</NAME>
<TEXT>_______.__</TEXT>
<LINE>004</LINE>
<COLUMN>015</COLUMN>
<LENGTH>010</LENGTH>
<VISLENGTH>010</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>INT4</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX11</NAME>
<TEXT>Type_i</TEXT>
<LINE>004</LINE>
<COLUMN>028</COLUMN>
<LENGTH>006</LENGTH>
<VISLENGTH>006</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX9</NAME>
<TEXT>CH</TEXT>
<LINE>006</LINE>
<COLUMN>003</COLUMN>
<LENGTH>002</LENGTH>
<VISLENGTH>002</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
<LABELLEFT>X</LABELLEFT>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEMPLATE</TYPE>
<NAME>TAB_STRUC-CH</NAME>
<TEXT>__________</TEXT>
<LINE>006</LINE>
<COLUMN>015</COLUMN>
<LENGTH>010</LENGTH>
<VISLENGTH>010</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX12</NAME>
<TEXT>Type_c_length_10</TEXT>
<LINE>006</LINE>
<COLUMN>028</COLUMN>
<LENGTH>016</LENGTH>
<VISLENGTH>016</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX10</NAME>
<TEXT>NUM</TEXT>
<LINE>008</LINE>
<COLUMN>003</COLUMN>
<LENGTH>003</LENGTH>
<VISLENGTH>003</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
<LABELLEFT>X</LABELLEFT>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEMPLATE</TYPE>
<NAME>TAB_STRUC-NUM</NAME>
<TEXT>_______.__</TEXT>
<LINE>008</LINE>
<COLUMN>015</COLUMN>
<LENGTH>010</LENGTH>
<VISLENGTH>010</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>INT4</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX13</NAME>
<TEXT>Type_i</TEXT>
<LINE>008</LINE>
<COLUMN>028</COLUMN>
<LENGTH>006</LENGTH>
<VISLENGTH>006</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX14</NAME>
<TEXT>Dynpro_number:</TEXT>
<LINE>011</LINE>
<COLUMN>003</COLUMN>
<LENGTH>014</LENGTH>
<VISLENGTH>014</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEMPLATE</TYPE>
<NAME>DYNNR</NAME>
<TEXT>___________</TEXT>
<LINE>011</LINE>
<COLUMN>019</COLUMN>
<LENGTH>011</LENGTH>
<VISLENGTH>011</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<OUTPUT_FLD>X</OUTPUT_FLD>
<OUTPUTONLY>X</OUTPUTONLY>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>OKCODE</TYPE>
<NAME>OK_CODE</NAME>
<TEXT>____________________</TEXT>
<LENGTH>020</LENGTH>
<VISLENGTH>020</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
</RPY_DYFATC>
</FIELDS>
<FLOW_LOGIC>
<RPY_DYFLOW>
<LINE>PROCESS BEFORE OUTPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE STATUS_9760.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW/>
<RPY_DYFLOW>
<LINE>PROCESS AFTER INPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE USER_COMMAND_9760.</LINE>
</RPY_DYFLOW>
</FLOW_LOGIC>
</item>
<item>
<HEADER>
<PROGRAM>ZDEMO_ABAP_SAP_LUW</PROGRAM>
<SCREEN>9770</SCREEN>
<LANGUAGE>E</LANGUAGE>
<DESCRIPT>End SAP LUW</DESCRIPT>
<TYPE>N</TYPE>
<NEXTSCREEN>0000</NEXTSCREEN>
<LINES>027</LINES>
<COLUMNS>121</COLUMNS>
</HEADER>
<CONTAINERS>
<RPY_DYCATT>
<TYPE>SCREEN</TYPE>
<NAME>SCREEN</NAME>
</RPY_DYCATT>
<RPY_DYCATT>
<TYPE>RADIOGROUP</TYPE>
<NAME>%A_COMMIT</NAME>
<ELEMENT_OF>SCREEN</ELEMENT_OF>
<LINE>004</LINE>
<COLUMN>003</COLUMN>
<LENGTH>048</LENGTH>
<HEIGHT>005</HEIGHT>
</RPY_DYCATT>
</CONTAINERS>
<FIELDS>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX6</NAME>
<TEXT>Select_one_of_the_following_options_to_proceed:</TEXT>
<LINE>002</LINE>
<COLUMN>003</COLUMN>
<LENGTH>047</LENGTH>
<VISLENGTH>047</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
<LABELLEFT>X</LABELLEFT>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>%#AUTOTEXT009</NAME>
<TEXT>Dynpro_number:</TEXT>
<LINE>012</LINE>
<COLUMN>003</COLUMN>
<LENGTH>014</LENGTH>
<VISLENGTH>014</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEMPLATE</TYPE>
<NAME>DYNNR</NAME>
<TEXT>___________</TEXT>
<LINE>012</LINE>
<COLUMN>018</COLUMN>
<LENGTH>011</LENGTH>
<VISLENGTH>011</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<OUTPUT_FLD>X</OUTPUT_FLD>
<OUTPUTONLY>X</OUTPUTONLY>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>OKCODE</TYPE>
<NAME>OK_CODE</NAME>
<TEXT>____________________</TEXT>
<LENGTH>020</LENGTH>
<VISLENGTH>020</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_COMMIT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>COMMIT</NAME>
<TEXT>Asynchronous_update_with_COMMIT_WORK</TEXT>
<LINE>004</LINE>
<COLUMN>003</COLUMN>
<LENGTH>038</LENGTH>
<VISLENGTH>038</VISLENGTH>
<HEIGHT>001</HEIGHT>
<GROUP1>1</GROUP1>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_COMMIT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>COMMIT_WAIT</NAME>
<TEXT>Synchronous_update_with_COMMIT_WORK_AND_WAIT</TEXT>
<LINE>005</LINE>
<COLUMN>003</COLUMN>
<LENGTH>046</LENGTH>
<VISLENGTH>046</VISLENGTH>
<HEIGHT>001</HEIGHT>
<GROUP1>1</GROUP1>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_COMMIT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>ROLLBACK</NAME>
<TEXT>Rollback_changes_using_ROLLBACK_WORK</TEXT>
<LINE>006</LINE>
<COLUMN>003</COLUMN>
<LENGTH>038</LENGTH>
<VISLENGTH>038</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_COMMIT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>ERR</NAME>
<TEXT>Cause_a_failure_in_the_current_SAP_LUW</TEXT>
<LINE>007</LINE>
<COLUMN>003</COLUMN>
<LENGTH>040</LENGTH>
<VISLENGTH>040</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>RADIOGROUP</CONT_TYPE>
<CONT_NAME>%A_COMMIT</CONT_NAME>
<TYPE>RADIO</TYPE>
<NAME>TERMINATE</NAME>
<TEXT>Terminate_program_with_error_message_of_type_A</TEXT>
<LINE>008</LINE>
<COLUMN>003</COLUMN>
<LENGTH>048</LENGTH>
<VISLENGTH>048</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
<OUTPUT_FLD>X</OUTPUT_FLD>
</RPY_DYFATC>
</FIELDS>
<FLOW_LOGIC>
<RPY_DYFLOW>
<LINE>PROCESS BEFORE OUTPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE STATUS_9770.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW/>
<RPY_DYFLOW>
<LINE>PROCESS AFTER INPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE USER_COMMAND_9770.</LINE>
</RPY_DYFLOW>
</FLOW_LOGIC>
</item>
</DYNPROS>
<CUA>
<ADM>
<ACTCODE>000003</ACTCODE>
<PFKCODE>000003</PFKCODE>
</ADM>
<STA>
<RSMPE_STAT>
<CODE>STATUS9750</CODE>
<MODAL>D</MODAL>
<ACTCODE>000001</ACTCODE>
<PFKCODE>000001</PFKCODE>
<BUTCODE>0001</BUTCODE>
<INT_NOTE>Delete database table entries</INT_NOTE>
</RSMPE_STAT>
<RSMPE_STAT>
<CODE>STATUS9760</CODE>
<MODAL>D</MODAL>
<ACTCODE>000002</ACTCODE>
<PFKCODE>000002</PFKCODE>
<BUTCODE>0001</BUTCODE>
<INT_NOTE>Create database table entry</INT_NOTE>
</RSMPE_STAT>
<RSMPE_STAT>
<CODE>STATUS9770</CODE>
<MODAL>D</MODAL>
<ACTCODE>000003</ACTCODE>
<PFKCODE>000003</PFKCODE>
<BUTCODE>0001</BUTCODE>
<INT_NOTE>End SAP LUW</INT_NOTE>
</RSMPE_STAT>
</STA>
<FUN>
<RSMPE_FUNT>
<CODE>ENTER</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<FUN_TEXT>Enter</FUN_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>GO</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<TEXT_NAME>ICON_MAPPED_RELATION</TEXT_NAME>
<ICON_ID>@EY@</ICON_ID>
<FUN_TEXT>Go</FUN_TEXT>
<ICON_TEXT>Go</ICON_TEXT>
<INFO_TEXT>Go</INFO_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>LEAVE</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<FUN_TEXT>Exit</FUN_TEXT>
</RSMPE_FUNT>
</FUN>
<BUT>
<RSMPE_BUT>
<PFK_CODE>000001</PFK_CODE>
<CODE>0001</CODE>
<NO>01</NO>
<PFNO>08</PFNO>
</RSMPE_BUT>
<RSMPE_BUT>
<PFK_CODE>000002</PFK_CODE>
<CODE>0001</CODE>
<NO>01</NO>
<PFNO>08</PFNO>
</RSMPE_BUT>
<RSMPE_BUT>
<PFK_CODE>000003</PFK_CODE>
<CODE>0001</CODE>
<NO>01</NO>
<PFNO>08</PFNO>
</RSMPE_BUT>
</BUT>
<PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>00</PFNO>
<FUNCODE>ENTER</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>08</PFNO>
<FUNCODE>GO</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>15</PFNO>
<FUNCODE>LEAVE</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000002</CODE>
<PFNO>00</PFNO>
<FUNCODE>ENTER</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000002</CODE>
<PFNO>08</PFNO>
<FUNCODE>GO</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000002</CODE>
<PFNO>15</PFNO>
<FUNCODE>LEAVE</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000003</CODE>
<PFNO>00</PFNO>
<FUNCODE>ENTER</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000003</CODE>
<PFNO>08</PFNO>
<FUNCODE>GO</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000003</CODE>
<PFNO>15</PFNO>
<FUNCODE>LEAVE</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
</PFK>
<SET>
<RSMPE_STAF>
<STATUS>STATUS9750</STATUS>
<FUNCTION>ENTER</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9750</STATUS>
<FUNCTION>GO</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9750</STATUS>
<FUNCTION>LEAVE</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9760</STATUS>
<FUNCTION>ENTER</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9760</STATUS>
<FUNCTION>GO</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9760</STATUS>
<FUNCTION>LEAVE</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9770</STATUS>
<FUNCTION>ENTER</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9770</STATUS>
<FUNCTION>GO</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9770</STATUS>
<FUNCTION>LEAVE</FUNCTION>
</RSMPE_STAF>
</SET>
<DOC>
<RSMPE_ATRT>
<OBJ_TYPE>A</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Delete database table entries</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>P</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Delete database table entries</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>B</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<SUB_CODE>0001</SUB_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Delete database table entries</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>A</OBJ_TYPE>
<OBJ_CODE>000002</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Create database table entry</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>P</OBJ_TYPE>
<OBJ_CODE>000002</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Create database table entry</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>B</OBJ_TYPE>
<OBJ_CODE>000002</OBJ_CODE>
<SUB_CODE>0001</SUB_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Create database table entry</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>A</OBJ_TYPE>
<OBJ_CODE>000003</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>End SAP LUW</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>P</OBJ_TYPE>
<OBJ_CODE>000003</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>End SAP LUW</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>B</OBJ_TYPE>
<OBJ_CODE>000003</OBJ_CODE>
<SUB_CODE>0001</SUB_CODE>
<MODAL>D</MODAL>
<INT_NOTE>End SAP LUW</INT_NOTE>
</RSMPE_ATRT>
</DOC>
<TIT>
<RSMPE_TITT>
<CODE>TITLE9750</CODE>
<TEXT>Delete database table entries</TEXT>
</RSMPE_TITT>
<RSMPE_TITT>
<CODE>TITLE9760</CODE>
<TEXT>Create database table entry</TEXT>
</RSMPE_TITT>
<RSMPE_TITT>
<CODE>TITLE9770</CODE>
<TEXT>End SAP LUW</TEXT>
</RSMPE_TITT>
</TIT>
</CUA>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>Demonstrating SAP LUW</ENTRY>
<LENGTH>21</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,139 @@
*&---------------------------------------------------------------------*
*& Demo program used in the context of the SAP LUW ABAP cheat sheet
*&
*&----------------------------- NOTE -----------------------------------*
*& The code presented in this class is intended only to support the ABAP
*& cheat sheets. It is not intended for direct use in a production system
*& environment. The code examples in the ABAP cheat sheets are primarily
*& intended to provide a better explanation and visualization of the
*& syntax and semantics of ABAP statements, not to solve concrete
*& programming tasks. For production application programs, you should
*& always work out your own solution for each individual case. There is
*& no guarantee for the correctness or completeness of the code.
*& Furthermore, there is no legal responsibility or liability for any
*& errors or their consequences that may occur when using the the example
*& code.
*&---------------------------------------------------------------------*
REPORT zdemo_abap_sap_luw_displ.
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
dynnr LIKE sy-dynnr.
END-OF-SELECTION.
"Checks if program is started separately
SELECT COUNT(*)
FROM zdemo_abap_logt
INTO @DATA(entries).
SELECT SINGLE id
FROM zdemo_abap_logt
WHERE id = 100
INTO @DATA(exists).
IF sy-subrc = 0 OR entries = 0.
DELETE FROM zdemo_abap_logt.
DATA(check) = abap_true.
zcl_demo_abap_sap_luw_helper=>create_log_entries(
VALUE #( ( id = 97
context = '-'
name = '-'
details = `Choose Start over from the menu.`
timestamp = utclong_current( ) ) ) ).
ENDIF.
zcl_demo_abap_sap_luw_helper=>create_log_entries(
VALUE #( ( id = 100
context = '-'
name = '-'
details = |New program executed: { sy-repid }|
timestamp = utclong_current( ) ) ) ).
CALL SCREEN 9780.
**********************************************************************
***************** Dialog modules for 9780 ****************************
MODULE status_9780 OUTPUT.
SET PF-STATUS 'STATUS9780'.
SET TITLEBAR 'TITLE9780'.
"Checks for asynchronous update
IF check = abap_false.
DATA(idx) = 0.
DO 5 TIMES. "A maximum of 5 seconds of waiting time
SELECT SINGLE id, context
FROM zdemo_abap_logt
WHERE
"Entry inserted ...
id = 93 "by the final update function module
OR id = 99 "in case of ROLLBACK WORK
OR id = 96 "in case of the intended failure in SAP LUW
OR context = 'Subroutine' "if subroutines are used
INTO @DATA(wa). "#EC CI_CMPLX_WHERE
IF sy-subrc = 0.
EXIT.
ELSE.
idx = sy-index.
WAIT UP TO 1 SECONDS.
ENDIF.
ENDDO.
IF idx = 5.
MESSAGE `The asynchronous update takes too long. ` &&
`You may want to restart the example and try again.`
TYPE 'I'.
ENDIF.
ENDIF.
zcl_demo_abap_sap_luw_helper=>create_log_entries(
VALUE #(
( id = 101
context = 'PBO'
name = 'status_9780'
details = `Module called`
timestamp = utclong_current( ) )
( id = 102
context = 'PBO'
name = 'status_9780'
details = zcl_demo_abap_sap_luw_helper=>get_work_process_info( )
timestamp = utclong_current( ) )
( id = 103
context = 'PBO'
name = 'status_9780'
details = `SAP LUW Key: ` &&
cl_system_transaction_state=>get_sap_luw_key( )
timestamp = utclong_current( ) )
( id = 104
context = 'PBO'
name = 'status_9780'
details = zcl_demo_abap_sap_luw_helper=>checking_transaction_state( )
timestamp = utclong_current( ) ) ) ).
zcl_demo_abap_sap_luw_helper=>cc_alv_display( 'CC_DB_FINAL' ).
zcl_demo_abap_sap_luw_helper=>cc_alv_display( container = 'CC_WP'
log = abap_true ).
dynnr = sy-dynnr.
ENDMODULE.
MODULE user_command_9780 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'STARTOVER'.
ROLLBACK WORK.
DELETE FROM zdemo_abap_logt.
SUBMIT ('ZDEMO_ABAP_SAP_LUW').
WHEN OTHERS.
DELETE FROM zdemo_abap_logt.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.

View File

@@ -0,0 +1,240 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_SAP_LUW_DISPL</NAME>
<DBAPL>S</DBAPL>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<DYNPROS>
<item>
<HEADER>
<PROGRAM>ZDEMO_ABAP_SAP_LUW_DISPL</PROGRAM>
<SCREEN>9780</SCREEN>
<LANGUAGE>E</LANGUAGE>
<DESCRIPT>Display database table and log</DESCRIPT>
<TYPE>N</TYPE>
<NEXTSCREEN>9780</NEXTSCREEN>
<LINES>027</LINES>
<COLUMNS>186</COLUMNS>
</HEADER>
<CONTAINERS>
<RPY_DYCATT>
<TYPE>SCREEN</TYPE>
<NAME>SCREEN</NAME>
</RPY_DYCATT>
<RPY_DYCATT>
<TYPE>CUST_CTRL</TYPE>
<NAME>CC_DB_FINAL</NAME>
<ELEMENT_OF>SCREEN</ELEMENT_OF>
<LINE>003</LINE>
<COLUMN>002</COLUMN>
<LENGTH>074</LENGTH>
<HEIGHT>007</HEIGHT>
</RPY_DYCATT>
<RPY_DYCATT>
<TYPE>CUST_CTRL</TYPE>
<NAME>CC_WP</NAME>
<ELEMENT_OF>SCREEN</ELEMENT_OF>
<LINE>013</LINE>
<COLUMN>002</COLUMN>
<LENGTH>156</LENGTH>
<HEIGHT>014</HEIGHT>
</RPY_DYCATT>
</CONTAINERS>
<FIELDS>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX15</NAME>
<TEXT>Database_table_entries:</TEXT>
<LINE>001</LINE>
<COLUMN>002</COLUMN>
<LENGTH>023</LENGTH>
<VISLENGTH>023</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>%#AUTOTEXT003</NAME>
<TEXT>Dynpro_number:</TEXT>
<LINE>001</LINE>
<COLUMN>130</COLUMN>
<LENGTH>014</LENGTH>
<VISLENGTH>014</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEMPLATE</TYPE>
<NAME>DYNNR</NAME>
<TEXT>___________</TEXT>
<LINE>001</LINE>
<COLUMN>146</COLUMN>
<LENGTH>011</LENGTH>
<VISLENGTH>011</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<OUTPUT_FLD>X</OUTPUT_FLD>
<OUTPUTONLY>X</OUTPUTONLY>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>TEXT</TYPE>
<NAME>TX16</NAME>
<TEXT>Log_database_table_entries:</TEXT>
<LINE>011</LINE>
<COLUMN>002</COLUMN>
<LENGTH>027</LENGTH>
<VISLENGTH>027</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<REQU_ENTRY>N</REQU_ENTRY>
</RPY_DYFATC>
<RPY_DYFATC>
<CONT_TYPE>SCREEN</CONT_TYPE>
<CONT_NAME>SCREEN</CONT_NAME>
<TYPE>OKCODE</TYPE>
<NAME>OK_CODE</NAME>
<TEXT>____________________</TEXT>
<LENGTH>020</LENGTH>
<VISLENGTH>020</VISLENGTH>
<HEIGHT>001</HEIGHT>
<FORMAT>CHAR</FORMAT>
<INPUT_FLD>X</INPUT_FLD>
</RPY_DYFATC>
</FIELDS>
<FLOW_LOGIC>
<RPY_DYFLOW>
<LINE>PROCESS BEFORE OUTPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE STATUS_9780.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW/>
<RPY_DYFLOW>
<LINE>PROCESS AFTER INPUT.</LINE>
</RPY_DYFLOW>
<RPY_DYFLOW>
<LINE> MODULE USER_COMMAND_9780.</LINE>
</RPY_DYFLOW>
</FLOW_LOGIC>
</item>
</DYNPROS>
<CUA>
<ADM>
<ACTCODE>000001</ACTCODE>
<PFKCODE>000001</PFKCODE>
</ADM>
<STA>
<RSMPE_STAT>
<CODE>STATUS9780</CODE>
<MODAL>D</MODAL>
<ACTCODE>000001</ACTCODE>
<PFKCODE>000001</PFKCODE>
<BUTCODE>0001</BUTCODE>
<INT_NOTE>Display database table and log</INT_NOTE>
</RSMPE_STAT>
</STA>
<FUN>
<RSMPE_FUNT>
<CODE>LEAVE</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<FUN_TEXT>Exit</FUN_TEXT>
</RSMPE_FUNT>
<RSMPE_FUNT>
<CODE>STARTOVER</CODE>
<TEXTNO>001</TEXTNO>
<TEXT_TYPE>S</TEXT_TYPE>
<TEXT_NAME>ICON_SYSTEM_UNDO</TEXT_NAME>
<ICON_ID>@2W@</ICON_ID>
<FUN_TEXT>STARTOVER</FUN_TEXT>
<ICON_TEXT>Start over</ICON_TEXT>
<INFO_TEXT>Start over</INFO_TEXT>
</RSMPE_FUNT>
</FUN>
<BUT>
<RSMPE_BUT>
<PFK_CODE>000001</PFK_CODE>
<CODE>0001</CODE>
<NO>01</NO>
<PFNO>08</PFNO>
</RSMPE_BUT>
</BUT>
<PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>08</PFNO>
<FUNCODE>STARTOVER</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
<RSMPE_PFK>
<CODE>000001</CODE>
<PFNO>15</PFNO>
<FUNCODE>LEAVE</FUNCODE>
<FUNNO>001</FUNNO>
</RSMPE_PFK>
</PFK>
<SET>
<RSMPE_STAF>
<STATUS>STATUS9780</STATUS>
<FUNCTION>LEAVE</FUNCTION>
</RSMPE_STAF>
<RSMPE_STAF>
<STATUS>STATUS9780</STATUS>
<FUNCTION>STARTOVER</FUNCTION>
</RSMPE_STAF>
</SET>
<DOC>
<RSMPE_ATRT>
<OBJ_TYPE>A</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Display database table and log</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>P</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Display database table and log</INT_NOTE>
</RSMPE_ATRT>
<RSMPE_ATRT>
<OBJ_TYPE>B</OBJ_TYPE>
<OBJ_CODE>000001</OBJ_CODE>
<SUB_CODE>0001</SUB_CODE>
<MODAL>D</MODAL>
<INT_NOTE>Display database table and log</INT_NOTE>
</RSMPE_ATRT>
</DOC>
<TIT>
<RSMPE_TITT>
<CODE>TITLE9780</CODE>
<TEXT>Display database table and log</TEXT>
</RSMPE_TITT>
</TIT>
</CUA>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>Demonstrating SAP LUW - Display</ENTRY>
<LENGTH>31</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,103 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
*
*
* -------------------------- PURPOSE ----------------------------------
* This program can be used for starting the selection screen and
* classic list programs contained in the repository.
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
PROGRAM.
TYPES: BEGIN OF reps_str,
number TYPE i,
report LIKE sy-repid,
END OF reps_str.
DATA: rep LIKE sy-repid,
reports TYPE TABLE OF reps_str WITH EMPTY KEY,
allowed TYPE string.
SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE title.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (25) lbl FOR FIELD report.
PARAMETERS report TYPE i AS LISTBOX VISIBLE LENGTH 60.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK bl.
**********************************************************************
INITIALIZATION.
title = 'Select and run a program'.
lbl = 'Program:'.
reports = VALUE #(
( number = 1 report = 'ZDEMO_ABAP_SELSCR_PARAMETERS' )
( number = 2 report = 'ZDEMO_ABAP_SELSCR_SELECT_OPT' )
( number = 3 report = 'ZDEMO_ABAP_SELSCR_STANDALONE' )
( number = 4 report = 'ZDEMO_ABAP_SELSCR_STMTS_VAR' )
( number = 5 report = 'ZDEMO_ABAP_LISTS' )
( number = 6 report = 'ZDEMO_ABAP_EVENT_BLOCKS' )
( number = 7 report = 'ZDEMO_ABAP_ALV' )
).
**********************************************************************
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = CONV vrm_id( 'REPORT' )
values = VALUE vrm_values(
( key = 1 text = 'Selection screens: PARAMETERS (zdemo_abap_selscr_parameters)' )
( key = 2 text = 'Selection screens: SELECT-OPTIONS (zdemo_abap_selscr_select_opt)' )
( key = 3 text = 'Selection screens: SELECTION-SCREEN (zdemo_abap_selscr_standalone)' )
( key = 4 text = 'Selection screens: SELECTION-SCREEN Variants (zdemo_abap_selscr_stmts_var)' )
( key = 5 text = 'Lists: Creating Lists (zdemo_abap_lists)' )
( key = 6 text = 'Event blocks (zdemo_abap_event_blocks)' )
( key = 7 text = 'SAP List Viewer (ALV) (zdemo_abap_alv)' ) ).
**********************************************************************
START-OF-SELECTION.
IF report BETWEEN 1 AND 7.
"Dynamic programming check: Only submit program if its name is available
"in the allow list
TRY.
rep = reports[ number = report ]-report.
allowed = cl_abap_dyn_prg=>check_whitelist_tab(
val = rep
whitelist = VALUE #( ( `ZDEMO_ABAP_SELSCR_PARAMETERS` )
( `ZDEMO_ABAP_SELSCR_SELECT_OPT` )
( `ZDEMO_ABAP_SELSCR_STANDALONE` )
( `ZDEMO_ABAP_SELSCR_STMTS_VAR` )
( `ZDEMO_ABAP_LISTS` )
( `ZDEMO_ABAP_EVENT_BLOCKS` )
( `ZDEMO_ABAP_ALV` ) ) ).
SUBMIT (rep) AND RETURN VIA SELECTION-SCREEN.
CATCH cx_root INTO DATA(err).
MESSAGE |Error: { err->get_text( ) }| TYPE 'E'.
ENDTRY.
ELSE.
MESSAGE 'Please select a program.' TYPE 'I' DISPLAY LIKE 'E'.
ENDIF.

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_SELSCR_LISTS_INTRO</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>ABAP Cheat Sheet: Selection Screen/Classic List Examples Intro</ENTRY>
<LENGTH>62</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,224 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
* Example: PARAMETERS statements
*
* -------------------------- PURPOSE ----------------------------------
* Example that demonstrates PARAMETERS statements in standard selection
* screens
*
* Notes:
* - A selection of additions is used. For more additions and details,
* see the ABAP Keyword Documentation.
* - The MODIF ID addition is possible for PARAMETERS. This is also true
* for SELECTION-SCREEN statements. See the details in that example.
* - See the ABAP cheat sheet for other statements used here, for example,
* the ones related to event blocks such as START-OF-SELECTION.
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
PROGRAM.
****************************** Type options ******************************
"Displaying some explanatory text on the standard selection screen
"The actual text content is assigned to the variable in the INITIALIZATION
"event block.
SELECTION-SCREEN COMMENT /1(70) t1.
"Referring to a built-in type with TYPE
"In this case, a variable length character string can be inserted in the
"generated input field. Note the LOWER CASE addition further down.
PARAMETERS p_str TYPE string.
"Referring to an existing data object with the LIKE addition.
"When referencing to a data type from the ABAP Dictionary after LIKE,
"you can benefit from things such as input help (if available).
DATA dobj TYPE i.
PARAMETERS plikedo LIKE dobj.
"Dynamic spefication of data object in parentheses after LIKE
"You can reference to a data type from the ABAP Dictionary. some_dobj in
"the example may be the name of a component of a database table,
"provided in capital letters.
DATA some_dobj TYPE c LENGTH 50 VALUE 'ZDEMO_ABAP_CARR-CARRID'.
PARAMETERS p_dyn LIKE (some_dobj).
"Length specifications
"Similar to declarations with DATA, the length can be specified for data
"types with generic length (i.e. the types c, n, p, and x).
PARAMETERS p_c1 TYPE c LENGTH 1.
PARAMETERS p_n5 TYPE n LENGTH 5.
"You may also see specifications in which the length is specified in parentheses.
"For better readability, specifying LENGTH explicitly is recommended.
PARAMETERS pbracket(2) TYPE c.
"No length specified means LENGTH 1 by default
PARAMETERS p_no_len TYPE c.
"No explicit type specification means TYPE c by default
PARAMETERS plenonl1(40).
PARAMETERS plenonl2 LENGTH 40.
"No explicit type and length specification means TYPE c LENGTH 1 by default
PARAMETERS pnothing.
****************************** Value options ******************************
SELECTION-SCREEN COMMENT /1(70) t2.
"DEFAULT: Defining a start value (can also be a data object instead of a literal)
PARAMETERS pdefault TYPE i DEFAULT 12345.
"LOWER CASE: Prevents the effect of capitalizing the entry made when the content
"is transported to the data object
PARAMETERS p_upper TYPE string DEFAULT `Hello World`. "Value you insert will be capitalized.
PARAMETERS p_lower TYPE string DEFAULT `Hello World` LOWER CASE.
"Note: There are more additions available, e.g. for linking the parameter to search help,
"or checking against fixed values defined in the domain of the data type, and so on.
"You can also perform your custom input checks in event blocks.
****************************** Screen options ******************************
SELECTION-SCREEN COMMENT /1(70) t3.
"OBLIGATORY: Declaring the input field as a required field
"If there is no entry, the program cannot proceed when choosing Execute.
"A message is displayed.
PARAMETERS p_oblig TYPE string OBLIGATORY.
"NO-DISPLAY: Hiding the input field on the selection screen
"A value can be supplied when calling the program with SUBMIT and the WITH addition.
"Note that with the NO-DISPLAY addition, the parameter can have any data types except
"for reference/enumerated types, unlike in the other additions which require flat
"types (except type string).
PARAMETERS p_nodisp TYPE string NO-DISPLAY.
"VISIBLE LENGTH: Defining the visible length of the field
PARAMETERS p_vislen TYPE c LENGTH 5 VISIBLE LENGTH 3.
"AS CHECKBOX: Displaying input fields as checkbox
"Type c and length 1 is expected, but the explicit length specification is not allowed.
"The checkbox is selected if the value has the value X or x.
PARAMETERS p_check1 AS CHECKBOX. "Implicit type c
"Explicit type specification (but no explicit length), select by default
PARAMETERS p_check2 TYPE c AS CHECKBOX DEFAULT 'X'.
"RADIOBUTTON GROUP: Defining a radio button group for parameters
"Note:
"- Group name can have a maximum of four characters
"- Regarding the data type, the same applies as for AS CHECKBOX
"- Only one parameter can be defined with the DEFAULT addition
"- If DEFAULT is not specified, the first parameter of the group is set to the value X
"- You can also use chained statements
PARAMETERS: p_radio1 RADIOBUTTON GROUP rbgr,
p_radio2 TYPE c RADIOBUTTON GROUP rbgr, "Explicit type specification
p_radio3 RADIOBUTTON GROUP rbgr DEFAULT 'X'. "Set this radio button as selected
"AS LISTBOX VISIBLE LENGTH: Creating a dropdown list box
"You can use the function module VRM_SET_VALUES by passing a suitable list at the
"events AT SELECTION-SCREEN OUTPUT or AT SELECTION-SCREEN ON VALUE-REQUEST.
PARAMETERS plistbox TYPE i AS LISTBOX VISIBLE LENGTH 10 OBLIGATORY.
*********************** Assigning function codes ***********************
"The AS CHECKBOX, RADIOBUTTON GROUP, AS LISTBOX additions can be combined
"with the addition USER-COMMAND. That means, on selection, the event
"AT SELECTION-SCREEN is raised and you can evaluate the function code there.
"Note: To enable it, include the statement 'TABLES sscrfields.' in the code.
"When the button is clicked, the event AT SELECTION-SCREEN is raised and the
"function code ('cmd', 'rbcm' in the example) is passed to the 'ucomm' component
"in the interface work area 'sscrfields' which can be evaluated and reacted upon
"accordingly.
"Before exploring the effect in the example, make entries for the
"obligatory input fields first, then choose the checkbox/radio buttons.
SELECTION-SCREEN COMMENT /1(70) t4.
TABLES sscrfields.
PARAMETERS pchckcmd AS CHECKBOX USER-COMMAND cmd.
PARAMETERS: prad1cmd RADIOBUTTON GROUP grp USER-COMMAND rbcm,
prad2cmd RADIOBUTTON GROUP grp.
**********************************************************************
INITIALIZATION.
t1 = 'PARAMETERS: Demonstrating various type options:'.
t2 = 'Demonstrating value options:'.
t3 = 'Demonstrating screen options:'.
t4 = 'Click these screen elements to explore the USER-COMMAND addition.'.
**********************************************************************
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'CMD'.
MESSAGE |Hallo { sy-uname }.| TYPE 'I'.
WHEN 'RBCM'.
MESSAGE |Today's date: { sy-datum DATE = ISO }| TYPE 'I'.
ENDCASE.
**********************************************************************
AT SELECTION-SCREEN OUTPUT.
"This is relevant for the AS LISTBOX VISIBLE LENGTH addition.
"Note:
"- The function module VRM_SET_VALUES is used
"- Column TEXT: What is displayed in the list box
"- Colum KEY: When a line is selected, the KEY value is added to the
" parameter
"In the example, the numbers 1 - 10 are added as values.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = CONV vrm_id( 'PLISTBOX' )
values = VALUE vrm_values(
FOR i = 1 UNTIL i > 10
( key = i text = |Value { i }| ) ).
**********************************************************************
START-OF-SELECTION.
"Creating a classic list
WRITE / `This list displays the values provided on the selection screen.`.
SKIP.
WRITE / |p_str: "{ p_str }"| .
WRITE / |plikedo: "{ plikedo }"| .
WRITE / |p_dyn: "{ p_dyn }"| .
WRITE / |p_c1: "{ p_c1 }"| .
WRITE / |p_n5: "{ p_n5 }"| .
WRITE / |pbracket: "{ pbracket }"| .
WRITE / |p_no_len: "{ p_no_len }"| .
WRITE / |plenonl1: "{ plenonl1 }"| .
WRITE / |plenonl2: "{ plenonl2 }"| .
WRITE / |pnothing: "{ pnothing }"| .
WRITE / |pdefault: "{ pdefault }"| .
WRITE / |p_upper: "{ p_upper }"| .
WRITE / |p_lower: "{ p_lower }"| .
WRITE / |p_oblig: "{ p_oblig }"| .
WRITE / |p_nodisp: "{ p_nodisp }"| .
WRITE / |p_vislen: "{ p_vislen }"| .
WRITE / |p_check1: "{ p_check1 }"| .
WRITE / |p_check2: "{ p_check2 }"| .
WRITE / |Radio button selected: "{ COND #( WHEN p_radio1 = 'X' THEN 'p_radio1' WHEN p_radio2 = 'X' THEN 'p_radio2' ELSE 'p_radio3' ) }"| .
WRITE / |plistbox: "{ plistbox }"| .
WRITE / |pchckcmd: "{ pchckcmd }"| .
WRITE / |Radio button selected: "{ COND #( WHEN prad1cmd = 'X' THEN 'prad1cmd' ELSE 'prad2cmd' ) }"| .

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_SELSCR_PARAMETERS</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>PARAMETERS (ABAP Cheat Sheet: Selection Screens/Classic Lists)</ENTRY>
<LENGTH>62</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,142 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
* Example: SELECT-OPTIONS statements
*
* -------------------------- PURPOSE ----------------------------------
* Example that demonstrates SELECT-OPTIONS statements in standard
* selection screens
*
* Notes:
* - A selection of additions is used. For more additions and details,
* see the ABAP Keyword Documentation.
* - See the ABAP cheat sheet for other statements used here, for example,
* the ones related to event blocks such as START-OF-SELECTION.
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
PROGRAM.
DATA int TYPE i.
DATA int_tab TYPE TABLE OF i WITH EMPTY KEY.
DATA selcriteria TYPE string_table.
DATA str TYPE string.
FIELD-SYMBOLS <fs> TYPE ANY TABLE.
"SELECT-OPTIONS statements demonstrating various additions
"The following statement creates two input fields that can be
"used to specify selection criteria on the selection screen.
"In addition, the Multiple Selection button is available to
"further specify the selection criteria, e.g. what to include,
"exclude, etc.. As in all examples, an internal table of type
"TYPE RANGE OF whose contents can be evaluated.
"The FOR addition is followed by an already declared data object.
SELECT-OPTIONS a FOR int.
"NO-DISPLAY: Hides
SELECT-OPTIONS b FOR int NO-DISPLAY.
"NO-EXTENSION: The Multiple Selection button is not created on
"the selection screen
SELECT-OPTIONS c FOR int NO-EXTENSION.
"NO INTERVALS: Only one input field. Intervals can still be
"selected using the Multiple Selection button.
SELECT-OPTIONS d FOR int NO INTERVALS.
"Additions can be combined
SELECT-OPTIONS e FOR int NO-EXTENSION NO INTERVALS.
"DEFAULT ... TO ...: Providing start values for the columns in
"the first line of the selection table (low and high values)
SELECT-OPTIONS f FOR int NO-EXTENSION DEFAULT 3 TO 10.
SELECT-OPTIONS g FOR int DEFAULT 5 TO 9.
"DEFAULT ... OPTION ... SIGN ...: Providing further start values.
"See the details in the ABAP cheat sheet.
SELECT-OPTIONS h FOR int DEFAULT 4 TO 8 OPTION NB SIGN I.
**********************************************************************
INITIALIZATION.
"Providing start values for data objects
"The following internal table is filled and used as a data source
"for a SELECT statement.
int_tab = VALUE #( FOR i = 1 UNTIL i > 20 ( i ) ).
"This table is filled here with the names from above. The table is looped
"over in the START-OF-SELECTION event block to cover all SELECT-OPTIONS
"from above.
selcriteria = VALUE #( ( `A` ) ( `B` ) ( `C` ) ( `D` )
( `E` ) ( `F` ) ( `G` ) ( `H` ) ).
**********************************************************************
START-OF-SELECTION.
"Creating a classic list
WRITE / `Data was retrieved from an internal table using a SELECT statement based on selection criteria.`.
WRITE / `The table has the following content:`.
LOOP AT int_tab INTO int.
WRITE |{ int }|.
ENDLOOP.
SKIP 2.
LOOP AT selcriteria INTO str.
CASE str.
"For historical reasons, the selection table is a table with header line.
"Therefore, if you want to address the table content (beyond the use in a
"SELECT ... WHERE ... IN ... statement), use the syntax `...[]`.
WHEN `A`.
ASSIGN a[] TO <fs>.
WHEN `B`.
ASSIGN b[] TO <fs>.
WHEN `C`.
ASSIGN c[] TO <fs>.
WHEN `D`.
ASSIGN d[] TO <fs>.
WHEN `E`.
ASSIGN e[] TO <fs>.
WHEN `F`.
ASSIGN f[] TO <fs>.
WHEN `G`.
ASSIGN g[] TO <fs>.
WHEN `H`.
ASSIGN h[] TO <fs>.
ENDCASE.
WRITE / |Result for selection options specified for "{ str }":| COLOR 2.
SKIP.
SELECT *
FROM @int_tab AS tab
WHERE table_line IN @<fs>
INTO @int.
WRITE |{ int }|.
ENDSELECT.
IF <fs> IS INITIAL.
WRITE `(No selection criteria were provided. Therefore, all table lines are respected.)`.
ENDIF.
SKIP.
ENDLOOP.

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_SELSCR_SELECT_OPT</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>SELECT-OPTIONS (ABAP Cheat Sheet: Selection Screens/Classic Lists)</ENTRY>
<LENGTH>66</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,218 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
* Example: Creating standalone selection screens
*
* -------------------------- PURPOSE ----------------------------------
* - Example that demonstrates standalone selection screens
* - In the example, calculations are performed based on user input.
* Includes:
* - Creating selection screens as regular dynpros with
* SELECTION-SCREEN BEGIN/END OF SCREEN ... statements
* - Creating selection screens as subscreen dynpros with the AS SUBSCREEN
* addition
* - Calling standalone selection screen with CALL SELECTION-SCREEN
* statements
* - Using variants of the SELECTION-SCREEN statements that do not create
* selection screens, but are used to modify the layout
* - INCLUDE addition for reusing already created elements
*
* Notes:
* - A selection of additions is used. For more additions and details,
* see the ABAP Keyword Documentation.
* - See the ABAP cheat sheet for other statements used here, for example,
* the ones related to event blocks such as START-OF-SELECTION.
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
PROGRAM.
"Creating standalone selection screens as regular dynpros
"The dynpro number must be unique in the program. Do not use 1000.
SELECTION-SCREEN BEGIN OF SCREEN 9810.
"Here go all PARAMETERS, SELECT-OPTIONS, and SELECTION-SCREEN statements
"to define the screen elements of the standalone selection screen.
SELECTION-SCREEN COMMENT /1(70) t1.
PARAMETERS number1 TYPE i OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 9810.
"AS WINDOW/TITLE: The following selection screen is displayed in a modal
"dialog box. Plus, a title is specified.
SELECTION-SCREEN BEGIN OF SCREEN 9820 TITLE title1 AS WINDOW.
SELECTION-SCREEN COMMENT /1(70) t2.
PARAMETERS number2 TYPE i OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 9820.
"Creating a standalone selection screens as subscreen dynpro
"They can be included in other dynpros or selection screens, or in
"subscreen areas or tab pages. The following example covers the latter.
"Note: The selection screens as subscreen dynpros cannot be called
"explicitly.
"The following two selection screens are included in tab pages
"further down.
SELECTION-SCREEN BEGIN OF SCREEN 9830 AS SUBSCREEN.
PARAMETERS: number3 TYPE i OBLIGATORY,
number4 TYPE i OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 9830.
SELECTION-SCREEN BEGIN OF SCREEN 9840 AS SUBSCREEN.
PARAMETERS: plus AS CHECKBOX DEFAULT 'X',
minus AS CHECKBOX DEFAULT 'X',
multiply AS CHECKBOX DEFAULT 'X',
divide AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF SCREEN 9840.
"The following selection screen (as regular dynpro) is created
"as dummy, i.e. it is not included as the ones above. It is
"used to demonstrate the INCLUDE addition.
SELECTION-SCREEN BEGIN OF SCREEN 9850.
SELECTION-SCREEN COMMENT /1(50) t3.
SELECTION-SCREEN END OF SCREEN 9850.
"The following declaration is required in the context of the
"TABBED BLOCK addition.
TABLES sscrfields.
"The following selection screen (as regular dynpro) is created to
"demonstrate ...
"- the use of subscreen dynpros. In this case, the subscreen dynpros
" are used in the context of tab pages (TABBED BLOCK, TAB additions).
"- the reuse of available screen elements in the program using the
" INCLUDE addition.
SELECTION-SCREEN BEGIN OF SCREEN 9860 TITLE title2.
SELECTION-SCREEN INCLUDE COMMENT /1(70) t3. "Reusing a screen element
SELECTION-SCREEN: BEGIN OF TABBED BLOCK tabs FOR 10 LINES,
"In such a TABBED BLOCK statement, only TAB statements are allowed
"to include subscreen dynpros.
"The USER-COMMAND addition specifies a function code. If a tab is
"selected by users, the function code can be evaluated using the the
"component ucomm of the structure sscrfields after the
"AT SELECTION-SCREEN event.
TAB (20) btn_nums USER-COMMAND uc_num,
TAB (20) btn_op USER-COMMAND uc_op,
END OF BLOCK tabs.
SELECTION-SCREEN END OF SCREEN 9860.
**********************************************************************
INITIALIZATION.
title1 = 'First calculation'.
title2 = 'Second calculation'.
t1 = 'Insert an integer value for the first calculation.'.
t2 = 'Provide the second number for the first calculation.'.
t3 = 'Make entries in the tabs for the second calculation.'.
btn_nums = 'Numbers'.
btn_op = 'Operators'.
"Instead of the following assignements, you can also use the DEFAULT,
"SCREEN, PROGRAM additions of the ... TAB ... statement
tabs-prog = sy-repid.
tabs-dynnr = 9830.
tabs-activetab = 'UC_NUM'.
**********************************************************************
AT SELECTION-SCREEN.
CASE sy-dynnr.
WHEN 9860.
CASE sscrfields-ucomm.
WHEN 'UC_NUM'.
tabs-dynnr = 9830.
WHEN 'UC_OP'.
tabs-dynnr = 9840.
ENDCASE.
ENDCASE.
**********************************************************************
START-OF-SELECTION.
"The following statements call the selection screens.
CALL SELECTION-SCREEN 9810.
IF sy-subrc = 0.
"STARTING AT: Specifies that the selection screen is displayed as a
"modal dialog box.
CALL SELECTION-SCREEN 9820 STARTING AT 10 10.
ENDIF.
IF sy-subrc = 0.
CALL SELECTION-SCREEN 9860.
ENDIF.
IF sy-subrc = 0.
"Creating a classic list
WRITE / |Results of the first calculation using the provided numbers { number1 } and { number2 } (all basic arithmetic operations):| COLOR COL_POSITIVE.
WRITE / |{ number1 } + { number2 } = { number1 + number2 }|.
WRITE / |{ number1 } - { number2 } = { number1 - number2 }|.
TRY.
WRITE / |{ number1 } * { number2 } = { number1 * number2 }|.
CATCH cx_sy_arithmetic_error INTO DATA(error).
WRITE / |{ number1 } * { number2 } = ??? Error in multiplication: { error->get_text( ) }| COLOR COL_NEGATIVE.
ENDTRY.
TRY.
WRITE / |{ number1 } / { number2 } = { CONV decfloat34( number1 / number2 ) DECIMALS = 3 }|.
IF number1 = 0 AND number2 = 0.
WRITE / `No zero division error? Note that ABAP "allows" zero division if the first number is also 0 :)` COLOR COL_NEGATIVE.
ENDIF.
CATCH cx_sy_zerodivide INTO error.
WRITE / |{ number1 } / { number2 } = ??? Error in division: { error->get_text( ) }| COLOR COL_NEGATIVE.
ENDTRY.
SKIP 2.
WRITE / |Results of the second calculation using the provided numbers { number3 } and { number4 } (selected basic arithmetic operations):| COLOR COL_POSITIVE.
IF plus IS INITIAL
AND minus IS INITIAL
AND multiply IS INITIAL
AND divide IS INITIAL.
WRITE / 'You did not select any operators from the tab. No calculation was performed.' COLOR COL_NEGATIVE.
ELSE.
IF plus = 'X'.
WRITE / |{ number3 } + { number4 } = { number3 + number4 }|.
ENDIF.
IF minus = 'X'.
WRITE / |{ number3 } - { number4 } = { number3 - number4 }|.
ENDIF.
IF multiply = 'X'.
TRY.
WRITE / |{ number3 } * { number4 } = { number3 * number4 }|.
CATCH cx_sy_arithmetic_error INTO error.
WRITE / |{ number3 } * { number4 } = ??? Error in multiplication: { error->get_text( ) }| COLOR COL_NEGATIVE.
ENDTRY.
ENDIF.
IF divide = 'X'.
TRY.
WRITE / |{ number3 } / { number4 } = { CONV decfloat34( number3 / number4 ) DECIMALS = 3 }|.
IF number3 = 0 AND number4 = 0.
WRITE / `No zero division error? Note that ABAP "allows" zero division if the first number is also 0 :)` COLOR COL_NEGATIVE.
ENDIF.
CATCH cx_sy_zerodivide INTO error.
WRITE / |{ number3 } / { number4 } = ??? Error in division: { error->get_text( ) }| COLOR COL_NEGATIVE.
ENDTRY.
ENDIF.
ENDIF.
ENDIF.

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_SELSCR_STANDALONE</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>Standalone selection screens (ABAP cheat sheet)</ENTRY>
<LENGTH>47</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>

View File

@@ -0,0 +1,263 @@
***********************************************************************
*
* ABAP cheat sheet: Selection screens and classic lists
* Example: Variants of SELECTION-SCREEN statements
*
* -------------------------- PURPOSE ----------------------------------
* Example that demonstrates variants of the SELECTION-SCREEN statements
* to modify the layout, create additional screen elements etc.
* Includes:
* - Adding blank lines (SKIP)
* - Creating a horizontal line (ULINE)
* - Providing text (COMMENT)
* - Creating a pushbutton (PUSHBUTTON)
* - Specifying the output position of a screen element (POSITION)
* - Defining a new line with multiple elements (BEGIN OF LINE)
* - Creating blocks (BLOCK)
* - Creating tabbed blocks (TABBED BLOCK/TAB)
* - Assigning a screen element to a modification group (MODIF ID)
* - Adding pushbuttons in the application toolbar (FUNCTION KEY)
*
* Notes:
* - A selection of additions is used. For more additions and details,
* see the ABAP Keyword Documentation.
* - See the ABAP cheat sheet for other statements used here, for example,
* the ones related to event blocks such as START-OF-SELECTION.
*
* ----------------------- GETTING STARTED -----------------------------
* - Open the program with the ABAP development tools for Eclipse (ADT).
* - Choose F8 to run the program.
*
* ----------------------------- NOTE -----------------------------------
* The code presented in this class is intended only to support the ABAP
* cheat sheets. It is not intended for direct use in a production system
* environment. The code examples in the ABAP cheat sheets are primarily
* intended to provide a better explanation and visualization of the
* syntax and semantics of ABAP statements, not to solve concrete
* programming tasks. For production application programs, you should
* always work out your own solution for each individual case. There is
* no guarantee for the correctness or completeness of the code.
* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
***********************************************************************
PROGRAM.
"The following declaration is required in the context of the
"TABBED BLOCK, FUNCTION KEY, and USER-COMMAND additions.
TABLES sscrfields.
"Creating blocks (BLOCK)
"The WITH FRAME additions draws a frame around a block.
"Note that the block must be ended with a ... END OF BLOCK ... statement.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.
"Providing text (COMMENT)
SELECTION-SCREEN COMMENT /30(70) t1.
"Assigning a screen element to a modification group (MODIF ID)
"An identifier can be specified to assign a screen element to a
"modification group. This identifier is assigned to the component
"'group1' of the SCREEN structure. Using MODIFY SCREEN statements,
"the elements can be modified before displaying
"in the AT SELECTION-SCREEN OUTPUT event block.
"Note: The additions is possible for PARAMETERS, SELECT-OPTIONS
"and SELECTION-SCREEN.
PARAMETERS my_name LIKE sy-uname MODIF ID nd.
"Adding blank lines (SKIP)
"Just SKIP, no further addition means it skips one line.
SELECTION-SCREEN SKIP.
PARAMETERS sap_rel LIKE sy-saprl MODIF ID nd.
"Specifying the number of blank lines
SELECTION-SCREEN SKIP 2.
"Creating a horizontal line (ULINE)
SELECTION-SCREEN ULINE /10(40).
PARAMETERS random_i TYPE i MODIF ID nd.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN SKIP.
"Defining a new line with multiple elements (BEGIN OF LINE)
"Chained statements are handy.
SELECTION-SCREEN: BEGIN OF LINE,
"Specifying the output position of a screen element (POSITION)
"Only possible within BEGIN/END OF LINE
POSITION 2,
PUSHBUTTON (5) btn1 USER-COMMAND btn_1,
POSITION 9,
COMMENT (25) t2,
POSITION 35,
PUSHBUTTON (5) btn2 USER-COMMAND btn_2,
POSITION 42,
COMMENT (25) t3,
END OF LINE.
SELECTION-SCREEN SKIP.
"Radio buttons in a block with a frame and title
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE title1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb1 RADIOBUTTON GROUP grp.
SELECTION-SCREEN COMMENT (20) text1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: rb2 RADIOBUTTON GROUP grp.
SELECTION-SCREEN COMMENT (20) text2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK block2.
SELECTION-SCREEN SKIP.
"Further statements with the MODIF ID addition
"The layout of the following screen element should be modified
"using the specified ID.
"Note: Outside of BEGIN/END OF LINE statements, the specified
"format must contain one position (/...)
SELECTION-SCREEN COMMENT /10(70) t4 MODIF ID mod.
SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME.
"The layout of the following screen elements should be modified
"using the specified ID.
PARAMETERS: pa1 RADIOBUTTON GROUP gr MODIF ID mbl,
pa2 RADIOBUTTON GROUP gr MODIF ID mbl,
pa3 RADIOBUTTON GROUP gr,
pa4 RADIOBUTTON GROUP gr.
SELECTION-SCREEN END OF BLOCK bl.
"Creating tabbed blocks (TABBED BLOCK/TAB)
"Creating standalone selection screens as subscreen dynpros
"They can be included in other dynpros or selection screens, or in
"subscreen areas or tab pages. This example covers the latter.
SELECTION-SCREEN BEGIN OF SCREEN 9990 AS SUBSCREEN.
PARAMETERS: par_sub1 TYPE c LENGTH 10 LOWER CASE.
SELECTION-SCREEN END OF SCREEN 9990.
SELECTION-SCREEN BEGIN OF SCREEN 9991 AS SUBSCREEN.
PARAMETERS: par_sub2 TYPE c LENGTH 10 LOWER CASE.
SELECTION-SCREEN END OF SCREEN 9991.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK tabs FOR 2 LINES,
"The USER-COMMAND addition specifies a function code.
"If a tab is selected by users, the function code can
"be evaluated using the the component ucomm of the structure
"sscrfields after the AT SELECTION-SCREEN event.
TAB (20) tabtitl1 USER-COMMAND tab1,
TAB (20) tabtitl2 USER-COMMAND tab2,
END OF BLOCK tabs.
"Adding pushbuttons in the application toolbar (FUNCTION KEY)
"There are five inactive pushbuttons to which the function codes FC01, FC02
"up to FC05 are assigned. The ... FUNCTION KEY ... statement activates the
"pushbuttons for the specified codes.
"Note: To enable it, include the statement 'TABLES sscrfields.' in the code.
"When the button is clicked, the event AT SELECTION-SCREEN is raised and the
"function code is passed to the 'ucomm' component in the interface
"work area 'sscrfields' which can be evaluated and reacted upon accordingly,
"e.g. in a CASE control structure.
SELECTION-SCREEN: FUNCTION KEY 1, "Stands for FC01
FUNCTION KEY 2, "FC02
FUNCTION KEY 3, "FC03
FUNCTION KEY 4. "FC04
**********************************************************************
INITIALIZATION.
title1 = 'Block including radio buttons + comments put in one line using BEGIN/END OF LINE'.
t1 = 'This is a selection screen comment included in a block with frame.'.
t2 = '<- Click to get the time'.
t3 = '<- Click to get the date'.
t4 = 'This text and the following radio button group was modified.'.
text1 = 'Radio button A'.
text2 = 'Radio button B'.
btn1 = 'A'.
btn2 = 'B'.
"Relevant to the tabbed blocks
tabtitl1 = 'Selection Screen A'.
tabtitl2 = 'Selection Screen B'.
tabs-prog = sy-repid.
tabs-dynnr = 9990.
tabs-activetab = 'TAB1'.
"Relevant to the function keys
"To provide text for the buttons, assign values to the component functxt_0n
"(while n stands for the numbers 1 - 5). Otherwise, there won't be any button
"text.
sscrfields-functxt_01 = 'Get my name'.
sscrfields-functxt_02 = 'Get ABAP release'.
sscrfields-functxt_03 = 'Get random integer'.
sscrfields-functxt_04 = 'Clear input fields'.
**********************************************************************
AT SELECTION-SCREEN OUTPUT.
"Modifying the layout of screen elements
LOOP AT SCREEN INTO DATA(wa).
IF wa-group1 = 'MOD'.
"Intensify the text output
wa-intensified = '1'.
MODIFY SCREEN FROM wa.
ENDIF.
IF wa-group1 = 'MBL'.
"Make the screen element invisible
wa-invisible = '1'.
MODIFY SCREEN FROM wa.
ENDIF.
IF wa-group1 = 'ND'.
"Disable the input for a field
wa-input = '0'.
MODIFY SCREEN FROM wa.
ENDIF.
ENDLOOP.
**********************************************************************
AT SELECTION-SCREEN.
"Evaluating the function codes relevant to the
"TABBED BLOCK, FUNCTION KEY, and USER-COMMAND additions.
"Evaluating only if sy-dynnr has the value of the standard selection
"screen
CHECK sy-dynnr = 1000.
CASE sscrfields-ucomm.
WHEN 'FC01'.
my_name = sy-uname.
WHEN 'FC02'.
sap_rel = sy-saprl.
WHEN 'FC03'.
random_i = cl_abap_random_int=>create(
seed = cl_abap_random=>seed( ) min = 1
max = 100 )->get_next( ).
WHEN 'FC04'.
CLEAR: my_name, sap_rel, random_i, par_sub1, par_sub2.
WHEN 'BTN_1'.
MESSAGE |You clicked button A. The time is { sy-uzeit TIME = ISO }.| TYPE 'I'.
WHEN 'BTN_2'.
MESSAGE |You clicked button B. The date is { sy-datum DATE = ISO }.| TYPE 'I'.
WHEN 'TAB1'.
tabs-dynnr = 9990.
WHEN 'TAB2'.
tabs-dynnr = 9991.
ENDCASE.
**********************************************************************
START-OF-SELECTION.
"Creating a classic list
WRITE / `This list displays the values provided on the selection screen.`.
SKIP.
WRITE / |my_name: "{ my_name }"|.
WRITE / |sap_rel: "{ sap_rel }"|.
WRITE / |random_i: "{ random_i }"|.
WRITE / |Radio button selected (1): "{ COND #( WHEN rb1 = 'X' THEN 'rb1' ELSE 'rb2' ) }"| .
WRITE / |Radio button selected (2): "{ COND #( WHEN pa1 = 'X' THEN 'pa1' WHEN pa2 = 'X' THEN 'pa2' WHEN pa3 = 'X' THEN 'pa3' ELSE 'pa4' ) }"| .
WRITE / |par_sub1: "{ par_sub1 }"|.
WRITE / |par_sub2: "{ par_sub2 }"|.

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZDEMO_ABAP_SELSCR_STMTS_VAR</NAME>
<DBAPL>S</DBAPL>
<DBNA>D$</DBNA>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>Variants of SELECTION-SCREEN statements (ABAP cheat sheet)</ENTRY>
<LENGTH>58</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>