Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Interactive Report Events

Former Member
0 Kudos

AT PF<nn> (obsolete)

AT LINE-SELECTION

AT USER-COMMAND

can anybody tell me the purpose of above events?

Regards,

pandu.

3 REPLIES 3

Former Member
0 Kudos

Hi,

AT LINE-SELECTION.

This statement defines an event block whose event is triggered by the ABAP runtime environment during the display of a screen list - provided the scren cursor is on a list line and you select a function using the function code PICK. Through the definition of this event block, the standard list status is automatically enhanced in such a way that the function code F2 and, with it, the double-click mouse function is linked up to the function code PICK.

Note

If the function key F2 is linked with a function code different than PICK, each double click will trigger its even, usually AT USER-COMMAND, and not AT LINE-SELECTION.

Example

This program works with the standard list status. A line selection with the left mouse key causes the event AT LINE-SELECTION and creates details lists.

REPORT demo_at_line_selection.

START-OF-SELECTION.

WRITE 'Click me!' COLOR = 5 HOTSPOT.

AT LINE-SELECTION.

WRITE: / 'You clicked list', sy-listi,

/ 'You are on list', sy-lsind.

IF sy-lsind < 20.

SKIP.

WRITE: 'More ...' COLOR = 5 HOTSPOT.

ENDIF.

<b>at user command :</b>

AT USER-COMMAND.

<statements>.

In this event block, you can use an IF or CASE structure to tell the function codes apart. They are available in the system field SY-UCOMM. There are further system fields that are filled in list events, such as SY-LSIND and SY-PFKEY, that allow you to make further case distinctions.

REPORT demo_list_at_user_command NO STANDARD PAGE HEADING.

START-OF-SELECTION.

WRITE: 'Basic List',

/ 'SY-LSIND:', sy-lsind.

TOP-OF-PAGE.

WRITE 'Top-of-Page'.

ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.

CASE sy-pfkey.

WHEN 'TEST'.

WRITE 'Self-defined GUI for Function Codes'.

ULINE.

ENDCASE.

AT LINE-SELECTION.

SET PF-STATUS 'TEST' EXCLUDING 'PICK'.

PERFORM out.

sy-lsind = sy-lsind - 1.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'FC1'.

PERFORM out.

WRITE / 'Button FUN 1 was pressed'.

WHEN 'FC2'.

PERFORM out.

WRITE / 'Button FUN 2 was pressed'.

WHEN 'FC3'.

PERFORM out.

WRITE / 'Button FUN 3 was pressed'.

WHEN 'FC4'.

PERFORM out.

WRITE / 'Button FUN 4 was pressed'.

WHEN 'FC5'.

PERFORM out.

WRITE / 'Button FUN 5 was pressed'.

ENDCASE.

sy-lsind = sy-lsind - 1.

FORM out.

WRITE: 'Secondary List',

/ 'SY-LSIND:', sy-lsind,

/ 'SY-PFKEY:', sy-pfkey.

ENDFORM.

Former Member
0 Kudos

AT-line selection is used when we try with the interactive report concept..It will traverse through the list..At user command command will hold the function code of the button name...

But we cannot use both of them in a single print program..If we need to use we want to set the pick keyword in the PF status of f2 button..

REQARD IF USEFUL

Former Member
0 Kudos

Hi

Syntax

<b>AT LINE-SELECTION.</b>

This statement defines an event block whose event is triggered by the ABAP runtime environment during the display of a screen list - provided the scren cursor is on a list line and you select a function using the function code PICK. Through the definition of this event block, the standard list status is automatically enhanced in such a way that the function code F2 and, with it, the double-click mouse function is linked up to the function code PICK.

Note

If the function key F2 is linked with a function code different than PICK, each double click will trigger its even, usually AT USER-COMMAND, and not AT LINE-SELECTION.

Example

This program works with the standard list status. A line selection with the left mouse key causes the event AT LINE-SELECTION and creates details lists.

REPORT demo_at_line_selection.

START-OF-SELECTION.

WRITE 'Click me!' COLOR = 5 HOTSPOT.

AT LINE-SELECTION.

WRITE: / 'You clicked list', sy-listi,

/ 'You are on list', sy-lsind.

IF sy-lsind < 20.

SKIP.

WRITE: 'More ...' COLOR = 5 HOTSPOT.

ENDIF.

See following link :

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba3ae35c111d1829f0000e829fbfe/content.htm

Check the link below. It gives you detailed description.

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba34635c111d1829f0000e829fbfe/content.htm

On a normal screen, a user action triggers the PAI event. In the screen flow logic, you code a processing block that calls ABAP dialog modules in this event. In list processing, the event is intercepted by the list processor and processed. Instead of calling dialog modules, one of the three following list events may be called, depending on the function code triggered by the user.

AT PF<nn> (obsolete)

AT LINE-SELECTION

AT USER-COMMAND

If you have written the corresponding event blocks in your program, they are executed. You can access the function code in the system field SY-UCOMM.

The output from any list statements that you write in these event blocks is written to detail lists. With one ABAP program, you can maintain one basic list and up to 19 detail lists.

http://www.sapgenie.com/abap/reports.htm

http://www.allsaplinks.com/material.html

http://www.sapdevelopment.co.uk/reporting/reportinghome.htm

http://www.sapfans.com/forums/viewtopic.php?t=58286

http://www.sapfans.com/forums/viewtopic.php?t=76490

http://www.sapfans.com/forums/viewtopic.php?t=20591

http://www.sapfans.com/forums/viewtopic.php?t=66305

http://www.erpgenie.com/abap/drill_down_reports.htm

STEP ONE - ADD THESE LINES OF CODE IN THE DECLARATION AREA

        • DECLARATION

DATA: BEGIN OF items OCCURS 100,

id type sy-tabix,

parent_id type sy-tabix,

text(1000),

symbol,

END OF items,

tabix_stack LIKE sy-tabix OCCURS 10 WITH HEADER LINE,

items_show LIKE items OCCURS 100 WITH HEADER LINE.

DATA: parent_stack LIKE sy-tabix OCCURS 10 WITH HEADER LINE,

t_parent LIKE sy-tabix,

current LIKE sy-tabix.

INCLUDE <symbol>.

INCLUDE ZTREE_REPORT_INCLUDES.

STEP TWO - ADD THESE LINES OF CODE TO POPULATE THE INTERNAL TABLE

        • POPULATE DATA

REFRESH parent_stack. current = 0.

parent_stack = 0. APPEND parent_stack.

  • itab_data is an internal table with one field of length 1000.

  • itab_data contains the output in this one field, as it must appear on the

screen

LOOP AT itab_data.

CASE itab_data-qualf.

WHEN 1. "New parent

current = current + 1.

PERFORM read_from_parent_stack CHANGING t_parent.

parent_stack = current. APPEND parent_stack.

PERFORM append_item USING current

t_parent

itab_xml_data.

WHEN 2. "End of current leg

current = current + 1.

PERFORM append_item USING current

t_parent

itab_xml_data.

perform delete_parent_stack.

WHEN 3. "Same level

current = current + 1.

PERFORM read_from_parent_stack CHANGING t_parent.

PERFORM append_item USING current

t_parent

itab_xml_data.

ENDCASE.

ENDLOOP.

STEP THREE - ADD THESE LINES OF CODE TO PRINT THE REPORT

LOOP AT items WHERE parent_id = 0.

MOVE-CORRESPONDING items TO items_show.

items_show-symbol = '+'.

APPEND items_show.

ENDLOOP.

PERFORM print_tree TABLES items_show.

STEP FOUR - ADD THESE LINES OF CODE TO EXPAND \ COLLAPSE THE TREE

  • at line-selection - when the node is opened/closed or item double-clk

AT LINE-SELECTION.

READ TABLE items WITH KEY parent_id = items_show-id. "see 'hide'

IF sy-subrc = 0. "item has children - expand or collapse

sy-lsind = 0.

PERFORM expand_collapse USING items_show-id.

PERFORM print_tree TABLES items_show.

ELSE. "item has NO children - perform some action

READ TABLE items WITH KEY id = items_show-id.

WRITE: 'Action performed on item "' NO-GAP, items-text NO-GAP,

'", id.', items-id.

ENDIF.

STEP FIVE - ADD THIS INCLUDE CODE

----


  • INCLUDE ZTREE_REPORT_INCLUDES *

----


  • form append_item

FORM append_item USING value(id) value(parent_id) value(text).

items-id = id.

items-parent_id = parent_id.

items-text = text.

APPEND items.

ENDFORM. " APPEND_ITEM

  • form read_from_stack

FORM read_from_stack CHANGING tabix LIKE sy-tabix.

DESCRIBE TABLE tabix_stack.

CHECK sy-tfill NE 0.

READ TABLE tabix_stack INDEX sy-tfill.

tabix = tabix_stack.

DELETE tabix_stack INDEX sy-tfill.

ENDFORM.

  • form print tree

FORM print_tree TABLES items STRUCTURE items.

DATA: v_tabix LIKE sy-tabix,

start_tabix LIKE sy-tabix,

v_level LIKE sy-tfill,

v_offset TYPE i,

v_id LIKE items-id,

v_parent_id LIKE items-parent_id,

v_parent_id_for_vline LIKE items-parent_id,

v_prev_level TYPE i,

v_items_count LIKE sy-tfill,

v_vlines_string(200).

CHECK NOT items[] IS INITIAL.

SORT items BY parent_id id.

READ TABLE items INDEX 1.

v_parent_id = items-parent_id.

start_tabix = 1.

REFRESH tabix_stack.

DO.

LOOP AT items FROM start_tabix.

v_tabix = start_tabix = sy-tabix. "remember current index

v_id = items-id.

v_parent_id_for_vline = items-parent_id.

  • decrease level and exit loop if parent not the same as previous

IF items-parent_id NE v_parent_id.

PERFORM read_from_stack CHANGING start_tabix. "level = NoOfRecs

READ TABLE items INDEX start_tabix.

v_parent_id = items-parent_id.

ADD 1 TO start_tabix. "next loop starts from parent index + 1

  • clear vline

IF v_level > 1.

v_offset = 2 + ( v_level - 2 ) * 3.

IF v_level = 1. v_offset = 1. ENDIF.

v_vlines_string+v_offset = ' '.

ENDIF.

EXIT.

ENDIF.

v_parent_id = items-parent_id.

  • write item

FORMAT COLOR OFF.

DESCRIBE TABLE tabix_stack LINES v_level."level is no of StackRecs

WRITE: / v_vlines_string.

v_offset = v_level * 3.

IF v_level NE 0.

IF v_prev_level < v_level.

WRITE: AT v_offset '|', / ''.

WRITE: / v_vlines_string.

ENDIF.

v_offset = v_level * 3.

WRITE AT v_offset '|--'.

ENDIF.

v_offset = v_offset + 3.

CASE items-symbol.

WHEN '+'.

WRITE AT v_offset sym_plus_folder AS SYMBOL

COLOR 4 INTENSIFIED HOTSPOT.

WHEN '-'.

WRITE AT v_offset sym_minus_folder AS SYMBOL

COLOR 4 INTENSIFIED HOTSPOT.

WHEN OTHERS. FORMAT COLOR 5.

ENDCASE.

WRITE: items-text.

v_prev_level = v_level.

HIDE: items-id.

ADD 1 TO v_items_count.

READ TABLE items WITH KEY parent_id = items-id.

  • increase level and exit loop if item has children

IF sy-subrc = 0.

start_tabix = sy-tabix.

APPEND v_tabix TO tabix_stack. "level is no of recs in stack

v_parent_id = items-parent_id.

  • set vline

v_tabix = v_tabix + 1.

READ TABLE items INDEX v_tabix.

v_offset = 2 + ( v_level - 1 ) * 3.

IF v_level > 0.

IF items-parent_id = v_parent_id_for_vline AND sy-subrc = 0.

v_vlines_string+v_offset = '|'.

ELSE.

v_vlines_string+v_offset = ' '.

ENDIF.

ENDIF.

EXIT.

ENDIF.

  • at last - decrease level

AT LAST.

  • clear vline

IF v_level > 1.

v_offset = 2 + ( v_level - 2 ) * 3.

IF v_level = 1. v_offset = 1. ENDIF.

v_vlines_string+v_offset = ' '.

ENDIF.

" next loop starts from parent index, not parent index + 1

" because of different parents level will decrease anyway

PERFORM read_from_stack CHANGING start_tabix.

APPEND start_tabix TO tabix_stack. "must return index to stack

ENDAT.

ENDLOOP.

DESCRIBE TABLE items.

IF start_tabix > sy-tfill OR v_items_count >= sy-tfill.

EXIT.

ENDIF.

ENDDO.

ENDFORM.

  • form expand_collapse

FORM expand_collapse USING value(v_id).

DATA: v_no_more_orphans,

items_temp LIKE items OCCURS 100 WITH HEADER LINE.

DELETE items_show WHERE parent_id = v_id. "try to collapse

IF sy-subrc = 0. "succesfull first collapse

DO. "cascade collapse - delete 'orphans' that are left

REFRESH items_temp.

MOVE items_show[] TO items_temp[].

SORT items_temp BY id.

v_no_more_orphans = 'X'.

LOOP AT items_show WHERE parent_id NE ''.

READ TABLE items_temp WITH KEY id = items_show-parent_id

BINARY SEARCH TRANSPORTING NO FIELDS.

IF sy-subrc NE 0. "no parent - it's an orphan

CLEAR v_no_more_orphans.

DELETE items_show.

ENDIF.

ENDLOOP.

IF v_no_more_orphans = 'X'. EXIT. ENDIF.

ENDDO.

items_show-symbol = '+'.

MODIFY items_show TRANSPORTING symbol WHERE id = v_id.

ELSE. "unsuccessfull collapse - expand

items_show-symbol = '-'.

MODIFY items_show TRANSPORTING symbol WHERE id = v_id.

LOOP AT items WHERE parent_id = v_id. "show children

APPEND items TO items_show.

ENDLOOP.

LOOP AT items_show WHERE parent_id = v_id. "check grandchildren

READ TABLE items WITH KEY parent_id = items_show-id.

IF sy-subrc = 0.

items_show-symbol = '+'.

ELSE.

items_show-symbol = ''.

ENDIF.

MODIFY items_show.

ENDLOOP.

ENDIF.

ENDFORM.

  • form read_from_parent_stack

FORM read_from_parent_stack CHANGING tabix LIKE sy-tabix.

DESCRIBE TABLE parent_stack.

CHECK sy-tfill NE 0.

READ TABLE parent_stack INDEX sy-tfill.

tabix = parent_stack.

ENDFORM.

*& Form delete_parent_stack

&----


form delete_parent_stack.

DESCRIBE TABLE parent_stack.

CHECK sy-tfill NE 0.

DELETE parent_stack INDEX sy-tfill.

endform. " delete_parent_stack

<b>Reward if usefull</b>