Skip to Content
author's profile photo Former Member
Former Member

when we have to use sy-lsind

Hi all,

when we have to use sy-lsind

Message was edited by: hari haran

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 01:49 PM

    In interactive lists in events

    AT USER-COMMAND

    AT LINE-SELECTION

    AT PFn.

    SY-LSIND has the number of secondary list .

    On basic list it is 0.

    When you goto first secondary list at any user command it

    will be 1 . It increments by 1 on every user action in interactive lists and decremnets by 1 by clicking "BACK" button. This si automatic.

    You can explicitly set the list number by changing sy-lsind .

    Cheers.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 01:51 PM

    Hi hari,

    in simple words....

    <b>SY-LSIND</b> is the index of the current list

    regards,

    venu.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 19, 2005 at 01:48 PM

    This is the list index. It will increment everytime you lay a list on top of another. If you want to replace a list instead of laying over top, then you will need to decrement the list index by one before writing the new list.

    Sy-lsind = sy-lsind - 1.

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 01:48 PM

    sy-lisind gives u the number for the Secondary list.

    if u have more then one secondary list then it plays as a counter value.

    Regards,

    Azee.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 01:48 PM

    Hi,

    When the system processes event blocks that are not assigned to interactive list events, and when processing dialog modules, the ABAP program writes its list output to the basic list.

    The ABAP system field SY-LSIND contains the index of the list currently being created. While the basic list is being created, SY-LSIND is zero.

    By default, the basic list has a standard list status and a standard page header. The TOP-OF-PAGE and END-OF-PAGE events can occur while the basic list is being created. All output in these events is placed in the page header or footer of the basic list. In executable programs, the basic list is automatically sent to the list processor and displayed at the end of the END-OF-SELECTION event. Otherwise, it is displayed after the PAI processing block on the screen from which the LEAVE TO LIST-PROCESSING statement occurred.

    regards,

    venu.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 01:50 PM

    sy-lsind is a system variable which indicated whihc secondary list you are processing. You will use like this in the AT Line selection event

    AT LINE-SELECTION.

    CASE SY-LSIND.

    WHEN 1.

    PERFORM WRITE_REPORT_1.

    WHEN 2.

    PERFORM WRITE_REPORT_2.

    Have a look at the code below

    &----


    &----


    *& Report Z_INT_TEST *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT Z_INT_TEST LINE-COUNT 55(5)

    LINE-SIZE 95

    NO STANDARD PAGE HEADING

    MESSAGE-ID ZZ.

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

    • Table Declarations

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

    TABLES: MARA.

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

    • Data Declarations

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

    DATA: BEGIN OF IT_MARA OCCURS 0,

    MATNR LIKE MARA-MATNR,

    MTART LIKE MARA-MTART,

    MATKL LIKE MARA-MATKL,

    MEINS LIKE MARA-MEINS,

    DATAB LIKE MARA-DATAB,

    END OF IT_MARA.

    DATA: BEGIN OF IT_MAKT OCCURS 0,

    MATNR LIKE MAKT-MATNR,

    MAKTX LIKE MAKT-MAKTX,

    END OF IT_MAKT.

    DATA: BEGIN OF IT_MARD OCCURS 0,

    MATNR LIKE MARD-MATNR,

    WERKS LIKE MARD-WERKS,

    LGORT LIKE MARD-LGORT,

    END OF IT_MARD.

    DATA: NO_SEL(1) TYPE C.

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

    • Selection Screen

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

    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

    PARAMETERS: P_DATAB LIKE MARA-DATAB.

    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. " OBLIGATORY.

    SELECTION-SCREEN END OF BLOCK BLK1.

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

    • Initialization

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

    INITIALIZATION.

    P_DATAB = SY-DATUM.

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

    • Start of Selection

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

    START-OF-SELECTION.

    SET PF-STATUS 'XXX'.

    *-- Get Material details from MARA

    PERFORM GET_MATNR_DETAILS.

    *-- Get Material Description

    PERFORM GET_MATNR_DESC.

    *-- Get Storage location

    PERFORM GET_STORAGE.

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

    • End of Selection

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

    END-OF-SELECTION.

    IF NO_SEL = 'X'.

    MESSAGE I000 WITH 'no selection found'.

    EXIT.

    ENDIF.

    *-- Write Bsaic list

    PERFORM WRITE_BASIC_0.

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

    • Top-of-page

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

    TOP-OF-PAGE.

    PERFORM WRITE_BASIC_HEADER.

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

    • End-of-page

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

    END-OF-PAGE.

    PERFORM WRITE_FOOTER.

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

    • At line-selection

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

    AT LINE-SELECTION.

    CASE SY-LSIND.

    WHEN 1.

    PERFORM WRITE_REPORT_1.

    WHEN 2.

    PERFORM WRITE_REPORT_2.

    ENDCASE.

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

    • top-of-page during line-selection

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

    TOP-OF-PAGE DURING LINE-SELECTION.

    CASE SY-LSIND.

    WHEN 1.

    PERFORM WRITE_HEADER_1.

    WHEN 2.

    PERFORM WRITE_HEADER_2.

    ENDCASE.

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

    • At user-command

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

    AT USER-COMMAND.

    CASE SY-UCOMM.

    WHEN 'BACK'.

    CALL SCREEN 0.

    WHEN 'SAVE'.

    PERFORM DOWNLOAD_LOCAL.

    WHEN 'AABB'.

    CALL SCREEN 0.

    ENDCASE.

    &----


    *& Form get_matnr_details

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM GET_MATNR_DETAILS .

    SELECT MATNR

    MTART

    MATKL

    MEINS

    DATAB

    FROM MARA

    INTO TABLE IT_MARA

    WHERE MATNR IN S_MATNR AND

    DATAB >= P_DATAB.

    IF SY-SUBRC <> 0.

    NO_SEL = 'X'.

    STOP.

    ELSE.

    SORT IT_MARA BY MATNR.

    ENDIF.

    ENDFORM. " get_matnr_details

    &----


    *& Form get_matnr_desc

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM GET_MATNR_DESC .

    SELECT MATNR

    MAKTX

    FROM MAKT

    INTO TABLE IT_MAKT

    FOR ALL ENTRIES IN IT_MARA

    WHERE MATNR = IT_MARA-MATNR AND

    SPRAS = SY-LANGU.

    IF SY-SUBRC = 0.

    SORT IT_MAKT BY MATNR.

    ENDIF.

    ENDFORM. " get_matnr_desc

    &----


    *& Form get_storage

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM GET_STORAGE .

    SELECT MATNR

    WERKS

    LGORT

    FROM MARD

    INTO TABLE IT_MARD

    FOR ALL ENTRIES IN IT_MARA

    WHERE MATNR = IT_MARA-MATNR.

    IF SY-SUBRC = 0.

    SORT IT_MARD BY MATNR.

    ENDIF.

    ENDFORM. " get_storage

    &----


    *& Form write_basic_header

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM WRITE_BASIC_HEADER .

    FORMAT COLOR COL_HEADING.

    ULINE.

    WRITE:/ SY-VLINE,

    (18) 'Material'(002), SY-VLINE,

    (13) 'Material Type'(003), SY-VLINE,

    (14) 'Material Group'(004), SY-VLINE,

    (19) 'Unit of Measurement'(005), SY-VLINE,

    (15) 'Valid from Date'(006), SY-VLINE.

    ULINE.

    FORMAT RESET.

    ENDFORM. " write_basic_header

    &----


    *& Form write_basic_0

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM WRITE_BASIC_0 .

    LOOP AT IT_MARA.

    WRITE:/ SY-VLINE,

    (18) IT_MARA-MATNR,SY-VLINE,

    (13) IT_MARA-MTART,SY-VLINE,

    (14) IT_MARA-MATKL,SY-VLINE,

    (19) IT_MARA-MEINS,SY-VLINE,

    (15) IT_MARA-DATAB,SY-VLINE.

    HIDE: IT_MARA-MATNR.

    CLEAR: IT_MARA.

    ENDLOOP.

    ULINE.

    ENDFORM. " write_basic_0

    &----


    *& Form write_footer

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM WRITE_FOOTER .

    DATA: V_TEMP(125) TYPE C.

    ULINE.

    SKIP.

    CONCATENATE 'Program run by : ' SY-UNAME 'on: ' SY-DATUM INTO V_TEMP.

    WRITE:/(125) V_TEMP.

    SKIP.

    ULINE.

    ENDFORM. " write_footer

    &----


    *& Form write_report_1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM WRITE_REPORT_1 .

    CLEAR IT_MAKT.

    READ TABLE IT_MAKT WITH KEY MATNR = IT_MARA-MATNR BINARY SEARCH.

    IF SY-SUBRC = 0.

    WRITE:/(18) IT_MAKT-MATNR,SY-VLINE,

    (40) IT_MAKT-MAKTX,SY-VLINE.

    HIDE: IT_MAKT-MATNR.

    CLEAR IT_MAKT.

    ULINE (62).

    ENDIF.

    ENDFORM. " write_report_1

    &----


    *& Form write_header_1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM WRITE_HEADER_1 .

    FORMAT COLOR COL_HEADING.

    ULINE (62).

    WRITE:/(18) TEXT-002,SY-VLINE,

    (40) 'Material Description'(010),SY-VLINE.

    ULINE (62).

    FORMAT RESET.

    ENDFORM. " write_header_1

    &----


    *& Form write_header_1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM WRITE_HEADER_2 .

    NEW-PAGE LINE-SIZE 45.

    FORMAT COLOR COL_HEADING.

    ULINE (45).

    WRITE:/(15) TEXT-002,SY-VLINE,

    (5) 'Plant'(011),SY-VLINE,

    (16) 'Storage Location'(012),SY-VLINE.

    ULINE (45).

    FORMAT RESET.

    ENDFORM. " write_header_2

    &----


    *& Form write_report_1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM WRITE_REPORT_2 .

    CLEAR IT_MARD.

    READ TABLE IT_MARD WITH KEY MATNR = IT_MAKT-MATNR BINARY SEARCH.

    IF SY-SUBRC = 0.

    WRITE:/(18) IT_MARD-MATNR,SY-VLINE,

    (5) IT_MARD-WERKS,SY-VLINE,

    (16) IT_MARD-LGORT,SY-VLINE.

    ULINE.

    ELSE.

    MESSAGE E000 WITH 'No data'.

    ENDIF.

    ENDFORM. " write_report_1

    &----


    *& Form download_local

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DOWNLOAD_LOCAL .

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    FILENAME = 'C:\temp.txt'

    • FILETYPE = 'ASC'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ' '

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • IMPORTING

    • FILELENGTH =

    TABLES

    DATA_TAB = IT_MARA

    • EXCEPTIONS

    • FILE_WRITE_ERROR = 1

    • NO_BATCH = 2

    • GUI_REFUSE_FILETRANSFER = 3

    • INVALID_TYPE = 4

    • NO_AUTHORITY = 5

    • UNKNOWN_ERROR = 6

    • HEADER_NOT_ALLOWED = 7

    • SEPARATOR_NOT_ALLOWED = 8

    • FILESIZE_NOT_ALLOWED = 9

    • HEADER_TOO_LONG = 10

    • DP_ERROR_CREATE = 11

    • DP_ERROR_SEND = 12

    • DP_ERROR_WRITE = 13

    • UNKNOWN_DP_ERROR = 14

    • ACCESS_DENIED = 15

    • DP_OUT_OF_MEMORY = 16

    • DISK_FULL = 17

    • DP_TIMEOUT = 18

    • FILE_NOT_FOUND = 19

    • DATAPROVIDER_EXCEPTION = 20

    • CONTROL_FLUSH_ERROR = 21

    • OTHERS = 22

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDFORM. " download_local

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.