How to implement String.split() on 1.3?
Hi,
I have a String split method which is able to be run on 1.4.
The string "boo:and:foo", for example, yields the following results with these parameters:
Regex Limit Result
: 2 { "boo", "and:foo" }
: 5 { "boo", "and", "foo" }
: -2 { "boo", "and", "foo" }
o 5 { "b", "", ":and:f", "", "" }
o -2 { "b", "", ":and:f", "", "" }
o 0 { "b", "", ":and:f" }
The program cannot be complied if I run it on 1.3. How can I do the 1.4 split function on 1.3?
Thanks for advice
If you don't require the more powerful regular expression matching, you can implement the split() functionality with existing String methods.
If you are splitting around a character, you can use StringTokenizer, unless you care about empty tokens. If you need empty tokens returned, then you can use the following method:
public static String[] split(String input, char c) {
int tokenCount = 0;
int cIndex = -1;
do {
cIndex = input.indexOf(c, cIndex + 1);
tokenCount++;
} while (cIndex >= 0);
String[] tokens = new String[tokenCount];
int tokenIndex = 0;
do {
int index = input.indexOf(c, cIndex + 1);
if (index < 0) {
tokens[tokenIndex] = input.substring(cIndex + 1);
else {
tokens[tokenIndex] = input.substring(cIndex + 1, index);
cIndex = index;
tokenIndex++;
} while (cIndex >= 0);
return tokens;
}If you need to split around a multiple character string, use the following method.
public static String[] split(String input, String str) {
int strLength = str.length();
int tokenCount = 0;
int strIndex = -strLength;
do {
strIndex = input.indexOf(str, strIndex + strLength);
tokenCount++;
} while (strIndex >= 0);
String[] tokens = new String[tokenCount];
int tokenIndex = 0;
strIndex = -strLength;
do {
int index = input.indexOf(str, strIndex + strLength);
if (index < 0) {
tokens[tokenIndex] = input.substring(strIndex + strLength);
else {
tokens[tokenIndex] = input.substring(strIndex + strLength, index);
strIndex = index;
tokenIndex++;
} while (strIndex >= 0);
return tokens;
}These have only been lightly tested, no guarantees.
Similar Messages
-
How to implement 'no split' on end of page in smartforms
Hi frnz,
in my smartform, there is a main window on the page.
i have implemented a loop in the main window.
each row in a loop displays a box in the window.
the box has 7 rows. The height of the rows is not fixed & so the height of the box is not fixed...
so if the first row is fetched, 1st box is displayed....
now 2nd row is fetched & 2nd box is also displayed if there is still space in the the main window on page 1...
what happens sometime is that only half box is printed on page 1 & half box is printed on page 2 due
to lack of space on page on in main window..
i dont wnat this to happen.. the box should be printed only on one page.... can any1 help...
thanks in advance....sims wrote:
Hi Anil,
Its a standard page & i want it on click of apply button but my question is when i click apply button it navigates to other page..is it possible in such scenario to extend the controller.
Thnx for ur suggestion
SimsThat is not an issue, you can extend the controller of that page and get the value of sequence and set it to the VO attribute.
Thanks
--Anil
http://oracleanil.blogspot.com -
How to implement 'no split' at end of page in smartforms
Hi frnz,
in my smartform, there is a main window on the page.
i have implemented a loop in the main window.
each row in a loop displays a box in the window.
the box has 7 rows. The height of the rows is not fixed & so the height of the box is not fixed...
so if the first row is fetched, 1st box is displayed....
now 2nd row is fetched & 2nd box is also displayed if there is still space in the the main window on page 1...
what happens sometime is that only half box is printed on page 1 & half box is printed on page 2 due
to lack of space on page on in main window..
i dont wnat this to happen.. the box should be printed only on one page.... can any1 help...
thanks in advance....thans frnz for ur prompt reply...
i have a main window which may extend upto 1 or more pages...
in the main wndow i have a loop & in that loop there are 7 rows...
i have not made use of table...
i have tried putting the folder at 2 places in the main window.
1. before the loop & included the loop along with its elements in the folder.
2. after the loop statement and only included the elements in the folder....
but the page protection check box is disabled in either case...
any idea guys... -
is it possible , with some code, to implement the split() method of the String class......which is added in JDK1.4 ..... in JDK1.3
would be helpful if anyone could suggest some code for this...Here it is
public static String[] split(String source, char separ){
answer=new Vector();
int position=-1, newPosition;
while ((newPosition=source.indexOf(separ,position+1))>=0){
answer.add(source.subString(position+1,newPosition));
position=newPosition;
} //while
answer.add(source.subString(position+1,source.length-1);
return (String[])(answer.toArray());
} //split -
How to use method String.split
I am spliting a string, just like "1a|24|3|4". My code is
String[] array = new String[10];
String buff = "1|2|3|4";
array = buff.split("|");
System.out.println(array[1]);
I think that the result should be "24", but the result always
is "1". Why? When I use String.split(",") to split a string "1a,24,3,4",
I can get the result "24". Can't "|" be used as a delimiter? Who can
explain this issue? Thanks.Hi
The argument of split is a "regular expression" instead any common string with delimiters as used in StringTokenizer.
The char "|" is named as "branching operator" or "alternation"..doesn't matter this moment.
If you must to use "|" in source strings, change the regular expression to "\\D", it means "any non numeric char":
// can use any delimiter not in range '0'..'9'
array = buff.split("\\D");
Regards. -
How to avoid string copy when spliting the string?
Hi all,
I have some old APIs (which I do not have control over) that expects the caller to pass the "content" of a text file as either String or String[] (each element is a line in the text file). Since the text file can be huge, I want to save memory and try to only hold 1 copy of the file content in memory. So, the question boils down to how can I make a String variable and a String[] variable share one single piece of memory.
After digging into the source code, I notice the String.substring(...) always makes allocate a new memory space for the returning string if the result substring is smaller than 1/4 of the actual String. The String.split() method internally also invokes the String.substring(...) method.
This creates a problem for me. If I first load the content of a file into a String "a". Then I call "String[] array = a.split("\n")", as the result, each element in the resulting array will be a copy of the substring of the original String "a" (since each line in my text file will be smaller than 1/4 of the entire file). StringTokenizer seems to have the same problem. Is there anything else I could do?
I really would like to extends the String class and override the substring method to make it always "share" the same memory content. But since String class is declared as final, I cannot do this. I think maybe the String.split() method implementation should make the return String[] from the split function share the same memory space as the original string. Any workaround anyone can suggest?
Thanks
-- GaryWhile you could try to create some sort of custom class, if you want something that is already in java, you need to use one of the instantiations of CharSequence
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/CharSequence.html
Personally, I would recommend CharBuffer. From the look of it, it seems most like what you want.
Hi all,
I have some old APIs (which I do not have control
rol over) that expects the caller to pass the
"content" of a text file as either String or String[]
(each element is a line in the text file). Since the
text file can be huge, I want to save memory and try
to only hold 1 copy of the file content in memory.
So, the question boils down to how can I make a
a String variable and a String[] variable share one
single piece of memory.
After digging into the source code, I notice the
the String.substring(...) always makes allocate a new
memory space for the returning string if the result
substring is smaller than 1/4 of the actual String.
The String.split() method internally also invokes
s the String.substring(...) method.
This creates a problem for me. If I first load
oad the content of a file into a String "a". Then I
call "String[] array = a.split("\n")", as the result,
each element in the resulting array will be a copy of
the substring of the original String "a" (since each
line in my text file will be smaller than 1/4 of the
entire file). StringTokenizer seems to have the same
problem. Is there anything else I could do?
I really would like to extends the String class and
nd override the substring method to make it always
"share" the same memory content. But since String
class is declared as final, I cannot do this. I
think maybe the String.split() method implementation
should make the return String[] from the split
function share the same memory space as the original
string. Any workaround anyone can suggest?
Thanks
-- Gary -
How to use two split this method in my code
How to use two split this method in my code
if i got one string line which like this
("aa!bb!cc~ab!bc!cd") a
nd want to use two split to spare ! and ~ this seal for my spare point how that output
has come diff ?
public static void main(String[] args) {
String str = "aa!bb!cc~ab!bc!cd";
String strs[]= str.split("~");
String strE[]= str.split("!");
int count =0;
for(int j=0; j < strs.length; j++){
for (int i = 0; i < strE.length; i++){
System.out.println(count + " " + strE);
count++;
the output how can it be like this
0 aa
0 bb
0 cc
1 ab
1 bc
1 cdMove your second slit inside the first loop, so you are splitting the substring, not the entire string.
-
Can't Figure Out How To Implement IEnumerable T
I have no problem implementing IEnumerable but can't figure out how to implement IEnumerable<T>. Using the non-generic ArrayList, I have this code:
class PeopleCollection : IEnumerable
ArrayList people = new ArrayList();
public PeopleCollection() { }
public IEnumerator GetEnumerator()
return people.GetEnumerator();
class Program
static void Main(string[] args)
PeopleCollection collection = new PeopleCollection();
foreach (Person p in collection)
Console.WriteLine(p);
I'm trying to do the same thing (using a List<Person> as the member variable instead of ArrayList) but get compile errors involving improper return types on my GetEnumerator() method. I start out with this:
class PeopleCollection : IEnumerable<Person>
List<Person> myPeople = new List<Person>();
public PeopleCollection() { }
public IEnumerator<Person> GetEnumerator()
throw new NotImplementedException();
IEnumerator IEnumerable.GetEnumerator()
throw new NotImplementedException();
class Program
static void Main(string[] args)
// Create a PeopleCollection object.
PeopleCollection peopleCollection = new PeopleCollection();
// Iterate over the collection.
foreach (Person p in peopleCollection)
Console.WriteLine(p);
Console.ReadLine();
That code compiles (basically because I haven't really done anything yet), but I get compile errors when I try to implement the GetEnumerator() methods.The List<T> class implements the IEnumerable<T> interface, so your enumerator can return the GetEnumerator call from the list.
class PeopleCollection : IEnumerable<Person>
List<Person> myPeople = new List<Person>();
public PeopleCollection() { }
public IEnumerator<Person> GetEnumerator()
return myPeople.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
return myPeople.GetEnumerator();
class Program
static void Main(string[] args)
// Create a PeopleCollection object.
PeopleCollection peopleCollection = new PeopleCollection();
// Iterate over the collection.
foreach (Person p in peopleCollection)
Console.WriteLine(p);
Console.ReadLine(); -
How to implement setLineWrap equivalent method in a JTextPane
I using a JTextPane in a chat Window, but if in this are writing a very large line this don't break lines as in the case of the setLineWrap(true) method for a JTextArea.
How to implement break lines in a JTextPane equivalent to the setLineWrap(true) method for a JTextArea????import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test3 extends JFrame {
public Test3() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
JTextPane jtp = new JTextPane();
StringBuffer sb = new StringBuffer();
for (int i=0; i<100; i++) sb.append("this is some text. ");
jtp.setText(sb.toString());
content.add(new JScrollPane(jtp), BorderLayout.CENTER);
setSize(400, 400);
setVisible(true);
public static void main(String[] args) { new Test3(); }
} -
How to implement a Session Object.
Hi,
If anybody show me any example of how to implement
session object so that I can store any parameters such as user id and use it later on. And also if there is any good web site for reference about using session object.
thanksYou can use the the session.setAttribute and session.getAttribute methods.
For example let's say you would want to store a username in the session after a user has logged on:
String usrname = request.getParameter("username");
session.setAttribute("myStoredUsername", usrname);
you can then retrieve it using the get method. Remember that the entities stored inside a session object are generic objects and need to be cast to be used:
String usrname2 = (String)session.getAttribute("username");
Hope this helps
Chelman -
How to implement this? please help
In my java class, I have a string array called strarray which hold serveral elements, some of the elements have the same value , for example, the first element is "swimming", the forth element is also swimming. I use a for loop to get each element and give it to arrayHolder which is also a array with the same size as strarray. Now, what I want is: I defined a Vector called element I want this vector to filter out the element from arrayHolder, get the name of non-duplicated name from the arrayHolder, the result should be inside the element vector (swimming,walking,running,dancing), no duplicated name. My code is like follows:
import java.util.*;
import java.io.*;
public class arrayTest{
public static void main(String arg[]){
String[] strarray={"swimming","running","walking","swimming","dancing","running"};
String[] arrayHolder=new String[strarray.size];
Vector element=new Vector();
for(int i=0;i<strarray.length();i++){
arrayHolder[ i ]=strarray[ i ];
/* What should I do next to get the non-duplicated element from arrayHolder and
* add them into the element vector????
I did not finnish it, since I am a little bit confused, how to implement? Need some help. thanks.
Message was edited by:
MellonNot sure if I see the use of strArray & arrayHolder (I've not looked at your code - you might use code tags next time (check the "code" button above the message textarea), but may I suggest using a Map of some sort instead of a Vector? It will prevent duplicates for you.
Good Luck
lee -
How to Implement HTTP Request Status Code Processing
I actually have two questions. First, I wondering how to add multiple status code processing to an http request. Secondly, I was wondering how to go about using alternate http requests to different servers in case the primary server is down. What kind of parameter would the program use to determine that the server is unavailable and switch to another server??
Currently, the program I've written calls an rdf server (http://www.rdfabout.com/sparql) using a sparql query,
the server returns an xml string, the program parses it, and calculates numbers
from the string. The program works, but the problem is that the server is down occasionally.
When the server is down, we need to add calls to another server to
increase reliability. So, the next task is to call this server:
http://www.melissadata.com/lookups/ZipDemo2000.asp
I need to do exactly the same things I did with the rdf server. The
difference will be constructing a request and a bit different parsing of
the response.
current SPARQL query is defined as follows:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX census: <http://www.rdfabout.com/rdf/schema/census/>
PREFIX census1: <tag:govshare.info,2005:rdf/census/details/100pct/>
DESCRIBE ?table WHERE {
<http://www.rdfabout.com/rdf/usgov/geo/census/zcta/90292> census:details
?details .
?details census1:totalPopulation ?table .
?table dc:title "SEX BY AGE (P012001)" .
}current HTTP Request is defined as follows:
import java.net.*;
import java.net.URL;
import java.net.URLConnection;
import java.io.*;
import java.io.DataOutputStream;
import java.io.BufferedReader;
import java.io.StringReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Arrays;
public class MyConnection
static Scanner sc = new Scanner(System.in);//allows user to input zipcode
public static void main(String[] args) throws Exception
int zip;//zipcode is declared as integer format
//User defines zip through input
//proceed to put SPARQL query into string, which is then used to call the server
String requestPart1 =
"query=PREFIX+dc%3A++%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E+%0D%0APREFIX+census%3A+%3Chttp%3A%2F%2Fwww.rdfabout.com%2Frdf%2Fschema%2Fcensus%2F%3E+%0D%0APREFIX+census1%3A+%3Ctag%3Agovshare.info%2C2005%3Ardf%2Fcensus%2Fdetails%2F100pct%2F%3E+%0D%0A%0D%0ADESCRIBE+%3Ftable+WHERE+%7B+%0D%0A+%3Chttp%3A%2F%2Fwww.rdfabout.com%2Frdf%2Fusgov%2Fgeo%2Fcensus%2Fzcta%2F";
String requestPart2 = "" + zip; // zipcode is transformed from int to string format and plugged into SPARQL query here
String requestPart3 =
"%3E+census%3Adetails+%3Fdetails+.+%0D%0A+%3Fdetails+census1%3AtotalPopulation+%3Ftable+.+%0D%0A+%3Ftable+dc%3Atitle+%22SEX+BY+AGE+%28P012001%29%22+.+%0D%0A%7D%0D%0A&outputMimeType=text%2Fxml";
String response = "";
URL url = new URL("http://www.rdfabout.com/sparql");//designates server to connect to
URLConnection conn = url.openConnection();//opens connection to server
// Set connection parameters.
conn.setDoInput (true);
conn.setDoOutput (true);
conn.setUseCaches (false);
// Make server believe we are form data
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream (conn.getOutputStream ());
// Write out the bytes of the content string to the stream.
out.writeBytes(requestPart1 + requestPart2 + requestPart3);
out.flush ();
out.close ();
// Read response from the input stream.
BufferedReader in = new BufferedReader (new InputStreamReader(conn.getInputStream ()));
String temp;
while ((temp = in.readLine()) != null)
response += temp + "\n";
temp = null;
in.close ();
//parsing stuff is taken care of after here
}What remains now is to:
1) add status code processing: notify if the server is not available, ect.
2) add ability to connect to additional server if primary server is down.
I'm thinking an if/else statement, which I've tried a few different ways,
but I don't quite know how to implement that...Also trying to add the
status code processing/error handling, but I'm not sure how to do that
for multiple/different errors, such as 404, 503, 504, ect.. try/catch statements?
So yeah, just been scratching my head on this trying to figure out how to work it..
If you can help me out on this, I've been going nuts trying to figure this out...I think your issue comes form the fact that you are not casting URLConnection to HttpURLConnection.
Doing the cast would allow you to use getResponseCode() - among other methods - and test for a response different than 200.
Read: [http://mindprod.com/jgloss/urlconnection.html|http://mindprod.com/jgloss/urlconnection.html] -
How to implement Breadcrumb functionality in weblogic portal 10.3
Hi,
We need to implement the breadcrumb functionality in weblogic portal 10.3.
Tried to look for it in Google. But couldn't get success.
Can someone help on how to implement this.
Thanks
UttamPlease find the example code for Breadcrumbs
<%
ArrayList breadcrumbTitles = new ArrayList();
ArrayList breadcrumbURLs = new ArrayList();
BookPresentationContext book = BookPresentationContext.getBookPresentationContext(request);
PagePresentationContext pageCtx = PagePresentationContext.getPagePresentationContext(request);
if(pageCtx.getDefinitionLabel() != null )
breadcrumbTitles.add(pageCtx.getTitle());
breadcrumbURLs.add(PageURL.createPageURL(request, response, pageCtx.getDefinitionLabel()).toString());
if (!(book.getDefaultPage().equals(pageCtx.getDefinitionLabel())))
breadcrumbTitles.add(book.getTitle());
breadcrumbURLs.add(PageURL.createPageURL(request, response, book.getDefaultPage()).toString());
else
breadcrumbTitles.add(book.getTitle());
breadcrumbURLs.add(PageURL.createPageURL(request, response, pageCtx.getDefinitionLabel()).toString());
PagePresentationContext parentPage = book.getParentPagePresentationContext();
while (parentPage != null)
breadcrumbTitles.add(parentPage.getTitle());
if (parentPage instanceof BookPresentationContext)
BookPresentationContext parentBook = (BookPresentationContext)parentPage;
// condition for not showing my eagle page when user not logged in. instead show default home page
if (parentBook.getDefaultPage().equalsIgnoreCase(""))
breadcrumbURLs.add(PageURL.createPageURL(request, response, ""));
}else
breadcrumbURLs.add(PageURL.createPageURL(request, response, parentBook.getDefaultPage()).toString());
else
breadcrumbURLs.add(PageURL.createPageURL(request, response, parentPage.getDefinitionLabel()).toString());
parentPage = parentPage.getParentPagePresentationContext();
%>
<ul class="breadcrumbs">
<%
// compare if current page is selected. then dont show hyper link
if (pageCtx.getTitle().toString().equalsIgnoreCase((String)breadcrumbTitles.get(i)))
%>
<%=breadcrumbTitles.get(i)%>
<%
}else
%>
<a href="<%=breadcrumbURLs.get(i)%> "><font color="#005596"><%=breadcrumbTitles.get(i)%></font></a></b><img src="<render:getSkinPath imageName="/spacer.gif" />" width="2" /><img align="bottom" src="<render:getSkinPath imageName="/arrow_right.gif" />" />
<%
%>
</ul> -
How to implement classes with alv's
hi
how to implement classes with alv'sHi Jyotsna,
check this example codes.
*"Table declarations...................................................
TABLES:
EKKO, " Purchasing Document Header
CDHDR, " Change document header
SSCRFIELDS. " Fields on selection screens
*"Selection screen elements............................................
SELECT-OPTIONS:
S_EBELN FOR EKKO-EBELN, " Purchasing Document Number
S_LIFNR FOR EKKO-LIFNR, " Vendor's account number
S_EKGRP FOR EKKO-EKGRP, " Purchasing group
S_BEDAT FOR EKKO-BEDAT, " Purchasing Document Date
S_UDATE FOR CDHDR-UDATE. " Creation date of the change
" document
*" Data declarations...................................................
Field String to hold Purchase Document Number *
DATA:
BEGIN OF FS_EBELN,
EBELN(90) TYPE C, " Purchase Document Number
ERNAM TYPE EKKO-ERNAM, " Name of Person who Created
" the Object
LIFNR TYPE EKKO-LIFNR, " Vendor's account number
EKGRP TYPE EKKO-EKGRP, " Purchasing group
BEDAT TYPE EKKO-BEDAT, " Purchasing Document Date
END OF FS_EBELN,
Field String to hold Purchase Document Header *
BEGIN OF FS_EKKO,
EBELN TYPE EKKO-EBELN, " Purchasing Document Number
ERNAM TYPE EKKO-ERNAM, " Name of Person who Created the
" Object
LIFNR TYPE EKKO-LIFNR, " Vendor's account number
EKGRP TYPE EKKO-EKGRP, " Purchasing group
BEDAT TYPE EKKO-BEDAT, " Purchasing Document Date
END OF FS_EKKO,
Field String to hold Account Number and name of the Vendor *
BEGIN OF FS_LFA1,
LIFNR TYPE LFA1-LIFNR, " Account Number of Vendor
NAME1 TYPE LFA1-NAME1, " Name1
END OF FS_LFA1,
Field String to hold Change date and the name of the user *
BEGIN OF FS_CDHDR,
OBJECTCLAS TYPE CDHDR-OBJECTCLAS, " Object Class
OBJECTID TYPE CDHDR-OBJECTID, " Object value
CHANGENR TYPE CDHDR-CHANGENR, " Document change number
USERNAME TYPE CDHDR-USERNAME, " User name
UDATE TYPE CDHDR-UDATE, " Creation date of the change
" document
END OF FS_CDHDR,
Field String to hold Change document items *
BEGIN OF FS_CDPOS,
OBJECTCLAS TYPE CDPOS-OBJECTCLAS," Object class
OBJECTID(10) TYPE C, " Object Value
CHANGENR TYPE CDPOS-CHANGENR, " Document change number
TABNAME TYPE CDPOS-TABNAME, " Table Name
FNAME TYPE CDPOS-FNAME, " Field Name
VALUE_NEW TYPE CDPOS-VALUE_NEW, " New contents of changed field
VALUE_OLD TYPE CDPOS-VALUE_OLD, " Old contents of changed field
END OF FS_CDPOS,
Field String to hold Date Element Name *
BEGIN OF FS_DATAELE,
TABNAME TYPE DD03L-TABNAME, " Table Name
FIELDNAME TYPE DD03L-FIELDNAME, " Field Name
ROLLNAME TYPE DD03L-ROLLNAME, " Data element (semantic domain)
END OF FS_DATAELE,
Field String to hold Short Text of the Date Element *
BEGIN OF FS_TEXT,
ROLLNAME TYPE DD04T-ROLLNAME, " Data element (semantic domain)
DDTEXT TYPE DD04T-DDTEXT, " Short Text Describing R/3
" Repository Objects
END OF FS_TEXT,
Field String to hold data to be displayed on the ALV grid *
BEGIN OF FS_OUTTAB,
EBELN TYPE EKKO-EBELN, " Purchasing Document Number
ERNAM TYPE EKKO-ERNAM, " Name of Person who Created the
" Object
LIFNR TYPE EKKO-LIFNR, " Vendor's account number
EKGRP TYPE EKKO-EKGRP, " Purchasing group
BEDAT TYPE EKKO-BEDAT, " Purchasing Document Date
WERKS TYPE LFA1-WERKS, " Plant
NAME1 TYPE LFA1-NAME1, " Name1
USERNAME TYPE CDHDR-USERNAME, " User name
UDATE TYPE CDHDR-UDATE, " Creation date of the change
" document
DDTEXT TYPE DD04T-DDTEXT, " Short Text Describing R/3
" Repository Objects
VALUE_NEW TYPE CDPOS-VALUE_NEW, " New contents of changed field
VALUE_OLD TYPE CDPOS-VALUE_OLD, " Old contents of changed field
END OF FS_OUTTAB,
Internal table to hold Purchase Document Number *
T_EBELN LIKE STANDARD TABLE
OF FS_EBELN,
Internal table to hold Purchase Document Header *
T_EKKO LIKE STANDARD TABLE
OF FS_EKKO,
Temp Internal table to hold Purchase Document Header *
T_EKKO_TEMP LIKE STANDARD TABLE
OF FS_EKKO,
Internal table to hold Account number and Name of the Vendor *
T_LFA1 LIKE STANDARD TABLE
OF FS_LFA1,
Internal Table to hold Change date and the name of the user *
T_CDHDR LIKE STANDARD TABLE
OF FS_CDHDR,
Internal Table to hold Change document items *
T_CDPOS LIKE STANDARD TABLE
OF FS_CDPOS,
Temp. Internal Table to hold Change document items *
T_CDPOS_TEMP LIKE STANDARD TABLE
OF FS_CDPOS,
Internal Table to hold Data Element Name *
T_DATAELE LIKE STANDARD TABLE
OF FS_DATAELE,
Temp. Internal Table to hold Data Element Name *
T_DATAELE_TEMP LIKE STANDARD TABLE
OF FS_DATAELE,
Internal Table to hold Short Text of the Date Element *
T_TEXT LIKE STANDARD TABLE
OF FS_TEXT,
Internal Table to hold data to be displayed on the ALV grid *
T_OUTTAB LIKE STANDARD TABLE
OF FS_OUTTAB.
C L A S S D E F I N I T I O N *
CLASS LCL_EVENT_HANDLER DEFINITION DEFERRED.
*" Data declarations...................................................
Work variables *
DATA:
W_EBELN TYPE EKKO-EBELN, " Purchasing Document Number
W_LIFNR TYPE EKKO-LIFNR, " Vendor's account number
W_EKGRP TYPE EKKO-EKGRP, " Purchasing group
W_VALUE TYPE EKKO-EBELN, " Reflected Value
W_SPACE VALUE ' ', " Space
W_FLAG TYPE I, " Flag Variable
W_VARIANT TYPE DISVARIANT, " Variant
ALV Grid
W_GRID TYPE REF TO CL_GUI_ALV_GRID,
Event Handler
W_EVENT_CLICK TYPE REF TO LCL_EVENT_HANDLER,
Field catalog table
T_FIELDCAT TYPE LVC_T_FCAT.
AT SELECTION-SCREEN EVENT *
AT SELECTION-SCREEN ON S_EBELN.
Subroutine to validate Purchase Document Number.
PERFORM VALIDATE_PD_NUM.
AT SELECTION-SCREEN ON S_LIFNR.
Subroutine to validate Vendor Number.
PERFORM VALIDATE_VEN_NUM.
AT SELECTION-SCREEN ON S_EKGRP.
Subroutine to validate Purchase Group.
PERFORM VALIDATE_PUR_GRP.
START-OF-SELECTION EVENT *
START-OF-SELECTION.
Subroutine to select all Purchase orders.
PERFORM SELECT_PO.
CHECK W_FLAG EQ 0.
Subroutine to select Object values.
PERFORM SELECT_OBJ_ID.
CHECK W_FLAG EQ 0.
Subroutine to select Changed values.
PERFORM SELECT_CHANGED_VALUE.
CHECK W_FLAG EQ 0.
Subroutine to Select Purchase Orders.
PERFORM SELECT_PUR_DOC.
Subroutine to select Vendor Details.
PERFORM SELECT_VENDOR.
Subroutine to select Text for the Changed values.
PERFORM DESCRIPTION.
END-OF-SELECTION EVENT *
END-OF-SELECTION.
IF NOT T_EKKO IS INITIAL.
Subroutine to populate the Output Table.
PERFORM FILL_OUTTAB.
Subroutine to build Field Catalog.
PERFORM PREPARE_FIELD_CATALOG CHANGING T_FIELDCAT.
CALL SCREEN 100.
ENDIF. " IF NOT T_EKKO...
CLASS LCL_EVENT_HANDLER DEFINITION
Defining Class which handles events
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
HANDLE_HOTSPOT_CLICK
FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID.
ENDCLASS. " LCL_EVENT_HANDLER DEFINITION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION
Implementing the Class which can handle events
CLASS LCL_EVENT_HANDLER IMPLEMENTATION .
*---Handle Double Click
METHOD HANDLE_HOTSPOT_CLICK .
Subroutine to get the HotSpot Cell information.
PERFORM GET_CELL_INFO.
SET PARAMETER ID 'BES' FIELD W_VALUE.
CALL TRANSACTION 'ME23N'.
ENDMETHOD. " HANDLE_HOTSPOT_CLICK
ENDCLASS. " LCL_EVENT_HANDLER
*& Module STATUS_0100 OUTPUT
PBO Event
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'OOPS'.
SET TITLEBAR 'TIT'.
Subroutine to fill the Variant Structure
PERFORM FILL_VARIANT.
IF W_GRID IS INITIAL.
CREATE OBJECT W_GRID
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = CL_GUI_CONTAINER=>SCREEN0
I_APPL_EVENTS =
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 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. " IF SY-SUBRC 0
CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT = W_VARIANT
I_SAVE = 'A'
I_DEFAULT = 'X'
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = T_OUTTAB
IT_FIELDCATALOG = T_FIELDCAT
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4
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 SY-SUBRC 0.
ENDIF. " IF W_GRID IS INITIAL
CREATE OBJECT W_EVENT_CLICK.
SET HANDLER W_EVENT_CLICK->HANDLE_HOTSPOT_CLICK FOR W_GRID.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
PAI Event
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form PREPARE_FIELD_CATALOG
Subroutine to build the Field catalog
<--P_T_FIELDCAT Field Catalog Table
FORM PREPARE_FIELD_CATALOG CHANGING PT_FIELDCAT TYPE LVC_T_FCAT .
DATA LS_FCAT TYPE LVC_S_FCAT.
Purchasing group...
LS_FCAT-FIELDNAME = 'EKGRP'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Purchasing Document Number...
LS_FCAT-FIELDNAME = 'EBELN'.
LS_FCAT-REF_TABLE = 'EKKO' .
LS_FCAT-EMPHASIZE = 'C411'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-HOTSPOT = 'X'.
APPEND LS_FCAT TO PT_FIELDCAT .
CLEAR LS_FCAT .
Name of Person who Created the Object...
LS_FCAT-FIELDNAME = 'ERNAM'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-OUTPUTLEN = '15' .
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Purchasing Document Date...
LS_FCAT-FIELDNAME = 'BEDAT'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Vendor's account number...
LS_FCAT-FIELDNAME = 'LIFNR'.
LS_FCAT-REF_TABLE = 'EKKO'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Account Number of Vendor or Creditor...
LS_FCAT-FIELDNAME = 'NAME1'.
LS_FCAT-REF_TABLE = 'LFA1'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-COLTEXT = 'Vendor Name'(001).
LS_FCAT-SELTEXT = 'Vendor Name'(001).
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Creation date of the change document...
LS_FCAT-FIELDNAME = 'UDATE'.
LS_FCAT-REF_TABLE = 'CDHDR'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-COLTEXT = 'Change Date'(002).
LS_FCAT-SELTEXT = 'Change Date'(002).
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
User name of the person responsible in change document...
LS_FCAT-FIELDNAME = 'USERNAME'.
LS_FCAT-REF_TABLE = 'CDHDR'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-COLTEXT = 'Modified by'(003).
LS_FCAT-SELTEXT = 'Modified by'(003).
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Short Text Describing R/3 Repository Objects...
LS_FCAT-FIELDNAME = 'DDTEXT'.
LS_FCAT-REF_TABLE = 'DD04T'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '15'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
Old contents of changed field...
LS_FCAT-FIELDNAME = 'VALUE_OLD'.
LS_FCAT-REF_TABLE = 'CDPOS'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '12'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
New contents of changed field...
LS_FCAT-FIELDNAME = 'VALUE_NEW'.
LS_FCAT-REF_TABLE = 'CDPOS'.
LS_FCAT-INTTYPE = 'C'.
LS_FCAT-OUTPUTLEN = '12'.
APPEND LS_FCAT TO PT_FIELDCAT.
CLEAR LS_FCAT.
ENDFORM. " PREPARE_FIELD_CATALOG
*& Form SELECT_PO
Subroutine to select all the Purchase Orders
There are no interface parameters to be passed to this subroutine.
FORM SELECT_PO .
SELECT EBELN " Purchasing Document Number
ERNAM " Name of Person who Created
" the Object
LIFNR " Vendor's account number
EKGRP " Purchasing group
BEDAT " Purchasing Document Date
FROM EKKO
PACKAGE SIZE 10000
APPENDING TABLE T_EBELN
WHERE EBELN IN S_EBELN
AND BEDAT IN S_BEDAT.
ENDSELECT.
IF SY-SUBRC NE 0.
W_FLAG = 1.
MESSAGE S401(M8).
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " SELECT_PO
*& Form SELECT_OBJ_ID
Subroutine to select Object ID
There are no interface parameters to be passed to this subroutine.
FORM SELECT_OBJ_ID .
IF NOT T_EBELN IS INITIAL.
SELECT OBJECTCLAS " Object Class
OBJECTID " Object value
CHANGENR " Document change number
USERNAME " User name
UDATE " Creation date
FROM CDHDR
INTO TABLE T_CDHDR
FOR ALL ENTRIES IN T_EBELN
WHERE OBJECTID EQ T_EBELN-EBELN
AND UDATE IN S_UDATE
AND TCODE IN ('ME21N','ME22N','ME23N').
ENDSELECT.
IF SY-SUBRC NE 0.
W_FLAG = 1.
MESSAGE S833(M8) WITH 'Header Not Found'(031).
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_EBELN IS INITIAL
ENDFORM. " SELECT_OBJ_ID
*& Form SELECT_CHANGED_VALUE
Subroutine to select Changed Values
There are no interface parameters to be passed to this subroutine.
FORM SELECT_CHANGED_VALUE .
IF NOT T_CDHDR IS INITIAL.
SELECT OBJECTCLAS " Object class
OBJECTID " Object value
CHANGENR " Document change number
TABNAME " Table Name
FNAME " Field Name
VALUE_NEW " New contents of changed field
VALUE_OLD " Old contents of changed field
FROM CDPOS
PACKAGE SIZE 10000
APPENDING TABLE T_CDPOS
FOR ALL ENTRIES IN T_CDHDR
WHERE OBJECTCLAS EQ T_CDHDR-OBJECTCLAS
AND OBJECTID EQ T_CDHDR-OBJECTID
AND CHANGENR EQ T_CDHDR-CHANGENR.
ENDSELECT.
IF SY-SUBRC NE 0.
W_FLAG = 1.
MESSAGE S833(M8) WITH 'Item Not Found'(032).
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_CDHDR IS INITIAL
T_CDPOS_TEMP] = T_CDPOS[.
ENDFORM. " SELECT_CHANGED_VALUE
*& Form SELECT_PUR_DOC
Subroutine to select Purchase Order Details
There are no interface parameters to be passed to this subroutine.
FORM SELECT_PUR_DOC .
IF NOT T_CDPOS IS INITIAL.
SORT T_EBELN BY EBELN.
LOOP AT T_CDPOS INTO FS_CDPOS.
READ TABLE T_EBELN INTO FS_EBELN WITH KEY EBELN =
FS_CDPOS-OBJECTID BINARY SEARCH.
IF SY-SUBRC NE 0.
DELETE TABLE T_EBELN FROM FS_EBELN.
ENDIF. " IF SY-SUBRC NE 0.
ENDLOOP. " LOOP AT T_CDPOS...
LOOP AT T_EBELN INTO FS_EBELN.
MOVE FS_EBELN-EBELN TO FS_EKKO-EBELN.
MOVE FS_EBELN-ERNAM TO FS_EKKO-ERNAM.
MOVE FS_EBELN-LIFNR TO FS_EKKO-LIFNR.
MOVE FS_EBELN-EKGRP TO FS_EKKO-EKGRP.
MOVE FS_EBELN-BEDAT TO FS_EKKO-BEDAT.
APPEND FS_EKKO TO T_EKKO.
ENDLOOP. " LOOP AT T_EBELN...
T_EKKO_TEMP] = T_EKKO[.
ENDIF. " IF NOT T_CDPOS IS INITIAL
ENDFORM. " SELECT_PUR_DOC
*& Form SELECT_VENDOR
Subroutine to select Vendor details
There are no interface parameters to be passed to this subroutine.
FORM SELECT_VENDOR .
IF NOT T_EKKO IS INITIAL.
SORT T_EKKO_TEMP BY LIFNR.
DELETE ADJACENT DUPLICATES FROM T_EKKO_TEMP COMPARING LIFNR.
SELECT LIFNR " Account Number of Vendor or
" Creditor
NAME1 " Name 1
FROM LFA1
INTO TABLE T_LFA1
FOR ALL ENTRIES IN T_EKKO_TEMP
WHERE LIFNR EQ T_EKKO_TEMP-LIFNR.
IF SY-SUBRC NE 0.
MESSAGE S002(M8) WITH 'Master Details'(033).
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_EKKO IS INITIAL
ENDFORM. " SELECT_VENDOR
*& Form DESCRIPTION
Subroutine to get the description
There are no interface parameters to be passed to this subroutine.
FORM DESCRIPTION .
IF NOT T_CDPOS IS INITIAL.
SORT T_CDPOS_TEMP BY TABNAME FNAME.
DELETE ADJACENT DUPLICATES FROM T_CDPOS_TEMP COMPARING TABNAME FNAME
SELECT TABNAME " Table Name
FIELDNAME " Field Name
ROLLNAME " Data element
FROM DD03L
INTO TABLE T_DATAELE
FOR ALL ENTRIES IN T_CDPOS_TEMP
WHERE TABNAME EQ T_CDPOS_TEMP-TABNAME
AND FIELDNAME EQ T_CDPOS_TEMP-FNAME.
IF NOT T_DATAELE IS INITIAL.
T_DATAELE_TEMP] = T_DATAELE[.
SORT T_DATAELE_TEMP BY ROLLNAME.
DELETE ADJACENT DUPLICATES FROM T_DATAELE_TEMP COMPARING ROLLNAME.
SELECT ROLLNAME " Data element
DDTEXT " Short Text Describing R/3
" Repository Objects
FROM DD04T
INTO TABLE T_TEXT
FOR ALL ENTRIES IN T_DATAELE_TEMP
WHERE ROLLNAME EQ T_DATAELE_TEMP-ROLLNAME
AND DDLANGUAGE EQ SY-LANGU.
IF SY-SUBRC NE 0.
EXIT.
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF NOT T_DATAELE IS INITIAL.
ENDIF. " IF NOT T_CDPOS IS INITIAL.
ENDFORM. " DESCRIPTION
*& Form FILL_OUTTAB
Subroutine to populate the Outtab
There are no interface parameters to be passed to this subroutine.
FORM FILL_OUTTAB .
SORT T_CDHDR BY OBJECTCLAS OBJECTID CHANGENR.
SORT T_EKKO BY EBELN.
SORT T_LFA1 BY LIFNR.
SORT T_DATAELE BY TABNAME FIELDNAME.
SORT T_TEXT BY ROLLNAME.
LOOP AT T_CDPOS INTO FS_CDPOS.
READ TABLE T_CDHDR INTO FS_CDHDR WITH KEY
OBJECTCLAS = FS_CDPOS-OBJECTCLAS
OBJECTID = FS_CDPOS-OBJECTID
CHANGENR = FS_CDPOS-CHANGENR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_CDHDR-USERNAME TO FS_OUTTAB-USERNAME.
MOVE FS_CDHDR-UDATE TO FS_OUTTAB-UDATE.
READ TABLE T_EKKO INTO FS_EKKO WITH KEY
EBELN = FS_CDHDR-OBJECTID
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_EKKO-EBELN TO FS_OUTTAB-EBELN.
MOVE FS_EKKO-ERNAM TO FS_OUTTAB-ERNAM.
MOVE FS_EKKO-LIFNR TO FS_OUTTAB-LIFNR.
MOVE FS_EKKO-EKGRP TO FS_OUTTAB-EKGRP.
MOVE FS_EKKO-BEDAT TO FS_OUTTAB-BEDAT.
READ TABLE T_LFA1 INTO FS_LFA1 WITH KEY
LIFNR = FS_EKKO-LIFNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_LFA1-NAME1 TO FS_OUTTAB-NAME1.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0.
MOVE FS_CDPOS-VALUE_NEW TO FS_OUTTAB-VALUE_NEW.
MOVE FS_CDPOS-VALUE_OLD TO FS_OUTTAB-VALUE_OLD.
READ TABLE T_DATAELE INTO FS_DATAELE WITH KEY
TABNAME = FS_CDPOS-TABNAME
FIELDNAME = FS_CDPOS-FNAME
BINARY SEARCH.
IF SY-SUBRC EQ 0.
READ TABLE T_TEXT INTO FS_TEXT WITH KEY
ROLLNAME = FS_DATAELE-ROLLNAME
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE FS_TEXT-DDTEXT TO FS_OUTTAB-DDTEXT.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0.
APPEND FS_OUTTAB TO T_OUTTAB.
CLEAR FS_OUTTAB.
ENDLOOP.
ENDFORM. " FILL_OUTTAB
*& Form GET_CELL_INFO
Subroutine to get the Cell Information
--> W_VALUE Holds the value of Hotspot clicked
FORM GET_CELL_INFO .
CALL METHOD W_GRID->GET_CURRENT_CELL
IMPORTING
E_ROW =
E_VALUE = W_VALUE
E_COL =
ES_ROW_ID =
ES_COL_ID =
ES_ROW_NO =
ENDFORM. " GET_CELL_INFO
*& Form VALIDATE_PD_NUM
Subroutine to validate Purchase Document Number
There are no interface parameters to be passed to this subroutine.
FORM VALIDATE_PD_NUM .
IF NOT S_EBELN[] IS INITIAL.
SELECT EBELN " Purchase Document Number
FROM EKKO
INTO W_EBELN
UP TO 1 ROWS
WHERE EBELN IN S_EBELN.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR SSCRFIELDS-UCOMM.
MESSAGE E717(M8).
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF NOT S_EBELN[]...
ENDFORM. " VALIDATE_PD_NUM
*& Form VALIDATE_VEN_NUM
Subroutine to validate Vendor Number
There are no interface parameters to be passed to this subroutine.
FORM VALIDATE_VEN_NUM .
IF NOT S_LIFNR[] IS INITIAL.
SELECT LIFNR " Vendor Number
FROM LFA1
INTO W_LIFNR
UP TO 1 ROWS
WHERE LIFNR IN S_LIFNR.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR SSCRFIELDS-UCOMM.
MESSAGE E002(M8) WITH W_SPACE.
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF NOT S_LIFNR[]...
ENDFORM. " VALIDATE_VEN_NUM
*& Form VALIDATE_PUR_GRP
Subroutine to validate the Purchase Group
There are no interface parameters to be passed to this subroutine.
FORM VALIDATE_PUR_GRP .
IF NOT S_EKGRP[] IS INITIAL.
SELECT EKGRP " Purchase Group
FROM T024
INTO W_EKGRP
UP TO 1 ROWS
WHERE EKGRP IN S_EKGRP.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR SSCRFIELDS-UCOMM.
MESSAGE E622(M8) WITH W_SPACE.
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF NOT S_EKFRP[]...
ENDFORM. " VALIDATE_PUR_GRP
*& Form FILL_VARIANT
Subroutine to fill the Variant Structure
There are no interface parameters to be passed to this subroutine
FORM FILL_VARIANT .
Filling the Variant structure
W_VARIANT-REPORT = SY-REPID.
W_VARIANT-USERNAME = SY-UNAME.
ENDFORM. " FILL_VARIANT
REPORT YMS_HIERSEQLISTDISPLAY .
Program with FM REUSE_ALV_HIERSEQ_LIST_DISPLAY *
Author : Michel PIOUD *
Email : mpioudyahoo.fr HomePage : http://www.geocities.com/mpioud *
TYPE-POOLS: slis. " ALV Global types
CONSTANTS :
c_x VALUE 'X',
c_gt_vbap TYPE SLIS_TABNAME VALUE 'GT_VBAP',
c_gt_vbak TYPE SLIS_TABNAME VALUE 'GT_VBAK'.
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(02) TYPE n DEFAULT '10' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_2 FOR FIELD p_expand. "#EC NEEDED
PARAMETERS p_expand AS CHECKBOX DEFAULT c_x.
SELECTION-SCREEN END OF LINE.
TYPES :
1st Table
BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln, " Sales document
kunnr TYPE vbak-kunnr, " Sold-to party
netwr TYPE vbak-netwr, " Net Value of the Sales Order
erdat TYPE vbak-erdat, " Creation date
waerk TYPE vbak-waerk, " SD document currency
expand TYPE xfeld,
END OF ty_vbak,
2nd Table
BEGIN OF ty_vbap,
vbeln TYPE vbap-vbeln, " Sales document
posnr TYPE vbap-posnr, " Sales document
matnr TYPE vbap-matnr, " Material number
netwr TYPE vbap-netwr, " Net Value of the Sales Order
waerk TYPE vbap-waerk, " SD document currency
END OF ty_vbap.
DATA :
1st Table
gt_vbak TYPE TABLE OF ty_vbak,
2nd Table
gt_vbap TYPE TABLE OF ty_vbap.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
v_2 = 'With ''EXPAND'' field'.
START-OF-SELECTION.
Read Sales Document: Header Data
SELECT vbeln kunnr netwr waerk erdat
FROM vbak
UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE gt_vbak.
IF NOT gt_vbak[] IS INITIAL.
Read Sales Document: Item Data
SELECT vbeln posnr matnr netwr waerk
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE gt_vbap
FOR ALL ENTRIES IN gt_vbak
WHERE vbeln = gt_vbak-vbeln.
ENDIF.
PERFORM f_display.
Form F_DISPLAY
FORM f_display.
Macro definition
DEFINE m_fieldcat.
ls_fieldcat-tabname = &1.
ls_fieldcat-fieldname = &2.
ls_fieldcat-ref_tabname = &3.
ls_fieldcat-cfieldname = &4. " Field with currency unit
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
ls_sort-tabname = &1.
ls_sort-fieldname = &2.
ls_sort-up = c_x.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_layout TYPE slis_layout_alv,
ls_keyinfo TYPE slis_keyinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
lt_sort TYPE slis_t_sortinfo_alv," Sort table
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv." Field catalog
ls_layout-group_change_edit = c_x.
ls_layout-colwidth_optimize = c_x.
ls_layout-zebra = c_x.
ls_layout-detail_popup = c_x.
ls_layout-get_selinfos = c_x.
IF p_expand = c_x.
ls_layout-expand_fieldname = 'EXPAND'.
ENDIF.
Build field catalog and sort table
m_fieldcat c_gt_vbak 'VBELN' 'VBAK' ''.
m_fieldcat c_gt_vbak 'KUNNR' 'VBAK' ''.
m_fieldcat c_gt_vbak 'NETWR' 'VBAK' 'WAERK'.
m_fieldcat c_gt_vbak 'WAERK' 'VBAK' ''.
m_fieldcat c_gt_vbak 'ERDAT' 'VBAK' ''.
m_fieldcat c_gt_vbap 'POSNR' 'VBAP' ''.
m_fieldcat c_gt_vbap 'MATNR' 'VBAP' ''.
m_fieldcat c_gt_vbap 'NETWR' 'VBAP' 'WAERK'.
m_fieldcat c_gt_vbap 'WAERK' 'VBAP' ''.
m_sort c_gt_vbak 'KUNNR'.
m_sort c_gt_vbap 'NETWR'.
ls_keyinfo-header01 = 'VBELN'.
ls_keyinfo-item01 = 'VBELN'.
ls_keyinfo-item02 = 'POSNR'.
Dipslay Hierarchical list
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
i_tabname_header = c_gt_vbak
i_tabname_item = c_gt_vbap
is_keyinfo = ls_keyinfo
TABLES
t_outtab_header = gt_vbak
t_outtab_item = gt_vbap
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. " F_LIST_DISPLAY
Form USER_COMMAND *
FORM user_command USING i_ucomm TYPE sy-ucomm
is_selfield TYPE slis_selfield. "#EC CALLED
DATA ls_vbak TYPE ty_vbak.
CASE i_ucomm.
WHEN '&IC1'. " Pick
CASE is_selfield-tabname.
WHEN c_gt_vbap.
WHEN c_gt_vbak.
READ TABLE gt_vbak INDEX is_selfield-tabindex INTO ls_vbak.
IF sy-subrc EQ 0.
Sales order number
SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.
Display Sales Order
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM. " USER_COMMAND
Kindly Reward Points If You Found The Reply Helpful,
Cheers,
Chaitanya. -
How to implement Disaster Recovery in TimesTen?
hello, chris:
we have a requirement to implement disaster recovery from remote when the master and standby nodes are failover in local. how to implement it in timesten? Can master standby pairs with subscribers mode caryy out it? when the master and standby nodes are fail, can subscriber node take over the application?? thank you.The best, and recommended, solution for this is to have an active/standby pair located locally as the primary mechanism for high-availability and to configure a remote readonly subscriber datastore. In the event that the primary site completely fails, the remote subscriber can be easily (few seconds) promoted to an active to form the basis of a new active/standby pair at the remote site.
It is not supported to split an active/standby pair across a network connection that is anything less than LAN grade but a remote subscriber can be located across any reasonable network connection (WAN, VPN etc.) as long as there is sufficient bandwidth and the latency is not too high.
Chris
Maybe you are looking for
-
Hello. I am trying to install a patch in a 8.1.7 server, that also contains a 9i client, the universal installer fails with a "Error. Not need to install products from patch 8.1.7.2.5". When I see the installes software list, I can see the 9i client
-
LiveCycle Data Services without Flex UI
Is it possible to use LiveCycle Data Services as a backend without Flex/Flash as front end ( any other tech as front end Struts, JSP, JSF etc). Idea is to get advantage of features provided by Data Services with something other than Flash player as f
-
Nokia 5530 Xpress lcd replace went wrong - help! p...
I disassemblyed my phone. After replacement the touchscreen won't lit. Why? Leds and sound is working but when I when I placed the nearly fault original LCD, nothing happened. Screen went black. I need some quick help, please!
-
SO created is Open or Close Sales Order
<b>Hi I hav ot write a report for SD , In this for sales order I hav to check that - Is this Sales order is Open or Close order , Select-optoins are SALES ORDER , DATE , PLANT , St location . if it is a close sales order , Then this report should pas
-
[Schema Design]: How to reduce inventory snapshot table size
We are planning to store inventory level's periodic snapshot at the end of each day. We have close to 50k different products. But on a given day only 5-6k products inventory changes. As I understand if I start inserting just the products which have