DATABASE table...plz urgent
hi experts,
can anyone help me with my requirement.i want step by step
process.
i am very new to SAP ABAP.
create a ztable having fields name,id,salary,designation with custom dataelements and domain.
i will reward points if helpful.
hi nani,
We can create the customized tables using data element or without dataelement.
since u are asking for fields with dataelement.
Go to T.code se11
go to datatable radiobutton.Give any name eg: znanitable.
go for create pushbutton.
now enter the small descriprition for table.
now go to fields and give ur first field as name and give it as primary key if u want and give any dataelement name in the component fields
Creating data elements
http://help.sap.com/saphelp_nw70/helpdata/en/90/8d7307b1af11d194f600a0c929b3c3/frameset.htm
Creating domains
http://help.sap.com/saphelp_nw70/helpdata/en/cf/21edf2446011d189700000e8322d00/frameset.h
now similarly u can create the other fields as with dataelements as shown above.
Regards.
shashikanth naram
Similar Messages
-
Data adding to database table Its urgent
How to add data from jsp page to DB table ...
If jsp contain login&password the n I want to store in table CMS in sql-server ...
The CMS contain two colomns name & pwd.
How to add?
Please tell me by two ways like by inserting to data base by bean using <jsp:useBean> tag...
And also by adding scriplet in JSP which directly adds to database.
If any body gives the sample code its good...
Please I want it urgent.
thanks in advance...
by
amit bhadreJSTL has a special sql taglib that you can use to execute queries if you want. I wouldn't recommend that however, JSP's should be used for presentation only. Database transactions should be done in servlets and/or beans, and for that you need to JDBC API.
JDBC tutorial:
http://java.sun.com/docs/books/tutorial/jdbc/index.html
JSTL SQL examples:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL7.html -
Fetch last record from database table
hi,
how to fetch last record from database table.
plz reply earliest.
Regards,
Jyotsna
Moderator message - Please search before asking - post locked
Edited by: Rob Burbank on Dec 11, 2009 9:44 AMabhi,
just imagine the table to be BSEG or FAGLFLEXA... then what would be performance of the code ?
any ways,
jyotsna, first check if you have a pattern to follow like if the primary key field have a increasing number range or it would be great if you find a date field which stores the inserted date or some thing..
you can select max or that field or order by descending using select single.
or get all data.. sort in descending order.(again you need some criteria like date).
read the first entry. using read itab index 1 -
Its very urgent:how to insert data into database tables
Hi All,
I am very new to oaf.
I have one requirement data insert into database tables.
here createPG having data that data insert into one custom table.
but i dont know how to insert data into database tables.
i wrote the code in am,co as follows.
in am i wrote the code:
public void NewoperationManagerLogic()
ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
OADBTransaction oadbt=getOADBTransaction();
if(!vo1.isPreparedForExecution())
vo1.executeQuery();
Row row=vo1.createRow();
vo1.insertRow(row);
in createPG processrequest co:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.NewoperationManagerLogic();
process form request:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Submit")!=null)
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.getOADBTransaction().commit();
please help with an example(sample code).
its very urgent.
thanks in advance
Seshu
Edited by: its urgent on Dec 25, 2011 9:31 PMHi ,
1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
Thanks
Pratap -
Database Table where MRP Run results are saved-Urgent
Hi Gurus
i need your help in identifying the database table where the MRP Run results are saved , this is needed for creating a custom report similar to MD45(but for entire plant) where i can look and pull the sum of all the receipts and issues, ATP Quantity for a given material in a particular plant
and ignore zero quantities in the receipts and issues field
i tried in <b>MDTB</b> table, MDTB-MNG01 Quantity received or quantity required but it has no entries maintained in it and so it cannot be used.
So can you please help me with the table where i can get this information asap
thank you very much for your time and solutionPlease use the code below which will help you in extracting data from MRP table.
You can enhance this program basing on your requirement.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A sample program to extract data from the MRP table.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
REPORT ZMRPTABLE.
TABLES: MDKP, "Header Data for MRP Document
MDTB, "MRP table
MDTC, "Aggregated MRP table items
T457T. "Description of MRP elements
DATA: BEGIN OF MDTBX OCCURS 0.
INCLUDE STRUCTURE MDTB.
DATA: END OF MDTBX.
SELECT-OPTIONS: PLANT FOR MDKP-PLWRK OBLIGATORY,
MATNR FOR MDKP-MATNR OBLIGATORY.
CLEAR: MDKP, MDTB.
SELECT * FROM MDKP WHERE DTART EQ 'MD'
AND MATNR IN MATNR
AND PLWRK IN PLANT.
WRITE:/ MDKP-MATNR, MDKP-PLWRK.
IF MDKP-CFLAG EQ 'X'.
CLEAR MDTBX. REFRESH MDTBX.
IMPORT MDTBX FROM DATABASE MDTC(AR) ID MDKP-DTNUM.
LOOP AT MDTBX.
MOVE MDTBX TO MDTB.
SELECT SINGLE * FROM T457T WHERE SPRAS = 'E'
AND DELKZ = MDTB-DELKZ.
IF MDTB-PLUMI = '-'. MULTIPLY MDTB-MNG01 BY -1. ENDIF.
WRITE:/ MDTB-DAT00, T457T-DELB1, MDTB-VSTAT,
MDTB-MNG01, MDTB-LGORT.
ENDLOOP.
ELSE.
SELECT * FROM MDTB
WHERE DTNUM EQ MDKP-DTNUM
ORDER BY PRIMARY KEY.
SELECT SINGLE * FROM T457T WHERE SPRAS = 'E'
AND DELKZ = MDTB-DELKZ.
IF MDTB-PLUMI = '-'. MULTIPLY MDTB-MNG01 BY -1. ENDIF.
WRITE:/ MDTB-DAT00, T457T-DELB1, MDTB-VSTAT,
MDTB-MNG01, MDTB-LGORT.
ENDSELECT.
ENDIF.
ENDSELECT.
This is taken from www.sap-img.com
Hope this helps you. -
1. i have one html page - in that two combo boxes are there
2. first one called--> Bank Name and second one called-->Main Branch
3. i have a database table like BANK_MASTER(MAIN_BRANCH,BANK_NAME)
i am giving here some data for the above table:
(sbi-kurnool, sbi),(sbi-cadapah,sbi),(sbi-chittor,sbi),(ab-rangareddy,ab),(ab-varangal,ab) ..like that every bank has its own main branch in different location.
MY PROBLEM:
In HTML page, in the first combo box ie., Bank Name will display all the bank name using the table BANK_MASTER ie.,sbi,ab,cb,sbh ...... (its ok - i too get )
main Problem: Whenever i select a particular bank name in the first combo box, the second combo box ie.,Main Branch has to display the main branches using the table Bank_Master depending on the Selected bank name from the Bank Name Combo box ( ie., if we select the sbi, it has to display all main branches of sbi's only, but not other bank's main branches)Hi friend,
I had a similar situation and i tried to solve it by using XmlHttpRequest Object(used in AJAX).
U can checkout the below example just for further reference delete
UserForm.jsp:
==========
<head>
<script>
var xmlHttp
function showState(str)
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
alert ("Browser does not support HTTP Request")
return
var url="getState.jsp"
url=url+"?count="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChange
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
function stateChange()
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("state").innerHTML=xmlHttp.responseText
</head>
<body>
<select name='country' onchange="showState(this.value)">
<option value='india>india</option>
</select>
<br>
<div id='state'>
<select name='state' >
<option value='-1'>pickone</option>
</select>
</div>
</body>
getState.jsp
============
<%@page language="java" import ="java.util.Hashtable" import ="java.util.Set" %>
<%
String country=request.getParameter("count");
response.setContentType("text/html");
response.setHeader("Cache-Control","no-cache");
try{
Hashtable ht = (Hashtable)session.getAttribute("<ATTRIBUTE_NAME>");
String buffer="<select name='state'><option value='-1'>Pick One</option>";
Set s=ht.keySet();
Object keys[]=s.toArray();
int size=keys.length;
for(int i=0; i < size;i++){
buffer=buffer+"<option value='"+ht.get(keys).toString()+"'>"+ht.get(keys).toString()+"</option>";
buffer=buffer+"</select>";
response.getWriter().println(buffer);
catch(Exception exp){
response.getWriter().println(exp);
%> I think u may go upon replacing country with your Main Branch and vice versa -
Dear all experts,
I am able to populate all fields data from database table, using dynamic table creation.
eg,
SELECT * FROM (w_tabname) INTO TABLE <t_itab>.
where w_tabname is the table name given by the user, and t_itab is field symbol.
but some requirement is like that i need to pick up only few fields, <b>which user will give at the runtime.</b>
<b>I can</b> take those fields from file into any internal table,
but the problem is that instead of <b>select *</b>, i need to put selected the fields given by user.
i have tried with field symbol, it is not working (as per my knowledge.)
do i need to create any structures dynamically ?
Can anybody please help in this regards ?
Your help will be surely rewarded with points.
Waiting for reply..
Regards
VinayHi Vinay ,
Adding to the below code , you can use some more fields in the select stmt as below:-
REPORT ychatest.
PARAMETERS : p_field1 LIKE dd03l-fieldname,
P_field2 LIKE dd03l-fieldname,
p_table LIKE dd03l-tabname.
FIELD-SYMBOLS : <fs> TYPE STANDARD TABLE.
SELECT (p_field1) (p_field2) ( FROM (p_table) INTO TABLE <fs>.
Now p_field1 & p_field2 belong to the same table since you have give the user to enter only one table name.
This should work fine.
please try & let me know .
Thanks & Regards,
Daniel -
UrGENT-DUMP while querying database table into itab(Assigned field Symbol)
Hi,
__I am getting a dump whose description is as follows__-
"" In an SQL array select, the internal table used to hold the
selected records must be at least as wide as the database table
from which the records are being read.
In this particular case, the database table is 820 bytes wide,
but the internal table is only 814 bytes wide.""
The following code had been written:
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_tabl TYPE dd02l-tabname. "Table Name
SELECTION-SCREEN END OF BLOCK b1.
FIELD-SYMBOLS: <fs_itab> TYPE STANDARD TABLE,
<fs_wa> TYPE ANY,
<fs_itab1> TYPE STANDARD TABLE,
<fs_wa1> TYPE ANY.
FORM generate_internal_tab .
DATA: o_itab TYPE REF TO data,
o_wa TYPE REF TO data,
o_itab1 TYPE REF TO data,
o_wa1 TYPE REF TO data.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_tabl
CHANGING
ct_fieldcat = it_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*Create Dynamic Table for it_fcat
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = o_itab
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc EQ 0 OR o_itab IS NOT INITIAL.
ASSIGN o_itab->* TO <fs_itab>.
CREATE DATA o_wa LIKE LINE OF <fs_itab>.
ASSIGN o_wa->* TO <fs_wa>.
ENDIF.
*Download the file to Application server
SELECT *
FROM (p_tabl)
INTO TABLE <fs_itab>.
So i am geting a dump in placing contents of table(p_tabl) into <fs_itab>.Should the type declarations be changed???
Please give me an solution to resolve this dump.
Thanks and regards-
SumitaYou are trying to put more fields in the internal table than what is declared presently for itab. Check if one of the fields is selected but not being passed on to a internal table field.
-
How to insert message style text columns in database tables
Hi All,
i have two pages.
in first page segment1 lov is their.once u select the segment1 and click on the create button its navigate to next page.
and display the releted segment1 details(these columns are message text input fields but read only columns).
plz help me those columns are insert into database tables.
its very urgent
Thanks
Latha.Hi Anil,
plz help me still i am faceing the problem
so plz help me because i dont know java.
i wrote below code and i got the below error.
if(pageContext.getParameter("Submit")!=null)
String projnumber=pageContext.getParameter("ProjectNO");
//String projectnumber=pageContext.getParameter("Projectnumber");
String oldoperationid=pageContext.getParameter("EmployeeNumber");
String newManagerName=pageContext.getParameter("NewManagerName");
String ProjectID=pageContext.getParameter("ProjectID");
String OldOperationName=pageContext.getParameter("OperationsManager");
String OldOperationID=pageContext.getParameter("OldOperationID");
OAMessageTextInputBean projnumberbean =webBean.findIndexedChildRecursive("ProjectNO");
String projnumber=null;
if(bean!=null)
projnumber = (String)projnumberbean.getValue(pageContext);
Serializable[] params = {projnumber,oldoperationid,newManagerName,ProjectID,OldOperationName,OldOperationID};
am.invokeMethod("xxinsertpagelogic",params);
and i wrote import also.
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
my errors are
Error(64,78): incompatible types; found: oracle.apps.fnd.framework.webui.beans.OAWebBean, required: oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean
Error(65,13): duplicate definition of variable projnumber in method processFormRequest(oracle.apps.fnd.framework.webui.OAPageContext, oracle.apps.fnd.framework.webui.beans.OAWebBean)
Error(66,9): variable bean not found in class wnsgs.oracle.apps.pa.projectinfo.webui.ProjectInfoCreateCO
plz help me.
its very urgent
Thanks
Edited by: Latha on Jan 4, 2012 9:57 PM
Edited by: Latha on Jan 4, 2012 10:00 PM -
BW database table to infoobject
Hi,
I have created a table in bw and filled up the data......
From this table i would like to add the data to infoobject....
how to assign BW Database table to InfoObject....
Plz answer its an urgent.
AnjaliHi,
If you want to load data into InfoObject (Master data) from BW itself.
1. Then create Generic DataSource in RSO2 in BW
2. Select DS type as Master Data.
3. Select datasource based on Table or View & mention this table name.
And use this datasource for loading data.
Regards
SS -
I want to delete the transactional record from database table
Hai,
I want to delete the transactional data from database table with out using the dialog programming is it there any trancation for this.
for master data we have the transaction code for delete the records. The t.code is 'OBR2'.
Plz help in that cse.
Thanks and regards,
P.Naganjana ReddyHai,
Plz help me urgent.
I am asking i want to delete transactional data from database table without using the dialog programming.
Thanks and Regards,
P.Naganjana -
Help needed in reading text file to database table
Hello experts,
i have to insert the values from the column of this text file and insert them in my database table.
I have done a few file to table insertions but i'm having some trouble with this one.
Any suggestions plz
thanks
liab_report 1.00 Page: 1
CDC:00537 / Mon Jun-21-2010 LIABILITY REPORT Mon Jun-21-2010 22:06:26
DRAW 1; SET 1; November 7, 2009
TOTAL PAID ON TOTAL EXPIRED ON TOTAL FRAC OUTSTANDING
WINNERS 06/21/10 PAID 06/21/10 EXPIRED ROUND
DIVISION AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT
Div1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Div2 701040.00 0.00 660146.00 0.00 40894.00 0.00 0.00
Div3 1444128.00 0.00 1330056.00 0.00 114072.00 0.00 0.00
Div4 4711900.00 0.00 3889700.00 0.00 822200.00 0.00 0.00
6857068.00 0.00 5879902.00 0.00 977166.00 0.00 0.00
DRAW 2; SET 1; November 14, 2009
TOTAL PAID ON TOTAL EXPIRED ON TOTAL FRAC OUTSTANDING
WINNERS 06/21/10 PAID 06/21/10 EXPIRED ROUND
DIVISION AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT
Div1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Div2 817817.00 0.00 817817.00 0.00 0.00 0.00 0.00
Div3 1687405.00 0.00 1611742.00 0.00 75663.00 0.00 0.00
Div4 3402100.00 0.00 3034200.00 0.00 367900.00 0.00 0.00
5907322.00 0.00 5463759.00 0.00 443563.00 0.00 0.00
DRAW 3; SET 1; November 21, 2009
TOTAL PAID ON TOTAL EXPIRED ON TOTAL FRAC OUTSTANDING
WINNERS 06/21/10 PAID 06/21/10 EXPIRED ROUND
DIVISION AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT
Div1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Div2 779933.00 0.00 769804.00 0.00 10129.00 0.00 0.00
Div3 1605548.00 0.00 1525104.00 0.00 80444.00 0.00 0.00
Div4 4891700.00 0.00 4256800.00 0.00 634000.00 0.00 900.00
7277181.00 0.00 6551708.00 0.00 724573.00 0.00 900.00Plz clarify whether u want to load text file as a file into database or value of this text file into database. If values are to be loaded from this text file, U can better format the text file and use SQL loader to load the file into database. By formatting the database, i mean remove the unnecessary headings and characters, kee only the values to be loaded idelimited by ' '(space) or ','(comma). Create a control file and load it into the target table.
-
Displaying data in a tree from database table
Hi,
I want to display data from a database table (mara-matnr) in a tree structure. I went through the coding of SBSPEXT_HTMLB. There static data was taken in to wa_tab. But there I want to bring data from a database table into wa_tab. For this I created an internal table without headerline by taking a work area, now how can I move data from this work area to wa_tab record by record.
I hope some one might have worked on this. Plz help me....
Thanks in advance,
Ravindra.Hi,
take a look at this <a href="/people/tomas.altman/blog/2004/12/13/sdn-blog-how-to-do-internal-tables-in-bsp which explains how internal tables work in ABAP OO.
Furthermore I think you want to do this:
insert <yourWorkarea> into table wa_tab.
A complete mara example would be:
data tab_mara type table of mara.
data wa_mara type mara.
select * from mara into table tab_mara.
*or you can use:
select * from mara into wa_mara.
insert wa_mara into table tab_mara.
endselect.
regards
Thomas -
How to save data after clicking checkbox stored in database table
TYPE-pools: slis.
tables:mkpf,mseg,mard.
TYPES: BEGIN OF tp_data,
mblnr LIKE mseg-mblnr,
matnr LIKE mseg-matnr,
werks LIKE mard-werks,
lgort LIKE mard-lgort,
lgpbe LIKE mard-lgpbe,
charg LIKE mseg-charg,
bwart LIKE mseg-bwart,
budat LIKE mkpf-budat,
menge LIKE mseg-menge,
meins LIKE mseg-meins,
kostl LIKE mseg-kostl,
aufnr LIKE mseg-aufnr,
rsnum LIKE mseg-rsnum,
checkbox TYPE c,
__mark,
END OF tp_data,
tp_tbl_data TYPE STANDARD TABLE OF tp_data.
Constants
Data objects (variable declarations and definitions)
Report data to be shown.
DATA: it_data TYPE STANDARD TABLE OF tp_data.
Heading of the report.
DATA: t_heading TYPE slis_t_listheader.
========================== Selection Screen ==========================
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:smblnr FOR mseg-mblnr MODIF ID m1,
smatnr FOR mseg-matnr MODIF ID m2,
swerks FOR mard-werks MODIF ID m3,
slgort FOR mard-lgort MODIF ID m4,
slgpbe FOR mard-lgpbe MODIF ID m5,
scharg FOR mseg-charg MODIF ID m6,
sbwart FOR mseg-bwart MODIF ID m7,
skostl FOR mseg-kostl MODIF ID m8,
saufnr FOR mseg-aufnr MODIF ID m9,
srsnum FOR mseg-rsnum MODIF ID m10.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS:pre RADIOBUTTON GROUP radi USER-COMMAND ucomm DEFAULT 'X',
pse RADIOBUTTON GROUP radi,
bps RADIOBUTTON GROUP radi.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETER:layout TYPE i.
SELECTION-SCREEN END OF BLOCK b3.
=========================== Event Blocks =============================
AT selection-SCREEN.
start-OF-selection.
PERFORM get_data USING it_data.
END-OF-selection.
PERFORM build_alv USING it_data t_heading.
=========================== Subroutines ==============================
*& Form get_data
Gets the information to be shown in the report.
FORM get_data USING t_data TYPE tp_tbl_data.
SELECT msegmblnr msegmatnr mardwerks mardlgort mardlgpbe msegcharg msegbwart mkpfbudat
msegmenge msegmeins msegkostl msegaufnr mseg~rsnum
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM mseg
JOIN mard ON mardmatnr EQ msegmatnr
JOIN mkpf ON msegmblnr EQ mkpfmblnr
WHERE mseg~matnr IN smatnr.
ENDFORM. " get_data
*& Form build_alv
Builds and display the ALV Grid.
FORM build_alv USING t_data TYPE tp_tbl_data
t_heading TYPE slis_t_listheader.
ALV required data objects.
DATA: w_title TYPE lvc_title,
w_comm TYPE slis_formname,
w_status TYPE slis_formname,
x_layout TYPE slis_layout_alv,
t_event TYPE slis_t_event,
t_fieldcat TYPE slis_t_fieldcat_alv,
t_sort TYPE slis_t_sortinfo_alv.
REFRESH t_fieldcat.
REFRESH t_event.
REFRESH t_sort.
CLEAR x_layout.
CLEAR w_title.
Field Catalog
PERFORM set_fieldcat2 USING:
1 'MBLNR' 'MBLNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
2 'MATNR' 'MATNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
3 'WERKS' 'WERKS' 'MARD' space space space space space space space space space space space space t_fieldcat,
4 'LGORT' 'LGORT' 'MARD' space space space space space space space space space space space space t_fieldcat ,
5 'LGPBE' 'LGPBE' 'MARD' space space space space space space space space space space space space t_fieldcat ,
6 'CHARG' 'CHARG' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
7 'BWART' 'BWART' 'MSEG' space space space space space space space space space space space space t_fieldcat,
8 'BUDAT' 'BUDAT' 'MKPF' space space space space space space space space space space space space t_fieldcat,
9 'MENGE' 'MENGE' 'MSEG' space space space space space space space space space space space space t_fieldcat,
10 'MEINS' 'MEINS' 'MSEG' space space space space space space space space space space space space t_fieldcat,
11 'KOSTL' 'KOSTL' 'MSEG' space space space space space space space space space space space space t_fieldcat,
12 'AUFNR' 'AUFNR' 'MSEG' space space space space space space space space space space space space t_fieldcat,
13 'RSNUM' 'RSNUM' 'MSEG' space space space space space space space space space space space space t_fieldcat,
14 '__MARK' 'XFELD' space space space 'Select' 'Select this row' 'Sel' 'Select this row' space space space 'X' 'X' space t_fieldcat.
Layout
x_layout-zebra = 'X'.
Top of page heading
PERFORM set_top_page_heading USING t_heading t_event.
Events
PERFORM set_events USING t_event.
GUI Status
w_status = ''.
User commands
w_comm = 'USER_COMMAND'.
Order
Example
PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
PERFORM set_order USING 'LIFNR' 'IT_DATA' 'X' space 'X' t_sort.
PERFORM set_order USING 'EBELN' 'IT_DATA' 'X' space 'X' t_sort.
PERFORM set_order USING 'EBELP' 'IT_DATA' 'X' space space t_sort.
Displays the ALV grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = t_fieldcat
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
TABLES
t_outtab = t_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " build_alv.
*& Form set_top_page_heading
Creates the report headings.
FORM set_top_page_heading USING t_heading TYPE slis_t_listheader
t_events TYPE slis_t_event.
DATA: x_heading TYPE slis_listheader,
x_event TYPE LINE OF slis_t_event.
Report title
CLEAR t_heading[].
CLEAR x_heading.
x_heading-typ = 'H'.
x_heading-info = 'Reporte Prueba'(001).
APPEND x_heading TO t_heading.
Program name
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'Program: '.
x_heading-info = sy-repid.
APPEND x_heading TO t_heading.
User who is running the report
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'User: '.
x_heading-info = sy-uname.
APPEND x_heading TO t_heading.
Date of execution
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'Date: '.
WRITE sy-datum TO x_heading-info.
APPEND x_heading TO t_heading.
Time of execution
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'Time: '.
WRITE sy-uzeit TO x_heading-info.
APPEND x_heading TO t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-FORM = 'TOP_OF_PAGE'.
APPEND x_event TO t_events.
ENDFORM.
*& Form set_events
Sets the events for ALV.
The TOP_OF_PAGE event is alredy being registered in
the set_top_page_heading subroutine.
FORM set_events USING t_events TYPE slis_t_event.
DATA: x_event TYPE LINE OF slis_t_event.
Example
clear x_event.
x_event-name = .
x_event-form = .
append x_event to t_event.
ENDFORM.
*& Form set_order
Adds an entry to the order table.
FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
t_sort TYPE slis_t_sortinfo_alv.
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = p_fieldname.
x_sort-tabname = p_tabname.
x_sort-UP = p_up.
x_sort-down = p_down.
x_sort-subtot = p_subtot.
APPEND x_sort TO t_sort.
ENDFORM. "set_order
*& Form set_fieldcat2
Adds an entry to the field catalog.
FORM set_fieldcat2 USING p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
t_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-HOTSPOT = p_hotspot.
wa_fieldcat-CHECKBOX = p_checkbox.
wa_fieldcat-ICON = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set reference fieldname, tablenam and rollname.
If p_ref_tabname is not given, the ref_fieldname given is a data element.
If p_ref_tabname is given, the ref_fieldname given is a field of a table. In case ref_fieldname is not given, it is copied from the fieldname.
IF p_ref_tabname IS INITIAL.
wa_fieldcat-rollname = p_ref_fieldname.
ELSE.
wa_fieldcat-ref_tabname = p_ref_tabname.
IF p_ref_fieldname EQ space.
wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.
ELSE.
wa_fieldcat-ref_fieldname = p_ref_fieldname.
ENDIF.
ENDIF.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
Set as editable or not.
IF p_edit IS NOT INITIAL.
wa_fieldcat-INPUT = 'X'.
wa_fieldcat-EDIT = 'X'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
=========================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'XXXXX'
it_list_commentary = t_heading.
ENDFORM. " alv_top_of_page
*& Form user_command
Called on user_command ALV event.
Executes custom commands.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Example Code
Executes a command considering the sy-ucomm.
CASE r_ucomm.
WHEN '&IC1'.
Set your "double click action" response here.
Example code: Create and display a status message.
DATA: w_msg TYPE string,
w_row(4) TYPE n.
w_row = rs_selfield-tabindex.
CONCATENATE 'You have clicked row' w_row
'field' rs_s lfield-fieldname
'with value' rs_selfield-value
INTO w_msg SEPARATED BY space.
MESSAGE w_msg TYPE 'S'.
ENDCASE.
End of example code.
LOOP AT T_DATA.
IF it_data-__MARK EQ 'X'.
insert ztable.
ENDIF.
ENDLOOP.
ENDFORM. "user_command
ur sending code loop is error ,plz check that one after checking send meHi,
After displaying ALV report output, if you want to update database table based on your selected record, then use the below logic in your User_command subroutine.
You will get the index of the selected record in rs_selfield-tabindex. using this index read the respective record from the internal table and move corresponding field to the table fields and then update.
data : wa_data like t_data.
read table t_data index rs_selfield-tabindex into wa_data.
if sy-subrc = 0.
move-corresponding wa_data to ztable.
insert ztable.
endif.
thanks,
sksingh -
How to fetch the customer debit balances form the KNC1 database table
Hi Experts,
I am creating a ABAP report which would dispaly the customer credit balances for the currenct fiscal year.
I am fetching the values form KNC1 database table.....But in this table values are stored year wise.
But I want to display for the current fiscal year that means if teh user selects the 07/2011 as the month on the sleection screen then the debit balances from 072010 to 062011 should be dispalyed.
Could anyone please help me out to fetch this the debit balaces form KNC1 database table in the above format.
Or is there any other way to solve this problem?
Awating your urgent reply.
Many Thanks,
Komal.Hi Komal,
First, you have to compute the initial period and the final period.
Next, you must read table KNC1 for the years comprised between these two periods.
Last, you must read the fields of table KNC1. For that, you should compose dynamically the name of the field, and then ASSIGN it to a FIELD-SYMBOL.
Now, just add up the values!
Please try the following code:
FIELD-SYMBOLS: <fs>.
DATA: t_knc1 TYPE TABLE OF knc1 WITH HEADER LINE.
DATA: d_debits LIKE knc1-um01s.
PARAMETERS: p_kunnr LIKE knc1-kunnr,
p_bukrs LIKE knc1-bukrs,
p_spmon TYPE spmon.
DATA: l_fieldname(20) TYPE c.
DATA: l_date LIKE sy-datum,
l_date_from LIKE sy-datum,
l_date_to LIKE sy-datum.
DATA: l_period(2) TYPE n.
DATA: l_num_times TYPE i.
START-OF-SELECTION.
"Compute the initial and final periods
CONCATENATE p_spmon '01' INTO l_date.
CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'
EXPORTING
months = '-1'
olddate = l_date
IMPORTING
newdate = l_date_to.
CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'
EXPORTING
months = '-12'
olddate = l_date
IMPORTING
newdate = l_date_from.
"Read table KNC1
SELECT *
INTO CORRESPONDING FIELDS OF TABLE t_knc1
FROM knc1
WHERE kunnr = p_kunnr
AND bukrs = p_bukrs
AND gjahr BETWEEN l_date_from(4) AND l_date_to(4).
"this will yield at most 2 records, one for present year, and another one for the previous year.
"but if you select i.e. period '01.2012', initial_date = '01.01.2011' and final_date = '31.12.2011'
" --> thus only one year --> one record
CLEAR: d_debits.
LOOP AT t_knc1.
" If there's no year change
IF l_date_from(4) = l_date_to(4).
DO 16 TIMES.
l_period = sy-index.
CONCATENATE 'UM' "compute dynamically the field name
l_period
'S'
INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE t_knc1 TO <fs>. "assign
ADD <fs> TO d_debits. "and add up
ENDDO.
ELSE.
" If there IS a year change
IF t_knc1-gjahr = l_date_from+0(4).
l_num_times = 16 - l_date_from+4(2) + 1. "you must loop 16 - initial_period + 1 times for the first year
DO l_num_times TIMES.
l_period = sy-index + l_date_from+4(2) - 1.
CONCATENATE 'UM' "compute dynamically the field name
l_period
'S'
INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE t_knc1 TO <fs>. "assign
ADD <fs> TO d_debits. "and add up
ENDDO.
ELSE.
l_num_times = l_date_to+4(2). "you must loop final_period times for the second year
DO l_num_times TIMES.
l_period = sy-index.
CONCATENATE 'UM' "compute dynamically the field name
l_period
'S'
INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE t_knc1 TO <fs>. "assign
ADD <fs> TO d_debits. "and add up
ENDDO.
ENDIF.
ENDIF.
ENDLOOP.
You'll have the result on variable 'd_debits'.
I hope this helps. Kind regards,
Alvaro -
How to change a field of type CHAR of a database table to DATS
Dear ABAP experts,
I have a database table: ZLT_aztnew with fields M1, M2, K1, K2, A1, A2, P1, P2, S2, D1, D2, STD, BES. All these fields are of type 'Character'. except D2 which is of type DATS. The field D1 is date and is in format DD.MM.YYYY.
I want to convert this field D1 to type DATS so that I can use a date range through 'selection option' to select other data of other fields (M1, M2, K1, K2, A1, A2, P1, P2, S2, D1, STD, BES.) related to field D1 from the database table Zlt_aztnew.
How should I introduce this change (CONVERSION OF D1 CHAR to DATS in the .AZT file upload code itself.
Problem: If I define D1 as Type DATS in database table ZLT_AZTNEW then the UPLOAD fails.
The AZT file upload code is:
Data it_string type stringtab.
Data lv_string type string.
DATA: itab TYPE STANDARD TABLE OF zlt_aztnew.
DATA: wa_tab TYPE zlt_aztnew.
DATA: file_str1 type string.
Data: it_tab TYPE STANDARD TABLE OF file_table,
lw_file LIKE LINE OF it_tab,
gd_subrc TYPE i.
SELECTION-SCREEN begin of block blk with frame title text-100.
SELECTION-SCREEN SKIP 2.
parameters : p_file like rlgrap-filename .
SELECTION-SCREEN end of block blk.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select only Text File'
default_filename = '.azt'
multiselection = 'X'
CHANGING
file_table = it_tab
rc = gd_subrc.
READ TABLE it_tab INTO lw_file INDEX 1.
p_file = lw_file-FILENAME.
Start-of-Selection.
file_str1 = P_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_str1
* filename = '\\10.10.1.92\Volume_1\_projekte\Zeiterfassung-SAP\test.azt'
tables
data_tab = it_string
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 AT it_string INTO lv_string.
clear wa_tab.
SPLIT lv_string AT ';' INTO wa_tab-M2 wa_tab-k2 wa_tab-A2 wa_tab-P2 wa_tab-S2 wa_tab-D1 wa_tab-STD wa_tab-BES.
Append wa_tab to itab.
Write: sy-uline(120),
/ sy-vline,
2 wa_tab-M2,
11 sy-vline,
13 wa_tab-k2,
25 sy-vline,
27 wa_tab-A2,
32 sy-vline,
34 wa_tab-P2,
39 sy-vline,
41 wa_tab-S2,
46 sy-vline,
48 wa_tab-D1,
60 sy-vline,
62 wa_tab-STD,
72 sy-vline,
74 wa_tab-BES,
120 sy-vline.
ENDLOOP.
DATA: Answer.
UPDATE zlt_aztnew From Table itab.
* INSERT ZLT_aztnew From Table itab accepting duplicate keys.
If sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'TITLE '
* DIAGNOSE_OBJECT = ' '
text_question = 'Wollen Sie die vorhandenen Inhalte ändern'
TEXT_BUTTON_1 = 'Ja'(001)
* ICON_BUTTON_1 = ' '
TEXT_BUTTON_2 = 'Nein'(002)
* ICON_BUTTON_2 = ' '
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = answer
* TABLES
* PARAMETER =
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2
*IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
IF Answer = '1'.
WRITE: / 'Die vorhandenen Inhalte war geändernt'.
MODIFY zlt_aztnew From Table itab.
ENDIF.
ENDIF.
TO introduce a date range and pull data from the database table Zlt_AZTNEW--> I wrote the BELOW code SEPARATELY,
but after execution, the error I am getting is: Enter a valid Date (for example, 31.03.2014).
TABLES: ZLT_aztnew.
TYPES: Begin OF ty_AZTN,
M2 TYPE Zlt_AZTNEW-M2,
K2 TYPE Zlt_AZTNEW-K2,
A2 TYPE Zlt_AZTNEW-A2,
P2 TYPE Zlt_AZTNEW-P2,
S2 TYPE Zlt_AZTNEW-S2,
D1 TYPE Zlt_AZTNEW-D1,
STD TYPE Zlt_AZTNEW-STD,
BES TYPE Zlt_AZTNEW-BES,
END OF ty_AZTN.
DATA: gv_datum TYPE d.
DATA: it_aztn TYPE STANDARD TABLE OF ty_aztn with header line.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = zlt_aztnew-D1
* ACCEPT_INITIAL_DATE =
IMPORTING
DATE_INTERNAL = gv_datum
* EXCEPTIONS
* DATE_EXTERNAL_IS_INVALID = 1
* OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SELECT-OPTIONS: s_datum FOR gv_datum.
INITIALIZATION.
s_datum-low = sy-datum.
s_datum-high = sy-datum.
APPEND s_datum.
********** After this further code follows with "SELECT" wherein I want to use the gv_datum as Where condition.
SELECT M2
K2
A2
P2
S2
D1
STD
BES
FROM ZLt_AZTNEW
INTO TABLE it_AZTN
Where D1 = gv_datum.
Please provide me your valuable suggestion to correct any flaw in my code above.
Looking forward for your reply.
Best regards
Chandan KumarDear Rama,
Plz refer the following difference in naming conventions as compared to your suggestion:
it_flat_file --> itab, (internal table for AZT fiel upload and split)
ls_flat_file ---> wa_itab,
Ztable --> Zlt_aztnew2, (Dbase file)
it_ztable ---> it_zlt_aztnew2, (internal table)
ls_ztable --> wa_aztnew2,
I wrote the following code but it is not working. Please also refer the attached screen shot of the database table : ZLT_AZTNEW2.
Data it_string type stringtab.
Data lv_string type string.
DATA: file_str1 type string.
Data: it_tab TYPE STANDARD TABLE OF file_table,
lw_file LIKE LINE OF it_tab,
gd_subrc TYPE i.
TYPES: Begin of Ty_itab,
M2 TYPE Char7,
K2 TYPE Char3,
A2 TYPE Char3,
P2 TYPE Char3,
S2 TYPE Char3,
D1 TYPE Char8,
STD TYPE Char8,
BES TYPE Char80,
END OF ty_itab.
DATA: itab Type Standard Table of ty_itab,
wa_itab Type ty_itab.
DATA: it_zlt_aztnew2 type standard table of Zlt_aztnew2,
wa_aztnew2 TYPE Zlt_aztnew2.
SELECTION-SCREEN begin of block blk with frame title text-100.
SELECTION-SCREEN SKIP 2.
parameters : p_file like rlgrap-filename .
SELECTION-SCREEN end of block blk.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select only Text File'
default_filename = '.azt'
multiselection = 'X'
CHANGING
file_table = it_tab
rc = gd_subrc.
READ TABLE it_tab INTO lw_file INDEX 1.
p_file = lw_file-FILENAME.
Start-of-Selection.
file_str1 = P_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_str1
* filename = '\\10.10.1.92\Volume_1\_projekte\Zeiterfassung-SAP\test.azt'
tables
data_tab = it_string
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 AT it_string INTO lv_string.
Clear wa_itab.
SPLIT lv_string AT ';' INTO wa_itab-M2 wa_itab-k2 wa_itab-A2 wa_itab-P2 wa_itab-S2 wa_itab-D1 wa_itab-STD wa_itab-BES.
append wa_itab to itab.
Write: sy-uline(120),
/ sy-vline,
2 wa_itab-M2,
11 sy-vline,
13 wa_itab-k2,
25 sy-vline,
27 wa_itab-A2,
32 sy-vline,
34 wa_itab-P2,
39 sy-vline,
41 wa_itab-S2,
46 sy-vline,
48 wa_itab-D1,
60 sy-vline,
62 wa_itab-STD,
72 sy-vline,
74 wa_itab-BES,
120 sy-vline.
ENDLOOP.
LOOP at itab into wa_itab.
CLEAR wa_aztnew2.
wa_aztnew2-D1+0(4) = wa_itab+6(4).
wa_aztnew2-D1+4(2) = wa_itab+3(2).
wa_aztnew2-D1+6(2) = wa_itab+0(2).
Append wa_aztnew2 to it_zlt_aztnew2.
ENDLOOP.
MODIFY Zlt_aztnew2 from table it_zlt_aztnew2.
Looking forward for your suggestiojn.
Regards
Chandan
Maybe you are looking for
-
When I first open Firefox it is fine but if I open a second tab to search another site I get a white screen and have to continually click 'back', click the site link, white screen, back, click the link, white screen and so on.
-
Indesign to PDF trim mark issue
I have a business card file in InDesign and exported it to a PDF last week with trim marks for bleed with no issues. Now I export the same file with the same export settings and there is a white trim space. Last week's export: This week's export:
-
Server OS: Windows 2008 R2 Standard Function: Primary Domain Controller and Print Server Clients: All are running Windows 7 Pro 64-Bit SP1 We're considering disabling the HP Universal Print Driver Language Monitor and in-turn Bi-directional Printing
-
Hi friends, my requirement is like this. i have notification number. when right click on that i need to show select ,move .. any body have answer pls let me know it's urgent... ex :in edit right clik u will get select,move. same i need when i ha
-
MacBook Pro Won't sleep sometimes
Soon after starting my MacBook Pro (2010 model) it will be able to sleep. However, after some time, it will being able to sleep. It won't sleep when I close the lid, or when I choose sleep out of the Apple menu. I've tried quitting all applications,