2007 Sep 28 6:33 AM
How can i acheive the Interactive ALV functionality??
Can u provide any pseudocode???
2007 Sep 28 6:36 AM
HI,
REPORT ZBHREP3 LINE-COUNT 15(1) LINE-SIZE 75.
TABLES: SFLIGHT.
DATA VAR LIKE SFLIGHT-CONNID.
DATA ITAB LIKE SFLIGHT OCCURS 0 WITH HEADER LINE.
SELECT-OPTIONS CARRID1 FOR SFLIGHT-CARRID.
SET PF-STATUS 'MENU'.
SET TITLEBAR 'TIT'.
FORMAT HOTSPOT ON.
WRITE:/10 'AIRLINE CODE',25 'CONNECTION ID',40 'FLIGHT DATE'.
SELECT * FROM SFLIGHT WHERE CARRID IN CARRID1.
WRITE:/10 SFLIGHT-CARRID,25 SFLIGHT-CONNID,40 SFLIGHT-FLDATE.
HIDE SFLIGHT-CONNID.
ENDSELECT.
*END-OF-PAGE.
END-OF-PAGE.
WRITE:/64 'P.NO:',SY-PAGNO.
*TOP-OF-PAGE.
TOP-OF-PAGE.
WRITE:/ 'THIS IS MY FIRST REPORTS PROGRAM.'.
*AT LINE-SELECTION.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN '1'.
SELECT * FROM SFLIGHT INTO CORRESPONDING FIELDS OF ITAB WHERE
CONNID = SY-LISEL+24(4).
WRITE:/ ITAB-CARRID,ITAB-PLANETYPE,ITAB-PAYMENTSUM.
ENDSELECT.
SKIP 1.
WRITE:/ SY-LISEL+24(4).
WHEN '2'.
WRITE:/ SY-LILLI.
WHEN '3'.
WRITE 😕 'BHARAT'.
ENDCASE.
<b>NOTE:</b>create a menu with name MENU and in that assign PICK as function code to F2 key
rgds,
bharat.
2007 Sep 28 6:36 AM
&----
*& Report Name:- ZNA_ALV_TEMP Create Date : -
*& Author Name:-
*& Program Title:-
&----
*&
&----
REPORT ZNA_ALV_TEMP.
TYPE-POOLS: SLIS.
TABLES: SFLIGHT , SBOOK.
DATA: FIELDS TYPE SLIS_T_FIELDCAT_ALV,
LAYOUT TYPE SLIS_LAYOUT_ALV,
HEADER TYPE SLIS_T_LISTHEADER.
DATA: BEGIN OF IT_FLI OCCURS 0.
DATA: CHECK TYPE C.
INCLUDE STRUCTURE SFLIGHT.
DATA: END OF IT_FLI.
DATA: IT_FLI2 LIKE IT_FLI OCCURS 0 WITH HEADER LINE.
DATA: IT_BOOK TYPE SBOOK OCCURS 0 WITH HEADER LINE.
DATA: WA_FLI LIKE LINE OF IT_FLI.
DATA: WA_BOOK LIKE LINE OF IT_BOOK.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: CARRID FOR SFLIGHT-CARRID,
CONNID FOR SFLIGHT-CONNID.
SELECTION-SCREEN: END OF BLOCK B1.
START-OF-SELECTION.
SELECT * FROM SFLIGHT
INTO CORRESPONDING FIELDS OF TABLE IT_FLI
WHERE
CARRID IN CARRID AND
CONNID IN CONNID.
PERFORM BUILD_FIELDS.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_HEADER.
PERFORM BUILD_COMMENT.
PERFORM GRID_DISPLAY.
PERFORM SET_STATUS .
&----
*& Form BUILD_FIELDS
&----
text
----
--> p1 text
<-- p2 text
----
FORM BUILD_FIELDS .
DATA: FLD TYPE SLIS_FIELDCAT_ALV.
DATA: POS TYPE I.
FLD-FIELDNAME = 'CARRID'.
FLD-TABNAME = 'IT_FLI'.
FLD-JUST = 'C'.
FLD-SELTEXT_M = 'CARRIER ID'.
FLD-COL_POS = POS.
FLD-OUTPUTLEN = 10.
POS = POS + 1.
APPEND FLD TO FIELDS.
CLEAR FLD.
FLD-FIELDNAME = 'CONNID'.
FLD-TABNAME = 'IT_FLI'.
FLD-JUST = 'C'.
FLD-SELTEXT_M = 'CONNECTION ID'.
FLD-COL_POS = POS.
FLD-OUTPUTLEN = 15.
POS = POS + 1.
APPEND FLD TO FIELDS.
CLEAR FLD.
FLD-FIELDNAME = 'FLDATE'.
FLD-TABNAME = 'IT_FLI'.
FLD-JUST = 'C'.
FLD-SELTEXT_M = 'FLIGHT DATE'.
FLD-COL_POS = POS.
FLD-OUTPUTLEN = 12.
POS = POS + 1.
APPEND FLD TO FIELDS.
CLEAR FLD.
FLD-FIELDNAME = 'PRICE'.
FLD-TABNAME = 'IT_FLI'.
FLD-JUST = 'C'.
FLD-SELTEXT_M = 'PRICE'.
FLD-COL_POS = POS.
FLD-OUTPUTLEN = 10.
POS = POS + 1.
APPEND FLD TO FIELDS.
CLEAR FLD.
FLD-FIELDNAME = 'SEATSMAX'.
FLD-TABNAME = 'IT_FLI'.
FLD-JUST = 'C'.
FLD-SELTEXT_M = 'MAXIMUM SEATS'.
FLD-COL_POS = POS.
FLD-OUTPUTLEN = 15.
POS = POS + 1.
APPEND FLD TO FIELDS.
CLEAR FLD.
FLD-FIELDNAME = 'SEATSOCC'.
FLD-TABNAME = 'IT_FLI'.
FLD-JUST = 'C'.
FLD-SELTEXT_M = 'SEATS OCCUPIED'.
FLD-COL_POS = POS.
FLD-OUTPUTLEN = 15.
POS = POS + 1.
APPEND FLD TO FIELDS.
CLEAR FLD.
ENDFORM. " BUILD_FIELDS
&----
*& Form BUILD_LAYOUT
&----
text
----
--> p1 text
<-- p2 text
----
FORM BUILD_LAYOUT .
LAYOUT-ZEBRA = 'X'.
LAYOUT-BOX_FIELDNAME = 'CHECK'.
ENDFORM. " BUILD_LAYOUT
&----
*& Form BUILD_HEADER
&----
text
----
--> p1 text
<-- p2 text
----
FORM BUILD_HEADER .
DATA: TP TYPE SLIS_LISTHEADER.
DATA: STR TYPE STRING,
DAT(10) TYPE C.
TP-TYP = 'H'.
TP-INFO = 'Flight Details'.
APPEND TP TO HEADER.
TP-TYP ='S'.
TP-INFO = 'Flights Available'.
APPEND TP TO HEADER.
WRITE SY-DATUM TO DAT.
CONCATENATE 'DATE : ' DAT INTO STR SEPARATED BY SPACE.
TP-TYP = 'A'.
TP-INFO = STR.
APPEND TP TO HEADER.
ENDFORM. " BUILD_HEADER
&----
*& Form BUILD_COMMENT
&----
text
----
--> p1 text
<-- p2 text
----
FORM BUILD_COMMENT .
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADER
I_LOGO = 'SAPLOGO'.
ENDFORM. " BUILD_COMMENT
&----
*& Form GRID_DISPLAY
&----
text
----
--> p1 text
<-- p2 text
----
FORM GRID_DISPLAY .
IN THIS SUBROUTINE U CAN CHANGE THE DISPLAY MODE BETWEEN GRID AND LIST
BY REMOVING COMMENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDS[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_FLI
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'BUILD_COMMENT'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDS[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_FLI
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
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. " GRID_DISPLAY
&----
*& Form SET_STATUS
&----
text
----
--> p1 text
<-- p2 text
----
FORM SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD'.
ENDFORM. " SET_STATUS
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM SELECT_FIELD TYPE SLIS_SELFIELD.
DATA: WA_FIELDS LIKE LINE OF FIELDS.
DATA: FLAG TYPE I VALUE 0.
CASE R_UCOMM.
WHEN 'DET'.
REFRESH IT_FLI2.
LOOP AT IT_FLI WHERE CHECK = 'X'.
MOVE-CORRESPONDING IT_FLI TO IT_FLI2.
APPEND IT_FLI2.
FLAG = 1.
ENDLOOP.
IF FLAG = 1.
PERFORM DATA_RETRIEVAL.
FLAG = 0.
ENDIF.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDFORM.
&----
*& Form DATA_RETRIEVAL
&----
text
----
--> p1 text
<-- p2 text
----
FORM DATA_RETRIEVAL .
SELECT * FROM SBOOK
UP TO 100 ROWS
INTO TABLE IT_BOOK
FOR ALL ENTRIES IN IT_FLI2
WHERE
CARRID = IT_FLI2-CARRID AND
CONNID = IT_FLI2-CONNID AND
FLDATE = IT_FLI2-FLDATE.
PERFORM LIST_DISPLAY.
ENDFORM. " DATA_RETRIEVAL
&----
*& Form LIST_DISPLAY
&----
text
----
--> p1 text
<-- p2 text
----
FORM LIST_DISPLAY .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_STRUCTURE_NAME = 'SBOOK'
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_BOOK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
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. " LIST_DISPLAY
points please.......
2007 Sep 28 6:38 AM
There's somuch content available. Check this in code gallery.
Also have a look at the below link :
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2binteractive%2balv%2bprogram
2007 Sep 28 6:38 AM
hi madan,
i will give u the sample coding
&----
*& Report ZBAS_INTERACTIVE_REPORT
*&
&----
*&
*&
&----
REPORT ZBAS_INTERACTIVE_REPORT NO STANDARD PAGE HEADING LINE-SIZE 175
LINE-COUNT 35.
TYPE-POOLS : SLIS.
**********Data Declaration
data : selected_field type slis_selfield,
L_Flag value 'F',
ICON_NAME(20),
L_Icon_Status(12),
L_Counter type I value 0.
**********Structure for Purchase Document No
data : Begin of Str_DocumentNo,
EBELN like EKPO-EBELN,
End of Str_DocumentNo.
**********End of Structure for Purchase Document No
**********Structure for Purchase Details
data : Begin of Str_PurchaseDetail,
ICON TYPE ICONS-TEXT, "Status Icon
EBELN like EKKO-EBELN, "Purchase Document No.
KUNNR like EKPO-KUNNR, "Customer
BSART like EKKO-BSART, "Order Type
BEDAT like EKKO-BEDAT, "Date
EKORG like EKKO-EKORG, "Purchase Organization
EKGRP like EKKO-EKGRP, "Purchase Group
ZTERM like EKKO-ZTERM, "Pay Terms
ERNAM like EKKO-ERNAM, "Created By
KDATB like EKKO-KDATB, "Valid From
KDATE like EKKO-KDATE, "Valid Up to
MENGE like EKPO-MENGE, "Items
NETWR like EKPO-NETWR, "Net Amount
WAERS like EKKO-WAERS, "Currency
STATU like EKKO-STATU, "Status Complete/InComplete
End of Str_PurchaseDetail.
**********End of Structure for Purchase Details
**********Internal Table Declarations
data : IT_PurchaseNo like table of Str_DocumentNo with header
line,
IT_PurchaseDetail like table of Str_PurchaseDetail,
WA_PurchaseDetail like line of IT_PurchaseDetail.
**********End of Internal Table Declarations
**********Importing the SelField value
IMPORT selected_field-fieldname FROM MEMORY ID 'FieldName'.
IMPORT selected_field-value FROM MEMORY ID 'FieldValue'.
TOP-OF-PAGE.
uline 1(175).
FORMAT COLOR COL_HEADING.
write : /2 'Status' ,15 'Purchase No.',28 'Customer',
39 'Order Type', 50 'Date',
61 'Purchase Org',74 'Purchase Group',
89 'Pay Terms',99 'Created By',
110 'Valid From',121 'Valid Up to',
133 'Items',149 'Net Amount', 165 'Currency'.
write : 1 sy-vline, 14 sy-vline,27 sy-vline,38 sy-vline,49 sy-vline,
60 sy-vline,73 sy-vline,88 sy-vline,98 sy-vline,
109 sy-vline,120 sy-vline,132 sy-vline,148 sy-vline,164
sy-vline,175 sy-vline.
uline /1(175).
Start-of-Selection.
**********Checking whether Plant/Material Group/Purchase Organization
*********Selected
if selected_field-fieldname = 'WERKS'.
L_Flag = 'T'.
*********Selecting the Purchase Document No based on selected Plant
SELECT EBELN
FROM EKPO
Into Table IT_PurchaseNo
Where WERKS = selected_field-value and EBELN NE ''.
Delete adjacent duplicates from IT_PurchaseNo.
elseif selected_field-fieldname = 'MATKL'.
L_Flag = 'T'.
*********Selecting the Purchase Document No based on selected Material Group
SELECT EBELN
FROM EKPO
Into Table IT_PurchaseNo
Where MATKL = selected_field-value and EBELN NE ''.
Delete adjacent duplicates from IT_PurchaseNo.
elseif selected_field-fieldname = 'EKORG'.
L_Flag = 'T'.
*********Selecting the Purchase Document No based on selected Plant
SELECT EBELN
FROM EKKO
Into Table IT_PurchaseNo
Where EKORG = selected_field-value and EBELN NE ''.
endif.
**********Checking Flag if Plant/Material Group/Purchase Organization is Selected
if L_Flag = 'T'.
loop at IT_PurchaseNo.
*********Selecting the Purchase Details based on Purchase Document No
SELECT SINGLE AEBELN BKUNNR ABSART ABEDAT AEKORG AEKGRP
AZTERM AERNAM AKDATB AKDATE AWAERS ASTATU
FROM EKKO AS A
Inner Join EKPO as B On
AEBELN = BEBELN AND AMANDT = BMANDT
Into Corresponding Fields of WA_PurchaseDetail
Where A~EBELN = IT_PurchaseNo-EBELN.
select sum( MENGE ) sum( NETWR ) into (WA_PurchaseDetail-MENGE,
WA_PurchaseDetail-NETWR)
FROM EKPO
WHERE EBELN = IT_PurchaseNo-EBELN.
Append WA_PurchaseDetail To IT_PurchaseDetail.
endloop.
**********Displaying the Report Information in the Screen
loop at IT_PurchaseDetail into WA_PurchaseDetail.
L_Counter = L_Counter + 1.
IF WA_PurchaseDetail-STATU EQ ''.
ICON_NAME = 'icon_green_light'.
ELSE.
ICON_NAME = 'icon_RED_light'.
ENDIF.
**********Function for Creating ICON
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = ICON_NAME
info = 'STATUS'
IMPORTING
RESULT = WA_PurchaseDetail-ICON.
Modify IT_PurchaseDetail From WA_PurchaseDetail
Transporting ICON
Where EBELN = WA_PurchaseDetail-EBELN.
L_Icon_Status = WA_PurchaseDetail-ICON.
**********End of Function for Creating ICON
FORMAT COLOR COL_NORMAL.
write : / L_Icon_Status UNDER 'Status',
WA_PurchaseDetail-EBELN UNDER 'Purchase No.',
WA_PurchaseDetail-KUNNR UNDER 'Customer',
WA_PurchaseDetail-BSART UNDER 'Order Type',
WA_PurchaseDetail-BEDAT UNDER 'Date',
WA_PurchaseDetail-EKORG UNDER 'Purchase Organization',
WA_PurchaseDetail-EKGRP UNDER 'Purchase Group',
WA_PurchaseDetail-ZTERM UNDER 'Pay Terms',
WA_PurchaseDetail-ERNAM UNDER 'Created By',
WA_PurchaseDetail-KDATB UNDER 'Valid From',
WA_PurchaseDetail-KDATE UNDER 'Valid Up to',
WA_PurchaseDetail-MENGE UNDER 'Items',
WA_PurchaseDetail-NETWR UNDER 'Net Amount',
WA_PurchaseDetail-WAERS UNDER 'Currency'.
write : 1 sy-vline, 14 sy-vline,27 sy-vline,38 sy-vline,49
sy-vline,
60 sy-vline,73 sy-vline,88 sy-vline,98 sy-vline,
109 sy-vline,120 sy-vline,132 sy-vline,148 sy-vline,164
sy-vline,175 sy-vline.
if L_Counter = 31.
L_Counter = 0.
uline /1(175).
endif.
endloop.
uline /1(175).
endif.
**********Displaying the Standard Screen based on selected Purchase Order No
at line-selection.
**********Variable declaration
Data : FldName TYPE String,
EBELN LIKE EKKO-EBELN.
if sy-lsind = 1.
**********Calling the Standard Screen for Selected Field and its value.
Get Cursor Field FldName value EBELN.
if FldName EQ 'WA_PURCHASEDETAIL-EBELN'.
Set Parameter ID 'BES' Field EBELN.
Call Transaction 'ME23' AND Skip First Screen.
else.
Message 'Wrong Selection. Select Purchase Order No' type 'E'.
endif.
endif.
<b>
pls reward if helpful.</b>
2007 Sep 28 6:38 AM
ya madan u can do that...
for that you have to use sy-ucomm for getting the user action...and then in that u can pu your code to display another alv list..
just check following code..
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM SELECT_FIELD TYPE SLIS_SELFIELD.
DATA: FIELD_NAME TYPE SLIS_FIELDNAME.
FIELD_NAME = SELECT_FIELD-FIELDNAME.
<b> CASE R_UCOMM.
WHEN 'DETAIL' OR '&IC1'.</b> CONCATENATE SELECT_FIELD-FIELDNAME ':' SELECT_FIELD-VALUE INTO FNAME.
PERFORM DISPLAY_YEAR.
WHEN 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDFORM.
reward if useful...
2007 Sep 28 6:40 AM
REUSE_ALV_BLOCK_LIST_APPEND Append Simple List in Block Mode
REUSE_ALV_BLOCK_LIST_DATA_GET Internal Use
REUSE_ALV_BLOCK_LIST_DATA_SET Internal Use
REUSE_ALV_BLOCK_LIST_DISPLAY Display a block table
REUSE_ALV_BLOCK_LIST_HS_APPEND
REUSE_ALV_BLOCK_LIST_INIT Initialization of Block List Output
REUSE_ALV_BLOCK_LIST_REFRESH
REUSE_ALV_BLOCK_STATUS_GET
REUSE_ALV_CHECKBOX_SET
REUSE_ALV_COMMENTARY_WRITE List body comment block output
REUSE_ALV_EVENTS_GET Returns table of possible events for a list type
REUSE_ALV_EVENTS_TRANSFER
REUSE_ALV_EVENT_NAMES_GET Returns table of constant names of possible events for a list type
REUSE_ALV_FIELDCATALOG_MERGE Create field catalog from dictionary structure or internal table
REUSE_ALV_HIERSEQ_LIST_DISPLAY Hierarchical sequential list output
REUSE_ALV_HS_LIST_WIDTH_GET Calculate list width
REUSE_ALV_HS_TABLES_GET
REUSE_ALV_LIST_DISPLAY Output a simple list (single line or several lines)
REUSE_ALV_LIST_LAYOUT_INFO_GET Read current ALV list information
REUSE_ALV_LIST_LAYOUT_INFO_SET Set current ALV list information
REUSE_ALV_LIST_SELECTIONS_GET
REUSE_ALV_LIST_SELECTIONS_SET
REUSE_ALV_LIST_WIDTH_GET Calculate list width
REUSE_ALV_POPUP_TO_SELECT List in dialog box to choose one or more entries (or display only)
REUSE_ALV_TABLES_GET
REUSE_ALV_TABLE_CREATE Internal Use
REUSE_ALV_TEXTPOOL_WRITE List body comment block output
REUSE_ALV_TRANSFER_DATA
REUSE_ALV_TRANSFER_DATA_BACK
REUSE_ALV_VARIANT_ALL_MAINTAIN Maintain all display variants for one object
REUSE_ALV_VARIANT_DEFAULT_GET Read default display variant (description only, w/o field catalog)
REUSE_ALV_VARIANT_EXISTENCE Checks whether a display variant exists
REUSE_ALV_VARIANT_F4 Display variant selection dialog box
REUSE_ALV_VARIANT_MAINTAIN Definition of a display variant outside the list context
REUSE_ALV_VARIANT_SAVE Save a display variant
REUSE_ALV_VARIANT_SELECT Read a display variant
REUSE_ALV_GRID_COMMENTARY_SET
REUSE_ALV_GRID_DISPLAY Output of a simple list (single-line)
REUSE_ALV_GRID_DISPLAY_LVC
REUSE_ALV_GRID_LAYOUT_INFO_GET Read current ALV list information
REUSE_ALV_GRID_LAYOUT_INFO_SET Set current ALV list information
REUSE_ALV_TREE_DISPLAY_OM
Regards,
Abhay,
rewards point.
2007 Sep 28 7:10 AM
Hi,
if u want to execute alv inreactiv ereport there is function is there that is ..
SLIS_SELFIELD..in this function having 2 parameters
1) value 2)name...as u following way u have to pass the values..
FORM USERCOMMAND RU_COMM LIKE SY-UCOMM RU_SELFIELD TYPE SLIS_SELFILED.
RU_SELFIELD-NAME = 'VBELN'.
FILED_VALUE = RU_SELFIELD-VALUE.
in above code usercommand u have to pass in REUSE_ALV_GRID_DISLAY function module...
FIELD_VALUE is dynamically which u r going double click that value will store in that...
<b>reward me a points if it is use full answer...</b>
praveen