Dynamic Call to VIT that is a member of a LabVIEW Library (LVLIB)
Application is too complicated to post, so I will describe this in basic terms ..
Consider these VIs as members of an lvlib.
Template.VIT
Template Launcher.vi
func1.vi
'Template.VIT' and 'Template Launcher.vi' are public members of the lvlib.
'func1' is a private member of the lvlib.
'func1.vi' is a subVI on the block diagram of 'Template.VIT '
'Template Launcher.vi' calls 'Template.VIT' dynamically. It gets a path to the VIT, uses that to Open a reference, then runs it with the 'Run VI' method.
Whenever you launch a VIT this way, it creates a new named instance (because it is a template) by appending a number to the VIT name. In this instance, let's call it 'Template 2.VIT'.
Here is the Problem: 'Template 2.VIT' is not executable because it does not have access to the private member of the llvlib, so it cannot call 'func1.vi' from the block diagram. It seems that the instance 'Template 2.VIT' is not a member of the lvlib. Block Diagram error reads...
"SubVI is private and cannot be accessed from this VI."
My question: Is there any way to make the new instance a member of the lv library?
I don't need a workaround, I need to know if this is possible. Perhaps a particualr switch when Open VI Reference is called, or a particualr property that can be changed?
Message Edited by ADAC on 01-16-2007 11:14 AM
Hi ADAC,
The short answer is no, you cannot do this. If you set the "Open VI Reference" option to 2, you can open the template itself and this will not have this problem. But if you need to create new instances of the template this will not work for you. You may be able to "work around" this (even though work around is a dirty word). It might be possible to programatically make a copy of this VI on disk and then programatically edit the lvlib file such that your new file is a member of the library. I haven't tried this myself so I'm not positive this would work but it might.
I hope this helps,
Justin D
Applications Engineer
National Instruments
Similar Messages
-
Dynamically calling sequences with different prototypes
Hi,
Is there a way of dynamically calling from one sequence call, two sequences with different prototypes?
Thanks,
krsI know that this is not really an answer to your question, but could you write some sort of wrapper to the different sequences that has a common interface and call it?
Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
DISTek Integration, Inc. - NI Alliance Member
mailto:[email protected] -
Here's the problem. Dynamically called VI becomes broken inside an executable in debug executable mode Error 1003 is occuring from "Open VI Reference" Block. The computer has all of the necessary drivers, NI-VISA and NI-DAQmx. This executable is a new release of software that currently works on the PC in question. I can using NI-VISA Remote Server control the instruments from my PC using the executable. But when I put the executable on the PC I am getting this error. The only way I have been able to get this to work properly is to build the executable from the console I believe the project was created in, note that the project file has been moved to a network drive and it still works. All of the stations I have opened the project in show the VI that is being called is runnable. I've tried building the executable from the console I am deploying to and the same thing happens.
I am honestly at a loss for ideas why this is occuring. Is this something about the way LabView works internally that may be causing this problem?
I have trolled this forum for idea's and none have made sense to me.
Any input would be greatly appreciated.
-NateTwo ideas:
Mass compile the project to ensure all linkages are ironed out
Include the dynamically launched VI's into the "Always Included" section of the build spec
Report back on if either of these actions solves your problem.
a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;} -
Script to find users that are a member of more than one of a list of specific groups
Hi,
I need to generate a list of users that are members in more than one group, out of a list of specific security groups. Here's the situation:
1) We have about 1100 users, all nested under a specific OU called CompanyUsers. There are sub-OUs under CompanyUsers that users may actually be in.
2) We have about 75 groups, all directly under a specific OU called AppGroups. These groups correspond to a user's role within an internal line of business application. All these groups start with a specific character prefix "xyz", so the group
name is actually "xyz-approle".
I want to write a script that tells me if a user from point 1) is a member in more than one group in point 2). So far, I've come up with a way to enumerate the users to an array:
$userlist = get-qaduser -searchroot 'dq.ad/dqusers/doral/remote' | select samaccountname |Format-Table -HideTableHeaders
I also have a way to enumerate all the groups that start with xyz that the user is a member of:
get-QADMemberOf -identity <username> -name xyz* -Indirect
I figure I can use the first code line to start a foreach loop that uses the 2nd code line, outputting to CSV format for easy to see manual verification. But I'm having two problems:
1) How to get the output to a CSV file in the format <username>,groupa,groupb,etc.
2) Is there any easier way to do this, say just outputting the users in more than one group?
Any help/ideas are welcome.
Thanks in advance!
JohnHere is a PowerShell script solution. I can't think of way to make this more efficient. You could search for all groups in the specfied OU that start with "xyz", then filter on all users that are members of at least one of these groups. However, I suspect
that most (if not all) users in the OU are members of at least one such group, and there is no way to filter on users that are members of more than one. This solution returns all users and their direct group memberships, then checks each membership to
see if it meets the conditions. It outputs the DN of any user that is a member of more than one specfied group:
# Search CompanyUsers OU.
strUsersOU = "ou=CompanyUsers,ou=West,dc=MyDomain,dc=com"
$UsersOU = New-Object System.DirectoryServices.DirectoryEntry $strUsersOU
# Use the DirectorySearcher class.
$Searcher = New-Object System.DirectoryServices.DirectorySearcher
$Searcher.SearchRoot = $UsersOU
$Searcher.PageSize = 200
$Searcher.SearchScope = "subtree"
$Searcher.PropertiesToLoad.Add("distinguishedName") > $Null
$Searcher.PropertiesToLoad.Add("memberOf") > $Null
# Filter on all users in the base.
$Searcher.Filter = "(&(objectCategory=person)(objectClass=user))"
$Results = $Searcher.FindAll()
# Enumerate users.
"Users that are members of more than one specified group:"
ForEach ($User In $Results)
$UserDN = $User.properties.Item("distinguishedName")
$Groups = $User.properties.Item("memberOf")
# Consider users that are members of at least 2 groups.
If ($Groups.Count -gt 1)
# Count number of group memberships.
$Count = 0
ForEach ($Group In $Groups)
# Check if group Common Name starts with the string "xyz".
If ($Group.StartsWith("cn=xyz"))
# Make sure group is in specified OU.
If ($Group.Contains(",ou=AppsGroup,"))
$Count = $Count +1
If ($Count -gt 1)
# Output users that are members of more than one specified group.
$DN
# Break out of the ForEach loop.
Break
Richard Mueller - MVP Directory Services -
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 -
Dynamic call for a ref cursor: ORA-21779
Hi,
Here is an environment:
create or replace
PACKAGE PKG_GETDATA AS
TYPE cursor_type IS REF CURSOR;
Procedure SimpleGet (cData In Out Cursor_type);
Procedure DynamicGet (cData In Out Cursor_type);
END PKG_GETDATA;
create or replace
PACKAGE BODY "PKG_GETDATA" AS
Procedure SimpleGet (cData In Out Cursor_type) As
Begin
Open cData For
Select 1 from Dual;
End SimpleGet;
Procedure DynamicGet (cData In Out Cursor_type) As
Begin
Execute Immediate 'Begin PKG_GETDATA.SIMPLEGET(:1); End;'
Using In Out cData;
End DynamicGet;
END PKG_GETDATA;
So- first simple get works fine:
Declare
cData PKG_GETDATA.Cursor_type;
aNumber Number;
Begin
PKG_GETDATA.SimpleGet (cData);
LOOP
FETCH cData INTO aNumber;
EXIT WHEN cData%ROWCOUNT > 5 OR cData%NOTFOUND;
dbms_output.put_line (aNumber);
END LOOP;
close cData;
End;
BUT dynamic call does not works at all!:
Declare
cData PKG_GETDATA.Cursor_type;
aNumber Number;
Begin
PKG_GETDATA.DynamicGet (cData);
LOOP
FETCH cData INTO aNumber;
EXIT WHEN cData%ROWCOUNT > 5 OR cData%NOTFOUND;
dbms_output.put_line (aNumber);
END LOOP;
close cData;
End;
It throws ORA-21779 exception; what is more- it does work on 10.2 db version but does not work on 11.2 version! Could anyone explain that?
Regards
Bartlomiej D.Hi,
Believe me, it may be very handful while working with handlers.
Anyway- could anyone help me on that?
Regards
Bartlomiej D. -
Dynamic call of a vi with a reference stored in a global variable
Hello,
I am trying to program a VI which calls DAQmx functions in some cases, in other cases DAQmx may not even be installed. To prevent a broken arrow on machines where DAQmx is not installed, I want to use a sub-VI containing the DAQmx function calls which is called dynamically by a main VI. For speed I want to prevent continuous opening and closing the VI reference, so I want to store the reference to the sub VI in a global variable. In this variable I also want to store the Analog Input Task. I want to use an initialization VI to write the VI reference of the sub VI and to configure and start the Analog Input Task and write the Task ID to that Global, too. In that way I was hoping to be able to improve the performance of the dynamic calls and the Task calls. BUT - when I write the refererence and task to the Global and read it out from another VI, the reference is not valid anymore and the Analog Input task is also not valid, even if both the initialization VI and the Global are still open (but not running). Does somebody have an idea how to solve that? It is a bit difficult to describe, so here is what I want to do in a shorter description :
- run a initialization VI which
defines a reference to a sub VI which will be called dynamically later on
and a AI task ID definining a DAQmx physical channel configuration to use for subsequent read cycles
and writes both (VI reference and AI task) to a global variable
- run another VI which
reads the VI reference of the VI to call dynamically from that global
runs the corresponding VI dynamically
the dynamically called VI performs an AI task corresponding to the DAQmx task ID read from that global (it reads an analog value for instance from the
physical channel configured by that AI task)
Why all that? To prevent creating and destroying the VI reference for each call of the sub VI for speed. And to use the configured DAQmx channel for subsequent read tasks only if the subVI is called dynamically - if it is not, then the application will not see the DAQmx calls and therefore no broken arrow will occur if no DAQmx is installed on the machine.
Can somebody help me with this? Why can't I store and read out the reference to the sub VI to/from a global, and why is the AI task not valid when read out from the dynamically called sub VI? I am somewhat lost with all that...
Thanks in advance,
GabsUh - I am almost getting crazy with that
Kevin, that solution is the right one for programming an application. In that case everything will work fine. But during testing, it is more convenient to call all VIs from their front panels one after another. That's how I'm doing it for everything that needs to be exchanged between such VIs: store them either in a global or in a functional global variable. In that way the user can "play around" with the VIs without wiring them together in a main VI. Therefore, after some thinking I liked Davids idea with that daemon VI (I solved that by adding a boolean in the initialization VI to choose if that daemon is necessary - during testing phase - or not - when using the VIs in a main application). BUT:
David: It does not work!!! I have exactly done what you proposed and this daemon VI is really running, having a True/False frame with a constant of False wired to the selector and holding both the functional global and the dynamically to call VI in the True frame. In that way, after initialization is finished, both VIs are still running but idle. Anyway, when I read back the value of the reference or the DAQmx task, it is invalid again!
That really costs just too much time. Does anybody have any idea what to do now? David, I was hoping that your suggestion would solve the problem, because it would be logical that it would - why then is LabVIEW destroying the reference and task anyway even if that daemon VI containing the functional global is still running???
Regards,
Gabs -
Upgrade : Issue with Specical character being used in 4.6C ( Dynamic calls)
Hi ,
We are working on Upgrade from 4.6C to ECC6.0 . in SPAU phase we are facing an issue :
When we are trying to see the variants from the program, it says that the program contains Syntax Error
"In Unicode programs, the "&" character can not appear in names as it does here in the name 'op&xv0' "
The 'op&xv0' is a form. we tried changing the form name, but couldnt get the PERFORM stmt for the form and it might be a dynamic call. what can we do for this type of programs?
Please also suggest how we can identify the places where that particular Subroutine is being called.
Thanks & Regds
TejaThis is probably an operation defined in Tcode PE04. You can change the operation subroutine name and then modify the code accordingly in the report.
Go to PE04 and put in operation name, suposedly &xv0.
Instead of using standard name suggested by SAP use custom name (for example opYvx0) and then change in the report as well and it should be ok. -
I am on a family plan and was wondering is it possible to get a detailed break down of my calls and sms that would include phone numbers for my line only?
If you are the account owner, you can log into your My Verizon ccount online and view the usage details for all the lines on the account. If you are only an account member, you should be able to view some details for your line, but I am not sure exactly how much.
-
Unexpected delay when dynamically called VI closes
LV10.0 / WXP
A VI is called dynamically by Run VI Method (Wait Until Done = FALSE, Auto Dispose Ref = TRUE).
Queues are used to exchange data with the main VI.
When this VI closes ("stop" message from the main VI), LabVIEW hangs for about 25 seconds (!) with one of the CPUs of the dual core machine at 100%.
Has anyone else encountered this strange behaviour ? Any ideas ?
Many thanks in advance
Solved!
Go to Solution.Norbert B a écrit :
Can you give us a small picture of the way you are calling and releasing the subVIs?
As mentionned in my first message : Run VI Method (Wait Until Done = FALSE, Auto Dispose Ref = TRUE) is used to call the VIs.
Release : after reception of a "close" message (queue), the dynamic VIs terminate their execution
If called with Auto Dispose Ref = FALSE, the freeze appears when Close Reference is executed in the calling VI (after reception of a "I'm closing" message from the dynamic called VI).
If loading the VI takes only a short time but unloading takes long, it seems to me that those subVIs allocate many new handles/memory spaces during runtime. Is that the case?
As mentionned in a previous message : The memory usage changes from about 687 to 676 MB when the four
instances are closed. The number of handles decreases from about 272k to
61k.
This sounds like the whole application freezes for the time being. Is it a single loop architecture?
No. It is a rather big application with several VIs running independently and exchanging data through queues.
In addition: You call those subVIs dynamical with reentrant execution (at least some of them). So they should run in parallel.
Yes, they run in parallel.
Did you configure different preferred execution systems for your different subVIs?
Yes, I have tried several combinations and also changed the Priority. I also tried to replace the While Loop of the VI which communicates with the PLC by a Timed Loop in order to specify the processor. Unfortunately all my trials ended without any succes.
Did you check for reference leaks using the Execution Trace Toolkit?
Yes. There are none.
Norbert
Thank you very much for your help -
Dynamically loading a class that is part of a larger loaded package
I am dynamically loading a class that is part of a large package, much of which is loaded at startup. The code directly references protected variables in the parts of the package that is loaded by the default class loader. Attempting to access these protected variables gives an access error when the class is dynamically loaded that doesnt occur when the class is loaded at startup.
Is there a way to make this work?To answer my own question -- no
A reference from http://access1.sun.com/techarticles/DR-article.html says:
The use of Dynamic Class Reloading can introduce problems when classes that are being dynamically reloaded make calls to non-public methods of helper classes that are in the same package. Such calls are likely to cause a java.lang.IllegalAccesserror to be thrown. This is because a class that is dynamically reloaded is loaded by a different classloader than the one used to load the helper classes. Classes that appear to be in the same package are effectively in different packages when loaded by different classloaders. If class com.myapp.MyServlet is loaded by one classloader and an instance of it tries to call a non-public method of an instance of class com.myapp.Helper loaded by a different classloader, the call will fail because the two classes are in different packages.
So not being able to access non-private variables in this scenario is the way it works. -
How to check if internal table exists in dynamical called subroutine ?
Hi,
in a dynamically called subroutine i'm using a internal table, but in some calls this table is not exist.
How can i check in the code whether the internal table exist or not ?
regards,
HansIn Horst Keller's blog /people/horst.keller/blog/2005/05/27/abap-geek-10--everything-functions-150-but-how my issue is talked about :
All other parameters are handled in a way as they were declared as global data objects in the top include of the function group, that can be used only during the execution of the function module: They are visible throughout the function group but you can access them only while the function module is active. If you access such a parameter and the respective function module is not executed, you get the runtime error GETWA_NOT_ASSIGNED (Why? Well, technically thos guys are represented via field symbols which are valid only during the runtime of the function module).
The code is in SD pricing. Sometimes the code is called from function module PRICING_BUILD_XKOMV or PRICING_SUBSCREEN_PBO where TKOMV is defined as globalized parameter.
And sometimes it is called from function module PRCING_CHECK where TKOMV is NOT defined as parameter.
In the call of last function the dump occures on the ASSIGN statement :
data: ls_tkomv like line of tkomv,
lv_tablename(30) type c value 'TKOMV[]'.
field-symbols: <lfs> type any table.
assign (lv_tablename) to <lfs>.
if <lfs> is assigned.
Any suggestions to solve the issue ?
regards,
Hans -
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 -
Hi!
I am writing a script where we are trying to use dynamic call types based on the inputs from a database look up. Basically the call is comes into the script and a database lookup is done on the AW to determine which call type is used. Later on we use a menu script and change the call type. Once the system has allocated a precision queue we need to collect some queue stats. How do we do this? The format for collecting a stats is PQ.<preciscion queue name>.CallsInQ. How du you replace the precision queue name with a variable that is then evalutated.
PeterYour best best is to keep the call type name in a PV, then just do PV.CallsinQ.
david -
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, EdgarHello 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
Maybe you are looking for
-
HELP! An Unknown Error :(
hey guys , i just downloaded iTunes 7 it was OK , actually it was great but i'm having a problem i don't really what to do , so plz if you can help me with that .. when i try to open the iTunes7 it shows me that: The iTunes application could not be o
-
Merging vhdx & .avhdx with powershell error ....
i m trying to merge a vhdx & avhdx with powershell the codes are Run diskpart. Enter: select vdisk file="<full path to the latest differencing disk>" A differencing disk ends in either .avhd or .avhdx. Enter: merge vdisk depth=n n will be the number
-
I'm trying to buy CC Photoshop/Lightroom packages. In order to complete payment, I need to change the country from the default options (United States) to Brazil, But I'm not allowed to do it. I've already changed my origin country in my account infor
-
What about a Windows limited user ?
Hello everybody, I saw that the ODBC driver is installed on a path containing the name of the Windows user who installed it. I should like to verify one thing : can it be installed by a limited user ? If not, does the limited user use it in the path
-
Batch resize in pts as opposed to px
I've got Creative Cloud Photoshop running on Mac OSX. I'm trying to batch process image resize in points to 480x320 pts, however, the sizes defaults only to px. I don't understand why the option is not available as it was in Adobe Elements... Anyo