Lag Time in Calling Methods?
I ran the two code examples below and got the same elapsed time for both: 10 ms. I was wondering whether calling a method causes lag: for instance, if you had to add four components to a frame's content pane, would calling getContentPane() four times be less efficient than setting up a reference to the content pane container and adding the four components to the container that that is returned?
The reason why I think that there would be a lag time, however infinitessimal, is because calling a method pushes an EIP onto the stack and returning from a method pops the EIP from the stack. It only makes sense that skipping this step would result in faster execution (once again, however infinitessimally faster that would be).
Here is the code for the two programs I used to test this out. The examples go back to my example above -- I am setting up a reference to the content pane in one example and continually returning it in the other. As I said, both returned the same elapsed time: 10 ms. I'm not sure whether my method of timing the programs was inaccurate or whether there really is no lag time in calling a method. What is the verdict?
1)
package cntrl.testing;
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Container;
public class Test1 extends JFrame
public Test1()
long i = new Date().getTime();
this.setSize(500, 500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = this.getContentPane();
c.add(new JButton());
c.add(new JButton());
c.add(new JButton());
c.add(new JButton());
long f = new Date().getTime();
long te = f - i;
System.out.println("Time elapsed: " + te + " ms");
public static void main(String[] args)
new Test1();
}2)
package cntrl.testing;
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JButton;
public class Test2 extends JFrame
public Test2()
long i = new Date().getTime();
this.setSize(500, 500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().add(new JButton());
this.getContentPane().add(new JButton());
this.getContentPane().add(new JButton());
this.getContentPane().add(new JButton());
long f = new Date().getTime();
long te = f - i;
System.out.println("Time elapsed: " + te + " ms");
public static void main(String[] args)
new Test2();
}
You're probably using some operating system where the smallest time interval you can measure is 10 milliseconds.
I would suggest that pushing something onto the stack would take an interval measured in nanoseconds. You have, let's say, a 1 gigahertz machine? That means it performs one billion operations per second, give or take. That's one per nanosecond.
There are a million nanoseconds in a millisecond. You're going to have to run a LOT of code to take a measurable amount of time.
Similar Messages
-
How to call the secured EJB from timer ejb timedout method.
Hi All,
I have a couple of questions on EJB 3.1 Timer Service.
1. How to call the secured EJB (annotated @RolesAllowed) from Timer EJB @Timeout Method?
2. What's the default role/principal with which the Timer @Timeout Method gets called?
Please let me know any info regarding the same.
Thanks,
SureshI'd start here:
http://ant.apache.org/manual/index.html
If that doesn't help, go to the table of contents and start poking around. You don't need to read the whole thing front to back, but if you're not willing to spend some time researching and reading, you're not going to get very far. -
How to call methods from within run()
Seems like this must be a common question, but I cannot for the life of me, find the appropriate topic. So apologies ahead of time if this is a repeat.
I have code like the following:
public class MainClass implements Runnable {
public static void main(String args[]) {
Thread t = new Thread(new MainClass());
t.start();
public void run() {
if (condition)
doSomethingIntensive();
else
doSomethingElseIntensive();
System.out.println("I want this to print ONLY AFTER the method call finishes, but I'm printed before either 'Intensive' method call completes.");
private void doSomethingIntensive() {
System.out.println("I'm never printed because run() ends before execution gets here.");
return;
private void doSomethingElseIntensive() {
System.out.println("I'm never printed because run() ends before execution gets here.");
return;
}Question: how do you call methods from within run() and still have it be sequential execution? It seems that a method call within run() creates a new thread just for the method. BUT, this isn't true, because the Thread.currentThread().getName() names are the same instead run() and the "intensive" methods. So, it's not like I can pause one until the method completes because they're the same thread! (I've tried this.)
So, moral of the story, is there no breaking down a thread's execution into methods? Does all your thread code have to be within the run() method, even if it's 1000 lines? Seems like this wouldn't be the case, but can't get it to work otherwise.
Thanks all!!!I (think I) understand the basics.. what I'm confused
about is whether the methods are synced on the class
type or a class instance?The short answer is; the instance for non-static methods, and the class for static methods, although it would be more accurate to say against the instance of the Class for static methods.
The locking associated with the "sychronized" keyword is all based around an entity called a "monitor". Whenever a thread wants to enter a synchronized method or block, if it doesn't already "own" the monitor, it will try to take it. If the monitor is owned by another thread, then the current thread will block until the other thread releases the monitor. Once the synchronized block is complete, the monitor is released by the thread that owns it.
So your question boils down to; where does this monitor come from? Every instance of every Object has a monitor associated with it, and any synchronized method or synchonized block is going to take the monitor associated with the instance. The following:
synchronized void myMethod() {...is equivalent to:
void myMethod() {
synchronized(this) {
...Keep in mind, though, that every Class has an instance too. You can call "this.getClass()" to get that instance, or you can get the instance for a specific class, say String, with "String.class". Whenever you declare a static method as synchronized, or put a synchronized block inside a static method, the monitor taken will be the one associated with the instance of the class in which the method was declared. In other words this:
public class Foo {
synchronized static void myMethod() {...is equivalent to:
public class Foo{
static void myMethod() {
synchronized(Foo.class) {...The problem here is that the instance of the Foo class is being locked. If we declare a subclass of Foo, and then declare a synchronized static method in the subclass, it will lock on the subclass and not on Foo. This is OK, but you have to be aware of it. If you try to declare a static resource of some sort inside Foo, it's best to make it private instead of protected, because subclasses can't really lock on the parent class (well, at least, not without doing something ugly like "synchronized(Foo.class)", which isn't terribly maintainable).
Doing something like "synchronized(this.getClass())" is a really bad idea. Each subclass is going to take a different monitor, so you can have as many threads in your synchronized block as you have subclasses, and I can't think of a time I'd want that.
There's also another, equivalent aproach you can take, if this makes more sense to you:
static final Object lock = new Object();
void myMethod() {
synchronized(lock) {
// Stuff in here is synchronized against the lock's monitor
}This will take the monitor of the instance referenced by "lock". Since lock is a static variable, only one thread at a time will be able to get into myMethod(), even if the threads are calling into different instances. -
CALL METHOD GRID4- SET_TABLE_FOR_FIRST_DISPLAY
Hi All,
I would like to know how to display 5 internal table same time in a single output screen. I have attached the program for your reference.
Presently I am able to get i_final1 and i_final2 output on the screen. I need to display on the same screen grid 3 and grid 4. Is it possible to display.
*& REPORT Z_READ_PROFILE
REPORT Z_READ_PROFILE.
TABLES: TCATS, TCATST, TCATX_GRID.
DATA: ST_CT1_FIELDCAT1 TYPE LVC_T_FCAT WITH HEADER LINE.
DATA: IT_CT1_FIELDCAT1 TYPE LVC_T_FCAT.
DATA: ST_CT1_FIELDCAT2 TYPE LVC_T_FCAT WITH HEADER LINE.
DATA: IT_CT1_FIELDCAT2 TYPE LVC_T_FCAT.
DATA: ST_CT1_FIELDCAT3 TYPE LVC_T_FCAT WITH HEADER LINE.
DATA: IT_CT1_FIELDCAT3 TYPE LVC_T_FCAT.
DATA: ST_CT1_FIELDCAT4 TYPE LVC_T_FCAT WITH HEADER LINE.
DATA: IT_CT1_FIELDCAT4 TYPE LVC_T_FCAT.
DATA: DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER,
SPLIT TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
GRID1 TYPE REF TO CL_GUI_ALV_GRID,
GRID2 TYPE REF TO CL_GUI_ALV_GRID,
GRID3 TYPE REF TO CL_GUI_ALV_GRID,
GRID4 TYPE REF TO CL_GUI_ALV_GRID,
DOC1 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
DOC3 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
DOC4 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
CON22 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
LI_FIELDCAT1 TYPE LVC_T_FCAT.
SELECTION-SCREEN: BEGIN OF BLOCK B1.
PARAMETERS: P_PROF1 LIKE TCATS-VARIANT,
P_PROF2 LIKE TCATS-VARIANT.
SELECTION-SCREEN: END OF BLOCK B1.
DATA: BEGIN OF I_DD03P OCCURS 0.
INCLUDE STRUCTURE DD03P.
DATA: END OF I_DD03P.
DATA: BEGIN OF I_FIELDS1 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FIELDS1.
DATA: BEGIN OF I_FIELDS2 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FIELDS2.
DATA: BEGIN OF I_FINAL1 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
TEXT LIKE TCATST-TEXT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FINAL1.
DATA: BEGIN OF I_FINAL2 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
TEXT LIKE TCATST-TEXT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FINAL2.
DATA: BEGIN OF ENTRYLIST OCCURS 0,
MFELD TYPE FAWFLDNAM,
VISIBLE TYPE FAWCUST,
REQUIRED TYPE FAWCUST,
READONLY TYPE FAWCUST,
HIDE TYPE FAWCUST,
PROF1 LIKE TCATS-VARIANT,
END OF ENTRYLIST.
DATA: BEGIN OF WORKLIST OCCURS 0.
INCLUDE STRUCTURE FIELD_SELECTION.
DATA: END OF WORKLIST.
DATA: BEGIN OF I_TCATX_GRID1 OCCURS 0,
PROFIL LIKE TCATX_GRID-PROFIL,
TASKCOMPONENT LIKE TCATX_GRID-TASKCOMPONENT,
COL LIKE TCATX_GRID-COL,
OBLIGAT LIKE TCATX_GRID-OBLIGAT,
END OF I_TCATX_GRID1.
DATA: BEGIN OF I_TCATX_GRID2 OCCURS 0,
PROFIL LIKE TCATX_GRID-PROFIL,
TASKCOMPONENT LIKE TCATX_GRID-TASKCOMPONENT,
COL LIKE TCATX_GRID-COL,
OBLIGAT LIKE TCATX_GRID-OBLIGAT,
END OF I_TCATX_GRID2.
PERFORM STATEMENT TO GET THE DATA BASED ON PORIFLE
IF NOT P_PROF1 IS INITIAL .
PERFORM GET_FIELDS1.
PERFORM GET_COMPONENTS1.
ENDIF.
IF NOT P_PROF1 IS INITIAL .
PERFORM GET_FIELDS2.
PERFORM GET_COMPONENTS2.
ENDIF.
PERFORM COMPARE_TABLES.
CALL SCREEN 100.
*& FORM GET_FIELDS
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM GET_FIELDS1.
CLEAR : ENTRYLIST, WORKLIST.
REFRESH: ENTRYLIST, WORKLIST.
CALL FUNCTION 'CATS_GET_INFLUENCES'
EXPORTING
VARIANT = P_PROF1
TABLES
ENTRYLIST_SELECTION = ENTRYLIST
WORKLIST_SELECTION = WORKLIST
IF SY-SUBRC EQ 0.
LOOP AT ENTRYLIST WHERE VISIBLE EQ SPACE
AND REQUIRED EQ SPACE
AND READONLY EQ SPACE.
MOVE 'X' TO ENTRYLIST-HIDE.
MODIFY ENTRYLIST TRANSPORTING HIDE.
ENDLOOP.
LOOP AT ENTRYLIST.
MOVE P_PROF1 TO I_FIELDS1-PROFILE.
MOVE ENTRYLIST-MFELD TO I_FIELDS1-MFIELD.
IF ENTRYLIST-READONLY NE 'X' AND ENTRYLIST-REQUIRED NE 'X' .
MOVE ENTRYLIST-VISIBLE TO I_FIELDS1-INPUT.
ENDIF.
MOVE ENTRYLIST-REQUIRED TO I_FIELDS1-OBLIGAT.
MOVE ENTRYLIST-READONLY TO I_FIELDS1-DISPLAY.
MOVE ENTRYLIST-HIDE TO I_FIELDS1-NOTACT.
APPEND I_FIELDS1.
ENDLOOP.
ENDIF.
ENDFORM. " GET_FIELDS
*& FORM GET_FIELDS2
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM GET_FIELDS2 .
CLEAR : ENTRYLIST, WORKLIST.
REFRESH: ENTRYLIST, WORKLIST.
CALL FUNCTION 'CATS_GET_INFLUENCES'
EXPORTING
VARIANT = P_PROF2
TABLES
ENTRYLIST_SELECTION = ENTRYLIST
WORKLIST_SELECTION = WORKLIST
IF SY-SUBRC EQ 0.
LOOP AT ENTRYLIST WHERE VISIBLE EQ SPACE
AND REQUIRED EQ SPACE
AND READONLY EQ SPACE.
MOVE 'X' TO ENTRYLIST-HIDE.
MODIFY ENTRYLIST TRANSPORTING HIDE.
ENDLOOP.
LOOP AT ENTRYLIST.
MOVE P_PROF2 TO I_FIELDS2-PROFILE.
MOVE ENTRYLIST-MFELD TO I_FIELDS2-MFIELD.
IF ENTRYLIST-READONLY NE 'X' AND ENTRYLIST-REQUIRED NE 'X' .
MOVE ENTRYLIST-VISIBLE TO I_FIELDS2-INPUT.
ENDIF.
MOVE ENTRYLIST-REQUIRED TO I_FIELDS2-OBLIGAT.
MOVE ENTRYLIST-READONLY TO I_FIELDS2-DISPLAY.
MOVE ENTRYLIST-HIDE TO I_FIELDS2-NOTACT.
APPEND I_FIELDS2.
ENDLOOP.
ENDIF.
ENDFORM. " GET_FIELDS2
*& FORM COMPARE_TABLES
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM COMPARE_TABLES .
CLEAR: I_FIELDS1, I_FIELDS2.
SORT : I_FIELDS1, I_FIELDS2.
DATA: L_TABLE LIKE DD03L-TABNAME,
L_FIELD LIKE DD03L-FIELDNAME.
LOOP AT I_FIELDS1.
READ TABLE I_FIELDS2 WITH KEY MFIELD = I_FIELDS1-MFIELD
INPUT = I_FIELDS1-INPUT
OBLIGAT = I_FIELDS1-OBLIGAT
DISPLAY = I_FIELDS1-DISPLAY
NOTACT = I_FIELDS1-NOTACT.
IF SY-SUBRC NE 0.
MOVE I_FIELDS1-PROFILE TO I_FINAL1-PROFILE.
SPLIT I_FIELDS1-MFIELD AT '-' INTO L_TABLE L_FIELD.
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
I_TABNM = L_TABLE
I_FLDNM = L_FIELD
I_LANGU = SY-LANGU
IMPORTING
E_DD03P = I_DD03P
EXCEPTIONS
FIELD_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC EQ 0.
MOVE I_DD03P-DDTEXT TO I_FINAL1-TEXT.
ENDIF.
MOVE I_FIELDS1-MFIELD TO I_FINAL1-MFIELD.
MOVE I_FIELDS1-INPUT TO I_FINAL1-INPUT.
MOVE I_FIELDS1-OBLIGAT TO I_FINAL1-OBLIGAT.
MOVE I_FIELDS1-DISPLAY TO I_FINAL1-DISPLAY.
MOVE I_FIELDS1-NOTACT TO I_FINAL1-NOTACT.
APPEND I_FINAL1.
ENDIF.
ENDLOOP.
SORT : I_FIELDS1, I_FIELDS2.
LOOP AT I_FIELDS2.
READ TABLE I_FIELDS1 WITH KEY MFIELD = I_FIELDS2-MFIELD
INPUT = I_FIELDS2-INPUT
OBLIGAT = I_FIELDS2-OBLIGAT
DISPLAY = I_FIELDS2-DISPLAY
NOTACT = I_FIELDS2-NOTACT.
IF SY-SUBRC NE 0.
MOVE I_FIELDS2-PROFILE TO I_FINAL2-PROFILE.
SPLIT I_FIELDS2-MFIELD AT '-' INTO L_TABLE L_FIELD.
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
I_TABNM = L_TABLE
I_FLDNM = L_FIELD
I_LANGU = SY-LANGU
IMPORTING
E_DD03P = I_DD03P
EXCEPTIONS
FIELD_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC EQ 0.
MOVE I_DD03P-DDTEXT TO I_FINAL2-TEXT.
ENDIF.
MOVE I_FIELDS2-MFIELD TO I_FINAL2-MFIELD.
MOVE I_FIELDS2-INPUT TO I_FINAL2-INPUT.
MOVE I_FIELDS2-OBLIGAT TO I_FINAL2-OBLIGAT.
MOVE I_FIELDS2-DISPLAY TO I_FINAL2-DISPLAY.
MOVE I_FIELDS2-NOTACT TO I_FINAL2-NOTACT.
APPEND I_FINAL2.
ENDIF.
ENDLOOP.
ENDFORM. " COMPARE_TABLES
*& MODULE STATUS_0100 OUTPUT
TEXT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS SPACE.
SET TITLEBAR 'T001'.
PERFORM FIELDCAT_FINAL1.
PERFORM FIELDCAT_FINAL2.
CREATE OBJECT DOCK
EXPORTING
REPID = SY-REPID
DYNNR = '100'
EXTENSION = '600'
SIDE = '1'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT DOC1
EXPORTING
REPID = SY-REPID
DYNNR = '100'
EXTENSION = '1000'
SIDE = '4'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT GRID1 EXPORTING I_PARENT = DOCK.
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'I_FINAL1'
CHANGING
IT_OUTTAB = I_FINAL1[]
IT_FIELDCATALOG = IT_CT1_FIELDCAT1[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT GRID2 EXPORTING I_PARENT = DOC1.
CALL METHOD GRID2->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'I_FINAL2'
CHANGING
IT_OUTTAB = I_FINAL2[]
IT_FIELDCATALOG = IT_CT1_FIELDCAT2[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT DOC3
EXPORTING
REPID = SY-REPID
DYNNR = '100'
EXTENSION = '600'
SIDE = '1'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT DOC4
EXPORTING
REPID = SY-REPID
DYNNR = '100'
EXTENSION = '1000'
SIDE = '4'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT GRID3 EXPORTING I_PARENT = DOC3.
CALL METHOD GRID3->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'TCATX_GRID'
CHANGING
IT_OUTTAB = I_TCATX_GRID1[]
IT_FIELDCATALOG = IT_CT1_FIELDCAT1[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT GRID4 EXPORTING I_PARENT = DOC4.
CALL METHOD GRID4->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'TCATX_GRID'
CHANGING
IT_OUTTAB = I_TCATX_GRID2[]
IT_FIELDCATALOG = IT_CT1_FIELDCAT2[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC NE 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 SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& FORM FIELDCAT_FINAL1
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM FIELDCAT_FINAL1 .
IF IT_CT1_FIELDCAT1[] IS INITIAL.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'PROFILE'.
ST_CT1_FIELDCAT1-COL_POS = 0.
ST_CT1_FIELDCAT1-OUTPUTLEN = 8.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'PROFILE'.
ST_CT1_FIELDCAT1-KEY = 'X'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'MFIELD'.
ST_CT1_FIELDCAT1-COL_POS = 1.
ST_CT1_FIELDCAT1-OUTPUTLEN = 15.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'FIELD'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'TEXT'.
ST_CT1_FIELDCAT1-COL_POS = 1.
ST_CT1_FIELDCAT1-OUTPUTLEN = 30.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'TEXT'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'INPUT'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'INPUT'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'OBLIGAT'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'REQUIRED'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'DISPLAY'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'DISPLAY'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'NOTACT'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'HIDE'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ENDIF.
ENDFORM. " FIELDCAT_FINAL1
*& FORM FIELDCAT_FINAL2
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM FIELDCAT_FINAL2 .
IF IT_CT1_FIELDCAT2[] IS INITIAL.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'PROFILE'.
ST_CT1_FIELDCAT2-COL_POS = 0.
ST_CT1_FIELDCAT2-OUTPUTLEN = 8.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'PROFILE'.
ST_CT1_FIELDCAT2-KEY = 'X'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'MFIELD'.
ST_CT1_FIELDCAT2-COL_POS = 1.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'FIELD'.
ST_CT1_FIELDCAT2-OUTPUTLEN = 15.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'TEXT'.
ST_CT1_FIELDCAT2-COL_POS = 1.
ST_CT1_FIELDCAT2-OUTPUTLEN = 30.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'TEXT'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'INPUT'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'INPUT'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'OBLIGAT'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'REQUIRED'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT2-FIELDNAME = 'DISPLAY'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'DISPLAY'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'NOTACT'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'HIDE'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ENDIF.
ENDFORM. " FIELDCAT_FINAL2
*& Form GET_COMPONENTS1
text
--> p1 text
<-- p2 text
FORM GET_COMPONENTS1 .
CLEAR : I_TCATX_GRID1.
REFRESH: I_TCATX_GRID1.
SELECT * FROM TCATX_GRID
INTO CORRESPONDING FIELDS OF TABLE I_TCATX_GRID1
WHERE PROFIL EQ P_PROF1.
ENDFORM. " GET_COMPONENTS1
*& Form GET_COMPONENTS2
text
--> p1 text
<-- p2 text
FORM GET_COMPONENTS2 .
CLEAR : I_TCATX_GRID2.
REFRESH: I_TCATX_GRID2.
SELECT * FROM TCATX_GRID
INTO CORRESPONDING FIELDS OF TABLE I_TCATX_GRID2
WHERE PROFIL EQ P_PROF2.
ENDFORM. " GET_COMPONENTS2
Thanks & Regards,
Nagaraj KalbaviHi Uwe,
As per your suggestion I have updated my program with splitter. Now I am able to get 3 internal Table but 4th one is not displaying. What could be the reason. I have attached my program for your reference.
& REPORT ZTEST_NAG&
REPORT ZTEST_NAG.
TABLES: TCATS, TCATST, TCATX_GRID.
DATA: ST_CT1_FIELDCAT1 TYPE LVC_T_FCAT WITH HEADER LINE.
DATA: IT_CT1_FIELDCAT1 TYPE LVC_T_FCAT.
DATA: ST_CT1_FIELDCAT2 TYPE LVC_T_FCAT WITH HEADER LINE.
DATA: IT_CT1_FIELDCAT2 TYPE LVC_T_FCAT.
data: go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_splitter_2 TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_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,
go_grid3 TYPE REF TO cl_gui_alv_grid,
go_grid4 TYPE REF TO cl_gui_alv_grid.
SELECTION-SCREEN: BEGIN OF BLOCK B1.
PARAMETERS: P_PROF1 LIKE TCATS-VARIANT,
P_PROF2 LIKE TCATS-VARIANT.
SELECTION-SCREEN: END OF BLOCK B1.
DATA: BEGIN OF I_DD03P OCCURS 0.
INCLUDE STRUCTURE DD03P.
DATA: END OF I_DD03P.
DATA: BEGIN OF I_FIELDS1 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FIELDS1.
DATA: BEGIN OF I_FIELDS2 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FIELDS2.
DATA: BEGIN OF I_FINAL1 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
TEXT LIKE TCATST-TEXT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FINAL1.
DATA: BEGIN OF I_FINAL2 OCCURS 0,
PROFILE LIKE TCATS-VARIANT,
TEXT LIKE TCATST-TEXT,
MFIELD TYPE FAWFLDNAM,
INPUT LIKE RSFAC-INPUT,
OBLIGAT LIKE RSFAC-OBLIGAT,
DISPLAY LIKE RSFAC-DISPLAY,
NOTACT LIKE RSFAC-NOTACT,
END OF I_FINAL2.
DATA: BEGIN OF ENTRYLIST OCCURS 0,
MFELD TYPE FAWFLDNAM,
VISIBLE TYPE FAWCUST,
REQUIRED TYPE FAWCUST,
READONLY TYPE FAWCUST,
HIDE TYPE FAWCUST,
PROF1 LIKE TCATS-VARIANT,
END OF ENTRYLIST.
DATA: BEGIN OF WORKLIST OCCURS 0.
INCLUDE STRUCTURE FIELD_SELECTION.
DATA: END OF WORKLIST.
DATA: BEGIN OF I_TCATX_GRID1 OCCURS 0,
PROFIL LIKE TCATX_GRID-PROFIL,
TASKCOMPONENT LIKE TCATX_GRID-TASKCOMPONENT,
COL LIKE TCATX_GRID-COL,
OBLIGAT LIKE TCATX_GRID-OBLIGAT,
END OF I_TCATX_GRID1.
DATA: BEGIN OF I_TCATX_GRID2 OCCURS 0,
PROFIL LIKE TCATX_GRID-PROFIL,
TASKCOMPONENT LIKE TCATX_GRID-TASKCOMPONENT,
COL LIKE TCATX_GRID-COL,
OBLIGAT LIKE TCATX_GRID-OBLIGAT,
END OF I_TCATX_GRID2.
PERFORM STATEMENT TO GET THE DATA BASED ON PORIFLE
IF NOT P_PROF1 IS INITIAL .
PERFORM GET_FIELDS1.
PERFORM GET_COMPONENTS1.
ENDIF.
IF NOT P_PROF1 IS INITIAL .
PERFORM GET_FIELDS2.
PERFORM GET_COMPONENTS2.
ENDIF.
PERFORM COMPARE_TABLES.
CALL SCREEN 100.
*& FORM GET_FIELDS
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM GET_FIELDS1.
CLEAR : ENTRYLIST, WORKLIST.
REFRESH: ENTRYLIST, WORKLIST.
CALL FUNCTION 'CATS_GET_INFLUENCES'
EXPORTING
VARIANT = P_PROF1
TABLES
ENTRYLIST_SELECTION = ENTRYLIST
WORKLIST_SELECTION = WORKLIST
IF SY-SUBRC EQ 0.
LOOP AT ENTRYLIST WHERE VISIBLE EQ SPACE
AND REQUIRED EQ SPACE
AND READONLY EQ SPACE.
MOVE 'X' TO ENTRYLIST-HIDE.
MODIFY ENTRYLIST TRANSPORTING HIDE.
ENDLOOP.
LOOP AT ENTRYLIST.
MOVE P_PROF1 TO I_FIELDS1-PROFILE.
MOVE ENTRYLIST-MFELD TO I_FIELDS1-MFIELD.
IF ENTRYLIST-READONLY NE 'X' AND ENTRYLIST-REQUIRED NE 'X' .
MOVE ENTRYLIST-VISIBLE TO I_FIELDS1-INPUT.
ENDIF.
MOVE ENTRYLIST-REQUIRED TO I_FIELDS1-OBLIGAT.
MOVE ENTRYLIST-READONLY TO I_FIELDS1-DISPLAY.
MOVE ENTRYLIST-HIDE TO I_FIELDS1-NOTACT.
APPEND I_FIELDS1.
ENDLOOP.
ENDIF.
ENDFORM. " GET_FIELDS
*& FORM GET_FIELDS2
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM GET_FIELDS2 .
CLEAR : ENTRYLIST, WORKLIST.
REFRESH: ENTRYLIST, WORKLIST.
CALL FUNCTION 'CATS_GET_INFLUENCES'
EXPORTING
VARIANT = P_PROF2
TABLES
ENTRYLIST_SELECTION = ENTRYLIST
WORKLIST_SELECTION = WORKLIST
IF SY-SUBRC EQ 0.
LOOP AT ENTRYLIST WHERE VISIBLE EQ SPACE
AND REQUIRED EQ SPACE
AND READONLY EQ SPACE.
MOVE 'X' TO ENTRYLIST-HIDE.
MODIFY ENTRYLIST TRANSPORTING HIDE.
ENDLOOP.
LOOP AT ENTRYLIST.
MOVE P_PROF2 TO I_FIELDS2-PROFILE.
MOVE ENTRYLIST-MFELD TO I_FIELDS2-MFIELD.
IF ENTRYLIST-READONLY NE 'X' AND ENTRYLIST-REQUIRED NE 'X' .
MOVE ENTRYLIST-VISIBLE TO I_FIELDS2-INPUT.
ENDIF.
MOVE ENTRYLIST-REQUIRED TO I_FIELDS2-OBLIGAT.
MOVE ENTRYLIST-READONLY TO I_FIELDS2-DISPLAY.
MOVE ENTRYLIST-HIDE TO I_FIELDS2-NOTACT.
APPEND I_FIELDS2.
ENDLOOP.
ENDIF.
ENDFORM. " GET_FIELDS2
*& FORM COMPARE_TABLES
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM COMPARE_TABLES .
CLEAR: I_FIELDS1, I_FIELDS2.
SORT : I_FIELDS1, I_FIELDS2.
DATA: L_TABLE LIKE DD03L-TABNAME,
L_FIELD LIKE DD03L-FIELDNAME.
LOOP AT I_FIELDS1.
READ TABLE I_FIELDS2 WITH KEY MFIELD = I_FIELDS1-MFIELD
INPUT = I_FIELDS1-INPUT
OBLIGAT = I_FIELDS1-OBLIGAT
DISPLAY = I_FIELDS1-DISPLAY
NOTACT = I_FIELDS1-NOTACT.
IF SY-SUBRC NE 0.
MOVE I_FIELDS1-PROFILE TO I_FINAL1-PROFILE.
SPLIT I_FIELDS1-MFIELD AT '-' INTO L_TABLE L_FIELD.
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
I_TABNM = L_TABLE
I_FLDNM = L_FIELD
I_LANGU = SY-LANGU
IMPORTING
E_DD03P = I_DD03P
EXCEPTIONS
FIELD_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC EQ 0.
MOVE I_DD03P-DDTEXT TO I_FINAL1-TEXT.
ENDIF.
MOVE I_FIELDS1-MFIELD TO I_FINAL1-MFIELD.
MOVE I_FIELDS1-INPUT TO I_FINAL1-INPUT.
MOVE I_FIELDS1-OBLIGAT TO I_FINAL1-OBLIGAT.
MOVE I_FIELDS1-DISPLAY TO I_FINAL1-DISPLAY.
MOVE I_FIELDS1-NOTACT TO I_FINAL1-NOTACT.
APPEND I_FINAL1.
ENDIF.
ENDLOOP.
SORT : I_FIELDS1, I_FIELDS2.
LOOP AT I_FIELDS2.
READ TABLE I_FIELDS1 WITH KEY MFIELD = I_FIELDS2-MFIELD
INPUT = I_FIELDS2-INPUT
OBLIGAT = I_FIELDS2-OBLIGAT
DISPLAY = I_FIELDS2-DISPLAY
NOTACT = I_FIELDS2-NOTACT.
IF SY-SUBRC NE 0.
MOVE I_FIELDS2-PROFILE TO I_FINAL2-PROFILE.
SPLIT I_FIELDS2-MFIELD AT '-' INTO L_TABLE L_FIELD.
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
I_TABNM = L_TABLE
I_FLDNM = L_FIELD
I_LANGU = SY-LANGU
IMPORTING
E_DD03P = I_DD03P
EXCEPTIONS
FIELD_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC EQ 0.
MOVE I_DD03P-DDTEXT TO I_FINAL2-TEXT.
ENDIF.
MOVE I_FIELDS2-MFIELD TO I_FINAL2-MFIELD.
MOVE I_FIELDS2-INPUT TO I_FINAL2-INPUT.
MOVE I_FIELDS2-OBLIGAT TO I_FINAL2-OBLIGAT.
MOVE I_FIELDS2-DISPLAY TO I_FINAL2-DISPLAY.
MOVE I_FIELDS2-NOTACT TO I_FINAL2-NOTACT.
APPEND I_FINAL2.
ENDIF.
ENDLOOP.
ENDFORM. " COMPARE_TABLES
*& MODULE STATUS_0100 OUTPUT
TEXT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS SPACE.
SET TITLEBAR 'T001'.
PERFORM FIELDCAT_FINAL1.
PERFORM FIELDCAT_FINAL2.
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc ne 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 ne 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.
Create 2nd splitter container
CREATE OBJECT go_splitter_2
EXPORTING
parent = go_cell_left
rows = 2
columns = 1
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc ne 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_2->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter_2->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
IF sy-subrc ne 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 ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid3
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
IF sy-subrc ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid4
EXPORTING
i_parent = go_cell_left
EXCEPTIONS
OTHERS = 5.
IF sy-subrc ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'I_FINAL1'
CHANGING
it_outtab = I_FINAL1[]
IT_FIELDCATALOG = IT_CT1_FIELDCAT1[]
EXCEPTIONS
OTHERS = 4.
IF sy-subrc ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'I_FINAL2'
CHANGING
it_outtab = I_FINAL2[]
IT_FIELDCATALOG = IT_CT1_FIELDCAT2[]
EXCEPTIONS
OTHERS = 4.
IF sy-subrc ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_grid3->set_table_for_first_display
EXPORTING
i_structure_name = 'TCATX_GRID'
CHANGING
it_outtab = I_TCATX_GRID1[] " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_grid4->set_table_for_first_display
EXPORTING
i_structure_name = 'TCATX_GRID'
CHANGING
it_outtab = I_TCATX_GRID2[] " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc ne 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 = syst-repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc ne 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 SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& FORM FIELDCAT_FINAL1
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM FIELDCAT_FINAL1 .
IF IT_CT1_FIELDCAT1[] IS INITIAL.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'PROFILE'.
ST_CT1_FIELDCAT1-COL_POS = 0.
ST_CT1_FIELDCAT1-OUTPUTLEN = 8.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'PROFILE'.
ST_CT1_FIELDCAT1-KEY = 'X'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'MFIELD'.
ST_CT1_FIELDCAT1-COL_POS = 1.
ST_CT1_FIELDCAT1-OUTPUTLEN = 15.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'FIELD'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'TEXT'.
ST_CT1_FIELDCAT1-COL_POS = 1.
ST_CT1_FIELDCAT1-OUTPUTLEN = 30.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'TEXT'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'INPUT'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'INPUT'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'OBLIGAT'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'REQUIRED'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'DISPLAY'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'DISPLAY'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ST_CT1_FIELDCAT1-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT1-FIELDNAME = 'NOTACT'.
ST_CT1_FIELDCAT1-COL_POS = 2.
ST_CT1_FIELDCAT1-OUTPUTLEN = 2.
ST_CT1_FIELDCAT1-SCRTEXT_L = 'HIDE'.
APPEND ST_CT1_FIELDCAT1 TO IT_CT1_FIELDCAT1.
CLEAR ST_CT1_FIELDCAT1.
ENDIF.
ENDFORM. " FIELDCAT_FINAL1
*& FORM FIELDCAT_FINAL2
TEXT
--> P1 TEXT
<-- P2 TEXT
FORM FIELDCAT_FINAL2 .
IF IT_CT1_FIELDCAT2[] IS INITIAL.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'PROFILE'.
ST_CT1_FIELDCAT2-COL_POS = 0.
ST_CT1_FIELDCAT2-OUTPUTLEN = 8.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'PROFILE'.
ST_CT1_FIELDCAT2-KEY = 'X'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'MFIELD'.
ST_CT1_FIELDCAT2-COL_POS = 1.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'FIELD'.
ST_CT1_FIELDCAT2-OUTPUTLEN = 15.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'TEXT'.
ST_CT1_FIELDCAT2-COL_POS = 1.
ST_CT1_FIELDCAT2-OUTPUTLEN = 30.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'TEXT'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'INPUT'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'INPUT'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'OBLIGAT'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'REQUIRED'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL1'.
ST_CT1_FIELDCAT2-FIELDNAME = 'DISPLAY'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'DISPLAY'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ST_CT1_FIELDCAT2-TABNAME = 'I_FINAL2'.
ST_CT1_FIELDCAT2-FIELDNAME = 'NOTACT'.
ST_CT1_FIELDCAT2-COL_POS = 2.
ST_CT1_FIELDCAT2-OUTPUTLEN = 2.
ST_CT1_FIELDCAT2-SCRTEXT_L = 'HIDE'.
APPEND ST_CT1_FIELDCAT2 TO IT_CT1_FIELDCAT2.
CLEAR ST_CT1_FIELDCAT2.
ENDIF.
ENDFORM. " FIELDCAT_FINAL2
*& Form GET_COMPONENTS1
text
--> p1 text
<-- p2 text
FORM GET_COMPONENTS1 .
CLEAR : I_TCATX_GRID1.
REFRESH: I_TCATX_GRID1.
SELECT * FROM TCATX_GRID
INTO CORRESPONDING FIELDS OF TABLE I_TCATX_GRID1
WHERE PROFIL EQ P_PROF1.
ENDFORM. " GET_COMPONENTS1
*& Form GET_COMPONENTS2
text
--> p1 text
<-- p2 text
FORM GET_COMPONENTS2 .
CLEAR : I_TCATX_GRID2.
REFRESH: I_TCATX_GRID2.
SELECT * FROM TCATX_GRID
INTO CORRESPONDING FIELDS OF TABLE I_TCATX_GRID2
WHERE PROFIL EQ P_PROF2.
ENDFORM. " GET_COMPONENTS2
Thanks & Regards,
Nagaraj Kalbavi -
Issue with Capturing Long text using CALL METHOD EDITOR- GET_TEXT_AS_STREAM
HI Experts,
Standard Long text is capturing using CALL METHOD EDITOR->GET_TEXT_AS_STREAM
but not working for Custom Long text – Only changes
Here is the Issue:
1) Created Custom Long text in TAB. --> Good
2) Entered few lines in custom Long text --> Good
Click on Standard Tab , Leaving Custom tab and Custom Long text-->Good
4) In PAI of Custom Tab – Changes captured using CALL METHOD 1 ( See below Code 1)--> Good
5) Entered few lines in Standard Long text in Standard Tab -->Good
6) Click another Standard Tab
7) In PAI of Standard Tab – Changes captured using CALL MEHTOD 2 ( See Below Code 2)-->Good
8) Come back to Standard Tab / Standard Long Text , Enter few more lines.
9) Change the Tab , IN PAI of Standard Tab/Standard Text , Changes Captured using CALL METHOD2 ( See Below CODE 3) --> Good
10) Go to Custom Tab , Custom Long text , Entered few more lines--> Good
11) Click on any other tab, Triggered again PAI of Custom tab / Custom Long text using Call Method1 ( See Below Code 4) -->Good triggered PAI same CALL METHOD TEXT_EDITOR1->GET_TEXT_AS_STREAM.
12) But additional lines are not captured , saying ZERO LINES in Internal Table and IF_MODIFIED = NO -->Issues lies here.
CODE1 ( Custom Long text entry capturing – First Few Lines )
Custom Long text Entries are stored in LS_OUTTAB-TEXT first time when entered few lines and LV_MOD is 1.
PAI of Custom tab
CALL METHOD TEXT_EDITOR1->GET_TEXT_AS_STREAM
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TEXT = LS_OUTTAB-TEXT ( FIlled with Lines entered in custom long text )
IS_MODIFIED = LV_MOD ( Value 1 , Modified )
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
OTHERS = 3
CODE2 ( Standard Long Text Entry Capturing – First Few Lines )
Standard Long text Entries are stored in SELECTED_TEXT first time when entered few lines and FLAG_MODIFIED is 1.
PAI of Standard tab
CALL METHOD EDITOR->GET_TEXT_AS_STREAM
EXPORTING
ONLY_WHEN_MODIFIED = YTRUE ( Value 1 , Modified )
IMPORTING
TEXT = SELECTED_TEXT ( FIlled with Lines entered in standard long text )
IS_MODIFIED = FLAG_MODIFIED.
CODE 3 ( Standard Long Text Entry Capturing – Second time Few Lines )
Standard Long text Entries are stored in SELECTED_TEXT second time when entered few lines and FLAG_MODIFIED is 1.
PAI of Standard tab
CALL METHOD EDITOR->GET_TEXT_AS_STREAM
EXPORTING
ONLY_WHEN_MODIFIED = YTRUE
IMPORTING
TEXT = SELECTED_TEXT ( FIlled with Lines entered in standard long text )
IS_MODIFIED = FLAG_MODIFIED. ( Value 1 , Modified )
CODE4 ( Custom Long text entry capturing – Second Time Few Lines )
Custom Long text Entries are not stored in LS_OUTTAB-TEXT Second Time when entered few lines and LV_MOD is 0.
PAI of Custom tab
CALL METHOD TEXT_EDITOR1->GET_TEXT_AS_STREAM
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TEXT = LS_OUTTAB-TEXT ( ZERO ENTRIES )
IS_MODIFIED = LV_MOD ( NOT MODIFIED Flag )
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
OTHERS = 3
Can anyone help me out of this.
With Regards,
Bala MExcellent Eitan,
Here is what I am trying to Achieve.
In Create Notification IW21 , They need 5 Long Text in Custom Tab ( Say Tab Name is MBR ).
TAB1 NOTIFICATION Standard Information , TAB2 REFERENCE OBJ , TAB 3 MalFunction , Breakdown Standard one...... TAB 7 ( Custom Tab ).
In Custom Tab , I added 5 LONG TEXT ( its 5 WHY Concept ).
When the User enters data in 5 Long text , it should store long text along with Notification number when save.
But Notification number will be generated @ the time of SAVE , but before that its just shows as
%0000000001 ( and Number will be generated 1000065479) at Save.
How to achive this .
I did this:
Added 5 Custom Container. and In PBO / PAI
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
IN PBO
CREATE OBJECT TEXT_EDITOR1 , CREATE OBJECT TEXT_EDITOR2, CREATE OBJECT TEXT_EDITOR3 like wise 5
CALL METHOD TEXT_EDITOR1->SET_TEXT_AS_R3TABLE , CALL METHOD TEXT_EDITOR2->SET_TEXT_AS_R3TABLE .. Like wise 5 , So when the user Click on Custom Tab ( MBR ).
It give 5 Long text.
When he click tab1 or tab2 or tab3 .. and again tab MBR , still data is available.
How to store this data for future retrival ( IW22 or IW23 ) ?
Its working fine when I enter first time and goes here and there and finall save .
IN SAVE BADI , I imported the Long text and created Standard Text SO10 with Notification Number with LONG1 , LONG2 .. means 1000065479LONG1 as standard text.
But not working when I entered first time and go to tab1 and tab2 and then to MBR tab and added few more lines , its not exporting full lines and in IMPORT ( SAVE BADI ) giving ZERO Lines.
Please help and thanks for your quick response. -
ABAP OOP / Calling Method ...Help
Trying out few oop codes....
While calling class instance methods and passing parameters, when to use the following syntax.
data: cvar type ref to class1.
cvar->method( exporting variable1 = value )
(or) some time i see sample codes with out key word 'exporting'
cvar->method( variable1 = value ) .
(or)
cvar->method( value ) .
(or) some times with key word CALL METHOD
CREATE OBJECT cvar
CALL METHOD cvar->method
EXPORTING
variable1 = value.
Tried out a uniform way of calling ,but getting errors.Any inputs please..
Thanks,
BvanBhavan,
First declare the class.
Implement the class.
Declare the Class reference variable
Create the class object.
call the method.
data: cvar type ref to class1.
CREATE OBJECT cvar
Calling Methods
To call a method, use the following statement:
CALL METHOD <meth> EXPORTING... <ii> =.<f i>...
IMPORTING... <ei> =.<g i>...
CHANGING ... <ci> =.<f i>...
RECEIVING r = h
EXCEPTIONS... <ei> = rc i...
The way in which you address the method <method> depends on the method itself and from where you are calling it. Within the implementation part of a class, you can call the methods of the same class directly using their name <meth>.
CALL METHOD <meth>...
Outside the class, the visibility of the method depends on whether you can call it at all. Visible instance methods can be called from outside the class using
CALL METHOD <ref>-><meth>...
where <ref> is a reference variable whose value points to an instance of the class. Visible instance methods can be called from outside the class using
CALL METHOD <class>=><meth>...
where <class> is the name of the relevant class.
When you call a method, you must pass all non-optional input parameters using the EXPORTING or CHANGING addition in the CALL METHOD statement. You can (but do not have to) import the output parameters into your program using the IMPORTING or RECEIVING addition. Equally, you can (but do not have to) handle any exceptions triggered by the exceptions using the EXCEPTIONS addition. However, this is recommended.
You pass and receive values to and from methods in the same way as with function modules, that is, with the syntax:
... <Formal parameter> = <Actual parameter>
after the corresponding addition. The interface parameters (formal parameters) are always on the left-hand side of the equals sign. The actual parameters are always on the right. The equals sign is not an assignment operator in this context; it merely serves to assign program variables to the interface parameters of the method.
If the interface of a method consists only of a single IMPORTING parameter, you can use the following shortened form of the method call:
CALL METHOD <method>( f).
The actual parameter <f> is passed to the input parameters of the method.
If the interface of a method consists only of IMPORTING parameters, you can use the following shortened form of the method call:
CALL METHOD <method>(....<ii> =.<f i>...).
Each actual parameter <f i > is passed to the corresponding formal parameter <i i >.
Pls. mark if useful -
Multiple times constructors calling in Myfaces
Hi
i m fasing multiple times constructor calling for myfaces programs
i have created a small web appl. with one text box and one submit button, to test this behaviour.
i have used this sample to
get web page
enter some text value
submit the page
and atlast page get returned to me
i don't understand the multiple times consturctor calling and exact sequence of Getter/Setter calling?
Following are details -
faces-config.xml
<managed-bean>
<managed-bean-name>fileUploadBean</managed-bean-name>
<managed-bean-class>com.dbschenker.dts.model.backingbean.FileUpload</managed-bean-class>
<manged-bean-scope>request</manged-bean-scope>
</managed-bean>
jsp file
<h:inputText id="txtSample" value="#{fileUploadBean.txtName}"/>
<h:commandButton action="#{fileUploadBean.uploadFile}"
image="../../images/upload_0.png"
onmouseover="this.src='../../images/upload_0.png'"
onmouseout="this.src='../../images/upload_1.png'"
onclick="return true;"/>
Backing bean
public class FileUpload {
private String txtName;
public void setTxtName(String txtName) {
System.out.println("Calling Setter... ");
this.txtName= txtName;
public String getTxtName() {
System.out.println("Calling Getter... ");
return txtName==null?"":this.txtName;
public FileUpload() {
System.out.println("Calling Constructor... ");
public String uploadFile() {
System.out.println("Upload Form Submitted... ");
return "";
Output to Console
Calling Constructor...
Calling Getter...
Calling Constructor...
Calling Constructor...
Calling Getter...
Calling Constructor...
Calling Setter...
Calling Constructor...
Upload Form Submitted...
Calling Constructor...
Calling Getter...Hi
that blog was really good and in depth...
but i have one real time problem with multiple time constructor calling
if you replace text box with file upload tag in my earlier sample program and then following is out put ...
Calling Constructor...
getUploadedFile()...
Calling Constructor...
getUploadedFile()...
Calling Constructor...
setUploadedFile()...
Uploaded File Name - D:\AsnUploadTemplate02.XLS
Calling Constructor... ------------------(.1
Upload Form Submitted...
java.lang.NullPointerException
at com.dbschenker.dts.model.backingbean.FileUpload.uploadFile(FileUpload.java:40)
----------- trailing exception stack trace...
Calling Constructor...
getUploadedFile()...
form this output u can find that my UploadedFile backing bean object gets null just before form submit method...
whereas its has been properly instantiated in setter method,
if constructor (1 wasn't call then object (uploadedFile) can be found in method (FileUpload.uploadFile)
i have also tried to make scope of backing bean Session , but constructor, getter & setter calling sequence doesn't different even after.
i have also considered both of your blog as ---
http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html
http://balusc.blogspot.com/2008/02/uploading-files-with-jsf.html
but my problem stands as it is
kindly help -
Can I Call method on one JVM from another through a dll?
Let me explain.
I have this java jar file that I can only have one instance of running at any given time. I'm using a shared data segment in a dll to store a bool indicating whether the program is already running or not. If it's already running, I have to not run the second instance and give focus to the current running instance.
The jar file calls a native method "canInstantiate()" on a dll to see if there's already an app running. If there isn't, the env and obj are stored in the shared data segment of the dll and we return true. If there is already an instance of the program running, I want canInstantiate call a function on the current instance of the jar (like a callback) to tell it to request focus. It's not working. Can someone tell me if my code is right?
The .h file
#include "stdafx.h"
#include <jni.h>
#include "CardServer.h"
#pragma data_seg("SHARED") // Begin the shared data segment.
static volatile bool instanceExists = false;
static JavaVM *theJavaVM = NULL;
static JNIEnv* theJavaEnv= NULL;
static jobject instanceObject = NULL;
static jmethodID mid = NULL;
static jclass cls = NULL;
#pragma data_seg()
#pragma comment(linker, "/section:SHARED,RWS")
jdouble canInstantiate(JNIEnv *env, jobject obj);
jdouble instantiate(JNIEnv *env, jobject obj);
jdouble uninstantiate(JNIEnv *env, jobject obj);
void grabFocus();
</code>
The .cpp file:
<code>
#include "MyFunctions.h"
#include <string.h>
#include <stdlib.h>
#include "stdafx.h"
#include <iostream.h>
jdouble canInstantiate(JNIEnv *env, jobject obj)
printf("In canInstantiate!!");
if (!instanceExists)
printf("No instance exists!!");
return (jdouble)0.0;
else
printf("An instance already exists!!");
grabFocus();
return (jdouble)1.0;
jdouble instantiate(JNIEnv *env, jobject obj)
printf("**In CPP: Instantiate!!\n");
cout << "At start, env is: " << env << endl;
cout << "At start, obj is: " << obj << endl;
if (instanceExists == false)
instanceExists = true;
theJavaEnv = env;
instanceObject = obj;
theJavaEnv->GetJavaVM(&theJavaVM);
cls = (theJavaEnv)->FindClass("TheMainClassOfTheJar");
if (cls == 0) {
fprintf(stderr, "Can't find Prog class\n");
exit(1);
mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
if (mid == 0) {
fprintf(stderr, "Can't find grabFocusInJava\n");
exit(1);
printf("About to call grabFocusInJava\n");
grabFocus();
printf("CPP: After the grab focus command in instantiate!!\n");
cout << "At end, env is: " << env << endl;
cout << "At end, obj is: " << obj << endl;
return 0.0;
else
printf("CPP: Finished Instantiate!!\n");
return 1.0;
jdouble uninstantiate(JNIEnv *env, jobject obj)
printf("CPP: In uninstantiate!!\n");
if (instanceExists == true)
instanceExists = false;
theJavaVM = NULL;
instanceObject = NULL;
printf("CPP: Finishing uninstantiate!!\n");
return 0.0;
else
printf("CPP: Finishing uninstantiate!!\n");
return 1.0;
void grabFocus()
printf("In CPP::GrabFocus!!\n");
instanceObject = theJavaEnv->NewGlobalRef(instanceObject);
cls = (theJavaEnv)->FindClass("CardFormatter");
if (cls == 0) {
fprintf(stderr, "Can't find Prog class\n");
exit(1);
printf("Got the cls id again!!\n");
if (cls == 0)
printf("IT'S INVALID!!\n");
mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
if (mid == 0) {
fprintf(stderr, "Can't find grabFocusInJava\n");
exit(1);
theJavaEnv->CallIntMethod(instanceObject, mid, 2);
printf("Called grabFocusInJava\n");
</code>
thanks in advanceCan I Call method on one JVM from another through a dll
...The rest of your question merely expands on your title.
And the answer to that question is no.
When you call a method you are executing a "thread of execution." A thread of execution exists only in a single process. It can not exist in another process.
If the dll is doing some interesting things then you could call a method that sets a flag. Data can move between instances. But you would then have to have a thread in that different process monitoring that flag. And sharing data in a dll is not a normal process, so it would have to be coded appropriately.
If all you want to do is set the current focus to the existing application, then that can be done with existing windows functionality. You don't need to do anything special in your dll. You can probably search these forums to find the exact code. If not there are countless examples in windows repositories (like MSDN) on how to do that. -
Alternatives to long parameter lists when calling methods
I've heard you shouldn't have more than 3 parameters when calling methods. What are the alternatives to long parameter lists when calling methods? Compounding parameters into new inner classes, declaring them as member fields? Which one is preferable?
Okay, I get it. But since it's late in the day, I'll share my additional wandering thoughts. And I'll just go ahead and preemptively slap myself for doing so. Ouch! There. So the rules are more like this:
1) Only use setters if the values in question are meant to be part of the state of an object.
2) In general, don't let external entities directly set the state of an object.
Which can be combined into:
1) In general, never use setters.
Which could be reworded to:
1) Only use setters in non-general situations.
Or:
1) Only use setters when setters are a good solution...which isn't very often...generally speaking...
Or if I were to infer when it's a good solution:
1) Only use a setter when it is useful to the caller and has no significant negative effects on the operation of the object nor the maintainability, size, or performance of the class...generally speaking...
Actually, you might just infer from here forward that the "generally speaking" is implicit to every rule, and is essentially the "There is an exception to every rule" rule. Which is an interesting rule because it can be applied to itself, resulting in a paradox...generally speaking...but I digress.
And then translated back to the original topic:
1) You can use a setter instead of a constructor argument so long as the value isn't needed at time of construction (or a default value will suffice) and it is useful for the caller to be able to use the setter and using the setter has no significant negative effects on the operation of the object nor the maintainability, size, or performance of the class.
But this won't quite cut it either. With the input of others, we could eventually devise a very concise rule, but it will end up being so long that on one will ever read it...making it an ideal candidate to be included in a legal document. Which will eventually find it's way into a very long scroll pane with a check box at the end exclaiming that you read the document, at which you will not be able to continue unless you check the check box...at which point, what do you do? After all, you are not a liar...generally speaking...
In summary, you could potentially use setters in some limited cases, but in the general sense, that's more of an option than a recommendation. :-) -
Hello experts:
I have a little problem, I want to create an ALV field with 4 decimales, it's a dinamic table, but when the alv report shows the fields it shows only 2 decimals, here the main code for explaining me better:
Here the code for create the field with decimals:
* Netpr
lv_cols = lv_cols + 1.
MOVE lv_cols TO wa_it_fldcat-col_pos.
MOVE 'NETPR' TO wa_it_fldcat-fieldname.
MOVE 'Net Price' TO wa_it_fldcat-scrtext_l.
MOVE 'Net Price' TO wa_it_fldcat-scrtext_m.
MOVE 'Net Pr' TO wa_it_fldcat-scrtext_s.
MOVE 'CURR' TO wa_it_fldcat-datatype.
MOVE 'P' TO wa_it_fldcat-inttype.
MOVE 11 TO wa_it_fldcat-intlen.
MOVE 4 TO wa_it_fldcat-decimals.
MOVE '' TO wa_it_fldcat-ref_field.
MOVE '' TO wa_it_fldcat-ref_table.
APPEND wa_it_fldcat TO t_fldcat.
After create more fields, here the code for create the dinamic ALV table:
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fldcat
IMPORTING
ep_table = t_newtable.
ASSIGN t_newtable->* TO <t_dyntable>.
* Create dynamic work area and assign to FS
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
ASSIGN t_newline->* TO <fs_dyntable>.
After this method, the structure of the work area having the data type of the fields and all the atributes, the decimals of the NETPR fields just have 2 decimals =(
I hope my explanation it's clear.
Any help with this issue it's very welcome, thank you very much for your time.
MiriamHi
Xiaonan Hu is right: u need to delete the row where u transfer CURR as type:
* Netpr
lv_cols = lv_cols + 1.
MOVE lv_cols TO wa_it_fldcat-col_pos.
MOVE 'NETPR' TO wa_it_fldcat-fieldname.
MOVE 'Net Price' TO wa_it_fldcat-scrtext_l.
MOVE 'Net Price' TO wa_it_fldcat-scrtext_m.
MOVE 'Net Pr' TO wa_it_fldcat-scrtext_s.
*MOVE 'CURR' TO wa_it_fldcat-datatype.
MOVE 'P' TO wa_it_fldcat-inttype.
MOVE 11 TO wa_it_fldcat-intlen.
MOVE 4 TO wa_it_fldcat-decimals.
MOVE '' TO wa_it_fldcat-ref_field.
MOVE '' TO wa_it_fldcat-ref_table.
APPEND wa_it_fldcat TO t_fldcat.
If you transfer CURR, the method will defined a type p with 2 decimals by default, so it's useless to indicate the decimals in this case.
Infact the method calls the fm ALV_TABLE_CREATE, and here the abap code is:
- for CURR type:
elseif ls_fieldcat-datatype = 'CURR'.
concatenate 'DATA:'
ls_fieldcat-fieldname
'TYPE'
ls_fieldcat-inttype
'DECIMALS 2.'
into lt_source-line separated by space.
- for P type
if ls_fieldcat-inttype = 'P' and not ls_fieldcat-decimals is
initial.
replace '.' with 'DECIMALS' into lt_source-line.
concatenate lt_source-line ls_fieldcat-decimals '.' into
lt_source-line separated by space.
endif.
Max -
Is it possible to call methods from another class from within an abstract c
Is it possible to call methods from another class from within an abstract class ?
I found an example in teh JDK 131 JFC that may help you. I t is using swing interface and JTable
If you can not use Swing, then you may want to do digging or try out with the idea presented here in example 3
Notice that one should refine the abstract table model and you may want to create a method for something like
public Object getValuesAtRow(int row) { return data[row;}
to give the desired row and leave the method for
getValuesAt alone for getting valued of particaular row and column.
So Once you got the seelcted row index, idxSelctd, from your table
you can get the row or set the row in your table model
public TableExample3() {
JFrame frame = new JFrame("Table");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}});
// Take the dummy data from SwingSet.
final String[] names = {"First Name", "Last Name", "Favorite Color",
"Favorite Number", "Vegetarian"};
final Object[][] data = {
{"Mark", "Andrews", "Red", new Integer(2), new Boolean(true)},
{"Tom", "Ball", "Blue", new Integer(99), new Boolean(false)},
{"Alan", "Chung", "Green", new Integer(838), new Boolean(false)},
{"Jeff", "Dinkins", "Turquois", new Integer(8), new Boolean(true)},
{"Amy", "Fowler", "Yellow", new Integer(3), new Boolean(false)},
{"Brian", "Gerhold", "Green", new Integer(0), new Boolean(false)},
{"James", "Gosling", "Pink", new Integer(21), new Boolean(false)},
{"David", "Karlton", "Red", new Integer(1), new Boolean(false)},
{"Dave", "Kloba", "Yellow", new Integer(14), new Boolean(false)},
{"Peter", "Korn", "Purple", new Integer(12), new Boolean(false)},
{"Phil", "Milne", "Purple", new Integer(3), new Boolean(false)},
{"Dave", "Moore", "Green", new Integer(88), new Boolean(false)},
{"Hans", "Muller", "Maroon", new Integer(5), new Boolean(false)},
{"Rick", "Levenson", "Blue", new Integer(2), new Boolean(false)},
{"Tim", "Prinzing", "Blue", new Integer(22), new Boolean(false)},
{"Chester", "Rose", "Black", new Integer(0), new Boolean(false)},
{"Ray", "Ryan", "Gray", new Integer(77), new Boolean(false)},
{"Georges", "Saab", "Red", new Integer(4), new Boolean(false)},
{"Willie", "Walker", "Phthalo Blue", new Integer(4), new Boolean(false)},
{"Kathy", "Walrath", "Blue", new Integer(8), new Boolean(false)},
{"Arnaud", "Weber", "Green", new Integer(44), new Boolean(false)}
// Create a model of the data.
TableModel dataModel = new AbstractTableModel() {
// These methods always need to be implemented.
public int getColumnCount() { return names.length; }
public int getRowCount() { return data.length;}
public Object getValueAt(int row, int col) {return data[row][col];}
// The default implementations of these methods in
// AbstractTableModel would work, but we can refine them.
public String getColumnName(int column) {return names[column];}
public Class getColumnClass(int col) {return getValueAt(0,col).getClass();}
public boolean isCellEditable(int row, int col) {return (col==4);}
public void setValueAt(Object aValue, int row, int column) {
data[row][column] = aValue;
}; -
Hi gurus i have a problem i have created a dinamic internal table but the lenght of the internal table fields is 10 i need longer fields
here is my code thanks
data: begin of it_campos OCCURS 0,
campo1(12) type c,
END OF it_campos.
do n times.
clear nocamptmp.
add 1 to incont.
CONDENSE incont NO-GAPS.
cont = incont.
CONCATENATE nocamp cont into nocamptmp.
wa_campos-campo1 = nocamptmp.
append wa_campos to it_campos.
enddo .
loop at it_campos into wa_campos.
t_fieldcat_wa-col_pos = SY-TABIX.
t_fieldcat_wa-fieldname = wa_campos-campo1.
APPEND t_fieldcat_wa TO t_fieldcat.
endloop .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = tabla
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
others = 2.
ASSIGN tabla->* TO <l_table>.
CREATE DATA ep_line LIKE LINE OF <l_table>.
all is fine but the fields of <l_table> are char(10) and my data is longer than 10 how can i increase the lenght of the table fields
any idea thanksModify the fieldcatalog accordingly for e.g.,
LOOP AT it_campos INTO wa_campos.
t_fieldcat_wa-col_pos = sy-tabix.
t_fieldcat_wa-fieldname = wa_campos-campo1.
t_fieldcat_wa-inttype = 'C'. " Character Type
t_fieldcat_wa-intlen = '50'. "50 character length
APPEND t_fieldcat_wa TO t_fieldcat.
ENDLOOP .
BR,
Suhas -
Error calling method of a PBNI object
Dear All,
We are facing issue of "Error calling method of a PBNI object". We are calling web services of WCF after some time to refresh data.We need help to solve this issue as we have to go live with client.
It's really urgent!
Regards
Imran ZaheerHi Chris,
Thanks for your concern.
1) PB version & Build?
PB builder 12.5.2 build 5609
2) MS-Window version?
Windows 7 professional.
3) Why are you using PBNI and what kind of class are you utilizing in that context?
We are calling webservices through soap objects.
4) What error(s) codes and messages are you getting?
we get "Error calling method of a PBNI object"
5) Why are you not using PB.net that supports WCF natively (I wish PB classic did)?
For this we need to convert our whole application in PB.Net which is not feasible for us.
6) Can you lightly describe your over-all architecture and application approach to Web Services?
We have replace EASERVER with WCFserver and we are calling webservices for fetching( pulling) data from WCF server. It's a soft of 3 tier architecture.
Regards .... Imran -
Help For Calling Method........!
I am confused about a problem. When I access the method of EJB A: such as UpdJob(),it works seccessfully,
also it is successful when access EJB B: insert(...).
But when I call the both methods at the same time in a method:
public void bothmethod(){
B.insert();..........(the method of EJB B)
A.UpdJob();........(the method of EJB A)
the result is that the B.insert() is success and the B.UpdJob failed with exception: No Resource Available,ejbStore failed,getConnection...
It looks failed to connect the database.
I don't know what's the matter,who can tell me?
Thanks in advance.you may have closed some resources in calling the B.insert(), and then not establish that resource before calling A.UpdJob()
-
I NEVER USED OOPS CONCEPT.BUT I GOT A TASK ON ALV REPORT USING class CL_GUI_ALV_GRID, call method SET_TABLE_FOR_FIRST_DISPLAY for ALV . I HAD PASSED THE VALUES FROM INTERNAL TABLE AND GOT OUTPUT IN ALV.
The problem is When i save an layout(default setting button ).
iam unable to get the output for all fields.
if u want i will send screenshots to ur mail
THANKS IN ADVANCE.ok fine,
In the output (alv grid) there is an icon for layout settings.
if i want to save layout (as DEFAULT SETTING) i am missing some fields in output
EX:
mat no | batch | proces order | time | date |
when i save layout (as DEFAULT SETTING) i am missing some fields in output
mat no | batch |
the rest of the field were not displayed.
if u are not clear just ask me. i will send some more examples.
Maybe you are looking for
-
[HELP] using multiple value parameter in c:import tag
I need to pass a multi-value parameter to a included page. e.g. http://myhost/MyContext/dir1/page1.jsp?abc=value1&abc=value2/dir1/page1.jsp includes /dir2/page2.jsp, and would like to pass this multi-value parameter over, but change the name to xyz,
-
hi, I am using htmldb mail facility,i have 4-5 checkbox with static values,now on page in which i am using mail option, it contain a select list in which there is static values of checkboxes,and text ,the data written in this i want to send. now i ha
-
Preinstalled songs cannot be played
Hello All, Last night I've updated my Nokia 5800 firmware to the v20.0.012 but I am surprised to see that now I am unable to play the preinstalled songs available on my device... Can anyone let me know whats wrongs!!!!!!!!!!!! Regards, rohit
-
As so often happens, I know alot more about my project then when I first began it, and now I need to change the name to make it more accurate and descriptive. Is this possible? I know RH is very picky about file names, and I don't want to mess anythi
-
Why is my wifi button greyed out
For some reason my phone wont let me switch my wifi button on. Its very frustrating because i cant update my phone to ios 7. Also i work long hours soo i dont have time to go to the apple store. Please help me