ALV GRID DATA IDENTIFICATION
Hi all,
I am using FM : REUSE_ALV_GRID_DISPLAY to set up an ALV list.
I have added a button to export the data to a particular format of text as a *.txt document.
I cannot find out how to identify the data that is actually on the screen.
I explain, if I have 5 colums and that I hide 3 of them, when I export to excel, I only get the two remaining colums.
I would like to acheive the same data extraction to send to my txt file.
Has anyone got an idea ?
Nicolas
Nicolas,
The function REUSE_ALV_GRID_LAYOUT_INFO_GET will give you back the modified field catalog with the changes you have done. So the NO_OUT parameter will be set for the fields you have hidden.
Identify those fields and transfer only those fields data into another internal table and export the data.
Regards,
Ravi
Note : please mark the helpful answers
Similar Messages
-
Hi iam getting the alv grid data in excel format but iam facing one problem
hi iam getting the alv grid data in excel format but iam facing one problem ,
i.e., i want it read only but iam getting it in edit mode i use layout default in excel iam getting in xl directly but in edit mode but i need it in read only mode
what i have to do for that and bdy knows reply me i need it urgently.there's always edit-mode if you choose excel-inplace - but noone can modify/rewrite the data
A. -
Reg: Download alv grid data with top of page into excel sheet
Hi All,
I have a selection screen with radio button for download .
If that radio button was selected then the data will download into excel sheet (like if we execute normal ALV grid display from there we can download top-of-page and body as it is).
AOO : 2009P
Fiscal year : 2009
Posting period : 00
Local Currency : USD
CO Area Currency :
Accounting standard:
Sector : 23
BB code Period Value LC Periodic Quantity
AHDKGKAJ 200 0Did not get your question
-
Hi All,
I developed alv grid.I passed data from it_final table into grid.In our it_final table, there is 10 rows and when I execute report then it comes 10 line item.It is perfect. Now I do subtotal in any field.Then In the
grid total 15 line item comming.Now I want that 15 line item should come in a table.eithe it_final or
either any defined table.is it possible?please help me.I want just output alv grid after subtotal(15 lines item) should come in table after pressing in any button.
Thanks,
RakeshYou will have to manually loop at it_final and calculate the subtotal for the fields and append this into the it_final while displaying.
If you r calculating subtotal in sort table by subtos = 'X'. this entry cannot be put into final internal table.
Regards,
Mansi. -
Re: ALV grid date format MM/DD/YYYY
Hi All,
i am craeting report in ALV grid, in that report i want to dispaly date like 'MM/DD/YYYY'. present its display like YYYYMMDD.
can you give me some idea...
Thanks
zeniIf you want to use the date type (this is the easiest way and it will be formatted according to the logon default of the master data of the current user):
1. Be sure you are using a proper date type in the output table.
2. Make sure that the following fields of the field catalog contain the following:
LVC_S_FCAT-DATATYPE = 'DATS'.
LVC_S_FCAT-INTTYPE = 'D'.
LVC_S_FCAT-INTLEN = '000008'.
LVC_S_FCAT-DD_OUTLEN = '000010'.
However if you want to have a more generic approach that is independent on the user master data:
Assuming output_tab-external_date is of type C and has 10 digits.
data: date_int type d value '20080808'.
case date_format.
when 'MM/DD/YYYY'.
write date_int to output_tab-external_date MM/DD/YYYY.
when 'MM/DD/YY'.
write date_int to output_tab-external_date MM/DD/YY.
when 'DD/MM/YYYY'.
write date_int to output_tab-external_date DD/MM/YYYY.
when 'DD/MM/YY'.
write date_int to output_tab-external_date DD/MM/YY.
endcase.
append output_tab.
Then make sure that the following fields of the field catalog contain the following:
LVC_S_FCAT-DATATYPE = 'CHAR'.
LVC_S_FCAT-INTTYPE = 'C'.
LVC_S_FCAT-INTLEN = '000010'.
LVC_S_FCAT-DD_OUTLEN = '000010'. -
Transferring alv grid data to other program
Hi All,
We have two reports, report A is for displaying data using ALV GRID, we want to let user select some lines in A and then click a button to transfer selected records to report B and make relevant select-options value default to the selected records. I tried the statement "IMPORT XXX FROM MEMORY ID XXX" in report B but seems ALV will empty them while switching to new report so I cannot get any result. Because the selection conditions in report A are a bit complex, so I can neither use "SUBMIT A EXPORTING LIST TO MEMORY WITH SEL = 'X' AND RETURN." in report B. Is there any solution?
Thank you!
Best Regards,
JeffSee the example below
REPORT ZTEST.
TYPE-POOLS: SLIS.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: BEGIN OF TA_MARC OCCURS 0 ,
CHBOX(1)." TYPE C.
INCLUDE STRUCTURE MARC.
DATA: END OF TA_MARC.
SELECT *
FROM MARC
INTO CORRESPONDING FIELDS OF TABLE TA_MARC
UP TO 10 ROWS.
DATA: IS_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: I_GRID_SETTINGS TYPE LVC_S_GLAY.
I_GRID_SETTINGS-EDT_CLL_CB = 'X'.
*IS_LAYOUT-box_fieldname = 'CHBOX'.
*IS_LAYOUT-box_tabname = 'TA_MARC'.
*IS_LAYOUT-edit = 'X'.
WA_FIELDCAT-SELTEXT_L = 'Check'.
WA_FIELDCAT-FIELDNAME = 'CHBOX'.
WA_FIELDCAT-CHECKBOX = 'X'.
WA_FIELDCAT-EDIT = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT .
WA_FIELDCAT-SELTEXT_L = 'Material'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
*WA_FIELDCAT-edit = 'X'. If U want to Make Material as Editable Field
APPEND WA_FIELDCAT TO IT_FIELDCAT.
WA_FIELDCAT-SELTEXT_L = 'Plant'.
WA_FIELDCAT-FIELDNAME = 'WERKS'.
WA_FIELDCAT-EDIT = ''.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
IS_LAYOUT = IS_LAYOUT
I_GRID_SETTINGS = I_GRID_SETTINGS
TABLES
T_OUTTAB = TA_MARC.
*& Form USER_COMMAND
* text
* -->R_UCOMM text
* -->R_SELFIELD text
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
R_SELFIELD TYPE SLIS_SELFIELD.
RANGES : MATNR FOR MARA-MATNR.
LOOP AT TA_MARC WHERE CHBOX = 'X'.
MATNR-SIGN = 'I'.
MATNR-OPTION = 'EQ'.
MATNR-LOW = TA_MARC-MATNR.
MATNR-HIGH = ''.
APPEND MATNR.
ENDLOOP.
SUBMIT ZTEST1 VIA SELECTION-SCREEN WITH MATNR IN MATNR and RETURN.
ENDFORM. "USER_COMMAND
When u will select rows in ZTEST ALV and press submit button data will pass to ZTEST1 on selection screen.
REPORT ztest1.
tables: mara.
select-OPTIONS: matnr for mara-matnr.
BREAK-POINT.
Hope u are looking for same.
Thanks,
Suyog. -
ALV Grid data transfer to Exel
Hallo,
When I transfer data from ALV-Grid to Exel then the summation row is not considerd or it is not there.What can I do that
summation row also in EXEL appears.
regards
ranaCheck Mr. Naimesh Patel's blog for it [here >>>|http://help-abap.blogspot.com/2008/09/preserve-downloaded-data-formatting-in.html]
-
Hello;
i am using fm REUSE_ALV_GRID (not OO) to display an internal table. The user wants to change the data in a certain cell. I have marked this cell as editable and it works fine. I want to learn what to check in the event of data_changed. I have added this event in table ALV_EVENTS and directed to a subroutine. What parameters should i pass to the subroutine and what should i check to read the relevant line? Is it possible to control changes in more than one line?
Thx
Ali<i>Is it possible to control changes in more than one line?</i>
yes.
for usage of the method, and editable grid please refer the sample code.
REPORT ZTESTDFALV1 .
*Data Declaration
DATA: BEGIN OF T_EKKO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
END OF T_EKKO.
DATA: BEGIN OF IT_EKKO OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_EKKO.
DATA: BEGIN OF IT_BACKUP OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_BACKUP.
*ALV data declarations
TYPE-POOLS: SLIS. "ALV Declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID LIKE SY-REPID.
*Start-of-selection.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
IT_BACKUP[] = IT_EKKO[].
PERFORM DISPLAY_ALV_REPORT.
*& Form build_fieldcatalog
* text
FORM BUILD_FIELDCATALOG.
REFRESH FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELN'.
FIELDCATALOG-SELTEXT_M = 'Purchase Order'.
FIELDCATALOG-INPUT = 'X'.
FIELDCATALOG-EDIT = 'X'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELP'.
FIELDCATALOG-SELTEXT_M = 'PO Item'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM BUILD_LAYOUT.
"Permet d'ajuster les colonnes au text
* gd_layout-colwidth_optimize = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
* gd_layout-box_fieldname = 'SELECT'.
* gd_layout-box_tabname = 'IT_EKKO'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
FORM DISPLAY_ALV_REPORT.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
* i_callback_top_of_page = 'TOP-OF-PAGE'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* i_grid_title = 'My Title'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE:/ SY-SUBRC.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP
UP TO 10 ROWS
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.
ENDFORM. " DATA_RETRIEVAL
* FORM SET_PF_STATUS *
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD_FULLSCREEN1' EXCLUDING RT_EXTAB.
ENDFORM. "set_pf_status
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
<b>DATA: GD_REPID LIKE SY-REPID, "Exists
REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new
*then insert the following code in your USER_COMMAND routine...
IF REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF_GRID.
ENDIF.
IF NOT REF_GRID IS INITIAL.
CALL METHOD REF_GRID->CHECK_CHANGED_DATA
ENDIF.</b>
CASE R_UCOMM.
WHEN '&IC1'.
CHECK RS_SELFIELD-TABINDEX > 0.
IF RS_SELFIELD-VALUE EQ '6000000001'.
CALL TRANSACTION 'ZDF2'.
ENDIF.
WHEN 'ENTER'.
READ TABLE IT_EKKO INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
READ TABLE IT_BACKUP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
IF IT_EKKO <> IT_BACKUP.
* then do your check
ENDIF.
ENDIF.
ENDIF.
PERFORM DATA_RETRIEVAL.
RS_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM. "user_command
Regards
Vijay -
i wanted to write all data on grid to a txt file at the end of to program. this is my code. not all program but considered parts.
Regrads.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_background_id = 'ALV_BACKGROUND'
i_buffer_active = 'X'
i_callback_program = g_repid
it_fieldcat = it_fieldcat
is_layout = gs_layout
i_save = g_save
is_variant = gs_variant
it_events = gt_events[]
TABLES
t_outtab = it_vbak
EXCEPTIONS
program_error = 1
OTHERS = 2.
PERFORM save_file.
FORM save_file.
DATA: iv_filename TYPE string,
iv_vbak1 TYPE TABLE OF vbak.
iv_filename = 'C:\test\data1.txt'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = iv_filename
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = it_fieldcat.
ENDFORM. " save_fileHi,
Pls look into below code
TYPE-POOLS: slis,vrm.
TABLES:vbak,vbrk,vbrp.
TYPES:BEGIN OF gty_vbakvbap,
vbeln TYPE vbak-vbeln,
vkorg TYPE vbak-vkorg,
audat TYPE vbak-audat,
auart TYPE vbak-auart,
kunnr TYPE vbak-kunnr,
posnr TYPE vbap-posnr,
matnr TYPE vbap-matnr,
matkl TYPE vbap-matkl,
kwmeng TYPE vbap-kwmeng,
END OF gty_vbakvbap,
gty_t_vbakvbap TYPE TABLE OF gty_vbakvbap.
TYPES:BEGIN OF gty_kna1,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
END OF gty_kna1,
gty_t_kna1 TYPE TABLE OF gty_kna1.
TYPES : BEGIN OF gty_vbrkvbrp,
vbeln TYPE vbrk-vbeln,
bukrs TYPE vbrk-bukrs,
vkorg TYPE vbrk-vkorg,
vtweg TYPE vbrk-vtweg,
fkdat TYPE vbrk-fkdat,
posnr TYPE vbrp-posnr,
werks TYPE vbrp-werks,
END OF gty_vbrkvbrp,
gty_t_vbrkvbrp TYPE TABLE OF gty_vbrkvbrp.
TYPES:BEGIN OF gty_final,
vbeln TYPE vbak-vbeln,
vkorg TYPE vbak-vkorg,
audat TYPE vbak-audat,
auart TYPE vbak-auart,
kunnr TYPE vbak-kunnr,
posnr TYPE vbap-posnr,
matnr TYPE vbap-matnr,
matkl TYPE vbap-matkl,
kwmeng TYPE vbap-kwmeng,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
bukrs TYPE vbrk-bukrs,
fkdat TYPE vbrk-fkdat,
vtweg TYPE vbrk-vtweg,
werks TYPE vbrp-werks,
END OF gty_final,
gty_t_final TYPE TABLE OF gty_final.
TYPES:BEGIN OF gty_header,
vbeln(15) TYPE c,
vkorg(10) TYPE c,
audat(15) TYPE c,
auart(15) TYPE c,
kunnr(15) TYPE c,
posnr(10) TYPE c,
matnr(15) TYPE c,
matkl(10) TYPE c,
kwmeng(10) TYPE c,
land1(10) TYPE c,
name1(10) TYPE c,
ort01(10) TYPE c,
END OF gty_header,
gty_t_header TYPE TABLE OF gty_header.
TYPES : t_document_data TYPE sodocchgi1,
t_packing_list TYPE sopcklsti1,
t_attachment TYPE solisti1,
t_body_msg TYPE solisti1,
t_receivers TYPE somlreci1.
DATA: w_document_data TYPE t_document_data,
w_packing_list TYPE t_packing_list,
w_attachment TYPE t_attachment,
w_body_msg TYPE t_body_msg,
w_receivers TYPE t_receivers,
e(10) TYPE c.
DATA: i_document_data TYPE TABLE OF t_document_data,
i_packing_list TYPE TABLE OF t_packing_list,
i_attachment TYPE TABLE OF t_attachment,
i_body_msg TYPE TABLE OF t_body_msg,
i_receivers TYPE TABLE OF t_receivers.
DATA: e_mail TYPE somlreci1-receiver,
date(10) TYPE c,
time(8) TYPE c,
dd(2) TYPE c,
mm(2) TYPE c,
yy(4) TYPE c,
h(2) TYPE c,
m(2) TYPE c,
s(2) TYPE c,
orders(10) TYPE c VALUE 'C:\Orders',
gt_list TYPE vrm_values,
gw_list TYPE vrm_value,
gt_values TYPE TABLE OF dynpread,
gw_values TYPE dynpread,
gv_selected_value(10) TYPE c,
g_tab_lines TYPE i,
r_ucomm TYPE sy-ucomm,
* Sub total based on the header details Sales order no. vbeln = 5006.
gt_sort TYPE slis_t_sortinfo_alv,
gw_sort TYPE slis_sortinfo_alv.
DATA : gv_qty TYPE string.
DATA : gt_vbakvbap TYPE gty_t_vbakvbap,
gw_vbakvbap TYPE gty_vbakvbap,
gt_kna1 TYPE gty_t_kna1,
gw_kna1 TYPE gty_kna1,
gt_vbrkvbrp TYPE gty_t_vbrkvbrp,
gw_vbrkvbrp TYPE gty_vbrkvbrp,
gt_final TYPE gty_t_final,
gw_final TYPE gty_final,
gt_fcat TYPE slis_t_fieldcat_alv,
gw_fcat TYPE slis_fieldcat_alv,
tab TYPE TABLE OF gty_final.
data zbomrnd.
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-010.
SELECT-OPTIONS: s_fkdat FOR vbrk-fkdat,
s_bukrs FOR vbrk-bukrs,
s_vkorg FOR vbak-vkorg,
s_vtweg FOR vbak-vtweg,
s_werks FOR vbrp-werks,
s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN END OF BLOCK blk.
SELECTION-SCREEN BEGIN OF BLOCK selscr WITH FRAME TITLE text-001.
PARAMETERS: p_rad1 RADIOBUTTON GROUP rad1 USER-COMMAND a ,
p_rad2 RADIOBUTTON GROUP rad1 .
*-- Selection Screen for radio button 2
SELECTION-SCREEN BEGIN OF BLOCK rad2 WITH FRAME TITLE text-001.
PARAMETERS:p_file TYPE ibipparms-path MODIF ID one ,
p_type(4) TYPE c AS LISTBOX VISIBLE LENGTH 20 MODIF ID one.
SELECTION-SCREEN END OF BLOCK rad2.
PARAMETERS: p_rad3 RADIOBUTTON GROUP rad1.
*-- Selection Screen for radio button 3
SELECTION-SCREEN BEGIN OF BLOCK rad3 WITH FRAME TITLE text-030.
SELECT-OPTIONS : mail_id FOR e_mail NO INTERVALS MODIF ID two .
SELECTION-SCREEN END OF BLOCK rad3.
PARAMETERS:p_rad4 RADIOBUTTON GROUP rad1.
*-- Selection Screen for radio button 4
SELECTION-SCREEN BEGIN OF BLOCK rad4 WITH FRAME TITLE text-004.
PARAMETERS: p_path TYPE rlgrap-filename MODIF ID tri.
SELECTION-SCREEN END OF BLOCK rad4.
SELECTION-SCREEN END OF BLOCK selscr.
INITIALIZATION.
LOOP AT SCREEN.
IF screen-group1 = 'TWO' OR
screen-group1 = 'TRI'.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
date = sy-datum.
time = sy-uzeit.
yy = date+0(4).
mm = date+4(2).
dd = date+6(2).
h = time+0(2).
m = time+2(2).
s = time+4(2).
date+0(2) = dd.
date+2(1) = '-'.
date+3(2) = mm.
date+5(1) = '-'.
date+6(4) = yy.
time+0(2) = h.
time+2(1) = '.'.
time+3(2) = m.
time+5(1) = '.'.
time+6(2) = s.
CONCATENATE orders date time INTO p_file SEPARATED BY '_'.
LOOP AT SCREEN.
IF screen-group1 = 'ONE' OR
screen-group1 = 'TWO' OR
screen-group1 = 'TRI'.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
gw_list-key = '.TXT'.
gw_list-text = 'TXT'.
APPEND gw_list TO gt_list.
gw_list-key = '.CSV'.
gw_list-text = 'CSV'.
APPEND gw_list TO gt_list.
gw_list-key = '.XLS'.
gw_list-text = 'XLS'.
APPEND gw_list TO gt_list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_TYPE'
values = gt_list.
EXPORT tab TO MEMORY ID 'MESSAGE'.
AT SELECTION-SCREEN OUTPUT.
CASE 'X'.
WHEN p_rad1 .
LOOP AT SCREEN.
IF screen-group1 = 'ONE' OR
screen-group1 = 'TWO' OR
screen-group1 = 'TRI'.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN p_rad2.
LOOP AT SCREEN.
IF screen-group1 = 'TWO' OR
screen-group1 = 'TRI'.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN p_rad3.
LOOP AT SCREEN.
IF screen-group1 = 'ONE' OR
screen-group1 = 'TRI'.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN p_rad4.
LOOP AT SCREEN.
IF screen-group1 = 'ONE' OR
screen-group1 = 'TWO'.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDCASE.
AT SELECTION-SCREEN ON p_type.
CLEAR : gw_values,gt_values.
REFRESH gt_values.
gw_values-fieldname = 'P_TYPE'.
APPEND gw_values TO gt_values.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
translate_to_upper = 'X '
TABLES
dynpfields = gt_values.
READ TABLE gt_values INDEX 1 INTO gw_values.
IF sy-subrc = 0 AND gw_values-fieldvalue IS NOT INITIAL.
READ TABLE gt_list INTO gw_list WITH KEY key = gw_values-fieldvalue.
IF sy-subrc = 0.
gv_selected_value = gw_list-text.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE '
IMPORTING
file_name = p_file.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_PATH'
IMPORTING
file_name = p_path.
START-OF-SELECTION.
CONCATENATE p_file p_type INTO p_file .
PERFORM f_fetch_vbakvbap.
PERFORM f_fetch_kna1.
PERFORM f_fetch_vbrk.
SORT BY gt_kna1.
PERFORM f_fill_final.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = sy-tabix
TEXT = 'Extracting Data From Tables'.
END-OF-SELECTION.
CASE 'X'.
WHEN p_rad1.
IF gt_final IS NOT INITIAL.
PERFORM f_fill_fcat.
PERFORM f_display_alv.
ELSE.
MESSAGE 'No records exists for the selection' TYPE 'I'.
ENDIF.
WHEN p_rad2.
IF p_type = ''.
MESSAGE 'Enter the File Type' TYPE 'I'.
EXPORT tab TO MEMORY ID 'MESSAGE'.
ELSE.
PERFORM f_gui_download.
ENDIF.
WHEN p_rad3.
IF mail_id = ''.
MESSAGE ' Enter the Email ID' TYPE 'I'.
ELSE.
PERFORM f_email.
ENDIF.
WHEN OTHERS.
IF p_path = ''.
MESSAGE 'Enter the Path' TYPE 'I'.
ENDIF.
ENDCASE.
*& Form f_fetch_vbakvbap
* text
FORM f_fetch_vbakvbap .
SELECT vbak~vbeln vbak~vkorg vbak~audat vbak~auart vbak~kunnr
vbap~posnr vbap~matnr vbap~matkl vbap~kwmeng
INTO TABLE gt_vbakvbap
FROM vbak
INNER JOIN vbap
ON vbak~vbeln = vbap~vbeln
WHERE vbak~vtweg IN s_vtweg
AND vbak~vkorg IN s_vkorg
AND vbak~vbeln IN s_vbeln.
ENDFORM. "f_fetch_vbakvbap
*& Form f_fetch_kna1
* text
FORM f_fetch_kna1 .
IF NOT gt_vbakvbap[] IS INITIAL.
SELECT kunnr land1 name1 ort01
INTO TABLE gt_kna1
FROM kna1
FOR ALL ENTRIES IN gt_vbakvbap
WHERE kunnr = gt_vbakvbap-kunnr.
ENDIF.
ENDFORM. "f_fetch_kna1
*& Form f_fetch_vbrk
* text
FORM f_fetch_vbrk .
IF gt_vbakvbap[] IS NOT INITIAL.
SELECT vbrk~vbeln vbrk~bukrs vbrk~vkorg vbrk~vtweg vbrk~fkdat vbrp~posnr vbrp~werks
INTO TABLE gt_vbrkvbrp
FROM vbrk
INNER JOIN vbrp
ON vbrk~vbeln = vbrp~vbeln
WHERE fkdat IN s_fkdat
AND bukrs IN s_bukrs
AND werks IN s_werks
AND vtweg IN s_vtweg.
ENDIF.
ENDFORM. " f_fetch_vbrk
*& Form f_fetch_vbrp
* text
* --> p1 text
* <-- p2 text
*& Form f_fill_final
* text
FORM f_fill_final .
CLEAR :gv_qty.
LOOP AT gt_vbakvbap INTO gw_vbakvbap.
MOVE : gw_vbakvbap-vbeln TO gw_final-vbeln,
gw_vbakvbap-vkorg TO gw_final-vkorg,
gw_vbakvbap-audat TO gw_final-audat,
gw_vbakvbap-auart TO gw_final-auart,
gw_vbakvbap-kunnr TO gw_final-kunnr,
gw_vbakvbap-posnr TO gw_final-posnr,
gw_vbakvbap-matnr TO gw_final-matnr,
gw_vbakvbap-matkl TO gw_final-matkl,
gw_vbakvbap-kwmeng TO gw_final-kwmeng.
gv_qty = gv_qty + gw_final-kwmeng.
READ TABLE gt_kna1 INTO gw_kna1 WITH KEY kunnr = gw_vbakvbap-kunnr BINARY SEARCH.
IF sy-subrc = 0.
MOVE: gw_kna1-name1 TO gw_final-name1,
gw_kna1-land1 TO gw_final-land1,
gw_kna1-ort01 TO gw_final-ort01.
ENDIF.
READ TABLE gt_vbrkvbrp INTO gw_vbrkvbrp WITH KEY vkorg = gw_vbakvbap-vkorg.
IF sy-subrc = 0.
MOVE: gw_vbrkvbrp-fkdat TO gw_final-fkdat,
gw_vbrkvbrp-bukrs TO gw_final-bukrs,
gw_vbrkvbrp-vtweg TO gw_final-vtweg,
gw_vbrkvbrp-werks TO gw_final-werks.
ENDIF.
APPEND gw_final TO gt_final.
CLEAR gw_final.
ENDLOOP.
ENDFORM. "f_fill_final
*& Form f_fill_fcat
* text
FORM f_fill_fcat .
gw_fcat-fieldname = 'VBELN'.
gw_fcat-tabname = 'GT_FINAL'.
gw_fcat-seltext_m = 'Sales Order'.
APPEND gw_fcat TO gt_fcat.
CLEAR gw_fcat.
gw_fcat-fieldname = 'VKORG'.
gw_fcat-tabname = 'GT_FINAL'.
gw_fcat-seltext_m = 'Sales Org.'.
APPEND gw_fcat TO gt_fcat.
CLEAR gw_fcat.
gw_fcat-fieldname = 'VTWEG'.
gw_fcat-tabname = 'GT_FINAL'.
gw_fcat-seltext_m = 'Distribution Channel'.
APPEND gw_fcat TO gt_fcat.
CLEAR gw_fcat.
gw_fcat-fieldname = 'AUDAT'.
gw_fcat-tabname = 'GT_FINAL'.
gw_fcat-seltext_m = 'Document Date'.
APPEND gw_fcat TO gt_fcat.
CLEAR gw_fcat.
gw_fcat-fieldname = 'AUART'.
gw_fcat-tabname = 'GT_FINAL'.
gw_fcat-seltext_m = 'Document Type'.
APPEND gw_fcat TO gt_fcat. -
hey,
alv grid method for export data from alv grid to itab.
regards,
purnaHey,
Any methods for exporting alv grid data into itab. -
Problem: User has problems to export ALV Grid to Excel...
Hello experts,
I have a very strange problem with an single user: when she tries to export ALV Grid data from SAP into Excel by List/Export/Spreadsheet, she's only able to export this to an xml-based file on her local client, every other user gets the popup to choose the spreadsheet format (XXL...).
What I did so far:
- Look up Excel Makro Security --> the same as on other desktops
- SAP GUI Patch Level --> the same as on other desktops
- Test with an different user on her desktop on SAP Report S_ALR_87012284 --> it worked perfectly
- User parameters are the same as for the test user
- Security regarding ALV is the same (S_GUI ACTVT = 61...)
Has there ever been a similar problem to anyone else?
Many thanks in advance for your feedback!Hi ,
This problem looks very weired. Just try running that FM from SE37 from the same system and see that what is happening there.... if the problem is similar then it is not the problem of your report and some patch may be missing in that system. -
Reg : ALV Grid Refresh - Output not appearing
Hi All ,
Am calling a screen 100 at 3 different places.
Though i use refresh_table_display , The value in the output table, say i_final changes, but while displaying the output , the whole screen is blank , even the container is not appearing in the output .
Can you please help me with your inputs .
Regards,
Chitrayes it is good ...see the example...for your requirement..
REPORT yztest .
TYPE-POOLS: slis.
Tables
TABLES: mara.
TYPES: BEGIN OF ty_name,
name TYPE char10,
age TYPE i,
END OF ty_name.
TYPES: BEGIN OF ty_marks,
sub1 TYPE i,
sub2 TYPE i,
total TYPE i,
END OF ty_marks.
TYPES: BEGIN OF ty_phone,
phnum TYPE char10,
END OF ty_phone.
TYPES: BEGIN OF ty_addr,
address TYPE char20,
END OF ty_addr .
Output internal table
DATA: itab TYPE TABLE OF ty_name,
wa TYPE ty_name,
itab1 TYPE TABLE OF ty_marks,
wa1 TYPE ty_marks,
itab2 TYPE TABLE OF ty_phone,
wa2 TYPE ty_phone,
itab3 TYPE TABLE OF ty_addr,
wa3 TYPE ty_addr.
ALV Grid
DATA: r_grid TYPE REF TO cl_gui_alv_grid,
r_grid1 TYPE REF TO cl_gui_alv_grid,
r_grid2 TYPE REF TO cl_gui_alv_grid,
r_grid3 TYPE REF TO cl_gui_alv_grid,
g_dock TYPE REF TO cl_gui_docking_container,
g_dock1 TYPE REF TO cl_gui_docking_container,
g_dock2 TYPE REF TO cl_gui_docking_container,
g_dock3 TYPE REF TO cl_gui_docking_container,
g_dock4 TYPE REF TO cl_gui_docking_container,
it_fieldcat TYPE lvc_t_fcat,
it_fieldcat1 TYPE lvc_t_fcat,
it_fieldcat2 TYPE lvc_t_fcat,
it_fieldcat3 TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA picture TYPE REF TO cl_gui_picture.
DATA url(255).
CLEAR url.
DATA init.
START-OF-SELECTION.
wa-name = 'test01'.
wa-age = '1'.
APPEND wa TO itab.
wa-name = 'test02'.
wa-age = '2'.
APPEND wa TO itab.
wa-name = 'test03'.
wa-age = '3'.
APPEND wa TO itab.
wa1-sub1 = '11'.
wa1-sub2 = '22'.
wa1-total = wa1-sub1 + wa1-sub2.
APPEND wa1 TO itab1.
wa1-sub1 = '22'.
wa1-sub2 = '33'.
wa1-total = wa1-sub1 + wa1-sub2.
APPEND wa1 TO itab1.
wa2-phnum = '99999999999'.
APPEND wa2 TO itab2.
wa2-phnum = '888888888888'.
APPEND wa2 TO itab2.
wa2-phnum = '777777777777'.
APPEND wa2 TO itab2.
wa3-address = 'HItech City'.
APPEND wa3 TO itab3.
wa3-address = 'Secunderabad'.
APPEND wa3 TO itab3.
wa3-address = 'Hyderabad'.
APPEND wa3 TO itab3.
PERFORM display_image.
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'LISTOUT1'.
SET TITLEBAR 'LIST1'.
wa_fieldcat-fieldname = 'NAME'.
wa_fieldcat-seltext = 'NAME OF THE STUDENT'.
wa_fieldcat-coltext = 'NAME OF THE STUDENT'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AGE'.
wa_fieldcat-seltext = 'AGE OF THE STUDENT'.
wa_fieldcat-coltext = 'AGE OF THE STUDENT'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'SUB1'.
wa_fieldcat-seltext = 'SUBJECT1'.
wa_fieldcat-coltext = 'SUBJECT1'.
APPEND wa_fieldcat TO it_fieldcat1.
wa_fieldcat-fieldname = 'SUB2'.
wa_fieldcat-seltext = 'SUBJECT2'.
wa_fieldcat-coltext = 'SUBJECT2'.
APPEND wa_fieldcat TO it_fieldcat1.
wa_fieldcat-fieldname = 'TOTAL'.
wa_fieldcat-seltext = 'TOTAL'.
wa_fieldcat-coltext = 'TOTAL'.
APPEND wa_fieldcat TO it_fieldcat1.
wa_fieldcat-fieldname = 'PHNUM'.
wa_fieldcat-seltext = 'PHONE NO'.
wa_fieldcat-coltext = 'PHONE NO'.
APPEND wa_fieldcat TO it_fieldcat2.
wa_fieldcat-fieldname = 'ADDRESS'.
wa_fieldcat-seltext = 'ADDRESS'.
wa_fieldcat-coltext = 'ADDRESS'.
APPEND wa_fieldcat TO it_fieldcat3.
IF g_dock IS INITIAL.
CREATE OBJECT g_dock
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = g_dock->dock_at_left
extension = 300.
CREATE OBJECT r_grid
EXPORTING
i_parent = g_dock.
ENDIF.
IF g_dock1 IS INITIAL.
CREATE OBJECT g_dock1
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = g_dock1->dock_at_right
extension = 300.
CREATE OBJECT r_grid1
EXPORTING
i_parent = g_dock1.
ENDIF.
IF g_dock2 IS INITIAL.
CREATE OBJECT g_dock2
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = g_dock2->dock_at_top
extension = 100.
CREATE OBJECT r_grid2
EXPORTING
i_parent = g_dock2.
IF g_dock3 IS INITIAL.
CREATE OBJECT g_dock3
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = g_dock3->dock_at_top
extension = 100.
CREATE OBJECT r_grid3
EXPORTING
i_parent = g_dock3.
ENDIF.
IF NOT itab[] IS INITIAL.
CALL METHOD r_grid->set_table_for_first_display
CHANGING
it_outtab = itab
it_fieldcatalog = it_fieldcat.
ENDIF.
IF NOT itab1[] IS INITIAL.
CALL METHOD r_grid1->set_table_for_first_display
CHANGING
it_outtab = itab1
it_fieldcatalog = it_fieldcat1.
ENDIF.
IF NOT itab2[] IS INITIAL.
CALL METHOD r_grid2->set_table_for_first_display
CHANGING
it_outtab = itab2
it_fieldcatalog = it_fieldcat2.
ENDIF.
IF NOT itab3[] IS INITIAL.
CALL METHOD r_grid3->set_table_for_first_display
CHANGING
it_outtab = itab3
it_fieldcatalog = it_fieldcat3.
ENDIF.
if g_dock4 is initial.
CREATE OBJECT g_dock4
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = g_dock4->dock_at_bottom
extension = 100.
CREATE OBJECT picture
EXPORTING parent = g_dock4.
CALL METHOD picture->load_picture_from_url
EXPORTING
url = url.
init = 'X'.
endif.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form display_image
FORM display_image .
DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE.
DATA html_table LIKE w3html OCCURS 1.
DATA return_code LIKE w3param-ret_code.
DATA content_type LIKE w3param-cont_type.
DATA content_length LIKE w3param-cont_len.
DATA pic_data LIKE w3mime OCCURS 0.
DATA pic_size TYPE i.
REFRESH query_table.
query_table-name = '_OBJECT_ID'.
query_table-value = 'ENJOYSAP_LOGO'.
APPEND query_table.
CALL FUNCTION 'WWW_GET_MIME_OBJECT'
TABLES
query_string = query_table
html = html_table
mime = pic_data
CHANGING
return_code = return_code
content_type = content_type
content_length = content_length
EXCEPTIONS
object_not_found = 1
parameter_not_found = 2
OTHERS = 3.
IF sy-subrc = 0.
pic_size = content_length.
ENDIF.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image'
subtype = cndp_sap_tab_unknown
size = pic_size
lifetime = cndp_lifetime_transaction
TABLES
data = pic_data
CHANGING
url = url
EXCEPTIONS
OTHERS = 1.
ENDFORM. " display_image
*& Module EXIT INPUT
text
MODULE exit INPUT.
CALL METHOD g_dock->free.
CALL METHOD g_dock1->free.
CALL METHOD g_dock2->free.
CALL METHOD g_dock3->free.
ENDMODULE. " EXIT INPUT -
ALV OO and refreshing the ALV grid
Hi,
i have some problems with my ALV 00 program.
On screen 1 i have to fill in a material number.
For that material i'm getting some data and show in screen 2 in a ALV grid.
Via BACK-button i'm getting back to screen 1 and can fill in another material number.
But the 2nd (and 3rd, etc) time i fill a material, the ALV grid data from material 1 is shown. Even if the internal table I_ALV where the data is, is changed.
What should i do ?
I have initialized the customer container and the grid, but that didn't solved the problem.
regards,
HansHi,
Try clearing and refreshing the alv grid data table in screen 2.
Check with this code. this code is working fine. If we go back and change the input, it is showing the output corresponding to the second input only.
Have you use this method?
<b> GR_ALVGRID->REFRESH_TABLE_DISPLAY</b>
TYPE-POOLS : SLIS.
* Tables *
TABLES:
VBRK,
VBRP.
* Parameters and select options OR SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
S_VBELN FOR VBRK-VBELN.
SELECTION-SCREEN END OF BLOCK B1.
* Internal Tables *
* work areas
DATA: BEGIN OF IT_VBRP OCCURS 0,
VBELN LIKE VBRK-VBELN,
POSNR LIKE VBRP-POSNR,
UEPOS LIKE VBRP-UEPOS,
FKIMG LIKE VBRP-FKIMG,
NETWR LIKE VBRP-NETWR,
MEINS LIKE VBRP-MEINS.
DATA : END OF IT_VBRP.
* Variables *
DATA : GR_ALVGRID TYPE REF TO CL_GUI_ALV_GRID,
GC_CUSTOM_CONTROL_NAME TYPE SCRFNAME VALUE 'CC_ALV',
GR_CCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GT_FIELDCAT TYPE LVC_T_FCAT,
GS_LAYOUT TYPE LVC_S_LAYO,
V_FLAG VALUE 'X'.
* Start of Program *
* INITIALIZATION. *
INITIALIZATION.
S_VBELN-LOW = 1.
S_VBELN-HIGH = 1000000000.
S_VBELN-OPTION = 'EQ'.
S_VBELN-SIGN = 'I'.
APPEND S_VBELN.
* SELECTION-SCREEN *
AT SELECTION-SCREEN.
PERFORM VALIDATION.
* START-OF-SELECTION *
START-OF-SELECTION.
PERFORM GET_DATA.
CALL SCREEN 0100.
* END-OF-SELECTION *
END-OF-SELECTION.
* TOP-OF-PAGE *
TOP-OF-PAGE.
* END-OF-PAGE *
END-OF-PAGE.
* AT USER-COMMAND *
*& Form VALIDATION
* text
* --> p1 text
* <-- p2 text
FORM VALIDATION .
SELECT SINGLE VBELN
FROM VBRK
INTO VBRK-VBELN
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'no billing documents found'.
ENDIF.
ENDFORM. " VALIDATION
*& Form GET_DATA
* text
* --> p1 text
* <-- p2 text
FORM GET_DATA .
SELECT VBELN
POSNR
UEPOS
FKIMG
NETWR
MEINS
FROM VBRP
INTO TABLE IT_VBRP
WHERE VBELN IN S_VBELN.
ENDFORM. " GET_DATA
*& Module DISPLAY_ALV OUTPUT
* text
MODULE DISPLAY_ALV OUTPUT.
IF V_FLAG = 'X'.
PERFORM DISPLAY_ALV.
PERFORM PREPARE_FIELD_CATALOG CHANGING GT_FIELDCAT.
PERFORM PREPARE_LAYOUT CHANGING GS_LAYOUT.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'VBRP'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
IS_LAYOUT = GS_LAYOUT
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB = IT_VBRP[]
IT_FIELDCATALOG = GT_FIELDCAT
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ELSE.
<b>CALL METHOD GR_ALVGRID->REFRESH_TABLE_DISPLAY
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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>
ENDIF.
CLEAR V_FLAG.
ENDIF.
ENDMODULE. " DISPLAY_ALV OUTPUT
*& Form DISPLAY_ALV
* text
* --> p1 text
* <-- p2 text
FORM DISPLAY_ALV .
IF GR_ALVGRID IS INITIAL.
CREATE OBJECT GR_ALVGRID
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
I_PARENT = GR_CCONTAINER
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM. " DISPLAY_ALV
*& Form PREPARE_FIELD_CATALOG
* text
* <--P_GT_FIELDCAT text
FORM PREPARE_FIELD_CATALOG CHANGING P_GT_FIELDCAT TYPE LVC_T_FCAT.
DATA : LS_FCAT TYPE LVC_S_FCAT,
L_POS TYPE I.
L_POS = L_POS + 1.
LS_FCAT-FIELDNAME = 'VBELN'.
LS_FCAT-TABNAME = 'IT_VBRP'.
LS_FCAT-COL_POS = L_POS.
LS_FCAT-SCRTEXT_M = 'Billing Document'.
LS_FCAT-OUTPUTLEN = '10'.
APPEND LS_FCAT TO P_GT_FIELDCAT.
CLEAR LS_FCAT.
L_POS = L_POS + 1.
LS_FCAT-FIELDNAME = 'POSNR'.
LS_FCAT-TABNAME = 'IT_VBRP'.
LS_FCAT-COL_POS = L_POS.
LS_FCAT-SCRTEXT_M = 'Billing Item'.
LS_FCAT-OUTPUTLEN = '6'.
APPEND LS_FCAT TO P_GT_FIELDCAT.
CLEAR LS_FCAT.
L_POS = L_POS + 1.
LS_FCAT-FIELDNAME = 'UEPOS'.
LS_FCAT-TABNAME = 'IT_VBRP'.
LS_FCAT-COL_POS = L_POS.
LS_FCAT-SCRTEXT_M = 'Higher Level Item'.
LS_FCAT-OUTPUTLEN = '6'.
APPEND LS_FCAT TO P_GT_FIELDCAT.
CLEAR LS_FCAT.
L_POS = L_POS + 1.
LS_FCAT-FIELDNAME = 'FKIMG'.
LS_FCAT-TABNAME = 'IT_VBRP'.
LS_FCAT-COL_POS = L_POS.
LS_FCAT-SCRTEXT_M = 'Invoice Quantity'.
LS_FCAT-OUTPUTLEN = '13'.
APPEND LS_FCAT TO P_GT_FIELDCAT.
CLEAR LS_FCAT.
L_POS = L_POS + 1.
LS_FCAT-FIELDNAME = 'NETWR'.
LS_FCAT-TABNAME = 'IT_VBRP'.
LS_FCAT-COL_POS = L_POS.
LS_FCAT-SCRTEXT_M = 'Net Value'.
LS_FCAT-OUTPUTLEN = '15'.
APPEND LS_FCAT TO P_GT_FIELDCAT.
CLEAR LS_FCAT.
L_POS = L_POS + 1.
LS_FCAT-FIELDNAME = 'MEINS'.
LS_FCAT-TABNAME = 'IT_VBRP'.
LS_FCAT-COL_POS = L_POS.
LS_FCAT-SCRTEXT_M = 'Unit of Measure'.
LS_FCAT-OUTPUTLEN = '3'.
APPEND LS_FCAT TO P_GT_FIELDCAT.
CLEAR LS_FCAT.
L_POS = L_POS + 1.
ENDFORM. " PREPARE_FIELD_CATALOG
*& Form PREPARE_LAYOUT
* text
* <--P_GS_LAYOUT text
FORM PREPARE_LAYOUT CHANGING P_GS_LAYOUT TYPE LVC_S_LAYO.
P_GS_LAYOUT-ZEBRA = 'X'.
P_GS_LAYOUT-GRID_TITLE = 'INVOICE DETAILS'.
P_GS_LAYOUT-SMALLTITLE = 'X'.
P_GS_LAYOUT-EDIT = 'X'.
ENDFORM. " PREPARE_LAYOUT
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'CANCEL'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
CALL TRANSACTION 'SE38'.
WHEN 'CHANGE'.
IF GR_ALVGRID->IS_READY_FOR_INPUT( ) = 0.
CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ELSE.
CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 0.
ENDIF.
ENDCASE.
Regards,
Aswin -
Hi Experts,
I am working on ALV Grid , Data is Displayed in Grid well , But Can Any one please tell me how can i capture the event (back,exit and cancel) which is persent on standard toolbar on ALV Gried output .
Rgds,
PremrajHello PremRaj ,
Please find an dummy program to capture the events below:
TYPE-POOLS slis.
DATA: ITAB_EVENTS TYPE slis_t_event,
WA_EVENTS TYPE SLIS_ALV_EVENT.
DATA: IT_END TYPE SLIS_T_LISTHEADER,
WA_END TYPE SLIS_LISTHEADER.
** This function module will get all the events present in alv into internal table itab_events*
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = ITAB_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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.
** With this read table statement itab_events is read for the desired event*+
READ TABLE itAB_eventS INTO wa_eventS WITH KEY name = 'END_OF_LIST'.
wa_eventS-form = 'END'.
MODIFY itAB_eventS FROM wa_eventS INDEX sy-tabix.
CLEAR wa_eventS.
*Pass the ITAB_EVENTS created in this Function Module
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_EVENTS = ITAB_EVENTS
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_tab
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.
*READ TABLE itAB_eventS INTO wa_eventS WITH KEY name = 'END_OF_LIST'.
wa_eventS-form = 'END'.
MODIFY itAB_eventS FROM wa_eventS INDEX sy-tabix.
CLEAR wa_eventS.
*in these statements ,the second line will automatically try to call subroutine with name end.
FORM END.
WA_END-TYP = 'S'.
WA_END-KEY = TEXT-004.
WA_END-INFO = SY-DATUM.
APPEND WA_end TO IT_END.
CLEAR WA_END.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = IT_END
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM.
Hope it helps you.
Thanks Mansi
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 11:02 AM
Edited by: MANSI ASNANI on Jan 9, 2009 7:31 AM -
ALV GRID Using oo abap example
Hi Friends,
I am new to oo abap, Can any one give me a basic example how i can create alv grid in oo abap.
regards,
DVNSHI,
Programming for ALV grid display using the classes involves creation of a screen and calling it for display.
Since there has to be a linking between the program and the screen we have created , this comes in the form of a container. We use two important classes during the programming for displaying ALV grid, CL_GUI_ALV_GRID and CL_GUI_CUSTOM_CONTAINER.
Steps To Use ALV Grid in a Program
1. Declare reference variables for,
Container (class CL_GUI_CUSTOM_CONTAINER) and
Grid (class CL_GUI_ALV_GRID)
Example
DATA: grid TYPE REF TO cl_gui_alv_grid,
custom_container TYPE REF TO cl_gui_custom_container
2. Create Standard Screen and a container on that screen and give a name to that container ( Use custom control button from tool bar) . This name will be used to link the container we have created on the screen with the object reference of class CL_GUI_CUSTOM_CONTAINER, which we have declared in the first step
3. Call the screen which has been created
4. Instantiate the container control and the ALV Grid Control in PBO of the screen.
Example
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
CONTAINER_NAME = MY_CONTAINER'.
CREATE OBJECT grid
EXPORTING
I_PARENT = custom_container.
ENDIF
5. For displaying the data, call the method set_table_for_first_display of object reference of CL_GUI_ALV_GRID.
Example
CALL METHOD grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT =
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB =
IT_FIELDCATALOG =
IT_SORT =
IT_FILTER =
EXCEPTION
INVALID_PARAMETER_COMBINATION =
PROGRAM_ERROR =
TOO_MANY_LINES =
others =
EXPLANATION OF SOME IMPORTANT PARAMETERS.
I_BYPASSING_BUFFER & I_BUFFER_ACTIVE :
When the program is run for the first time, the fields present in the output table and their positions are stored in a buffer. So the buffer is taken as reference for the successive executions. In order to bypass this buffer the above parameter values should be X and (space) respectively. If these values are not passed to the function module, the changes made in the structure of the internal table will not be reflected in the output.
I_STRUCTURE_NAME:
If the structure of your output table corresponds to a structure stored in the Data Dictionary (DDIC), the ALV Grid Control can use this information to generate the field catalog automatically. Pass the table structure as parameter. In this case, all fields of this DDIC structure are displayed in the list.
IS_VARIANT :
It allows the user to save and reuse the layout. It is a structure of type DISVARIANT and contain the display variant name. It facilitates pre-assignment for a layout, rather than displaying report and then choosing displaying variant.
I_SAVE:
This single character variable specifies whether the user specific display variants can be saved or not.
The I_SAVE "Options for saving layouts" parameter can have the following values:
U Only user specific layouts can be saved
X Only global layouts can be saved
A Both user specific and global layouts can be saved
Space Layouts can not be saved
IS_LAYOUT:
This structure of type LVC_S_LAYO
is used to control the layout of the ALV. Two important fields are:
GRID TITLE. : Title of grid
ZEBRA : Alternate lines in list are displayed in different colors.
IT_FIELDCATALOG:
This internal table of type LVC_T_FCAT
is used to specify the position of various fields in the report itab.
There are three ways we can fill the field catalog table
1. Automatically through data dictionary structure (DDIC). In this case we pass the table structure to I_STRUCTURE_NAME.
2. Manually in ABAP program. Filling the internal table of type LVC_T_FCAT
1. . With each row corresponding to each column of output table. Each row of this table will hold value like
i). TABNAME & FIELDNAME specifies the reference fields for F1 help
ii). CTABNAME & CFIELDNAME specifies the reference fields for currency formatting
iii). QTABNAME & QFIELDNAME specifies the reference fields for quantity formatting
iv). SELTEXT_L holds the long description of the field
v). SELTEXT_M holds the medium description of the field
vi). SELTEXT_S holds the small description of the field
vii). KEY specifies the Key field ( cannot be hidden )
viii). OUTPUTLEN species the output length of the field
ix). DO_SUM specifies that subtotal is required on this field
x). NO_OUT specifies a hidden field
3. Semi-Automatically by combining the above 2 procedures.
Call function Module REUSE_ALV_FIELDCATALOG_MERGE and pass DDIC
structure or the output table to generate the field catalog.
Add additional Rows or modify existing properties of the fields to be displayed.
METHODS OF IMPLEMENTING SOME EXTRA FEATURES
Set focus to the grid
After CALL METHODgrid->set_table_for_first_display insert the following stament:
CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid
Refresh grid display
Use the grid method REFRESH_TABLE_DISPLAY
Example:
CALL METHOD grid->refresh_table_display.
Set the title of the grid
Fill the grid_title field of structure lvc_s_layo.
DATA:
gs_layout TYPE lvc_s_layo.
gs_layout-grid_title = 'TITLE'.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'structure name'
is_layout = gs_layout
CHANGING it_outtab = Output table.
The structure lvc_s_layo contains fields for setting graphical properties, displaying exceptions, calculating totals and enabling specific interaction options
Event Handling
We can handle the events triggered by
1. User defined Text Output
2. Mouse-controlled Actions
3. Self-defined and Standard Functions
Steps for Event Handling
1. Define a (local) class for event handling
2. Define a method for each event you need to handle
3. Implement your event handler methods.
4. Create Object of the above class
5. Link used events and event handler methods of the receiver object and the grid
object.
Example program : Handling Double Click Event
Step1.Define a class.
class lcl_my_event_receiver definition.
public section.
methods:
handle_double_click
for event double_click of cl_gui_alv_grid.
endclass.
Step 2. Implement the class
class lcl_my_event_receiver implementation.
method handle_double_click.
message i001(zz) with ' double click event - Triggerd '.
endmethod.
endclass.
Step 3. Declare and create Object for the local class defined and implemented in steps 1 and 2 respectively
o_receiver TYPE REF TO lcl_my_event_receiver (Declaration)
create object o_receiver. (Instantiation)
Step 4. Link the method for handling the event with the grid object in the PBO of screen after instantiating the grid object
set handler o_receiver->handle_double_click for grid.
EXAMPLE PROGRAM TO CHANGE A CLASSICAL REPORT OUTPUT TO A ALV GRID
This can be used as a template program to convert a classical report layout to a ALV grid.
Report<Report name>
Grid data Declarations----------------------------------------------*
INCLUDE ZVINALVD.
Internal table for ALV grid
TYPES: BEGIN OF T_ALV,
Field1 like table-field1,
Field2 like table-field2,
END OF T_ALV.
DATA: I_ALV TYPE TABLE OF T_ALV.
DATA: WA_ALV TYPE T_ALV.
-Class declarations----
INCLUDE ZVINALVE.
Add a checkbox in selection screen for ALV grid display. If it is unchecked
output will be of classical type.
SELECTION-SCREEN BEGIN OF BLOCK box01.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 4(30) To display repot output as a ALV grid.
PARAMETERS: p_alv AS CHECKBOX.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN END OF BLOCK box01.
START-OF-SELECTION.
Fill the ALV grid internal table
END-OF-SELECTION.
IF P_ALV = X.
PERFORM ALV_DISPLAY.
ELSE.
PERFORM CLASSICAL_DISPLAY.
ENDIF.
Alv Display
FORM ALV_DISPLAY.
CALL SCREEN 100.
ENDFORM.
Module STATUS_0100 OUTPUT
PBO for ALV Grid
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'GRID_DISPLAY'.
DATA:
For parameter IS_VARIANT that is used to set up options for storing
the grid layout as a variant in method set_table_for_first_display
l_layout TYPE disvariant.
GS_LAYOUT-SEL_MODE = 'B'.
Optimize column width
GS_LAYOUT-CWIDTH_OPT = 'X'.
Read data and create objects
IF go_custom_container IS INITIAL.
Create objects for container and ALV grid
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING i_parent = go_custom_container.
Create object for event_receiver class
and set handlers
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
Layout (Variant) for ALV grid
l_layout-report = sy-repid. "Layout to report
To built fieldcatalog
PERFORM alv_build_fieldcatalog.
Grid setup for first display
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_variant = l_layout
i_save = 'A'
is_layout = gs_layout
CHANGING it_outtab = I_ALV
it_fieldcatalog = fieldcat.
Raise event toolbar to show the modified toolbar
CALL METHOD go_grid->set_toolbar_interactive.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
Form ALV_BUILD_FIELDCATALOG.
Store contents of selected line in a internal table
FORM alv_build_fieldcatalog.
CLEAR afield.
afield-fieldname = 'FIELD1'.
afield-tabname = 'I_ALV'.
afield-coltext = Field Name 1.
afield-lzero = ' '.
afield-key = 'X'.
afield-outputlen = XX.
APPEND afield TO fieldcat.
CLEAR afield.
afield-fieldname = 'FIELD2'.
afield-tabname = 'I_ALV'.
afield-coltext = Field Name 2.
APPEND afield TO fieldcat.
ENDFORM. " alv_build_fieldcatalog
Module USER_COMMAND_0100 INPUT
PAI for ALV Grid
MODULE USER_COMMAND_0100 INPUT.
CASE OK_100.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Form SELECT_LINE
Store contents of selected line in a internal table
FORM SELECT_LINE.
DATA:l_lines TYPE i.
REFRESH gi_index_rows.
CLEAR g_selected_row.
Read index of selected rows
CALL METHOD go_grid->get_selected_rows
IMPORTING et_index_rows = gi_index_rows.
Check if any row are selected at all. If not
table gi_index_rows will be empty
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines = 0.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
textline1 = 'You must choose a line'.
EXIT.
ENDIF.
Read indexes of selected rows.
LOOP AT gi_index_rows INTO g_selected_row.
IF sy-tabix = 1.
READ TABLE I_ALV INDEX g_selected_row-index INTO
WA_ALV.
ENDIF.
ENDLOOP.
ENDFORM. " SELECT_LINE
Includes:
1. ZVINALVD for data declarations
INCLUDE ZVINALVD .
Type pool for icons - used in the toolbar
TYPE-POOLS: icon.
To allow the declaration of o_event_receiver before the
lcl_event_receiver class is defined, decale it as deferred in the
start of the program
CLASS lcl_event_receiver DEFINITION DEFERRED.
GLOBAL DATA FOR ALV GRID
DATA:
OK code for alv grid screen
OK_100(4) TYPE C,
ALV control: Layout structure
gs_layout TYPE lvc_s_layo,
Declare reference variables to the ALV grid and the container
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container,
o_event_receiver TYPE REF TO lcl_event_receiver,
Data for storing information about selected rows in the grid
Internal table
gi_index_rows TYPE lvc_t_row,
Information about 1 row
g_selected_row LIKE lvc_s_row.
fieldcatalog
DATA: fieldcat TYPE LVC_T_FCAT,
afield TYPE LVC_S_FCAT.
2. ZVINALVE for Class/object declarations
INCLUDE ZVINALVE.
C L A S S E S
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
Event handler method for event toolbar.
CONSTANTS:
Constants for button type
c_button_normal TYPE i VALUE 0,
c_menu_and_default_button TYPE i VALUE 1,
c_menu TYPE i VALUE 2,
c_separator TYPE i VALUE 3,
c_radio_button TYPE i VALUE 4,
c_checkbox TYPE i VALUE 5,
c_menu_entry TYPE i VALUE 6.
DATA: ls_toolbar TYPE stb_button.
Append seperator to the normal toolbar
CLEAR ls_toolbar.
MOVE c_separator TO ls_toolbar-butn_type..
APPEND ls_toolbar TO e_object->mt_toolbar.
Append a new button that to the toolbar. Use E_OBJECT of
event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
This class has one attribute MT_TOOLBAR which is of table type
TTB_BUTTON. The structure is STB_BUTTON
CLEAR ls_toolbar.
MOVE 'DISPLAY' TO ls_toolbar-function.
MOVE icon_DISPLAY TO ls_toolbar-icon.
MOVE 'Displaying customer' TO ls_toolbar-quickinfo.
MOVE 'Display' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_user_command.
Handle own functions defined in the toolbar
CASE e_ucomm.
WHEN 'DISPLAY'.
PERFORM SELECT_LINE.
ENDCASE.
ENDMETHOD.
Reward if useful
Maybe you are looking for
-
HT1386 Ipod is not showing up in the itunes interface
This is garbage
-
I just read a topic about IDL mapping to Java...I want to know ,does it have differences and similarities to the IDL mapping to Java?....
-
Average images from camera with IMAQdx
Hi, I need to average acquisition images from a camera and than subtract the average from a background image acquisition. Althought I'm using an ethernet connection the program is REALLY slow. I'm new with Labview so any suggestion is very wellcome..
-
My 2013 MacBook Pro 13" Solid state Retina display stars then it will randomly show a gray boxed message asking:Are you sure you want to shut down your computer. It gives 4 alternatives Re start, sleep cancel or shut down. This is what it shows befor
-
How can I fix itunes music file's permissions
I decided to import all my cds again at a higher bit rate. When importing a cd into itunes that I currently have in the library, itunes will ask me if I want to replace the existing files. To this i say yes, It prevents my library files from loosing