ALV resfresh working fine in SE80 but not with Z tcode - abap

I'm using this code to refresh my ALV-Grid:
CALL METHOD go_alv->refresh_table_display
EXPORTING
is_stable = is_stable.
go_alv is TYPE REF TO cl_gui_alv_grid.
is_stable is TYPE lvc_s_stbl and set like this:
is_stable-row = 'X'.
is_stable-col = 'X'.
This works with no problems when the Report is started in SE80. But when I open the Report using the T-Code I created for it in SE93, the Grid does get refreshed, but the is_stabale parameter is somehow ignored. As a result, the scroll position is reseted.
I tried playing around with the GUI Options in the TCODE, but it didn't work.

It behaves the same whatever it's started via a report or via a transaction code.
You can check by yourself with this little program, then create a transaction code running this program and check whether the problem still occurs. If not, then check what's different in your code. If you don't find any difference, simplify your code, or recreate a separate program and transaction code, etc., anything which can help you solve the issue.
TABLES sscrfields.
DATA go_alv TYPE REF TO cl_gui_alv_grid.
DATA gt_sflight TYPE TABLE OF sflight.
PARAMETERS dummy.
SELECTION-SCREEN FUNCTION KEY 1.
AT SELECTION-SCREEN OUTPUT.
sscrfields-functxt_01 = 'Refresh'.
IF go_alv IS INITIAL.
CREATE OBJECT go_alv
EXPORTING
i_parent = cl_gui_container=>screen0.
SELECT * FROM sflight INTO TABLE gt_sflight.
go_alv->set_table_for_first_display(
EXPORTING i_structure_name = 'SFLIGHT'
CHANGING it_outtab = gt_sflight ).
ENDIF.
AT SELECTION-SCREEN.
IF sscrfields-ucomm = 'FC01'.
DATA gs_sflight TYPE sflight.
MODIFY gt_sflight FROM gs_sflight TRANSPORTING price currency WHERE price <> 0.
DATA: ls_stbl TYPE lvc_s_stbl.
ls_stbl-col = abap_true.
ls_stbl-row = abap_true.
DATA: l_soft TYPE char01.
l_soft = abap_true. " do not recalculate totals
go_alv->refresh_table_display(
EXPORTING
is_stable = ls_stbl
i_soft_refresh = l_soft " default = false
EXCEPTIONS
finished = 1 ).
ENDIF.
AT SELECTION-SCREEN ON EXIT-COMMAND.
go_alv->free( ).
FREE go_alv.

Related

Checking if a report uses hierarchical ALV or not. How?

I found a way to export a hierarchical ALV with the help of this question. Unfortunately I don't know in advanced if the report uses hierarchical ALV or not.
If I apply the code of above answer to the report RFSKPL00, then I get an exception in cl_salv_bs_runtime_info=>get_data() here:
if t_data_line is requested.
import t_data_line to t_data_line from memory id cl_salv_bs_runtime_info=>c_memid_data_line.
if sy-subrc ne 0.
raise exception type cx_salv_bs_sc_runtime_info <=========
exporting
textid = 'ERROR'.
endif.
endif.
How can I check in ABAP if a report uses hierarchical ALV or not?
You can use TRY / CATCH / ENDTRY to prevent dumps based on catchable class based exceptions:
DATA lx_runtime_info TYPE REF TO cx_salv_bs_sc_runtime_info.
TRY.
cl_salv_bs_runtime_info=>get_data(
IMPORTING
t_data = <lt_data>
t_data_line = <lt_data_line>
).
CATCH cx_salv_bs_sc_runtime_info INTO lx_runtime_info.
DATA(lv_result) = lx_runtime_info->if_message~get_text( ).
DATA(lv_result_long) = lx_runtime_info->if_message~get_longtext( ).
ENDTRY.
(ST22 will always tell you which exception class you have to use.)
As all exception classes are subclasses (sub-subclasses, sub-sub-subclasses, etc.) of CX_ROOT, so you can use the methods get_text and get_longtext to get more information (implemented through interface if_message) about the problem.
To determine whether the ALV is a classic ALV or a hierarchical-sequential list :
IF cl_salv_bs_runtime_info=>get( )-structure_line IS INITIAL.
"---------------------
" classic ALV
"---------------------
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = DATA(lr_data) ).
ELSE.
"---------------------
" hierarchical-sequential list
"---------------------
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lr_data
r_data_line = DATA(lr_data_line) ).
ENDIF.
I wanted the same information and the answer by Sandra didn't help me/didn't work, because the parameters just wouldn't fill. But cl_salv_bs_runtime_info has another function that solved my problem, get_metadata. It has a parameter is_hierseq that gets filled as expected.
DATA: lr_data TYPE REF TO data,
lr_data_line TYPE REF TO data.
FIELD-SYMBOLS: <lt_data> TYPE ANY TABLE,
<lt_data_line> TYPE ANY TABLE.
" initialising runtime analysis
cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false
metadata = abap_true
data = abap_true ).
* ALV grid / hierarchical output:
CALL TRANSACTION 'MB51'.
* Testing output mode using metadata
DATA(runtime_metadata) = cl_salv_bs_runtime_info=>get_metadata( ).
IF runtime_metadata-is_hierseq IS INITIAL.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data_descr = DATA(lr_data_descr) ).
CREATE DATA lr_data TYPE HANDLE lr_data_descr.
ASSIGN lr_data->* TO <lt_data>.
cl_salv_bs_runtime_info=>get_data( IMPORTING t_data = <lt_data> ).
ELSE. " hierarchical
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data_descr = lr_data_descr
r_data_line_descr = DATA(lr_data_line_descr) ).
CREATE DATA lr_data TYPE HANDLE lr_data_descr.
CREATE DATA lr_data_line TYPE HANDLE lr_data_line_descr.
ASSIGN lr_data->* TO <lt_data>.
ASSIGN lr_data_line->* TO <lt_data_line>.
cl_salv_bs_runtime_info=>get_data( IMPORTING t_data = <lt_data>
t_data_line = <lt_data_line> ).
ENDIF.
In the case of a simple SALV grid <lt_data> var contains the output, and in the case of a hierarchical ALV list the result will be in <lt_data_line> instead.

EKPO fields not updated after PROCESS_ITEM method set_data in ME21N

I'm trying to change field WEORA and BSTAE in ME21n through BADI me_process_po_cust, method PROCESS_ITEM. I have successfully changed the value in the screen, BUT when I saved the PO, table EKPO is not updated with the new value. Am I missing something? Do I need to commit?
DATA: ls_mepoitem_set TYPE mepoitem.
DATA: cl_po TYPE REF TO cl_po_header_handle_mm.
DATA: ls_mepoitem TYPE mepoitem.
FIELD-SYMBOLS: <fs_item> TYPE mepoitem.
ls_mepoitem = im_item->get_data( ).
ls_mepoitem_set = ls_mepoitem.
ls_mepoitem_set-bstae = '0004'.
ls_mepoitem_set-weora = abap_true.
ASSIGN ls_mepoitem_set TO <fs_item>.
CALL METHOD im_item->set_data( EXPORTING im_data = <fs_item> ).
cl_po ?= lm_poheader.
IF NOT cl_po->my_recheck_queue IS INITIAL.
CLEAR cl_po->my_recheck_queue.
ENDIF.
Please check if there is project enhancement implentation for PO which might be updating field values.
regards,
Umar Abdullha
I had the same mistake and I was able to resolve it by using the same code shown before in IF_EX_ME_PROCESS_PO_CUST->PROCESS_ITEM.
I had to call im_item->get_data( ) to get the data from the position and the set method work perfectly.

Crash "Field symbol has not yet been assigned" when calling REUSE_ALV_GRID_DISPLAY

While displaying an ALV I get a crash report when executing the program. To create an ALV I have followed a few tutorials and stuff and at the moment it looks like this:
TYPE-POOLS: slis.
*build field catalog
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
repid TYPE sy-repid.
REFRESH it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Table ID'.
wa_fieldcat-fieldname = 'table_id'.
wa_fieldcat-tabname = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen = '18'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Table Description'.
wa_fieldcat-fieldname = 'table_description'.
wa_fieldcat-tabname = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen = '40'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Numer of Records Found'.
wa_fieldcat-fieldname = 'nr_of_records'.
wa_fieldcat-tabname = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen = '30'.
APPEND wa_fieldcat TO it_fieldcat.
*pass data and field catalog to ALV function module
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
it_fieldcat = it_fieldcat
i_structure_name = 'lty_where_used_data_of_coll'
TABLES
t_outtab = lt_where_used_data_of_coll.
'lt_where_used_data_of_coll' is my local table that I have already filled with a working function earlier in my program. This function works and I have tested it and the table fills itself with data. My next step was displaying this data to the end user. The error report I receive when executing this program is:
Short text: Field symbol has not yet been assigned.
What happened?:
Error in the ABAP Application Program.
The current ABAP program "SAPLSLVC" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis:
You attempted to access an unassigned field symbol
(data segment "-1").
Trigger Location of Runtime Error:
Program SAPLSLVC
Include LSLVCF36
Row 3,273
Module type (FORM)
Module Name FILL_DATA_TABLE
I really don't know how to start finding my mistake. It seems like it runs bad when calling a function from ABAP itself.
Any help is much appreciated.
EDIT: As was suggested I implemented another way of displaying an ALV that can be found below. This way works fine and gives no errors. Question still remains why the older method does give me an error.
I replaced the entire block of code above with this:
DATA alv TYPE REF TO cl_salv_table. DATA message TYPE REF TO cx_salv_msg.
*initialize ALV
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = lt_where_used_data_of_coll ).
CATCH cx_salv_msg INTO message.
" error handling
ENDTRY.
*display ALV
alv->display( ).
why the older method does give me an error
Field catalog names are case sensitive. Capitalize every fieldname and tabname value and see if the error's still there. Also make sure that the names match those of your internal table lt_where_used_data_of_coll

ABAP CALL TRANSACTION and fill variant field

I used this bit of code the exact same way in a previous program and it worked. Now I am using it to apply to a transaction with a range available for the field I want to fill with the information clicked on the hotspot. It is not placing anything in the field when taken to ME2N view. Any suggestions?
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'EBELN'.
READ TABLE itab_usr INTO wa_usr INDEX rs_selfield-tabindex.
SET PARAMETER ID 'BES' FIELD wa_usr-ebeln.
CALL TRANSACTION 'ME2N'.
ENDIF.
ENDCASE.
ENDFORM.
What you're doing is basically writing something on the wall and then nudging the next person. It's up to the next person to decide whether they want to read whatever's written on the wall. The parameters area is just a global memory - perhaps the called program will do something about it, but unless it states so in its documentation, you can't rely on that.
In the case of ME2N, you may want to examine the transaction and find out that it simply calls the selection screen of a report, let's say RM06EN00. You may then want to look up the keyword SUBMIT and the relevant documentation about filling the selection screen of a called program.
You can find more information from here.
DATA : WA_FCAT TYPE LVC_S_FCAT,
IT_FCAT TYPE STANDARD TABLE OF LVC_S_FCAT,
OB_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
OB_GRID TYPE REF TO CL_GUI_ALV_GRID,
G_VARIANT LIKE DISVARIANT,
LT_DEMO_DATA TYPE TABLE OF ZDEMO_TABLE.
INITIALIZATION.
START-OF-SELECTION.
" GET DATA .
REFRESH LT_DEMO_DATA.
SELECT * INTO TABLE LT_DEMO_DATA FROM ZDEMO_TABLE.
PERFORM FIELDCAT.
CALL SCREEN 1001.
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO.
ENDCLASS.
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD HANDLE_HOTSPOT_CLICK .
PERFORM HOTSPOT_CLICK USING E_ROW_ID E_COLUMN_ID.
ENDMETHOD.
ENDCLASS.
FORM HOTSPOT_CLICK USING E_ROW TYPE LVC_S_ROW E_COLUMN_ID TYPE LVC_S_COL.
DATA : WA_DEMO TYPE ZDEMO_TABLE.
READ TABLE LT_DEMO_DATA INTO WA_DEMO INDEX E_ROW-INDEX.
SET PARAMETER ID 'MAT' FIELD WA_DEMO-MATNR.
CALL TRANSACTION 'MB51'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Module STATUS_1001 OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_1001 OUTPUT.
SET PF-STATUS 'STANDARD_FULLSCREEN'.
SET TITLEBAR 'TITLE'.
IF G_VARIANT IS INITIAL.
G_VARIANT-REPORT = SY-REPID.
G_VARIANT-USERNAME = SY-UNAME.
ENDIF.
"Object creation for custom container exporting the name
CREATE OBJECT OB_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = 'ALV_GRID'.
CREATE OBJECT OB_GRID
EXPORTING
I_PARENT = OB_CUSTOM_CONTAINER.
CALL METHOD OB_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT = G_VARIANT
I_DEFAULT = 'X'
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = IT_FCAT
IT_OUTTAB = LT_DEMO_DATA.
**** For Hotspot Event Handling
DATA: G_HANDLER TYPE REF TO LCL_EVENT_HANDLER.
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR OB_GRID.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Form FIELDCAT
*&---------------------------------------------------------------------*
ENDFORM.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1001 INPUT
*&---------------------------------------------------------------------*
MODULE USER_COMMAND_1001 INPUT.
IF SY-UCOMM = '&F03' OR SY-UCOMM = '&F12' OR SY-UCOMM = '&F15'.
FREE: OB_GRID.
REFRESH: LT_DEMO_DATA.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.

Alv OO program error Message no. 0K534

Everytime i hit enter or any command button the program prompt an error message.
base on this thread http://scn.sap.com/thread/65856 i should declare my internal table
globally on top include.
Even though i already added all variable globally still the error is the same.
Top Include.
data: gr_data type ref to data.
data: la_data type ref to data.
field-symbols: <gt_data> type standard table.
Classs Declaration
me->get_data( CHANGING c_data = <f_tab> ). " Fetch Dynamic Data
METHOD get_data.
GET REFERENCE OF c_data INTO la_data.
move la_data TO gr_data.
assign gr_data->* to <gt_data>.
me->display( ).
assign gr_data->* to <gt_data>.
IF gc_custom_container is initial.
CREATE OBJECT gc_custom_container
EXPORTING
container_name = gv_mycontainer.
ENDIF.
if table is not bound.
try.
"// Create ALV Instance
cl_salv_table=>factory(
exporting
r_container = gc_custom_container
container_name = 'TC_MIXING'
importing
r_salv_table = table
changing
t_table = <gt_data>
).
catch cx_salv_msg. "#EC NO_HANDLER
endtry.
"// Setup ALV Attributes
functions = table->get_functions( ).
functions->set_all( abap_true ).
columns = table->get_columns( ).
columns->set_optimize( abap_true ).
try.
column = columns->get_column( 'MANDT' ).
column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found.
endtry.
"// Dispalay ALV Model
table->display( ).
else.
table->refresh( ).
endif.
ENDMETHOD.
and another question:
how to create structure dynamically base on field-symbol. is this possible?
ls_testvar like line of <f_tab>.
thanks and regards,
Mapet
Question two is possible, with some usage of runtime type services.
Take a look at runtime type services.
se24
CL_ABAP_CLASSDESCR Run Time Type Services
CL_ABAP_DATADESCR Run Time Type Services
CL_ABAP_ELEMDESCR Run Time Type Services
CL_ABAP_INTFDESCR Run Time Type Services
CL_ABAP_OBJECTDESCR Run Time Type Services
CL_ABAP_REFDESCR Run Time Type Services
CL_ABAP_STRUCTDESCR Run Time Type Services
CL_ABAP_TABLEDESCR Run Time Type Services
CL_ABAP_TYPEDESCR Run Time Type Services
You can get the type of the fieldsymbol and create a structure based on it, perhaps You have to iterate through fieldsymbol, if it is composed type and add each component.
I agree, you should not pass a field symbol to the changing parameter for the table data! Use a global or static table. You should also use a typed table instead of data and create your field catalog in design time. This improves the performance a lot.
Cheers
Your table variable holding the ALV must be declared globally as well.
cl_salv_table=>factory(
exporting
r_container = gc_custom_container
container_name = 'TC_MIXING'
importing
r_salv_table = table
changing
t_table = <gt_data>
).
You should separate data retrieving from your displaying code like this:
START-OF-SELECTION.
gr_class->get_data( ).
CALL SCREEN 2000.
PBO:
gr_class->display.
Your display method:
METHOD display IMPLEMENTATION.
IF me->gr_container IS NOT BOUND.
gr_table->display( ).
ELSE.
gr_table->refresh( ).
ENDIF.