How to store output of SQ01 into internal table.
Hello Experts
How to store output of SQ01 into internal table.
Thanks,
Umesh
You can't store the sq01 output into internal table.
Once you create the query it will generate the abap program, in that program you can see the contents.
Regards
Sasi
Similar Messages
-
How to transfer data of RFC into Internal Table inside a WD4A program?
Hi Experts,
I have created WD4A program. This program calls RFC. The output of RFC has to populate a UI table. THe different cells of the table should have different color based on data.
I have gone through following link:
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/707fb792-c181-2d10-61bd-ce15d58b5cf1
The above link fetches data from directly from table. Then it passes the data into internal table.
If I am using RFC, then how I can insert data of RFC into a internal table in WD4A program (se80 In drop down Web Dynpro Comp / Intf)
My motto is to have table ouput whose different cells should have different color based on data.
Please help.
Regards,
Gary
Edited by: Jason Lax on Dec 28, 2011 2:52 PM (Fixed broken link)Hi Experts,
I have resolved the issue. I have created WD4A program. This WD4A program calls the RFC.
The RFC has a structure as export parameters called 'RESULT_FINAL'. I have altered the associated type of this table export parameter. I added Component 'Color' of component type 'WDUI_TABLE_CELL_DESIGN'.
In the RFC I have added some code. The code is as below:
loop at it_t1.
select pernr from pa0000 into table it_t2 where pernr = it_t1-pernr and stat2 ='3'
and begda <= sy-datum AND endda >= sy-datum.
if sy-subrc = 0.
result_final-org_unit = result_objec-objid.
result_final-pernr = it_t1-pernr.
result_final-name = it_t1-name.
result_final-color = '02'. append result_final.
endif.
endloop.
The line result_final-color = '02'.
code returns Color.
In the WD4A program, I have changed the Cell Design property of selected table coloumn to Color.
This resolved the issue.
Thanks every one for the reply.
I have added above information for other SDN users.
I am closing this thread,
Regards,
Gary -
How to save value in struture into internal table?
good day to everyone,
i have a prb with my coding below. i am trying to save the value tvbdpr-uecha into wa_zmas-uecha by using modify as shown below.
however, the value uecha is not successfully being transported/saved into it_zmas.
could anyone guide me?
tvbdpr - is a structure table
it_zmas - is an internal table
LOOP AT tvbdpr WHERE posnr = wa_zmas-posnr AND matnr = wa_zmas-matnr.
wa_zmas-uecha = tvbdpr-uecha.
MODIFY TABLE it_zmas FROM wa_zmas TRANSPORTING uecha.
thank you
regards,
swHi,
If the internal table is already having contents and u need to modify it for the field uecha, you can try the following
LOOP AT tvbdpr WHERE posnr = wa_zmas-posnr AND matnr = wa_zmas-matnr.
wa_zmas-uecha = tvbdpr-uecha.
READ TABLE it_zmas with KEY posnr = wa_zmas-posnr matnr = wa_zmas-matnr.
if sy-subrc = 0.
it_zmas-uecha = wa_zmas-uecha.
MODIFY it_zmas index sy-index.
clear it_zmas-uecha.
endif.
ENDLOOP.
Else if the internal table is empty and you are populating the field uecha, use append
LOOP AT tvbdpr WHERE posnr = wa_zmas-posnr AND matnr = wa_zmas-matnr.
wa_zmas-uecha = tvbdpr-uecha.
it_zmas-uecha = wa_zmas-uecha.
append it_zmas.
clear it_zmas.
ENDLOOP.
Regards,
Vik -
How to decompose a string with ';' into Internal table
Hello all,
I need your help for find a Function module or Abap code.
I have a file with the separator is the ';'
Example of the contains of my file :
521010;16;46048,00;;*Soucet*Odmena za
524012;41;103807,00;;Zdrav.p.organizace
524012;42;;18332,00;Zdrav.p.organizace
I want a module function which can separate all the String separate by a ';' into a internal table :
for example my internal table have 5 column :
Num......|.....CC.....|............Credit....|...........Debit........|.....Label
521010....|.....16.....|......46048,00.....|...........................|.....Soucet**Odmena za
524012....|.....41.....|......103807,00...|...........................|.....Zdrav.p.organizace
524012....|.....42.....|..........................|........18332,00....|.....Zdrav.p.organizace
For read the date of my file is not a problem with ABAP Code :
DO.
CLEAR : ws_facm.
break epetrini.
READ DATASET myFile INTO test.
IF sy-subrc EQ 0.
IF ws_facm-codenreg = 'D'.
APPEND ws_facm TO wt_facm.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
Thank you for your helps.
Best regards Emilien
Edited by: Emilien P. on Mar 31, 2010 4:30 PM
Edited by: Emilien P. on Mar 31, 2010 4:34 PM
Edited by: Emilien P. on Mar 31, 2010 4:35 PM
Edited by: Emilien P. on Mar 31, 2010 4:36 PMHi,
Try whith this:
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
itab TYPE TABLE OF string,
text TYPE string.
text = `What a drag it is getting old`.
SPLIT text AT space INTO: str1 str2 str3,
TABLE itab.
Let me know if it works.
Regards,
Moh. -
How to upload the flat file records into internal table by position?
Hi
I have a flat file which has 7 records in each row and they are NOT provided with CSV or Tab demilited...
They are continous text without spaces....
but i know the fixed length of each field Eg : 1st field 7 char and seconc field 3 char and so on...
How can i upload this file into internal table by reading positions of each field...I know we can use GUI_UPLOAD and Read dataset and Open dataset...
But please let me know to read the file with the fixed postions and load into internal table...
Thanks in advance
MMHi
As per my knowledge i dont think thr is some function module or so to read with a fixed positions.
You can use the below method if you think this is the best way.
Suppose your file has
types : begin of ty_itab,
field1 type char7,
field2 type char3,
field3 type chat3,
field4 type char3,
end of ty_itab.
types : begin of ty_upload,
str type string,
end of ty_upload.
data : it_itab type standatd table of ty_itab,
it_upload type standard table ot ty_upload,
wa_itab type ty_itab,
wa_upload type ty_upload.
use gui_upload.get the data in it_upload.
here you know that u have first 16 charcters makes a first row n then next 16 charcters next row
Loop at it_upload into wa_upload.
v_len = strlen ( wa_upload ).
v_len = v_len / 16.
You get number of rows per record ,if it is decimal value make it final value if 3.9 make to 4.
do v_len times.
wa_itab = wa_upload.
By this only first 16 characters are moved and respective fields will get a value.or else u can use offset
wa_upload+0(16).
append wa_itab to it_itab.
Now shift 16 characters using shift command in wa_upload.
enddo.
endloop.
Hope this syntax help you to resolve your issue.May be something i have missed .Right now i don't have sap system to send you the full correct syntax code.
Cheers
Joginder -
How to store array of data into a single row of table ,using any of Stmts
HI Friends,
Based on my requirements ,i have retrived a set of data from a XXX.jsp page using a request.getParameter() and stored into single dimenssional array . Now i am paassing that array to JAVA class to store a into some table .
In JSP page users can add text boxes dynamically based on his intrest then those attributes will store in table .it means table attributes are not conatant , it table attributes may change at any time when user adds any textboxs or any fields on JSP page ....thats my module ..
Now i wanted to store all array of data into Table in a single row .......thats is my requirements .
How can we use prepareStatement and Statement to store array of results intoo table row ...on each iteration i wanted to store array of results into table atributes ..It means entire array of results should to into table row at time .....coule any one write sytax ,how we do this...
could any one suggest me stps that i can impliment ......?....please reply ASAPWell ..you code can be works for constant number of attributes in table .oopss here my requirement is table attributes not fixed ,we cant put constant number of place holder(? ) in a statement ,because those are not fixed ,
Let me explain here :
i am doing in that way only. As i mentioned you Table attributes are not constant .It may very if users add any fields dynamically on JSP page .If users have option to add any text box on Jsp page ,then that attribute will store in table as a attribute .
Now i amable fetching the all dyamic form data and stored in a Result Array below ...in this iteration all form result data are from jsp page as suggestion form ,it should stored in table in single row on corrsponding attribtes ......next time when users fills FROM ,then those data i am fetching and storing in a Result Array as below and need to store in corrsponding table attributes in a single row ....
for(int i=0;i<result.length;i++)
System.out.println(result);
pst3=connection.prepareStatement("insert into *emprecord* values(?)");
if(!result[i].equals(""))
System.out.println(result[i]);
pst3.setString(1,result[i]);
pst3.executeUpdate();
Thnks in advance ....let me know the the way we can store dynamic form data into dyanamic table ... -
How to convert xml file into internal table in ABAP Mapping.
Hi All,
I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
<BookingCode>2KY34R</BookingCode>
- <Passenger>
<Name>SARVESH</Name>
<Address>THANE</Address>
</Passenger>
- <Passenger>
<Name>RAJESH</Name>
<Address>POWAI</Address>
</Passenger>
- <Passenger>
<Name>CARRON</Name>
<Address>JUHU</Address>
</Passenger>
- <Flight>
<Date>03/03/07</Date>
<AirlineID>UA</AirlineID>
<FlightNumber>125</FlightNumber>
<From>LAS</From>
<To>SFO</To>
</Flight>
</ns0:MTO_ABAP_MAPPING>
AT the receiver side I wnat to concatenate the NAME & ADDRESS.
I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
but couldnt succeed to convert the xml file into internal table perfectly.
Can anybody help on this.
Thanks in advance!!
SarveshHi Sarvesh,
The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
Just in case you have not seen this
regards
Vijaya -
How to get data of tabulated text file into internal table
hi all,
i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding how to convert excel file into internal table but i didnt get posts regarding text file.
thanks
SAchintry:
DATA: BEGIN OF tabulator,
x(1) TYPE x VALUE '09',
END OF tabulator.
READ DATASET file INTO wa.
split wa at tabulator into table itab.
A. -
How to join THREE different tables into internal table using one select statement .
How to join THREE different tables into internal table using one select statement .
Hi experts,
I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
Scenario:
Database tables:
SPFLI
SFLIGHT
SBOOK.
Table Fields:
SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
SEATSOCC_C SEATSMAX_F SEATSOCC_F
SBOOK - CARRID CONNID CLASS
MY INTERNAL TABLE IS IT_XX.
Your help much appreciated.
Thanks in advance.
Pawan.Hi Pawan,
please check below codes. hope it can help you.
TYPES: BEGIN OF ty_xx,
carrid TYPE spfli-carrid ,
connid TYPE spfli-connid ,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom ,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto ,
fldate TYPE sflight-fldate ,
seatsmax TYPE sflight-seatsmax ,
seatsocc TYPE sflight-seatsocc ,
seatsmax_b TYPE sflight-seatsmax_b,
seatsocc_b TYPE sflight-seatsocc_b,
seatsmax_f TYPE sflight-seatsmax_f,
seatsocc_f TYPE sflight-seatsocc_f,
class TYPE sbook-class,
END OF ty_xx,
t_xx TYPE STANDARD TABLE OF ty_xx.
DATA: it_xx TYPE t_xx.
SELECT spfli~carrid
spfli~connid
spfli~countryfr
spfli~cityfrom
spfli~countryto
spfli~cityto
sflight~fldate
sflight~seatsmax
sflight~seatsocc
sflight~seatsmax_b
sflight~seatsocc_b
sflight~seatsmax_f
sflight~seatsocc_f
sbook~class
INTO TABLE it_xx
FROM spfli INNER JOIN sflight
ON spfli~carrid = sflight~carrid
AND spfli~connid = sflight~connid
INNER JOIN sbook
ON spfli~carrid = sbook~carrid
AND spfli~connid = sbook~connid.
Thanks,
Yawa -
How to transfer excel files(on ftp server) into internal table?
hello,everyone
pls tell me how to transfer excel files those on a ftp server into internal table?
ps.i know the function 'ftp_server_to_r3',it can help to transfer flat file.Hi,
I believe you want to get the data from the FTP Server to R3.
I am also sending the code. Have a look and it would help you.
First get the Password and user name and the FTP Server Path where file is stored and FTP Server Host name
FUNCTION zfi_ftp_get.
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_FILENAME) TYPE C
*" TABLES
*" T_BLOB STRUCTURE ZFI_TLM_LENGTH OPTIONAL " is a table type with a field called line of length 992
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
DATA : i_password(30) TYPE c,
i_user(30) TYPE c,
i_host(30) TYPE c,
i_rfc_destination TYPE rfcdes-rfcdest,
i_length TYPE i,
i_folder_path(100) TYPE c.
DATA: lv_blob_length TYPE i.
DATA: lv_length TYPE i, "Password length
lv_key TYPE i VALUE 26101957,
lv_password(30) TYPE c,
lv_ftp_handle TYPE i,
lv_cmd(80) TYPE c.
DATA: BEGIN OF result OCCURS 0,
line(100) TYPE c,
END OF result.
TYPES: BEGIN OF ty_dummy,
line(392) TYPE c,
END OF ty_dummy.
DATA: lt_dummy TYPE TABLE OF ty_dummy,
ls_dummy LIKE LINE OF lt_dummy.
i_password = 'vnhdh'.
i_user = 'sdkgd'.
i_host = 'sbnksbg'.
i_rfc_destination = 'SAPFTP'.
i_length = '992'.
i_folder_path = '/hioj/hohjk/hh'.
lv_length = STRLEN( i_password ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = i_password
sourcelen = lv_length
key = lv_key
IMPORTING
destination = lv_password.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = i_user
password = lv_password
host = i_host
rfc_destination = i_rfc_destination
IMPORTING
handle = lv_ftp_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc = 1.
return-type = 'E' .
return-message = 'FTP Connection not Successful'.
APPEND return.
ELSEIF sy-subrc = 2.
return-type = 'E' .
return-message = 'FTP Connection not Successful'.
APPEND return.
ELSEIF sy-subrc EQ 0.
return-type = 'S' .
return-message = 'FTP Connection Successful'.
APPEND return.
CONCATENATE 'cd' i_folder_path INTO lv_cmd SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = lv_ftp_handle
command = lv_cmd
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc = 1.
return-type = 'E' .
return-message = 'Command Error Occured during open of FTP Folder'.
APPEND return.
ELSEIF sy-subrc = 2.
return-type = 'E' .
return-message = 'TCIP Error Occured during open of FTP Folder'.
APPEND return.
ELSE.
REFRESH t_blob.
lv_blob_length = 992.
TRANSLATE i_filename TO LOWER CASE.
CALL FUNCTION 'FTP_SERVER_TO_R3'
EXPORTING
handle = lv_ftp_handle
fname = i_filename
IMPORTING
blob_length = lv_blob_length
TABLES
blob = lt_dummy.
t_blob[] = lt_dummy[].
ENDIF.
ENDIF.
ENDFUNCTION.
Regards
Sajid
Edited by: shaik sajid on Nov 16, 2010 7:25 AM -
How to store JcomboBox n textfield into textfile? Urgent!!!
How to store JcomboBox n textfield into textfile?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.text.DecimalFormat;
import java.io.*;
public class RecordMenu extends JPanel implements ActionListener {
private JComboBox monthSelection;
private JButton buttonOk;
double amtToTrack;
private JTextField amtField;
private static final String[] Months =
new String[] {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
public RecordMenu() {
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridLayout(4,2));
mainPanel.setBorder(new TitledBorder("Record Expenses"));
JLabel monthLabel = new JLabel("Select month");
monthSelection = new JComboBox(Months);
monthSelection.addActionListener(this);
JLabel label2 = new JLabel("Amount to track:");
JTextField amtField = new JTextField(5);
amtField.addActionListener(this);
JLabel nothing1 = new JLabel("nothing");
nothing1.setVisible(false);
JLabel nothing2 = new JLabel("nothing");
nothing2.setVisible(false);
JLabel nothing3 = new JLabel("nothing");
nothing3.setVisible(false);
JLabel nothing4 = new JLabel("nothing");
nothing4.setVisible(false);
JLabel nothing5 = new JLabel("nothing");
nothing5.setVisible(false);
JLabel nothing6 = new JLabel("nothing");
nothing6.setVisible(false);
JLabel nothing7 = new JLabel("nothing");
nothing7.setVisible(false);
JLabel nothing8 = new JLabel("nothing");
nothing8.setVisible(false);
mainPanel.add(monthLabel);
mainPanel.add(monthSelection);
mainPanel.add(nothing1);
mainPanel.add(label2);
mainPanel.add(amtField);
mainPanel.add(nothing2);
mainPanel.add(nothing3);
mainPanel.add(nothing4);
mainPanel.add(nothing5);
mainPanel.add(nothing6);
mainPanel.add(nothing7);
JButton buttonOk = new JButton("OK");
buttonOk.addActionListener(this);
mainPanel.add(buttonOk);
add(mainPanel);
setSize(400,300);
setVisible(true);
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonOk) {
double amtToTrack = 0.0;
try {
if (!amtField.getText().equals(""))
amtToTrack = Double.parseDouble(amtField.getText());
catch (NumberFormatException numberFormatException) {
JOptionPane.showMessageDialog(this, "You must enter numbers","Invalid Number Format", JOptionPane.ERROR_MESSAGE);
try{
BufferedWriter out = new BufferedWriter(new FileWriter("mySaved.txt",true));
out.write("For Month "+Months);
out.newLine();
if (!amtField.getText().equals("")) {
amtToTrack = Double.parseDouble(amtField.getText());
out.write("Amount to track = "+amtToTrack);
out.newLine();
out.close();
JOptionPane.showMessageDialog(this, "Saved!");
catch(IOException ex) {
ex.printStackTrace(System.err);
public static void main(String[] args) {
JPanel p = new RecordMenu();
JFrame f = new JFrame();
Container c = f.getContentPane();
c.add(p);
f.pack();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
}i had save e month at mySavedTotal
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.text.DecimalFormat;
import java.io.*;
public class RecordMenu extends JPanel implements ActionListener {
private JComboBox monthSelection;
private JButton buttonOk;
double amtToTrack;
private JTextField amtField;
private static final String[] Months =
new String[] {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
public RecordMenu() {
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridLayout(4,2));
mainPanel.setBorder(new TitledBorder("Record Expenses"));
JLabel monthLabel = new JLabel("Select month");
monthSelection = new JComboBox(Months);
monthSelection.addActionListener(this);
JLabel label2 = new JLabel("Amount to track:");
amtField = new JTextField(5);
amtField.addActionListener(this);
JLabel nothing1 = new JLabel("nothing");
nothing1.setVisible(false);
JLabel nothing2 = new JLabel("nothing");
nothing2.setVisible(false);
JLabel nothing3 = new JLabel("nothing");
nothing3.setVisible(false);
JLabel nothing4 = new JLabel("nothing");
nothing4.setVisible(false);
JLabel nothing5 = new JLabel("nothing");
nothing5.setVisible(false);
JLabel nothing6 = new JLabel("nothing");
nothing6.setVisible(false);
JLabel nothing7 = new JLabel("nothing");
nothing7.setVisible(false);
JLabel nothing8 = new JLabel("nothing");
nothing8.setVisible(false);
mainPanel.add(monthLabel);
mainPanel.add(monthSelection);
mainPanel.add(nothing1);
mainPanel.add(label2);
mainPanel.add(amtField);
mainPanel.add(nothing2);
mainPanel.add(nothing3);
mainPanel.add(nothing4);
mainPanel.add(nothing5);
mainPanel.add(nothing6);
mainPanel.add(nothing7);
buttonOk = new JButton("OK");
buttonOk.addActionListener(this);
mainPanel.add(buttonOk);
add(mainPanel);
setSize(400,300);
setVisible(true);
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonOk) {
double amtToTrack = 0.0;
try {
if (!amtField.getText().equals(""))
amtToTrack = Double.parseDouble(amtField.getText());
catch (NumberFormatException numberFormatException) {
JOptionPane.showMessageDialog(this, "You must enter numbers","Invalid Number Format", JOptionPane.ERROR_MESSAGE);
try{
BufferedWriter out = new BufferedWriter(new FileWriter("mySavedTotal.txt",true));
out.write("For Month "+monthSelection.getSelectedItem());
out.newLine();
if (!amtField.getText().equals("")) {
amtToTrack = Double.parseDouble(amtField.getText());
out.write("Amount to track = "+amtToTrack);
out.newLine();
out.close();
JOptionPane.showMessageDialog(this, "Saved!");
JPanel p = new CheckBox();
JFrame f = new JFrame();
Container c = f.getContentPane();
c.add(p);
f.pack();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
catch(IOException ex) {
ex.printStackTrace(System.err);
public static void main(String[] args) {
JPanel p = new RecordMenu();
JFrame f = new JFrame();
Container c = f.getContentPane();
c.add(p);
f.pack();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
}then i save data from other file in mySavedTotal again
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.text.DecimalFormat;
import java.io.*;
public class CheckBox extends JPanel implements ItemListener, ActionListener {
private JPanel checkPanel, buttonPanel;
private JCheckBox transport, bills, food, gifts, leisure, others;
private JTextField transportField, billsField, foodField, giftsField,leisureField,
othersField, totalField;
double transportAmt, billsAmt, foodAmt, giftsAmt, leisureAmt, othersAmt, totalAmt;
private JButton buttonTotal, saveButton, dontSaveButton;
private JLabel showTotal;
public CheckBox() {
//create a panel for diaplaying the checkboxs and buttons
checkPanel = new JPanel();
checkPanel.setLayout(new GridLayout(7,3));
//Create the check boxes.
transport = new JCheckBox("Transport");
transport.setSelected(false);
transport.setBounds(10,30,80,30);
transportField = new JTextField();
transportField.setEditable(false);
transportField.setBounds(100,35,45,20);
bills = new JCheckBox("Bills");
bills.setSelected(false);
bills.setBounds(10,60,80,30);
billsField = new JTextField(5);
billsField.setEditable(false);
billsField.setBounds(100,65,45,20);
food = new JCheckBox("Food");
food.setSelected(false);
food.setBounds(10,90,80,30);
foodField = new JTextField(5);
foodField.setEditable(false);
foodField.setBounds(100,95,45,20);
gifts = new JCheckBox("Gifts");
gifts.setSelected(false);
gifts.setBounds(200,30,80,30);
giftsField = new JTextField(5);
giftsField.setEditable(false);
giftsField.setBounds(300,35,45,20);
leisure = new JCheckBox("Leisure");
leisure.setSelected(false);
leisure.setBounds(200,60,80,30);
leisureField = new JTextField(5);
leisureField.setEditable(false);
leisureField.setBounds(300,65,45,20);
others = new JCheckBox("Others");
others.setSelected(false);
others.setBounds(200,90,80,30);
othersField = new JTextField(5);
othersField.setEditable(false);
othersField.setBounds(300,95,45,20);
JLabel nothing1 = new JLabel("nothing");
nothing1.setVisible(false);
JLabel nothing2 = new JLabel("nothing");
nothing2.setVisible(false);
JLabel nothing3 = new JLabel("nothing");
nothing3.setVisible(false);
JLabel nothing4 = new JLabel("nothing");
nothing4.setVisible(false);
JLabel nothing5 = new JLabel("nothing");
nothing5.setVisible(false);
JLabel nothing6 = new JLabel("nothing");
nothing6.setVisible(false);
JLabel nothing7 = new JLabel("nothing");
nothing7.setVisible(false);
JLabel nothing8 = new JLabel("nothing");
nothing8.setVisible(false);
JLabel nothing9 = new JLabel("nothing");
nothing9.setVisible(false);
JLabel nothing10 = new JLabel("nothing");
nothing10.setVisible(false);
JLabel nothing11 = new JLabel("nothing");
nothing11.setVisible(false);
//Register a listener for the check boxes.
transport.addItemListener(this);
bills.addItemListener(this);
food.addItemListener(this);
gifts.addItemListener(this);
leisure.addItemListener(this);
others.addItemListener(this);
transportField.addActionListener(this);
billsField.addActionListener(this);
foodField.addActionListener(this);
giftsField.addActionListener(this);
leisureField.addActionListener(this);
othersField.addActionListener(this);
checkPanel.add(transport);
checkPanel.add(transportField);
checkPanel.add(bills);
checkPanel.add(billsField);
checkPanel.add(food);
checkPanel.add(foodField);
checkPanel.add(gifts);
checkPanel.add(giftsField);
checkPanel.add(leisure);
checkPanel.add(leisureField);
checkPanel.add(others);
checkPanel.add(othersField);
checkPanel.setBounds(1,1,390,180);
checkPanel.setBorder(new TitledBorder("Check the amount you want to track"));
buttonTotal = new JButton("Calculate Total");
buttonTotal.setBounds(150,140,130,30);
buttonTotal.addActionListener(this);
showTotal = new JLabel(" = __");
showTotal.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
showTotal.setBounds(290,140,100,30);
checkPanel.add(nothing1);
checkPanel.add(nothing2);
checkPanel.add(nothing3);
checkPanel.add(nothing4);
checkPanel.add(nothing5);
checkPanel.add(nothing6);
checkPanel.add(buttonTotal);
checkPanel.add(showTotal);
checkPanel.add(nothing7);
checkPanel.add(nothing8);
checkPanel.add(nothing9);
checkPanel.add(nothing10);
checkPanel.add(nothing11);
saveButton = new JButton("Save");
saveButton.setBounds(90,190,100,30);
saveButton.addActionListener(this);
dontSaveButton = new JButton("Don't Save");
dontSaveButton.setBounds(200,190,100,30);
dontSaveButton.addActionListener(this);
checkPanel.add(saveButton);
checkPanel.add(dontSaveButton);
add(checkPanel);
setSize(400,260);
setVisible(true);
/** Listens to the check boxes. */
public void itemStateChanged(ItemEvent e) {
if (e.getSource() == transport)
if (e.getStateChange() == ItemEvent.SELECTED)
transportField.setEditable(true);
else
transportField.setEditable(false);
if (e.getSource() == bills)
if (e.getStateChange() == ItemEvent.SELECTED)
billsField.setEditable(true);
else
billsField.setEditable(false);
if (e.getSource() == food)
if (e.getStateChange() == ItemEvent.SELECTED)
foodField.setEditable(true);
else
foodField.setEditable(false);
if (e.getSource() == gifts)
if (e.getStateChange() == ItemEvent.SELECTED)
giftsField.setEditable(true);
else
giftsField.setEditable(false);
if (e.getSource() == leisure)
if (e.getStateChange() == ItemEvent.SELECTED)
leisureField.setEditable(true);
else
leisureField.setEditable(false);
if (e.getSource() == others)
if (e.getStateChange() == ItemEvent.SELECTED)
othersField.setEditable(true);
else
othersField.setEditable(false);
public void actionPerformed(ActionEvent event) {
try {
if (event.getSource() == buttonTotal) {
double transportAmt=0.0, billsAmt=0.0, foodAmt=0.0, giftsAmt=0.0,leisureAmt=0.0, othersAmt=0.0, totalAmt=0.0;
if (!transportField.getText().equals(""))
transportAmt = Double.parseDouble(transportField.getText());
if(!billsField.getText().equals(""))
billsAmt = Double.parseDouble(billsField.getText());
if(!foodField.getText().equals(""))
foodAmt = Double.parseDouble(foodField.getText());
if(!giftsField.getText().equals(""))
giftsAmt = Double.parseDouble(giftsField.getText());
if(!leisureField.getText().equals(""))
leisureAmt = Double.parseDouble(leisureField.getText());
if(!othersField.getText().equals(""))
othersAmt = Double.parseDouble(othersField.getText());
totalAmt = transportAmt + billsAmt + foodAmt + giftsAmt + leisureAmt + othersAmt;
showTotal.setText("= $" + totalAmt);
catch (NumberFormatException numberFormatException ) {
JOptionPane.showMessageDialog(this, "You must enter numbers!","Invalid Number Format", JOptionPane.ERROR_MESSAGE);
if (event.getSource() == dontSaveButton) {
System.exit(0);
if(event.getSource() ==saveButton){
double transportAmt=0.0, billsAmt=0.0, foodAmt=0.0, giftsAmt=0.0,leisureAmt=0.0, othersAmt=0.0, totalAmt=0.0;
try{
BufferedWriter out = new BufferedWriter(new FileWriter("mySavedTotal.txt",true));
if (!transportField.getText().equals("")) {
transportAmt = Double.parseDouble(transportField.getText());
out.write("Transport = "+transportAmt);
out.newLine();
if(!billsField.getText().equals("")) {
billsAmt = Double.parseDouble(billsField.getText());
out.write("Bills = "+billsAmt);
out.newLine();
if(!foodField.getText().equals("")) {
foodAmt = Double.parseDouble(foodField.getText());
out.write("Food = "+foodAmt);
out.newLine();
if(!giftsField.getText().equals("")){
giftsAmt = Double.parseDouble(giftsField.getText());
out.write("Gifts = "+giftsAmt);
out.newLine();
if(!leisureField.getText().equals("")){
leisureAmt = Double.parseDouble(leisureField.getText());
out.write("Leisure = "+leisureAmt);
out.newLine();
if(!othersField.getText().equals("")) {
othersAmt = Double.parseDouble(othersField.getText());
out.write("Others = "+othersAmt);
out.newLine();
out.write("Total amount "+showTotal.getText());
out.newLine();
out.close();
JOptionPane.showMessageDialog(this, "Everything is saved!");
catch(IOException e){
JOptionPane.showMessageDialog(this, "You must enter integers!","Invalid Number Format",JOptionPane.ERROR_MESSAGE);
public static void main(String[] args) {
JPanel p = new CheckBox();
JFrame f = new JFrame();
Container c = f.getContentPane();
c.add(p);
f.pack();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setVisible(true);
}urgent... how to rerieve saved data? i got try b4 but didnt work out -
How to load text data into internal table
I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
Say this is the text file:
IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
ZIO_TEST1, CHA, IO TEST1, IO TEST 1, CHAR, 20
ZIO_TEST2, CHA, IO TEST2, IO TEST 2, CHAR, 20
Regards,
MauHi,
U can use GUI_UPLOAD for this...
Declare an internal table like
data: begin of itab occurs 0,
string(1200),
end of itab.
check the sample code:
cange as you need
DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.
DATA: BEGIN OF ITAB occurs 0,
TXT(1024),
END OF ITAB.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = DATEI_PC
FILETYPE = 'ASC'
CHANGING
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
NOT_SUPPORTED_BY_GUI = 17
ERROR_NO_GUI = 18
OTHERS = 19.
IF SY-SUBRC NE 0. WRITE: / 'Error in Uploading'. STOP. ENDIF.
WRITE: / 'UPLOAD:'.
LOOP AT ITAB. WRITE: / ITAB-TXT. ENDLOOP. -
How to get editable data into internal table
Hi ABAPers,
I am displaying REUSE_ALV_GRID_DISPLAY report with one editable field and i have post button in report. Once i select post button i need to get editable data to internal table which i passed to REUSE_ALV_GRID_DISPLAY.
actually i am writing below code but data is not coming to internal table.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF-STATUS'
i_callback_user_command = 'USER_COMMAND '
it_fieldcat = t_field[]
i_default = 'X'
TABLES
t_outtab = <fs_display1>. "t_display
FORM user_command USING g_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
g_test1 = g_ucomm.
CASE g_ucomm.
WHEN 'POST'.
READ TABLE <fs_display1> ASSIGNING <fsw_display1> INDEX 1. "Just for testing index 1
IF sy-subrc = 0.
w_display = <fsw_display1>.
APPEND w_display TO t_display.
CLEAR : w_display.
ENDIF.
PERFORM v1.
PERFORM bapi_call.
ENDCASE.
ENDFORM. "USER_COMMAND
Please help me how to get.
Regards,
Raju.Hi,
Try the following:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'PF-STATUS'
i_callback_user_command = 'USER_COMMAND '
it_fieldcat = t_field[]
i_default = 'X'
TABLES
t_outtab = <fs_display1>. "t_display
FORM user_command USING g_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
g_test1 = g_ucomm.
CASE g_ucomm.
WHEN 'POST'.
* to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
READ TABLE <fs_display1> ASSIGNING <fsw_display1> INDEX 1. "Just for testing index 1
IF sy-subrc = 0.
w_display = <fsw_display1>.
APPEND w_display TO t_display.
CLEAR : w_display.
ENDIF.
PERFORM v1.
PERFORM bapi_call.
ENDCASE.
ENDFORM. "USER_COMMAND
Hope it helps.
Regards,
Gilberto Li -
How to get data from maintaince view into internal table
Hi,
I want to get the all data from v_t179 (maintanence view) into intrenal table.
if i write select stmt , it is giving error.
I want all data into internal table.
regards,
AjayI think this is what you want:
TABLES: t179, t179t.
DATA: v_t179_int TYPE TABLE OF v_t179.
SELECT * FROM t179
JOIN t179t ON
t179~prodh = t179t~prodh
INTO CORRESPONDING FIELDS OF TABLE v_t179_int.
Rob -
Question about reading csv file into internal table
Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
I would like to ask how can I read a CSV file into internal table from files in application server?
I can't simply use SPLIT as there may be comma in the content. e.g.
"abc","aaa,ab",10,"bbc"
My expected output:
abc
aaa,ab
10
bbb
Thanks again for your help.Hi Gundam,
Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET dsn INTO record.
PERFORM parser USING record.
ENDDO.
*DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
*DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
*DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
*DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
*DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
FORM parser USING str.
DATA field(12).
DATA field1(12).
DATA field2(12).
DATA field3(12).
DATA field4(12).
DATA cnt TYPE i.
DATA len TYPE i.
DATA temp TYPE i.
DATA start TYPE i.
DATA quote TYPE i.
DATA rec_cnt TYPE i.
len = strlen( str ).
cnt = 0.
temp = 0.
rec_cnt = 0.
DO.
* Start at the beginning
IF start EQ 0.
"string just ENDED start new one.
start = 1.
quote = 0.
CLEAR field.
ENDIF.
IF str+cnt(1) EQ '"'. "Check for qoutes
"CHECK IF quotes is already set
IF quote = 1.
"Already quotes set
"Start new field
start = 0.
quote = 0.
CONCATENATE field '"' INTO field.
IF field IS NOT INITIAL.
rec_cnt = rec_cnt + 1.
CONDENSE field.
IF rec_cnt EQ 1.
field1 = field.
ELSEIF rec_cnt EQ 2.
field2 = field.
ELSEIF rec_cnt EQ 3.
field3 = field.
ELSEIF rec_cnt EQ 4.
field4 = field.
ENDIF.
ENDIF.
* WRITE field.
ELSE.
"This is the start of quotes
quote = 1.
ENDIF.
ENDIF.
IF str+cnt(1) EQ ','. "Check end of field
IF quote EQ 0. "This is not inside quote end of field
start = 0.
quote = 0.
CONDENSE field.
* WRITE field.
IF field IS NOT INITIAL.
rec_cnt = rec_cnt + 1.
IF rec_cnt EQ 1.
field1 = field.
ELSEIF rec_cnt EQ 2.
field2 = field.
ELSEIF rec_cnt EQ 3.
field3 = field.
ELSEIF rec_cnt EQ 4.
field4 = field.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CONCATENATE field str+cnt(1) INTO field.
cnt = cnt + 1.
IF cnt GE len.
EXIT.
ENDIF.
ENDDO.
WRITE: field1, field2, field3, field4.
ENDFORM.
Regards,
Wenceslaus.
Maybe you are looking for
-
Task I'm using an iPhone 4, iPad Wifi (both iOS 5.0.1) and Macbook Pro (OSX 10.7.3) and I'd like to the same message history on all devices. What I've done On the iPhone 4 the set is something more complicated (for me). As can be found under "Setting
-
I had itunes on my Dell laptop, i downloaded an apple update and now error message 126
I had itunes on my Dell laptop, i downloaded an apple update and now I get error message widows 126 and error message MSVCR80.dll. Help please.
-
How to protect the media file ...?
hi i want to protect my media file i used binaryio xtra its works but problem is that when i run the director project exe file then during execution the media file decoce and user can run the media file on any media player tell me what i do? plz tell
-
Assign Authorization in User Groups
Dear All Please help me , assign authorization User Groups . I go Tcode : SUGR and Tcode : SU 10 but i can't assign authorization in User Group , please help me step by step Regard , Thanks Lannguyen
-
Ruby-activesupport and Ruby-actionpack not found
I'm trying installing ruby-rails via AUR then I got this error: Continue building ruby-railties ? [Y/n] ==> --------------------------------------- ==> ==> Building and installing package ==> Install or build missing dependencies for ruby-railties: =