Dynamical Call of ALV - No data update
Hi,
I tried to use use the ALV dynamically. With dynamically I mean that I that I have diffrent data structures, depending what was selected by the user. The first call of the program is always correct. The data is displayed correctly. But when the data structure is changing, the ALV display is not updated. For a better understanding I post a extract of my coding:
<b>1. Creation of Container</b>
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'PARENT_CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
ASSERT 1 = 2.
ENDIF.
<b>2.Creation of splitter container</b>
CREATE OBJECT splitter
EXPORTING
parent = g_custom_container
rows = 2
columns = 2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ASSERT 1 = 2.
ENDIF.
container_2 = splitter->get_container(
row = 1
column = 2 ).
<b>3.Dynamic Creation of alv object</b>
CREATE OBJECT go_grid
EXPORTING
i_parent = container_2.
<b>4. Get Fieldcatalogue</b>
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = lv_structure_name
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ASSERT 1 = 2.
ENDIF.
<b>5. Set table for first display</b>
CALL METHOD go_grid->set_table_for_first_display
* EXPORTING
* i_structure_name = lv_structure_name
CHANGING
it_fieldcatalog = lt_fieldcat
it_outtab = <lt_out_data>.
CALL METHOD ls_alv_ref-alv_ref->refresh_table_display.
CALL METHOD cl_gui_cfw=>flush.
Perhaps someone could help.....
Best Regards, Edgar
Hello Edgar
The following sample report <b>ZUS_SDN_TWO_ALV_GRIDS_8</b> shows how to solve your problem. Please note that for the sake of simplicity I replaced the tree containing the structure names with an ALV list. However, the switch between the different structures is triggered by the <b>DOUBLE_CLICK</b> event.
I like to add that the integration of the first displayed ALV list (DD02L) into GT_OUTTAB is not really elegant. In addition, with <b>$TMP</b> I marked a problematic part of the coding with respect to your requirement to have the right layout for each displayed ALV list:
If you have a <b>fixed </b>assignment of <i>tabname -> 4-digit handle</i> then it is ok. I my sample report the layouts only work if you select the tabnames in the very same order.
Before showing the entire coding I describe crucial parts of the coding:
[code]TYPES: BEGIN OF ty_s_outtab.
TYPES: tabname TYPE tabname.
TYPES: layout TYPE lvc_s_layo.
TYPES: variant TYPE disvariant.
TYPES: fcat TYPE lvc_t_fcat.
TYPES: data TYPE REF TO data.
TYPES: END OF ty_s_outtab.[/code]
Every time a new structure is selected the corresponding ALV data are stored as new record in GT_OUTTAB which is of line type TY_S_OUTTAB.
[code] READ TABLE gt_outtab INTO gs_outtab INDEX 2.
ASSIGN gs_outtab-fcat TO <gt_fcat>.
ASSIGN gs_outtab-data->* TO <gt_outtab>.[/code]
Since the ALV list data and the fieldcatalog are fully dynamic I use global field-symbols for these data.
[code]&----
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
SET TITLEBAR 'xxx'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
is_variant = gs_outtab-variant
i_save = 'A'
CHANGING
it_outtab = <gt_outtab>
it_fieldcatalog = <gt_fcat>
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT[/code]
The second ALV list which displays the table records is always newly displayed in the PBO module.
In the event handler method <b>HANDLE_DOUBLE_CLICK</b> we need to do two things:
- store the current fieldcatalog back to GT_OUTTAB
- store the name of the new selected table/structure -> trigger PAI
In routine <b>HANDLE_DB_CLICK</b> we create a new entry for GT_OUTTAB if it does not yet exist. Next we select this entry and display it again as second ALV list.
[code]
*& Report ZUS_SDN_TWO_ALV_GRIDS_8
*& Description: Display two ALV lists in splitter container (left/right)
*& Left ALV list contains DB table names,
*& right ALV list displays entries of selected DB table
*& SDN thread: Dynamical Call of ALV - No data update
*& Link: https:||Dynamical Call of ALV - No data update
*& Screen '0100' contains no elements.
*& ok_code -> assigned to GD_OKCODE
*& Flow logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
REPORT zus_sdn_two_alv_grids_8.
TYPE-POOLS: abap.
DATA:
gd_repid TYPE syst-repid,
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
TYPES: BEGIN OF ty_s_outtab.
TYPES: tabname TYPE tabname.
TYPES: layout TYPE lvc_s_layo.
TYPES: variant TYPE disvariant.
TYPES: fcat TYPE lvc_t_fcat.
TYPES: data TYPE REF TO data.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gt_dd02l TYPE STANDARD TABLE OF dd02l,
gs_outtab TYPE ty_s_outtab,
gt_outtab TYPE ty_t_outtab.
FIELD-SYMBOLS:
<gt_fcat> TYPE lvc_t_fcat,
<gt_outtab> TYPE table.
CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_tabname_selected TYPE tabname READ-ONLY.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
define local data
DATA:
ls_dd02l TYPE dd02l,
ls_outtab TYPE ty_s_outtab.
CHECK ( sender = go_grid1 ).
READ TABLE gt_dd02l INTO ls_dd02l INDEX e_row-index.
" Store data of currently displayed ALV list (except for DD02L)
IF ( md_tabname_selected = space ).
ELSE.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY tabname = md_tabname_selected. " old
CALL METHOD go_grid2->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = ls_outtab-fcat.
MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
ENDIF.
md_tabname_selected = ls_dd02l-tabname. " new selected DB table
Triggers PAI of the dynpro with the specified ok-code
cl_gui_cfw=>set_new_ok_code( 'HANDLE_DB_CLICK' ). " not 4.6c
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'HANDLE_DB_CLICK'
IMPORTING
RC =
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
gd_repid = syst-repid.
SELECT * FROM dd02l INTO TABLE gt_dd02l
WHERE tabname LIKE 'KN%1' OR
tabname LIKE 'LF%1' OR
tabname LIKE 'VB%' OR
tabname LIKE 'MAR%' OR
tabname LIKE 'E07%'
AND tabclass = 'TRANSP'. " transparent table
SORT gt_dd02l BY tabname.
PERFORM init_controls.
PERFORM add_first_table.
Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_grid1.
READ TABLE gt_outtab INTO gs_outtab INDEX 1.
Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
CHANGING
it_outtab = gt_dd02l
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE gt_outtab INTO gs_outtab INDEX 2.
ASSIGN gs_outtab-fcat TO <gt_fcat>.
ASSIGN gs_outtab-data->* TO <gt_outtab>.
NOTE: method called in PBO module
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
is_variant = gs_outtab-variant
i_save = 'A'
CHANGING
it_outtab = <gt_outtab>
it_fieldcatalog = <gt_fcat>
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
SET TITLEBAR 'xxx'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = gs_outtab-tabname
is_layout = gs_outtab-layout
is_variant = gs_outtab-variant
i_save = 'A'
CHANGING
it_outtab = <gt_outtab>
it_fieldcatalog = <gt_fcat>
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
User has pushed button "Display Details"
WHEN 'HANDLE_DB_CLICK'.
PERFORM handle_db_click.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form HANDLE_DB_CLICK
text
--> p1 text
<-- p2 text
FORM handle_db_click.
define local data
DATA:
ld_handle(4) TYPE n,
ls_outtab TYPE ty_s_outtab.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
IF ( syst-subrc NE 0 ).
CLEAR: ls_outtab.
ls_outtab-tabname = lcl_eventhandler=>md_tabname_selected.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = ls_outtab-tabname
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = ls_outtab-fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE DATA ls_outtab-data TYPE TABLE OF (ls_outtab-tabname).
ASSIGN ls_outtab-data->* TO <gt_outtab>.
SELECT * FROM (ls_outtab-tabname) UP TO 50 ROWS
INTO TABLE <gt_outtab>.
ls_outtab-layout-no_toolbar = abap_false.
ls_outtab-layout-zebra = abap_true.
ls_outtab-layout-smalltitle = abap_true.
CONCATENATE ls_outtab-tabname ':'
INTO ls_outtab-layout-grid_title.
CONCATENATE ls_outtab-layout-grid_title 'Table Records'
INTO ls_outtab-layout-grid_title
SEPARATED BY space.
ls_outtab-variant-report = gd_repid.
DESCRIBE TABLE gt_outtab.
ld_handle = syst-tfill + 1.
WRITE ld_handle TO ls_outtab-variant-handle. " $TMP: Problem!!!
APPEND ls_outtab TO gt_outtab.
ENDIF.
" NOTE: read into GLOBAL variable gs_outtab !!!!
READ TABLE gt_outtab INTO gs_outtab
WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
ASSIGN gs_outtab-fcat TO <gt_fcat>.
ASSIGN gs_outtab-data->* TO <gt_outtab>.
ENDFORM. " HANDLE_DB_CLICK
*& Form INIT_CONTROLS
text
--> p1 text
<-- p2 text
FORM init_controls .
Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999 " full-size screen
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 1
columns = 2
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_left.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_cell_right.
CALL METHOD go_splitter->set_column_mode
EXPORTING
mode = cl_gui_splitter_container=>mode_relative
IMPORTING
RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_splitter->set_column_width
EXPORTING
id = 1
width = 25
IMPORTING
RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_splitter->set_column_sash
EXPORTING
id = 1
type = cl_gui_splitter_container=>type_movable
value = cl_gui_splitter_container=>false
IMPORTING
RESULT =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_left
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " INIT_CONTROLS
*& Form ADD_FIRST_TABLE
text
--> p1 text
<-- p2 text
FORM add_first_table .
define local data
DATA:
ls_outtab TYPE ty_s_outtab.
ls_outtab-tabname = 'DD02L'.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = ls_outtab-tabname
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = ls_outtab-fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
GET REFERENCE OF gt_dd02l INTO ls_outtab-data.
ls_outtab-layout-no_toolbar = abap_false.
ls_outtab-layout-zebra = abap_true.
ls_outtab-layout-smalltitle = abap_true.
CONCATENATE ls_outtab-tabname ':'
INTO ls_outtab-layout-grid_title.
CONCATENATE ls_outtab-layout-grid_title 'Table Records'
INTO ls_outtab-layout-grid_title
SEPARATED BY space.
ls_outtab-variant-report = gd_repid.
ls_outtab-variant-handle = '0002'.
INSERT ls_outtab INTO gt_outtab INDEX 1.
ls_outtab-layout-no_toolbar = abap_true.
ls_outtab-layout-zebra = abap_true.
ls_outtab-layout-smalltitle = abap_true.
ls_outtab-layout-grid_title = 'DB Tables'.
ls_outtab-variant-report = gd_repid.
ls_outtab-variant-handle = '0001'.
DELETE ls_outtab-fcat WHERE ( fieldname NE 'TABNAME' ).
INSERT ls_outtab INTO gt_outtab INDEX 1.
ENDFORM. " ADD_FIRST_TABLE[/code]
Regards,
Uwe
Similar Messages
-
Empty Shared Variables & Data Binding not working in dynamically called VI
Hi,
I have just upgraded a system from LabVIEW 2011 to 2012 DS2. I have a real-time PXI system running several shared variables, hosted on the PXI.
After what appeared to be a succesful upgrade I have a couple of odd issues.
1. The PXI writes test data into a network shared variable, based on a typedef of an array of custom clusters. The variable is disconnected from the typedef, as RT does not function with shared variables linked to typedefs. It seems that writing a seingle entry to the array is fine, but writing multiple entries causes the variable to appear empty.
I still need to debug this a little more, as while I was station to do so this other issue popped up.
2. I have some controls on the Host app with data binding to shared variables. The host app uses three VIs dynamically called into the wrapper VI. One of these called VIs is not able to connect to its variable when inserted in to the wrapper, but it can if run independently. The other two have no such trouble. Where I see a problem, the indication LED is grey and the mouse-over text reads "no status". What does this mean?
Any clues?
Thanks,
IanI have changed the Invoke Node to a Run Asynchronous node, and this seems to have fixed the data binding issue.
The other issue may be related to a bug fixed in 2012 SP1:
368648 Network Stream operations return Error 42 when data type contains nested clusters of typedefs
I am now getting error 42 when reading a particular network shared variable. This variable contains the results of measurements, in a data type which contains an array of nested clusters of typedefs. When there is a single entry in the array I can read the variable fine, but when there is more than one entry in the array it does not read and I get error 42.
I have downloaded 2012 SP1, and will see if this helps.
Ian -
Carrier data update failure and droping calls continously
This issue with my new iphone 4s with only 1 carrier not all
carrier data update failure and droping calls continously & bad quality.my carrier which is ZAIN TELECOM/Iraq that not resolved with restoreAfter managed to keep my Z10 running again, it informed me, that there was a new update available, released at 6:38pm with 88MB.
I installed it, hoping that it would terminate the problems I mentioned in my initial post...and:
I can now JOIN THIS PROBLEM FRACTION:
http://supportforums.blackberry.com/t5/BlackBerry-Z10/Just-updated-to-latest-OS-and-phone-is-frozen-...
WHAT THE F IS WRONG WITH YOU PEOPLE????
I AM THAT CLOSE, SMASHING THAT DEVICE WITH A SLEDGEHAMMER!
Did I mention, that I normally charge my customers with 2.500€ a day, when they order my services as a communication consultant and that I do most of my business when I am mobile and traveling?
Due to Your sloppy work, I already "lost" a day, where I was not available and I did not get any kind of answer of You guys til know... Maybe I´ll should charge BlackBerry for each and every hour that I am "out of business" caused by Your work... -
How to edit a program dynamically called from another program
Hi all,
Can anyone help me in coding for a program which call's another
report dynamically from selection screen(for instance z_dynam_called)
and retreive the whole content of the dynamically called program(z_dynam_called)
into an internal table and replace the contents of the internal table with some new code and put it back in z_dynam_called and save it.
Thanks in advance.
Needful will be rewarded with pointsHi,
Follow this:
1) U can pass data from one program to another in a single login using SAP memory......
2) u can create a DBtable update dat table using ur first pgm and fetch from second program.....
3) U can pass the report output using EXPORT TO MEMORY addition and get it back using IMPORT FROM MEMORY..........
Eg:
Export the selected rows to the next program
EXPORT final TO MEMORY ID 'ABC'.
CALL TRANSACTION 'XXX'.
XXX is the tcode for the other program where u want to import the values.
In the second program
INITIALIZATION.
IMPORT the internal table from the first program
IMPORT final FROM MEMORY ID 'ABC'.
Thanks and Regards,
Reward If Helpful -
Hello experts,
is it possible to call an ALV via ( class cl_salv or fm REUSE_ALV_GRID_DISPLAY) with a dynamic table?
This dynamic table has for example one fix column for the material number and dynamic colums for additional data.
One material has 1 additional column, the other material has two additional columns.
So i need an ALV with 3 columns material add_data1 add_data2 (add_data2 of material one is empty this is ok).
To build an itab which can handle this is possible i know.Hello Benjamin,
Maybe you already found a solution for this, but if not (or for others looking for a solution), here is a sample program that creates, fills, and displays a dynamic table:
report ztpar_dynamic_salv.
parameters: p_colnr type i default 3.
start-of-selection.
perform execute.
form execute.
data t_table type ref to data.
** create dynamic table
perform create_dynamic_table using p_colnr
changing t_table.
** fill dynamic table
perform fill_dynamic_table changing t_table.
** display dynamic table
perform display_table using t_table.
endform.
form create_dynamic_table using colnr type i
changing table type ref to data.
data: lo_field type ref to cl_abap_typedescr,
lo_struct type ref to cl_abap_structdescr,
lo_table type ref to cl_abap_tabledescr.
data: t_comp type cl_abap_structdescr=>component_table,
l_comp like line of t_comp.
lo_field ?= cl_abap_typedescr=>describe_by_name( 'CHAR10' ).
do p_colnr times.
move sy-index to l_comp-name.
concatenate 'COLUMN' l_comp-name into l_comp-name.
condense l_comp-name no-gaps.
l_comp-type ?= lo_field.
append l_comp to t_comp.
enddo.
lo_struct = cl_abap_structdescr=>create( p_components = t_comp p_strict = space ).
lo_table = cl_abap_tabledescr=>create( lo_struct ).
create data table type handle lo_table.
endform.
form fill_dynamic_table changing table type ref to data.
field-symbols: <fs_table> type standard table,
<fs_line> type any,
<fs_field> type any.
assign table->* to <fs_table>.
do 5 times.
append initial line to <fs_table> assigning <fs_line>.
do.
assign component sy-index of structure <fs_line> to <fs_field>.
if sy-subrc ne 0.
exit.
endif.
<fs_field> = sy-index.
enddo.
enddo.
endform.
form display_table using i_table type ref to data.
data lo_alv type ref to cl_salv_table.
field-symbols <fs_tab> type any table.
assign i_table->* to <fs_tab>.
try.
cl_salv_table=>factory(
importing
r_salv_table = lo_alv
changing
t_table = <fs_tab> ).
catch cx_salv_msg.
message 'Cannot display result!' type 'E'.
endtry.
lo_alv->display( ).
endform.
Best regards,
Tanguy -
hi all,
HOw can we write the dynamic sort in ALV.
regards,
AJHi,
Please find the sample code for dynamic sort in OO ALV
perform built_sort_table.
form built_sort_table.
data ls_sort_wa type lvc_s_sort.
ls_sort_wa-spos = 1.
ls_sort_wa-fieldname = 'MATNR'. "<< here your pass fieldname to sort dynamically
ls_sort_wa-up = selected.
ls_sort_wa-subtot = ''.
append ls_sort_wa to gt_sort.
ls_sort_wa-spos = 2.
ls_sort_wa-fieldname = 'STATUS'. "<< here your pass fieldname to sort dynamically
ls_sort_wa-up = selected.
ls_sort_wa-subtot = ''.
append ls_sort_wa to gt_sort.
endform. " BUILT_SORT_TABLE
call method grid1->set_table_for_first_display
exporting
is_layout = gs_layout
is_variant = gs_variant
i_save = 'A'
it_toolbar_excluding = i_exclude[]
changing
it_outtab = i_output[]
it_fieldcatalog = i_fieldcat[]
it_sort = gt_sort[]
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
aRs -
Alle experts:
In ALV layout report, how to dynamic change the layout int ABAP porgram?
e.g. I have save 5 layout, I need to change them base the my selection in ABAP program? How to do this?
Thanks in advance!Try to call fieldcatlog dymnamically. Refer tofollowing code. Reward if helpful.
REPORT zfir0001 MESSAGE-ID ztax.
Tables
TABLES : glt0, t001, skat.
Internal Tables
DATA: BEGIN OF itab OCCURS 0,
racct LIKE glt0-racct, "Account number
txt20 LIKE skat-txt20, "G/L account short text
co_1000 LIKE glt0-hslvt, "Balance carried forward for company code 1000
co_1100 LIKE glt0-hslvt, "Balance carried forward for company code 1100
co_1200 LIKE glt0-hslvt, "Balance carried forward for company code 1200
DATA : BEGIN OF itab1 OCCURS 0,
bukrs LIKE glt0-bukrs,
waers LIKE t001-waers,
END OF itab1.
DATA : BEGIN OF it_itab1 OCCURS 0.
INCLUDE STRUCTURE glt0.
DATA : END OF it_itab1.
Data Declarations
DATA : w_total LIKE glt0-hslvt,
w_count LIKE glt0-bukrs,
w_flg TYPE c,
lv_count TYPE i.
w_slash TYPE c VALUE ' '.
Selection screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE tit1.
SELECT-OPTIONS : s_bukrs FOR glt0-bukrs OBLIGATORY,
s_racct FOR glt0-racct OBLIGATORY,
s_ryear FOR glt0-ryear OBLIGATORY,
s_rldnr FOR glt0-rldnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
tit1 = 'Please select:'(004).
TYPE-POOLS: slis. "ALV Declarations
DATA: i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
********Geting the selected company code in table itab1****
START-OF-SELECTION.
IF NOT s_bukrs-high IS INITIAL.
itab1-bukrs = s_bukrs-low.
APPEND itab1.
w_count = s_bukrs-low.
DO.
IF s_bukrs-high = w_count.
EXIT.
ELSE.
w_count = w_count + 1.
ENDIF.
SELECT SINGLE * FROM t001
WHERE bukrs = w_count.
IF sy-subrc = 0.
itab1-bukrs = w_count.
APPEND itab1.
CLEAR itab1.
ENDIF.
ENDDO.
ELSE.
itab1-bukrs = s_bukrs-low.
APPEND itab1.
ENDIF.
SELECT * FROM glt0 INTO CORRESPONDING FIELDS OF TABLE it_itab1
WHERE rldnr IN s_rldnr
AND bukrs IN s_bukrs
AND ryear IN s_ryear
AND racct IN s_racct.
SORT it_itab1 BY bukrs.
LOOP AT it_itab1.
AT END OF racct.
w_flg = 'X'.
ENDAT.
SELECT SINGLE txt20 INTO (itab-txt20) FROM skat
WHERE spras = sy-langu
AND saknr = it_itab1-racct.
PACK it_itab1-racct TO it_itab1-racct.
itab-racct = it_itab1-racct.
w_total = it_itab1-hsl01 + it_itab1-hsl02 + it_itab1-hsl03 + it_itab1-hsl04 +
it_itab1-hsl05 + it_itab1-hsl06 + it_itab1-hsl07 + it_itab1-hsl08 +
it_itab1-hsl09 + it_itab1-hsl10 + it_itab1-hsl11 + it_itab1-hsl12 +
w_total + it_itab1-hslvt.
IF w_flg = 'X'.
READ TABLE itab1 WITH KEY bukrs = it_itab1-bukrs.
IF sy-subrc = 0.
SELECT SINGLE * FROM t001
WHERE bukrs = itab1-bukrs.
IF t001-waers = 'JPY' OR
t001-waers = 'HUF'.
w_total = w_total * 100.
ENDIF.
CASE it_itab1-bukrs.
WHEN '1000'.
itab-co_1000 = w_total.
WHEN '1100'.
itab-co_1100 = w_total.
WHEN '1200'.
itab-co_1200 = w_total.
ENDCASE.
COLLECT itab.
CLEAR: itab, w_flg, w_total.
ENDIF.
ENDIF.
ENDLOOP.
SORT itab BY racct.
IF NOT itab[] IS INITIAL.
PERFORM field_cat1.
lv_count = 1.
LOOP AT itab1.
PERFORM field_cat USING itab1-bukrs.
ENDLOOP.
PERFORM display_alv_report .
ELSE.
MESSAGE s000 WITH 'No records Found'(003).
ENDIF.
*& Form display_alv_report
text
FORM display_alv_report .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = i_fieldcat[]
i_save = 'X'
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display_alv_report
*& Form field_cat1
text
FORM field_cat1 .
i_fieldcat-col_pos = 0.
i_fieldcat-fieldname = 'RACCT'.
i_fieldcat-seltext_m = 'Account'(001).
i_fieldcat-fix_column = 'X'.
i_fieldcat-emphasize = 'X'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-col_pos = 1.
i_fieldcat-fieldname = 'TXT20'.
i_fieldcat-seltext_m = 'Description'(002).
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
ENDFORM. "field_cat1
*& Form field_cat
text
-->XV_BURKS text
FORM field_cat USING xv_burks TYPE char4.
lv_count = lv_count + 1.
i_fieldcat-col_pos = lv_count.
CONCATENATE 'CO_' xv_burks INTO i_fieldcat-fieldname.
i_fieldcat-seltext_m = xv_burks.
i_fieldcat-just = 'C'.
i_fieldcat-no_zero = 'X'.
i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
ENDFORM. "field_cat
Edited by: dhanashree wadkar on Apr 30, 2008 6:00 AM -
VI Profiler on dynamic called VI archiecture
I have a question about debugging to put to the Gurus out there.
My architechure is this, Event driven Producer, which queues Data into the Primary Consumer Loop. Primary consumer Loop performs an action and Queues information into the Secondary consumer Loop which updates the front panel GUI.
The Primary consumer calls test VIs dynamically using a call by Ref node function.
I have a very simple test VI which I am repeatedly calling which is outputing the time since the whole test sequence started (in ms) to the Front panel.
For debugging I have put a conditional disable around the dynamic call function, and I can change it to call the test VI directly.
VI profiler is telling me that the execution of my run a test VI which does the dynamic call takes 0ms. This can't be true.
The results from VI profiler would indicate that I could run 20 tests in about 1 second, but it's taking me about 10 seconds.
I do 10 display updates (via property nodes to change the active row, colours and contents of a multicolum listbox) per test.
Any ideas how I should be debugging where the time is being lost? - VI profiler is not helping enough.
Cheers
JamesJames W wrote:
Ben wrote: Use the VI itself to time how long it takes by getting the time before and after.
Opening a dynamic VI takes time. Load ahead of time use it and when done close it.
1) Def FP updates (to shut of screen updates), hide the MCLB, update it, un-hide, un-defer. passing data directly to the MCLB via terminal is fastest but can't do color stuff without property nodes.
2) Pre-load
Ben
1)
And here comes the killer...
If I defer FP updates, the code runs slower!!! not faster.
If I change the MCLB from Synchronous to Asynchronous using the drop down menu before I run it has no effect on the run time.
If I change the MCLB from Synchronous to Asynchronous at runtime using at property node (not meant to do this), I get error 1073 and the GUI stops updating (sometimes while redrawing the screen half way down), but wiping over the FP window 10 seconds later shows the code has run significantly faster.
2) How do you preload 120 different tests all with the same VI pattern (generated from the same template) and ensure you have the correct VIs in memory without running them? (and producing loads of errors - these tests all logs any errors they produce to files)
I asked for the Guru's I didn't think I was going to the the Knights so fast!! Thanks Ben
Lacking Guru's you'll have to settle for me for now.
If the defer makes it go slower the issue may indeed be the FP updates since the defer forces an extra update when set.
Is is slower if do the next two steps of hiding updating and un-hiding?
If you toss all MCLB code does it run fast enough to make you believe it is the GUI update that is hitting you?
Can you post image of your code as png or jpg?
How much data is in the MCLB?
This cloud has links to LabVIEW_Performance threads. Not sure if any of those threads ring a bell.
Please show us the code to get the most out of us.
Not sure about Q#2 but I would open them and keep a ref to each in array so that they are loaded when I need to run them.
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
Show dynamic table in ALV grid
Hi !
how do I show a dynamic table in ALV GRID ?
I used the following commands:
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fieldcat[]
importing
ep_table = gt_new_table.
assign gt_new_table->* to <l_table>.
create data gs_new_line like line of <l_table>.
assign gs_new_line->* to <l_line>.
I added records into the table
Now I got a dynamic table.
How do I show it in ALV GRID ?
thanks
AdiHi,
Check these links
Re: Dynamic table
http://sap.ittoolbox.com/code/d.asp?a=s&d=3038
http://www.sap4.com/codigo-138.html
http://www.sapassist.com/code/d.asp?a=s&d=3365
There is an example in the report BCALV_TABLE_CREATE
report BCALV_TABLE_CREATE.
data: ok_code like sy-ucomm,
g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
grid1 type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container.
data: gt_fieldcat type lvc_t_fcat.
data: gp_table type ref to data.
field-symbols: <gt_table> type table.
parameters: n type i.
if n > 100.
message a000(0k) with 'N <= 100'.
endif.
perform fieldcat_build.
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = gt_fieldcat
importing ep_table = gp_table.
assign gp_table->* to <gt_table>.
perform fill_table.
call screen 100. -
Unable to run bapis for project status update and date update together
Hi Experts,
I have a requirement to update the dates and status of a project WBS at level 4. I am trying to do update the CJ02 Transaction using standard BAPI available. I need to do both Date update and status update in the same LOOP PASS i am using the below mention bapi. when i am doing so i am getting an error Project 'A._____' has been currently processed by ID i.e. my id.
I have tried putting a wait for 2 seconds in the code but its still not working. please find the order below in which i am calling the bapi.
Loop at itab.
if date_changed = 'X'.
CALL FUNCTION 'BAPI_PROJECT_MAINTAIN'
READ TABLE it_error WITH KEY message_type = c_e.
IF sy-subrc <> 0.
Commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x
IMPORTING
return = s_ret.
endif.
endif.
if Status_change = 'X'.
CALL FUNCTION 'BAPI_PS_INITIALIZATION' .
CALL FUNCTION 'BAPI_BUS2054_SET_STATUS'
READ TABLE t_result WITH KEY message_type = c_e.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
et_return = t_ret.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x
IMPORTING
return = s_ret.
ENDIF.
endif.
WAIT UP TO 4 SECONDS.
endloop.Try to use
SET UPDATE TASK LOCAL.
before each BAPI call.
Did you try to debug through your code, leaving sufficient time between BAPI calls? If it does work like that, then the above statement might help. -
How to send ALV output data into Excel sheet format via Mail to the user?
Hi friends,
I have a doubt ie,
How to send ALV output data into Excel sheet format via Mail to the user?
regards
MoosaHi,
Provide the output internal table to the objbin in the below FM
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = i_docdata
put_in_outbox = c_x
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
and specify the document type
i_objpack-doc_type = 'XLS'.
and try.
Regards,
Nandha -
Dynamic call for records in a table
hI,
Im having a ztable, the structure is as follows:
tabold fldold tabnew fldnew
The records in this table is are:
1.yvbap posnr xvbap posnr
2.yvbak auart xvbak auart
3.yvbak augru xvbak augru.
Now, i have to use this table dynamically to check each and every record in the program:mv45afzz.
So, my problem is that, i have to dynamically pass these records which contains table name and its field name.
i can write as: xvbap-posnr = yvbap-posnr for all the three records (the values will come from sales order tranx, report: mv45afzz)
but in future if the records are added then i have to again change the code, so this shouldn't happen.
It should dynamically call all the records in this table and check the condition.
Thanx
RohithHello Rohith
What is your question???
You described a few ingredients of your scenario (not all of them) and do not really explain your requirements.
Given the descriptions of the Z-table fields I assume you need to check whether OLD values are equal to NEW values.
If this assumption is correct then the solution is quite simple (except for XVBAP / YVBAP: Does this mean single entries or looping over all entries?)
DATA:
lt_ztable TYPE STANDARD TABLE OF zstructure,
ls_ztable TYPE zstructure.
FIELD-SYMBOLS:
<lt_tab> TYPE table,
<ls_struct_old> TYPE any,
<ls_struct_new> TYPE any,
<ld_old> TYPE any,
<ld_new> TYPE any.
" Read entries from z-table
SELECT * FROM ztable INTO table lt_ztable.
LOOP AT lt_ztable INTO ls_ztable.
ASSIGN (ls_ztable-tabold) TO <ls_struct_old>.
ASSIGN (ls_ztable-tabnew) TO <ls_struct_new>.
ASSIGN COMPONENT (ls_ztable-fldold) OF STRUCTURE <ls_struct_old> TO <ld_old>.
ASSIGN COMPONENT (ls_ztable-fldnew) OF STRUCTURE <ls_struct_new> TO <ld_new>.
IF ( <ld_old> = <ld_new> ).
" do something...
ENDIF.
ENDLOOP.
For the sake of simplicity I did not add the required statements for checking successful ASSIGN's.
Regards
Uwe -
Lumia 1020 call cut outs after Black update
My calls have problems after Black update. Either reciever can not hear me or I can not hear him for long periods. Tested SIM in other phone on same net on same location and seems to be Nokia problem.
Hi @abengs,
Have you tried to press and hold the power and volume down keys for 10 secs? Also check if your system apps are up to date by scanning these QR codes: http://discussions.nokia.com/t5/Pool-of-Knowledge/Nokia-Windows-Phone-8-App-Updates/td-p/1640082
Let us know the outcome. -
Dynamic call of a static method of an static attribute
Hi all,
is it possible to call dynamically a static method of a static attribute of a class.
The statement without dynamic call would look like this:
cl_test_class=>static_attribute=>static_method( ).
I would like to do it like this:
('CL_TEST_CLASS')=>static_attribute=>static_method( ).
Netiher the one nor the other way works for me - I'm getting the error "The notation used is reserved for business object classes".
Regards, StefanI guess, it is not possible to call method using the short form (parameters in brackets) is not possible in Dynamic Access. You may need to get the attribute first and then call the method.
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
CLASS-DATA: o_same TYPE REF TO lcl_main.
METHODS: run.
ENDCLASS. "lcl_main DEFINITION
CLASS lcl_main IMPLEMENTATION.
METHOD run.
WRITE: 'success'.
ENDMETHOD. "run
ENDCLASS. "lcl_main IMPLEMENTATION
START-OF-SELECTION.
DATA: lo_same TYPE REF TO lcl_main.
CREATE OBJECT lcl_main=>o_same.
* lcl_main=>o_same=>run( ).
TRY.
FIELD-SYMBOLS: <fs> TYPE REF TO lcl_main.
ASSIGN ('LCL_MAIN')=>('O_SAME') TO <fs>.
CALL METHOD <fs>->('RUN').
CATCH cx_root.
ENDTRY.
Regards,
Naimesh Patel -
How to dynamically call image in PDF for Acrobat ver 8.1 onwards?
Hi Experts,
I am using Web Dynpro Java. My requirement is to call the images dynamically on a PDF form. There are no of company code. I have to call different logos for different company codes/
We are now using Acrobat 8.1.1. Please refer following thread.
http://kb2.adobe.com/cps/405/kb405270.html
From Acrobat 8.*, we have to use some different method for dynamically calling the images. Earlier we were using the concept mentioned below to dynamically call images.
However this method is not applicable for Acrobat Reader 8.* onwards due to security reasons.
Click on the Layout tab and choose None for the Caption position.
u2022 Click on the Object, then the Binding tab and choose None for Default Binding.
u2022 Click on the Field tab, enter $record.SapOnlineShopUrl for the URL entry, and select Use Image Size for the Sizing field.
u2022 Click on the script editor and enter the following FormCalc script statement, which enables the dynamic integration of the image. Show: initialize Script: this.value.image.href = xfa.resolveNode(this.value.image.href).value; Language: FormCalc Run At: Client
write following code in wddoinit
try { String url = WDURLGenerator.getAbsoluteWebResourceURL( wdComponentAPI.getDeployableObjectPart(), "sap_online_shop.jpg"); wdContext.currentDataSourceElement().setSapOnlineShopUrl(url); } catch(Exception e) { throw new WDRuntimeException(e); }
Please let me know what is the alternate method for Adope ver 8.1.1
Regards,
GaryHi Gary,
First you upload the image in SAP through se78.then write the below code in your adobe form interface.
data : v_object type TDOBJECTGR value 'GRAPHICS',
v_id type TDIDGR value 'BMAP',
v_btype type TDBTYPE value 'BCOL',
V_FIELD TYPE XSTRING.
V_NAME = 'ZW_DEVMAN_LOGO'.
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = v_object " 'GRAPHICS'
p_name = v_name " Name of the logo as in se78
p_id = v_id " 'BMAP'
p_btype = v_btype " 'BCOL' ( whether the image is in color or black and white )
RECEIVING
p_bmp = v_field
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
g_logo = v_field.
Declare g_logo as xstring in global data.
In context of the form make one graphic element with field g_logo and mime type BMP.It will work.
Regards,
Simi A M
Edited by: amsimi on Jan 26, 2011 5:30 AM
Maybe you are looking for
-
Deleting emails with a specific subject from a single user mailbox
we are exchange 2007 on SP1. we do not have an edge server, only a hub server. A user mailbox was flooded with 11000 "Undeliverable:" emails in the last 2 days, the source being "DSA". I am still finding out why this has happened. As for now, I have
-
Getting all types of files with the help of get_file_name function
hi all, i am using Forms [32 Bit] Version 6.0.8.24.1 (Production). i have used get_file_name function to the file name of all type of files but i am able to get only the folders when i tried like below :FILE_NAME := GET_FILE_NAME(NULL,NULL,NULL,'Choo
-
Need help in creating virtual server
Hi I have configured the sun ONE portal server to run on a domain p1.test.com. A default virtual server with the listen socket is existing for this virtual server. But now I need to access the portal with another domain name p1.test.co.in. I have tri
-
HT1414 My slide to unlock doesn't work. What do I do?
What do I do if my slide button doesn't respond?
-
How do I set Firefox 8 to mark accessed links as read?
Firefox used to indicate which links provided in a search list had been accessed by changing the color in a read link. That seems to have disappeared in Firefox 8. I cannot find a setting to recreate that function.