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.
Related
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.
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.
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
I am new to SAP, and am encountering an issue I am not sure how to resolve.
I am setting a property to '' (empty), but it is not being displayed as such.
There is existing logic that sets specific fields to 'Display Only' when a checkbox is checked. I am working to extend this to clear any data that is within those fields. Due to how the original logic was implemented, this change is being handled in the "Get_..." method (may be moved to an event handler once I get it working).
Currently, the logic sets the property to be empty (I have confirmed this with debug); however, the webpage keeps the original value. A shortened outline of the code is below (all try catches, etc. removed to keep it short and simple):
DATA: current TYPE REF TO if_bol_bo_property_access.
DATA: dref TYPE REF TO data.
current = collection_wrapper->get_current( ).
dref = current->get_property( 'FIRSTNAME' ).
* If condition
DATA: copy TYPE REF TO data.
FIELD-SYMBOLS:
<nval> TYPE ANY,
<oval> TYPE ANY.
ASSIGN dref->* TO <oval>.
CREATE DATA copy LIKE <oval>.
CLEAR value.
TRY.
CALL METHOD if_bsp_model_util~convert_from_string
EXPORTING
data_ref = copy
value = value
attribute_path = attribute_path.
CATCH cx_sy_conversion_error.
RAISE EXCEPTION TYPE cx_bsp_conv_failed
EXPORTING
name = 'FIRSTNAME'.
ENDTRY.
current->set_property_as_string(
iv_attr_name = 'FIRSTNAME'
iv_value = value ).
value = current->get_property_text( 'FIRSTNAME' ). "Check empty ''
Most of this was pulled from the 'Set_...' method. Any help would be appreciated.
This issue is due to the CRM browser autosaving before the case is complete. This causes the values to be rendered as though they are cached.
Note 2104051 resolves this.
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.