Problem with Enable/Disable a button on SALV Full Screen - abap

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

Related

How to hide conditionally custom fields in screen exit? (CMOD)

My task is to customize the Header Details Screen of the ME33K transaction, the goal is to add a box with new fields that should appear only if the Agreement type is the one I defined by using the transaction SPRO (ex: Agreement type ABC).
I started making an enhancement to that screen by using the CMOD transaction, I created a dummy box and field with some hard-coded input value and it's working fine.
My next step would be to make these new fields appear only if the Agreement is of type ABC, but I cannot find the correct approach.
I tried doing some Screen-Loop programming and deactivating the box and/or fields, but the only ones that get deactivated are the standard ones that exist already, the ones I added with the enhancement are not affected.
EDIT :
The enhancement I used was 'MM06E005'.
I wrote the following Screen-Loop code in the include provided in the 'EXIT_SAPMM06E_006' user exit :
loop at screen.
if screen-name = 'CUSTOM_FIELDS'.
screen-active = 0.
modify screen.
endif.
endloop.
The enhancement MM06E005 refers to the subscreen SAPLXM06 0101, that you have created with a box with all your custom screen fields.
To hide your custom screen fields, you must:
Call a PBO (Process Before Output) module, to be done in the flow logic of your subscreen (the one which contains the screen fields):
PROCESS BEFORE OUTPUT.
...
MODULE modify_screen_field_attributes.
...
PROCESS AFTER INPUT.
...
In the include LXM06O01 (preferrably), do this:
MODULE modify_screen_field_attributes OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'CUSTOM_FIELDS'. " name of one screen field
screen-active = 0. " hide the screen field
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDMODULE.

Unhide a column in ALV grid

I have two SAP systems with the same program.
The column Nome 2 is displayed in the ALV grid of the system1 but in the ALV grid of the system2 is hidden and when select the details you could see the Nome 2 value in both sistems.
The program uses field catalog to pass a list of fields to display in ALV, and also uses the function 'REUSE_ALV_GRID_DISPLAY'.
I would be very pleased if someone have any suggestions that could solve it.
Regards,
Nataly
Check the no-out property of fieldcatalog in system 1. It seems to be enabled there:
You suppose to search lines like this:
IF T_FIELDCAT-FIELDNAME = 'NOME1'.
T_FIELDCAT-NO_OUT = 'X'.
MODIFY T_FIELDCAT INDEX sy-tabix.
ENDLOOP.
Remove NO-OUT line and voilá!

Dynamically update row contents via dialog screen

I need some help with the following problem. I currently have one dialog screen with a field in which a user can type a number. This number corresponds with an ID field in a database table I've made (using se/11). I want to display the contents of all fields (so only one row of the table) with the corresponding ID on a second screen. The user should also be able to edit the information in the fields and, after saving, those changes should be visible in the table itself. What it comes down to is that I want to dynamically change the contents of the returned row through the dialog screen. I know I have to use a Table Control, but apart from that I'm at a loss (I'm pretty new to ABAP).
Here's the table
Screen 1 where a user can input a number that corresponds to SEQNR in the table
When pressing F8 on Screen 1, I want to go to a second screen with the information of the person with SEQNR = 1, in other words, only this row should appear:
The user should be able to edit the information in this row. When he clicks "Save", the edited information should be updated in the table itself.
So far, I only made a standard second screen in which I added a Table Control for the above table in Screen Painter. I added this control to my DIALOG_TOP:
PROGRAM TAAK1.
DATA: OK_CODE TYPE sy-ucomm,
ls_table TYPE TABEL1,
SEQNR_TEXTFIELD TYPE i,
TXT_STATUS(25) TYPE c,
it_table LIKE TABEL1 OCCURS 0 WITH HEADER LINE.
TABLES: TABEL1.
CONTROLS: TABLE_CONTROL TYPE TABLEVIEW USING SCREEN 200.
I have no code for screen 2, other than the standard PBO and PAI Modules.
The code for screen 1 looks like this.
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'CHECKID'.
SELECT SINGLE * FROM TABEL1 WHERE SEQNR EQ SEQNR_TEXTFIELD.
IF sy-subrc EQ 0.
TXT_STATUS = 'ID BESTAAT'.
ELSE.
TXT_STATUS = 'ID BESTAAT NIET'.
ENDIF.
IF TXT_STATUS = 'ID BESTAAT'.
SELECT * FROM TABEL1 INTO ls_table WHERE SEQNR EQ SEQNR_TEXTFIELD.
ENDSELECT.
ENDIF.
WHEN 'EXEC'.
CLEAR OK_CODE.
SET SCREEN 200.
LEAVE SCREEN.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
I basically check if the Seqnr exists in the table. If it does, I store the corresponding row in a local structure which I've defined in the DIALOG_TOP.
It's probably easier and less time consuming to use an SM30 view. You can create a custom transaction to maintain the correct authorizations. Additionally you can adjust the screens (see the code of the generated function group) to your liking's.
More info here:
https://help.sap.com/saphelp_nw73ehp1/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
https://archive.sap.com/discussions/thread/851998
http://saptechnical.com/Tutorials/ABAP/TableMaintenance/demo.htm

Deleted Table Control leads to run time error

I have a screen with one table control which displayed values from my internal db.
It worked out flawlessly.
I added another table control which didn't worked out the way i wanted.
I deleted the control CONTROLS: tc_two TYPE TABLEVIEW USING SCREEN 9000.
And now I'm getting a runtime error CONTROL-Variable not found.
Q: What happens if i declare new Controls? Where do they get implemented?
I tried to debug my code and the error appears at CALL SCREEN 9000.
Here is the full code:
REPORT zsch_test.
CONTROLS: tc_one TYPE TABLEVIEW USING SCREEN 9000.
DATA: it_uebung TYPE TABLE OF zsch_uebung,
ok_code TYPE sy-ucomm,
fill TYPE i.
TABLES zsch_uebung.
DATA: lines TYPE i,
limit TYPE i.
SELECT * FROM zsch_uebung INTO CORRESPONDING FIELDS OF TABLE it_uebung WHERE status = '1'.
CALL SCREEN 9000.
MODULE status_9000 OUTPUT.
SET PF-STATUS 'STATUS9000'.
* SET TITLEBAR 'xxx'.
DESCRIBE TABLE it_uebung LINES fill.
tc_one-lines = fill.
ENDMODULE.
MODULE fill_table_control OUTPUT.
READ TABLE it_uebung INTO zsch_uebung INDEX tc_one-current_line.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE read_table_control INPUT.
lines = sy-loopc.
MODIFY it_uebung FROM zsch_uebung INDEX tc_one-current_line.
ENDMODULE.
MODULE user_command_9000 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
Screen 9000:
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
LOOP WITH CONTROL TC_ONE.
MODULE fill_table_control.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
LOOP WITH CONTROL TC_ONE.
MODULE read_table_control.
ENDLOOP.
MODULE USER_COMMAND_9000.
Thanks!
sadly it's in german
From the fact that the problem disappeared apparently without further action, one might assume that this was either a buffer issue (which is why you should re-start the entire transaction when testing a changed program) or you accidentally failed to activate the entire program (and, for example activated only the report source, but not the screen definition).

Event for back button after AT LINE SELECTION in ABAP list report?

I have a list report that uses the event block AT LINE SELECTION (and HIDE).
AT LINE-SELECTION.
WRITE: 'Testline'.
* and some more things
When I double click on a line in the main list, AT LINE SELECTION is processed, and the main list is replaced with a list that consists of the text 'Testline'.
When I klick on the green back button, the main list is shown again.
Everything works as espected.
Now to my question:
Is there some way how the report can be notified when the user clicks on the green back button to go from the detail list to the main list?
The obvious solution AT USER-COMMAND is not called.
This is the event where I want to SUBMIT the same report again to update the list.
(I know I could do this with an ALV report, but is this possible with a simple list report?)
When you check the documentation you will find the following information:
The function codes PICK and PF## ("##" stands for 01 to 24) do not cause the event AT USER-COMMAND, but the events AT LINE-SELECTION and AT PF##.
All function codes that start with the character "%" are interpreted as system functions and do not cause the event AT USER-COMMAND. The system functions for lists are listed in the following table 1.
The function codes in the following table 2, likewise, do not cause the event AT USER-COMMAND, but are handled by the list processor.
table 2 includes BACK (that's the default code for the green arrow).
What you can do: Write your own status.
REPORT ytest.
DATA pf_exclude TYPE TABLE OF sy-ucomm WITH HEADER LINE.
START-OF-SELECTION.
SET PF-STATUS 'LIST'. "<--- here
WRITE: / 'Hello World'.
AT LINE-SELECTION.
WRITE: 'Testline'.
* and some more things
AT USER-COMMAND.
BREAK-POINT.
CASE sy-ucomm.
WHEN 'MYBACK'.
ENDCASE.
Now you can define your own status:
Don't forget to define PICK - or the double click will not work.
Define your own back-function.