How to Use Table name at run time
Hi All
I have created a function that accepts a table name as a parameter and returns the maximam sequence number, but in my function body i can not write the parameter name as a table i.e.
CREATE OR REPLACE FUNCTION MAX_ID(TAB_NAME Varchar)
RETURN Number IS
max_id Number;
CURSOR curSalPoint IS
SELECT MAX(EMP_NUMBER)
FROM TAB_NAME ;
BEGIN
max_id:=0;
OPEN curSalPoint ;
FETCH curSalPoint INTO max_id;
CLOSE curSalPoint;
RETURN max_id
END
But it will give an error saying
(1):PL/SQL: ORA-00942: table or view does not exist
for "TAB_NAME"
Any help would be appreciate ........
Yes, as i contcatinated table name with the original statement, so you can also continate fields' names with your statment and execute immediate the statement.
Sorry i forgot this statement in my function, to execute the statement you need to include following statement
CREATE OR REPLACE FUNCTION MAX_ID(TAB_NAME Varchar)
RETURN Number IS
max_id Number;
query varchar2(200);
BEGIN
max_id:=0;
query:=null;
query := query || 'select max(empno) into max_id from'|| tab_name;
EXECUTE IMMEDIATE query;
RETURN max_id;
END;
Message was edited by:
Salman Qureshi
Similar Messages
-
How to pass column name at run time in function.
how to pass column name at run time in function as parameter.
thank in advance
pramod patelHello,
Using dynamic sql you can pass column name to function. well I am not getting what you really want to do ? Please write in more detail. By the way I am providing one example here. see it uses dynamic sql.
Create or replace function fun_updtest (p_columnname_varchar2 in varchar2,
p_value_number in number)
return number is
v_stmt varchar2(500);
begin
v_stmt := 'update emp
set '||p_columnname_varchar2||' = '||to_char(p_value_number)||'
where empno = 7369';
execute immediate v_stmt;
return 0;
commit;
end;
call to this function can be like this..
declare
v_number number;
begin
v_number := fun_updtest('SAL',5000);
end;
Adinath Kamode -
How to use table name dynamically in report procedure
Hello every body
I want to use table name dynamically means at runtime i want to pass table name.
I can do this by lexical parameter in main query.
But my problem is that i want to crate new format trigger or new function that use 1 cursor in which that lexical parameter : table name is used.
so how to do that?
i can not use that lexical parameter it is giving error.
please help me how to do that.Call a database function which you pass the lexical parameter. Then in the database function you use dynamic sql or the execute immediate option to build the SQL string.
Return the information from this function to build your business logic on in your format trigger.
Marcos -
How to get sequence name in run time.
hi
I have several sub sequence called in the main sequence in TestStand. Those sub sequences have different sequence names, which i wanted to display by string indicator on the Labview Operator Interface. Is there a simple way to show the current calling sub sequence name during run time(run main).
thanks.
Message Edited by Appledoll on 07-12-2007 10:12 AMHi,
The easiest way is to use the NameOf() function. In this case where you wish to get the name of the current sequence the syntax NameOf(RunState.Sequence) yields the name. I attach a very simple example also.
Getting the Name of Any TestStand Property Programmatically in TestStand
Hope this helps
Pelle S
District Sales Manager
National Instruments Sweden
Attachments:
Get sequence name.vi 15 KB -
How to find table size in run time ?
Hi all
I am using JTable problem is. �table data is being changed frequently� I waana method or any idea by which I could find the preferred size of table at run time�
Thanks & Regardsbut my problem is I have written one renderer for increase the row height at run time behalf of data.. And we are supposed to guess what you are doing from your original question?
I changed the code in my actionPerformed() method as follows:
table.setRowHeight(0, table.getRowHeight(0) + 10);
System.out.println(table.getPreferredSize());
The preferred size still changes.
I have no idea what your problem is or why you even care what the table preferred size is. You just add the table to a scroll pane and scroll bars will appear when required. -
How to use table name as variable in insert statement
Hi,
I want to insert data from the cursor into the table and I want to submit table name as a variable. I tried the code below but it's not working. Any ideas how to solve this problem? Thx
DECLARE
v_new_table_name VARCHAR2(30) := 'test';
--open cursor
CURSOR ACM IS
SELECT *
FROM DWH.CLI_DIMENSION@SLSPDW CLI
WHERE where_clause
FROM some_table;
BEGIN
FOR REC_ACM IN ACM LOOP
EXECUTE IMMEDIATE 'INSERT INTO ' || v_new_table_name || ' VALUES REC_ACM'; --table name as a variable in which the data from cursor will be inserted
V_ROWCOUNT := V_ROWCOUNT + 1;
IF MOD(V_ROWCOUNT, 100) = 0 THEN --this feature commits after 100 rows.
COMMIT;
END IF;
END LOOP;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Number of inserted records:' || V_ROWCOUNT);
END;Try this and let me know if it works. I have not tested it so I can not say for sure.
DECLARE
v_new_table_name VARCHAR2(30) := 'test';
CURSOR ACM IS
SELECT * FROM DWH.CLI_DIMENSION@SLSPDW CLI
WHERE where_clause
FROM some_table;
BEGIN
loop
fetch ACM INTO REC_ACM
exit when ACM%NOTFOUND;
EXECUTE IMMEDIATE 'INSERT INTO ' || v_new_table_name || ' VALUES REC_ACM';
V_ROWCOUNT := V_ROWCOUNT + 1;
IF MOD(V_ROWCOUNT, 100) = 0 THEN
COMMIT;
END IF;
end loop;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Number of inserted records:' || V_ROWCOUNT);
END; -
How to use a structure at run time....
Hi gurus,
I am confused on how to use the structure in our report..why do we need it...Please help me with that...
Thanks
Cheers:JimOr you could simply use a structure in your program to group like fields together. So that you could maybe clear them all at one shot.
For example, say that you have a structure with fields a - z.
data: begin of structure,
fielda type c,
fieldb type c,
fieldc type c,
fieldz type c,
end of structure.
So in your program, it is now important for you to clear these fields, if you would have defined them one by one without the structure, you would have to list them all in your CLEAR statement, but instead, since you have them in a structure, you can some say.... CLEAR STRUCTURE.
Regards,
Rich Heilman -
Table name at run time in Stored procedure
I have a SQl statement within my stored procedure as :
SELECT LastModifiedDate INTO v_Date FROM TABLE1 WHERE ID = v_ID;
Can I use a variable vTableName instead of directly putting the
value "TABLE1" (that is actual name of the table ).
Please excuse me if the question sounds trivial.
Cheers!!You need to use Dynamic Sql. In your procedure
DECLARE
v_sql_stmt varchar2(2000);
v_Date DATE ;
begin
v_sql_stmt := 'SELECT LastModifiedDate FROM TABLE1 WHERE ID = :1 ' ;
execute immediate v_sql_stmt into v_Date using v_ID ;
end; -
How to use table name as variable
P.s. I wish to send a tablename through a function as a variable
and then want to make a use in sql query. How can I make a use
of it.
nullRajeev Grover (guest) wrote:
: P.s. I wish to send a tablename through a function as a
variable
: and then want to make a use in sql query. How can I make a use
: of it.
Use the dbms_sql package.
E.g.
DECLARE
tbl_name VARCHAR2(40);
cur_stmt VARCHAR2(2000);
cur_hndl INTEGER;
BEGIN
cur_stmt :=
'SELECT column1, column2, column3, ... ' -
How to set table visibility in run time?
Dear all,
Initially i need to make my table invisible. if i click the button, it should be visible. Help me out to do this.
Thanks,
Gopi.Hi,
Rather hiding the table, apply the same for the transparant container...
Create a transparent contianer(TCO) and inside this have the TABLE....
Create a context attribtue of type wdui_visibility and bind it to the visible property oft the TCO.
After that, based on the data existence set this attribute value...
Do you have any input fields and this table in the same view....waht is your design....
If you have data in the internal table.......
data lv_visible type wdui_visibility.
if lt_table is not initial.
lv_viisble = '02''.
else.
lv_visible = '01'.
endif.
wd_context->set_attribute
exporting
name = 'VISIBLE_TCO'
value = lv_visible.
Hope this is clear...
Regards,
Lekha. -
How to find the list of un used table names in a schema?
Hi,
I have a doubt in Oracle. The doubt is that If we are using any tables in Function Or Proc.... Then...We can list all those used table names from USER_DEPENDENCIES system table. Right...
But, If the table is used with Execute Immediate Statement, then, those table names are not coming out with USER_DEPENDENCIES system table. Because they are identified at run time and not compile time.
It is fine. And I agree.. But, If I want to list out those tables also...then...How to do? Any idea?
I think ‘USER_SOURCE’ system table may not be the right one. If there is any other system table avails for this purpose...then..it would be very grateful to extract right...
So I am wanting that exact system table.
Please let me know about this, if you have any idea or check with your friends if they have any idea.
Regards,
Subramanian GHi Guys,
Thanks for all your answers.
Yes....You are all right. We can list out the used tables upto certain extent. Anyhow, I have done some R&D to derive the SQL's which is given below:
SELECT TABLE_NAME FROM USER_TABLES
MINUS
SELECT DISTINCT UPPER(REFERENCED_NAME)
FROM user_dependencies
where
referenced_type='TABLE' and UPPER(NAME) in
select distinct UPPER(object_name) from user_objects where UPPER(object_type) in
'MATERIALIZED VIEW',
'PACKAGE',
'PACKAGE BODY',
'PROCEDURE',
'TRIGGER',
'VIEW',
'FUNCTION'
UNION
SELECT UT.TABLE_NAME FROM
SELECT TABLE_NAME FROM USER_TABLES
MINUS
SELECT DISTINCT UPPER(REFERENCED_NAME)
FROM user_dependencies
where
referenced_type='TABLE' and UPPER(NAME) in
select distinct UPPER(object_name) from user_objects where UPPER(object_type) in
'MATERIALIZED VIEW',
'PACKAGE',
'PACKAGE BODY',
'PROCEDURE',
'TRIGGER',
'VIEW',
'FUNCTION'
AND REFERENCED_OWNER=(SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual)
) UT,
( SELECT * FROM USER_SOURCE
WHERE NAME IN
( SELECT DISTINCT NAME FROM USER_SOURCE
WHERE TYPE NOT IN ('TYPE')
AND
UPPER(TEXT) LIKE '%EXECUTE IMMEDIATE%'
) US
WHERE
UPPER(US.TEXT) LIKE '%'||UPPER(UT.TABLE_NAME)||'%'
AND
(UPPER(US.TEXT) NOT LIKE '%--%')
The above SQL Query can list out unused tables by checking the Dynamic SQL Statement also upto some level only.
Once we extracted the list of unused tables, having a manual check would be also greater to verify as it is should not impact the business applications.
Regards,
Subramanian G -
I have the code to read from a file but my problem is how to prompt the user for the file name at run time.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
import java.util.Scanner;
public class FileRead {
public static void main(String args[]) {
Scanner scan = null;
File file = new File("Results.txt");
String number;
try {
scan = new Scanner(file);
while (scan.hasNext()){
number = scan.next();
System.out.println(number);}
catch (FileNotFoundException ex1){
System.out.println("No such file");
catch (IllegalStateException ex2){
System.out.println("Did you close the read by mistake");
catch (InputMismatchException ex){
System.out.println("File structure incorrect");
finally{
scan.close();}
}Any hints would be greatly appreciated. Thank you in advanceI have read through some of the tutorials that you have directed me too and they are very useful, thank you. however there are still a few things that i am not clear about. I am using net beans 5.0 I have placed a text file named Results.txt into the project at the root so the program can view it.
When I use the code that you provided me with, does it matter where the file is, or will it look through everywhere on the hard drive to find a match?
This code compiles but at run time it comes up with this error
run-single:
java.lang.NoClassDefFoundError: NamedFile
Exception in thread "main"
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
import java.util.Scanner;
import java.io.*;
class NamedFileInput
public static void main (String[] args) throws IOException
int num, square;
// this Scanner is used to read what the user enters
Scanner user = new Scanner( System.in );
String fileName;
System.out.print("File Name: ");
fileName = user.nextLine().trim();
File file = new File( fileName ); // create a File object
// this Scanner is used to read from the file
Scanner scan = new Scanner( file );
while( scan.hasNextInt() ) // is there more data to process?
num = scan.nextInt();
square = num * num ;
System.out.println("The square of " + num + " is " + square);
}his is the code that i used. It is the same as the code you posted for me (on chapter 23 I/O using Scanner and PrintStream) Sorry im just really stuck on this!! -
How to use table control in bdc, plz somebody tell me.
Hi Gurus,
Ples tell me
how to use table control in bdc, plz somebody tell me.
And send Sample CODE also. Thnaks in advance.hi,
Table control / step loop in BDC
Steploop and table contol is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen?
Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction 'ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP')
we can determine the number of visible lines on Transaction Screen from our Calling BDC program.
Demo ABAP code has two purposes:
1. how to determine number of visible lines and how to calculte page number;
(the 'calpage' routine has been modify to meet general purpose usage)
2. using field symbol in BDC program, please pay special attention to the difference
in Static ASSIGN and Dynamic ASSIGN.
Step1: go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop.
Then have a look at steploop itselp, one entry of it will occupy two lines.
(Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line)
Now we have : FixedLine = 9
LoopLine = 2(for table control, LoopLine is always equal to 1)
Step2: go to transaction itself(ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input.
Now we have: FirstLine = 0
or FirstLine = 1 ( in our case, FirstLine is 1 because the first line of new page is fulfilled)
Step3: write a subroutine calcalculating number of pages
(here, the name of actual parameter is the same as formal parameter)
global data: FixedLine type i, " number of fixed line on a certain screen
LoopLine type i, " the number of lines occupied by one steploop item
FirstLine type i, " possbile value 0 or 1, 0 stand for the first line of new " scrolling screen is empty, otherwise is 1
Dataline type i, " number of items you will use in BDC, using DESCRIBE to get
pageno type i, " you need to scroll screen how many times.
line type i, " number of lines appears on the screen.
index(2) type N, " the screen index for certain item
begin type i, " from parameter of loop
end type i. " to parameter of loop
*in code sample, the DataTable-linindex stands for the table index number of this line
form calpage using FixedLine type i (see step 1)
LoopLine type i (see step 1)
FirstLine type i (see step 2)
DataLine type i ( this is the item number you will enter in transaction)
changing pageno type i (return the number of page, depends on run-time visible line in table control/ Step Loop)
changing line type i.(visible lines one the screen)
data: midd type i,
vline type i, "visible lines
if DataLine eq 0.
Message eXXX.
endif.
vline = ( sy-srows - FixedLine ) div LoopLine.
*for table control, you should compare vline with maximum line of
*table control, then take the small one that is min(vline, maximum)
*here only illustrate step loop
if FirstLine eq 0.
pageno = DataLine div vline.
if pageno eq 0.
pageno = pageno + 1.
endif.
elseif FirstLine eq 1.
pageno = ( DataLine - 1 ) div ( vline - 1 ) + 1.
midd = ( DataLine - 1 ) mod ( vline - 1).
if midd = 0 and DataLine gt 1.
pageno = pageno - 1.
endif.
endif.
line = vline.
endform.
Step4 write a subroutine to calculate the line index for each item.
form calindex using Line type i (visible lines on the screen)
FirstLine type i(see step 2)
LineIndex type i(item index)
changing Index type n. (index on the screen)
if FirstLine = 0.
index = LineIndex mod Line.
if index = '00'.
index = Line.
endif.
elseif FirstLine = 1.
index = LineIndex mod ( Line - 1 ).
if ( index between 1 and 0 ) and LineIndex gt 1.
index = index + Line - 1.
endif.
if Line = 2.
index = index + Line - 1.
endif.
endif.
endform.
Step5 write a subroutine to calculate the loop range.
form calrange using Line type i ( visible lines on the screen)
DataLine type i
FirstLine type i
loopindex like sy-index
changing begin type i
end type i.
If FirstLine = 0.
if loopindex = 1.
begin = 1.
if DataLine <= Line.
end = DataLine.
else.
end = Line.
endif.
elseif loopindex gt 1.
begin = Line * ( loopindex - 1 ) + 1.
end = Line * loopindex.
if end gt DataLine.
end = DataLine.
endif.
endif.
elseif FirstLine = 1.
if loopindex = 1.
begin = 1.
if DataLine <= Line.
end = DataLine.
else.
end = Line.
endif.
elseif loop index gt 1.
begin = ( Line - 1 ) * ( loopindex - 1 ) + 2.
end = ( Line - 1 ) * ( loopindex - 1 ) + Line.
if end gt DataLine.
end = DataLine.
endif.
endif.
endif.
endform.
Step6
using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index in steploop/Table Control
form creat_bdc.
field-symbols: , , .
data: name1(14) value 'EKPO-EMATN(XX)',
name2(14) value 'EKPO-MENGE(XX)',
name3(15) value 'RM06E-SELKZ(XX)'.
assign: name1 to ,
name2 to ,
name3 to .
do pageno times.
if sy-index gt 1
*insert scroll page ok_code"
endif.
perform calrange using Line DataLine FirstLine sy-index
changing begin end.
loop at DataTable from begin to end.
perform calindex using Line FirstLine DataTable-LineIndex changing Index.
name1+11(2) = Index.
name2+11(2) = Index.
name3+12(2) = Index.
perform bdcfield using DataTable-matnr.
perform bdcfield using DataTable-menge.
perform bdcfield using DataTable-indicator.
endloop.
enddo.
example 1
BDC table control is an area on the screen in which you can display data in tabular form. You process it using a loop. Table controls are comparable to step loop tables. While a table control consists of a single definition row, step loop blocks may extend over more than one row. Table controls are more flexible than step loops, and are intended to replace them
When you need to handle a scenario like in sales order,it may contain more than one material,if you have more than one material We have to use table control,it will have number of columns and number of rows.
Table controls allow you to enter, display, and modify tabular data easily on the screen
Check this code,
PARAMETERS: file1 LIKE rlgrap-filename.
*Internal Table Declarations
DATA: BEGIN OF itab OCCURS 0,
matnr(18) TYPE c, "MaterialNumber
werks(4) TYPE c, "Plant
vdatu(10) TYPE c, "Valid From Date
bdatu(10) TYPE c, "Valid To Date
lifnr(10) TYPE c, "Vendor Number
ekorg(4) TYPE c, "Purchasing Organization
feskz TYPE c, "Fixed
autet TYPE c, "MRP Indicator
END OF itab.
DATA: bdcdata LIKE TABLE OF bdcdata WITH HEADER LINE.
*VARIABLES Declarations
DATA: wa1 LIKE LINE OF itab. "Workarea for ITAB
DATA: n TYPE i, "Check
count TYPE i.
DATA: cnt(2), "Counter
wa(15). "Workarea to hold concatenatedvalue
DATA v_msg(100).
DATA: flag.
DATA: file TYPE string.
*Initialization event
INITIALIZATION.
*At-selection-screen event
*To provide Input help for file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file1.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = file1.
*START-OF-SELECTION EVENT
START-OF-SELECTION.
MOVE file1 TO file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*To populate BDCDATA and start data transfer
LOOP AT itab .
To validate Plant range
IF itab-werks = '1000' OR itab-werks = '2000'
OR itab-werks = '1008'.
AT NEW werks.
CLEAR: n.
cnt = 1.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EORD-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'EORD-MATNR'
itab-matnr.
PERFORM bdc_field USING 'EORD-WERKS'
itab-werks.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
PERFORM bdc_field USING 'BDC_CURSOR'
wa.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
ENDAT.
IF n = 12.
READ TABLE bdcdata WITH KEY fval = '=BU'.
bdcdata-fval = '=NS'.
MODIFY bdcdata INDEX sy-tabix TRANSPORTING fval.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EORD-VDATU(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
cnt = 2.
n = 2.
ENDIF.
CONCATENATE 'EORD-VDATU(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-vdatu.
CONCATENATE 'EORD-BDATU(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-bdatu.
CONCATENATE 'EORD-LIFNR(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-lifnr.
CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-ekorg.
CONCATENATE 'RM06W-FESKZ(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-feskz.
CONCATENATE 'EORD-AUTET(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-autet.
IF n <> 12.
n = cnt.
ENDIF.
cnt = cnt + 1.
AT END OF werks.
CALL TRANSACTION 'ME01' USING bdcdata
UPDATE 'S'
MODE 'A'.
CLEAR:bdcdata,bdcdata[].
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = 'EN'
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = v_msg.
WRITE:/ v_msg.
CLEAR: bdcdata,bdcdata[],flag.
ENDAT.
ENDIF.
ENDLOOP.
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM.
Insert field values
FORM bdc_field USING fnam fval.
IF NOT fval IS INITIAL.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
CLEAR wa.
ENDFORM.
Sample code 2
THis is example to upload the Bank details of the Vendor which has the TC.
REPORT zprataptable2
NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA : BEGIN OF itab OCCURS 0,
i1 TYPE i,
lifnr LIKE rf02k-lifnr,
bukrs LIKE rf02k-bukrs,
ekorg LIKE rf02k-ekorg,
ktokk LIKE rf02k-ktokk,
anred LIKE lfa1-anred,
name1 LIKE lfa1-name1,
sortl LIKE lfa1-sortl,
land1 LIKE lfa1-land1,
akont LIKE lfb1-akont,
fdgrv LIKE lfb1-fdgrv,
waers LIKE lfm1-waers,
END OF itab.
DATA : BEGIN OF jtab OCCURS 0,
j1 TYPE i,
banks LIKE lfbk-banks,
bankl LIKE lfbk-bankl,
bankn LIKE lfbk-bankn,
END OF jtab.
DATA : cnt(4) TYPE n.
DATA : fdt(20) TYPE c.
DATA : c TYPE i.
INCLUDE bdcrecx1.
START-OF-SELECTION.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\first1.txt'
filetype = 'DAT'
TABLES
data_tab = itab.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\second.txt'
filetype = 'DAT'
TABLES
data_tab = jtab.
LOOP AT itab.
PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-LIFNR'
itab-lifnr.
PERFORM bdc_field USING 'RF02K-BUKRS'
itab-bukrs.
PERFORM bdc_field USING 'RF02K-EKORG'
itab-ekorg.
PERFORM bdc_field USING 'RF02K-KTOKK'
itab-ktokk.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-LAND1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED'
itab-anred.
PERFORM bdc_field USING 'LFA1-NAME1'
itab-name1.
PERFORM bdc_field USING 'LFA1-SORTL'
itab-sortl.
PERFORM bdc_field USING 'LFA1-LAND1'
itab-land1.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
cnt = 0.
LOOP AT jtab WHERE j1 = itab-i1.
cnt = cnt + 1.
CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-banks.
CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankl.
CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankn.
IF cnt = 5.
cnt = 0.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-FDGRV'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-AKONT'
itab-akont.
PERFORM bdc_field USING 'LFB1-FDGRV'
itab-fdgrv.
PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-ZTERM'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB5-MAHNA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFM1-WAERS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFM1-WAERS'
itab-waers.
PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-LIFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
PERFORM bdc_transaction USING 'XK01'.
ENDLOOP.
PERFORM close_group.
Header file:
1 63190 0001 0001 0001 mr bal188 b in 31000 a1 inr
2 63191 0001 0001 0001 mr bal189 b in 31000 a1 inr
TC file:
1 in sb 11000
1 in sb 12000
1 in sb 13000
1 in sb 14000
1 in sb 15000
1 in sb 16000
1 in sb 17000
1 in sb 18000
1 in sb 19000
1 in sb 20000
1 in sb 21000
1 in sb 22000
2 in sb 21000
2 in sb 22000
Regards -
Update step limit name at run-time
I need to run through some test steps in a TestStand sequence multiple times. This wouldn't be a loop on a single step or group of steps but probably a goto a label "for" loop in TestStand. BTW, TestStand 2.0.1 calling code from a LabWindows/CVI DLL via the standard prototype adapter. Each iteration I need to have the test step limit names be updated with a different suffix. So step1 might have results0 and results1 and on the 2nd run results0 would be renamed to results0b. How do I update the limit names, at run-time, from a LabWindows/CVI function? I.e. the first test in the sequence's Main would update the steps below it to update the suffix. I started down the path of using TS_SeqContextGetProperty to get the sequence handle
TS_SeqContextGetProperty( testData->seqContextCVI, &errorInfo, TS_SeqContextSequence, CAVT_OBJHANDLE, &seq_hndl );
then using TS_SequenceGetNumSteps( seq_hndl, &errorInfo, TS_StepGroup_Main, &num_steps ) to determine the number of steps in the Main tab.
Enter a for loop:
TS_PropertyGetValString( testData->seqContextCVI, &errorInfo, buf, TS_PropOption_NoOptions, ( char ** )&rslt_name ) with buf as "Sequence.Main[0].Result.Measurement[0]" errors out with an invalid name message. The idea is to get this value, update it based on the iteration in TestStand ( this is already acquired and working ), and then set the value back. Then, move on to the next step and so forth.
Any suggestions?
Thanks.
-G-
Solved!
Go to Solution.So, I tried the example and it works but only for a single step. I've tried two options: 1. having a single step that programmatically changes all the result names in all the other steps in the sequence. 2. having each step update the result names itself. For thought 1 the loop would run and the changes would occur but when the function was exited I'd get an exception from TestStand. No real information in the details as it looked like a memory corruption error. I then examined the details of what occurred and tried more experiments. If I had the loop have more than 1 iteration this behavior occurred. If I comment out the set function it still occurs. Then, for thought 2, it works like a champ on all the steps until I loop back to the top of the sequence. Then, on the first step ( 2nd time through ) it bombs out.
Attached is the code for the 2nd possible solution.
Does anyone know what the problem is or if there's a way to do this?
-G-
Attachments:
Change Step Name.txt 7 KB -
How to find table name for the fields from Standard Extractor in CRM system
How to find table name of fields from the standard extractor in CRM system ?
e.g. We use LBWE TCode in R/3 system to find table name for the field from Extractor VCSCL(e.g.).
Likewise is there any way to find table name for the fields from Standard extractor like 0CRM_LEAD_I.Hi ,
Please find the link below for understanding BW CRM analysis.
http://help.sap.com/bp_biv135/html/bw.htm
activate the CRM DSs by scenario:
1) Activate the application component hierarchy (tcode RSA9). Changes made to the application component hierarchy in the CRM system can be transferred to the BW using the "Edit Application Component Hierarchy" (SBIW - Postprocessing of DataSources).
SAP Note 434886 must be implemented in CRM 3.0 before the application component hierarchy is activated.
2) Activate the Business Content DataSources (tcode RSA5).
Select/enter the application component and choose Execute (F8).
To compare the shipped and active versions, choose the 'Select Delta' pushbutton. If there is no active version of the DataSource, it is selected automatically.
To activate the shipped version, choose the 'Transfer DataSources' pushbutton.
3) Management of the versions of the BW-Adapter metadata (tcode BWA5). All DataSources are displayed that are managed by the BW Adapter.
As in transaction RSA5 (Service API Metadata Activation), the 'Select Delta' function can be used to select the inactive DataSources or compare shipped and active versions.
You can also go directly to the screen for maintaining DataSources that are managed by the BW Adapter.
The 'Compare Version' function makes a detailed comparison of the shipped and active versions.
All BW-Adapter metadata is considered when versions are compared:
Header information (Table SMOXHEAD)
Mapping information (Table SMOXRELP)
Global selection conditions (Table SMOXGSEL)
Attribute key fields (Table SMOXAFLD)
Hope this helps.
Regards,
csm reddy
Maybe you are looking for
-
Ideas For a Simple Program?
I need some ideas for a simple program for a project in class. Can anyone help me?
-
Could Apple offer me a discount to buy a new iPhone4 to replace the stolen one?
My iPhone was stolen last week, could I have a discount to have a new one??
-
PLEASE PLEASE HELP! My SIM card tray is stuck in my iPhone!
I accidentally put my SIM tray in backwards, yes I know stupid, and now it *****! I got the top part out, but the bottom part is still stuck in the phone!!!! How do I get it out? Will Apple fix it, i'm still under warranty.
-
Service error when installing OO4O
I get an error telling me to shut down the service OracleOra9i_HOMEAgent when trying to install OO4O in XP. I can't see anything relating to this in my processes. Does anyone know how to shut this down? thanks very much... Brian....
-
Install Acrobat Reader without Internet?
Hi, In my Windows XP computer, I want to install the latest version of Acrobat Reader. But the computer does not have an Internet connection. The version on Adobe website seems to be a 1MB download manager and installer, which must have Internet to c