Alv grid question
Hi all,
I m trying to print the content of an internal table as a alv grid , but i miss the F1 documentation of the field component:
I have the following code :
Types :
BEGIN OF ty_s_temp,
application TYPE char20,
component LIKE t512e-lgart,
END OF ty_s_inrichting,
DATA :
it_temp like table of ty_s_temp.
After defining the fieldcatalog .. i use the function
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_sort = gt_sort
i_save = 'X'
TABLES
t_outtab = it_temp.
Can someone tell me what i m doing wrong ?
regards,
Hi Adel,
give the reference fieldname in the fieldcatalog for that field and also roll name and checkout if it works
wa_fieldcat-rollname = 'LGART'.
wa_fieldcat-ref_fieldname = 'LGART'.
Similar Messages
-
Beginner ALV Grid question (using OO) "Possible Values" doesn't do anything
Hi,
I have a working ALV Grid report using the 'CL_CALV_TABLE' class, and FACTORY DISPLAY method.
Standard Functions are working, got single-click events programmed to drill-down into documents, key columns, etc.
So the report output seems fine.
<i>However, some columns / cells have a "possible values" icon, but when selected nothing happens. And some columns have the icon, for example, Material, Co.Code, but then others don't. </i>
I've looked at example report SALV_DEMO_TABLE_COLUMNS and SALV_TEST_FUNCTIONS, but I can't see any specific code in there that controls this.
<u>Would appreciate it if anyone can confirm:</u>
a) what triggers the icon to appear for some columns/cells but not others? Is it the TYPE of the table column?
b) is any coding needed for the "Possible values" window to popup?
TIA,
JamesSeems like f4availabl field is enabled in field catalog.
-
Hello, I have a report with an selection screen with a few input parameters. This results in an alv grid being displayed. The users downloads the alv grid to excel. This works fine.
I'd like to include the input parameters as the top row in the downloaded excel, on top of the result set. Is this possible? How do you do it?
Best regards /OttoThis data would have to be included in the ALV grid itself(assuming that you are using the standard excel functionality embedded into the ALV grid).
There are others ways to get around this. You could add a new button to the applicatoin toolbar, where then you would handle the building of the excel file in your custom code.
REgards,
Rich Heilman -
Hi,
I need to add a custom button to the alv grid menu and i couldnt able to see the screen when i execute this program. Will u please tell me how to add a new button to the existing application toolbar of the ALV grid. I had tried this code but couldnt succeeded.
Here is my code.
REPORT ZZZZ .
*& Report ZZZZ
type-pools: slis.
Data to be displayed
data: gt_wrkpool type table of zte_wrkpool.
data: gs_wrkpool type zte_wrkpool.
data: gs_layout type slis_layout_alv.
DATA:G_REPID TYPE SY-REPID.
Selection
select * from zte_wrkpool into corresponding fields of table gt_wrkpool.
Eingabebereit
gs_layout-edit = 'X'.
G_REPID = SY-REPID.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_CALLBACK_PROGRAM = g_repid
I_CALLBACK_USER_COMMAND = 'ACTION'
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
i_structure_name = 'zte_wrkpool'
is_layout = gs_layout
IT_SORT = SORT[]
IT_EVENTS = events[]
tables
t_outtab = gt_wrkpool.
FORM pf_status_set USING gt_extab TYPE slis_t_extab.
SET PF-STATUS <ZSTANDARD>.
ENDFORM.
Create another subroutine:
*& Form user_command
Takes the User command and acts accordingly
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
call function 'sAP_WI_FORWARD'
endform.Hi vicky,
1. The important things are :
a) New PF-STATUS is required , say 'ABCD'.
b) Handle user_commmand
2. First of all, from Function group SALV,
copy the STANDARD gui status to your program,
from SE80, by right clicking.
3. come to your program.
start-of-selection.
SET PF-STATUS 'ABCD'.
4. Double click ABCD and activate the gui status.
6. AT USER-COMMAND.
IF sy-ucomm = 'MYFCODE'.
ENDIF.
regards,
amit m. -
Question reg. converting code from ALV list to ALV grid
I created a report based on a code posted by an SDN user in ABAP forums. The code is below. Now I want to create the same functionality using ALV grid and not simple ALV list. Can you please tell me what modifications to be done to the below coding?
Appreciate your help and input.
Thanks a lot,
Krishen
******************Code start*******************
**Change required before executing the report..
1)
Create a GUI status for the program in SE41 by copying
from the program SAPLKKBL and Status 'STANDARD'..
and store the resulting in status 'TEST2'.
2)
I have used table name as ZTABLE..Change accordingly
to your ztable name..
**Endchange
declarations.
TABLES: ztable.
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF t_ztable OCCURS 0.
INCLUDE STRUCTURE ztable.
DATA: BOX TYPE c,
END OF t_ztable.
DATA: v_repid TYPE syrepid.
selection screen
SELECT-OPTIONS so_id for ztable-id.
SELECT-OPTIONS so_date for ztable-date.
start-of-selection.
Get the data.
SELECT * FROM ztable
INTO TABLE t_ztable.
where id in so_id
and date in so_date.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
v_repid = sy-repid.
Get the field catalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_structure_name = 'ZTABLE'
CHANGING
ct_fieldcat = t_fieldcatalog.
Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = t_ztable.
FORM SET_PF_STATUS *
--> EXTAB *
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'TEST2'.
ENDFORM.
FORM user_command *
--> UCOMM *
--> SELFIELD *
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Check the ucomm.
IF ucomm = 'DELETE'.
LOOP AT t_ztable WHERE box = 'X'.
DELETE FROM ztable WHERE matnr = t_ztable-matnr.
COMMIT WORK.
DELETE t_ztable.
ENDLOOP.
ENDIF.
selfield-refresh = 'X'.
ENDFORM.
**********Code ending**********************I believe that the only change would be to replace the work LIST with GRID in the function call.
CALL FUNCTION 'REUSE_ALV_<b>GRID</b>_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = t_ztable.
The function module interface should be exactly the same.
Regards,
Rich Heilman -
Hi,
I'm convincved this question has been asked and answered but I can't find it:
My report creates an ALV grid using function REUSE_ALV_GRID_DISPLAY. I can use GUI status function &VEXCEL to start excel inline in the grid area. But I get an empty sheet with those many SAP standard tabs - no data are transfered.
As far as I remember this is a BASIS problem but neither our basis people nor I know how to cure this.
Any help is welcome!
Kind regards,
Clemens LiHi,
sorry, I'm late: I tried as described, logged off and on, and suddenly it worked - for all systems including the one I did not do anything. Looks like a WinXp bug.
Never again any problem.
Sorry, not really satifying - possibly Rich never had this!
Regards,
Clemens
Message was edited by: Clemens Li -
Download from ALV grid to PDF format
hai Friends!
plz tell me how can i download from ALV grid to PDF format..
send me some sample codescheck this thread
ALV Grid to PDF
and do use the search functionality from next time and post the question only wheb u dont find the answer
кu03B1ятu03B9к -
ALV GRID - Handling selected rows? Sorting in OUTTAB is different from ALV
Dear Experts ,
I have a transaction with ALV grid. I have defined several application specific functions to the ALV grid tool bar. My requirement is to handle the ALV tool bar functions only for the selected rows.
Code snippet:
DATA:
LS_GRID_DS TYPE TYS_DS.
TYPES: BEGIN OF TYS_DS.
INCLUDE TYPE TYS_ALVGRID.
TYPES: STRUCNAME LIKE DD02L-TABNAME.
TYPES: PRETAB TYPE ZTAB_T,
OUTTAB TYPE ZTAB_T,
OUTTAB_HIDDEN TYPE ZTAB_T,
OUTTAB_SUM TYPE ZTAB_T,
OUTTAB_ROLLBACK TYPE ZTAB_T,
END OF TYS_DS.
LOOP AT ls_grid_ds-marked_rows INTO ss_index_split
WHERE rowtype IS INITIAL.
( Marked rows is correctly giving the row numbers of the highlighted rows)
READ TABLE ls_grid_ds-outtab INTO ss_sel_rows_ds_split
INDEX ss_index_split-index.
ISSUE : Sorting in ls_grid_ds-outtab internal table is different from ALV Grid display.
Hence, though ls_grid_ds-marked_rows giving correct rows, I am not able to handle the my requirement correctly.
Why sorting in gs_grid_ds-outtab is different from ALV display? How can they made in sync?
Thank you in Advance.
Sravan.
Edited by: Raja Sravan on Jan 16, 2009 1:13 AMHello Raja
The OUTTAB is usually in sync with the display on the frontend grid control because it is a CHANGING parameter (of method SET_TABLE_FOR_FIRST_DISPLAY).
Question: Do you "feed" ls_grid_ds-outtab to the parameter IT_OUTTAB of method SET_TABLE_FOR_FIRST_DISPLAY?
If not then it is obvious why you get discrepancies.
Regards
Uwe -
To have a list in a field of a row in ALV Grid
Dear Colleagues,
My question is that in an ALV Grid we have a number of rows.
Now in the row suppose i want one field as a drop down list with definite values is it possible..??
If so is there a function module to do this..??
Thanks and Regards
VarunThat was very helpful, But unfortunately that only allows only a pre defined list to be displayed....
I want a new drop down list for each record..??
Would that be possible..???
Is there any module for that...???? -
Average value for a Date Field in an OO Alv Grid.
Hi Abapers.
I've been searching for some info about averages in OO Alv grid lists but cannot find an answer to what I'm really need. The question is that, for getting an average, a 'C' value must be set in the field DO_SUM of the fieldcatalog structure for a field.
Now, the problem is that I need the average of a date field (in 'normal' date format). I've tried it several times and read a lot of things but cannot find a real answer: Could it be done the average of a date field (e.g. for dates 01.05.2009, 02.05.2009 and 03.05.2009 the average is 02.05.2009).
Best Regards.Hi,
It will come along with the standard tool bar.For number fields, you can see it(Mean). -
Button in alv grid cell using REUSE_ALV_GRID_DISPLAY
Hi all,
I want to make the contents of 2 columns of my alv grid as push button with values as text on it. I am not using classes or methods but alv grid fm. On clicking the button one dialog box has to pop up which gives edit option for the values in that coloumn, my question is how to introduce button in alv grid cell? if i can use t_fieldcatalog-icon, then please give me the complete steps for that.
Thanks.this may helps u
u need to copy stadard screen elemetn to MARATAB1(at PF -STATUS)
You should copy the 'STANDARD' GUI status from program <b>SAPLSLVC_FULLSCREEN</b>
type this one in SE41 program name is:<b>SAPLSLVC_FULLSCREEN</b>
status : <b>STANDARD_FULLSCREEN</b>
and copy it ...
Type-pool
type-pools slis.
Tables
tables: mara,sscrfields.
Selection screen
select-options: s_matnr for mara-matnr.
PARAMETERS: p_email TYPE somlreci1-receiver.
TYPES: BEGIN OF t_charmara,
matnr(18) TYPE c, " Material Number
ernam(12) TYPE c, " Person Credited
aenam(12) TYPE c, " Person Changed Object
pstat(15) TYPE c, " Maintenance Status
END OF t_charmara.
Data Declarations
data: rt_extab type slis_t_extab, " Table of inactive function
codes
wa_charmara TYPE t_charmara, " work area of mara Table
fs_fieldcat type slis_t_fieldcat_alv,
" Field catalog with field
descriptions
t_fieldcat like line of fs_fieldcat,
" Table of Field catalog
r_ucomm like sy-ucomm, " User Command
rs_selfield TYPE slis_selfield. " cursor position ALV
data: filedlayout type slis_layout_alv,
heading type slis_t_listheader with header line,
t_event type slis_t_event.
data: fs_event like line of t_event.
data: fs_sort type slis_sortinfo_alv,
t_sort type slis_t_sortinfo_alv.
data: w_char(200) type c,
w_matnr type mara-matnr.
fs_sort-fieldname = 'MATNR'.
fs_sort-up = 'X'.
fs_sort-group = '*'.
append fs_sort to t_sort.
clear fS_sort.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
Internal Tables
data: begin of it_mara occurs 0,
matnr like mara-matnr, " Material Number
ernam like mara-ernam, " Person Credited
aenam like mara-aenam, " Person Changed Object
pstat like mara-pstat, " Maintenance Status
end of it_mara.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
*at selection-screen on field event
AT SELECTION-SCREEN on s_matnr.
PERFORM f0100_VALIDATE_MATERIAL_NUMBER.
start-of-selection.
retrive Data from the data base table Mara
perform retrive_data_from_mara.
end-of-selection.
*Field catalog with field descriptions
perform fieldcat.
*perform top_of_page.
PERFORM EVENT_LIST.
*ALV Grid Display
perform alv_display.
Creating one Push button ENTER
perform maratab1 USING RT_EXTAB.
*& Form f0100_VALIDATE_MATERIAL_NUMBER
text
There are no interface parameters to be passed to this subroutine
FORM F0100_VALIDATE_MATERIAL_NUMBER .
select matnr " Material Number
from mara
up to 1 rows
into mara-matnr
where matnr in s_matnr.
endselect.
IF sy-subrc NE 0.
clear sscrfields-ucomm.
MESSAGE e000 WITH 'Enter valid Material number'(003).
ENDIF. " IF sy-subrc NE 0
ENDFORM. " f0100_VALIDATE_MATERIAL_NUMBER
*& Form retrive_data_from_mara
text
*There are no interface parameters to be passed to this subroutine
FORM retrive_data_from_mara .
select matnr " Material Number
ernam " Person Credited
aenam " Person Changed Object
pstat " Maintenance Status
from mara
into table It_mara
where matnr in s_matnr.
IF sy-subrc NE 0.
MESSAGE i001 WITH 'Records are not found'.
exit.
stop.
ENDIF. " IF sy-subrc NE 0
ENDFORM. " retrive_data_from_mara
*& Form fieldcat
text
*There are no interface parameters to be passed to this subroutine
FORM fieldcat .
*field catalog for MATNR
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'MATNR'.
t_fieldcat-col_pos = 1.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for ERNAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'ERNAM'.
t_fieldcat-col_pos = 2.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for AENAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'AENAM'.
t_fieldcat-col_pos = 3.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for PSTAT
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'PSTAT'.
t_fieldcat-col_pos = 4.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
ENDFORM. " fieldcat
*& Form EVENT_LIST
text
*There are no interface parameters to be passed to this subroutine
FORM EVENT_LIST .
fs_event-name ='TOP_OF_PAGE'.
fs_event-form = 'TOP_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_PAGE'.
fs_event-form = 'END_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_LIST'.
fs_event-form = 'LIST_END'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
ENDFORM. " EVENT_LIST
*& Form alv_display
text
*There are no interface parameters to be passed to this subroutine
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'MARATAB1'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = FS_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = T_SORT
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_EVENT
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = 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. " alv_display
form TOP_PAGE.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = 'Created by : Vijay Pawar'.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' Date ' sy-datum into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' From ' s_matnr-low ' To ' s_matnr-high into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form TOP_PAGE.
form END_PAGE.
STATICS W_PAGE TYPE I .
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = W_PAGE.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
add 1 to w_page.
endform. " form END_PAGE.
form list_end.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = '......................................Last Page'
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form list_end.
*& Form maratab1
text
-->P_RT_EXTAB text
FORM maratab1 USING P_RT_EXTAB.
SET PF-STATUS 'MARATAB1' EXCLUDING rt_extab.
ENDFORM. " maratab1
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when 'ENTER'.
perform bulid_xls_data_table.
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email "'[email protected]'
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
endcase. " case r_ucomm.
endform. " FORM user_command
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
DATA_FILENAME = 'MARA.XLS'
DATA_PATH_FLAG = 'W'
DATA_ENVIRONMENT =
DATA_TABLE = ITAB[]
MACRO_FILENAME =
MACRO_PATH_FLAG = 'E'
MACRO_ENVIRONMENT =
WAIT = 'X'
DELETE_FILE = 'X'
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
INTERNAL_ERROR = 3
CANCELLED = 4
DOWNLOAD_ERROR = 5
NO_AUTHORITY = 6
FILE_NOT_DELETED = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
leave to list-processing.
endcase.
*& Form bulid_xls_data_table
text
*There are no interface parameters to be passed to this subroutine
FORM bulid_xls_data_table .
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'matnr' 'ernam' 'aenam' 'pstat'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT It_mara INTO wa_charmara.
CONCATENATE wa_charmara-matnr wa_charmara-ernam
wa_charmara-aenam wa_charmara-pstat
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP. " LOOP AT it_mara INTO...
ENDFORM. " bulid_xls_data_table
*& Form send_file_as_email_attachment
Send email
-->P_IT_MESSAGE text
-->P_IT_ATTACH text
-->P_P_EMAIL text
-->P_0387 text
-->P_0388 text
-->P_0389 text
-->P_0390 text
-->P_0391 text
-->P_0392 text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. " send_file_as_email_attachment
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test mara records'.
APPEND it_message.
endform. "form populate_email_message_bod
rewards if it helps u -
Double click in alv grid not refreshing until I click elsewhere
Hello,
I'm very new to abap and just managed to partly implement double click in an alv grid.
I also created a button that calls the exact same function as double click (selects the row and fills in the data areas on the page). When I use the button, everything works fine, but when I double click, nothing changes until I click on a tab or other form of input button on the page.
I have followed the process in debugging and can't find the fault anywhere.
My double click is implemented by:
create object lcl_event_receiver.
set handler lcl_event_receiver->double_click
for search_alv_grid.
endif.
CLASS lcl_event_handler DEFINITION.
public section.
methods:
double_click for event double_click
of cl_gui_alv_grid.
ENDCLASS. "lcl_event_handler
CLASS lcl_event_handler IMPLEMENTATION.
* METHOD double_click *
method double_click.
perform select_search_result.
endmethod. "double_click
ENDCLASS.
Any help would be much appreciatedHello,
Try using the template code given below. Let me know if you have any questions.
data : GT_EVENTS TYPE SLIS_T_EVENT.
get event
PERFORM BUILD_EVENT_TOPOFPAGE USING GT_EVENTS[].
display alv data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_xxxxx
IT_FIELDCAT = GT_xxxx
IT_EVENTS = GT_EVENTS[]
TABLES
T_OUTTAB = T_xxxx
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
get event perform
FORM BUILD_EVENT_TOPOFPAGE USING LT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.
Read double click event using the below statement
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO LS_EVENT.
IF SY-SUBRC = 0.
ENDIF.
ENDFORM. " BUILD_EVENT_TOPOFPAGE
FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM
LS_SELFIELD TYPE SLIS_SELFIELD.
CASE L_UCOMM.
WHEN <double click>
Perform do_something.
ENDCASE.
ENDFORM. " USER_COMMAND
Best Regards,
Krishna -
Editable ALV Grid column behavior under ITS standalone
Hello experts,
I have a straight forward implementation of an ALV Grid with 3 columns. Two columns are display only and the third is editable. My question only involves the editable column and its behavior in a web browser served by a standalone ITS server. The underlying data type is CURR. The enterable amounts are restricted to a format of 9.99. Even so, a web user can accidentally enter a non-numeric value such as 1.x0 . We have coded a data changed event handler to check the input value for expected amounts. The event handler logic readily identifies the non-numeric value and handles the exception. Although we have full control of the internal table value, there are two problems encountered within the web browser interface:
1) We cannot return the cursor to the problem cell to prevent the user from continuing before correcting the problem.
2) We cannot reset/change to displayed value to the original internal table value (it will only refresh after a save or refresh action). So the user has no visual cue that they've entered a bad value unless they pay close attention.
Running the transaction in SAPGUI, we can force the cursor back to the erroneously cell using "CALL METHOD alv_grid->set_scroll_info_via_id" . This technique does not appear to affect the cursor within the web browser.
After searching SDN forums and SAP documentation it appears that there is no way to programmatically control the ALV Grid active cell within the web browser interface. I'm wondering if the experts can confirm this issue? If that is the way it works within the browser interface could members please suggest "user friendly" approaches to notifying the user of a data entry problem? For example, is POPUP_TO_INFORM to only option? Perhaps there is a JavaScript routine that can enforce the edit format? Please keep in mind that the standard ALV Grid techniques that work in SAPGUI don't necessarily behave the same way in the web browser. I'm most interested in advice regarding the web browser using standalone ITS as it will be another year before we can leverage WebDynPro in this scenario.
Thanks and best regards,
GaryHi Gary,
can you please create a short report which recreates the issue and post the ABAP here. The goal is that webgui and SAPGUI behaves the same way. If they don't we will try to fix it.
Best regards,
Klaus -
Need to display two ALV GRIDs in a single screen
Hi,
I have a question, i'm using version 4.6. I want to display 2 ALVs in a single screen or by calling.
Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2)
Step 2 : Display In a single report
ALV1 report (Editable ,Has to be a GRID)
ALV2 report (Non Editable, Has to be a GRID)
(or)
Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2)
Step 2 :
ALV1 report (Editable ,Has to be a GRID, with a custom button to call ALV2 hiding the ALV1 ie not visible to user)
ALV2 report (Non Editable ,Has to be a GRID, with a custom button to call ALV1 hiding the ALV2 ie not visible to user)
Please help me <b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada GalindoHi
ABAP List Viewer
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
Check the program in the following link:
http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
13. Top-of-page in ALV
selection-screen and top-of-page in ALV
14. ALV Group Heading
http://www.sap-img.com/fu037.htm
How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
15. ALV output to PDF conversion
It has an example code for PDF Conversion.
http://www.erpgenie.com/abap/code/abap51.htm
converting the output of alv in pdf
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
Regards
Anji -
The Visible attribute on alv grid column is not changed after Change Layout
Setup:
I have a program that displays output in an ALV grid (using cl_salv_table).
The ALV grid is displayed within a custom control on a subscreen.
I have 4 subscreens being used on a tabstrip control. So I have 4 ALV grids total (one on each subscreen).
On each ALV grid, I have set the set_layout_change function to true so that the user can hide and unhide columns etc. on each grid via the button on the alv grid toolbar.
I also allow the user to dowload the contents of all 4 grids to excel. To do this I have a custom button that when clicked goes to each ALV grid - gets the column metadata (via cl_salv_columns_table-get() ) and checks the visibility to determine if the column should be downloaded or not (via cl_salv_column-is_visible() ) to excel.
The Problem:
As I said I have 4 grids being displayed via a tab control. Let's say the user is on tab 1 and unhides some columns on the alv grid 1 via the Change Layout... button. And then the user navigates to tab 2. If they click the download button at that point - when the download code is run and it checks the visibility of the columns on alv grid 1 - the changes that were made via the Change Layout... button have not synchronized yet. When I call is_visible() for a column that was unhid it still comes back as false.
The only way I have found to remedy this is to make the user click on a button on the alv grid's toolbar before navigating to a different tab to force the synchronization between the changes made and the backend column metadata. However, this is not the best option and requires training for the user that they have to do this for the download to work correctly.
The Question:
1) why is the Change Layout... button not automatically synchronizing the changes it made to the back end? Is there a way to make it do this?
2) OR, is there a way that I can force the synchronization within the code and not force the user to click a button on the alv grid? If there is a way to force the synchronization - where do I put that code? As far as I can tell, when I switch between tabs - I am unable to catch that action in my PAI events.
Thanks in advance for any help.I was able to resolve this issue with a satisfactory solution.
In my program I had a local class definition to handle the grids' events. When the synchronization wasn't working I only had two events defined: for link_click and added_functions.
I created another definition for event after_salv_function:
on_after_salv_function for event after_salv_function of cl_salv_events importing e_salv_function
There is no code in the method implementation - but adding this event handler now causes a synchronization to occur after the Change Layout is done.
Maybe you are looking for
-
Is there a way to lock or secure imovie and its files
Hello and as always thanks for all the help in my previous posts. I frequently review and edit video that needs to remain secure during the editing process. Before I import it and when I'm done with a project I can secure it in several ways, but whil
-
Panorama and Windows 8.1
Why does panorama no longer function with Windows 8.1
-
OS-X won't restart after iTunes upgrade
Installed the upgrade of iTunes and QT7 last night and now on re boot my system freezes while in the "loading OSX" screen (reminiscent of Windows blue screen of death >:O), and I have to hold to power button to shutdown the system. Haven't seen anyon
-
Hi Friends, I am having a problem with this query. The query is to fetch all the elements for the employees. The elements that need to be fetched are set up in the flex sets. In the table fnd_flex_values there are columns start_date_active and end_da
-
Using UCCHECK during upgrade to ECC 6.0.
We are upgrading from 4.6B to ECC 6.0. I am running UCCHECK to flag unicode errors. We are in the process of correcting these. We are assuming the warning can be ignored and are not mandatory to address. Is his a valid assumption. thx,, J