Dynamically update row contents via dialog screen - abap

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

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.

Problem with Enable/Disable a button on SALV Full Screen

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

Get row ID when user double clicks the row in ALV report

I have a scenario which displays a list of purchase documents as ALV (function module REUSE_ALV_LIST_DISPLAY). By clicking on a purchase doc no, its specific details (e.g. NETPR) should show in a pop up. How should I do it?
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE r_ucomm.
WHEN '&IC1'.
READ TABLE ITAB INTO WA WITH KEY EBELN = WA-EBELN.
PERFORM popup_display.
ENDCASE.
ENDFORM. "user_command
Inside the subroutine in structure RS_SELFIELD is what you need:
field TABINDEX contains the line, which was double clicked (you can READ TABLE the internal table which holds the data with INDEX rs_selfield-tabindex) and field FIELDNAME contains the field, which was clicked (if that is relevant in your case).
Also check the documentation of the function module SE37 => Function Module Documentation, lots of useful information there see I_CALLBACK_USER_PROGRAM

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).

Double clicking a row and column in ALV Grids

Currently I have an ALV grid and I can double click to call transaction IE03 and pass the information in the first column (which is eqkt-equnr). However, this transaction is called regardless of what column you click on. This wouldn't be so bad, but I need to be able to call IW33 if you click on the 3rd column and pass along the equz-J_3GEIGNER value there.
My current double click code is as follows. t_report is my struct and matnr is the equnr part of it. maktx is the J_3GEIGNER part of it.
FORM user_command USING r_ucomm
wa_selrow TYPE slis_selfield.
IF r_ucomm = '&IC1'.
READ TABLE t_report INDEX wa_selrow-tabindex.
IF sy-subrc = 0.
SET PARAMETER ID 'EQN' FIELD t_report-matnr.
CALL TRANSACTION 'IE03' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDFORM.
Use the field wa_selrow-fieldname to determine which column was clicked. Be aware that you may have to switch the grid from row selection mode to cell selection mode - since you didn't show us how you created the grid in the first place, I can't tell you how to do this in your case. Take a look at the SEL_MODE property, it might help.