ALV List with checkboxes
Hello experts,
I'm working on an object where in I need to display an ALV List (using Funct Modules) with checkboxes.
When I select the checkboxes,and click on a button (Eg.Refresh Button) , I need to get all the details of the selected rows (checked rows) in a seperate ALV List (in a Dailog).
Could any one of u please suggest me about selecting the row which has been checked(Checkboxes in ALV ).
Thanks in advance.
Sanghamitra
Hi sangha,
1. To get a taste of it,
just copy paste this program.
2. It will display alv (t001)
It will show CHECKBOXES (besides every row)
TICK some rows,
and DOUBLE-CLICK ON any row.
3. It will display all the row numbers which have been checked/ticked.
4.
report abc.
TYPE-POOLS : slis.
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
CALL BACK FORM
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
data : msg(100) type c.
LOOP AT itab.
if itab-flag = 'X'.
msg = sy-tabix.
condense msg.
concatenate 'Row Number ' msg ' ' into msg
separated by space.
message msg type 'I'.
endif.
ENDLOOP.
ENDFORM. "ITAB_user_command
regards,
amit m.
Similar Messages
-
Hi guru's,
I want to create an ALV list with only a char255 field.
<all_table> contains data of sflight and is of type sflight(dynamically).
I want to show the data as one line.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = 'TPPARFIL'
fieldname = 'LINE'
TABLES
dfies_tab = it_dfies.
READ TABLE it_dfies INDEX 1.
IF sy-subrc IS INITIAL.
MOVE-CORRESPONDING it_dfies TO wa_fieldcat.
wa_fieldcat-scrtext_s = 'Results:'.
APPEND wa_fieldcat TO gt_fieldcat.
ENDIF.
t_output[] = <all_table>.
CALL FUNCTION 'LVC_TRANSFER_TO_SLIS'
EXPORTING
it_fieldcat_lvc = gt_fieldcat
IMPORTING
it_fieldcat_alv = it_fieldcat_alv.
PERFORM fill_alv_layout.
* Show list
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = lv_repid
i_grid_title = sy-title
is_layout = gs_layout
it_fieldcat = it_fieldcat_alv[]
TABLES
t_outtab = t_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form fill_alv_layout
FORM fill_alv_layout.
CLEAR: gs_layout.
gs_layout-max_linesize = 160.
gs_layout-min_linesize = 160.
gs_layout-detail_initial_lines = 'X'.
gs_layout-zebra = 'X'.
gs_layout-edit_mode = 'A'.
gs_layout-numc_sum = 'X'.
gs_layout-colwidth_optimize = 'X'.
gs_layout-window_titlebar = sy-title.
gs_layout-totals_only = 'X'.
ENDFORM. " fill_alv_layout
When I run this it only gives an empty view of the fields with type char255.
Regards,
Wimhi,
As per your code I think your internal table is empty. Please set debugger after internal table fill and check. If the data is there then please check your field catalog entry.
Regards,
Sachin -
Printing ALV list with ADS (pdf printer) in non-english charset
Hello!
I have an issue about printing alv list with pdf printer in non-english charset. We have two printers. One for alv lists (SWINCF: Casc.Fonts SAPWIN Unicode) and one for pdf forms(adobe document service). I want to use one printer for any documents. But PDF printer prints non-english charset like ########.
What can I do ?Hi, Roman!
I want to use PDF printer for both types of output. I have a dedicated java instance for ADS.
There is a device type for our Kyocera Printer. My pdf printer prints ALV list good exept russian charset.
It prints like ##### -
ALV LIST with few checkboxes fields
Hi everyone,
I want to create an ALV with 2 fields that are checkboxes.
I am succeeding to create an ALV with one checkbox field.
How do we do in order to create an ALV with 2 checkboxes fields using ALV LIST ?
I know that we have to specify in the layout of the ALV the name of the field we want it to be checkbox.
For example :
gs_layout-box_fieldname = 'FLAG'.
But, how do we specify a second checkbox field ?
Thanks.
Regards.Slight modification to my earlier post. this is with 2 checkboxes.
REPORT ztest_alv_checkbox.
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
wa_cat LIKE LINE OF it_fcat.
DATA: BEGIN OF it_alv OCCURS 0,
check1(1),
check2(1),
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
END OF it_alv.
DATA:it_events TYPE slis_t_event,
wa_events LIKE LINE OF it_events.
SELECT carrid
connid
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_alv
UP TO 20 ROWS.
wa_cat-fieldname = 'CHECK1'.
wa_cat-input = 'X'.
wa_cat-edit = 'X'.
wa_cat-checkbox = 'X'.
wa_cat-seltext_l = 'Check'.
wa_cat-tabname = 'IT_ALV'.
APPEND wa_cat TO it_fcat.
CLEAR wa_cat.
wa_cat-fieldname = 'CHECK2'.
wa_cat-input = 'X'.
wa_cat-edit = 'X'.
wa_cat-checkbox = 'X'.
wa_cat-seltext_l = 'Check'.
wa_cat-tabname = 'IT_ALV'.
APPEND wa_cat TO it_fcat.
CLEAR wa_cat.
wa_cat-fieldname = 'CARRID'.
wa_cat-seltext_l = 'Carrid'.
wa_cat-tabname = 'IT_ALV'.
APPEND wa_cat TO it_fcat.
CLEAR wa_cat.
wa_cat-fieldname = 'CONNID'.
wa_cat-seltext_l = 'Connid'.
wa_cat-tabname = 'IT_ALV'.
APPEND wa_cat TO it_fcat.
wa_events-name = slis_ev_end_of_list.
wa_events-form = 'MODIFY_LIST'.
APPEND wa_events TO it_events.
CLEAR wa_events.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fcat
it_events = it_events
TABLES
t_outtab = it_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
ENDIF.
"After The list display i am modifying the report output
"using the END_OF_LIST event of ALV
"here conditionally i can make the cell input off
*& Form MODIFY_LIST
* text
FORM modify_list.
DATA: l_lines TYPE i,
l_index TYPE i.
l_lines = l_lines + 3.
"because we have 3 lines extra occupied by lables.
"if we have header,i mean top of page add the no.of lines
"how many ever top of page have + 3 for labels.
DESCRIBE TABLE it_alv LINES l_lines.
l_lines = l_lines + 3.
"understnad this part alone.
DO l_lines TIMES.
IF sy-index GT 3.
l_index = sy-index - 3.
READ TABLE it_alv INDEX l_index.
"this is my condition..
IF sy-subrc = 0 .
IF it_alv-carrid <> 'AA'. "place your condition here.
"accordingly you can disable the checkbox
"use the below logic
READ LINE sy-index INDEX sy-lsind.
IF sy-subrc = 0.
MODIFY LINE sy-index INDEX sy-lsind
FIELD FORMAT it_alv-check1 INPUT OFF
it_alv-check2 INPUT OFF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "MODIFY_LIST -
How to display ALV list with more than 1 structure?
Hello everyone,
I am using REUSE_ALV_LIST_DISPLAY to generate a report that displays vendor/customer items with purchases/sales total. I have 2 internal table for this. For every vendor/customer i need a total table right after, this have a different structure. I cannot use REUSE_ALV_BLOCK_LIST_ as this is not capable of calculating the subtotal per currency and from the documentation it says do not use.
Any idea on how to proceed?
Thanks!Call ALV list function module per table structure.
Closing this thread. -
ALV list with count of the table
Dear all,
My requirement is i want display the output as alv list along with the count of the table .
i got the count but unable to diplay the below the list.
please suggest me.
Thanks& Regards,
RPIf you are using a custom control on the screen and then a custom container you can easily do this.
Create a screen(Size 200 x 240), place a custom control on the screen and make it to the max size 200 x 240. Now in the attributes of the custom control, check the Resizing option for both horizontal and vertical, with some minimum numbers there.
Now, your ALV grid automatically occupies all the space available on the screen irrespective of the size if the screen and you will have only one scroll bar.
Regards,
Ravi
Note - Please mark all the helpful answers -
ALV list with empty data - What could have gone wrong?
Dear experts,
I'm currently working on some codes to display data (the tables involved really do contain data), but when the codes are executed, the ALV list does not contain any data in it (only the column headers are fine).
What could have gone wrong? I've been staring at the codes for hours now. Please help. Appreciate any help at all.
Displaying ALV data with REUSE_ALV_LIST_DISPLAY:
form display_alv_data .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = w_prog
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = gt_field_cat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* 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 = gt_final
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. " display_alv_data
Retrieving data from the database tables into the internal table:
form retrieve_data .
" For internal table 1
SELECT ekbe~ebeln
mseg~mblnr
ekbe~belnr
ekbe~ebelp
ekbe~matnr
ekbe~menge
ekbe~dmbtr
ekbe~werks
mseg~lgort
mseg~lifnr
lfa1~name1
FROM ekbe INNER JOIN mseg ON ekbe~ebeln = mseg~ebeln
INNER JOIN lfa1 ON mseg~lifnr = lfa1~lifnr
INTO CORRESPONDING FIELDS OF TABLE gt_1
WHERE mseg~bwart = '101' AND " Movement type: Goods Receipt
ekbe~vgabe = '2' AND " Transaction / event type for Invoice Verification Number
ekbe~matnr IN s_m_num AND
mseg~lifnr IN s_v_num.
" For internal table 2
SELECT ekbe~ebeln
makt~maktx
eket~eindt
FROM ekbe INNER JOIN makt ON ekbe~matnr = makt~matnr
INNER JOIN eket ON ekbe~ebeln = eket~ebeln
INTO CORRESPONDING FIELDS OF TABLE gt_2
WHERE eket~eindt IN s_d_date.
" For internal table 3
SELECT ekbe~ebeln
ekko~bedat
ekko~ekorg
ekko~ekgrp
ekko~bukrs
FROM ekbe INNER JOIN ekko ON ekbe~ebeln = ekko~ebeln
INTO CORRESPONDING FIELDS OF TABLE gt_3
WHERE ekko~bedat IN s_p_date AND
ekko~ekorg IN s_p_org AND
ekko~ekgrp IN s_p_grp.
" For the final internal table
SORT: gt_1, gt_2, gt_3.
LOOP AT gt_1.
MOVE-CORRESPONDING gt_1 TO gt_final.
READ TABLE gt_2 WITH KEY gfs_ebeln = gt_1-gfs_ebeln BINARY SEARCH.
MOVE-CORRESPONDING gt_2 TO gt_final.
READ TABLE gt_3 WITH KEY gfs_ebeln = gt_1-gfs_ebeln BINARY SEARCH.
MOVE-CORRESPONDING gt_3 TO gt_final.
APPEND gt_final.
ENDLOOP.
endform. " retrieve_dataDear forumers,
I apologize for the rather late reply. The SAP server that I've been working on was down since Thursday evening and I wasn't able to debug much into the codes. Nevertheless, I really do appreciate all of your inputs and help here.
Rob,
I've just debugged my codes again and found out that in the first place, there is no data contained in the internal table gt_1 at all. My rough guess is because I've misused the INNER JOIN wrongly here (see code comments below):-
SELECT ekbe~ebeln
mseg~mblnr
ekbe~belnr
ekbe~ebelp
ekbe~matnr
ekbe~menge
ekbe~dmbtr
ekbe~werks
mseg~lgort
mseg~lifnr
lfa1~name1 " this line should probably be commented out
FROM ekbe INNER JOIN mseg ON mseg~ebeln = ekbe~ebeln
INNER JOIN lfa1 ON lfa1~lifnr = mseg~lifnr " this line should probably be commented out - the table join here is not based on table ekbe at all
INTO CORRESPONDING FIELDS OF TABLE gt_1
WHERE mseg~bwart = '101' AND
ekbe~vgabe = '2' AND
ekbe~matnr IN s_m_num AND
mseg~lifnr IN s_v_num.
Next, I commented out certain lines further and found that there is still no data contained in the internal table gt_1 again, as follows:-
SELECT ekbe~ebeln
mseg~mblnr
ekbe~belnr
ekbe~ebelp
ekbe~matnr
ekbe~menge
ekbe~dmbtr
ekbe~werks
mseg~lgort
mseg~lifnr
" lfa1~name1
FROM ekbe INNER JOIN mseg ON mseg~ebeln = ekbe~ebeln
" INNER JOIN lfa1 ON lfa1~lifnr = mseg~lifnr
INTO CORRESPONDING FIELDS OF TABLE gt_1.
" WHERE mseg~bwart = '101' AND
" ekbe~vgabe = '2' AND
" ekbe~matnr IN s_m_num AND
" mseg~lifnr IN s_v_num.
There should be data contained in table ekbe here. What could have really gone wrong now? -
Dear gurus,
Need help in displaying ALV list report. the below report is an example of AR aging report. The report output is as below:
DEC
NOV
OCT
SEP
0-30
31-60
61-90
90+
xx
xx
xx
xx
SUBTOTAL
The first 2 lines are the list header. While the 'x' is the amount.
How can i display the above output with 2 header lines? I was thinking of using the REUSE_ALV_FIELDCATALOG_MERGE function. But it will have 2 lines of body row too. In fact, i only one one row in the body. But if i define the header lines manually, i would not able to do the subtotal at the end of the alv list. I need to have the subtotal too.
Thanks in advance!Hi,
For this requirement you need to populate the fld catalog using row_pos and col_pos fields specifing proper position.
See this code snippet ..... this is only possible for ALV list.
TYPE-POOLS: slis.
DATA: ld_fieldcat TYPE slis_fieldcat_alv.
DATA: t_alv_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv.
DATA : it_fld TYPE slis_t_fieldcat_alv,
wa_fld TYPE slis_fieldcat_alv.
data: BEGIN OF itab OCCURS 0,
carrid like sflight-carrid,
connid like sflight-connid,
planetype like sflight-planetype,
seatsmax like sflight-seatsmax,
END OF itab.
START-OF-SELECTION.
SELECT carrid connid planetype seatsmax
FROM sflight
INTO TABLE itab.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '1'.
ld_fieldcat-col_pos = '1'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'CARRID'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '1'.
ld_fieldcat-col_pos = '2'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'CONNID'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '2'.
ld_fieldcat-col_pos = '1'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'PLANETYPE'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-row_pos = '2'.
ld_fieldcat-col_pos = '2'.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'SEATSMAX'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = t_alv_fieldcat[]
TABLES
t_outtab = ITAB. "internal table
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Amitava -
ALV List with two rows of heading
Hi All,
I am working on ALV list display. I have six columns of heading in my ALV. Out of the six columns i need to display five columns in the first row and the sixth heading will be in the second row first column.
Ex:
A B C D E F
G
I need to display a row of values for Column G for every row of A,B,C,D,E,F.
How is this possible with ALV list display.
Ex.
A B C D E F
G
v1A v1B v1C v1D v1E v1F
v1G
v2A v2B v2C v2D v2E v2F
v2G
v3A v3B v3C v3D v3E v3F
v3G
Looking forward to ur reply.
Regards
RamananHi,
You can use a hierachial list to display your output as required.
You can check the example program BCALV_TEST_HIERSEQ_LIST.
Regards,
Ankur Parab
Edited by: Ankur Parab on Jun 15, 2009 12:33 PM -
HI experts,
I want to display data in grid with checkboxes.in grid some rows have a negative value and some row have possitive value(means one filed have /-).if row have negative value in that row checkbox must be in disable mode or possitive in that row checkbox must be in enble mode.<Urgency downgraded>+
Thanks
V.Venu
Edited by: Suhas Saha on Nov 14, 2011 4:21 PMThanks Venu For Putting this Question and Thanks Deepak For getting bang on the point.. It Works Perfctlty fine...
I am Sending Code For Guys Who are suffering from this Problem...
TYPES: BEGIN OF TY_MARA,
FLAG TYPE CHAR1,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
WESCH TYPE MARA-WESCH,
STYLE TYPE LVC_T_STYL,
END OF TY_MARA.
DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA.
DATA : IT_MARA1 TYPE STANDARD TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA,
WA_MARA1 TYPE TY_MARA.
DATA : WA_SETTINGS TYPE LVC_S_GLAY.
DATA : WA_LAYOUT TYPE LVC_S_LAYO.
DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT,
WA_FIELDCATALOG TYPE LVC_S_FCAT.
DATA REF1 TYPE REF TO CL_GUI_ALV_GRID.
DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.
START-OF-SELECTION.
SELECT MATNR ERSDA ERNAM WESCH
FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
UP TO 10 ROWS.
WA_FIELDCATALOG-FIELDNAME = 'FLAG'.
WA_FIELDCATALOG-OUTPUTLEN = 6.
WA_FIELDCATALOG-CHECKBOX = 'X'. "as checkbox
WA_FIELDCATALOG-EDIT = 'X'.
WA_FIELDCATALOG-SELTEXT = 'Check box'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'MATNR'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Mat no'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'ERSDA'.
WA_FIELDCATALOG-OUTPUTLEN = 15.
WA_FIELDCATALOG-SELTEXT = 'Creation Date'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'ERNAM'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Creation Time'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'WESCH'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Quantity'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
CONSTANTS : LC_X TYPE CHAR1 VALUE 'X'.
WA_LAYOUT-CWIDTH_OPT = LC_X.
WA_LAYOUT-ZEBRA = LC_X.
WA_LAYOUT-STYLEFNAME = 'STYLE'.
LS_EDIT-FIELDNAME = 'FLAG'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE WA_MARA1-STYLE.
LOOP AT IT_MARA INTO WA_MARA..
IF WA_MARA-ERSDA EQ '20060809'.
MODIFY IT_MARA INDEX SY-TABIX FROM WA_MARA1 TRANSPORTING STYLE.
ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_GRID_TITLE = 'Example of select and deselect'
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCATALOG
TABLES
T_OUTTAB = IT_MARA.
FORM F_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STATUS1'.
ENDFORM.
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'ASEL'.
LOOP AT IT_MARA INTO WA_MARA.
WA_MARA-FLAG = 'X'.
MODIFY IT_MARA FROM WA_MARA.
ENDLOOP.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'DSEL'.
LOOP AT IT_MARA INTO WA_MARA.
WA_MARA-FLAG = ' '.
MODIFY IT_MARA FROM WA_MARA.
ENDLOOP.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'DELETE'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->CHECK_CHANGED_DATA.
DELETE IT_MARA
WHERE FLAG = 'X'.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'INSERT'.
CLEAR WA_MARA.
APPEND WA_MARA TO IT_MARA.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->REFRESH_TABLE_DISPLAY.
WHEN 'SAVEDB'.
ENDCASE.
ENDFORM. -
Hierarchical ALV list with control of printout and Excel download
Hello everybody,
i have to write a program, that has to generate a hierarchical master/client list. The list should
have the same functionality, that a standard ALV Grid
offers (sorting, grouping, OLE export to Excel). The printout must show a new sheet for every master group.
ALV grid does not allow to display hierarchical lists. The ALV hierarchical list and blocklist view switches to
text mode with no "single click Excel activation". I have tried to implement the &XXL ok_code, but in text mode, there is no chance to activate this single-table functionality.
Another possibility seems to be ALV tree, but there is no
possibility to control the printout (new sheet at group level) and the given practice, to load child nodes at selection, is not acceptable for my kind of program (all childs have to be expanded and the printout must contain a dialog to print i.e. a "from to group" selection).
Does anyone have an idea, to solve this problem in an easy object oriented way? my only thought at this time is, to use a standard ABAP list and to integrate Excel via document office integration. This gives me the fullcontrol about printout and export, but it needs far more time then ALV.
Another possibility may be, to develop a custom control, based on VS with Flexgrid, Singray or ComponentOne tools, but ich have to go as near as possible to SAP standard, without using 3rd party programming systems or controls.
I'm glad about tip's!
Greets from germany
JensJens,
Take a look at this for ideas:
REPORT Zsandbox_prog .
INCLUDE OLE2INCL.
field-symbols: <Val> type any.
data: row_cnt type i.
types: begin of t_Excel,
Material_Info(20),
Sugg_Price(20),
Cost(20),
Comments(100),
end of t_Excel.
data: r_Excel type t_Excel.
data: i_Excel type table of t_Excel with header line.
constants: xlCenter type i value '-4108',
xlBottom type i value '-4107',
xlLeft type i value '-4131',
xlRight type i value '-4152'.
constants: xlContinuous type i value '1',
xlInsideVertical type i value '11',
xlThin type i value '2',
xlLandscape type i value '2',
xlPortrait type i value '1',
xlLetter type i value '1',
xlLegal type i value '5',
xlThick type i value '4',
xlNone type i value '-4142',
xlAutomatic type i value '-4105'.
DATA: hExcel TYPE OLE2_OBJECT, " Excel object
hWorkBooks TYPE OLE2_OBJECT, " list of workbooks
hWorkbook TYPE OLE2_OBJECT, " workbook
hSheet TYPE OLE2_OBJECT, " worksheet object
hRange TYPE OLE2_OBJECT, " range object
hRange2 TYPE OLE2_OBJECT, " range object
hBorders TYPE OLE2_OBJECT, " Border object
hInterior TYPE OLE2_OBJECT, " interior object - for coloring
hColumn TYPE OLE2_OBJECT, "column
hCell TYPE OLE2_OBJECT, " cell
hFont TYPE OLE2_OBJECT, " font
hSelected TYPE OLE2_OBJECT, " range object
hPicture TYPE OLE2_OBJECT, "picture object
hLogo TYPE OLE2_OBJECT. "Logo object
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECTION-SCREEN skip 1.
parameter: wraptext as checkbox.
SELECTION-SCREEN END OF BLOCK b1.
row_cnt = 1.
Perform Build_Dummy_Vals.
Perform Start_Excel.
Perform Build_Header_Line using row_cnt.
Perform Pass_Records using row_cnt.
Perform Release_Excel.
FORM Build_Dummy_Vals .
data: matnum(5) type n.
data: baseprice(3) type n.
do 5 times.
matnum = matnum + 50.
clear r_Excel.
concatenate 'Material ' matnum into r_Excel-material_info
separated by space.
r_excel-Sugg_Price = baseprice * matnum.
r_excel-Cost = ( baseprice * matnum ) / 2.
concatenate 'Comments for Material ' matnum into r_excel-Comments
separated by space.
append r_excel to i_Excel.
enddo.
ENDFORM. " Build_Dummy_Vals
Form Start_Excel.
CREATE OBJECT hExcel 'EXCEL.APPLICATION'.
PERFORM ERR_HDL.
get list of workbooks, initially empty
CALL METHOD OF hExcel 'Workbooks' = hWorkbooks.
PERFORM ERR_HDL.
add a new workbook
CALL METHOD OF hWorkbooks 'Add' = hWorkbook.
PERFORM ERR_HDL.
Get Worksheet object.
get property of hWorkbook 'ActiveSheet' = hSheet.
EndForm.
FORM Build_Header_Line using p_row_cnt.
data: l_range(30).
data: row_start(10).
PERFORM Fill_The_Cell USING p_row_cnt 1 1 'Material'.
PERFORM Fill_The_Cell USING p_row_cnt 2 1 'Suggested Price'.
PERFORM Fill_The_Cell USING p_row_cnt 3 1 'Cost'.
PERFORM Fill_The_Cell USING p_row_cnt 4 1 'Comments'.
Perform Format_Column using 1 15 xlCenter ' ' xlCenter 0.
Perform Format_Column using 2 10 xlCenter ' ' xlCenter 1.
Perform Format_Column using 3 35 xlCenter ' ' xlCenter 0.
if WrapText = 'X'.
Perform Format_Column using 4 35 xlLeft ' ' xlCenter 1.
else.
Perform Format_Column using 4 100 xlLeft ' ' xlCenter 0.
endif.
Build the range object.
row_start = p_row_cnt.
concatenate 'A' row_start ':D' row_start into l_range.
condense l_range no-gaps.
Set row color to yellow.
CALL METHOD OF hExcel 'RANGE' = hRange EXPORTING #1 = l_range.
call method of hRange 'Interior' = hInterior.
set property of hInterior 'ColorIndex' = 6. "yellow
p_row_cnt = p_row_cnt + 1.
ENDFORM. " Build_Header_Line
FORM Format_Column USING p_ColNum
p_ColWidth
p_ColHAlign
p_ColFormat
p_ColVAlign
p_WrapText.
CALL METHOD OF hExcel 'COLUMNS' = hColumn
EXPORTING #1 = p_ColNum . "column number
SET PROPERTY OF hColumn 'HorizontalAlignment' = p_ColHAlign.
SET PROPERTY OF hColumn 'VerticalAlignment' = p_ColVAlign.
SET PROPERTY OF hColumn 'ColumnWidth' = p_ColWidth.
SET PROPERTY OF hColumn 'WrapText' = p_WrapText.
ENDFORM. " Format_Column
Form Pass_Records using p_row_cnt.
data: col_cnt type i.
data: l_range(30).
data: row_start(10).
col_cnt = 1.
*Pass the internal table values to the spreadsheet.
loop at i_Excel into r_Excel.
do 4 times.
assign component sy-index of STRUCTURE r_excel TO <Val>.
PERFORM Fill_The_Cell USING p_row_cnt col_cnt 0 <Val>.
col_cnt = col_cnt + 1. "increment column
enddo.
Build the range object.
row_start = p_row_cnt.
concatenate 'A' row_start ':D' row_start into l_range.
condense l_range no-gaps.
Set row color to yellow.
CALL METHOD OF hExcel 'RANGE' = hRange EXPORTING #1 = l_range.
call method of hRange 'Interior' = hInterior.
set property of hInterior 'ColorIndex' = 7. "yellow
p_row_cnt = p_row_cnt + 1. "increment row
col_cnt = 1. "reset column to A (ie. col 1)
endloop.
EndForm.
FORM Release_Excel .
SET PROPERTY OF hExcel 'Visible' = 1.
FREE OBJECT hExcel.
PERFORM ERR_HDL.
ENDFORM. " Release_Excel
FORM Fill_The_Cell *
Sets cell at coordinates i,j to value val boldtype bold *
BOLD --> 1 = true, set bold ON 0 = false, set bold OFF
FORM Fill_The_Cell USING I J BOLD TheValue.
CALL METHOD OF hExcel 'Cells' = hCell EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
SET PROPERTY OF hCell 'Value' = TheValue.
PERFORM ERR_HDL.
GET PROPERTY OF hCell 'Font' = hFont.
PERFORM ERR_HDL.
SET PROPERTY OF hFont 'Bold' = BOLD.
PERFORM ERR_HDL.
ENDFORM.
FORM ERR_HDL.
IF SY-SUBRC <> 0.
message i000(zz) with 'OLE Automation error: ' SY-SUBRC.
exit.
ENDIF.
ENDFORM. " ERR_HDL -
ALV - Problem with checkbox.
Dear All,
I have created an ALV Grid Control and have one column as a check box.
when i tick one checkbox in a line item i pop up a message saying "Do you wish to continue".
If the user selects NO then i automatically want to deselect the checkbox.
I tried clearing the work area of the internal table in the data change event.
But when the alv is refreshed the checkbox is still ticked.What should be done to avoid this.
Is freeing the custom container and creating it again everytime the user selects NO a good option?
Kindly suggest.
Regards,
VarunIn ALV you put check box like
X_FIELDCAT-FIELDNAME = 'CHK'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
X_FIELDCAT-INPUT = 'X'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-CHECKBOX = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
in between you put logic
IF CHK = 'X'
*---popup_to_continue_yes_no
PERFORM POPUP_TO_CONT_YES_NO.
endif.
FORM POPUP_TO_CONT_YES_NO .
CALL FUNCTION 'POPUP_CONTINUE_YES_NO'
EXPORTING
TEXTLINE1 = 'Click OK to leave program'
TITEL = 'POPUP_CONTINUE_YES_NO'
IMPORTING
ANSWER = ANS.
IF ANS = 'J'.
LEAVE PROGRAM.
ENDIF.
ENDFORM. " POPUP_TO_CONT_YES_NO -
Hello,
I am facing a problem in getting the refreshed value of the checkbox field in the internal table.
I will explain you what is the program does , first i am displaying the set of values with the internal table with the checkbox clicked.
Then user will uncheck some of the rows and then he presses a button to do the respective action .
When i press the button , in the usercommand form , i am trying to capture the checked rows . Here it is not displaying with the modified internal table , but it displays the internal table with all the checkbox field value as blank.
I have used the GLOBAL_SVC FM and check_changed_data , refresh_table before the usercommand action . Still it is not displaying . When i click the checkbox and then highlight the whole row , then click the button it is displaying the updated internal table.
My doubt is always we have to click the checkbox and hightlight the whole row or is there any way to get the updated value of the internal table when the checkbox is just clicked.?
Thanks,
kevinWhy don't you set a handler for event DATA_CHANGED and change data everytime you (de)select checkbox in the frontend. It's much more convenient as you keep control on any actions that user perform.
@christian
From help.sap.com
There is no guarantee that an automation queue will be sent when you call CL_GUI_CFW=>FLUSH. The queue recognizes whether it contains any return values. If this is not the case, it is not sent.
More on this [here|http://help.sap.com/saphelp_nw2004s/helpdata/en/e0/9424f2f16e11d2bdd8080009b4534c/frameset.htm]
So if he wants to ensure that synchronization takes place, he should rather use [CL_GUI_CFW=>UPDATE_VIEW|http://help.sap.com/saphelp_nw2004s/helpdata/en/e0/9424f7f16e11d2bdd8080009b4534c/frameset.htm]
Regards
Marcin -
How to display all items titles from custom list with checkbox to select for each user
Hi All,
I have a requirement in a sharepoint 2013 development project.
A custom list items will be created by admin with the following columns:
Title
Hyperlink
User business unit (This column which is a metadata will be a userprofile property)
In a page/form I have to display the list of titles with a check box based on each user business unit and each user will be allowed to check the list of titles and hit save. And then have to display the list chosen by the user in a webpart.
If they want to modify their list they have to go to the page/form again and will uncheck the list.
Am not sure whether I can achieve this through sharepoint out of box feature, I have not done any custom development.
Please provide your valuable suggestions/ideas on this. Thanks for looking on this !!!Hi,
Per my knowledge, there are no such OOTB features can meet your requirement, however, there is a workaround that if you can modify your requirement a bit.
Based on your description, you want different users be able to select values from a list and generate a list own by them.
If this is what you mean, we can do it like this:
1. Create another list "Users" which stores the names of every users;
2. Create a list "Result" which will be available for every user to add their own items, this list will have four Lookup columns and they look up to the "Users" list and the
list you mentioned before;
3. Users can add items into "Result" list by selecting the needed values from the other two list, then the items he/she created will be connected to them with the help of the
Lookup column which looks up to the "Users" list.
4. You can take use of the OOTB permission management of list to control the access of each item in the "Result" list, and it will be easier for you to manage and filter the
information you needed.
The links below about Lookup column for your reference:
http://office.microsoft.com/en-us/sharepoint-server-help/create-list-relationships-by-using-unique-and-lookup-columns-HA101729901.aspx
http://www.dummies.com/how-to/content/lookup-columns-in-sharepoint-2010.html
Best regards
Patrick Liang
TechNet Community Support -
How to retive the data from ALV display when checkbox clicked
HI.....
suppose i have a ALV list with 3 fields and checkbox attached with it.Now if i click any of the checkbox i want to retrieve the data from a particular field from one of the 3 fields.How shal i do that....
Kind Regards.hi
use the field catalog property wa_fcat-hotspot = 'X' and then
in in list display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'PFTEST'
i_callback_user_command = 'USER_COMMAND_ALV
is_layout = l_layout
it_fieldcat = it_fcat[]
TABLES
t_outtab = it_outtab[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
FORM user_command_alv USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: l_index LIKE sy-tabix.
DATA: l_belnr TYPE rbkp-belnr.
DATA: l_gjahr TYPE rbkp-gjahr.
DATA: l_awkey TYPE bkpf-awkey.
DATA: lwa_bkpf TYPE bkpf.
CLEAR g_flag.
IF r_ucomm EQ 'CREATESO'.
REFRESH it_outsel[].
LOOP AT it_outtab INTO wa_outtab.
IF wa_outtab-check = 'X'.
delete and put in new itab.
ENDIF.
CLEAR wa_outtab.
ENDLOOP.
shiva
Maybe you are looking for
-
How can I save downloaded iOS system updates when using multiple iPhones
I have multiple iPhones, and every time I want to update them, I have to wait forever for these downloads to transfer. The update downloads, but is not saved so that I can use it for another iPhone, requiring me to download the same file yet again, a
-
I am trying to access a work site. It allows access scheduling program. When I try to access it, it tells me that I need IE 6.0 or greater. I can get to it with Safari but it won't let me do anything. I set the Safari User agent to IE 7.0 and 8.0. Be
-
How to do a TableCellRenderer with Windows XP Look'n Feel ?
In my application i use a sortable JTable view. In order to visualize the sorted column selected by user interaction i wrote my own TableCellRenderer implemantation to feature this with an icon in the table header which shows an arrow symbol for asce
-
Hello, I'm trying to write a query which is of the form below: select (aa.name || bb.name) full_name from (select * from per_positions where name = 'Igwe') aa, (select * from per_positions where name = 'OSHS.Application.Specialist.Head Office') bb Th
-
Scan failed message kodak i40 acrobat 8.0
Ive just purchased Acrobat 8.0. I was using acrobat 5.0 with a Kodak i40 scanner. Scanning directly into acrobat with 5.0 was no problem. Since uninstalling 5.0 and installeing 8.0 (and rebooting in between), acrobat gives me a scan failed error mess