I need to display empty editable table in SAP (something like transaction SM30 when you want to insert new records). I know how to make editable table, but my problem is how to display empty table. I true with APPEND INITIAL LINE TO t_output but is not working.
Ok, I found my problem
This is my previous code.
DO 5 TIMES.
APPEND INITIAL LINE TO t_output.
ENDDO.
t_output_alv = t_output.
IF go_container IS INITIAL.
CREATE OBJECT go_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_container.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = s_layout
is_variant = s_variant
CHANGING
it_fieldcatalog = t_fieldcat
it_outtab = t_output_alv.
ENDIF.
and this is my new code.
DO 5 TIMES.
APPEND INITIAL LINE TO t_output_alv.
ENDDO.
The difference here is that in the second code i'm appending to t_output_alv not to t_output.
Related
I have a script (provided below) created to extract and assign values from a nested object to text fields residing on a PDF form. Unfortunately, the script fails resulting in a number of undefines due to what appears to be a Null f value. To clarify, the event.value is a value selected by the user that gets assigned to a combo box on the form. Hence, for whatever reason, the combo box selection is not getting assigned to variable 'f' in which event the script fails and results in undefines for the field values on the form. I am contemplating that the solution requires a minor script adjustment for accessing the objects values. Thank you ahead of time.
var oField = getField("dataSource");
oVendors = JSON.parse(oField.value);
for(j=0;j<14;j++){
f=getField("inf."+j);
f.value = oVendors[event.value][j];
}
Upon further reading and learning about how to create and use a JS
object, the initial script posted was entirely wrong. The script
required to extract and assign values from a JS object to text fields
residing on a PDF form is as follows:
dsFld =getField("dataSrc");// dataSrc is a hidden text field that
resides on the PDF form
oVendors = JSON.parse(dsFld.value);//parse oVendors, a JS object stored
as a JSON string in the hidden dataSrc field
btnDel=getField("btn.del");
var oFld;//declare var oFld for later use
var oPassData = oVendors[event.value];//assign a field value to var
oPassData
if(oPassData){
//walk members to fill form fields
for(var nNm in oPassData){ // skip fields that don't exist on form
oFld = this.getField("inf." + nNm);
if(oFld)
oFld.value = oPassData[nNm]// assign property values stored in
oVendors data object to associated PDF form fields
}
Sorry for my initial post and any inconvenience to the forum.
Dear all I need your help on the below desperately.
I have created an ALV from SALV and I have copied a GUI Status SALV_STANDARD from a standard program. Firstly I added 2 buttons the POSTNEW & POSTDIFF and after a day I added the SELECT button.
Depending on the selection of the user I want to enable or disable the buttons according to the business requirements.
I have this code in a procedure:
r_alv type reference CL_SALV_TABLE.
if status_name is not initial and report_name is not initial.
set pf-status status_name.
r_alv->set_screen_status(
pfstatus = status_name
report = report_name
set_functions = r_alv->c_functions_all ).
endif.
data: lit_functions_list type salv_t_ui_func,
lwa_functions_list like line of lit_functions_list.
r_functions = r_alv->get_functions( ). "Get Toolbar functions
lit_functions_list = r_functions->get_functions( ).
if i_button_name is not initial.
** Now hide the BUTTON
loop at lit_functions_list into lwa_functions_list.
if lwa_functions_list-r_function->get_name( ) = i_button_name.
lwa_functions_list-r_function->set_visible( i_button_visable ).
endif.
endloop.
endif.
The variables status_name, report_name, i_button_name and i_button_visable are parameters of the procedure and I think that their names show what they are carrying.
The internal table lit_functions_list has 60 records and the last 2 have data for the first 2 buttons and this is the reason that I can enable/disable them.
But there is no record with my 3rd button SELECT. Instead there is a record with the button MYFUNCTION which I have already deleted.
Can someone tell me what to do in order to have the 3rd button available in the lit_functions_list?
Can someone tell me why this itab has so many garbages?
Thanks in advance
Elias
Even I had the same problem. After I ran the report BALVBUFDEL it solved the issue.
Newly created buttons now coming inside the function list ..
lit_functions_list = r_functions->get_functions( ).
For Adding 3rd button in the lit_functions_list, You can use below code.
r_functions->set_function( NAME = 'BUT3' BOOLEAN = 'X' ).
you can also use add_function to add new button.
try.
r_functions->add_function(
name = 'BUT3'
icon = l_icon
text = l_text
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_existing cx_salv_wrong_call.
endtry.
itab does not have garbage. It contains all the data related to status like menu bar, application tool bar and function keys.
Finally I found the answer at least to my problem. Let me describe again what I did:
I copy the GUI Status from the standard program SALV_DEMO_TABLE_FUNCTIONS to my program through Tcode SE41. I added 2 buttons POSTNEW & POSTDIF. Until now all working perfect and I can Enable/Disable these 2 buttons.
Next day the business asked me to add a button SELECT with which the user can make editable the corresponding SELECT column of the itab in order to choose which record to be posted. And here started my problem where the itab with the functions didn't contain the last created button SELECT. What I did was, I created a button through the design process of the GUI Status but I could not get it through the below code:
lit_functions_list = r_functions->get_functions( ).
With your answers I found other problems in my code but still I could not get the new button in the above itab.
Finally, yesterday evening I remembered, what someone told me in the past. In old systems (like oursSAP ECC 6.0 R701 SP007) sometimes the ALV buffer stuck and we have to reset it. So I run the program BALVBUFDEL and vuala the button SELECT appeared in the itab and I can now Enable or Disable.
So keep in mind that sometimes the ALV buffer needs a reset.
Thanks all for your help.
Elias
I am using the CL_GUI_ALV_GRID class to display a table. I would like to be able to edit the table (adding new rows and removing all lines), but I don't want existing rows to be editable. That means:
I've got 5 records to display, and I would like to be able to remove and add new records but I don't want the user to edit the 5 existing records (I'd like him to be able to remove them).
Is that possible?
By default when you call the 'LVC_FIELDCATALOG_MERGE' function module to generate a field catalog for the CL_GUI_ALV_GRID, the cells are not editable.
You must set which column is going to be edited setting the 'edit' attribute like this:
...
data: it_fieldcat type lvc_t_fcat,
wa_fieldcat like line of it_fieldcat.
call function 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSTRUCT'
CHANGING
ct_fieldcat = it_fieldcat.
loop at it_fieldcat into wa_fieldcat.
wa_fieldcat-edit = 'X'. " ---->Here is set the editable column
modify it_fieldcat from wa_fieldcat.
endloop.
If you don't want cells to be edited do not set this attribute.
But for better reference check programs 'BCALV_EDIT_03' and 'BCALV_EDIT_04' for complete examples.
Hope it helps.
The problem is I want that some cell of checkbox column in my WD ALV will be editable some cell will be non editable depending on some property.
I make next steps to achieve the required result:
1) Add attribute READONLY type WDY-BOOLEAN to the corresponding node ( attribute CHECK type WDY-BOOLEAN has already added ) .
2) Then in my code I Check some conditions in row of my table and assign attribute READONLY value abap_true or abap_false.
3) Then I bind my node with table. Table is filled correctly, I checked in debugger.
4) Configure my alv:
DATA: lo_table_settings TYPE REF TO if_salv_wd_table_settings,
lo_column_settings TYPE REF TO if_salv_wd_column_settings,
lo_column TYPE REF TO cl_salv_wd_column.
lo_column_settings ?= lv_value.
lo_table_settings ?= lv_value.
lo_column = lv_value->if_salv_wd_column_settings~get_column( 'CHECK' ).
DATA lr_checkbox TYPE REF TO cl_salv_wd_uie_checkbox.
" create checkbox
CREATE OBJECT lr_checkbox
EXPORTING checked_fieldname = 'CHECK'.
" make our table is editable
lo_table_settings->set_read_only( abap_false ).
lo_column = lo_column_settings->get_column( 'CHECK' ).
" Creating UI Elmenent 'INPUT FIELD' to make the column editable
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'CHECK'.
lr_checkbox->set_read_only_fieldname( value = 'READONLY' ).
lv_value->if_salv_wd_column_settings~delete_column( ID = 'READONLY' ).
But it doesn't work, all of cells of checkbox column is editable and I don't get non editable cells of checkbox column.
To make a field A editable or readonly, it's only a matter of "using a field B's value to the A's readonly property".
So, as I understand , you have a column which is checkbox, and you want some rows to be editable ,and others to be readonly.
To do so, you won't need to create input field, the only thing you need to do is get the checkbox column reference and set its readonly property bind to the field in your data structure.
if that still doesn't work, check your data, whether the readonly field's value of each record is '', if yes, then of course, every cell of the check will be editable.
Your first step is correct. You added attribute READONLY of type WDY-BOOLEAN to your node and assigned it abap_true value before calling the grid.
The next step is to create input field reference for each field/row which you wanna make editable and assign this reference to the field attribute READONLY and change this attribute only for the lines that fit the condition.
Here is the sample code:
Initial assignment
loop at lt_table assigning field-symbol(<fs_table>).
<fs_table>-read_only = abap_true. " non editable
endloop.
Setting column editibility
* input type reference
data lr_input type ref to cl_salv_wd_uie_input_field.
* Retrieving all column id and reference
call method lv_value->if_salv_wd_column_settings~get_columns
receiving
value = data(lt_columns).
loop at lt_columns into ls_columns.
* Assigning column reference
data(lr_column) = ls_columns-r_column.
* Creating input field UI Element
create object lr_input
exporting
value_fieldname = ls_columns-id.
*Assigning input field to column to make it as editable
call method lr_column->set_cell_editor
exporting
value = lr_input.
* binding input field ref to READONLY field
lr_input->set_read_only_fieldname( value = "READONLY" ).
endloop.
Making single lines editable based on condition
loop at lt_table assigning field-symbol(<fs_table>).
if smth = abap_true
<fs_table>-read_only = abap_false. " non editable
endif.
endloop.
Check this guide for reference.
I'd want to be able to have multiple range selections for "Sales order no."
Problem is: when i press the button marked with green, i get the error "Fill in all required entry fields".
I put my main processing block at the START-OF-SELECTION event.
What to do to not have this happen? It seems to me that i should be able to add multiple selections without all the hassle of first filling every other mandatory field.
With parameters/select-options set to OBLIGATORY, this won't work. I had the very same problem some time ago, and had no chance to fill the OBLIGATORY input parameters with useful values by default, so I did the following:
Remove the OBLIGATORY option from all select-options and parameters
Handle the check for obligatory input yourself in cases no F4,help, F1 help or the button next to any select option is pressed:
Code:
AT SELECTION-SCREEN ON s_reswk.
IF sy-ucomm(1) <> '%' AND " sel screen action request
sy-ucomm(1) <> '_' AND " scope option
s_reswk IS INITIAL. " Obligatory input missing
MESSAGE text-e01 TYPE 'E'. " Error message
ENDIF.
Here's what i found that completely reproduces the behavior set by the OBLIGATORY addition:
1:Take OUT the "OBLIGATORY" addition.
2:at PBO:
LOOP AT SCREEN.
IF screen-name cs 'name-of-your-select-options-or-parameter'.
screen-required = 2.
MODIFY SCREEN.
ENDIF.
3: at PAI:
if sscrfields-ucomm = 'ONLI'.
if 'name of your select-option-or-parameter' is initial.
clear sscrfields.
message 'Fill in all required fields.'(009) type 'E'.
endif.
endif.
Notice the first if statement contains a 'cs' logical operator. That's cuz the name of your control will contain other weird stuff as well. For instance %_P_MATNR_%SCREEN%% (where your parameter was p_matnr).
Also, the declaration : TABLES sscrfields. is necessary.