Standard toolbar in an ALV output report
hey guys,
can i manipulate the standard toolbar (BACK, CANCEL, EXIT) of an ALV output report as in a screen?
I want to put some codes when the user ticks on the particular button.
Thanks a lot!
Regards,
Mark
in SE41
copy Program SAPLKKBL
Status STANDARD
to ur Program ZPROGRAM
Status ZSTANDARD
in ur Z program
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
below of ur program write these 2FOMS...
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
*PF status of program 'SAPLKKBL' is 'STANDARD' is copied for standard
*options(buttons)
SET PF-STATUS 'ZLSTANDARD'.
ENDFORM. "set_pf_status
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE sy-ucomm.
WHEN 'SAVE'.
*write ur code here
WHEN 'BACK'.
*write ur code here
WHEN 'EXIT'.
*write ur code here
ENDCASE.
ENDFORM. "user_command
Regatds,
Ramesh.
Similar Messages
-
How to capture multiple(Random) records of an ALV output report?
Hi Friends,
1) I have an output in Grid format(using reuse_alv_grid_displlay). I have 3 push buttons on the menu bar(for ex.. Approve, reject and forward). The user will select multiple lines on the ALV output and hits either one of these push buttons. My question is how do I capture the multiple selected output lines.
2) This question has been asked before..and I tried to implement the answer. The problem I am facing is ..I need a function key to say that everytime I select a line(single click)..it should modify the internal tabel with CHECK = 'X'.
Any help is kindly appreciated.Hi
If you should have in your output table a field for MARK, the system'll set this field for every selected fields.
DATA: BEGIN OF T_OUTPUT,
FIELD1,....
FIELDN,
MARK,
END OF T_OUTPUT
Before calling ALV GRID
You have to indicate tne name of field for selection:
gt_layout-box_fieldname = 'MARK'.
gt_layout-box_tabname = 'T_OUTPUT'.
So in your user command
LOOP AT T_OUTPUT WHERE MARK = 'X'.
ENDLOOP.
Max -
How to display standard toolbar buttons in ALV which are not displayed in REUSE_ALV_GRID_DISPLAY
HI
GOOD
GO THROUGH THIS REPORT
TYPE-POOLS: SLIS.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF FIELDCAT,
SORTCAT TYPE SLIS_T_SORTINFO_ALV,
SORTCAT_LN LIKE LINE OF SORTCAT,
EVENTCAT TYPE SLIS_T_EVENT,
EVENTCAT_LN LIKE LINE OF EVENTCAT,
LAYOUT TYPE SLIS_LAYOUT_ALV,
C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
W_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: COL_POS TYPE I,
P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'STATUS'.
******Declare Data Areas for List Viewer (End)**************
Other Variables
DATA: W_DATUM(10) TYPE C. "Convert system Date for Output
******Declare Internal Table to Store Selected Data (Begin)*
DATA: BEGIN OF IREPO OCCURS 0,
EQUNR LIKE EQUI-EQUNR,
EQKTX LIKE EQKT-EQKTX, "description
ERDAT LIKE EQUI-ERDAT,
ERNAM LIKE EQUI-ERNAM,
AEDAT LIKE EQUI-AEDAT,
AENAM LIKE EQUI-AENAM,
EQART LIKE EQUI-EQART,
INBDT LIKE EQUI-INBDT,
ZZ_DESPATCH LIKE EQUI-ZZ_DESPATCH,
( ten million other Z fields)
VKBUR LIKE ILOA-VKBUR, "Sales Office
SWERK LIKE ILOA-SWERK, "Base Plant
KOSTL LIKE ILOA-KOSTL, "Cost Centre
ANLNR LIKE ITOB-ANLNR, "Asset Number
NAME1 LIKE LFA1-NAME1, "Haulier name
STATUS TYPE C, "Is it flagged for deletion?
END OF IREPO.
Table for descriptions
DATA: BEGIN OF IEQKT OCCURS 0,
EQUNR LIKE EQKT-EQUNR,
EQKTX LIKE EQKT-EQKTX,
END OF IEQKT.
LOD Names - Internal Buffering
DATA: BEGIN OF VENDLIST OCCURS 0,
LIFNR LIKE LFA1-LIFNR, "Vendor Number
NAME1 LIKE LFA1-NAME1, "Vendor Name
END OF VENDLIST.
******Declare Internal Table to Store Selected Data (End)**
TABLES: EQUI,ILOA.
*******Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: P_EQUNR FOR EQUI-EQUNR, "Fleet Number
P_PLATE FOR EQUI-ZZ_PLATE_NO, "Registration
P_EQART FOR EQUI-EQART. "Truck Type
PARAMETER: EXCLUDE AS CHECKBOX. "Exclude Deleted Trucks
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: P_DESPG FOR EQUI-ZZ_DESPATCH, "Dgroup
P_VKBUR FOR ILOA-VKBUR, "Sales Office
P_SWERK FOR ILOA-SWERK. "Plant
SELECTION-SCREEN END OF BLOCK BLK2.
SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-003.
SELECT-OPTIONS: P_HAULER FOR EQUI-ZZ_HAULER. "Haulier Vendor
SELECTION-SCREEN END OF BLOCK BLK3.
*******Select Data into Internal Table (Begin) ***************
START-OF-SELECTION.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
TEXT = 'Reading Truck Master Table' .
SELECT EQUIEQUNR EQUIEQART EQUIERNAM EQUIERDAT EQUI~AENAM
EQUIAEDAT EQUIINBDT
EQUI~ZZ_DESPATCH
( ten million custom Z fields )
EQUI~ZZ_TIMEZONE
ILOAVKBUR ILOASWERK ILOA~KOSTL
INTO CORRESPONDING FIELDS OF TABLE IREPO
FROM ( EQUI INNER JOIN EQUZ ON
EQUIEQUNR = EQUZEQUNR )
INNER JOIN ILOA ON
EQUZILOAN = ILOAILOAN
WHERE EQUI~EQUNR IN P_EQUNR "Fleet Number
AND EQUI~EQART IN P_EQART "Truck Type
AND EQUI~ZZ_PLATE_NO IN P_PLATE "Registration
AND EQUI~ZZ_DESPATCH IN P_DESPG "Despatch Group
AND EQUI~ZZ_HAULER IN P_HAULER"Vendor
AND ILOA~SWERK IN P_SWERK "Plant
AND ILOA~VKBUR IN P_VKBUR."Sales Office
If successful go and get the descriptions
IF SY-SUBRC EQ 0.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
TEXT = 'Reading Descriptions' .
SELECT EQUNR EQKTX FROM EQKT
INTO CORRESPONDING FIELDS OF TABLE IEQKT
FOR ALL ENTRIES IN IREPO
WHERE EQUNR = IREPO-EQUNR
AND SPRAS = 'EN'.
SORT IEQKT BY EQUNR.
ENDIF.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
TEXT = 'Check For Deletion Flags' .
DATA: L_EQUNR LIKE EQUI-EQUNR,
L_OBJNR LIKE JEST-OBJNR.
LOOP AT IREPO.
CONCATENATE 'IE' IREPO-EQUNR INTO L_OBJNR.
Start off by saying that the Truck is OK
IREPO-STATUS = '3'.
Now see if the Truck has been flagged as Inactive e.g. under repair
PERFORM STATUS_CHECK USING L_OBJNR 'I0320'.
IF SY-SUBRC EQ 0.
IREPO-STATUS = '2'. "It's inactive
ENDIF.
Now see if the Truck has been flagged for deletion.
PERFORM STATUS_CHECK USING L_OBJNR 'I0076'.
IF SY-SUBRC EQ 0.
IREPO-STATUS = '1'. "It's deleted
ENDIF.
MODIFY IREPO.
CLEAR IREPO.
ENDLOOP.
If exclude is chosen lose deleted items
IF EXCLUDE = 'X'.
DELETE IREPO WHERE STATUS = '1'.
ENDIF.
Final processing
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
TEXT = 'Prepare Data for Display' .
SORT IREPO BY EQUNR.
LOOP AT IREPO.
Get Description of Truck
READ TABLE IEQKT WITH KEY EQUNR = IREPO-EQUNR BINARY SEARCH.
IF SY-SUBRC EQ 0.
IREPO-EQKTX = IEQKT-EQKTX.
ELSE.
IREPO-EQKTX = 'No Description in Truck Master'.
ENDIF.
Get Name of Owner
READ TABLE VENDLIST WITH KEY LIFNR = IREPO-ZZ_HAULER BINARY SEARCH.
IF SY-SUBRC NE 0.
SELECT SINGLE NAME1 FROM LFA1 INTO IREPO-NAME1
WHERE LIFNR = IREPO-ZZ_HAULER.
VENDLIST-LIFNR = IREPO-ZZ_HAULER.
VENDLIST-NAME1 = IREPO-NAME1.
APPEND VENDLIST.
SORT VENDLIST BY LIFNR.
ELSE.
IREPO-NAME1 = VENDLIST-NAME1.
ENDIF.
MODIFY IREPO.
CLEAR IREPO.
ENDLOOP.
END-OF-SELECTION.
Select Data into Internal Table (End) ****************
Build Field Catalogs (Begin)**************************
Fields with Standard Names
PERFORM RESETVALUES.
PERFORM ADDFIELD USING '1' 'EQUI' 'STATUS'. "Traffic Lights
FIELDCAT_LN-HOTSPOT = 'X'.
FIELDCAT_LN-KEY = 'X'.
PERFORM ADDFIELD USING '2' 'EQUI' 'EQUNR'. "Fleet Number
PERFORM ADDFIELD USING '3' 'EQKT' 'EQKTX'. "Description
PERFORM ADDFIELD USING '4' 'EQUI' 'ZZ_PLATE_NO'.
PERFORM ADDFIELD USING '5' 'EQUI' 'EQART'.
PERFORM ADDFIELD USING '6' 'ILOA' 'SWERK'.
PERFORM ADDFIELD USING '8' 'ILOA' 'KOSTL'.
PERFORM ADDFIELD USING '9' 'EQUI' 'ZZ_MINLOADSIZE'.
PERFORM HIDFIELD USING '10' 'EQUI' 'ERNAM'.
PERFORM HIDFIELD USING '11' 'EQUI' 'AEDAT'.
PERFORM HIDFIELD USING '12' 'EQUI' 'AENAM'.
PERFORM HIDFIELD USING '13' 'EQUI' 'INBDT'.
( ten million custom Z fields )
PERFORM HIDFIELD USING '56' 'EQUI' 'ZZ_TIMEZONE'.
PERFORM HIDFIELD USING '57' 'ILOA' 'VKBUR'.
PERFORM HIDFIELD USING '58' 'EQUI' 'ZZ_HAULER'.
PERFORM HIDFIELD USING '59' 'EQUI' 'ERDAT'.
Fields with Custom Names
PERFORM NEWNAME USING 'Haulier Name'.
FIELDCAT_LN-OUTPUTLEN = '20'.
PERFORM ADDFIELD USING '7' 'LFA1' 'NAME1'. "Haulier Vendor Name
PERFORM NEWNAME USING 'Tare Time'.
PERFORM HIDFIELD USING '54' 'EQUI' 'ZZ_TARE_TIME'.
PERFORM NEWNAME USING 'Trailer 1'.
PERFORM HIDFIELD USING '19' 'EQUI' 'ZZ_TRAILER1'.
PERFORM NEWNAME USING 'Trailer 2'.
PERFORM HIDFIELD USING '20' 'EQUI' 'ZZ_TRAILER2'.
PERFORM NEWNAME USING 'Trailer 3'.
PERFORM HIDFIELD USING '21' 'EQUI' 'ZZ_TRAILER3'.
Sort Criteria
PERFORM BUILD_SORTCAT.
******Build Event Catalog (Begin)****************************
PERFORM BUILD_EVENTCAT.
Magic box for selection criteria & traffic lights for truck status
PERFORM BUILD_LAYOUT.
********Add a header at the top of the report *******
PERFORM SET_REPORT_HEADER USING W_LIST_TOP_OF_PAGE[].
********Start List Viewer
PERFORM START_LIST_VIEWER.
******Start List Viewer (End)********************************
********FORM ROUTINES (Begin)********************************
Start Values for ALV Field Catalouge
FORM RESETVALUES.
FIELDCAT_LN-KEY = SPACE.
FIELDCAT_LN-DO_SUM = SPACE.
FIELDCAT_LN-NO_OUT = SPACE.
FIELDCAT_LN-QFIELDNAME = SPACE.
FIELDCAT_LN-HOTSPOT = SPACE.
FIELDCAT_LN-OUTPUTLEN = '0'.
CLEAR: fieldcat_ln-seltext_l, fieldcat_ln-seltext_m,
fieldcat_ln-seltext_s, fieldcat_ln-reptext_ddic.
ENDFORM.
Change key values for additional fields
FORM ADDFIELD USING POSITION TABLE_VALUE FIELD_VALUE.
FIELDCAT_LN-REF_TABNAME = TABLE_VALUE .
FIELDCAT_LN-FIELDNAME = FIELD_VALUE.
FIELDCAT_LN-COL_POS = POSITION.
APPEND FIELDCAT_LN TO FIELDCAT.
PERFORM RESETVALUES.
ENDFORM.
FORM HIDFIELD USING POSITION TABLE_VALUE FIELD_VALUE.
FIELDCAT_LN-NO_OUT = 'X'.
FIELDCAT_LN-REF_TABNAME = TABLE_VALUE .
FIELDCAT_LN-FIELDNAME = FIELD_VALUE.
FIELDCAT_LN-COL_POS = POSITION.
APPEND FIELDCAT_LN TO FIELDCAT.
PERFORM RESETVALUES.
ENDFORM.
FORM NEWNAME USING NAME.
FIELDCAT_LN-SELTEXT_L = NAME..
FIELDCAT_LN-SELTEXT_M = NAME.
FIELDCAT_LN-SELTEXT_S = NAME.
FIELDCAT_LN-REPTEXT_DDIC = NAME.
FIELDCAT_LN-OUTPUTLEN = '10'.
ENDFORM.
Sort Criteria
FORM BUILD_SORTCAT.
SORTCAT_LN-SPOS = '1'.
SORTCAT_LN-FIELDNAME = 'EQUNR'. "Truck Number
SORTCAT_LN-UP = 'X'.
SORTCAT_LN-DOWN = SPACE.
SORTCAT_LN-SUBTOT = SPACE.
APPEND SORTCAT_LN TO SORTCAT.
ENDFORM.
FORM BUILD_EVENTCAT.
EVENTCAT_LN-NAME = C_TOP_OF_PAGE.
EVENTCAT_LN-FORM = C_TOP_OF_PAGE.
APPEND EVENTCAT_LN TO EVENTCAT.
ENDFORM. " BUILD_EVENTCAT
Add an extra button to get an extra button the user can press to
see what selection criteria they entered
This info will then appear when the report is printed
FORM BUILD_LAYOUT.
LAYOUT-GET_SELINFOS = 'X'.
Now we want a traffic light to say if the Truck is deleted
the variable p_lignam contains the name in IREPO which stores the
value for the traffic light
LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.
LAYOUT-LIGHTS_CONDENSE = 'X'.
ENDFORM.
Invoke a custom status (toolbar) in case we want to add any extra
icons at a later date
FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STAND' EXCLUDING EXTAB.
ENDFORM.
FORM START_LIST_VIEWER.
DATA: PGM LIKE SY-REPID.
PGM = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = PGM
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT
IT_SORT = SORTCAT
I_SAVE = 'A'
IT_EVENTS = EVENTCAT[]
TABLES
T_OUTTAB = IREPO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
*******Process Call Back Events (Begin)**************************
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE IREPO INDEX SELFIELD-TABINDEX.
CHECK SY-SUBRC = 0.
CASE UCOMM.
WHEN '&IC1'.
CASE SELFIELD-SEL_TAB_FIELD.
WHEN 'IREPO-EQUNR'.
Set Parameter ID and call ZTM3
Custom transaction to view Trucks
SET PARAMETER ID 'EQN' FIELD IREPO-EQUNR.
CALL TRANSACTION 'ZTM3' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.
*******Process Call Back Events (End)*****************************
Routine to print out user at the top
FORM SET_REPORT_HEADER USING LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
PERFORM CONVERT_DATE.
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = 'ZT01 : Truck Master Data Report'.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Run On :'.
LS_LINE-INFO = W_DATUM.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
LS_LINE-KEY = 'User Name :'.
LS_LINE-INFO = SY-UNAME.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
ENDFORM. " SET_REPORT_HEADER
FORM CONVERT_DATE.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
DATE_INTERNAL = SY-DATUM
IMPORTING
DATE_EXTERNAL = W_DATUM.
ENDFORM. " CONVERT_DATE
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = W_LIST_TOP_OF_PAGE.
ENDFORM. "TOP_OF_PAGE
FORM STATUS_CHECK USING OBJNR
STATUS.
This uses reverse logic i.e. subrc = 0 means the status being
checked (delete / inactive) is active.
e.g checking for I0076 and subrc = 0 means it's been flagged for
deletion
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
BYPASS_BUFFER = 'X'
OBJNR = OBJNR
STATUS = STATUS
EXCEPTIONS
OBJECT_NOT_FOUND = 1
STATUS_NOT_ACTIVE = 2
OTHERS = 3.
ENDFORM. " STATUS_CHECK
**********FORM ROUTINES (END)*************************************
The other thing to note is that below I include a FORM to call a custom
status (toolbar). I define this in the repositry browser by copying the
STANDARD status from another ALV report, but you do not need to do this
unless you want to add some more buttons to the standard toolbar. I now do
this as a matter of course, as my users tend to want extra buttons e.g.
'REFRESH'.
How to add an extra button:-
Create a new status using the repository browser by copying an existing
one from an ALV program. Call it something like ZSTANDARD. Then change it by
adding a new button to the toolbar - give it an icon and a four digit name
like '&TMP' so the program knows what button the user has pressed.
(ii) Within your program include a FORM called something like SET_PF_STATUS
as in my example program below. Make sure the name of this FORM is included
in the call to the ALV function module, again as in the example below.
(iii) In the USER_COMMAND form, insert code to deal with the user pressing
the new button e.g.
Example of how to deal with users pressing new buttons
*******Process Call Back Events (Begin)**************************
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'.
READ TABLE irepo INDEX selfield-tabindex.
CHECK sy-subrc = 0.
CASE selfield-sel_tab_field.
WHEN 'IREPO-VBELN'.
SET PARAMETER ID 'VL' FIELD irepo-vbeln.
CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN. "Outbound
WHEN '&TMP'.
We are going to refresh the display so tell the ALV this
selfield-refresh = 'X'.
Isn't that clever!
PERFORM refresh. "Subroutine to refresh the screen (for example)
ENDCASE.
ENDFORM.
********Process Call Back Events (End) ****************************
THANKS
MRUTYUN -
Displaying a Push button in the application toolbar for an ALV report
Hello everyone,
Query:
Is it possible to display a custom push button in the application tool bar while displaying an ALV report(1st one)?
On pressing this custom push button will I be able to display another ALV report(2nd one) based on the selection made on the current ALV report(1st one)?Yes u can have pushbutton on application toolbar.
You just have to use the new pf status in your report program.
You should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 >Programming SubObjects> Gui Status.
Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.
Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.
Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality.
Have a look at below code for using the new status.
TYPE-POOLS: slis.
DATA: i_qmel LIKE qmel OCCURS 0.
data v_repid type repid.
SELECT * FROM qmel INTO TABLE i_qmel.
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
i_structure_name = 'QMEL'
TABLES
t_outtab = i_qmel
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.
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'TEST'.
endform.
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
data lv_ucomm type sy-ucomm.
lv_ucomm
= sy-ucomm.
CASE lv_ucomm.
WHEN 'BUTTON'. "Double Click line Item
**Write ur functinality here
endcase.
endform.
Also have a look at below links.
http://www.sap-basis-abap.com/abap/add-button-to-alv-toolbar-with-reuse-alv-list-display.htm
ALV report
Best Regards,
Vibha
*Please mark all the helpful answers -
Should Standard Toolbar FIND work on an ALV within a custom container ?
I have an ALV in a custom container on a screen.
The FIND and FIND NEXT of the ALV toolbar work fine against the grid.
Should the FIND and FIND NEXT of the standard toolbar also work against the ALV if they are "activate" in the GUI status?
If so, what do I call/execute in response to the "FIND" ok-code?
I've tried calling the function ALV_POPUP_TO_SEARCH2 and the popup comes up, but it doesn't do anything.
Please advise at your earliest convenience.
Thanks
djhHi Rich,
Absolutely. Especially as they can paint the picture, and then blame the techies when their fiction is exposed.
Similarly, we had a situation where the Expense Report WD was failing, and the functional person ensured that everyone knew it was a technical problem and therefore my fault (with SAP as the popular co-conspirator).
Sadly the message above the Java stack messages was "No entry in table T706Z for argument ' '". Had the functional check their config and all was well. No one apologised though......
Last week at a different site the same thing happened (this time with TA20C) but the funky took one look at it and reviewed their config to solve - so they're not ALL the same.
Cheers
Gareth -
Add Button with ALV Standard Toolbar.
Hi,
Can any one tell me how to add user-defined button with ALV
Standard toolbar? When I add Pf-status for alv output , standard alv toolbar is not displayed.
Plz do needful.On the toolbar event of your alv grid, all the button as shown in the code below.
FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set .
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 'EXCH' TO ls_toolbar-function. "#EC NOTEXT
MOVE 2 TO ls_toolbar-butn_type.
MOVE icon_calculation TO ls_toolbar-icon.
MOVE 'Payment in Other Currencies'(202) TO ls_toolbar-quickinfo.
MOVE ' ' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO i_object->mt_toolbar.
ENDFORM
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*To add new functional buttons to the ALV toolbar
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive ,
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION .
*Handle Toolbar
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object e_interactive .
ENDMETHOD .
ENDCLASS.
DATA gr_event_handler TYPE REF TO lcl_event_handler .
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*--Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid .
Hope this helps.
Thanks,
Balaji -
How to code in the standard refresh button in ALV toolbar
Hi Experts,
My ALV includes some standard toolbar buttons like refresh, select all, sort, and etc. How can I put logic into the refresh button such that when user click on the refresh button, I want to run some logic on my own?
THanks in advance.Hi again,
1. Further to my previous reply
2. This code will make it clear.
3. just copy paste
a. Before that, copy the SALV Standard Toolbar to ABCD as suggested before.
<b>Important & Relevant code has been marked in bold.</b>
4.
report abc.
type-pools : slis.
Data
data : itab like t001 occurs 0 with header line.
DATA : fc type SLIS_T_FIELDCAT_ALV.
Logic
select * from t001 into table itab.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = fc
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
<b> I_CALLBACK_PF_STATUS_SET = 'MYSTATUS '</b>
<b> I_CALLBACK_USER_COMMAND = 'MYFORM'</b> IT_FIELDCAT = FC
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
<b>
IMPORTANT
This sets the PF Status on ALV Screen
And not Selection screen
FORM MYSTATUS USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ABCD'.
ENDFORM. "MYSTATUS
IMPORTANT
When Fcode is pressed on ALV Toolbar
FORM MYFORM USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
IF R_UCOMM = 'ZREFRESH'.
*----CODE
ENDIF.
ENDFORM. "MYFORM</b>
regards,
amit m. -
Hide/Remove Subtotal Icon in ALV Grid report output.
Hi,
Is ther a way to remove or hide the Subtotal icon in the ALV Grid report output?
Thanks & Regards,
Praveen.Hi,
You can add names of the buttons(which you want to hide) to internal table and pass this internal table for tool bar excluding parameter while calling ALV.
Here as shown in below code, 'Sorting, Ascending,Descending' buttons are removed from the tool bar list.
data : lt_exclude TYPE ui_functions.
ls_exclude = cl_gui_alv_grid=>MC_FC_SORT.
APPEND ls_exclude TO lt_exclude .
ls_exclude = cl_gui_alv_grid=>MC_FC_SORT_ASC.
APPEND ls_exclude TO lt_exclude .
ls_exclude = cl_gui_alv_grid=>MC_FC_SORT_DSC.
APPEND ls_exclude TO lt_exclude .
CALL METHOD alvgd->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = lt_exclude
Regards,
Maharshi Vyas -
ALV output for Purchase reports
Hi Friends,
How can I have ALV output for my Purchase reports like ME2L, ME2N, ME2M. My scope of Lists do not have ALV output as yet. How do we configure it..?
Thanks in advance.
Sarveshwhich ECC version are you working on? I think versions below 4.7 didnt have ALV (im not sure though)
Try this path :
SPRO->Materials mgmt->purchasing->Reportng->Maintain Purchasing lists->Scope of lists->Define scope of list.
check if ALV is maintained here. if not , create ZALV by Copying from ALLES or make your own new one ZALV , and inside ZALV , make sure to Tick the "Use ALV grid Control" in the last tab "settings for ALV grid control" -
Custom Button in ALV Grid standard toolbar
Hello Experts,
I am working on the program in which i have to add custom button to standard toolbar in ALV. I have created the button using the method as below
data: lr_functions type ref to cl_salv_functions_list.
lr_functions = gr_table->get_functions( ).
lr_functions->set_default( abap_true ).
data: l_text type string,
l_icon type string.
* l_text = text-b01.
l_icon = icon_complete.
try.
lr_functions->add_function(
name = 'Update Equipment Cost'
icon = l_icon
text = l_text
tooltip = 'Update Equipment Cost'
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_existing cx_salv_wrong_call.
endtry.
I don't understand how to add functionality to this button. I want to design the functionality as when user press button then corresponding values on the screen will be automatically get updated in the table.
Thanks,
AvadhutHi Avadhut,
When you want to add a custom button on ALV - better copy the GUI Status of the standard ALV to your program. So all the function codes are copied , now you can go to the GUI_STATUS which is copied and you can mention your own function code or you can let the standard function codes as it is. You can copy the GUI of standard ALV from SE80 transaction. Let me know if you need any assistance in doing it.
Now, if you want to write the code for any of the button on ALV - then you need to handle it is the class.
I used CL_SALV_TABLE - if you are using same then the below code gives you an idea of it.
1. Create a local class in your program
* CLASS lcl_alv_events DEFINITION
CLASS lcl_alv_events DEFINITION FINAL.
PUBLIC SECTION.
METHODS: on_user_command FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function.
ENDCLASS. "lcl_alv_events DEFINITION
DATA: gv_event_handler TYPE REF TO lcl_alv_events.
CREATE OBJECT gv_event_handler.
* Header object
CREATE OBJECT gr_header.
2. Class Implementation
CLASS lcl_alv_events IMPLEMENTATION.
METHOD on_user_command.
CASE e_salv_function.
**When PROCESS Button is selected
WHEN '&PROC'. ***> In my program I added Process button and fcode for it - &PROC
***********Write your code here ******************
ENDCASE.
ENDMETHOD.
ENDCLASS. "lcl_alv_events IMPLEMENTATION
3. Calling events
data: gr_events TYPE REF TO cl_salv_events_table,
gr_alv TYPE REF TO cl_salv_table.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = p_in_tab[]. ***This is my internal table data.
gr_events = gr_alv->get_event( ).
SET HANDLER gv_event_handler->on_user_command FOR gr_events.
CATCH cx_salv_msg INTO lv_msg. "#EC NO_HANDLER
CATCH cx_salv_not_found INTO lv_excep. "#EC NO_HANDLER
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
Regards,
Rafi -
How to attch ALV output to mailthrough report ?
HI,
Experts,
I have displayed ALV output but i want to attach this ALV output to compose mail in attachments you people can suggest me how to achieve me this scenario.
Thanks in advance,
Shabeer Ahmed.Shabheer,
As far as I know, there is no other way. SCOT transaction will have the setting through which you will connect to the external network.
If you get to know about any other way. Please do let me know as well.
Thanks,
Babu Kilari -
I appreciate if anyone can let me know how to get the ALV output to an EXCEL file.I have done it thru list->export. Is there any other way?
Hi Deepti,
1) Once you have alv report displayed in the screen.
2) Click button 'View' ( next to print button) on application toolbar
3) Select Excel in Place
4) This will download the same format as of Report
I hope your ALV have all the Standard functions in Toolbar. If not copy the status from and get the function as mentioned above.
Program - SAPLSALV
Status - STANDARD
OR For downloading into Excel sheet use EXPORT->LOCAL FILE->Spread sheet
If you want to do programatically then:
Refer the link:
http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
Please use the following FM
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename =
I_APPL_KEEP = ' '
tables
i_tab_sap_data =
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 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.
Another FM
MS_EXCEL_OLE_STANDARD_DAT
A simple option:
a) form download_file .
call function 'WS_EXCEL'
importing
filename = excel_name
tables
data = itab.
Reward points if this Helps.
Manish -
Hi all ,
Iam Generating ALV Grid using OOPs method, In the output list Iam editing some of the entries , now i need to store the edited output in a custom table.
Can anyubody tell me how to capture these changes into an internal table.
Early replies would be rewarded points.
Thanks In advance,
NehaHi Neha,
check this code
*& Report ZLAXMI_REPORT6 *
REPORT ZLAXMI_REPORT6 NO STANDARD PAGE HEADING
MESSAGE-ID ZZ
LINE-SIZE 132
LINE-COUNT 65 .
TABLES: MARA.
TYPE-POOLS: SLIS.
TYPES: BEGIN OF T_MARA,
MATNR TYPE MARA-MATNR, "Material Number
ERSDA TYPE MARA-ERSDA, "Creation date
BRGEW TYPE MARA-BRGEW, "Gross weight
NTGEW TYPE MARA-NTGEW, "Net weight
MTART TYPE MARA-MTART, "Material type
MBRSH TYPE MARA-MBRSH, "Industry Sector
REC_SEL TYPE C , "checkbox
END OF T_MARA.
V A R I A B L E S
DATA: V_REPID LIKE SY-REPID,
V_FLAG(1) TYPE C.
CONSTANTS :
C_X(1) TYPE C VALUE 'X',
C_PF_STATUS TYPE SLIS_FORMNAME VALUE 'F_SET_PF_STATUS',
C_FC_DELETE(6) TYPE C VALUE 'DELETE',
C_FC_MODIFY(6) TYPE C VALUE 'MODIFY',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'F_USER_COMMAND',
C_USER_COMMAND_MODIFY TYPE SLIS_FORMNAME
VALUE 'F_USER_COMMAND_MODIFY',
C_ICON_DELETE TYPE ICON-NAME VALUE 'ICON_DELETE', " Icon,Delete'
C_ICON_CANCEL TYPE ICON-NAME VALUE 'ICON_CANCEL', " Icon,Cancel'
C_FC_SAVE(4) TYPE C VALUE 'SAVE'.
*internal table declarations.
DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE,
IT_MODIFY TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE,
IT_TEMP TYPE STANDARD TABLE OF MARA WITH HEADER LINE,
*-ALV Internal Tables.
*--Field Catalog
IT_FIELDCAT TYPE STANDARD TABLE OF
SLIS_FIELDCAT_ALV WITH HEADER LINE,
*--Layout
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
*--Sort
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV ,
**-Structure for excluding function codes
WA_EXTAB TYPE SLIS_EXTAB,
**-To hold function codes to be excluded in ALV toolbar
IT_EXTAB TYPE SLIS_T_EXTAB.
*selection screen.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
S_ERSDA FOR MARA-ERSDA.
SELECTION-SCREEN: END OF BLOCK B1.
*--Radio buttons to select either Display/Delete/Modify
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME
TITLE TEXT-002.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-003.
PARAMETERS: P_DISP RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-005.
PARAMETERS: P_UPD RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-004.
PARAMETERS: P_DEL RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN END OF BLOCK B2 .
AT SELECTION-SCREEN.
PERFORM VALIDATE_SCREEN.
*start of selection
START-OF-SELECTION.
*clear the internal tables to be used.
CLEAR: IT_MARA,IT_MARA[],
V_FLAG.
*get the data
PERFORM GET_DATA.
*end of selection
END-OF-SELECTION.
IF IT_MARA[] IS INITIAL.
MESSAGE I000 WITH
'No Records found for the given Selection Criteria'(012).
ELSE.
*do alv process
V_REPID = SY-REPID.
*--Sort the Output Fields
PERFORM SORT_FIELDS.
*--Build Field catalog for the Output fields
PERFORM BUILD_FIELDCAT.
*--Set the Layout for ALV
PERFORM SET_LAYOUT.
IF P_DISP = C_X.
*--Exclude any Buttons on the Appn tool bar
perform change_default_pf_status.
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ELSEIF P_UPD = C_X.
*--Exclude DELETE Button on the appn tool bar
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ELSEIF P_DEL = C_X.
*--Exclude MODIFY button on appn tool bar
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDIF.
*--Exclude SAVE button for all options
MOVE 'SAVE' TO WA_EXTAB-FCODE. " SAVE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
*--Display ALV output
PERFORM LIST_DISPLAY TABLES IT_MARA
USING C_USER_COMMAND.
ENDIF.
*& Form get_data
text
--> p1 text
<-- p2 text
FORM GET_DATA .
SELECT MATNR
ERSDA
BRGEW
NTGEW
MTART
MBRSH
FROM MARA
INTO TABLE IT_MARA
WHERE MATNR IN S_MATNR
AND ERSDA IN S_ERSDA.
IF SY-SUBRC <> 0.
*no records selected leave processing
STOP.
ENDIF.
SORT IT_MARA.
ENDFORM. " get_data
*& Form sort_fields
text
--> p1 text
<-- p2 text
FORM SORT_FIELDS .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'MATNR'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'ERSDA'.
WA_SORT-SPOS = '2'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
ENDFORM. " sort_fields
*& Form build_fieldcat
text
--> p1 text
<-- p2 text
FORM BUILD_FIELDCAT .
IT_FIELDCAT-COL_POS = '1'.
IT_FIELDCAT-FIELDNAME = 'MATNR'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '15'.
IT_FIELDCAT-SELTEXT_L = 'Material number'(022).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '2'.
IT_FIELDCAT-FIELDNAME = 'ERSDA'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'Created on'(023).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '3'.
IT_FIELDCAT-FIELDNAME = 'BRGEW'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'GROSS WEIGHT'(024).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '4'.
IT_FIELDCAT-FIELDNAME = 'NTGEW'.
IT_FIELDCAT-OUTPUTLEN = '15'.
IT_FIELDCAT-SELTEXT_L = 'NET WEIGHT'(025).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '5'.
IT_FIELDCAT-FIELDNAME = 'MTART'.
IT_FIELDCAT-OUTPUTLEN = '3'.
IT_FIELDCAT-SELTEXT_L = 'Material type'(026).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '6'.
IT_FIELDCAT-FIELDNAME = 'MBRSH'.
IT_FIELDCAT-OUTPUTLEN = '25'.
IT_FIELDCAT-SELTEXT_L = 'Industry sector'(027).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-FIELDNAME = 'REC_SEL'.
IT_FIELDCAT-NO_OUT = C_X.
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
ENDFORM. " build_fieldcat
*& Form list_display
text
-->P_IT_MARA text
-->P_C_USER_COMMAND text
FORM LIST_DISPLAY TABLES P_IT_MARA
USING P_USER_COMMAND TYPE SLIS_FORMNAME.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = C_PF_STATUS
I_CALLBACK_USER_COMMAND = P_USER_COMMAND
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EXCLUDING = IT_EXTAB[]
IT_SORT = IT_SORT[]
TABLES
T_OUTTAB = P_IT_MARA
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
*& Form F_SET_PF_STATUS
Set PF_STATUS STANDARD modifying the standard toolbar
by excluding some buttons
-->P_IT_EXTAB -- TABLE OF EXCLUDING FUNCTIONS
FORM F_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
CLEAR : WA_EXTAB,
IT_EXTAB.
*--Set the Modified PF status for the ALV.
SET PF-STATUS 'ALV_STATUS_01' EXCLUDING RT_EXTAB.
ENDFORM. " SET_PF_STATUS
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
RS_SELFIELD-REFRESH = C_X.
IF R_UCOMM = C_FC_DELETE.
*--User Selected DELETE button.
PERFORM DELETE_SELECTED_RECORDS.
ELSEIF R_UCOMM = C_FC_MODIFY.
*--If user selects MODIFY button.
PERFORM CHANGE_RECORDS.
ENDIF.
ENDFORM. "F_USER_COMMAND
*& Form POP_UP_CONFIRMATION
text
<--P_ANSWER text
FORM POP_UP_CONFIRMATION
CHANGING P_ANSWER TYPE C.
DATA:
L_TITLE(14) TYPE C, " Title of pop-up
L_TXT_QUESTION(52) TYPE C, " Text displayed in pop-up
L_DISP_CANCEL TYPE C, " Display 'Cancel' button?
L_BTN1 TYPE ICON-NAME, " Icon on button 1
L_BTN2 TYPE ICON-NAME. " Icon on button 2
L_TITLE = 'Delete'(017). " delete
L_TXT_QUESTION = 'Are you sure to delete?'(018).
L_BTN1 = C_ICON_DELETE.
L_BTN2 = C_ICON_CANCEL.
**-Display pop-up asking user for confirmation
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = L_TITLE
TEXT_QUESTION = L_TXT_QUESTION
TEXT_BUTTON_1 = 'Yes'
ICON_BUTTON_1 = L_BTN1
TEXT_BUTTON_2 = 'No'
ICON_BUTTON_2 = L_BTN2
DEFAULT_BUTTON = '2'
DISPLAY_CANCEL_BUTTON = 'X'
IMPORTING
ANSWER = P_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Error executing function module:'(019)
'POPUP_TO_CONFIRM'.
ENDIF.
ENDFORM. "pop_up_confirmation
*& Form set_layout
text
--> p1 text
<-- p2 text
FORM SET_LAYOUT .
IF P_DEL = C_X OR P_UPD = C_X.
*--Allow Input only if user choose 'UPDATE'/ 'DELETE' radio buttons
WA_LAYOUT-BOX_FIELDNAME = 'REC_SEL'.
WA_LAYOUT-BOX_TABNAME = 'IT_MARA'.
ENDIF.
*--Display Header based on the user selection
IF P_DISP = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Display '(036).
ELSEIF P_DEL = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Delete '(037).
ELSEIF P_UPD = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Change '(038).
ENDIF.
ENDFORM. " set_layout
*& Form change_default_pf_status
text
--> p1 text
<-- p2 text
FORM CHANGE_DEFAULT_PF_STATUS .
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDFORM. " change_default_pf_status
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND_MODIFY USING R_UCOMM LIKE SY-UCOMM "#EC *
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_ANSWER TYPE C. "#EC *
IF R_UCOMM = C_FC_SAVE.
*user selected save button
READ TABLE IT_MODIFY WITH KEY REC_SEL = 'X'.
*check if user selected atleast one line.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Modify'(016).
EXIT.
ENDIF.
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
*--Check the entered values are valid or not.
IF NOT ( it_modify-status = 'A' OR
it_modify-status = 'C' OR
it_modify-status = 'E' ).
*--User Entered invalid value for STATUS field,so Display Error Msg
CLEAR R_UCOMM.
MESSAGE e000 WITH 'Invalid value '''(031)
'' for Status in the Record # '(032)
sy-tabix.
ENDIF.
ENDLOOP.
CLEAR: IT_TEMP,
IT_TEMP[].
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
MOVE-CORRESPONDING IT_MODIFY TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
*--start new code
DATA : IT_TEMP2 LIKE STANDARD TABLE OF MARA WITH HEADER LINE.
SELECT * FROM MARA
INTO TABLE IT_TEMP2
FOR ALL ENTRIES IN IT_TEMP
WHERE MATNR = IT_TEMP-MATNR.
IF SY-SUBRC = 0.
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
READ TABLE IT_TEMP2 WITH KEY MATNR = IT_MODIFY-MATNR.
IF SY-SUBRC = 0.
IT_TEMP2-NTGEW = IT_MODIFY-NTGEW.
IT_TEMP2-BRGEW = IT_MODIFY-BRGEW.
MODIFY IT_TEMP2 INDEX SY-TABIX.
ENDIF.
ENDLOOP.
ENDIF.
*modify mara table with the changed values
MODIFY MARA FROM TABLE IT_TEMP2 .
*--end new code
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT.
*--Display message with Success in Updating database
MESSAGE I000 WITH SY-DBCNT
' Record(s) has been Updated'(020).
CLEAR :
IT_MARA,
IT_MARA[].
*get-data again from database.
PERFORM GET_DATA.
RS_SELFIELD-REFRESH = C_X.
ELSE.
*--Error occurred
MESSAGE I000 WITH 'Error occured in Modifying the database'(021).
ENDIF.
ENDIF.
ENDFORM. "f_user_command_modify
*& Form validate_screen
text
--> p1 text
<-- p2 text
FORM VALIDATE_SCREEN .
DATA : LV_MATNR LIKE MARA-MATNR.
*--validate product
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR
INTO MARA-MATNR
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
IF SY-SUBRC <> 0.
*--Error
MESSAGE E000 WITH 'Invalid Material'(034).
ENDIF.
ENDIF.
ENDFORM. " validate_screen
*& Form delete_records
text
--> p1 text
<-- p2 text
FORM DELETE_RECORDS .
LOOP AT IT_MARA.
MOVE-CORRESPONDING IT_MARA TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
DELETE MARA FROM TABLE IT_TEMP.
IF SY-SUBRC = 0.
*--Successfully selected records Deleted.
COMMIT WORK AND WAIT.
*--Display Success Message to the user
MESSAGE I000 WITH SY-DBCNT
' Record(s) deleted Successfully'(010).
ELSE.
*--Error occured in deletion
MESSAGE I000 WITH 'Error occured in Deleting the Record(s)'(011).
ENDIF.
CLEAR: IT_MARA,
IT_MARA[],
IT_TEMP,
IT_TEMP[].
V_FLAG = C_X.
STOP.
ENDFORM. " delete_records
*& Form delete_selected_records
text
--> p1 text
<-- p2 text
FORM DELETE_SELECTED_RECORDS .
DATA : L_ANSWER(1) TYPE C.
READ TABLE IT_MARA WITH KEY REC_SEL = C_X.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Delete'(013).
EXIT.
ELSE.
*--Ask for delete confirmation
PERFORM POP_UP_CONFIRMATION
CHANGING L_ANSWER.
IF L_ANSWER = '1'. " 'Yes'
CLEAR: IT_TEMP,
IT_TEMP[].
LOOP AT IT_MARA WHERE REC_SEL = 'X'.
MOVE-CORRESPONDING IT_MARA TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
DELETE MARA FROM TABLE IT_TEMP.
IF SY-SUBRC = 0.
*--Successfully selected records Deleted.
COMMIT WORK AND WAIT.
*--Display completed work information to the user
MESSAGE I000 WITH SY-DBCNT
' Record(s) deleted Successfully'(014).
*--Clear the Internal tables
CLEAR: IT_MARA,
IT_MARA[].
*--Reselects entries from Database again & display in ALV
PERFORM GET_DATA.
ELSE.
*--Error occured
MESSAGE I000 WITH
'Error occured in Deleting the Record(s)'(015).
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " delete_selected_records
*& Form change_records
text
--> p1 text
<-- p2 text
FORM CHANGE_RECORDS .
READ TABLE IT_MARA WITH KEY REC_SEL = 'X'.
*--check user selected at least 1 record to MODIFY or not
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Modify'(016).
EXIT.
ELSE.
CLEAR : IT_MODIFY,
IT_MODIFY[].
LOOP AT IT_MARA WHERE REC_SEL = 'X'.
IT_MODIFY = IT_MARA.
APPEND IT_MODIFY.
CLEAR IT_MODIFY.
ENDLOOP.
*--Change PF status for this new ALV list.
PERFORM CHANGE_PF_STATUS_AGAIN.
*--Change Field Catalog to make INPUT enabled.
READ TABLE IT_FIELDCAT WITH KEY FIELDNAME = 'NTGEW'.
IT_FIELDCAT-INPUT = C_X.
MODIFY IT_FIELDCAT INDEX SY-TABIX.
*--Call ALV LIST DISPLAY with this new values.
PERFORM LIST_DISPLAY TABLES IT_MODIFY
USING C_USER_COMMAND_MODIFY.
ENDIF.
ENDFORM. " change_records
*& Form change_pf_status_again
text
--> p1 text
<-- p2 text
FORM CHANGE_PF_STATUS_AGAIN .
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDFORM. " change_pf_status_again
Regards,
Laxmi. -
ALV Tree Report without using ABAP Objects
Hi all,
I want to know the name of a function module to create ALV Tree in SE38 as a report. I am required to create this ALV Tree Report without using ABAP OBJECTS. Can u pls help me as early as possible.Hi
see this link
http://www.sapdev.co.uk/reporting/alv/alvtree.htm
*& Report ZBCALV_TREE
REPORT ZBCALV_TREE.
class cl_gui_column_tree definition load.
class cl_gui_cfw definition load.
data tree1 type ref to cl_gui_alv_tree.
data mr_toolbar type ref to cl_gui_toolbar.
include <icon>.
include bcalv_toolbar_event_receiver.
include bcalv_tree_event_receiver.
data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
data: gt_VBAK type VBAK occurs 0, "Output-Table
gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
ok_code like sy-ucomm. "OK-Code
start-of-selection.
end-of-selection.
call screen 100.
*& Module STATUS_0100 OUTPUT
text
module STATUS_0100 output.
SET PF-STATUS 'MAIN'.
if tree1 is initial.
perform Zinit_tree.
endif.
call method cl_gui_cfw=>flush.
endmodule. " STATUS_0100 OUTPUT
*& Form Zinit_tree
text
--> p1 text
<-- p2 text
form Zinit_tree .
perform Zbuild_fieldcatalog.
create container for alv-tree
data: l_tree_container_name(30) type c,
l_custom_container type ref to cl_gui_custom_container.
l_tree_container_name = 'TREE1'.
if sy-batch is initial.
create object l_custom_container
exporting
container_name = l_tree_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
endif.
create tree control
create object tree1
exporting
parent = l_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = ''
no_toolbar = ''
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
create Hierarchy-header
data l_hierarchy_header type treev_hhdr.
perform zbuild_hierarchy_header changing l_hierarchy_header.
create info-table for html-header
data: lt_list_commentary type slis_t_listheader,
l_logo type sdydo_value.
perform Zbuild_comment using
lt_list_commentary
l_logo.
repid for saving variants
data: ls_variant type disvariant.
ls_variant-report = sy-repid.
create emty tree-control
call method tree1->set_table_for_first_display
exporting
is_hierarchy_header = l_hierarchy_header
it_list_commentary = lt_list_commentary
i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
changing
it_outtab = gt_VBAK "table must be emty !!
it_fieldcatalog = gt_fieldcatalog.
create hierarchy
perform Zcreate_hierarchy.
add own functioncodes to the toolbar
perform zchange_toolbar.
register events
perform zregister_events.
endform. " Zinit_tree
*& Form Zbuild_fieldcatalog
text
--> p1 text
<-- p2 text
form Zbuild_fieldcatalog .
get fieldcatalog
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'VBAK'
changing
ct_fieldcat = gt_fieldcatalog.
sort gt_fieldcatalog by scrtext_l.
change fieldcatalog
data: ls_fieldcatalog type lvc_s_fcat.
loop at gt_fieldcatalog into ls_fieldcatalog.
case ls_fieldcatalog-fieldname.
when 'AUART' .
ls_fieldcatalog-no_out = 'X'.
ls_fieldcatalog-key = ''.
endcase.
modify gt_fieldcatalog from ls_fieldcatalog.
endloop.
endform. " Zbuild_fieldcatalog
*& Form zbuild_hierarchy_header
text
<--P_L_HIERARCHY_HEADER text
form zbuild_hierarchy_header changing
p_hierarchy_header type treev_hhdr.
p_hierarchy_header-heading = 'Hierarchy Header'. "#EC NOTEXT
p_hierarchy_header-tooltip =
'This is the Hierarchy Header !'. "#EC NOTEXT
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
endform. " zbuild_hierarchy_header
*& Form Zbuild_comment
text
-->P_LT_LIST_COMMENTARY text
-->P_L_LOGO text
form Zbuild_comment using
pt_list_commentary type slis_t_listheader
p_logo type sdydo_value.
data: ls_line type slis_listheader.
LIST HEADING LINE: TYPE H
clear ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = 'ALV-tree-demo: flight-overview'. "#EC NOTEXT
append ls_line to pt_list_commentary.
STATUS LINE: TYPE S
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = 'valid until'. "#EC NOTEXT
ls_line-info = 'January 29 1999'. "#EC NOTEXT
append ls_line to pt_list_commentary.
ls_line-key = 'time'.
ls_line-info = '2.00 pm'. "#EC NOTEXT
append ls_line to pt_list_commentary.
ACTION LINE: TYPE A
clear ls_line.
ls_line-typ = 'A'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = 'actual data'. "#EC NOTEXT
append ls_line to pt_list_commentary.
p_logo = 'ENJOYSAP_LOGO'.
endform. " Zbuild_comment
*& Form Zcreate_hierarchy
text
--> p1 text
<-- p2 text
form Zcreate_hierarchy .
data: ls_vbak type vbak,
lt_vbak type vbak occurs 0.
get data
select * from vbak into table lt_vbak
up to 200 rows . "#EC CI_NOWHERE
sort lt_vbak by AUART.
add data to tree
data: l_AUART_key type lvc_nkey.
loop at lt_vbak into ls_vbak.
on change of ls_vbak-AUART.
perform Zadd_AUART_line using ls_vbak
changing l_AUART_key.
endon.
endloop.
calculate totals
call method tree1->update_calculations.
this method must be called to send the data to the frontend
call method tree1->frontend_update.
endform. " Zcreate_hierarchy
*& Form Zadd_AUART_line
text
-->P_LS_vbak text
-->P_0379 text
<--P_L_AUART_KEY text
form Zadd_AUART_line using p_ls_vbak type vbak
p_relat_key type lvc_nkey
changing p_node_key type lvc_nkey.
data: l_node_text type lvc_value,
ls_vbak type vbak.
set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3P@'.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
append ls_item_layout to lt_item_layout.
add node
l_node_text = p_ls_vbak-AUART.
data: ls_node type lvc_s_layn.
ls_node-n_image = space.
ls_node-exp_image = space.
call method tree1->add_node
exporting
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_vbak
is_node_layout = ls_node
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key .
endform. " Zadd_AUART_line
*& Form zchange_toolbar
text
--> p1 text
<-- p2 text
form zchange_toolbar .
get toolbar control
call method tree1->get_toolbar_object
importing
er_toolbar = mr_toolbar.
check not mr_toolbar is initial.
add seperator to toolbar
call method mr_toolbar->add_button
exporting
fcode = ''
icon = ''
butn_type = cntb_btype_sep
text = ''
quickinfo = 'This is a Seperator'. "#EC NOTEXT
add Standard Button to toolbar (for Delete Subtree)
call method mr_toolbar->add_button
exporting
fcode = 'DELETE'
icon = '@18@'
butn_type = cntb_btype_button
text = ''
quickinfo = 'Delete subtree'. "#EC NOTEXT
add Dropdown Button to toolbar (for Insert Line)
call method mr_toolbar->add_button
exporting
fcode = 'INSERT_LC'
icon = '@17@'
butn_type = cntb_btype_dropdown
text = ''
quickinfo = 'Insert Line'. "#EC NOTEXT
set event-handler for toolbar-control
create object toolbar_event_receiver.
set handler toolbar_event_receiver->on_function_selected
for mr_toolbar.
set handler toolbar_event_receiver->on_toolbar_dropdown
for mr_toolbar.
endform. " zchange_toolbar
*& Form zregister_events
text
--> p1 text
<-- p2 text
form zregister_events .
define the events which will be passed to the backend
data: lt_events type cntl_simple_events,
l_event type cntl_simple_event.
define the events which will be passed to the backend
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_click.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
append l_event to lt_events.
call method tree1->set_registered_events
exporting
events = lt_events
exceptions
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
set Handler
data: l_event_receiver type ref to lcl_tree_event_receiver.
create object l_event_receiver.
set handler l_event_receiver->handle_node_ctmenu_request
for tree1.
set handler l_event_receiver->handle_node_ctmenu_selected
for tree1.
set handler l_event_receiver->handle_item_ctmenu_request
for tree1.
set handler l_event_receiver->handle_item_ctmenu_selected
for tree1.
endform. " zregister_events
*& Module USER_COMMAND_0100 INPUT
text
module USER_COMMAND_0100 input.
ok_code = sy-ucomm.
clear sy-ucomm.
case ok_code.
when 'EXIT' or 'BACK' or 'CANC'.
perform Zexit_program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
clear ok_code.
call method cl_gui_cfw=>flush.
endmodule. " USER_COMMAND_0100 INPUT
*& Form Zexit_program
text
--> p1 text
<-- p2 text
form Zexit_program .
call method tree1->free.
leave program.
endform. " Zexit_program
<b>Reward if usefull</b> -
Toolbar buttons in ALV column tree
Dear Experts,
Currently a report is being displayed using 2 custom container and class CL_GUI_ALV_COLUMN_TREE in a single screen Screen 100.
Funtions like Select all, Deselect All, Expand All, Colapse all are in the GUI status of this Screen 100.
<b>Q1</b>. Is it possible to have buttons on the container itself (instead of having it in the GUI status of Scr. 100) and have the above funtions work for ALV column tree .
<b>Q2.</b> There exists a check box in each row of the node in both the containers which is meant for comparing data between two containers.
e.g the user Checks one row of the first container (ALV tree output) and another in 2nd container and press Compare button which is present in Scr 100 GUI status.
When the ckeck box is selected the rows are being selected, this is done in CheckBoX Change event of CL_GUI_ALV_COLUMN_TREE. Now when the Deselect ALL button is clicked rows are getting deselected but check marks are not getting cleared from the check box.
How can the check box be cleared when we press Deselect All button which is in GUI Status of Scr 100.?
Thanks n RegardsHello Mahesh
Assuming that you are dealing with class
CL_GUI_ALV_TREE (because I cannot find class CL_GUI_ALV_COLUMN_TREE) sample report BCALV_TREE_04 shows how to add a button to the toolbar.
The crucial points can be found in routine CHANGE_TOOLBAR:
form change_toolbar.
* §1.Get toolbar instance of your ALV Tree.
* When you instantiate an instance of CL_GUI_ALV_TREE the constructor
* of the base class (CL_ALV_TREE_BASE) creates a toolbar.
* Fetch its reference with the following method if you want to
* modify it:
call method g_alv_tree->get_toolbar_object
importing
er_toolbar = g_toolbar.
check not g_toolbar is initial. "could happen if you do not use the
"standard toolbar
* §2.Modify toolbar with methods of CL_GUI_TOOLBAR:
* add seperator to toolbar
call method g_toolbar->add_button
exporting
fcode = ''
icon = ''
butn_type = cntb_btype_sep.
* add Standard Button to toolbar (for Delete Subtree)
call method g_toolbar->add_button
exporting
fcode = 'DELETE'
icon = '@11@'
butn_type = cntb_btype_button
text = ''
quickinfo = text-901. "Delete subtree
endform.
Regards
Uwe
Maybe you are looking for
-
Windows 8.1 update problem
I tryed to restore my computer (HP Spectre XT 15-4010nr) to certain date and I got a blank screen, I didn't know what to do so I used the recovery media, know I can't install windows 8.1 in the machine, I did all the updates from windows an the HP w
-
experts, Can i know any FM /BAPI to create Move in ,i have Installation & Contract Account available with me. Tried using ISU_S_MOVE_IN_CREATE & BAPI_ISUMOVEIN_CREATEFROMDATA , but dont know what parameters to be passed. Please help me out in this. T
-
How do I crop edges out of Flash movie
I created a header using flash that involves a piece of content hanging off the stage. I thought when you did that, the part that is off the stage does not show. However, when published to the web, it does show and shifts adjacent content. To see wha
-
Studio 3.1 & Portal 9.2 - JSF portlet problem
Hi, first time here. Let say I have create a simple jsf navigation application using Studio 3.1 like this: // inside faces-config.xml <navigation-rule> <from-view-id>/pages/inputname.jsp</from-view-id> <navigation-case> <from-outcome>greeting</from-o
-
Error when managing archive mailboxes through ECP
Hi I deploying Exchange 2013 CU2 (fully patched) next to our old 2007. I have 3 Mailbox-server 2 CAS-servers and 1 Archive-server Everything is working ok until I started giving migrated users an archive mailbox. It Archive mailbox works OK for the u