ALV GRID and AUTHORITY-CHECK
Hi all !!!
I'm using the ALV Grid control with checkboxes and I want to control if the actual user have the appropriate authorization to check/uncheck them.
In the AUTHORITY-CHECK call, I want to make the authorization test on the "DEPARTMENT" of the user (from Table USER_ADDR or SU01).
For example :
DEPARTMENT AA1 --> check/uncheck OK
DEPARTMENT AA2 --> check/uncheck NOT OK
DEPARTMENT AA3 --> check/uncheck OK
... etc.
How can I do ? Create an new authorization object/field ?
PS : it's the first time I'm using AUTHORITY-CHECK..
Much of the data in an R/3 system has to be protected so that unauthorized users cannot access it. Therefore the appropriate authorization is required before a user can carry out certain actions in the system. When you log on to the R/3 system, the system checks in the user master record to see which transactions you are authorized to use. An authorization check is implemented for every sensitive transaction.
If you wish to protect a transaction that you have programmed yourself, then you must implement an authorization check.
This means you have to allocate an authorization object in the definition of the transaction.
For example:
program an AUTHORITY-CHECK.
AUTHORITY-CHECK OBJECT <authorization object>
ID <authority field 1> FIELD <field value 1>.
ID <authority field 2> FIELD <field value 2>.
ID <authority-field n> FIELD <field value n>.
The OBJECT parameter specifies the authorization object.
The ID parameter specifies an authorization field (in the authorization object).
The FIELD parameter specifies a value for the authorization field.
The authorization object and its fields have to be suitable for the transaction. In most cases you will be able to use the existing authorization objects to protect your data. But new developments may require that you define new authorization objects and fields.
Example ;
REPORT EXAMPLE MESSAGE-ID Z1.
TABLES: USR02.
PARAMETERS: LOCK AS CHECKBOX, LISTLOCK AS CHECKBOX.
DATA: UFLAGVAL TYPE I, LOCKSTRING(8) TYPE C.
---- Authorization check -
AUTHORITY-CHECK OBJECT 'ZPROG_RUN' ID 'PROGRAM' FIELD SY-CPROG.
IF SY-SUBRC <> 0.
IF SY-SUBRC = 4.
MESSAGE E000 WITH SY-CPROG. "some message about authorization check failure
ELSE.
MESSAGE E005 WITH SY-SUBRC. "some message about authorization check failure
ENDIF.
ENDIF.
IF LISTLOCK = 'X'.
WRITE:/ 'List all locked users: '.
SELECT * FROM USR02 WHERE UFLAG = 64.
WRITE: / USR02-BNAME.
ENDSELECT.
EXIT.
ENDIF.
IF LOCK = 'X'.
UFLAGVAL = 64. "lock all users
LOCKSTRING = 'locked'.
ELSE.
UFLAGVAL = 0. "unlock all users
LOCKSTRING = 'unlocked'.
ENDIF.
SELECT * FROM USR02 WHERE BNAME <> 'SAP*' AND BNAME <> SY-UNAME.
IF USR02-UFLAG <> 0 AND USR02-UFLAG <> 64.
WRITE: 'User', USR02-BNAME, 'untouched; please handle manually.'.
CONTINUE.
ENDIF.
check that user has authority to make these changes
AUTHORITY-CHECK OBJECT 'S_USER_GRP'
ID 'CLASS' FIELD USR02-CLASS
ID 'ACTVT' FIELD '05'.
IF SY-SUBRC <> 0.
IF SY-SUBRC = 4.
WRITE: /'You are not authorized to lock/unlock user ',
USR02-BNAME, USR02-CLASS.
ELSE.
WRITE: /'Authorization error checking user ',
USR02-BNAME, USR02-CLASS, '(return code', SY-SUBRC, ').'.
ENDIF.
ELSE. "has authority
UPDATE USR02 SET UFLAG = UFLAGVAL WHERE BNAME = USR02-BNAME.
WRITE: / 'User', USR02-BNAME, LOCKSTRING, '.'.
ENDIF.
Similar Messages
-
Help me in alv grid and form printing
hi experts,
my requirement is
i have a check box in the selection screen for batch processing.
if i tick the check box, the data which is in the t_output table should be displayed in alv grid and
in turn if i select one row in alv o/p and double click on it the entire data shold be displayed in the form.
if 2 rows are selected in alv and double clicked on it then data in the two rows is dispalyed in the form.
points are rewarded .
thanks in advance.Hi,
Check the following link:
http://sapdev.co.uk/reporting/alv/alvgrid_rowsel.htm
Regards,
bhaskar -
ALV REPORT: read selected checkbox in alv grid and process the pushbutton
my requirement is to check some rows from alv grid and the press the pushbutton. Thereby following things should process:
select all checked rows into an itab and call the transaction code CJ01 for all
entries......
I am finding the problem that when I select the checkbox....the internal table doesnt recognize the boxes as checked ones......
thanks in advance...
Kartikey Singh,Data: ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data.
loop at t_output where Flag = 'X'.
if t_output-VKUEGRU is initial.
message e000 with text-110.
endif.
endloop. -
ALV Grid and Icon : Printing Problem
Hi, i develop some reports using ALV Grid and Icon and i'm facing printing problem, all report that using ALV grid with the option icon = 'X' cannot print properly, all the character field showing improper icon instead of the text. While all the ALV grid report with the option icon = ' ' can print normally.
Thanks.Hi,
Check the Demo Program <b>BCALV_DEMO_TOOLTIP</b>, Here i am able to see the Output Properly, and also able to Print them.
Regards
vijay -
ALV Grid and return to selection screen
Hello
I have an ALV Grid and when I push a buttom that I program appears another ALV Grid. In this second ALV I try to program different buttoms. When I program the BACK buttom I want to go to selection screen.
I try with CALL SELECTION SCREEN but when I stay in selection screen and push the execute buttom the ALV that I see is the second, not the first. It seems that we don't catch the news selections.
I put rs_selfied-refresh = 'X' after the CALL SELECTION SCREEN but is wrong again.
What can I do????Hello Silvia
There is a simple trick to return from the second ALV list directly back to the selection screen:
*& Report ZUS_SDN_REUSE_ALV_GRID_DISPLAY
REPORT zus_sdn_reuse_alv_grid_display.
TYPE-POOLS: slis.
DATA:
gt_t001 TYPE STANDARD TABLE OF t001,
gt_knb1 TYPE STANDARD TABLE OF knb1.
DATA:
gs_fcat TYPE slis_fieldcat_alv,
gt_fcat_t001 TYPE slis_t_fieldcat_alv,
gt_fcat_knb1 TYPE slis_t_fieldcat_alv.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '1000'.
START-OF-SELECTION.
SELECT * FROM t001 INTO TABLE gt_t001.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
* I_PROGRAM_NAME =
* I_INTERNAL_TABNAME =
i_structure_name = 'T001'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = gt_fcat_t001
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
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_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = syst-cprog
i_callback_pf_status_set = 'ALV_SET_PF_STATUS'
i_callback_user_command = 'ALV_USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME = ' '
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = gt_fcat_t001
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_t001
* 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.
END-OF-SELECTION.
*& Form set_pf_status
* text
* -->RT_EXTAB text
FORM alv_set_pf_status USING rt_extab TYPE slis_t_extab.
* NOTE: identical to STANDARD_FULLSCREEN with additional button
* for detail list ('DETAILLIST')
SET PF-STATUS 'STANDARD_FULLSCREEN'.
ENDFORM. "set_pf_status
*& Form alv_user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
FORM alv_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
* Display detail list: all customers for selected company code
WHEN 'DETAILLIST'.
IF ( rs_selfield-fieldname = 'BUKRS' ).
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = rs_selfield-value.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = syst-cprog
i_callback_pf_status_set = 'ALV_SET_PF_STATUS'
i_callback_user_command = 'ALV_USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = 'KNB1'
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_knb1
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.
<b>* NOTE: when the program logic returns from the 2nd ALV list
* and exit = 'X' then the program leaves the
* 1st ALV list, too, and returns to the selection screen.</b>
rs_selfield-exit = 'X'.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDFORM. "alv_user_command
Regards
Uwe -
ALV GRID and Integrated ITS 7 (SAP GUI for HTML) - dissapears on reload
Hi All,
We have a custom report that uses an ALV grid to display information to the user. Within this grid, there are fields that are display only and fields that are editable. Also, the grid is wider than the screen's width. It works fine in ECC. It also worked fine when we were using ITS 6.4.
We have recently upgraded to ITS 7. Now when we run the report using a Transaction iView (in EP 7) or the Webgui service (SAP GUI for HTML), if a field that is editable has focus when an event is triggered that reloads the grid, the screen becomes blank. So, you can click the Save button and the screen goes blank, also, there are date fields in the grid and if you choose a new date, the grid reloads and the screen becomes blank.
We have found that when the screen is blank, you can use the "Page Up" button on your keyboard and the last few columns of the grid will appear. As if the entire grid has moved off-screen to the left.
If you click onto a non-editable field and refresh or save, the grid returns to its normal state.
We are on Basis Patch level 15.
Does anyone have any ideas on how to fix this?
Also, does anyone know of a standard SAP transaction we can call from the Webgui that would have a similar setup...with an ALV grid containing editable and non-editable fields? We would like to rule out any errors in the report itself. Since it worked before we upgraded and it works fine in ECC. This would be a really big help too.
Thank you so much!
-KevinHi,
Thanks Raymond, I have seen Note 314568. I could not get the second link to work but I have looked at just about every Note in reference to Integrated ITS 7 and Tables or ALV Grids and there are very many, so it would appear that SAP has had a hard time with implementing this control, but I have not seen any instance that matches the problem we are having.
Unfortunately, SAP will not investigate this unless we can provide a standard Transaction that exhibits the same behavior.
If anyone knows of a standard SAP Transaction that displays an ALV Grid that is wider than the screen (requiring a horizontal scroll bar) and with editable and non-editable fields, that would be fantastic. If we can test against that, then we would know for sure if this is a problem with ITS / SAP GUI for HTML, or if there is an issue with this specific report.
Thanks!
-Kevin -
With regard to lock object and authority check
hi all
i would like to know about lock object and authority check specifically in reports. there is a coding in sap library with regard to authority check, but there is no coding to restrict user (i mean there is no user names that the object is restricting for a particular user or any user has got permission to change or display object).
further, the code mentions that you need an authorization in your user master record for the object, could any of u explain where is user master record.
below is the code for authority check.
*& Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'SHOW'.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD '*'
ID 'ACTVT' FIELD '03'.
IF SY-SUBRC NE 0. MESSAGE E009. ENDIF.
MODE = CON_SHOW.
SELECT SINGLE * FROM SPFLI
WHERE CARRID = SPFLI-CARRID
AND CONNID = SPFLI-CONNID.
IF SY-SUBRC NE 0.
MESSAGE E005 WITH SPFLI-CARRID SPFLI-CONNID.
ENDIF.
CLEAR OK_CODE.
SET SCREEN 200.
WHEN 'CHNG'.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD '*'
ID 'ACTVT' FIELD '02'.
IF SY-SUBRC NE 0. MESSAGE E010. ENDIF.
MODE = CON_CHANGE.
SELECT SINGLE * FROM SPFLI
WHERE CARRID = SPFLI-CARRID
AND CONNID = SPFLI-CONNID.
IF SY-SUBRC NE 0.
MESSAGE E005 WITH SPFLI-CARRID SPFLI-CONNID.
ENDIF.
OLD_SPFLI = SPFLI.
CLEAR OK_CODE.
SET SCREEN 200.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
i thank u all for the help in advance.hi
this might help
REPORT YUSRLOCK NO STANDARD PAGE HEADING.
TABLES: TRDIR, USR02.
DATA: MARK,CNTR TYPE I,
ACCNT LIKE USR02-ACCNT, ERDAT LIKE USR02-ERDAT,
ANAME LIKE USR02-ANAME, CLI(3) VALUE 'AAA', SZIN TYPE I,
SYDATUM LIKE SY-DATUM, FLAG(3).
TABLES: UINFO.
DATA: OPCODE TYPE X VALUE 2.
DATA: BEGIN OF USR_TABL OCCURS 10.
INCLUDE STRUCTURE UINFO.
DATA: END OF USR_TABL.
START-OF-SELECTION.
CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE
ID 'TAB' FIELD USR_TABL-SYS.
SELECT * FROM USR02 CLIENT SPECIFIED ORDER BY MANDT BNAME.
IF USR02-MANDT <> CLI.
SZIN = SZIN + 1. SZIN = SZIN MOD 2.
CLI = USR02-MANDT.
ENDIF.
IF USR02-UFLAG = 0.
MARK = ' '.
ELSE.
MARK = 'X'.
ENDIF.
CLEAR FLAG.
LOOP AT USR_TABL.
IF USR_TABL-BNAME = USR02-BNAME AND USR_TABL-MANDT = USR02-MANDT.
FLAG = '!!!'.
ENDIF.
ENDLOOP.
SYDATUM = SY-DATUM - 30.
IF SYDATUM < USR02-TRDAT.
IF SZIN = 0.
WRITE:/ ' ', MARK AS CHECKBOX,' ', USR02-BNAME COLOR 2,
' ',USR02-MANDT COLOR 2,
' ',USR02-USTYP COLOR 2,
' ',USR02-TRDAT COLOR 2, USR02-LTIME COLOR 2,
' ',FLAG COLOR 6.
ELSE.
WRITE:/ ' ', MARK AS CHECKBOX,' ', USR02-BNAME COLOR 3,
' ',USR02-MANDT COLOR 2,
' ',USR02-USTYP COLOR 2,
' ',USR02-TRDAT COLOR 2, USR02-LTIME COLOR 2,
' ',FLAG COLOR 6.
ENDIF.
ELSE.
IF SZIN = 0.
WRITE:/ ' ', MARK AS CHECKBOX,' ', USR02-BNAME COLOR 2,
' ',USR02-MANDT COLOR 2,
' ',USR02-USTYP COLOR 2,
' ',USR02-TRDAT COLOR 4, USR02-LTIME COLOR 4,
' ',FLAG COLOR 6.
ELSE.
WRITE:/ ' ', MARK AS CHECKBOX,' ', USR02-BNAME COLOR 3,
' ',USR02-MANDT COLOR 2,
' ',USR02-USTYP COLOR 2,
' ',USR02-TRDAT COLOR 4, USR02-LTIME COLOR 4,
' ',FLAG COLOR 6.
ENDIF.
ENDIF.
HIDE: USR02-BNAME, USR02-MANDT.
ENDSELECT.
CLEAR USR02.
TOP-OF-PAGE.
WRITE:/ 'LOCK USER CLIENT TYPE LAST lOGIN ' COLOR 6.
SKIP.
AT USER-COMMAND.
IF SY-UCOMM = 'SEL'.
DO.
CLEAR MARK.
READ LINE SY-INDEX FIELD VALUE MARK.
IF SY-SUBRC NE 0. EXIT. ENDIF.
IF USR02-BNAME IS INITIAL.CONTINUE.ENDIF.
SELECT SINGLE * FROM USR02 CLIENT SPECIFIED WHERE
MANDT = USR02-MANDT AND BNAME = USR02-BNAME.
IF MARK = 'X' AND USR02-UFLAG = 0.
USR02-UFLAG = 64.
UPDATE USR02 CLIENT SPECIFIED SET: UFLAG = 64 WHERE
MANDT = USR02-MANDT AND
BNAME = USR02-BNAME.
COMMIT WORK.
ENDIF.
IF MARK = ' ' AND USR02-UFLAG = 64.
USR02-UFLAG = 0.
UPDATE USR02 CLIENT SPECIFIED SET: UFLAG = 0 WHERE
MANDT = USR02-MANDT AND
BNAME = USR02-BNAME.
COMMIT WORK.
ENDIF.
ENDDO.
CLEAR USR02.
ENDIF.
regards
Arun -
User role and Authority-check ?
Hello,
Could you please let me know how are the differences between User role and Authority-check. In a program I do not use Authority-check , And The user is not assigned to user role which contain this transaction ( for this program), Can the user execute this transaction OR he must be assigned to user role which contain this transaction to execute it . Supposing that we do not use any Authority-check in then program.
Thanks in advanceHello Martin,
I think this answers the OP's question about user not being assigned the role which contains the trxn code. As you have explained in this case the default auth. check for S_TCODE will fail & user cannot execute the trxv. (If i remember correctly the tables for this are AGR_USERS & AGR_TCODES)
Anyways just to add to the OP's query. Auth. objects are added to profiles which in turn assigned to roles. So if you implement the auth. object in your program the user must also subscribe to the role containing the auth. obj. profile to be able to execute it.
@OP:
The transactions PFCG & SUIM might interest you. Also the tables dealing with these stuffs begin with AGR*. You can check the tables for better understanding.
BR,
Suhas -
Report with two ALV grids and a header
Hi experts,
I have a report with two ALV grids in the same screen, each one in a separated container. The information displays it correctly. The report has been implemented by using OO Programming.
My real trouble is in the header. It must have a logo, a title with a specific font and other information.
I'll attach a capture of my need:
[Report with two ALV grids and a header|http://picasaweb.google.com/lh/photo/AcQD49QPmm-0L_jL2iMedA?feat=directlink]
Then, I want to set up the header you can see, with logo, a font with specific features. Obviously, the header you see has taken from another report. But is the same idea.
I've tried with a third container, using the CL_GUI_CONTAINER and CL_GUI_CONTAINER classes, but it doesn't work.
Any idea? Would welcome any help you can provide.
Thanks in advance,
Jorge RojasHi, Jorge.
Should the header be a"attached" to any of the ALV? Or it should be carried alone?
If first applies, you've given the solution yourself: put the info & logo in first ALV's header and invoke it from the proper method.
You could use CL_GUI_DOCKING_CONTAINER CLASS to divide screen in several containers and then, in the upper one, I would create another one docking container to divide the screen into two: the written info could be performed with an HTML viewer class and the logo with a CL_GUI_PICTURE element.
Cheers. -
ALV-Grid and update dynpro fields
Hi!
I've created a dynpro with an ALV-Grid for Data-Overview and fields on the dynpro to change additional data.
My ALV has one editable column, when this value change I calculate other value for a field dynrpo, but I canu2019t see this change in my field dynpro.
How can I update my data filed dynpro when changing the selected row at the ALV.
I use the method handle_data_changed to obtain changes in ALV-Grid and it works fine, but I canu2019t update my fileds on the dynpro, when changing value in ALV.
Thanks for any hints!
Lili.This error occurs becuase when you change anything on the ALV, control is not triggering the PAI and PBO of your dynpro. Hence your values are not getting updated in the dynpro field.
You should call the CL_GUI_CFW=>DISPATCH in PAI module to trigger the PAI also after the event has been triggered in the ALV.
CALL METHOD CL_GUI_CFW=>DISPATCH
importing return_code = return_code.
* a control event occured => exit PAI
if return_code <> cl_gui_cfw=>rc_noevent.
clear g_ok_code.
exit.
endif.
Regards,
Naimesh Patel -
ALV Grid and ALV List difference?
Hello,
Can you help me differentiate ALV List and ALV grid and the low-level definition or context of each?
Also, can you give me a transaction code that outputs an ALV list as well as a tcode for ALV grid?
Thanks,
JennahHi Kirtish,
Thanks but I havent done any function module stuff as I am not an ABAPer but anyway can you guide me through thios?
"I hope this might slove your query. For more please refer to documentation on ALV and also implement the ALV LIST and GRID reports. By using class Class CL_GUI_ALV_GRID, Function module REUSE_ALV_LIST_DISPLAY , REUSE_ALV_GRID_DISPLAY and some more functions like that only."
I will give you some tcode can you please try tcode FBL1n? then execute the report. What is the output is it an ALV list?
I wish to see an ALV list also an ALV grid to see difference.
Tjhakns,
Jennah -
What is the difference between Alv Grid and Table Control?Explain in detail..
Table control is a screen table to display table data in a screen. You can add table control to a screen in the Screen Painter. The typical flow-logic to process table control is:
LOOP AT <internal table> CURSOR <scroll-var>
[WITH CONTROL <table-control> ]
[FROM <line1> ] [TO <line2> ].
...<actions>...
ENDLOOP.
ALV Grid is a SAP Technology to display a set of data on the output screen. For example if you have selected some SAP tables and processed these data in a way you want to display, then you can pass the internal table to the ALV Grid and it will be displayed on the result screen as ALV Grid. See example in SE16 result. -
HI all,
Diff between ALV GRID and ALV LIST?
sachin.Hi,
ckeck these differences.
first one is for list display and second one is for grid display.
For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
ALV LIST Can be coded using only FMs
ALV GRID Can be coded using FMs and object oriented concepts
ALV LIST Can be displayed hieraicharlly
ALV GRID cannot be displayed hierarichally.
reward points if hlpful. -
Display totals on the first line in ALV grid and ALV LIST
Generally we wll display totals at the end..
bu the requirement is to display it in the first line of the column.
how to display the totals in the first line?
I have used ALV GRID and ALV LIST (choice) using function modules.
Plz help me
.for example : Po qty : Should display total po qty on the first line of the Po line item.IN LAYOUT
ILAYOUT-totals_before_items = 'X'.
REGARDS
SHIBA DUTTA -
Hello ;
My Program is type of report, not a moduler program.
And Im using the alv grid , But there isnt refresh button ,I couldnt see it.
How can I see refresh button?
Thanks.Hai
Check the following Code
REPORT z_alv_grid_ctrl_refresh_2.
ALV Grid Control *
This report reads and displays data from table MARA, using *
the Method set_table_for_first_display of CL_GUI_ALV_GRID *
Button 'NEXT_PAGE' : displays the next N records *
Button 'PREV_PAGE' : displays the previous N records *
Button 'FIRST_PAGE' : displays the first page *
Button 'LAST_PAGE' : displays the last page *
When the buttons Sort up, sort down, Filter, Delete Filter are *
pressed, N record are still displayed *
Steps : *
- Create the report Z_ALV_GRID_CTRL_REFRESH_2 *
- Create the Dynpro 0100 (size 27x120) *
- Add OKCODE (type OK) in the element list *
- Modify the flow logic of dynpro 0100 : *
* PROCESS BEFORE OUTPUT. *
MODULE pbo_0100. *
* PROCESS AFTER INPUT. *
MODULE user_command_0100. *
- Create a status named 'MAIN' *
with the buttons : REFRESH BACK EXIT *
and the buttons : FIRST_PAGE PREV_PAGE NEXT_PAGE LAST_PAGE *
Author : Michel PIOUD *
Email : [email protected] HomePage : http://www.geocities.com/mpioud *
CONSTANTS:
c_first_page TYPE syucomm VALUE 'FIRST_PAGE',
c_next_page TYPE syucomm VALUE 'NEXT_PAGE',
c_prev_page TYPE syucomm VALUE 'PREV_PAGE',
c_last_page TYPE syucomm VALUE 'LAST_PAGE'.
TYPES:
BEGIN OF ty_s_mara,
ernam LIKE mara-ernam,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
brgew LIKE mara-brgew,
END OF ty_s_mara.
CLASS lcl_event_alv DEFINITION DEFERRED.
DATA:
gt_mara TYPE STANDARD TABLE OF ty_s_mara,
go_container TYPE REF TO cl_gui_docking_container,
go_alv_grid TYPE REF TO cl_gui_alv_grid,
go_events TYPE REF TO lcl_event_alv,
gt_mara_ftr TYPE STANDARD TABLE OF ty_s_mara, " Data filtered
gt_mara_all TYPE STANDARD TABLE OF ty_s_mara, " Data readfrom DB
okcode TYPE syucomm,
gv_okcode TYPE syucomm.
CLASS lcl_event_alv DEFINITION
CLASS lcl_event_alv DEFINITION.
PUBLIC SECTION.
METHODS:
h_user_command FOR EVENT after_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm
sender.
ENDCLASS. " LCL_EVENT_ALV DEFINITION
Class (Implementation) lcl_event_alv
CLASS lcl_event_alv IMPLEMENTATION.
METHOD h_user_command.
CASE e_ucomm.
WHEN '&SORT_ASC' OR '&SORT_DSC'. " Sort
PERFORM f_sort_big_table.
PERFORM f_read_data USING c_first_page.
PERFORM f_refresh_table.
WHEN '&FILTER'. " Filter
PERFORM f_filter_data.
PERFORM f_read_data USING c_first_page.
PERFORM f_refresh_table.
WHEN '&DELETE_FILTER'. " Delete filter
gt_mara_ftr[] = gt_mara_all[].
PERFORM f_read_data USING c_first_page.
PERFORM f_refresh_table.
ENDCASE.
ENDMETHOD. " user_command
ENDCLASS. " LCL_EVENT_ALV
SELECTION-SCREEN :
BEGIN OF LINE,COMMENT 10(20) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '30' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
v_1 = 'Lines per page'.
START-OF-SELECTION.
SELECT matnr ernam ersda brgew
INTO TABLE gt_mara_all
FROM mara.
gt_mara_ftr[] = gt_mara_all[].
PERFORM f_read_data USING c_first_page.
CALL SCREEN 100.
Module pbo_0100 OUTPUT
MODULE pbo_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
PERFORM create_and_init_alv.
ENDMODULE. " PBO_0100 OUTPUT
Module user_command_0100 INPUT
MODULE user_command_0100 INPUT.
gv_okcode = okcode.
CLEAR okcode.
CASE gv_okcode.
WHEN 'BACK'.
SET SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN c_first_page OR c_next_page OR c_last_page OR c_prev_page.
PERFORM f_read_data USING gv_okcode. " Update gt_mara
PERFORM f_refresh_table.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Form f_read_data
FORM f_read_data USING u_ucomm TYPE syucomm.
STATICS :
l_1 TYPE sytabix,
l_2 TYPE sytabix.
DATA l_max TYPE sytabix. " Internal table size
DESCRIBE TABLE gt_mara_ftr LINES l_max.
CASE u_ucomm.
WHEN c_first_page. " 1st page
l_1 = 1.
WHEN c_prev_page. " Previous page
SUBTRACT p_max FROM l_1.
IF l_1 < 1.
l_1 = 1.
ENDIF.
WHEN c_next_page. " Next page
IF l_1 IS INITIAL.
l_1 = 1.
ELSE.
ADD p_max TO l_1.
ENDIF.
IF l_1 > l_max.
l_1 = l_max.
ENDIF.
WHEN c_last_page. " Last page
l_1 = l_max - p_max + 1.
IF l_1 < 1.
l_1 = 1.
ENDIF.
ENDCASE.
l_2 = l_1 + p_max - 1.
IF l_2 > l_max.
l_2 = l_max.
ENDIF.
REFRESH gt_mara.
IF l_max > 0.
APPEND LINES OF gt_mara_ftr FROM l_1
TO l_2
TO gt_mara.
ENDIF.
ENDFORM. " F_READ_DATA
Form create_and_init_alv
FORM create_and_init_alv.
Macro definition
DEFINE m_fieldcat.
add 1 to ls_alv_cat-col_pos.
ls_alv_cat-fieldname = &1.
ls_alv_cat-ref_table = 'MARA'.
append ls_alv_cat to lt_alv_cat.
END-OF-DEFINITION.
DATA:
ls_variant TYPE disvariant,
lt_alv_cat TYPE lvc_t_fcat,
ls_alv_cat TYPE lvc_s_fcat,
ls_alv_lay TYPE lvc_s_layo,
l_offline TYPE char1.
CHECK go_container IS INITIAL.
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING e_offline = l_offline.
IF l_offline EQ 0.
CREATE OBJECT go_container
EXPORTING
extension = 2000
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc NE 0.
MESSAGE e208(00) WITH 'The control could not be created'.
ENDIF.
ENDIF.
Create an instance of alv control
CREATE OBJECT go_alv_grid
EXPORTING i_parent = go_container.
CREATE OBJECT go_events.
SET HANDLER go_events->h_user_command FOR go_alv_grid.
Build field catalog
m_fieldcat 'ERNAM'.
m_fieldcat 'MATNR'.
m_fieldcat 'ERSDA'.
m_fieldcat 'BRGEW'.
Layout
CLEAR ls_alv_lay.
ls_alv_lay-zebra = 'X'.
ls_alv_lay-cwidth_opt = 'X'.
ls_variant-report = sy-cprog.
Display
CALL METHOD go_alv_grid->set_table_for_first_display
EXPORTING
is_variant = ls_variant
is_layout = ls_alv_lay
i_save = 'A'
CHANGING
it_outtab = gt_mara
it_fieldcatalog = lt_alv_cat.
ENDFORM. " CREATE_AND_INIT_ALV
Form F_REFRESH_TABLE
FORM f_refresh_table.
DATA: ls_layout TYPE lvc_s_layo.
CALL METHOD go_alv_grid->get_frontend_layout
IMPORTING es_layout = ls_layout.
ls_layout-cwidth_opt = 'X'.
CALL METHOD go_alv_grid->set_frontend_layout
EXPORTING is_layout = ls_layout.
CALL METHOD go_alv_grid->refresh_table_display.
ENDFORM. " F_REFRESH_TABLE
Form F_SORT_BIG_TABLE
FORM f_sort_big_table.
DATA:
lt_sort_kkblo TYPE kkblo_t_sortinfo,
lt_sort TYPE lvc_t_sort.
CALL METHOD go_alv_grid->get_sort_criteria
IMPORTING et_sort = lt_sort.
CHECK NOT lt_sort[] IS INITIAL.
Format LVC --> KKBLO
CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
EXPORTING
it_sort_lvc = lt_sort
IMPORTING
et_sort_kkblo = lt_sort_kkblo.
The big tables must be sorted like the small one
PERFORM fb_outtab_sort(saplkkbl) TABLES gt_mara_ftr
lt_sort_kkblo
USING 'X'
'X'.
PERFORM fb_outtab_sort(saplkkbl) TABLES gt_mara_all
lt_sort_kkblo
USING 'X'
'X'.
ENDFORM. " F_SORT_BIG_TABLE
Form f_filter_data
FORM f_filter_data.
DATA:
lt_filter_lvc TYPE lvc_t_filt,
lt_filter_index TYPE lvc_t_fidx WITH HEADER LINE.
CALL METHOD go_alv_grid->get_filter_criteria
IMPORTING et_filter = lt_filter_lvc.
Find data to filter
CALL FUNCTION 'LVC_FILTER_APPLY'
EXPORTING
it_filter = lt_filter_lvc
IMPORTING
et_filter_index = lt_filter_index[]
TABLES
it_data = gt_mara_all.
gt_mara_ftr[] = gt_mara_all[].
SORT lt_filter_index DESCENDING.
LOOP AT lt_filter_index.
DELETE gt_mara_ftr INDEX lt_filter_index.
ENDLOOP.
ENDFORM. " F_FILTER_DATA
END OF PROGRAM Z_ALV_GRID_CTRL_REFRESH_2 ********************
Thanks & regards
Sreenivasulu P
Maybe you are looking for
-
Mr. Frank Could u plz check this ...
Hi, Could u please guide me wat is the reason of this error...Is this error occuring due to some configuration Problem. I tried to run the backup application, which was running smoothly previous days. The error----- C:\Oracle\Middleware\jdeveloper\sy
-
F110 bank charges where to maintain??
Dear Expert, I am configuring the automatic payment and client required that the bank charges bear by which party will depend on the transaction. I know that I could maintain the instruction key on vendor master data to inform SAP whether bank charge
-
IPod Classic won't connect - need to restore. What do I do?
I installed the latest iTunes onto my laptop (Windows 8), and now my iPod Classic won't connect to my laptop or iTunes. It's also telling me I need to connect to iTunes to restore it. I can't connect it to iTunes. When I plug in the USB cord, It star
-
Anything like adobe acrobat 9 pro extended for mac?
Ready to switch to mac - buying on Friday - deal breaker though would be that there are no programs like acrobat 9 pro extended that can create pdf files from almost any video file... anything like that available on mac?? Thanks and I'm hoping the an
-
Hi,i have some problem about my order, my order number is W2*****145 , i brought a iphone 6plus in the apple online website, but today i got the massage from my account said that we are unable to obtain an authorization for the credit card. i have be