‎2007 Dec 20 10:14 AM
Hi forum,
I've two tables ekko and ekpo.
In that first i should display ekko-ebeln records.
After that by double clicking on any one of the records
a secondary list should display containing the details of ekpo-ebeln of that particular record of ekko (not all the records of ekpo)
Pls help me out in writting at line-selection event.
thanks,
mahathi
‎2007 Dec 20 10:27 AM
try this code..
TABLES : ekpo, ekko.
DATA : i_ekko LIKE ekko OCCURS 0 WITH HEADER LINE.
DATA : i_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
AT LINE-SELECTION.
READ LINE sy-lilli.
if sy-subrc = 0.
SELECT * INTO table i_ekpo FROM ekpo WHERE ebeln EQ i_ekko-ebeln.
LOOP at i_ekpo.
write 😕 i_ekpo-matnr,i_ekpo-ebeln, i_ekpo-ebelp.
endloop.
endif.
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE i_ekko
UP TO 30 ROWS.
LOOP AT i_ekko.
WRITE 😕 i_ekko-ebeln.
HIDE i_ekko-ebeln.
ENDLOOP.
‎2007 Dec 20 10:19 AM
Hi,
Pls go through this.
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.
This should help you to understand.
Regards,
Pankaj
‎2007 Dec 20 10:22 AM
Hi
in both the tables ekko and ekpo the ebeln is the same
which is the primary key for the two tables
so i think no need to display ekpo-ebeln as separate
as if that is ekko-ebeln
Hope this help u
Reward points if useful
Regards,
Sreenivas
‎2007 Dec 20 10:27 AM
Hi
Mahathi
use the HIDE concept thenu can retrive all the previous values i mean prevuiovs list values so
at line selction .
you can write required quiries
plzz reward if usefull..
‎2007 Dec 20 10:27 AM
try this code..
TABLES : ekpo, ekko.
DATA : i_ekko LIKE ekko OCCURS 0 WITH HEADER LINE.
DATA : i_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
AT LINE-SELECTION.
READ LINE sy-lilli.
if sy-subrc = 0.
SELECT * INTO table i_ekpo FROM ekpo WHERE ebeln EQ i_ekko-ebeln.
LOOP at i_ekpo.
write 😕 i_ekpo-matnr,i_ekpo-ebeln, i_ekpo-ebelp.
endloop.
endif.
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE i_ekko
UP TO 30 ROWS.
LOOP AT i_ekko.
WRITE 😕 i_ekko-ebeln.
HIDE i_ekko-ebeln.
ENDLOOP.
‎2007 Dec 20 10:32 AM
‎2007 Dec 20 10:33 AM
Hi Queen,
Try this example.
REPORT ZSDN.
TABLES : EKPO,
EKKO.
DATA : I_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE,
I_EKPO LIKE EKPO OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM EKKO INTO TABLE I_EKKO.
LOOP AT I_EKKO.
WRITE: / I_EKKO-EBELN.
HIDE: I_EKKO-EBELN.
ENDLOOP.
AT LINE-SELECTION.
SELECT * INTO TABLE I_EKPO FROM EKPO WHERE EBELN EQ I_EKKO-EBELN.
IF SY-SUBRC = 0.
LOOP AT I_EKPO.
WRITE 😕 I_EKPO-MATNR,I_EKPO-EBELN, I_EKPO-EBELP.
ENDLOOP.
ENDIF.
Hope this will solve your query.
- Selva
‎2007 Dec 20 10:35 AM
Hi Mahathi,
Check this code. this will give a better idea of at line selection event.
In this program i am using two tables bsik and bseg for getting the vendor information
In that first i should display vendor details from bsik based on the selection screen.
After that i display the G/L account info from bseg table corresponding to the vendors selected in the primary list in the secondary list.
TABLES : BSIK,BSEG.
TYPES : BEGIN OF TABINV,
LIFNR TYPE BSIK-LIFNR,
WAERS TYPE BSIK-WAERS,
WRBTRD TYPE BSIK-WRBTR,
WRBTRC TYPE BSIK-WRBTR,
END OF TABINV.
TYPES : BEGIN OF INVDOC,
HKONT TYPE BSEG-HKONT,
WRBTR TYPE BSEG-WRBTR,
WAERSK TYPE BSIK-WAERS,
SHKZG TYPE BSEG-SHKZG,
END OF INVDOC.
DATA : ITAB_BSIK LIKE TABLE OF BSIK WITH HEADER LINE,
CHK1 TYPE C,
ITAB TYPE STANDARD TABLE
OF TABINV INITIAL SIZE 10 WITH HEADER LINE,
IBSEG TYPE STANDARD TABLE
OF INVDOC INITIAL SIZE 10 WITH HEADER LINE,
VARLIFNR(10) TYPE C.
SELECTION-SCREEN BEGIN OF BLOCK INVOICE WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS S_BUKRS FOR BSIK-BUKRS DEFAULT '0500' TO '1000'
NO-EXTENSION.
SELECT-OPTIONS S_LIFNR FOR BSIK-LIFNR NO-EXTENSION.
SELECT-OPTIONS S_GJAHR FOR BSIK-GJAHR NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK INVOICE.
START-OF-SELECTION.
SKIP.
SET PF-STATUS 'ZMENU_PROCINV'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = S_LIFNR
IMPORTING
OUTPUT = S_LIFNR.
SELECT DISTINCT LIFNR BUKRS BELNR BUDAT GJAHR WRBTR WAERS SHKZG FROM
BSIK INTO CORRESPONDING FIELDS OF
TABLE ITAB_BSIK WHERE
BUKRS IN S_BUKRS AND
LIFNR IN S_LIFNR AND
GJAHR IN S_GJAHR.
IF SY-SUBRC <> 0.
WRITE 😕 'NO RECORD FOUND'.
ENDIF.
LOOP AT ITAB_BSIK.
MOVE ITAB_BSIK-LIFNR TO ITAB-LIFNR.
MOVE ITAB_BSIK-WAERS TO ITAB-WAERS.
IF ITAB_BSIK-SHKZG = 'S'.
MOVE ITAB_BSIK-WRBTR TO ITAB-WRBTRD.
ELSEIF ITAB_BSIK-SHKZG = 'H'.
MOVE ITAB_BSIK-WRBTR TO ITAB-WRBTRC.
ENDIF.
COLLECT ITAB.
ENDLOOP.
LOOP AT ITAB.
WRITE 😕 CHK1 AS CHECKBOX,
SY-TABIX,SY-VLINE,
ITAB-LIFNR,ITAB-WRBTRD,
ITAB-WRBTRC,ITAB-WAERS.
ENDLOOP.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'PROCITEM' .
PERFORM DISPLAY.
ENDCASE.
TOP-OF-PAGE.
SKIP.
WRITE :/25 'INVOICE SUMMARY REPORT '.
ULINE :/21(30).
ULINE :/1(67).
WRITE: /10 'SNo.',
17 'Vendor Number',
34 'Debit Amt',
50 'Credit Amt',
61 'Curr.'.
ULINE :/1(67).
TOP-OF-PAGE DURING LINE-SELECTION.
SKIP.
WRITE :/54 'GENERAL LEDGER LINE-ITEMS DETAIL REPORT '.
ULINE :/50(50).
ULINE :/1(255).
WRITE :/2 'DOCUMENT NO.',
18 'DOC.DATE',
30 'DOC.YEAR',
42 'VENDOR NO./GL NUMBER',
70 'AMOOUNT IN LC',
90 'LOCAL CURR.',
106 'DR/CR IND.'.
ULINE :/1(255).
&----
*& Form DISPLAY
&----
text
----
--> p1 text
<-- p2 text
----
FORM DISPLAY .
SET PF-STATUS ' '.
DO.
CLEAR CHK1.
READ LINE SY-INDEX FIELD VALUE CHK1.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
CHECK CHK1 NE space.
READ LINE SY-INDEX FIELD VALUE ITAB-LIFNR INTO VARLIFNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = VARLIFNR
IMPORTING
OUTPUT = VARLIFNR.
LOOP AT ITAB_BSIK.
IF ITAB_BSIK-LIFNR = VARLIFNR.
SELECT HKONT WRBTR PSWSL AS WAERSK SHKZG FROM BSEG
INTO CORRESPONDING FIELDS OF TABLE IBSEG
WHERE BELNR = ITAB_BSIK-BELNR
AND GJAHR = ITAB_BSIK-GJAHR
AND BUKRS = ITAB_BSIK-BUKRS
AND KOART NE 'K' .
IF SY-SUBRC = 0.
WRITE :/2 ITAB_BSIK-BELNR,18 ITAB_BSIK-BUDAT,
31 ITAB_BSIK-GJAHR,43 ITAB_BSIK-LIFNR,
68 ITAB_BSIK-WRBTR,92 ITAB_BSIK-WAERS,
108 ITAB_BSIK-SHKZG.
ULINE :/42(255) .
LOOP AT IBSEG.
WRITE :/43 IBSEG-HKONT,68 IBSEG-WRBTR,
92 IBSEG-WAERSK,108 IBSEG-SHKZG.
ENDLOOP.
ULINE :/1(255).
ENDIF.
ENDIF.
ENDLOOP.
MODIFY CURRENT LINE :
FIELD VALUE CHK1 FROM ' '
FIELD FORMAT CHK1 INPUT ON.
ENDIF.
ENDDO.
ENDFORM. " DISPLAY
Reward Points,if helpful.
Regards,
Manoj Kumar
‎2007 Dec 20 10:47 AM
Hi,
Please check the code below given.
I tried and checked .its working fine.
-
REPORT zstemp_qty2_ LINE-SIZE 255 .
DATA:it_ekko LIKE ekko OCCURS 0 WITH HEADER LINE.
DATA:it_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE it_ekko UP TO 10 ROWS.
IF NOT it_ekko[] IS INITIAL.
SELECT * FROM ekpo INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
ENDIF.
LOOP AT it_ekko.
WRITE:/ it_ekko-ebeln.
HIDE it_ekko-ebeln.
ENDLOOP.
AT LINE-SELECTION.
LOOP AT it_ekpo WHERE ebeln = it_ekko-ebeln.
WRITE:/ it_ekpo-ebelp,it_ekpo-ebeln.
ENDLOOP.
*If you want single to be output then use read
READ TABLE it_ekpo WITH KEY ebeln = it_ekko-ebeln.
IF sy-subrc = 0 .
WRITE:it_ekpo-ebelp,it_ekpo-ebeln.
ENDIF.
-
Regds
Sivaparvathi
Please reward points if helpful.................