Double clicking a row and column in ALV Grids - abap

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.

Related

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

Listbox error "Entry is too long for the field"

After selecting a value in a dropdown listbox field, there is this error message:
Entry is too long for the field
(it's the message number 00092)
I created one text field TXTOPENV as Listbox with key value, set value using VRM_SET_VALUES in PBO section.
Here is the screenshot of screen painter:
Screen flow logic:
PROCESS BEFORE OUTPUT.
MODULE status_0210.
ABAP code:
DATA txtopenv TYPE c LENGTH 1.
MODULE status_0210 OUTPUT.
SET PF-STATUS 'ST210'.
SET TITLEBAR 'T210'.
PERFORM GetVacancy.
ENDMODULE.
FORM GetVacancy.
TYPES: BEGIN OF ty_vacancy,
plans TYPE t528t-plans,
plstx TYPE t528t-plstx,
END OF ty_vacancy.
DATA: wa_vacancy TYPE ty_vacancy.
LOOP AT it_vacancyid INTO wa_vacancyid.
SELECT plans plstx
FROM t528t
INTO wa_vacancy
WHERE plans = wa_vacancyid-ty_objid.
ENDSELECT.
field_id = wa_vacancy-ty_plans.
value = wa_vacancy-ty_plstx.
APPEND value TO values.
CLEAR wa_vacancy.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'TXTOPENV'
values = values
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
ENDFORM.
The error "Entry is too long for the field" is not specifically related to the listbox fields, but may occur with all types of screen fields, so I will first answer the general case, and then explain why you were mistaken .
The error happens when the screen field is defined with a "definition length" which is larger than the length defined for the eponym global variable in the ABAP program (eponym: the name has to be the same so that to allow the transfer of values between screen and program, back and forth), and when the input value is larger than the length of the ABAP program.
In your case, the key of the selected value in the listbox is probably larger than 1 character which is the length of the global variable.
The solution in your case is to set the variable to 8 characters:
DATA txtopenv TYPE t528t-plstx.
NB:
In your screenshot of the listbox field with possible values, only the texts are shown, but you can also display the key value via SAP GUI settings Interaction Design > Visualization 1 > Show keys within dropdown lists.

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

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.

How to change input fields disregard of mandatory fields?

I have a dynpro with several mandatory fields. Now, I want to implement a button that prefills those fields with suggested values. Further, another button should deactive certain input fields.
My problem is that the button actions are stopped by the empty mandatory fields. Is there a way to skip those validations, if a certain button has been pressend and acces the PAI - PBO handling?
You must execute your action before the mandatory checks bloc other changes.
Instead of
MODULE ... INPUT
you can try
MODULE ... AT EXIT-COMMAND
Normally the AT EXIT-COMMAND allows you to leave the screen, even if the values are missing. But you can use it also to fill mandatory fields.
After filling the mandatory field I would call again the screen to process PBO/PAI again. So the user can see the new changed values.
One question: Could you also fill the values during PBO?
Something like:
MODULE ... OUTPUT.
IF field is initial.
field = default_value.
ENDIF.