2012 Feb 13 10:06 AM
Dear All,
I have created an ALV report with few of the cells are editable, where-in user can input some values.
Upon clicking some 'push button' I am trying to read these input values back into the program for further processing.
I assume, we can do this using custom container using OOPs., but I need to get these values in the procedural ALV.
Can you pl. give some hint on the above.
BR \
Mahesh
2012 Feb 13 10:17 AM
Yes you can achieve the same by FM ALV's also.
Use the event USER_COMMAND to capture the push button click, and then play around with the changed data
Cheers
Abhinab.
Dear All,
I have created an ALV report with few of the cells are editable, where-in user can input some values.
Upon clicking some 'push button' I am trying to read these input values back into the program for further processing.
I assume, we can do this using custom container using OOPs., but I need to get these values in the procedural ALV.
Can you pl. give some hint on the above.
BR \
Mahesh
2012 Feb 13 10:17 AM
Yes you can achieve the same by FM ALV's also.
Use the event USER_COMMAND to capture the push button click, and then play around with the changed data
Cheers
Abhinab.
2012 Feb 13 10:44 AM
Hi Mahesh,
Just write this code when your push button is pressed -
DATA: REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
CLEAR: REF_GRID.
IF REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING "getting alv grid details
E_GRID = REF_GRID.
IF SY-SUBRC <> 0. "#EC *
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IF NOT REF_GRID IS INITIAL.
CALL METHOD REF_GRID->CHECK_CHANGED_DATA. "checking and modifying
"changes in internal table
ENDIF.
Modify zsold_to_status from TABLE i_soldto. "modifying data into
"database table
In this, i_soldto is my internal table using which i am displaying my ALV.
So, after executing
CALL METHOD REF_GRID->CHECK_CHANGED_DATA. "checking and modifying
"changes in internal table
your alv internal table i_any_name (here i_soldto), will be having the changed data. You can process it.
I have used it to modify my database table.(Zsold_to_status).
Regards,
Harsh Bansal
2012 Feb 13 10:47 AM
2012 Feb 14 6:01 AM
Hi Mahesh,
First of all I am displaying alv grid and after that I used USER_COMMAND event on the first alv. In the first alv I am changing the vbeln value by setting the property at the fieldcatalog level LS_FCAT_EDIT = 'X' at the vbeln(SALES DOCUMENT).
After that i am editing the vbeln value and after that When I double click on the field vbeln value , Based on the vbeln value the corresponding item details will be displayed.
The following code is:
type-pools : slis.
data : lv_vbeln type vbak-vbeln.
types : BEGIN OF ty_vbak,
vbeln type vbak-vbeln,
erdat TYPE vbak-erdat,
erzet TYPE vbak-erzet,
ernam type vbak-ernam,
end of ty_vbak.
data : lt_vbak type STANDARD TABLE OF ty_vbak,
ls_vbak type ty_vbak.
types : begin of ty_vbap,
vbeln type vbap-vbeln,
posnr type vbap-posnr,
matnr TYPE vbap-matnr,
end of ty_vbap.
data : lt_vbap type STANDARD TABLE OF ty_vbap,
ls_vbap type ty_vbap.
data : lt_fcat type SLIS_T_FIELDCAT_ALV,
ls_fcat like LINE OF lt_fcat.
data : lt_events type SLIS_T_EVENT,
ls_events like line of lt_events.
SELECT-OPTIONS so_vbeln FOR lv_vbeln.
INITIALIZATION.
so_vbeln-low = '4970'.
so_vbeln-high = '4975'.
append so_vbeln.
START-OF-SELECTION.
perform getdata.
if sy-subrc eq 0.
perform fldcat.
perform events.
perform display.
endif.
form GETDATA .
select vbeln erdat erzet ernam FROM vbak
into CORRESPONDING FIELDS OF TABLE lt_vbak
where vbeln in so_vbeln.
endform. " GETDATA
form FLDCAT .
clear ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-col_pos = 1.
ls_fcat-seltext_m = 'Sales No'.
ls_fcat-outputlen = 10.
ls_fcat-edit = 'X'.
APPEND ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERDAT'.
ls_fcat-col_pos = 2.
ls_fcat-seltext_m = 'Date'.
ls_fcat-outputlen = 10.
APPEND ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERZET'.
ls_fcat-col_pos = 3.
ls_fcat-seltext_m = 'Time'.
ls_fcat-outputlen = 10.
APPEND ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERNAM'.
ls_fcat-col_pos = 4.
ls_fcat-seltext_m = 'Created By'.
ls_fcat-outputlen = 10.
APPEND ls_fcat to lt_fcat.
endform. " FLDCAT
form pf-status USING status.
set PF-STATUS 'SETABC'.
ENDFORM.
form DISPLAY .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IT_FIELDCAT = lt_fcat[]
IT_EVENTS = lt_events[]
TABLES
t_outtab = lt_vbak[].
endform. " DISPLAY
form EVENTS .
clear lt_events.
ls_events-name = 'USER_COMMAND'.
ls_events-form = 'ZITEM'.
append ls_events to lt_events.
endform. " EVENTS
form zitem using ucomm type sy-ucomm
sel type slis_selfield.
read table lt_vbak into ls_vbak index
sel-tabindex.
if sy-subrc eq 0.
clear lv_vbeln.
lv_vbeln = ls_vbak-vbeln.
if lv_vbeln is not INITIAL.
perform getvbap.
if lt_vbap[] is not INITIAL.
perform fieldcat.
perform displayvbap.
ENDIF.
endif.
endif.
ENDFORM.
form GETVBAP .
select vbeln posnr matnr FROM vbap into table lt_vbap
where vbeln = lv_vbeln.
endform. " GETVBAP
form FIELDCAT .
REFRESH lt_fcat[].
clear ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-col_pos = 1.
ls_fcat-seltext_m = 'Sales No'.
ls_fcat-outputlen = 10.
APPEND ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'POSNR'.
ls_fcat-col_pos = 2.
ls_fcat-seltext_m = 'Item No'.
ls_fcat-outputlen = 10.
APPEND ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-col_pos = 3.
ls_fcat-seltext_m = 'Material No'.
ls_fcat-outputlen = 10.
APPEND ls_fcat to lt_fcat.
endform. " FIELDCAT
form DISPLAYVBAP .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = lt_fcat[]
TABLES
t_outtab = lt_vbap[].
endform. " DISPLAYVBAP
Thanks & Regards,
Raghunadh . K
2012 Feb 14 8:23 AM
Hi Raghunadh,
This issue happens because the internal table associated with the output, is not refreshed.
Hence, in our call back subroutine, we need to write some extra code.
In your example, you can write the code inside the subroutine ZITEM, just before READ TABLE.
form zitem using ucomm type sy-ucomm
sel type slis_selfield.
"-----> insert code here
read table lt_vbak into ls_vbak index
sel-tabindex.
if sy-subrc eq 0.
clear lv_vbeln.
lv_vbeln = ls_vbak-vbeln.
if lv_vbeln is not INITIAL.
perform getvbap.The code to be inserted is:
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.Regards,
Amit Mittal.
2012 Feb 15 1:30 PM
Thanks Guys,
I have called the FM REUSE_ALV_GRID_DISPLAY twice in my program, to read back my edited values back into the program for further processing.
Appreciating your help.
BR
Mahesh
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |