Need to save the data in mutiple tables
Dear Experts,
I need to insert the data ,which is accepted from the user at runtime using table control and also generate automatic number when clicked on the save button the data should be in the database as well.
I am new to module pool, your help is reqd. The user will be awarded ample points if answered correctly.
regards,
Rachel
Hi Rachel,
For automatic number generation you need to create number range object using tcode SNRO and then use the foolowing logic.
*& Form GET_NEXT_NUMBER
text
--> p1 text
<-- p2 text
FORM get_next_number .
DATA: w_quant LIKE inri-quantity, "dummy
w_code LIKE inri-returncode. "returncode
To lock the number range object
CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
EXPORTING
object = 'ZNUM'
EXCEPTIONS
foreign_lock = 1
object_not_found = 2
system_failure = 3
OTHERS = 4.
To raise the exception to the corresponding exception of
'NUMBER_RANGE_ENQUEUE'
IF sy-subrc NE 0.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
To get the next number from the object
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = 'Z2'
object = 'ZNUM'
toyear = '2008'
IMPORTING
number = l_lbc_next
quantity = w_quant
returncode = w_code
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc <> 0
To unlock the number range object
CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
EXPORTING
object = 'ZNUM'
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
ENDFORM. " GET_NEXT_NUMBER
And for table control logic
see the below link.
Table control of Module Pool Program
Regards,
Raju
Similar Messages
-
How can i convert the data from mutiple-table to the other database(MSSQL)?
Dears,
How can i convert the data from mutiple-table to the other database such as MS-SQL?
I have a third party system based on MS-SQL 2000.
Now we want to make a integration between SAP R/3(Oracle) and SQL server.
When my user releases the purchase order in R/3, the application we coded will convert the releated data to the temp database on the SQL server.
But i don't know which tools will help me reach the purpose. BAPI, LSMW, IDoc... ???
Would anybody tell me which way is better and how to do?
Thanks a lot!
Kevin WangHello Kevin,
The question to use which method depend on your detail requirements. If you use BAPI, you need to find which Bapi can provide the data you want. Bapi normally use as a function called by external system. So you need to develop an external program like VB/Java to call this Bapi and move it to SQL. LSMW is use when you want to upload data from an external system to SAP. So it does not serve your requirement. Idoc can be use to export data to an external system. Again like Bapi, you need to find what Idoc can provide the data you want. However, it does not any programming from the external system. If I were you, based on your requirements, I think writing an Abap program that read the data you want and download it to NT/SQL server will be faster and easier. -
Need to join the data, of different tables
I have some data in 3 tables, Table 1 has all the names say, table1 has column Name with data as A,B,C,D,E. Table 2 has columns Name,Logins_T2,Entering_T2. Same way table2 has columns Name,Logins_T3,entering_T3. Now, I want to join these 3 tables, i want
all the names of table1 and the columns logins_T2,entering_T2,logins_T3,entering_T3.
How can I join them, i tried by using left join but it is not giving the correct result, can anyone help me do thisI think this is what you are trying to do. Please try this.CREATE TABLE Test1 (Name varchar(20), Col2 varchar(20))
CREATE TABLE Test2 (logins_T2 varchar(20), entering_T2 varchar(20))
CREATE TABLE Test3 (logins_T3 varchar(20), entering_T3 varchar(20))
INSERT INTO Test1(Name, Col2) VALUES('A', 'test1_A'), ('B', 'test1_B'), ('C', 'test1_C'), ('D', 'test1_D')
INSERT INTO Test2(logins_T2, entering_T2) VALUES('A', 'test2_A'), ('C', 'test2_C')
INSERT INTO Test3(logins_T3, entering_T3) VALUES('B', 'test3_B'), ('C', 'test3_C')
SELECT * FROM Test1 t1
LEFT OUTER JOIN Test2 t2 ON t1.Name = t2.logins_T2
LEFT OUTER JOIN Test3 t3 ON t1.Name = t3.logins_T3
Prakash Machiraju
Please vote if you find this posting was helpful or Mark it as answered.
I am doing this way,
SELECT t1.name,t2.logins_T2,enteringS_T2,t3.Logins_T3,t3.entering_T3 FROM Test1 t1
LEFT OUTER JOIN Test2 t2 ON t1.Name = t2.Name
LEFT OUTER JOIN Test3 t3 ON t1.Name = t3.Name
Logins and enterings are the integers and Table 2 and 3 also has column 'Name'. -
Hi,
I have the following situation. I need to be able to save the data I write in a table (front panel) when desired.
This allows me to modify, add new data, etc in the "Table" when wanted and to SAVE the latest information when wanted.
I need to save all the table data by using ONLY one button.
Thanks for the help!
Kind regards,
Amaloa S.Hi,
Thanks for the feedback. :-)
Your answered helped.
In this case I need to save the Data into an ARRAY.
Now I have the following issue. I will try to explain:
Suppose that I have following:
1. Several GROUPS of Data like this:
ER-1234
ER-3245
ER-4786
ER-9080
2. Each GROUP has the following ELEMENTS:
A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
So it would be like
ER-1234: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
ER-3245: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
ER-4786: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
ER-9080: A, Bi, Pb, Sn, Sn, Cr, Ni, Ca, ...., Al
3. An each ELEMENT has DATA that I need to save, BUT! that I need to be able to get by specifying the group and the element.
A:
2,3 2,4 2, 8, 2,8
2,2 2,3 2, 7, 2,6
2,1 2,6 2, 6, 2,7
2,5 2,4 2, 5, 2,3
How can I save the ELEMENT "A" Data with the label of the GROUP and the ELEMENT so that I can recongnize it when I need to get the DATA again?
Thanks for the help!
Best regards,
Amaloa. -
How to delete the data in a table using function
hi all,
i need to delete the data in a table using four parameters in a function,
the parameters are passed through shell script.
How to write the function
Thanks>
But the only thing is that such function cannot be used in SQL.
>
Perhaps you weren't including the use of autonomous transactions?
CREATE OR REPLACE FUNCTION remove_emp (employee_id NUMBER) RETURN NUMBER AS
PRAGMA AUTONOMOUS_TRANSACTION;
tot_emps NUMBER;
BEGIN
SELECT COUNT(*) INTO TOT_EMPS FROM EMP3;
DELETE FROM emp3
WHERE empno = employee_id;
COMMIT;
tot_emps := tot_emps - 1;
RETURN TOT_EMPS;
END;
SQL> SELECT REMOVE_EMP(7499) FROM DUAL;
REMOVE_EMP(7499)
12
SQL> SELECT REMOVE_EMP(7521) FROM DUAL;
REMOVE_EMP(7521)
11
SQL> SELECT REMOVE_EMP(7566) FROM DUAL;
REMOVE_EMP(7566)
10
SQL> -
How to dynamically display the data from a table base on row selection of another table in ADF
Hi ,
I have a requirement in ADF. I need to change the data of a table based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.
For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.
My method is following
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log
"Definition DepartmentId of type Variable is not found in EmployeesView1."
I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.
Thanks
NileshNote quite sure why you simply wont create a viewlink for the viewobject the tables are based on..
The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.
However, if both tables are on the same page; using your hack about;
On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.
I would bind table two to a RichTable component:
RichTable t2;
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
refreshTable2(pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
private void refreshTable2(Number pallet){
RichTable x=getT2();
CollectionModel cm=(CollectionModel)x.getValue();
JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");
ViewObject vo =dciter.getViewObject();
ViewCriteriaManager vcm=vo.getViewCriteriaManager();
ViewCriteria vc=vcm.getViewCriteria("listById");
vo.applyViewCriteria(vc);
vo.setNamedWhereClauseParam("DepartmentId",pallet);
vo.executeQuery();
AdfFacesContext.getCurrentInstance().addPartialTarget(getT2()); -
I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?
You only need the ODBC driver on each computer. If you are distributing the SQL Toolkit app as an executable and do not install the whole toolkit on each computer, you'll need the SQL Toolkit support files. This is about a dozen files. You can get the list at http://digital.ni.com/public.nsf/websearch/b814be005f9da9258625658700550c75?OpenDocument.
-
I need to print save the date magnets that are 8.5x5.5 but I can’t seem to align the printer / paper to print correctly!! HELP!
Please read this post then provide some details. What printer model? What operating system? What program are you using to print?
How thick are the magnet sheets? I would expect most printers would have trouble feeding this material.
Bob Headrick, HP Expert
I am not an employee of HP, I am a volunteer posting here on my own time.
If your problem is solved please click the "Accept as Solution" button ------------V
If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V -
How to modify and save the data in the table control
how to modify and save the data in the table control
hi priya,
kindly go thru the code below.
PROCESS BEFORE OUTPUT.
MODULE status_9010.
LOOP WITH CONTROL tab_control.
MODULE move_data_to_table.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE user_cancel AT EXIT-COMMAND.
LOOP WITH CONTROL tab_control.
MODULE move_data_from_table.
ENDLOOP.
MODULE move_data_to_table OUTPUT.
This is to move the data from the internal table to *the table control
*zmpets_mode-modecode, zmpets_range-rangeid, *zmpets_servfacto-factor are field names of the table *control columns.
READ TABLE int_factor INDEX tab_control-current_line.
IF sy-subrc = 0.
zmpets_mode-modecode = int_factor-modecode.
zmpets_range-rangeid = int_factor-rangeid.
zmpets_servfacto-factor = int_factor-factor.
ENDIF.
ENDMODULE. " move_data_to_table OUTPUT
**********************************************8888
MODULE move_data_from_table INPUT.
*To move the data from the table control to internal *table 'INT_FACTOR'.
int_factor-chk = line.
int_factor-modecode = zmpets_mode-modecode.
int_factor-rangeid = zmpets_range-rangeid.
int_factor-factor = zmpets_servfacto-factor.
MODIFY int_factor INDEX tab_control-current_line.
IF sy-subrc NE 0.
APPEND int_factor.
CLEAR int_factor.
ENDIF.
ENDMODULE. " move_data_from_table INPUT
if this helps , kindly award points.
for any clarification just mail me.
regards,
Anversha.S
[email protected] -
How do i save the data in table ??? URGENT
how do i save the data in table ??? URGENT
Hope can attach some example VI for reference =]
Attachments:
data in table.JPG 271 KB
block diagram.JPG 459 KBYou didn't mention which version of LabVIEW you are using. I adapted your method in this example. Not sure this is an efficient method. I just pass the 2d array through in the false case.
Using LabVIEW 2010SP1 and TestStand 4.5
Attachments:
WriteTable.PNG 35 KB -
Need to extract the data from the CRM table : SCAPPTSEG
Hi BW Experts,
I want to extract the Data from CRM Table "SCAPPTSEG" to BW. The dates are stored in UTC Format.So for getting the date in CET format, we have used the Function Module "IB_CONVERT_FROM_TIMESTAMP".
I want to create a datasource for extracting the data from "SCAPPTSEG" table and i need to use the function module for getting the date in CET Format.
Can i achieve this action through Generic Extraction.
please provide me the steps to achieve this.
Thanks,
Shahina.Anot answered
-
Do I need to save anything data (apps, photos, video) before I proceed the update? I am on iOS5.1 using ipad2
Be more precise, updating from iOS 5.1 ---> iOS 6
-
How can i save the data from the Oracle database to my local directory
How can i save the data from the Oracle database to my local directory instead Of saving the data file to the Directory created on the Oracle Server ?
I require to design the Procedure which will pull the data from various tables and needs to store the data in the Client's local directory.Since SQL*PLUS runs on the client, you can use SQL*PLUS to spool data to your local drive.
You could also use the database to write a a specified drive where all users have access to (mapped network drive, e.g.). I wouldn't recommend doing it that way, but it is sometimes useful when the files are created in some nightly batch run. -
How to save the data present in TEXT BOX?
Hi friends i am able to create a text editor in one of my screen but i want to know how to save the data when the text is entered in that text box and retrive when they open the screen?
Hi ,
Please check the format below since it is based on a working code
first you need to create a text in s010 function module...
there should be some key based on which you plan to save the text..imagine it is Purchase order then..PO+item numner is always unique.eg:0090010(900PO/item10).so in the code you can append these two and they will be unique..so you can always retrieve them,overwrite,save them anytime you need
**************data declarations
TYPES: BEGIN OF TY_EDITOR,
EDIT(254) TYPE C,
END OF TY_EDITOR.
data: int_line type table of tline with header line.
data: gw_thead like thead.
data: int_table type standard table of ty_editor.
****************fill header..from SO10 t-code..when you save you need the unique key..youfill it here and pass it in save_text function module
GW_THEAD-TDNAME = loc_nam. " unique key for the text -> our unique key to identify the text
GW_THEAD-TDID = 'ST'. " Text ID from SO10
GW_THEAD-TDSPRAS = SY-LANGU. "current language
GW_THEAD-TDOBJECT = 'ZXXX'. "name of the text object created in SO10
*To Read from Container and get data to int_table
CALL METHOD EDITOR ->GET_TEXT_AS_R3TABLE
IMPORTING
TABLE = int_table
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop data from int_table and save to int_line-tdline appending it.
*save the text
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
HEADER = GW_THEAD
TABLES
LINES = InT_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
OBJECT = 4
OTHERS = 5.
IF SY-SUBRC 0.
ENDIF.
*To pass to Container
CALL METHOD EDITOR ->SET_TEXT
hope that the above sample with helps you solve the problem
Please check and revert,
Reward if helpful
Regards
Byju -
Dynamically built query on execution How to save the data in Object Type
Hi,
In pl/sql I am building and executing a query dynamically. How can I stored the output of the query in object type. I have defined the following object type and need to store the
output of the query in it. Here is the Object Type I have
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPE AS OBJECT(
pkid NUMBER,
pkname VARCHAR2(100);
pkcity VARCHAR2(100);
pkcounty VARCHAR2(100)
CREATE OR REPLACE TYPE DEMO.FIRST_RECORDTYPETAB AS TABLE OF FIRST_RECORDTYPE;Here is the query generated at runtime and is inside a LOOP
--I initialize my Object Type*
data := new FIRST_RECORDTYPETAB();
FOR some_cursor IN c_get_ids (username)
LOOP
x_context_count := x_context_count + 1;
-- here I build the query dynamically and the same query generated is
sql_query := 'SELECT pkid as pid ,pkname as pname,pkcity as pcity, pkcounty as pcounty FROM cities WHERE passed = <this value changes on every iteration of the cursor>'
-- and now I need to execute the above query but need to store the output
EXECUTE IMMEDIATE sql_query
INTO *<I need to save the out put in the Type I defined>*
END LOOP;
How can I save the output of the dynamically built query in the Object Type. As I am looping so the type can have several records.
Any help is appreciated.
Thankshai ,
solution for Dynamically built query on execution How to save the data in Object Type.
Step 1:(Object creation)
SQL> ED
Wrote file afiedt.buf
1 Create Or Replace Type contract_details As Object(
2 contract_number Varchar2(15),
3 contrcat_branch Varchar2(15)
4* );
SQL> /
Type created.
Step 2:(table creation with object)
SQL> Create Table contract_dtls(Id Number,contract contract_details)
2 /
Table created.
Step 3:(execution Of procedure to insert the dynamic ouput into object types):
Declare
LV_V_SQL_QUERY Varchar2(4000);
LV_N_CURSOR Integer;
LV_N_EXECUTE_CURSOR Integer;
LV_V_CONTRACT_BR Varchar2(15) := 'TNW'; -- change the branch name by making this as input parameter for a procedure or function
OV_V_CONTRACT_NUMBER Varchar2(15);
LV_V_CONTRACT_BRANCH Varchar2(15);
Begin
LV_V_SQL_QUERY := 'SELECT CONTRACT_NUMBER,CONTRACT_BRANCH FROM CC_CONTRACT_MASTER WHERE CONTRACT_BRANCH = '''||LV_V_CONTRACT_BR||'''';
LV_N_CURSOR := Dbms_Sql.open_Cursor;
Dbms_Sql.parse(LV_N_CURSOR,LV_V_SQL_QUERY,2);
Dbms_Sql.define_Column(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER,15);
Dbms_Sql.define_Column(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH,15);
LV_N_EXECUTE_CURSOR := Dbms_Sql.Execute(LV_N_CURSOR);
Loop
Exit When Dbms_Sql.fetch_Rows (LV_N_CURSOR)= 0;
Dbms_Sql.column_Value(LV_N_CURSOR,1,OV_V_CONTRACT_NUMBER);
Dbms_Sql.column_Value(LV_N_CURSOR,2,LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_BRANCH--'||LV_V_CONTRACT_BRANCH);
Dbms_Output.put_Line('CONTRACT_NUMBER--'||OV_V_CONTRACT_NUMBER);
INSERT INTO contract_dtls VALUES(1,CONTRACT_DETAILS(OV_V_CONTRACT_NUMBER,LV_V_CONTRACT_BRANCH));
End Loop;
Dbms_Sql.close_Cursor (LV_N_CURSOR);
COMMIT;
Exception
When Others Then
Dbms_Output.put_Line('SQLERRM--'||Sqlerrm);
Dbms_Output.put_Line('SQLERRM--'||Sqlcode);
End;
step 4:check the values are inseted in the object included table
SELECT * FROM contract_dtls;
Regards
C.karukkuvel
Maybe you are looking for
-
How can I restore my iPhone 4S with a broken lock button and with a passcode
I have tried restoring the phone by trying to let the battery drain and by plugging it in and holding the home button but that did not work. I also tried using RecBoot but kept getting an error message. The iPhone has a passcode and a broken sleep/wa
-
help!!! My new phone is asking for a password but I never set one and am locked out - what can I do?!?!
-
Uninstall LiveCycle Designer 9 via script
Hello, I am having issues with LiveCycle Designer 9 that got installed inadvertently with a mass roll out of Acrobat 10.1.8 via SCCM. I am in a very large environment (80,000 + systems per network covering 3 networks) and during our deployment of 10.
-
Upgrading iM from 8.1.6 to 8.1.7
I migrated one of our 8.1.6 databases to 8.1.7. Based on the migration documentation, InterMedia Text needs to be manually upgraded. Following Doc ID 120611.1, I ran s0801070 as SYS, then as CTXSYS, I ran the following: u081070.sql dr0typec.pkh dr0pk
-
Read out loud accessible PDFs - is it possible to switch on this feature so that PDFs automatically start to read upon opening?