Application Development and Automation 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: 
Read only

AT LINE_SELECTION

Former Member
0 Likes
1,130

can any tell me how to use 'at line-selection' with some description and example.

I am at starting phase of ABAP devlopment

can any tell me how to use 'at line-selection' with some description and example.

I am at starting phase of ABAP devlopment

7 REPLIES 7
Read only

Former Member
0 Likes
1,031

This event is triggered in interactive reports.

say you have 10 rows in o/p report.

when you select any particular row this event will be trigered and you can have you custom code in the assigned sub routine.

Regards,

Raghavendra

Read only

Former Member
0 Likes
1,031

Syntax

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.

***************************************

AT LINE-SELECTION.

Effect

Event in interactive reporting

This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE,ULINE, or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or clicking once in the case of a hotspot.

The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If you want the current list display to remain visible (to aid user orientation), you can do this with the key word WINDOW.

In most cases, the information from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line.

Note

You can choose a line and start new processing even in the details lists.

The following system fields are useful for orientation purposes, since their values change with each interactive event executed.

SY-LSIND

Index of list created by current event (basic list = 0, 1st details list = 1, ...)

SY-PFKEY

Status of displayed list (SET PF-STATUS)

SY-LISEL

Contents of selected line

SY-LILLI

Absolute number of this line in the displayed list

SY-LISTI

Index of this list - usually SY-LSIND - 1 (READ LINE)

SY-CUROW

Last cursor position: Line in window

SY-CUCOL

Last cursor position: Column in window (GET CURSOR)

SY-CPAGE

1st displayed page of displayed list

SY-STARO

1st displayed line of this page of displayed list

SY-STACO

1st displayed column of displayed list (SCROLL LIST)

The system field SY-LSIND defines the line selection level (basic list: SY-LSIND = 0).

System field for interactive reporting are also contained in the System Fields for Lists documentation.

Example

DATA TEXT(20).

START-OF-SELECTION.

PERFORM WRITE_AND_HIDE USING SPACE SPACE.

AT LINE-SELECTION.

CASE TEXT.

WHEN 'List index'.

PERFORM WRITE_AND_HIDE USING 'X' SPACE.

WHEN 'User command'.

PERFORM WRITE_AND_HIDE USING SPACE 'X'.

WHEN OTHERS.

SUBTRACT 2 FROM SY-LSIND.

PERFORM WRITE_AND_HIDE USING SPACE SPACE.

ENDCASE.

CLEAR TEXT.

FORM WRITE_AND_HIDE USING P_FLAG_LSIND P_FLAG_UCOMM.

WRITE / 'SY-LSIND:'.

PERFORM WRITE_WITH_COLOR USING SY-LSIND P_FLAG_LSIND.

TEXT = 'List index'.

HIDE TEXT.

WRITE / 'SY-UCOMM:'.

PERFORM WRITE_WITH_COLOR USING SY-UCOMM P_FLAG_UCOMM.

TEXT = 'User command'.

HIDE TEXT.

IF SY-LSIND > 0.

WRITE / 'PICK here to go back one list level'.

ENDIF.

ENDFORM.

FORM WRITE_WITH_COLOR USING P_VALUE

P_FLAG_POSITIVE.

IF P_FLAG_POSITIVE = SPACE.

WRITE P_VALUE COLOR COL_NORMAL.

ELSE.

WRITE P_VALUE COLOR COL_POSITIVE.

ENDIF.

ENDFORM.

Read only

0 Likes
1,031

Hi

When the user triggers the function code PICK, AT LINE-SELECTION is always triggered if the cursor is positioned on a list line. The function code PICK is, by default, always linked with function key F2 and hence with the mouse double-click. Consequently, if you have a simple program that does not react to any further user actions, you only need to write this event block.

AT LINE-SELECTION.

<statements>.

As described in the section Dialog Status for Lists, the function code PICK is always added to the standard list status when you have an AT LINE-SELECTION event in your program.

If you assign PICK to other function keys or menu entries, AT LINE-SELECTION is also triggered when the user chooses then. You should avoid this for the sake of the semantics.

Conversely, if you have a more extensive program that does not react to line selection, you should not use the function code PICK. Instead you should assign a different function code to F2 , to ensure that as many events as possible trigger the AT USER-COMMAND event.

TABLES: E070, T000.

*-----------------------------------------------------------------------
*      Constants
*-----------------------------------------------------------------------

CONSTANTS: DATAC(4) VALUE 'data',
           COFILES(7) VALUE 'cofiles',
           LOGC(3) VALUE 'log',
           TPPARAM(12) VALUE 'bintpparam',

*      pointer to TPPARAM file (see HELP for tp.exe)

           TR_R VALUE 'R',
           TR_K VALUE 'K',
           TR_I VALUE 'I',
           TR_D VALUE 'D'.


DATA RE070 LIKE E070.

DATA IE070 LIKE E070 OCCURS 1.

DATA: BEGIN OF SELECT_REQUESTS OCCURS 1,
        TRKORR LIKE E070-TRKORR,
        TRFUNCTION LIKE E070-TRFUNCTION,
      END OF SELECT_REQUESTS.

DATA PROTOCOL LIKE BTCXPM OCCURS 0 WITH HEADER LINE.

DATA COMMAND LIKE SXPGCOLIST-NAME.

DATA PARAM LIKE SXPGCOLIST-PARAMETERS.

DATA DEST(12).


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-008.

*      TEXT-008 : Request_parameters

SELECT-OPTIONS TRKORR FOR E070-TRKORR.
SELECT-OPTIONS TRSTATUS FOR E070-TRSTATUS DEFAULT 'R' NO INTERVALS.

*      TRSTATUS - Correction status

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS REPEAT AS CHECKBOX.

*      If REPEAT = 'X' then request REPKORR will be transported once more

SELECTION-SCREEN COMMENT 3(25) TEXT-012 FOR FIELD REPEAT.

*      TEXT-012 : Repeating_transport_request

SELECTION-SCREEN POSITION POS_LOW.
PARAMETERS REPKORR LIKE E070-TRKORR. "recurring transport request name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B4.

SELECTION-SCREEN BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-015.

*      TEXT-015 : Sourse_system

PARAMETERS SSYSTEM LIKE SY-SYSID DEFAULT 'DEV'.    "sourse system ID
PARAMETERS SHOST(6) DEFAULT 'sshost' LOWER CASE."sourse DB host name
PARAMETERS STRCAT(25) DEFAULT 'sapmnttrans' LOWER CASE.

*      STRCAT - sourse system transport directory

SELECTION-SCREEN END OF BLOCK B5.

SELECTION-SCREEN BEGIN OF BLOCK B6 WITH FRAME TITLE TEXT-016.

*      TEXT-015 : Target_system

PARAMETERS TSYSTEM LIKE SY-SYSID DEFAULT 'QAS'.    "target system ID
PARAMETERS THOST(6) DEFAULT 'tthost' LOWER CASE."target DB host name
PARAMETERS TTRCAT(25) DEFAULT 'sapmnttrans' LOWER CASE.

*      TTRCAT - target system transport directory

SELECT-OPTIONS CLIENT FOR T000-MANDT DEFAULT '010' NO INTERVALS.

*      CLIENT - target clients

SELECTION-SCREEN END OF BLOCK B6.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-009.

*      TEXT-009 : Additional_parameters

PARAMETERS MAXSEL LIKE RSEUMOD-TBMAXSEL DEFAULT 100.

*      MAXSEL - check out 'Imported/Not imported' request list size

PARAMETERS LIKEKORR LIKE E070-TRKORR DEFAULT 'DEVK9%'.          "mask
PARAMETERS RFCNAME(20) DEFAULT 'QASBG' LOWER CASE.  "RFC-connect name
PARAMETERS ADDPARAM(12) LOWER CASE. "additional parameters for tp.exe
SELECTION-SCREEN END OF BLOCK B2.


AT USER-COMMAND.
  CASE SY-PFKEY.

*----------------------- GUI-status MAIN -------------------------------

    WHEN 'MAIN'.
      CASE SY-UCOMM.
        WHEN 'PICK'.
          PERFORM MARK_LINE.
        WHEN 'TRNS'.
          SET PF-STATUS '0001'.
          SET TITLEBAR '001'.
          LOOP AT SELECT_REQUESTS.
            PERFORM TRANS_REQUEST.
          ENDLOOP.
        WHEN 'REFR'.
          PERFORM REFRESH_LIST.
        WHEN 'ELOG'.
          READ CURRENT LINE FIELD VALUE:
                       RE070-TRKORR INTO RE070-TRKORR
                       RE070-TRFUNCTION INTO RE070-TRFUNCTION.
          PERFORM READ_LOG USING 'E'
                                 RFCNAME
                                 RE070-TRKORR
                                 RE070-TRFUNCTION.
        WHEN OTHERS.
      ENDCASE.

*------------------------- GUI-status 0001 -----------------------------

    WHEN '0001'.
      CASE SY-UCOMM.
        WHEN 'ILOG'.
          WINDOW STARTING AT 45 10 ENDING AT 60 12.
          SET PF-STATUS '0002'.
          SET TITLEBAR '002'.
          PERFORM LIST_TRANS_REQUESTS.
        WHEN 'REFR'.
          IF REPEAT IS INITIAL.
            SET PF-STATUS 'MAIN'.
            SET TITLEBAR '001'.
            PERFORM REFRESH_LIST.
          ELSE.
            LEAVE SCREEN.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.

*------------------------ GUI-status 0002 ------------------------------

    WHEN '0002'.
      CASE SY-UCOMM.
        WHEN 'PICK'.
          READ CURRENT LINE FIELD VALUE:
                       SELECT_REQUESTS-TRKORR INTO RE070-TRKORR
                       SELECT_REQUESTS-TRFUNCTION INTO RE070-TRFUNCTION.
          PERFORM READ_LOG USING 'I'
                                 RFCNAME
                                 RE070-TRKORR
                                 RE070-TRFUNCTION.
      ENDCASE.
    WHEN OTHERS.
  ENDCASE.

AT LINE-SELECTION.
  CASE SY-PFKEY.
    WHEN 'MAIN'.
      PERFORM MARK_LINE.
    WHEN '0002'.
      READ CURRENT LINE FIELD VALUE:
                   SELECT_REQUESTS-TRKORR INTO RE070-TRKORR
                   SELECT_REQUESTS-TRFUNCTION INTO RE070-TRFUNCTION.
      PERFORM READ_LOG USING 'I'
                             RFCNAME
                             RE070-TRKORR
                             RE070-TRFUNCTION.
    WHEN OTHERS.
  ENDCASE.

START-OF-SELECTION.
  IF REPEAT IS INITIAL.
    SET PF-STATUS 'MAIN'.
    SET TITLEBAR '001'.
    PERFORM EXTRACT_REQUESTS.
    PERFORM WRITE_REQUESTS_LIST.
  ELSE.
    SET PF-STATUS '0001'.
    SET TITLEBAR '001'.
    NEW-PAGE NO-HEADING NO-TITLE.
    SELECT_REQUESTS-TRKORR = REPKORR.
    SELECT SINGLE TRFUNCTION FROM E070 INTO SELECT_REQUESTS-TRFUNCTION
                  WHERE TRKORR EQ REPKORR.
    APPEND SELECT_REQUESTS.
    PERFORM TRANS_REQUEST.
  ENDIF.

*----------------------------------------------------------------------
*       FORM EXTRACT_REQUESTS                                         
*----------------------------------------------------------------------

FORM EXTRACT_REQUESTS.
  DATA DIR_NAME LIKE EPSF-EPSDIRNAM.
  DATA FILE_MASK LIKE EPSF-EPSFILNAM.
  DATA LOG_DIR LIKE EPSFILI OCCURS 0 WITH HEADER LINE.
  DATA RKEY LIKE EPSFILI-NAME.

  REFRESH IE070.
  SELECT * FROM E070 APPENDING TABLE IE070 UP TO MAXSEL ROWS
                     WHERE TRKORR IN TRKORR
                       AND TRKORR LIKE LIKEKORR
                       AND TRFUNCTION IN ('K','W')
                       AND TRSTATUS IN TRSTATUS
                       ORDER BY TRKORR DESCENDING.
  IF SY-SUBRC NE 0.
    MESSAGE I001 WITH 'Requests not found'(005).
  ENDIF.
  CONCATENATE '\' THOST TTRCAT '' LOGC INTO DIR_NAME.
  CONCATENATE SSYSTEM TR_I '*' INTO FILE_MASK.
  CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
       EXPORTING
            DIR_NAME  = DIR_NAME
            FILE_MASK = FILE_MASK
       TABLES
            DIR_LIST  = LOG_DIR.

  LOOP AT IE070 INTO RE070.
    RE070-TRKORR+3(1) = TR_I.
    CONCATENATE RE070-TRKORR '.' TSYSTEM INTO RKEY.
    READ TABLE LOG_DIR WITH KEY NAME = RKEY.
    IF SY-SUBRC EQ 0.
      DELETE IE070.
    ENDIF.
  ENDLOOP.
ENDFORM.                               "EXTRACT_REQUESTS.

*---------------------------------------------------------------------
*      Form  MARK_LINE
*---------------------------------------------------------------------

FORM MARK_LINE.
  GET CURSOR FIELD RE070-TRKORR VALUE RE070-TRKORR.
  IF SY-SUBRC EQ 0.
    READ CURRENT LINE FIELD VALUE RE070-TRKORR INTO RE070-TRKORR.
    READ TABLE SELECT_REQUESTS WITH KEY TRKORR = RE070-TRKORR.
    IF SY-SUBRC NE 0.
      MODIFY CURRENT LINE LINE FORMAT COLOR = 3.
      READ CURRENT LINE FIELD VALUE RE070-TRFUNCTION
                              INTO RE070-TRFUNCTION.
      APPEND RE070 TO SELECT_REQUESTS.
    ELSE.
      MODIFY CURRENT LINE LINE FORMAT COLOR OFF
                          FIELD FORMAT RE070-TRKORR COLOR 5
                                       RE070-TRFUNCTION COLOR 3
                                       RE070-TRSTATUS COLOR 3
                                       RE070-AS4DATE COLOR 2.
      DELETE SELECT_REQUESTS WHERE TRKORR = RE070-TRKORR.
    ENDIF.
  ENDIF.
ENDFORM.                               " MARK_LINE

*----------------------------------------------------------------------
*      Form  TRANS_REQUEST
*----------------------------------------------------------------------

FORM TRANS_REQUEST.
  DATA: NAME1 LIKE EPSF-EPSPATH,
        NAME2 LIKE EPSF-EPSPATH.
  DATA: BEGIN OF PARAMETER OCCURS 0,
          BEFORE(74), AFTER(74),
        END OF PARAMETER.

  IF REPEAT IS INITIAL AND TSYSTEM NE SSYSTEM.
    CONCATENATE '\' SHOST STRCAT '' DATAC '' TR_D
                SELECT_REQUESTS-TRKORR+4
                '.' SSYSTEM INTO NAME1.
    OPEN DATASET NAME1.
    IF SY-SUBRC EQ 0.
      CLOSE DATASET NAME1.
      CONCATENATE '\' THOST TTRCAT '' DATAC '' TR_D
                  SELECT_REQUESTS-TRKORR+4
                  '.' SSYSTEM INTO NAME2.
      PERFORM COPY_FILE USING NAME1 NAME2.
    ENDIF.
    CLEAR: NAME1, NAME2.

    CONCATENATE '\' SHOST STRCAT '' COFILES '' TR_K
                SELECT_REQUESTS-TRKORR+4
                '.' SSYSTEM INTO NAME1.
    CONCATENATE '\' THOST TTRCAT '' COFILES '' TR_K
                SELECT_REQUESTS-TRKORR+4
                '.' SSYSTEM INTO NAME2.
    PERFORM COPY_FILE USING NAME1 NAME2.
    CLEAR: NAME1, NAME2.
    CONCATENATE '\' SHOST STRCAT '' DATAC '' TR_R
                SELECT_REQUESTS-TRKORR+4
                '.' SSYSTEM INTO NAME1.
    CONCATENATE '\' THOST TTRCAT '' DATAC '' TR_R
                SELECT_REQUESTS-TRKORR+4
                '.' SSYSTEM INTO NAME2.
    PERFORM COPY_FILE USING NAME1 NAME2.
  ENDIF.

  REFRESH PARAMETER.
  PARAMETER-BEFORE = 'addtobuffer'.
  CONCATENATE TSYSTEM
              'pf='
              INTO PARAMETER-AFTER SEPARATED BY ' '.
  CONCATENATE PARAMETER-AFTER
              '\' THOST TTRCAT TPPARAM
              INTO PARAMETER-AFTER.
  APPEND PARAMETER.
  LOOP AT CLIENT.
    IF SY-TABIX NE 1 OR NOT ( REPEAT IS INITIAL ).
      ADDPARAM = 'u1'.
    ENDIF.
    PARAMETER-BEFORE = 'import'.
    CONCATENATE TSYSTEM 'client'
                INTO PARAMETER-AFTER SEPARATED BY ' '.
    CONCATENATE PARAMETER-AFTER
                CLIENT-LOW
                INTO PARAMETER-AFTER.
    CONCATENATE PARAMETER-AFTER
                ADDPARAM 'pf=\'
                INTO PARAMETER-AFTER SEPARATED BY ' '.
    CONCATENATE PARAMETER-AFTER
                THOST TTRCAT TPPARAM
                INTO PARAMETER-AFTER.
    APPEND PARAMETER.
  ENDLOOP.
  COMMAND = 'ZTP'.
  LOOP AT PARAMETER.
    CONCATENATE PARAMETER-BEFORE
                SELECT_REQUESTS-TRKORR
                PARAMETER-AFTER
                INTO PARAM SEPARATED BY ' '.
    IF TSYSTEM NE SSYSTEM.
      DEST = RFCNAME.
    ENDIF.
    PERFORM CALL_EXTERNAL_COMMAND.
    CLEAR DEST.
    REFRESH PROTOCOL.
  ENDLOOP.
  REFRESH PARAMETER.

ENDFORM.                               " TRANS_REQUEST

*----------------------------------------------------------------------
*      Form  WRITE_REQUESTS_LIST
*----------------------------------------------------------------------

FORM WRITE_REQUESTS_LIST.
  IF IE070 IS INITIAL.
    SKIP.
    WRITE: 'Requests not found'(002).
  ELSE.
    LOOP AT IE070 INTO RE070.
      WRITE: /3(3) SY-TABIX, RE070-TRKORR COLOR 5 INTENSIFIED OFF.
      WRITE: RE070-TRFUNCTION COLOR 3 INTENSIFIED OFF,
             RE070-TRSTATUS COLOR 3 INTENSIFIED OFF,
             RE070-AS4USER INTENSIFIED OFF,
             RE070-AS4DATE COLOR 2 INTENSIFIED OFF.
    ENDLOOP.
  ENDIF.

ENDFORM.                               " WRITE_REQUESTS_LIST

*----------------------------------------------------------------------
*      Form  REFRESH_LIST
*----------------------------------------------------------------------

FORM REFRESH_LIST.
  IF SY-LSIND NE 0.
    SY-LSIND = 0.
  ENDIF.
  NEW-PAGE WITH-HEADING WITH-TITLE.
  PERFORM EXTRACT_REQUESTS.
  PERFORM WRITE_REQUESTS_LIST.
  REFRESH SELECT_REQUESTS.

ENDFORM.                               " REFRESH_LIST

*----------------------------------------------------------------------
*      Form  CALL_EXTERNAL_COMMAND
*----------------------------------------------------------------------

FORM CALL_EXTERNAL_COMMAND.

  WRITE: PARAM COLOR 2.
  CALL FUNCTION 'SXPG_CALL_SYSTEM'
       DESTINATION DEST
       EXPORTING
            COMMANDNAME                = COMMAND
            PARAMETERS                 = PARAM
       TABLES
            EXEC_PROTOCOL              = PROTOCOL.

  PERFORM WRITE_PROTOCOL.

ENDFORM.                               " CALL_EXTERNAL_COMMAND

*---------------------------------------------------------------------
*      Form  LIST_TRANS_REQUESTS
*---------------------------------------------------------------------

FORM LIST_TRANS_REQUESTS.
  LOOP AT SELECT_REQUESTS.
    WRITE: / SELECT_REQUESTS-TRKORR COLOR 2,
             SELECT_REQUESTS-TRFUNCTION.
  ENDLOOP.

ENDFORM.                               " LIST_TRANS_REQUESTS

*---------------------------------------------------------------------
*      Form  READ_LOG
*---------------------------------------------------------------------

FORM READ_LOG USING TYPE_LOG VALUE(DEST) VALUE(TRKORR) VALUE(FUNCTION).
  DATA TCODE LIKE SY-TCODE VALUE 'SE01'.
  DATA MODE LIKE SY-SUBCS VALUE 'E'.
  DATA BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  REFRESH BDCTAB.
  CLEAR BDCTAB.
  BDCTAB-PROGRAM = 'RDDM0004'.
  BDCTAB-DYNPRO = '0100'.
  BDCTAB-DYNBEGIN = 'X'.
  APPEND BDCTAB.
  CLEAR BDCTAB.
  BDCTAB-FNAM = 'KO003-TRKORR'.
  BDCTAB-FVAL = TRKORR.
  APPEND BDCTAB.
  CLEAR BDCTAB.
  CASE FUNCTION.
    WHEN 'K'.
      BDCTAB-FNAM = 'KO003-TR_FLAG'.
    WHEN 'W'.
      BDCTAB-FNAM = 'KO003-CW_FLAG'.
    WHEN OTHERS.
      EXIT.
  ENDCASE.
  BDCTAB-FVAL = 'X'.
  APPEND BDCTAB.
  CLEAR BDCTAB.
  BDCTAB-FNAM = 'BDC_OKCODE'.
  BDCTAB-FVAL = 'DISP'.
  APPEND BDCTAB.
  CLEAR BDCTAB.
  BDCTAB-PROGRAM = 'RDDM0005'.
  CASE FUNCTION.
    WHEN 'K'.
      BDCTAB-DYNPRO = '0610'.
    WHEN 'W'.
      BDCTAB-DYNPRO = '0670'.
    WHEN OTHERS.
      EXIT.
  ENDCASE.
  BDCTAB-DYNBEGIN = 'X'.
  APPEND BDCTAB.
  CLEAR BDCTAB.
  BDCTAB-FNAM = 'BDC_OKCODE'.
  BDCTAB-FVAL = '/8'.
  APPEND BDCTAB.
  CLEAR BDCTAB.

  IF TYPE_LOG EQ 'E' OR TSYSTEM EQ SSYSTEM.
    DEST = SPACE.
  ENDIF.
  CALL FUNCTION 'Z_RFC_CALL_TRANSACTION'
       DESTINATION DEST
       EXPORTING
            TCODE   = TCODE
            MODE    = MODE
       TABLES
            BDC_TAB = BDCTAB
       EXCEPTIONS
            OTHERS  = 1.
  IF SY-SUBRC NE 0.
    MESSAGE I000 WITH 'Log not found'(001).
    EXIT.
  ENDIF.
  IF TYPE_LOG EQ 'I'.
    SET USER-COMMAND 'RW'.
  ENDIF.

ENDFORM.                               " READ_LOG

*---------------------------------------------------------------------
*      Form  COPY_FILE
*---------------------------------------------------------------------

FORM COPY_FILE USING SOURSEFILE LIKE EPSF-EPSPATH
                     TARGETFILE LIKE EPSF-EPSPATH.
  DATA BIN TYPE X.

  OPEN DATASET SOURSEFILE FOR INPUT IN BINARY MODE.
  OPEN DATASET TARGETFILE FOR OUTPUT IN BINARY MODE.

  DO.
    READ DATASET SOURSEFILE INTO BIN.
    IF SY-SUBRC NE 0. EXIT. ENDIF.
    TRANSFER BIN TO TARGETFILE.
  ENDDO.
  CLOSE DATASET SOURSEFILE.
  CLOSE DATASET TARGETFILE.

ENDFORM.                               " COPY_FILE

*---------------------------------------------------------------------
*      Form  WRITE_PROTOCOL
*---------------------------------------------------------------------

FORM WRITE_PROTOCOL.
  LOOP AT PROTOCOL.
    WRITE / PROTOCOL-MESSAGE.
  ENDLOOP.

ENDFORM.                               " WRITE_PROTOCOL


*FUNCTION Z_RFC_CALL_TRANSACTION.         "with RFC-support
**"---------------------------------------------------------------------
**"       IMPORTING
**"             VALUE(TCODE) LIKE  SY-TCODE
**"             VALUE(MODE) LIKE  SY-SUBCS DEFAULT 'A'
**"             VALUE(UPDATE) LIKE  SY-SUBCS DEFAULT 'A'
**"             VALUE(SKIP_FIRST_SCREEN) LIKE  SY-SUBCS DEFAULT SPACE
**"       TABLES
**"              BDC_TAB STRUCTURE  BDCDATA
**"---------------------------------------------------------------------
*  TRANSLATE TCODE TO UPPER CASE.
*  IF SKIP_FIRST_SCREEN IS INITIAL.
*    CALL TRANSACTION TCODE USING BDC_TAB MODE MODE UPDATE UPDATE.
*  ELSE.
*    CALL TRANSACTION TCODE USING BDC_TAB MODE MODE UPDATE UPDATE
*                                              AND SKIP FIRST SCREEN.
*  ENDIF.
*ENDFUNCTION.
 

Regards

Pavan

Read only

Former Member
0 Likes
1,031

AT LINE-SELECTION.

Effect

Event in interactive reporting

This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE,ULINE, or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or clicking once in the case of a hotspot.

The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If you want the current list display to remain visible (to aid user orientation), you can do this with the key word WINDOW.

In most cases, the information from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line.

Note

You can choose a line and start new processing even in the details lists.

The following system fields are useful for orientation purposes, since their values change with each interactive event executed.

SY-LSIND

Index of list created by current event (basic list = 0, 1st details list = 1, ...)

SY-PFKEY

Status of displayed list (SET PF-STATUS)

SY-LISEL

Contents of selected line

SY-LILLI

Absolute number of this line in the displayed list

SY-LISTI

Index of this list - usually SY-LSIND - 1 (READ LINE)

SY-CUROW

Last cursor position: Line in window

SY-CUCOL

Last cursor position: Column in window (GET CURSOR)

SY-CPAGE

1st displayed page of displayed list

SY-STARO

1st displayed line of this page of displayed list

SY-STACO

1st displayed column of displayed list (SCROLL LIST)

The system field SY-LSIND defines the line selection level (basic list: SY-LSIND = 0).

System field for interactive reporting are also contained in the System Fields for Lists documentation.

Example

DATA TEXT(20).

START-OF-SELECTION.

PERFORM WRITE_AND_HIDE USING SPACE SPACE.

AT LINE-SELECTION.

CASE TEXT.

WHEN 'List index'.

PERFORM WRITE_AND_HIDE USING 'X' SPACE.

WHEN 'User command'.

PERFORM WRITE_AND_HIDE USING SPACE 'X'.

WHEN OTHERS.

SUBTRACT 2 FROM SY-LSIND.

PERFORM WRITE_AND_HIDE USING SPACE SPACE.

ENDCASE.

CLEAR TEXT.

FORM WRITE_AND_HIDE USING P_FLAG_LSIND P_FLAG_UCOMM.

WRITE / 'SY-LSIND:'.

PERFORM WRITE_WITH_COLOR USING SY-LSIND P_FLAG_LSIND.

TEXT = 'List index'.

HIDE TEXT.

WRITE / 'SY-UCOMM:'.

PERFORM WRITE_WITH_COLOR USING SY-UCOMM P_FLAG_UCOMM.

TEXT = 'User command'.

HIDE TEXT.

IF SY-LSIND > 0.

WRITE / 'PICK here to go back one list level'.

ENDIF.

ENDFORM.

FORM WRITE_WITH_COLOR USING P_VALUE

P_FLAG_POSITIVE.

IF P_FLAG_POSITIVE = SPACE.

WRITE P_VALUE COLOR COL_NORMAL.

ELSE.

WRITE P_VALUE COLOR COL_POSITIVE.

ENDIF.

ENDFORM.

Depending on whether you choose the line at SY-LSIND or SY-UCOMM, the next details list contains the corresponding value with the color "positive". If the line is chosen without HIDE information, the list level is reduced.

Variant 2

AT USER-COMMAND.

Effect

Event in interactive reporting

This event is executed whenever the user presses a function key in the list or makes an entry in the command field.

Some functions are executed directly by the system and thus cannot be processed by programs. These include:

PICK

See variant AT LINE-SELECTION

PFn

See variant AT PFn

/...

System command

%...

System command

PRI

Print

BACK

Back

RW

Cancel

P...

Scroll function (e.g.: P+ , P- , PP+3, PS-- etc.)

Instead of this functions, you can use the SCROLL statement in programs.

Since many of these system functions begin with "P", you should avoid using this letter to start your own function codes.

Otherwise, the effect is as for AT LINE-SELECTION; also, the current function code is stored in the system field SY-UCOMM.

Example

DATA: NUMBER1 TYPE I VALUE 20,

NUMBER2 TYPE I VALUE 5,

RESULT TYPE I.

START-OF-SELECTION.

WRITE: / NUMBER1, '?', NUMBER2.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'ADD'.

RESULT = NUMBER1 + NUMBER2.

WHEN 'SUBT'.

RESULT = NUMBER1 - NUMBER2.

WHEN 'MULT'.

RESULT = NUMBER1 * NUMBER2.

WHEN 'DIVI'.

RESULT = NUMBER1 / NUMBER2.

WHEN OTHERS.

WRITE 'Unknown function code'.

EXIT.

ENDCASE.

WRITE: / 'Result:', RESULT.

After entry of a function code, the appropriate processing is performed under the event AT USER-COMMAND and the result is displayed in the details list.

Variant 3

AT PFn.

Effect

Event in interactive reporting

Here, n stands for a numeric value between 0 and 99.

This event is executed whenever the user presses a function key that contains the function code PFn in the interface definition. The default status for lists contains some of these functions.

Otherwise, the effect is as for the variant AT LINE-SELECTION. The cursor can be on any line.

Notes

To ensure that the chosen function is executed only for valid lines, you can check the current HIDE information.

This variant should be used only for test or prototyping purposes, since the default status is not normally used. Instead, you should set a program-specific status with SET PF-STATUS. This should not contain any function codes beginning with "PF".

Example

DATA NUMBER LIKE SY-INDEX.

START-OF-SELECTION.

DO 9 TIMES.

WRITE: / 'Row', (2) SY-INDEX.

NUMBER = SY-INDEX.

HIDE NUMBER.

ENDDO.

AT PF8.

CHECK NOT NUMBER IS INITIAL.

WRITE: / 'Cursor was in row', (2) NUMBER.

CLEAR NUMBER.

Message was edited by:

Amit Singla

Read only

Former Member
0 Likes
1,031

Hi Pankaj,

Please read below:

AT LINE-SELECTION.

Effect

Event in interactive reporting

This event is processed whenever the user chooses a valid line in the list (i.e. a line generated by statements such as WRITE,ULINE, or SKIP) with the cursor and presses the function key which has the function PICK in the interface definition. This should normally be the function key F2, because it has the same effect as double-clicking the mouse, or clicking once in the case of a hotspot.

The processing for the event AT LINE-SELECTION usually generates further list output (the details list) which completely covers the current list display. If you want the current list display to remain visible (to aid user orientation), you can do this with the key word WINDOW.

In most cases, the information from the selected line is used to retrieve more comprehensive information by direct reading. When displaying the original list, you store the key terms needed for this in the HIDE area of the output line.

Note

You can choose a line and start new processing even in the details lists.

The following system fields are useful for orientation purposes, since their values change with each interactive event executed.

SY-LSIND

Index of list created by current event (basic list = 0, 1st details list = 1, ...)

SY-PFKEY

Status of displayed list (SET PF-STATUS)

SY-LISEL

Contents of selected line

SY-LILLI

Absolute number of this line in the displayed list

SY-LISTI

Index of this list - usually SY-LSIND - 1 (READ LINE)

SY-CUROW

Last cursor position: Line in window

SY-CUCOL

Last cursor position: Column in window (GET CURSOR)

SY-CPAGE

1st displayed page of displayed list

SY-STARO

1st displayed line of this page of displayed list

SY-STACO

1st displayed column of displayed list (SCROLL LIST)

The system field SY-LSIND defines the line selection level (basic list: SY-LSIND = 0).

System field for interactive reporting are also contained in the System Fields for Lists documentation.

Example

DATA TEXT(20).

START-OF-SELECTION.

PERFORM WRITE_AND_HIDE USING SPACE SPACE.

AT LINE-SELECTION.

CASE TEXT.

WHEN 'List index'.

PERFORM WRITE_AND_HIDE USING 'X' SPACE.

WHEN 'User command'.

PERFORM WRITE_AND_HIDE USING SPACE 'X'.

WHEN OTHERS.

SUBTRACT 2 FROM SY-LSIND.

PERFORM WRITE_AND_HIDE USING SPACE SPACE.

ENDCASE.

CLEAR TEXT.

FORM WRITE_AND_HIDE USING P_FLAG_LSIND P_FLAG_UCOMM.

WRITE / 'SY-LSIND:'.

PERFORM WRITE_WITH_COLOR USING SY-LSIND P_FLAG_LSIND.

TEXT = 'List index'.

HIDE TEXT.

WRITE / 'SY-UCOMM:'.

PERFORM WRITE_WITH_COLOR USING SY-UCOMM P_FLAG_UCOMM.

TEXT = 'User command'.

HIDE TEXT.

IF SY-LSIND > 0.

WRITE / 'PICK here to go back one list level'.

ENDIF.

ENDFORM.

FORM WRITE_WITH_COLOR USING P_VALUE

P_FLAG_POSITIVE.

IF P_FLAG_POSITIVE = SPACE.

WRITE P_VALUE COLOR COL_NORMAL.

ELSE.

WRITE P_VALUE COLOR COL_POSITIVE.

ENDIF.

ENDFORM.

Depending on whether you choose the line at SY-LSIND or SY-UCOMM, the next details list contains the corresponding value with the color "positive". If the line is chosen without HIDE information, the list level is reduced.

Lokesh

PS: Please reward helpful posts

Read only

Former Member
0 Likes
1,031

HI,

this event will trigger whenever user selects a line in the list output.

<b>example:</b>

START-OF-SELECTION.

WRITE 'Basic List'.

set pf-status 'MYMENU'.

AT LINE-SELECTION.

WRITE: 'Secondary List by Line-Selection',

/ 'SY-UCOMM =', sy-ucomm.

in my menu u have to assign the function code(PICK) for button F2.

for more info see this link

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

rgds,

bharat.

Read only

Former Member
0 Likes
1,031

Hi,

At line selection is used to make the interactive report.....

->say in a report program you have displayed the output.

->the output consists of many lines.

->when you click on some line in the output you need extra information

->this can be achieved using At line selection.

example:

AT LINE-SELECTION.

CASE sy-lsind. "list count

WHEN 1.

//display additional information.

ENDCASE.

<b>reward points if useful.</b>

regards,

Vinod Samuel.